Skip to content

enforce block-snapshots cap inside aggregator collation#20852

Open
sudeepdino008 wants to merge 3 commits intorelease/3.4from
collate_ap_loop_34
Open

enforce block-snapshots cap inside aggregator collation#20852
sudeepdino008 wants to merge 3 commits intorelease/3.4from
collate_ap_loop_34

Conversation

@sudeepdino008
Copy link
Copy Markdown
Member

@sudeepdino008 sudeepdino008 commented Apr 28, 2026

  • https://github.com/erigontech/erigon/pull/20701/changes was added, wherein the cap was passed to BuildFiles* api
  • but BuildFilesInBackground can ignore the passed txnum value (considering lastTxNumInDb etc.)
  • this PR moves the state collation cap logic inside the aggregator; the aggregator then needs a SetFrozenBlocksProvider which is called to find block snapshots progress, and use it to cap the state collation.

@sudeepdino008 sudeepdino008 changed the title [wip] enforce block-snapshots cap inside collation loop enforce block-snapshots cap inside aggregator collation Apr 28, 2026
@sudeepdino008 sudeepdino008 marked this pull request as ready for review April 28, 2026 08:46
@AskAlexSharov AskAlexSharov requested a review from Copilot April 28, 2026 08:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR moves the “max collatable txNum” cap enforcement from call sites into the state Aggregator, so state collation can’t advance past block snapshot progress (addressing the BuildFilesInBackground loophole noted in #20701). It introduces a SetFrozenBlocksProvider hook to let the aggregator query snapshot progress and applies the cap during collation readiness checks.

Changes:

  • Add FrozenBlocksProvider + SetFrozenBlocksProvider to db/state.Aggregator and enforce the snapshot boundary cap inside readyForCollation.
  • Wire the provider in main entry points (node backend setup, integration snapshots, retire command).
  • Remove external capping logic in ExecV3 and snapshots_cmd, and add regression tests covering BuildFiles/BuildFiles2 cap behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
node/eth/backend.go Wires SetFrozenBlocksProvider(blockReader) during block reader/aggregator setup.
execution/stagedsync/exec3.go Removes call-site max-collatable capping; relies on aggregator internal enforcement.
db/test/aggregator_ext_test.go Adds regression tests ensuring BuildFiles/BuildFiles2 respect the cap and that nil/low-cap behavior is safe.
db/state/aggregator.go Introduces FrozenBlocksProvider, stores it on the aggregator, and enforces the cap in readyForCollation.
db/services/snapshot_progress.go Updates doc comment to reflect that the aggregator enforces the cap internally.
cmd/utils/app/snapshots_cmd.go Wires provider for retire flow and removes explicit MaxCollatableTxNum capping of lastTxNum.
cmd/integration/commands/stages.go Wires provider in allSnapshots() integration setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread db/state/aggregator.go
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.

2 participants