go-ethereum/triedb
YQ AltLayer eabbd68c19 triedb/pathdb: fix trienode history gap when newly enabled on existing node
When enabling trienode history (--history.trienode=0) on a node that
already has state at block N, repairHistory() returns a fatal error:
"gap between state [#N] and trienode history [#0]"

This happens because the newly created trienode freezer has 0 entries
while state is at block N. The gap check on line 427 treats this as a
data corruption error, but the function's own comments document that
it should "detect and resolve such gaps" for the optional trienode
history.

Fix by detecting the newly-enabled case (empty freezer + non-zero
stateID) and skipping both the gap check and the head truncation.
An empty freezer with head=0 would also fail truncateFromHead because
ohead(0) < nhead(stateID) is outside the valid range.

The trienode history will begin accumulating naturally from the
current state forward, which is the expected behavior documented
in the v1.17.0 release notes.

Fixes ethereum/go-ethereum#33907
2026-03-01 12:20:50 +00:00
..
database trie: optimize memory allocation (#30932) 2025-03-25 14:59:44 +01:00
hashdb cmd, core, miner: rework genesis setup (#30907) 2025-01-14 11:49:30 +01:00
pathdb triedb/pathdb: fix trienode history gap when newly enabled on existing node 2026-03-01 12:20:50 +00:00
database.go core, eth, internal, triedb/pathdb: enable eth_getProofs for history (#32727) 2026-01-22 09:19:27 +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