fix: handle missing L1 finalized block on devnets#22663
Merged
spalladino merged 1 commit intomerge-train/spartanfrom Apr 21, 2026
Merged
fix: handle missing L1 finalized block on devnets#22663spalladino merged 1 commit intomerge-train/spartanfrom
spalladino merged 1 commit intomerge-train/spartanfrom
Conversation
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.
03cde8b to
43fc41a
Compare
spypsy
approved these changes
Apr 21, 2026
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.
Motivation
On freshly-started L1 devnets (anvil, local geth/reth/nethermind) there is a startup window during which the
finalizedblock tag is not yet available — calls likegetBlock({ 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
getFinalizedL1Blockhelper in@aztec/ethereum/queriesthat returnsundefinedwhen 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-32000surfaced by geth/reth/nethermind). All three production call sites now handleundefinedgracefully: 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
getFinalizedL1Blockhelper andisFinalizedBlockTagNotFoundErrorpredicate inqueries.ts.updateFinalizedCheckpointuses the helper and returns early with a trace log instead of warning; removed the old"returned no data"substring workaround.refreshStaleEntryandfetchAndCacheuse the helper and guard thesamplingTs <= finalizedBlock.timestampcomparison so entries stay unfinalized when L1 has none yet.FakeL1Stateconfigured with no finalized block, and an epoch-cache test asserting entries stay unfinalized and keep refreshing.