Skip to content

feat: stop history pruning after certain checkpoint - #25656

Merged
alexghr merged 1 commit into
v5-nextfrom
stack/feat-stop-history-pruning-after-certain-checkpoint
Oct 16, 2026
Merged

alexghr merged 1 commit into
v5-nextfrom
stack/feat-stop-history-pruning-after-certain-checkpoint

Conversation

@alexghr

@alexghr alexghr commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Allow pinning history to a certain checkpoint number.

Related to A-2390

@alexghr alexghr added the port-to-aztec-node PRs need to be ported to the new repo label Oct 15, 2026
@alexghr

alexghr commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

This will have to be ported manually to aztec-node.

@alexghr
alexghr force-pushed the stack/feat-stop-history-pruning-after-certain-checkpoint branch from aa50227 to 6962aea Compare October 15, 2026 16:59
@alexghr
alexghr requested a review from IlyasRidhuan as a code owner October 15, 2026 16:59
@alexghr
alexghr force-pushed the stack/feat-stop-history-pruning-after-certain-checkpoint branch from 6962aea to fa395e3 Compare October 15, 2026 17:47

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

Requesting changes: the new history validation also runs on nodes without a pin, and it changes startup and snapshot-sync behaviour for every v5 node. Details are in the inline comment on snapshot-sync.ts.

Written by Claude

Comment thread yarn-project/node-lib/src/actions/snapshot-sync.test.ts Outdated
Comment on lines +69 to +75
if (worldStateDirectory && (await hasWorldStateDatabase(worldStateDirectory))) {
await validateLocalWorldStateHistory(config, log, genesis);
if (historyStartCheckpoint !== undefined) {
log.info('Using existing world-state database with compatible retained history', { historyStartCheckpoint });
return false;
}
}

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.

IIUC what happens here is that if the historyStartCheckpoint is set, then we'll refuse to use a snapshot? I'm worried this could lead to excessively long syncing times. Maybe we could sync anyway, but regenerate world state from archive?

EDIT: I think I understand now. You cannot "backfill" world state entries you already pruned. So the best you can do is get a new archiver snapshot, an old world state one from another snapshot bundle, and then have world state sync the missing entries from the archiver. But that's extra complexity, so we stick with picking a snapshot with the old world state. Is that the case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no, the scenario is:

  1. we have local state
  2. our config is updated to say "we need to retain full history from this block onwards"
  3. node restarts (since it's an env var change)
  4. on boot we check if our local state is compatible. If it isn't (ie our local db has state from block N but env var says to keep state from block N - 100) we refuse to start
  5. otherwise we print the above log and continue.

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.

Why the submodule changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll double check they are the same commits as v5-next but I hadn't bootstrapped properly before working on this code and committed with deleted submodules. See 6962aea

Comment on lines +271 to +276
if (checkpoint) {
maxSnapshotBlock = BlockNumber(checkpoint.startBlock + checkpoint.blockCount - 1);
}
throw new Error(
`Snapshot is at checkpoint ${latestBlock.checkpointNumber}, after requested checkpoint ${historyStartCheckpoint}`,
);

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.

I find this bit confusing. Why is it a problem for the snapshot to be at a later point in time than the requested history?

EDIT: I think I understand now: we want to sync from a snapshot that has an old archive and world state, so we can sync state and regen world state from there, without pruning, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

correct

Comment thread yarn-project/node-lib/src/actions/snapshot-sync.ts Outdated
@alexghr
alexghr force-pushed the stack/feat-stop-history-pruning-after-certain-checkpoint branch from fa395e3 to 3c139ba Compare October 16, 2026 09:36
@alexghr
alexghr force-pushed the stack/feat-stop-history-pruning-after-certain-checkpoint branch from 3c139ba to c08b2d1 Compare October 16, 2026 09:41
@alexghr
alexghr merged commit 0d09d31 into v5-next Oct 16, 2026
12 checks passed
@alexghr
alexghr deleted the stack/feat-stop-history-pruning-after-certain-checkpoint branch October 16, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

port-to-aztec-node PRs need to be ported to the new repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants