Skip to content

fix(consensus): size sequencer catch-up buffer for fast block times - #6320

Merged
niran merged 6 commits into
mainfrom
fix/sequencer-catchup-buffer-fast-blocks
Nov 5, 2026
Merged

niran merged 6 commits into
mainfrom
fix/sequencer-catchup-buffer-fast-blocks

Conversation

@niran

@niran niran commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Followers that restart under fast block times can fall outside the sequencer catch-up buffer and never finish catching up.

The canonical catch-up buffer (CanonicalUnsafeCatchup) and the regular-state external gossip gap both reused the shadow reconciliation cycle limit of 300 blocks. That is ten minutes at two-second blocks but one minute at 200 ms blocks. A follower that restarts several minutes behind advances only through L1 derivation, and derivation latency (batch submission, L1 inclusion, derivation) leaves its safe head more than 300 blocks behind the newest gossip. The oldest retained payload is then never adjacent to the safe head, the contiguous suffix never connects, and catch-up stays stuck.

Changes

  • Decouple the catch-up capacity from SequencerConfig::MAX_SHADOW_BLOCKS_PER_CYCLE, which keeps governing shadow reconciliation cycles.
  • Size the catch-up buffer as a ten-minute window divided by the block interval, computed once from the rollup config: 3,000 payloads at 200 ms (about 9.5x the 314-block lag observed in practice) and 300 at two-second blocks, so memory scales with throughput rather than block rate. A chain with Denim scheduled uses the 200 ms cadence.
  • Use the same capacity for the regular-state external unsafe gossip gap, which had the same race (formerly a separate constant of 300).
  • Clamp the computed capacity to at least one payload.
  • Apply buffered payloads in batches of at most 300 so the engine loop can serve other requests between batches.

Notes

  • Regular-state gossip up to the new gap (ten minutes of blocks) may be inserted with its parent missing. The execution client then answers Syncing, the consensus layer keeps its confirmed unsafe head unchanged, and the execution client may start a backfill. The old 300-block gap at two-second blocks already allowed the same ten-minute lead, so the gap stays scaled to the block cadence rather than staying at 300 blocks, which would be a liveness regression on fast-block chains.
  • Resource cost: the buffer holds up to 3,000 payloads (ten times more than before at 200 ms), and memory is bounded by throughput over the ten-minute window rather than by block rate. Buffered payloads are applied in batches of at most 300, cloning only the current batch, and the engine loop serves queued requests between batches. A failed batch resumes after the payloads the engine already applied.
  • Measured on a sample of 26 recent Base mainnet blocks (2 s cadence): mean 134 KB, median 128 KB, max 283 KB per block. A 200 ms block carries about a tenth of that, so 3,000 payloads is on the order of 40 MB typical and under 200 MB at several times the sampled maximum, before the suffix clone made when applying. A byte cap is not needed for this window.
  • Exposure: on high-traffic chains batches close on size and land often, so the remaining risk is lag from L1 inclusion and confirmations compared with the old 60 s window at 200 ms blocks; the ten-minute window covers that with wide margin.
  • Chains with one-second blocks and no Denim go from 300 to 600 payloads.
  • Larger alternatives (chunked replay, execution-layer sync for regular followers with large gaps) are not part of this change.

Test plan

  • New unit tests fail with the old 300-payload window (verified by shrinking the window to 60 s): a restarted follower 314 blocks behind connects to the buffer and completes catch-up; capacity per block time (200 ms, two-second, Denim scheduled, very long intervals); capacity bound is respected.
  • New buffer tests: the full window is applied in bounded batches, and a retry after a failed batch resumes after the applied prefix.
  • New coordinator test: regular-state gossip 301 and 2,999 blocks ahead is admitted, 3,001 is dropped.
  • cargo test -p base-consensus-node --lib (419 passed) and cargo clippy -p base-consensus-node --all-targets -- -D warnings pass.

type=routine
risk=medium
impact=sev5

