recentIterateRange: narrow DB query to exclude file range#20362
Merged
sudeepdino008 merged 2 commits intomainfrom Apr 7, 2026
Merged
recentIterateRange: narrow DB query to exclude file range#20362sudeepdino008 merged 2 commits intomainfrom
sudeepdino008 merged 2 commits intomainfrom
Conversation
AskAlexSharov
approved these changes
Apr 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the inverted index DB-range iteration logic to avoid querying MDBX for txNum ranges that are already covered by frozen snapshot files, addressing #20358 (prunable data should not be required for correctness/iteration).
Changes:
- Narrow
recentIterateRange’sRangeDupSortbounds so DB iteration excludes the frozen-file-covered txNum prefix for both ascending and descending iteration. - Add a regression test that builds frozen files, prunes DB entries in the file-covered range, and verifies
IdxRangestill returns correct results for asc/desc.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| db/state/inverted_index.go | Adjusts DB iterator bounds in recentIterateRange to skip the frozen-file-covered txNum range. |
| db/state/inverted_index_test.go | Adds TestInvertedIndex_IdxRange_SkipsFileRange to validate IdxRange behavior after pruning DB entries covered by files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Apr 10, 2026
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Apr 11, 2026
…st (#20444) Fixes #20355 - Skip DB entries whose step falls within the file range (`step.ToTxNum < files.EndTxNum()`) in both the initial DB cursor push and the advance loop — they are never loaded into the heap - Matches the "don't query DB for data in files" pattern from #20360, #20361, #20362 - Add `TestDomain_IteratePrefix_PrefersFilesOverDB` that simulates partial lexicographic prune and verifies file values win Follow-up: #20474 applies the same fix to `DomainLatestIterFile.initCursorMDBX()` and `advanceInFiles()` ## Test plan - [x] New test passes with fix, fails without it - [x] `make lint` clean - [x] `make erigon integration` builds
sudeepdino008
added a commit
that referenced
this pull request
Apr 13, 2026
Closes #20358 - Adjust `recentIterateRange` DB query bounds to skip txNums already covered by frozen files - For ascending: raise the inclusive lower bound (`from`) to `filesEndTxNum` - For descending: raise the exclusive lower bound (`to`) to `filesEndTxNum-1` (so `value > filesEndTxNum-1` ≡ `value >= filesEndTxNum`) - Add `TestInvertedIndex_IdxRange_SkipsFileRange`: builds files for 2 steps, prunes DB entries in the file range, verifies IdxRange still returns correct results for both asc and desc ## Test plan - [x] New test `TestInvertedIndex_IdxRange_SkipsFileRange` passes - [x] All existing `TestInvIndex*` / `TestInvertedIndex*` tests pass - [x] `make lint` clean - [x] `make erigon integration` builds
sudeepdino008
added a commit
that referenced
this pull request
Apr 13, 2026
Closes #20358 - Adjust `recentIterateRange` DB query bounds to skip txNums already covered by frozen files - For ascending: raise the inclusive lower bound (`from`) to `filesEndTxNum` - For descending: raise the exclusive lower bound (`to`) to `filesEndTxNum-1` (so `value > filesEndTxNum-1` ≡ `value >= filesEndTxNum`) - Add `TestInvertedIndex_IdxRange_SkipsFileRange`: builds files for 2 steps, prunes DB entries in the file range, verifies IdxRange still returns correct results for both asc and desc ## Test plan - [x] New test `TestInvertedIndex_IdxRange_SkipsFileRange` passes - [x] All existing `TestInvIndex*` / `TestInvertedIndex*` tests pass - [x] `make lint` clean - [x] `make erigon integration` builds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #20358
recentIterateRangeDB query bounds to skip txNums already covered by frozen filesfrom) tofilesEndTxNumto) tofilesEndTxNum-1(sovalue > filesEndTxNum-1≡value >= filesEndTxNum)TestInvertedIndex_IdxRange_SkipsFileRange: builds files for 2 steps, prunes DB entries in the file range, verifies IdxRange still returns correct results for both asc and descTest plan
TestInvertedIndex_IdxRange_SkipsFileRangepassesTestInvIndex*/TestInvertedIndex*tests passmake lintcleanmake erigon integrationbuilds