fix(archiver): handle duplicate checkpoint from L1 reorg#22252
Merged
Conversation
When an L1 reorg moves a checkpoint to a different L1 block, the archiver re-discovers it during the next scan. Previously this threw InitialCheckpointNumberNotSequentialError because the checkpoint was already in the store. Now addCheckpoints accepts duplicate checkpoints if their archive root matches (same content) and updates the L1 metadata. If archives don't match, it throws a clear error about the mismatch.
PhilWindle
approved these changes
Apr 2, 2026
Collaborator
Author
|
❌ Failed to cherry-pick to |
PhilWindle
added a commit
that referenced
this pull request
Apr 2, 2026
…2252) (#22257) ## Summary Backport of #22252 to v4. Fixes a mainnet issue where an L1 reorg moved a checkpoint to a different L1 block, causing the archiver to re-discover it and crash with `InitialCheckpointNumberNotSequentialError` in an infinite loop. When `addCheckpoints` receives a checkpoint that's already stored, it now: - **Accepts it** if the archive root matches (same content, just different L1 block) - **Updates the L1 metadata** (block number, timestamp, hash) and attestations - **Throws** if the archive root doesn't match (content mismatch — genuine conflict) ## Conflict Resolution Cherry-pick had one conflict in `block_store.ts`: - v4 uses inline code for extracting previous checkpoint block data; `next` refactored this into a `getPreviousCheckpointBlock()` helper. Kept v4's inline approach but updated to use `checkpoints[0]` reference (correct after potential skip of already-stored checkpoints). - Only ported `skipOrUpdateAlreadyStoredCheckpoints` method (the fix). Dropped `getPreviousCheckpointBlock` and `validateCheckpointBlocks` refactors that exist on `next` but not v4. ## Test Results - 176 passed in `kv_archiver_store.test.ts` - 33 passed in `archiver-sync.test.ts` (includes new `handles L1 reorg that moves a checkpoint to a later L1 block` test) - Build, format pass ClaudeBox log: https://claudebox.work/s/21a4c138364df1ef?run=1
spalladino
reviewed
Apr 2, 2026
Comment on lines
+353
to
+359
| // Verify the checkpoint content matches (archive root) | ||
| if (!stored.archive.root.equals(incoming.checkpoint.archive.root)) { | ||
| throw new Error( | ||
| `Checkpoint ${incoming.checkpoint.number} already exists in store but with a different archive root. ` + | ||
| `Stored: ${stored.archive.root}, incoming: ${incoming.checkpoint.archive.root}`, | ||
| ); | ||
| } |
Contributor
There was a problem hiding this comment.
@Maddiaa0 not sure if this can cause issues with syncing a checkpoint that should override a proposed checkpoint
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Apr 6, 2026
BEGIN_COMMIT_OVERRIDE fix: deflake HA governance voting test by polling for L1/DB convergence (#22220) feat(world-state): add genesis timestamp support and GenesisData type (#22201) chore: revert: feat(world-state): add genesis timestamp support and GenesisData type (#22201) (#22255) fix(archiver): handle duplicate checkpoint from L1 reorg (#22252) chore: update dashboard (#22260) fix: remove detailed revert codes (#22274) chore: use ESO in grafana (#22271) chore: (A-751) robust response error handling in json-rpc client (#22246) fix: separate fisherman StatefulSet from rpc-node and stop archiver pollution (#22183) fix: restore mainnet prover agents to 4 replicas (#22305) END_COMMIT_OVERRIDE
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
Fixes a mainnet issue where an L1 reorg moved a checkpoint to a different L1 block, causing the archiver to re-discover it and crash with
InitialCheckpointNumberNotSequentialErrorin an infinite loop.When
addCheckpointsreceives a checkpoint that's already stored, it now:Changes
block_store.ts: AddedskipOrUpdateAlreadyStoredCheckpointsmethod that handles duplicate checkpoints at the start of a batch. Verifies archive roots match and updates L1 info.fake_l1_state.ts: AddedmoveCheckpointToL1Blockhelper for simulating L1 reorgs that move checkpoints.archiver-sync.test.ts: Added e2e testhandles L1 reorg that moves a checkpoint to a later L1 blockin the reorg handling suite.kv_archiver_store.test.ts: Added unit tests for accepting matching duplicates with updated L1 info, accepting fully-duplicate batches, and rejecting mismatching duplicates.Test plan
kv_archiver_store.test.tsarchiver-sync.test.tsClaudeBox log: https://claudebox.work/s/e5247344b8df94ca?run=2