Skip to content

fix: skip handleChainFinalized when block is behind oldest available#21656

Merged
PhilWindle merged 1 commit intomerge-train/spartanfrom
claudebox/8e97449f22ba9343-4
Mar 17, 2026
Merged

fix: skip handleChainFinalized when block is behind oldest available#21656
PhilWindle merged 1 commit intomerge-train/spartanfrom
claudebox/8e97449f22ba9343-4

Conversation

@AztecBot
Copy link
Collaborator

Summary

Follow-up to #21643. The clamping fix avoided the setFinalized error, but the method continued into the pruning logic where removeHistoricalBlocks failed with:

Unable to remove historical blocks to block number 15812, blocks not found. Current oldest block: 15812

Two changes:

  • When the finalized block is older than oldestHistoricalBlock, return early instead of clamping and continuing. There's nothing useful to do — world-state is already finalized past this point.
  • Guard removeHistoricalBlocks against being called with a block <= oldestHistoricalBlock, which the C++ layer rejects.

The C++ reorder fix from #21643 is preserved.

ClaudeBox log: https://claudebox.work/s/8e97449f22ba9343?run=4

@AztecBot AztecBot added the claudebox Owned by claudebox. it can push to this PR. label Mar 17, 2026
When the finalized block jumps backwards past pruned state, return early
instead of clamping and continuing into the pruning logic. The previous
clamping fix avoided the setFinalized error but then removeHistoricalBlocks
would fail trying to prune to a block that is already the oldest.

Also guard removeHistoricalBlocks against being called with a block number
that is not newer than the current oldest available block.
@AztecBot AztecBot force-pushed the claudebox/8e97449f22ba9343-4 branch from b627036 to 7cdaafc Compare March 17, 2026 09:36
@PhilWindle PhilWindle marked this pull request as ready for review March 17, 2026 09:41
@PhilWindle PhilWindle enabled auto-merge March 17, 2026 09:41
@PhilWindle PhilWindle disabled auto-merge March 17, 2026 09:42
@PhilWindle PhilWindle enabled auto-merge March 17, 2026 09:42
@PhilWindle PhilWindle merged commit fac513c into merge-train/spartan Mar 17, 2026
24 of 28 checks passed
@PhilWindle PhilWindle deleted the claudebox/8e97449f22ba9343-4 branch March 17, 2026 09:59
AztecBot pushed a commit that referenced this pull request Mar 17, 2026
…21656)

## Summary

Follow-up to #21643.
The clamping fix avoided the `setFinalized` error, but the method
continued into the pruning logic where `removeHistoricalBlocks` failed
with:
```
Unable to remove historical blocks to block number 15812, blocks not found. Current oldest block: 15812
```

Two changes:
- When the finalized block is older than `oldestHistoricalBlock`, return
early instead of clamping and continuing. There's nothing useful to do —
world-state is already finalized past this point.
- Guard `removeHistoricalBlocks` against being called with a block `<=
oldestHistoricalBlock`, which the C++ layer rejects.

The C++ reorder fix from #21643 is preserved.

ClaudeBox log: https://claudebox.work/s/8e97449f22ba9343?run=4
@AztecBot
Copy link
Collaborator Author

✅ Successfully backported to backport-to-v4-staging #21651.

alexghr added a commit that referenced this pull request Mar 17, 2026
BEGIN_COMMIT_OVERRIDE
fix(aztec-nr): return Option from decode functions and fix event
commitment capacity (backport #21264) (#21360)
fix: backport #21271 — handle bad note lengths on
compute_note_hash_and_nullifier (#21364)
fix: not reusing tags of partially reverted txs (#20817)
chore: revert accidental backport of #20817 (#21583)
feat: Implement commit all and revert all for world state checkpoints
(#21532)
cherry-pick: fix: dependabot alerts (#21531)
fix: dependabot alerts (backport #21531 to v4) (#21592)
fix: backport #21443 — Don't update state if we failed to execute
sufficient transactions (v4) (#21610)
chore: Fix msgpack serialisation (#21612)
fix(p2p): fall back to maxTxsPerCheckpoint for per-block tx validation
(#21605)
chore: merge v4 into backport-to-v4-staging (#21618)
fix(revert): avm sim uses event loop again (#21138) (#21630)
fix(e2e): remove historic/finalized block checks from epochs_multiple
test (#21642)
fix: clamp finalized block to oldest available in world-state (#21643)
fix: skip handleChainFinalized when block is behind oldest available
(#21656)
chore: demote finalized block skip log to trace (#21661)
fix: off-by-1 in getBlockHashMembershipWitness archive snapshot
(backport #21648) (#21663)
fix: capture txs not available error reason in proposal handler (#21670)
chore: add L1 inclusion time to stg public (#21665)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Jan Beneš <janbenes1234@gmail.com>
Co-authored-by: PhilWindle <60546371+PhilWindle@users.noreply.github.com>
Co-authored-by: Phil Windle <philip.windle@gmail.com>
Co-authored-by: Santiago Palladino <santiago@aztecprotocol.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: ludamad <adam.domurad@gmail.com>
Co-authored-by: Alex Gherghisan <alexghr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v4 claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants