Skip to content

fix: handle missing L1 finalized block on devnets#22663

Merged
spalladino merged 1 commit into
merge-train/spartanfrom
spl/fix/handle-missing-l1-finalized-block
Apr 21, 2026
Merged

fix: handle missing L1 finalized block on devnets#22663
spalladino merged 1 commit into
merge-train/spartanfrom
spl/fix/handle-missing-l1-finalized-block

Conversation

@spalladino

Copy link
Copy Markdown
Contributor

Motivation

On freshly-started L1 devnets (anvil, local geth/reth/nethermind) there is a startup window during which the finalized block tag is not yet available — calls like getBlock({ blockTag: 'finalized' }) fail with a JSON-RPC error instead of returning a block. The archiver currently logs noisy warnings during this window and epoch-cache would crash dereferencing the missing block's timestamp.

Approach

Added a shared getFinalizedL1Block helper in @aztec/ethereum/queries that returns undefined when the chain has no finalized block yet, distinguishing that specific failure from other RPC errors by walking the viem error chain for the "finalized|safe block not found" message (the code -32000 surfaced by geth/reth/nethermind). All three production call sites now handle undefined gracefully: the archiver skips the finalized checkpoint update, and epoch-cache treats entries as "not finalized yet" so they continue to refresh on TTL until the L1 chain catches up.

Changes

  • ethereum: New getFinalizedL1Block helper and isFinalizedBlockTagNotFoundError predicate in queries.ts.
  • archiver: updateFinalizedCheckpoint uses the helper and returns early with a trace log instead of warning; removed the old "returned no data" substring workaround.
  • epoch-cache: refreshStaleEntry and fetchAndCache use the helper and guard the samplingTs <= finalizedBlock.timestamp comparison so entries stay unfinalized when L1 has none yet.
  • tests: Unit tests for the helper/predicate, an archiver sync test using FakeL1State configured with no finalized block, and an epoch-cache test asserting entries stay unfinalized and keep refreshing.

@spalladino spalladino requested a review from alexghr April 20, 2026 14:19
Adds getFinalizedL1Block helper that returns undefined when the L1 chain
does not yet have a finalized block (common on freshly-started devnets)
and uses it in the archiver and epoch-cache call sites.
@spalladino spalladino force-pushed the spl/fix/handle-missing-l1-finalized-block branch from 03cde8b to 43fc41a Compare April 20, 2026 14:27
@spalladino spalladino merged commit dbf8b95 into merge-train/spartan Apr 21, 2026
12 checks passed
@spalladino spalladino deleted the spl/fix/handle-missing-l1-finalized-block branch April 21, 2026 12:06
chrismarino pushed a commit to chrismarino/aztec-packages that referenced this pull request May 5, 2026
BEGIN_COMMIT_OVERRIDE
fix(kv-store): ensure LMDB cursor is closed on iteration abort (AztecProtocol#22509)
fix(telemetry-client): use appropriate histogram buckets for L1 gas
prices (AztecProtocol#22512)
fix(telemetry-client): log warning when BatchSpanProcessor drops spans
(AztecProtocol#22511)
fix(stdlib): wrap HA signer databaseUrl in SecretValue (AztecProtocol#22510)
fix(prover-client): don't mark in-progress epoch N jobs as stale when
epoch N+1 starts (AztecProtocol#22508)
chore: (A-730) graceful shutdown for services in node startup failure
path (AztecProtocol#22112)
fix(prover-client): reject stale job promises and count timeouts toward
retry limit (AztecProtocol#21842)
feat(archiver): validate historical L1 log availability at startup
(AztecProtocol#22644)
fix(archiver): do not query MessageSent events by blockhash (AztecProtocol#22641)
refactor(e2e): skip initial sequencer in p2p and epochs tests (AztecProtocol#22535)
fix: handle missing L1 finalized block on devnets (AztecProtocol#22663)
fix(world-state): treat historical block 0 queries as historical, not
latest (AztecProtocol#22679)
fix(sequencer): re-check parent checkpoint validity before pipelined L1
submission (AztecProtocol#22586)
fix(world-state): make block 0 a first-class historical block (AztecProtocol#22711)
chore: show all running versions (AztecProtocol#22376)
chore: fix prettier inside worktrees (AztecProtocol#22557)
feat: use optimized verifier for rollup (AztecProtocol#21840)
fix(kv-store): skip pool creation on ephemeral deleteDb to unstick
browser tests (AztecProtocol#22693)
chore: rm claude lockfile (AztecProtocol#22718)
fix(e2e): wait for first checkpoint in fee_asset_price_oracle_gossip
test (AztecProtocol#22719)
chore(prover-node): track estimated L1 fee when proof publishing is
disabled (AztecProtocol#22691)
fix(ci): rerun squashed PR check on base branch change (AztecProtocol#22713)
feat(archiver): decouple calldata from blob fetching in L1 synchronizer
(AztecProtocol#22716)
refactor(e2e): enable pipelining in e2e_epochs tests (AztecProtocol#22544)
feat(p2p): reject and evict txs with insufficient max fee per gas
(AztecProtocol#22118)
refactor(world-state): always index block 0 regardless of initial tree
size (AztecProtocol#22724)
fix(e2e): fix redistribution test (AztecProtocol#22729)
END_COMMIT_OVERRIDE
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