go-ethereum/trie/bintrie
weiihann bdb7b64173 trie/bintrie: mark promoted stem dirty during splitStemValuesInsert
When splitStemValuesInsert inserts a new stem that shares a prefix with
an existing stem, it increments the existing stem's depth and inserts a
new internal node above it. The existing stem's on-disk path is derived
from its depth via collectChildGroups + extendPathToGroupLeaf, so
promoting its depth means it should be flushed at a new path.

Previously, only the new stem (created in the divergence branch) was
marked dirty. The promoted existing stem retained whatever dirty value
it had — false if it was just deserialized from disk via a HashedNode
resolve. collectNodes would then skip flushing the existing stem at its
new path, while the new ancestor internal blob (also dirty) overwrites
the existing stem's old blob at the prior path. The stem's data is
left with no on-disk home, breaking subsequent reads with
"missing trie node".

The bug surfaces in the integration-test harness (state-actor builds a
DB with single-stem-per-slot at depth 8, geth then mutates by adding a
new stem that shares ≥8 prefix bits with the existing stem). After
mutation, geth's `getValuesAtStem` resolves a HashedNode whose blob
should be at the extended-depth path but isn't on disk.

Mark `existing.dirty = true` when promoting the depth so collectNodes
re-flushes the stem at its new path.

Verification: the 100MB integration-test harness (which previously
failed at block 9-10 with "missing trie node bdaf89... (path c96010)")
now runs cleanly through 200+ blocks of ERC20 deploys and bloat
transactions without any missing-trie-node errors.
2026-05-13 09:39:31 +08:00
..
binary_node.go trie: group 2^N binary trie nodes in serialization (#34794) 2026-05-01 15:28:19 +02:00
binary_node_test.go trie/bintrie: postpend bit-length to disambiguate path encoding 2026-05-11 11:37:28 +08:00
bitarray.go trie/bintrie: postpend bit-length to disambiguate path encoding 2026-05-11 11:37:28 +08:00
bitarray_test.go trie/bintrie: use bitarray for path encoding 2026-05-08 12:58:48 +08:00
hashed_node.go trie/bintrie: replace BinaryNode interface with GC-free NodeRef arena (#34055) 2026-04-20 14:08:30 +02:00
hashed_node_test.go trie: group 2^N binary trie nodes in serialization (#34794) 2026-05-01 15:28:19 +02:00
hasher.go trie/bintrie: use a sync.Pool when hashing binary tree nodes (#33989) 2026-03-12 10:20:12 +01:00
internal_node.go trie/bintrie: postpend bit-length to disambiguate path encoding 2026-05-11 11:37:28 +08:00
internal_node_test.go trie/bintrie: use bitarray for path encoding 2026-05-08 12:58:48 +08:00
iterator.go trie/bintrie: postpend bit-length to disambiguate path encoding 2026-05-11 11:37:28 +08:00
iterator_test.go trie/bintrie: replace BinaryNode interface with GC-free NodeRef arena (#34055) 2026-04-20 14:08:30 +02:00
key_encoding.go trie/bintrie: spec change, big endian hashing of slot key (#34670) 2026-04-13 09:42:37 +02:00
node_ref.go trie/bintrie: replace BinaryNode interface with GC-free NodeRef arena (#34055) 2026-04-20 14:08:30 +02:00
node_store.go trie/bintrie: fix hashInternal at group boundaries to match read-back hash 2026-05-13 09:39:19 +08:00
stem_node.go trie/bintrie: replace BinaryNode interface with GC-free NodeRef arena (#34055) 2026-04-20 14:08:30 +02:00
stem_node_test.go trie/bintrie: use bitarray for path encoding 2026-05-08 12:58:48 +08:00
store_commit.go trie/bintrie: fix hashInternal at group boundaries to match read-back hash 2026-05-13 09:39:19 +08:00
store_ops.go trie/bintrie: mark promoted stem dirty during splitStemValuesInsert 2026-05-13 09:39:31 +08:00
trie.go trie/bintrie: fix hashInternal at group boundaries to match read-back hash 2026-05-13 09:39:19 +08:00
trie_test.go trie: group 2^N binary trie nodes in serialization (#34794) 2026-05-01 15:28:19 +02:00