Parent issue
Part of #16239 -- avoiding inconsistency due to lexicographic prune.
Problem
In db/state/domain_stream.go, debugIteratePrefixLatest pushes DB entries into the priority heap even when their step is already covered by segment files. After a partial (lexicographic) prune, the DB may retain stale entries with steps within the file range — these should never be queried.
The initial DB cursor entry is pushed with endTxNum: math.MaxUint64, which always wins over file entries. The advance loop computes endTxNum from the step but still pushes entries within the file range into the heap.
Fix
Compute filesEndTxNum := dt.files.EndTxNum() once, then in both the initial DB push and the advance loop, skip any DB entry whose step.ToTxNum(stepSize) < filesEndTxNum. Only push DB entries whose step is beyond the file range.
This matches the "don't query DB for data that is in files" pattern already applied to History (#20360, #20361) and InvertedIndex (#20362).
Test
TestDomain_IteratePrefix_PrefersFilesOverDB: writes entries across two steps, builds files, deletes the latest DB dup to simulate partial prune, verifies file value is returned instead of stale DB value.
Parent issue
Part of #16239 -- avoiding inconsistency due to lexicographic prune.
Problem
In
db/state/domain_stream.go,debugIteratePrefixLatestpushes DB entries into the priority heap even when their step is already covered by segment files. After a partial (lexicographic) prune, the DB may retain stale entries with steps within the file range — these should never be queried.The initial DB cursor entry is pushed with
endTxNum: math.MaxUint64, which always wins over file entries. The advance loop computesendTxNumfrom the step but still pushes entries within the file range into the heap.Fix
Compute
filesEndTxNum := dt.files.EndTxNum()once, then in both the initial DB push and the advance loop, skip any DB entry whosestep.ToTxNum(stepSize) < filesEndTxNum. Only push DB entries whose step is beyond the file range.This matches the "don't query DB for data that is in files" pattern already applied to History (#20360, #20361) and InvertedIndex (#20362).
Test
TestDomain_IteratePrefix_PrefersFilesOverDB: writes entries across two steps, builds files, deletes the latest DB dup to simulate partial prune, verifies file value is returned instead of stale DB value.