go-ethereum/triedb
CPerezz 135a5e1e3b
triedb/pathdb: add regression test for zero-base-root lookup fallback
TestLookupZeroBaseRootFallback constructs a layer tree whose disk-layer
root is common.Hash{} (mirroring the bintrie/verkle configuration where
an empty trie hashes to EmptyVerkleHash), stacks diff layers on top,
and exercises four cases:

  1. lookupAccount on a never-written key must fall through to the disk
     layer and return (diskLayer, nil). Before the previous commit this
     returned errSnapshotStale because the disk-layer fallback hash
     collided with the stale sentinel.
  2. Symmetric case for lookupStorage.
  3. lookupAccount on a written account must still return the diff
     layer that holds it — pins the normal resolution path.
  4. lookupAccount/lookupStorage for an unknown state root must still
     return errSnapshotStale. This pins the other half of the contract
     so a future refactor that always returned ok=true would be caught
     here rather than in production.

Verified by reverse-applying the previous commit: the test fails with
the exact pre-fix error ("layer stale") on cases 1 and 2, and passes
once the fix is restored.

The existing TestAccountLookup/TestStorageLookup tests use
newTestLayerTree which hard-codes common.Hash{0x1} as the disk-layer
root, so none of them could cover the zero-root case without a tailored
helper; this test inlines newDiskLayer(common.Hash{}, …) directly
rather than parameterize the shared helper.
2026-04-08 00:42:37 +02:00
..
database trie: optimize memory allocation (#30932) 2025-03-25 14:59:44 +01:00
hashdb core, miner, tests: introduce codedb and simplify cachingDB (#33816) 2026-03-10 08:29:21 +01:00
internal triedb, triedb/internal, triedb/pathdb: add GenerateTrie + extract shared pipeline into triedb/internal (#34654) 2026-04-07 14:36:53 +08:00
pathdb triedb/pathdb: add regression test for zero-base-root lookup fallback 2026-04-08 00:42:37 +02:00
database.go core, eth, ethclient, triedb: report trienode index progress (#34633) 2026-04-04 21:00:07 +08:00
generate.go triedb, triedb/internal, triedb/pathdb: add GenerateTrie + extract shared pipeline into triedb/internal (#34654) 2026-04-07 14:36:53 +08:00
generate_test.go triedb, triedb/internal, triedb/pathdb: add GenerateTrie + extract shared pipeline into triedb/internal (#34654) 2026-04-07 14:36:53 +08:00
history.go cmd, triedb: implement history inspection (#29267) 2024-03-22 20:12:10 +08:00
preimages.go all: remove the dependency from trie to triedb (#28824) 2024-02-13 14:49:53 +01:00
preimages_test.go triedb: add test suite for preimage store (#31574) 2025-05-05 14:01:53 +08:00
states.go all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00