niran and others added 3 commits October 30, 2026 11:17
The catch-up buffer and the regular-state external gossip gap reused the
shadow reconciliation cycle limit of 300 blocks. That is ten minutes at
two-second blocks but only one minute at 200ms blocks, so a follower that
restarts behind the tip can finish derivation still more than 300 blocks
behind the newest gossip and never connect to the buffer.

Decouple the catch-up capacity from the shadow cycle limit and size it as
a ten minute window divided by the block interval, computed once from the
rollup config. The regular-state gossip gap uses the same capacity.

Co-authored-by: Toshi <[email protected]>
@depot-code-access

depot-code-access Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

✅ All benchmarks green — 16 within ±2% (deterministic instruction counts). View run

Benchmark details (16)
Benchmark Base (target) Head (this PR) Δ instructions
batch_queue/drain/drain_cached_span_batches 242,027 242,027 +0.0%
batch_transaction/encode_in_place/encode_in_place 4,199,759 4,199,759 +0.0%
batch_transaction/temporary_frame_buffers/temporary_frame_buffers 8,408,350 8,408,350 +0.0%
build_loop/mainnet_block/enforce 264,440,116 264,376,090 -0.0%
build_loop/mainnet_block/off 330,930,985 331,029,188 +0.0%
flashblock_decode/decode/brotli 3,296,484 3,296,484 +0.0%
flashblock_decode/decode/plain_json 2,280,194 2,280,194 +0.0%
flz/compress_len/real_contract_call 43,148 43,148 +0.0%
flz/compress_len/synthetic_0 38,205 38,205 +0.0%
flz/compress_len/synthetic_1 54,682 54,682 +0.0%
flz/compress_len/synthetic_2 147,976 147,976 +0.0%
flz/data_gas 43,059 43,059 +0.0%
flz/tx_estimated_size 43,056 43,056 +0.0%
frame_parse/decode/single_4kib 1,031 1,031 +0.0%
frame_parse/parse_frames/few_large 1,053,062 1,053,062 +0.0%
frame_parse/parse_frames/many_small 154,763 154,763 +0.0%

@cb-heimdall

cb-heimdall commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Heimdall Review Status

Requirement Status More Info
Reviews ✅ 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
1 if authored by an app that is not allowlisted and lacks verified human attribution 0
Sum 1

@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@depot-code-access

depot-code-access Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Acceptance Tests: ✅ Passed

3/3 checks passed · Checks & reports

Acceptance report
  • smoke / chain-identity — passed: chain identity matched
    • Expected: 84538453
    • Observed: 84538453
  • smoke / production — passed: head advanced
    • Expected: {"minimum_blocks":3}
    • Observed: {"delta":3,"from":13,"last":16,"required_delta":3}
  • smoke / validator-converges — passed: heads converged on a common canonical block
    • Expected: {"common_height_hash":true,"max_lag_blocks":5}
    • Observed: {"common_height":16,"hash":"0x3fa61824c5dcdcdf37dec905949df941bacefc7c780bfdacd362e760b2ebec26","high":16,"lag":0,"low":16,"low_timestamp":1793380252,"maximum_lag":5,"minimum_timestamp":0}

@niran
niran marked this pull request as ready for review October 30, 2026 19:41
@niran
niran added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit e4fd821 Nov 5, 2026
33 checks passed
@niran
niran deleted the fix/sequencer-catchup-buffer-fast-blocks branch November 5, 2026 18:55
niran added a commit that referenced this pull request Nov 5, 2026
…v1.5.4 backport) (#6321)

* [backport] fix(consensus): size sequencer catch-up buffer for fast block times to v1.5.2 (#6320)

Co-authored-by: Toshi <[email protected]>

* test(consensus): cover regular gossip gap against catch-up window

Co-authored-by: Toshi <[email protected]>

* test(actions): pass catch-up batch limit in shadow sequencer action test

Co-authored-by: Toshi <[email protected]>

---------

Co-authored-by: Toshi <[email protected]>
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.

3 participants