Merge branch 'ethereum:master' into portal

This commit is contained in:
Chen Kai 2024-06-20 16:16:44 +08:00 committed by GitHub
commit a7cb535e53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 34 deletions

View file

@ -1598,8 +1598,8 @@ func (p *BlobPool) SubscribeTransactions(ch chan<- core.NewTxsEvent, reorgs bool
// Nonce returns the next nonce of an account, with all transactions executable // Nonce returns the next nonce of an account, with all transactions executable
// by the pool already applied on top. // by the pool already applied on top.
func (p *BlobPool) Nonce(addr common.Address) uint64 { func (p *BlobPool) Nonce(addr common.Address) uint64 {
p.lock.Lock() p.lock.RLock()
defer p.lock.Unlock() defer p.lock.RUnlock()
if txs, ok := p.index[addr]; ok { if txs, ok := p.index[addr]; ok {
return txs[len(txs)-1].nonce + 1 return txs[len(txs)-1].nonce + 1
@ -1610,8 +1610,8 @@ func (p *BlobPool) Nonce(addr common.Address) uint64 {
// Stats retrieves the current pool stats, namely the number of pending and the // Stats retrieves the current pool stats, namely the number of pending and the
// number of queued (non-executable) transactions. // number of queued (non-executable) transactions.
func (p *BlobPool) Stats() (int, int) { func (p *BlobPool) Stats() (int, int) {
p.lock.Lock() p.lock.RLock()
defer p.lock.Unlock() defer p.lock.RUnlock()
var pending int var pending int
for _, txs := range p.index { for _, txs := range p.index {

View file

@ -332,11 +332,7 @@ func ServiceGetAccountRangeQuery(chain *core.BlockChain, req *GetAccountRangePac
return nil, nil return nil, nil
} }
} }
var proofs [][]byte return accounts, proof.List()
for _, blob := range proof.List() {
proofs = append(proofs, blob)
}
return accounts, proofs
} }
func ServiceGetStorageRangesQuery(chain *core.BlockChain, req *GetStorageRangesPacket) ([][]*StorageData, [][]byte) { func ServiceGetStorageRangesQuery(chain *core.BlockChain, req *GetStorageRangesPacket) ([][]*StorageData, [][]byte) {
@ -438,9 +434,7 @@ func ServiceGetStorageRangesQuery(chain *core.BlockChain, req *GetStorageRangesP
return nil, nil return nil, nil
} }
} }
for _, blob := range proof.List() { proofs = append(proofs, proof.List()...)
proofs = append(proofs, blob)
}
// Proof terminates the reply as proofs are only added if a node // Proof terminates the reply as proofs are only added if a node
// refuses to serve more data (exception when a contract fetch is // refuses to serve more data (exception when a contract fetch is
// finishing, but that's that). // finishing, but that's that).

View file

@ -286,10 +286,7 @@ func createAccountRequestResponse(t *testPeer, root common.Hash, origin common.H
t.logger.Error("Could not prove last item", "error", err) t.logger.Error("Could not prove last item", "error", err)
} }
} }
for _, blob := range proof.List() { return keys, vals, proof.List()
proofs = append(proofs, blob)
}
return keys, vals, proofs
} }
// defaultStorageRequestHandler is a well-behaving storage request handler // defaultStorageRequestHandler is a well-behaving storage request handler
@ -371,9 +368,7 @@ func createStorageRequestResponse(t *testPeer, root common.Hash, accounts []comm
t.logger.Error("Could not prove last item", "error", err) t.logger.Error("Could not prove last item", "error", err)
} }
} }
for _, blob := range proof.List() { proofs = append(proofs, proof.List()...)
proofs = append(proofs, blob)
}
break break
} }
} }
@ -430,9 +425,7 @@ func createStorageRequestResponseAlwaysProve(t *testPeer, root common.Hash, acco
t.logger.Error("Could not prove last item", "error", err) t.logger.Error("Could not prove last item", "error", err)
} }
} }
for _, blob := range proof.List() { proofs = append(proofs, proof.List()...)
proofs = append(proofs, blob)
}
break break
} }
} }
@ -586,9 +579,8 @@ func testSyncBloatedProof(t *testing.T, scheme string) {
source.accountRequestHandler = func(t *testPeer, requestId uint64, root common.Hash, origin common.Hash, limit common.Hash, cap uint64) error { source.accountRequestHandler = func(t *testPeer, requestId uint64, root common.Hash, origin common.Hash, limit common.Hash, cap uint64) error {
var ( var (
proofs [][]byte keys []common.Hash
keys []common.Hash vals [][]byte
vals [][]byte
) )
// The values // The values
for _, entry := range t.accountValues { for _, entry := range t.accountValues {
@ -618,10 +610,7 @@ func testSyncBloatedProof(t *testing.T, scheme string) {
keys = append(keys[:1], keys[2:]...) keys = append(keys[:1], keys[2:]...)
vals = append(vals[:1], vals[2:]...) vals = append(vals[:1], vals[2:]...)
} }
for _, blob := range proof.List() { if err := t.remote.OnAccounts(t, requestId, keys, vals, proof.List()); err != nil {
proofs = append(proofs, blob)
}
if err := t.remote.OnAccounts(t, requestId, keys, vals, proofs); err != nil {
t.logger.Info("remote error on delivery (as expected)", "error", err) t.logger.Info("remote error on delivery (as expected)", "error", err)
t.term() t.term()
// This is actually correct, signal to exit the test successfully // This is actually correct, signal to exit the test successfully

View file

@ -102,14 +102,14 @@ func (db *ProofSet) DataSize() int {
return db.dataSize return db.dataSize
} }
// List converts the node set to a ProofList // List converts the node set to a slice of bytes.
func (db *ProofSet) List() ProofList { func (db *ProofSet) List() [][]byte {
db.lock.RLock() db.lock.RLock()
defer db.lock.RUnlock() defer db.lock.RUnlock()
var values ProofList values := make([][]byte, len(db.order))
for _, key := range db.order { for i, key := range db.order {
values = append(values, db.nodes[key]) values[i] = db.nodes[key]
} }
return values return values
} }