Skip to content

--persist.receipts.distance support - #22349

Merged
AskAlexSharov merged 31 commits into
mainfrom
alex/prune_persist_rcp_36
Jul 12, 2026
Merged

AskAlexSharov merged 31 commits into
mainfrom
alex/prune_persist_rcp_36

Conversation

@AskAlexSharov

@AskAlexSharov AskAlexSharov commented Jul 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

#21306 step 5: skip downloading old receipt-cache (RCache) snapshots.

Current behavior:

  • --persist.receipts does store --prune.distance.blocks amount of data

PR:
Adds --persist.receipts.distance=<N|keep-all> — keep the receipt cache only for the latest N blocks (or keep-all to keep it all): skip older rcache-history snapshots at download and retire them past the window. Empty or 0 (default) follows the state-history window (not keep-all); requires --persist.receipts.

Refs #21306.

…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 AskAlexSharov changed the title db/kv/prune, db/snapshotsync, execution: --persist.receipts.distance to skip old receipt snapshots --persist.receipts.distance to skip download Jul 9, 2026
@yperbasis
yperbasis requested a review from Copilot July 9, 2026 09:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Mode with a Receipts BlockAmount, including persistence (DatabaseInfo key), string rendering, CLI parsing, and retention-window change handling.
  • Wire new CLI flag --persist.receipts.distance into pruning mode computation and apply it to snapshot download filtering and to retire cutoffs for RCacheDomain.
  • 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.

Comment thread node/cli/flags.go Outdated
@AskAlexSharov AskAlexSharov changed the title --persist.receipts.distance to skip download [wip] --persist.receipts.distance to skip download Jul 9, 2026
@AskAlexSharov AskAlexSharov changed the title [wip] --persist.receipts.distance to skip download [wip] --persist.receipts.distance support Jul 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@AskAlexSharov AskAlexSharov changed the title [wip] --persist.receipts.distance support --persist.receipts.distance support Jul 10, 2026
@AskAlexSharov
AskAlexSharov requested a review from JkLondon July 10, 2026 08:27
…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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via isReceiptsSegmentPruned, which uses the Blocks retention policy (blocksRetentionCutoff). This means configurations where Blocks and History differ (e.g. BlocksMode: Blocks=keep-all, History finite) will still download old rcache history segments even though pruning/retirement treats rcache as following the general History window (see historyRetireCutoffs and ReceiptsFollowHistory docs). 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
			}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Comment thread db/snapshotsync/snapshotsync.go
Comment thread db/kv/prune/storage_mode_test.go Outdated
- 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).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.

Comment thread docs/site/docs/fundamentals/configuring-erigon.mdx Outdated
Comment thread llms-full.txt Outdated
Comment thread docs/site/static/llms-full.txt Outdated
Comment thread db/snapshotsync/snapshotsync.go Outdated
…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).
@AskAlexSharov
AskAlexSharov added this pull request to the merge queue Jul 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 11, 2026
@AskAlexSharov
AskAlexSharov added this pull request to the merge queue Jul 12, 2026
Merged via the queue into main with commit b9e4d3c Jul 12, 2026
176 of 178 checks passed
@AskAlexSharov
AskAlexSharov deleted the alex/prune_persist_rcp_36 branch July 12, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants