Skip to content

fix(engine-api): never assemble a block older than its parent - #221

Merged
panos-xyz merged 3 commits into
mainfrom
fix/clamp-assembled-block-timestamp
Nov 11, 2026
Merged

panos-xyz merged 3 commits into
mainfrom
fix/clamp-assembled-block-timestamp

Conversation

@panos-xyz

Copy link
Copy Markdown
Contributor

Summary

  • The CL passes time.Now().Unix() as the timestamp of every engine_assembleL2BlockV2 call, and build_l2_payload used it unchanged. The max(parent + 1, now) default only applied when no timestamp was passed.
  • When the sequencer's clock is behind its parent's timestamp (the clock steps back, or HA leadership moves to a node whose clock lags the previous leader's by more than the handover takes), the assembled block has timestamp < parent.timestamp. Followers reject it with TimestampIsInPast. The sequencer does not: the built payload is already in the engine tree, so its own engine_newL2BlockV2 returns through the already-seen path without header validation, the block becomes canonical and the sequencer keeps building on it.
    • Single sequencer: every follower stalls at the parent.
    • HA: each follower's FSM apply fails and panics by design, and a restarted follower applies the same committed entry again, so the cluster stalls.
  • Assembly now raises the requested timestamp to the earliest one the header rules accept: the parent's own timestamp from Emerald on (equal timestamps are valid and already common with sub-second blocks), one second past it before Emerald. That is the minimum valid value, so a lagging clock holds block timestamps at the parent's until it catches up instead of producing a block nobody else accepts.
  • engine_newSafeL2Block is unchanged: derivation rebuilds blocks already committed to L1 and must reproduce them exactly.
  • A warning is logged whenever a timestamp is raised, since it means the sequencer's clock is behind.

morph-geth after Emerald has the same exposure (its worker raises a stale timestamp to parent + 1, but Prepare then caps it at the local clock, and the leader skips verification of its own block), so this is not a regression of the migration, but the reth sequencer no longer has it.

Tests

  • Unit (morph-engine-api): payload_timestamp raises assembly timestamps behind the parent (to the parent's from Emerald on, one second past it before), keeps valid ones, keeps derivation timestamps as given, and keeps the max(parent + 1, now) default.
  • e2e (engine.rs, two nodes): assemble_l2_block_v2_raises_timestamp_behind_parent (all forks active) and assemble_l2_block_v2_raises_timestamp_past_parent_before_emerald (pre-Emerald schedule). Block 2 is assembled with a timestamp five seconds behind block 1, comes back at block 1's timestamp (one second later before Emerald), and becomes canonical on both the sequencer and a follower. With the fix reverted both fail on the timestamp assertion: the block comes back with the requested timestamp (5) instead of 10 / 11.
  • make lint, make clippy-e2e, cargo test --doc --all (6 passed), make test (910 passed), make test-e2e (130 passed).

Scope

Found in the pre-migration sequencer/validator audit (SEQB-01 / SEQ-ENG-01). This PR only fixes the timestamp. The sequencer still imports the payloads it builds through the already-seen path without header or pre-execution validation, so any other disagreement between the builder and the consensus rules (for example a --morph.max-tx-payload-bytes above the consensus limit) would still reach followers unchecked.

The CL passes its wall-clock second as the timestamp of every assembled
block, and the engine API used it as given. When the sequencer's clock
steps back, or HA leadership moves to a node whose clock is behind, that
second falls below the parent's timestamp. Every follower rejects such a
block (TimestampIsInPast), but the sequencer imports the payload it built
through the already-seen path without re-validating the header, so it
makes the block canonical and keeps building on it: the chain splits.
Under HA the followers' FSM panics on the failed apply and the cluster
stalls.

Raise the requested timestamp to the earliest one the header rules
accept: the parent's own timestamp from Emerald on, one second later
before it. Only sequencer assembly is adjusted; newSafeL2Block rebuilds
blocks already committed to L1 and keeps their timestamps as given. A
warning is logged whenever a timestamp is raised, since it means the
sequencer clock is behind.
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a5fc59a-066c-420f-a370-b32391ef7457
Commits

Reviewing files that changed from the base of the PR and between 7cf90e3 and 4d0a258.

Files selected for processing: 4

  • crates/engine-api/src/api.rs
  • crates/engine-api/src/builder.rs
  • crates/node/tests/it/engine.rs
  • crates/payload/types/src/params.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@panos-xyz
panos-xyz requested a review from dylanCai9 November 9, 2026 13:41

@dylanCai9 dylanCai9 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review 7512ad8

@curryxbo curryxbo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@panos-xyz
panos-xyz merged commit 0f60520 into main Nov 11, 2026
12 checks passed
@panos-xyz
panos-xyz deleted the fix/clamp-assembled-block-timestamp branch November 11, 2026 03:39
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