Skip to content

feat(consensus): gate inactive sequencer historical EL startup - #6713

Draft
wlawt wants to merge 7 commits into
mainfrom
feat/sequencer-historical-el-startup
Draft

wlawt wants to merge 7 commits into
mainfrom
feat/sequencer-historical-el-startup

Conversation

@wlawt

@wlawt wlawt commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Inactive sequencers need a serialized historical EL-sync phase before they can safely resume production. A prior VALID response or the engine's one-shot completion flag cannot authorize a new target.

Changes

  • Add target-specific startup confirmation before ordinary bootstrap or engine draining. Require stopped regular sequencing, caller-authenticated targets and no outstanding build jobs. This parent draft adds no CLI, public RPC or default change; stacked feat(consensus): expose stopped historical EL startup target #6714 supplies the opt-in operator flag.
  • Cover the actual authenticated-gossip router, including retargeting beyond the active gap window, immediate readiness revocation, ignored old/duplicate/undecodable payloads and no payload insertion.
  • Log successful one-time cold-entry admission with the fixed message Historical startup phase starting and structured target block/hash plus local head.
  • Enforce non-leadership at entry, every probe and immediately before handoff. Use named historical errors with original sources, named phase/probe budgets and an explicit readiness invalidation method.
  • Reject builds/admin activation and defer the stopped actor's initial reset. Startup rejection replies are nonblocking, including full response channels; ordinary engine work stays excluded.
  • Repeat only SYNCING observations. A label FCU returning SYNCING commits no state or notifications and resumes target confirmation at the normal cadence within the original 600-second deadline. Invalid statuses, transport/selection errors, deadlines and delivery failures are terminal and end the coordinator/engine actor without releasing activation.
  • Refuse a single-use target before any startup FCU when the local EL head is already at or above it, including equal-height conflicts. Missing heads also fail closed. Share one-time admission across task entry and public pre-start probes; do not reapply it after synchronization has begun. No ancestry-based skip is assumed.
  • After canonical target and label VALID, commit labels, record the reset outcome, and queue derivation reset/completion before releasing normal routing. Skip redundant ordinary-bootstrap queries after successful handoff. Sequencing stays stopped until normal admin activation.

Not proven

  • Checkpoints for the selected safe/finalized heads are written unconditionally at handoff. This does not implement feat(consensus): resume derivation from an EL-sync anchor #6665 offset-anchor validation or its persistence guard.
  • A conductor election during the handoff walk/delivery remains unfenced despite the extra pre-handoff check. Manual activation still performs its normal leadership check.
  • Timeout or channel failure after engine-state commit can leave partial internal progress. Those failures terminate the phase rather than retrying the committed handoff.
  • Sync-status may expose constructor/stale heads until handoff; an unconfirmed remote target is not seeded as executed local state.
  • Signer authentication does not establish ancestry, freshness or conflict policy. Full pipeline-processing acknowledgement, live re-entry, stale-build cancellation, arbitrary peer history availability and hours-old recovery remain outside this proof.
  • The earlier real local experiment with feat(consensus): expose stopped historical EL startup target #6714 showed a 614-second recovery, peer fetching, derivation progress and one successful canonical build after activation. It predates this fix round. A later invalid-forkchoice crash also occurred unflagged and is investigated separately; stable repeated activation is not claimed.

Tests

Test Name Description
Gossip branch mutation historical_startup_gossip_retarget_revokes_readiness went RED when the actual retarget branch was disabled, then GREEN when restored. Checks immediate invalidation, exact next target/no attributes and no payload insertion.
Entry leadership mutation historical_startup_entry_admission_precedes_probe_admission went RED with the entry block removed, despite the old leader test remaining green. Ordered follower-at-entry then leader-at-probe requires zero FCUs.
Label SYNCING regression historical_startup_label_syncing_defers_handoff was RED before implementation. Pending leaves state and notifications unchanged; invalid and transport errors remain typed and terminal.
Label retry lifecycle and deadline VALID/SYNCING/VALID/VALID requires exactly four FCUs and one notification sequence. A paused-clock test ends continued syncing at the original phase deadline with the gate retained.
Stale-target restart regression At/equal-conflict/past-head cases refuse task entry and public pre-start probing with zero FCUs. RED before task guard and again before the shared public-probe guard.
Full response channels and missing state Nonblocking activation/build/reset replies, unselected public probe and missing-head fail-closed behavior are covered.
Check, library suites, strict lint Passed check, 147 engine tests, 458 node tests and Clippy with -D warnings; four test threads. Existing fixed-port8080 RPC launch test excluded because an unrelated process owns its port; the unfiltered suite was not rerun for this round.
Operator-entry follow-up Parent admission log merged into #6714; actual constructor mutation and rendered-help regression pass there. Current unified-feature stack check, CLI145/engine154/node478 library tests and all-targets Clippy -D warnings passed; CLI1 ignored and node1 fixed-port exclusion remain.
Dependency policy and whitespace Passed. No formatting command run; formatting remains with the user.

Evidence: /tmp/sequencer-el-sync/fix-round1/review-response1.md, with durable RED/GREEN logs and exact final head/results. Everything remains draft. No new real-node experiment or full pipeline acknowledgement is claimed for these fixes.

@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
1 if authored by an app that is not allowlisted and lacks verified human attribution 0
Sum 1

/// and unexpected statuses leave readiness pending. A timeout may follow an EL side effect;
/// callers must reconfirm state rather than assume the request did not execute. No automatic
/// retries or engine resets occur here.
pub async fn probe<C: EngineClient>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This sets up a second FCU-confirmation path next to Engine::probe_el_sync (task_queue/core.rs), which the sequencer coordinator and engine processor already call. That method also sends a forced, attribute-free FCU on every call and treats VALID/SYNCING the same way. The new path drifts from it in three ways:

  • It doesn't classify INVALID_FORK_CHOICE_STATE.
  • It doesn't publish anything on state_sender.
  • It leaves EngineState.sync_state alone.

That last point matters most. A VALID FCU is not read-only: it makes target the EL's canonical head, and the CL's unsafe_head doesn't move to match. Once this is wired in, the CL and EL can disagree about the head, and derivation or the next SynchronizeTask will act on a stale view.

Since nothing calls this type yet, I'd suggest leaving it out until there's a caller. When there is one, extend probe_el_sync, for example with an optional timeout and a target-scoped result, instead of keeping a separate implementation.

