go-ethereum/trie/bintrie
CPerezz f57dd20461
trie/bintrie: mark stems created via Empty.Insert* as dirty
Empty.Insert and Empty.InsertValuesAtStem construct a fresh StemNode with
mustRecompute=true but left the new `dirty` field at its zero value. With
the skip-clean CollectNodes optimization enabled, the resulting stem was
treated as already-persisted and never flushed to disk. A parent
InternalNode's blob would be written referencing a hash for which no
blob existed, causing "missing trie node" errors on subsequent reads.

This is the path hit whenever a key is inserted into an Empty subtree —
the common case on the first insert, and frequently thereafter on splits
that leave one side Empty. A long-running deployment surfaced the bug
after ~15 hours of random ERC20 writes.

Add `dirty: true` to both struct literals, and add regression guards
TestEmptyInsertMarksDirty / TestEmptyInsertValuesAtStemMarksDirty that
assert the returned stem is dirty.
2026-04-18 09:06:11 +02:00
..
binary_node.go trie/bintrie: skip clean nodes in CollectNodes to reduce commit write amplification 2026-04-17 15:54:16 +02:00
binary_node_test.go cmd/evm/internal/t8ntool, trie: support for verkle-at-genesis, use UBT, and move the transition tree to its own package (#32445) 2025-11-14 15:25:30 +01:00
empty.go trie/bintrie: mark stems created via Empty.Insert* as dirty 2026-04-18 09:06:11 +02:00
empty_test.go trie/bintrie: mark stems created via Empty.Insert* as dirty 2026-04-18 09:06:11 +02:00
hashed_node.go trie/bintrie: cache hashes of clean nodes so as not to rehash the whole tree (#33961) 2026-03-06 18:06:24 +01:00
hashed_node_test.go cmd/evm/internal/t8ntool, trie: support for verkle-at-genesis, use UBT, and move the transition tree to its own package (#32445) 2025-11-14 15:25:30 +01: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: skip clean nodes in CollectNodes to reduce commit write amplification 2026-04-17 15:54:16 +02:00
internal_node_test.go trie/bintrie: skip clean nodes in CollectNodes to reduce commit write amplification 2026-04-17 15:54:16 +02:00
iterator.go trie/bintrie: fix NodeIterator Empty node handling and expose tree accessors (#34056) 2026-03-20 13:53:14 -04:00
iterator_test.go trie/bintrie: fix NodeIterator Empty node handling and expose tree accessors (#34056) 2026-03-20 13:53:14 -04:00
key_encoding.go trie/bintrie: spec change, big endian hashing of slot key (#34670) 2026-04-13 09:42:37 +02:00
stem_node.go trie/bintrie: skip clean nodes in CollectNodes to reduce commit write amplification 2026-04-17 15:54:16 +02:00
stem_node_test.go trie/bintrie: skip clean nodes in CollectNodes to reduce commit write amplification 2026-04-17 15:54:16 +02:00
trie.go cmd, core, trie, triedb: split CachingDB into merkle + binary dbs. (#34700) 2026-04-17 08:55:54 +08:00
trie_test.go trie/bintrie: skip clean nodes in CollectNodes to reduce commit write amplification 2026-04-17 15:54:16 +02:00