mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 09:51:36 +00:00
BinaryTrie.GetAccount returned the wrong account data for non-existent
addresses when the trie root was a StemNode (single-account trie). The
StemNode branch directly returned r.Values without verifying that the
queried address's stem matched the node's stem. Similarly, GetStorage
panicked via StemNode.Get("this should not be called directly") when
the root was a StemNode.
Additionally, Empty.GetValuesAtStem returned a non-nil slice of 256
nil entries instead of nil, creating a semantic trap for callers that
check values != nil to determine membership.
Fix all four bug sites:
1. StemNode.Get: replace panic with proper stem verification and value
lookup, matching InternalNode.Get's contract.
2. GetAccount StemNode branch: delegate to GetValuesAtStem (which
already has the stem equality check) instead of accessing r.Values
directly. This is consistent with the InternalNode branch.
3. Empty.GetValuesAtStem: return nil instead of 256 nil values.
Callers (InternalNode.Get, GetAccount) already handle nil correctly.
4. GetAccount: add explicit nil-values guard before the decode logic
as defense-in-depth, and simplify the now-redundant values != nil
condition in the emptyAccount loop.
|
||
|---|---|---|
| .. | ||
| bintrie | ||
| transitiontrie | ||
| trienode | ||
| bytepool.go | ||
| committer.go | ||
| database_test.go | ||
| encoding.go | ||
| encoding_test.go | ||
| errors.go | ||
| hasher.go | ||
| inspect.go | ||
| inspect_test.go | ||
| iterator.go | ||
| iterator_test.go | ||
| levelstats.go | ||
| levelstats_test.go | ||
| list_hasher.go | ||
| node.go | ||
| node_enc.go | ||
| node_test.go | ||
| proof.go | ||
| proof_test.go | ||
| secure_trie.go | ||
| secure_trie_test.go | ||
| stacktrie.go | ||
| stacktrie_fuzzer_test.go | ||
| stacktrie_test.go | ||
| sync.go | ||
| sync_test.go | ||
| tracer.go | ||
| tracer_test.go | ||
| trie.go | ||
| trie_id.go | ||
| trie_reader.go | ||
| trie_test.go | ||