mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
For an InternalNode at a group-boundary depth, hashInternal previously computed pure SHA256(left, right) recursion over the natural-depth in-memory tree built by UpdateStem. But serializeSubtree extends stems to the group's bottom layer via key-bit extension, so the on-disk blob encodes an extended-depth structure. When a fresh reader deserializes that blob, hashInternal walks the extended-depth in-memory tree and produces a different value. The result was that for any subtree with multiple stems sharing a prefix shorter than groupDepth, the parent's stored child-hash (computed from the natural-depth in-memory tree at commit time) did not equal the child blob's read-back hash. Geth's own write-read cycle was internally inconsistent: state-actor's groundtruth test, which feeds the same stems through state-actor's streaming builder and geth's UpdateStem + Commit and diffs the resulting on-disk node sets, fails at n=4 with a mismatched slot hash in the root group blob. At a group boundary, recompute the hash via serializeSubtree + groupedRecursiveHash so that the parent stores the same value the reader will compute when it deserializes the child blob. The fix is gated on groupDepth > 0, so nodeStore tests that construct the store directly without going through NewBinaryTrie retain the existing pure-SHA256 recursion semantics. Verification: - All existing trie/bintrie tests pass unchanged. - state-actor/generator's TestStreamingMatchesGethCommit (which compares state-actor's streaming builder output to geth's Commit output byte-for-byte at n=2,4,8,32,128) now passes. |
||
|---|---|---|
| .. | ||
| binary_node.go | ||
| binary_node_test.go | ||
| bitarray.go | ||
| bitarray_test.go | ||
| hashed_node.go | ||
| hashed_node_test.go | ||
| hasher.go | ||
| internal_node.go | ||
| internal_node_test.go | ||
| iterator.go | ||
| iterator_test.go | ||
| key_encoding.go | ||
| node_ref.go | ||
| node_store.go | ||
| stem_node.go | ||
| stem_node_test.go | ||
| store_commit.go | ||
| store_ops.go | ||
| trie.go | ||
| trie_test.go | ||