mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 09:51:36 +00:00
eth/protocols/snap: handle StateReader error in ServiceTrieNodesQuery
When the snapshot is unavailable, ServiceTrieNodesQuery falls back to triedb.StateReader but discards the error. If StateReader fails (e.g. state pruned or DB corruption), the nil reader is passed to trie operations, causing a nil pointer dereference when serving trie node requests. Return a proper error instead of silently proceeding with a nil state reader.
This commit is contained in:
parent
8a3a309fa9
commit
5cafd07009
1 changed files with 5 additions and 1 deletions
|
|
@ -561,7 +561,11 @@ func ServiceGetTrieNodesQuery(chain *core.BlockChain, req *GetTrieNodesPacket, s
|
|||
reader = chain.Snapshots().Snapshot(req.Root)
|
||||
}
|
||||
if reader == nil {
|
||||
reader, _ = triedb.StateReader(req.Root)
|
||||
var err error
|
||||
reader, err = triedb.StateReader(req.Root)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create state reader for root %x: %w", req.Root, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve trie nodes until the packet size limit is reached
|
||||
|
|
|
|||
Loading…
Reference in a new issue