Decouple finalization from head ingestion#499
Open
kalabukdima wants to merge 1 commit into
Open
Conversation
11127c3 to
1bd4f5d
Compare
Part of NET-408
1bd4f5d to
78d3a81
Compare
tmcgroul
approved these changes
Jun 19, 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.
Problem
The EVM hot-block data service spiked block-lag every ~6.4 min, locked to
blockNumber % 32on Ethereum.Root cause: when Ethereum finalizes an epoch (~32 blocks at once), the finalizer pushed a burst of finalized-only batches (
{blocks: [], finalizedHead}) through the same single output queue as head blocks, serializing ahead of head ingestion and stalling the head-poll loop.Fix
Take finalization off the data-loading path (
evm-rpc/src/data-source/finalizer.ts):probe()records the confirmed finalized head inthis.currentand returns — nooutput.put({blocks: [], finalizedHead}).visit()addsthis.currentto each head batch'sfinalizedHead.outputnow carries only head batches; the finalized head rides the next head block. Finality lags the head by ~13 min, so a sub-second delivery delay costs nothing. Probe batch size stays at 5 — the RPC requests are not affected.Benchmark (live Dwellir Ethereum, 3 epochs)
The
%32lock is gone; remaining>5000blocks sit at scattered residues (normal jitter). Finality advances in correct single +32 jumps.Why a stalled head can't starve compaction
chain.push(cache growth),chain.finalize, andchain.compactall run in the same per-head-batch consumer step, so the cache never grows without finality being delivered alongside it. A stalled head stops cache growth too. The only residual effect is the reported finalized head going stale during a head stall — conservative (under-reports finality, never over-reports), therefore safe. Genuine non-finality behaves identically to the old code.