Skip to content

[wip] snapshots: align state files to block file boundary on startup - #20508

Closed
AskAlexSharov wants to merge 1 commit into
mainfrom
fix/align-state-to-block-snapshots
Closed

AskAlexSharov wants to merge 1 commit into
mainfrom
fix/align-state-to-block-snapshots

Conversation

@AskAlexSharov

Copy link
Copy Markdown
Collaborator

Summary

  • On fresh sync, preverified state domain files may extend past the block file boundary, causing "behind commitment" errors when SeekCommitment returns a block number that TxNums doesn't cover
  • After opening aggregator files, reads the commitment "state" key; if the committed block exceeds FrozenBlocks(), iteratively removes the highest state files and de-registers them from the downloader
  • Alignment only runs on fresh start — skipped if TxNums already covers all frozen blocks (node previously indexed past the boundary)
  • Includes helper functions (isStateDomainFile, findHighestStateFileStartStep) and unit tests

Split out from #20503.

The preverified snapshot set may include state domain files whose
committed block number extends past the block file boundary. This
causes "behind commitment" errors on fresh sync because SeekCommitment
returns a block number that TxNums doesn't cover.

After downloading snapshots and opening the aggregator files, read the
commitment "state" key via a temporary temporal RO tx. If the committed
block exceeds FrozenBlocks(), iteratively remove the highest state files
(across all dirs: domain, idx, history, accessor), de-register them from
the downloader via seeder.Delete(), and strip from preverified.toml.

The alignment only runs on fresh start — if TxNums already covers all
frozen blocks (checked via a temporal RO tx), the node previously
indexed past the boundary and alignment is skipped.

Includes:
- isStateDomainFile() filter to avoid deleting block snapshot files
- findHighestStateFileStartStep returns (step, found) for step-0 safety
- Debug logging for alignment decisions
- Unit tests for all helper functions
@sudeepdino008
sudeepdino008 self-requested a review April 13, 2026 06:46
@AskAlexSharov AskAlexSharov changed the title snapshots: align state files to block file boundary on startup [wip] snapshots: align state files to block file boundary on startup Apr 13, 2026

@mh0lt mh0lt 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.

This is a duplicate of #20434

We should merge one and close the other.

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