--persist.receipts.distance support - #22349
Merged
Merged
Conversation
…to skip old receipt snapshots #21306 step 5: don't download old receipt-cache (RCache) snapshots. Mirrors the commitment-history pattern (#21200): keep the --persist.receipts bool, add a companion --persist.receipts.distance=<N blocks> that keeps the receipt cache only for the latest N blocks. 0 (default) keeps everything; requires --persist.receipts. The window lives in prune.Mode as a Receipts BlockAmount next to History/ Blocks/CommitmentHistory (persisted under a new pruneReceipts DB key; a missing key resolves to keep-all, so no schema bump). buildBlackListForPruning skips rcache state-history segments beyond the window at download time, and historyRetireCutoffs uses it for the RCacheDomain retire cutoff (overriding the follow-history default only when set), resolving the prior TODO.
…nload; tolerate bad rcache names Code-review follow-ups to the --persist.receipts.distance change: - On download, rcache retention now follows the receipts window (its own blacklist) rather than being overridden by a tighter --prune.distance.blocks via isReceiptsSegmentPruned, matching the retire side where the receipts window is authoritative for RCacheDomain. Only the log indexes still follow the block-data window. Gated behind --persist.receipts.distance, so configs without the flag are unchanged. - The rcache-history blacklist branch no longer aborts the whole sync on an unparseable rcache filename; such a file is left for download instead. - Minor: hoist the repeated pm.ReceiptsAmount() call in historyRetireCutoffs.
AskAlexSharov
requested review from
mh0lt,
sudeepdino008 and
yperbasis
as code owners
July 9, 2026 08:27
--persist.receipts.distance to skip download
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a receipts-specific retention window (--persist.receipts.distance) to the existing pruning/retention machinery so Erigon can skip downloading old receipt-cache (RCache) history snapshots and retire them outside the configured window.
Changes:
- Extend
prune.Modewith aReceipts BlockAmount, including persistence (DatabaseInfokey), string rendering, CLI parsing, and retention-window change handling. - Wire new CLI flag
--persist.receipts.distanceinto pruning mode computation and apply it to snapshot download filtering and to retire cutoffs forRCacheDomain. - Add/extend unit tests covering RCache download blacklisting, minimum-step cutoff calculation, and per-domain retire cutoffs when receipts retention is enabled.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| node/cli/flags.go | Reads --persist.receipts.distance and passes it into prune.FromCli; adds dependency check in urfave path (cobra path still needs parity). |
| node/cli/default_flags.go | Registers the new flag in the default urfave flag list. |
| cmd/utils/flags.go | Defines PersistReceiptsDistanceFlag and its help text. |
| db/kv/tables.go | Adds PruneReceipts database-info key for persisting receipts retention. |
| db/kv/prune/storage_mode.go | Adds Receipts to prune.Mode and wires parsing/persistence/string rendering/retention-change logic. |
| db/kv/prune/storage_mode_test.go | Adds tests for receipts defaults, parsing, string rendering, and legacy DB behavior. |
| db/kv/prune/distance_test.go | Updates FromCli call for new signature. |
| db/snapshotsync/snapshotsync.go | Adds RCache history download blacklist based on receipts retention; propagates receipts cutoff through minimum-block/step computation. |
| db/snapshotsync/snapshotsync_test.go | Adds tests for receipts-based blacklist behavior and minimum-step computation with three cutoffs. |
| execution/stagedsync/stage_execute.go | Makes RCacheDomain retire cutoff follow receipts retention window when set. |
| execution/stagedsync/stage_execute_prune_test.go | Adds coverage for retire cutoffs when receipts retention is enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
--persist.receipts.distance to skip download--persist.receipts.distance to skip download
--persist.receipts.distance to skip download--persist.receipts.distance support
…p_36 # Conflicts: # db/snapshotsync/snapshotsync.go # db/snapshotsync/snapshotsync_test.go
--persist.receipts.distance support--persist.receipts.distance support
…distance and --prune.commitment-history.distance Both flags become string-valued and accept "keep-all". commitment-history maps it to the existing KeepAllBlocksPruneMode (its default already keeps all). receipts needs a distinct KeepAllReceiptsPruneMode sentinel because its KeepAllBlocksPruneMode default means "follow the state-history window" — so an operator needs a separate value to force keep-all, overriding follow-history on both the retire and download sides.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
db/snapshotsync/snapshotsync.go:540
- When
ReceiptsFollowHistory()is true (no explicit--persist.receipts.distance), rcache segments are currently filtered viaisReceiptsSegmentPruned, which uses the Blocks retention policy (blocksRetentionCutoff). This means configurations whereBlocksandHistorydiffer (e.g.BlocksMode:Blocks=keep-all,Historyfinite) will still download old rcache history segments even though pruning/retirement treats rcache as following the general History window (seehistoryRetireCutoffsandReceiptsFollowHistorydocs). That defeats the PR goal of skipping old rcache snapshots and creates inconsistent behavior between download-time filtering and runtime retirement.
// rcache follows the block-data window here only under the
// follow-history default; a finite --persist.receipts.distance uses
// its own window (the receipts blacklist), and keep-all keeps it all.
// Log indexes always follow the block-data window.
isRcacheRelatedSegment := strings.Contains(p.Name, kv.LogAddrIdx.String()) ||
strings.Contains(p.Name, kv.LogTopicIdx.String())
if prune.ReceiptsFollowHistory() {
isRcacheRelatedSegment = isRcacheRelatedSegment || strings.Contains(p.Name, kv.RCacheDomain.String())
}
if isRcacheRelatedSegment && isReceiptsSegmentPruned(ctx, tx, txNumsReader, cc, prune, frozenBlocks, p, stepSize) {
continue
}
AskAlexSharov
requested review from
bloxster,
lupin012,
lystopad and
mriccobene
as code owners
July 10, 2026 14:10
- docs: regenerate llms-full.txt from source docs. These files are generated by docs/site/scripts/generate-llms.py; the prior hand-edits failed the docs-site --check job. Now byte-identical to generator output. - db/snapshotsync: getMinimumBlocksToDownload normalizes an unfound prune-to boundary (MaxUint32 sentinel) to 0 so it disables that download filter instead of blacklisting every matching history file (CR). Add regression test. - db/kv/prune: clarify the named-modes assertion message — Receipts stays at the follow-history default (KeepAllBlocksPruneMode), not the explicit keep-all sentinel (CR).
…llms The Default: false bullet belonged to --prune.include-commitment-history; it was re-parented onto the string-valued --prune.receipts.distance flag when the two distance-flag bullets were inserted. Move it back and give both distance flags an accurate default note; regenerate llms (CR).
…essages ParseReceiptsDistance/ParseCommitmentHistoryDistance no longer hardcode the CLI flag name for their error text; the caller (which owns the flag definition) passes it in. Keeps the db/kv/prune package decoupled from CLI flag spellings (CR).
awskii
approved these changes
Jul 11, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jul 11, 2026
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.
Summary
#21306 step 5: skip downloading old receipt-cache (RCache) snapshots.
Current behavior:
--persist.receiptsdoes store--prune.distance.blocksamount of dataPR:
Adds
--persist.receipts.distance=<N|keep-all>— keep the receipt cache only for the latest N blocks (orkeep-allto keep it all): skip older rcache-history snapshots at download and retire them past the window. Empty or0(default) follows the state-history window (not keep-all); requires--persist.receipts.Refs #21306.