@wlawt wlawt changed the title feat(consensus): prototype target-specific sequencer EL startup confirmation feat(consensus): gate inactive sequencer historical EL startup Nov 23, 2026
}
_ = interval.tick() => {
let remaining = deadline.saturating_duration_since(TokioInstant::now()).min(SEQUENCER_EL_SYNC_PROBE_INTERVAL);
let status = self.probe_historical_startup(remaining).await?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Startup failures shut down the node, not just the startup phase. The PR description says non-SYNCING probe failures "end the phase without releasing activation". In practice, any probe_historical_startup error propagates through ?, out of run_historical_startup, and out of the coordinator task in start. The same happens when the handoff times out and when the hard-coded 600s deadline expires. EngineActor's handle_task_result then cancels the shared cancellation token, which stops the whole node.

Errors that trigger this:

  • one fork_choice_updated_v3 call taking longer than 5s, which is plausible while reth is busy with historical sync;
  • one transport error;
  • one conductor leader() error or timeout, checked on every tick;
  • the 600s deadline running out, which a real historical backfill will almost always exceed.

Today nothing calls this API, so it can't halt anything yet. Once it is wired up, though, an inactive sequencer becomes a node that exits on any transient EL or conductor problem during catch-up.

Suggested fix:

  • Classify transient failures (timeouts, transport errors, conductor errors) and retry them on the next tick, or keep the gate closed without returning from start.
  • Replace the 600s literal with a named constant, or a config value tied to the expected backfill time.
  • Add a test asserting that a probe timeout or RPC error leaves the coordinator task running.

match base_protocol::L2BlockInfo::from_payload_and_genesis(
envelope.execution_payload, envelope.parent_beacon_block_root, &self.processor.rollup().genesis,
) {
Ok(target) if target != phase.target() => phase.set_target(target),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Startup may never converge at the chain tip. Every gossip payload at or above the target moves the target to that block's hash, but the payload itself is never sent to the EL with newPayload; it is simply dropped. Near the tip, a new block arrives every 2s and the probe runs every 5s, so each probe FCU names a block the EL hasn't seen. Reth answers an unknown head with SYNCING and starts downloading it. By the next tick the target has moved again.

So the probe can keep returning SYNCING indefinitely, and the 600s deadline then turns that into node shutdown (see the comment on line 245).

Suggested fix: either insert the authenticated gossip payloads during startup, or stop moving the target once the EL is close to the tip. The mocked FCU tests can't catch this, so it needs coverage that simulates a moving tip.

/// Admission failure revokes earlier readiness. The old engine completion latch is not used.
pub async fn probe_historical_startup(&mut self, remaining: Duration) -> Result<base_consensus_engine::StartupSyncStatus, EngineError> {
let started = TokioInstant::now();
let phase = self.historical_startup.as_mut().expect("historical startup selected");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

probe_historical_startup is a pub API, but it calls expect on historical_startup without checking it. A caller that probes before begin_historical_startup (or after a completed handoff, which resets it to None) panics instead of getting an error back. Return a named EngineError instead.

}
let update = EngineSyncStateUpdate { unsafe_head: Some(target), local_safe_head: Some(start.safe), safe_head: Some(start.safe), finalized_head: Some(start.finalized) };
let proposed = self.engine.state().sync_state.updated(update);
let response = self.client.fork_choice_updated_v3(proposed.create_forkchoice_state(), None).await

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The handoff sends its own label FCU and then commits the labels through accept_confirmed_startup. Engine::probe_el_sync / SynchronizeTask::new_forced already does both, and also handles INVALID_FORK_CHOICE_STATE and engine metrics, so this re-implements it.

Separately, every failure in the handoff gets flattened into BootstrapHeadQuery(String):

  • transport errors;
  • a non-canonical target;
  • a non-VALID FCU status.

That discards the typed error, so a caller can't tell a retryable failure from a terminal one. Reuse probe_el_sync, and add distinct EngineError variants for these cases.

}
// Normal routing starts only after canonical reset and completion delivery.
self.historical_startup = None;
self.complete_startup(target);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After handoff, complete_startup(target) sets the state to Regular, which skips the CatchingUp gate that a stopped follower normally gets in ordinary bootstrap.

That causes two problems once startup finishes:

  • prepare_sequencer_start only checks el_sync_finished and that the hash matches. Admin activation is accepted at target even when newer canonical payloads have already been observed.
  • Any queued or later gossip more than catchup_capacity blocks ahead is dropped by the Regular gap filter instead of being buffered.

Either can let a stopped node activate on a stale head and reorg canonical blocks. Consider entering CatchingUp here, seeded with gossip observed during the phase, rather than going straight to the completed state.

pub async fn handoff_historical_startup(&mut self, target: L2BlockInfo) -> Result<HistoricalStartupHandoff, EngineError> {
let latest = self.client.l2_block_info_by_label(BlockNumberOrTag::Latest).await
.map_err(|error| HistoricalStartupFailure::HeadQuery(Box::new(error)))?;
if latest != Some(target) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The probe confirms the target by block_info.hash alone, but this check and the start.un_safe != target check compare the whole L2BlockInfo, including l1_origin and seq_num.

So an operator JSON target with the right hash but a wrong origin or sequence number goes like this:

  • The probe returns VALID and makes the target canonical on the EL.
  • The handoff then fails terminally with a misleading "no longer canonical" error.
  • Because the EL head is now at the target, a restart with the same flag fails with ReusedTarget.

Validate the target against the EL's own L2BlockInfo before the first FCU, or compare by hash here and report a field mismatch as its own error.

) -> JoinHandle<Result<(), EngineError>> {
tokio::spawn(async move {
// Bootstrap: pre-populate the unsafe_head_tx watch channel so that external callers
// An explicitly selected historical phase owns the connection before bootstrap.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line was inserted in the middle of the existing bootstrap sentence ("…so that external callers / (admin_startSequencer, sync-status RPC) never observe a zero hash"). That breaks the sentence, and the comment now reads as though the historical phase pre-populates unsafe_head_tx, which it doesn't. Move it above the historical_startup_selected check instead.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary. Earlier review comments still apply to this revision. The most serious ones:

  • Any probe, conductor, handoff or deadline error terminates the coordinator task, which shuts down the whole node.
  • A gossip target that keeps moving may never converge near the tip, because the payloads are never inserted.
  • After handoff the coordinator goes straight to Regular and skips CatchingUp.
  • The handoff compares the full L2BlockInfo while the probe compares only the hash.
  • SequencerStartupSync duplicates Engine::probe_el_sync and the label-commit logic.

No additional halt or stall triggers were found beyond those. Nothing calls the new API yet, so none of this affects running nodes until #6714 wires it up. They should be resolved before then.

New in this pass: one minor inline comment about a misplaced comment line that splits the existing bootstrap explanation.

This branch has not been deployed

No deployments
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.

2 participants