Repository navigation
feat(watch): finalize at the chain's finalized block, not a configured depth - #121
Merged
Merged
Conversation
…d depth The watch requests the "finalized" block after each new block (and each catch-up batch), drops its local chain up to it, and emits a Finalized message. The runtime finalizes settlement blocks at or below it. Removes confirmations.finalizedBlockDepth. Dev Anvil uses --slots-in-an-epoch 1 so it finalizes two blocks behind; the sim chain answers "finalized" from its own reorg bound per node view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…startup
Also reports a missing "finalized" block as BlockNotFoundError instead of
throwing on BigInt("finalized"), and splits finalized settlement blocks
by number up front.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A watch behind the chain by more than the finality distance always saw a finalized block ahead of its tip, so it never finalized. Seeds 0x10, 0x13, 0x20, 0x22, 0x23 and 0x2c stalled without reorgs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Requesting it before latest means the chain caught up to latest holds it, so the watch needs no finalized target to wait on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Finalizes at the chain's
"finalized"block instead of a configuredconfirmations.finalizedBlockDepth.watch.ts): each poll requests"finalized"before"latest", so once the chain has caught up tolatestit holds the finalized block. After reconciling (and after each catch-up batch) it drops the blocks up to that block and emits a newFinalizedmessage. A finalized block not in the chain (a provider ahead of the one that servedlatest, or a fork not yet reorged out) is skipped until a later poll.maxChainDepthis removed.typewriter.ts): onFinalized, every settlement block at or below it is finalized, after the existing canonical-hash check.nextBlockStatusis removed."finalized"block.confirmations.finalizedBlockDepthis removed (breaking).null"finalized"block now fails withBlockNotFoundErrorinstead of throwing onBigInt("finalized").--slots-in-an-epoch 1, so it finalizes 2 blocks behind latest instead of 64.SIM.chain.finalizedBlockDepth. The sim chain answers"finalized"as the highest head at each node's view time minus that depth, which matches its reorg bound. (Anvil's own"finalized"doesn't bound reorgs.)Testing
reorgRate: [0], local edit only): 30/30 seeds (0x10–0x2d) pass. An earlier version that requested"finalized"after catching up stalled 6 of those seeds: a watch behind the chain by more than the finality distance always saw the finalized block ahead of its tip. The same 6 seeds pass on main.feat/reorg-handling.Notes
eth_getBlockByNumberper poll, including idle polls.latest, so a reorg of the start block is still unrecoverable, as before.feat/reorg-handlingin the runtime's watch consumer.🤖 Generated with Claude Code