Skip to content

fix(archiver): update finalized block lookback to account for checkpoints#21597

Merged
spalladino merged 1 commit intov4from
palla/fix/finalized-block-lookback
Mar 16, 2026
Merged

fix(archiver): update finalized block lookback to account for checkpoints#21597
spalladino merged 1 commit intov4from
palla/fix/finalized-block-lookback

Conversation

@spalladino
Copy link
Contributor

Summary

  • Updates the finalized block heuristic from epochDuration * 2 to epochDuration * 2 * 4 to subtract checkpoints (assumed 4 blocks each) instead of blocks.
  • The proper fix is in chore: Properly compute finalized block #21156 which replaces this heuristic with L1 finality.

🤖 Generated with Claude Code

…ints

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@spalladino spalladino enabled auto-merge (squash) March 16, 2026 13:48
@spalladino spalladino added the ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure label Mar 16, 2026
@spalladino spalladino merged commit c10ca4f into v4 Mar 16, 2026
18 of 20 checks passed
@spalladino spalladino deleted the palla/fix/finalized-block-lookback branch March 16, 2026 15:07
AztecBot added a commit that referenced this pull request Mar 17, 2026
PR #21597 increased the finalized block lookback from epochDuration*2
to epochDuration*2*4. This caused the finalized block number to jump
backwards past blocks that had already been pruned from world-state,
causing advance_finalized_block to fail with 'Failed to read block data'.

Two fixes:
1. TypeScript: clamp blockNumber to oldestHistoricalBlock before calling
   setFinalized, so we never request a pruned block.
2. C++: reorder checks in advance_finalized_block to check the no-op
   condition (already finalized past this block) before attempting to
   read block data. This makes the native layer resilient to receiving
   a stale finalized block number.
PhilWindle added a commit that referenced this pull request Mar 17, 2026
## Summary

PR #21597 increased the finalized block lookback from `epochDuration*2`
to `epochDuration*2*4`, which caused the finalized block number to jump
backwards past blocks already pruned from world-state. The native
`advance_finalized_block` then failed trying to read pruned block data,
crashing the block stream with:
```
Error: Unable to advance finalized block: 15370. Failed to read block data. Tree name: NullifierTree
```

Two fixes:
- **TypeScript** (`server_world_state_synchronizer.ts`): Clamp the
finalized block number to `oldestHistoricalBlock` before calling
`setFinalized`, so we never request a pruned block.
- **C++** (`cached_content_addressed_tree_store.hpp`): Reorder checks in
`advance_finalized_block` to check the no-op condition
(`finalizedBlockHeight >= blockNumber`) before attempting
`read_block_data`. This makes the native layer resilient to stale
finalized block numbers.

Full analysis:
https://gist.github.com/AztecBot/6221fb074ed7bbd8a753ec3602133b42

ClaudeBox log: https://claudebox.work/s/8e97449f22ba9343?run=1
AztecBot added a commit that referenced this pull request Mar 17, 2026
PR #21597 increased the finalized block lookback from epochDuration*2
to epochDuration*2*4. This caused the finalized block number to jump
backwards past blocks that had already been pruned from world-state,
causing advance_finalized_block to fail with 'Failed to read block data'.

Two fixes:
1. TypeScript: clamp blockNumber to oldestHistoricalBlock before calling
   setFinalized, so we never request a pruned block.
2. C++: reorder checks in advance_finalized_block to check the no-op
   condition (already finalized past this block) before attempting to
   read block data. This makes the native layer resilient to receiving
   a stale finalized block number.
AztecBot pushed a commit that referenced this pull request Mar 17, 2026
## Summary

PR #21597 increased the finalized block lookback from `epochDuration*2`
to `epochDuration*2*4`, which caused the finalized block number to jump
backwards past blocks already pruned from world-state. The native
`advance_finalized_block` then failed trying to read pruned block data,
crashing the block stream with:
```
Error: Unable to advance finalized block: 15370. Failed to read block data. Tree name: NullifierTree
```

Two fixes:
- **TypeScript** (`server_world_state_synchronizer.ts`): Clamp the
finalized block number to `oldestHistoricalBlock` before calling
`setFinalized`, so we never request a pruned block.
- **C++** (`cached_content_addressed_tree_store.hpp`): Reorder checks in
`advance_finalized_block` to check the no-op condition
(`finalizedBlockHeight >= blockNumber`) before attempting
`read_block_data`. This makes the native layer resilient to stale
finalized block numbers.

Full analysis:
https://gist.github.com/AztecBot/6221fb074ed7bbd8a753ec3602133b42

ClaudeBox log: https://claudebox.work/s/8e97449f22ba9343?run=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants