Skip to content

feat(devnet): Start-in-sequencer-mode devnet switch for devnet - #1030

Open
tomatoishealthy wants to merge 1 commit into
mainfrom
feat/devnet-born-as-sequencer
Open

feat(devnet): Start-in-sequencer-mode devnet switch for devnet#1030
tomatoishealthy wants to merge 1 commit into
mainfrom
feat/devnet-born-as-sequencer

Conversation

@tomatoishealthy

@tomatoishealthy tomatoishealthy commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What

Adds an isolated, test-only node/devtool package that lets a node boot directly in sequencer mode — skipping the pre-upgrade PBFT phase — for HA testnet / devnet bring-up. Enabled via --startInSequencerMode / MORPH_NODE_START_IN_SEQUENCER_MODE. Default off, so production and normal devnet runs are unaffected.

Why

Bring up a single-sequencer / HA cluster in a test environment without waiting for the timestamp-driven PBFT→sequencer upgrade, and without deploying a full PBFT validator set. Useful for QA of sequencer behaviour and Grafana panels before the mainnet fork.

How it works

ApplyStartInSequencerMode pre-sets the consensus upgrade block height to 0, so IsUpgraded(1) is true at startup and the node starts the sequencer routines directly (the PBFT consensus reactor never starts). It runs before the upgrade store is wired, so on a fresh DB the value is not persisted and is re-applied on every restart (idempotent).

Changes

  • node/devtool/start_in_sequencer_mode.go (new): flag + ApplyStartInSequencerMode, self-registering via init() so node/flags/flags.go is untouched.
  • node/cmd/node/main.go: one guarded call before SetupNode.
  • docker-compose-cluster.yml / docker-compose-devnet.yml: default the HA cluster to start-in-sequencer-mode and run node-0 as a local-verify P2P follower (test infra).

Safety

TEST/TESTNET-ONLY. Every entry point is guarded and marked "never enable on a production network". No production code path changes when the flag is unset.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a test-only option to start nodes directly in sequencer mode, bypassing the initial PBFT phase.
    • Added configuration controls through CLI flags and environment variables.
    • Updated Docker-based cluster and devnet setups to support direct sequencer startup and local derivation verification.
  • Documentation

    • Added configuration comments describing the test-only behavior and the alternative startup path.

Add an isolated, test-only devtool package that lets a node boot directly in
sequencer mode (skipping the pre-upgrade PBFT phase) for HA testnet / devnet
bring-up. Enabled via --startInSequencerMode / MORPH_NODE_START_IN_SEQUENCER_MODE;
default off, so production and normal devnet runs are unaffected.

- node/devtool/start_in_sequencer_mode.go: flag + ApplyStartInSequencerMode;
  self-registers via init() so node/flags/flags.go is untouched. Pre-sets the
  upgrade block height to 0 so IsUpgraded(1) is true and the node starts the
  sequencer routines directly, never entering the PBFT consensus reactor.
- node/cmd/node/main.go: one guarded call before the upgrade store is wired.
- docker-compose-cluster.yml / docker-compose-devnet.yml: default the HA cluster
  to start-in-sequencer-mode and run node-0 as a local-verify P2P follower.

TEST/TESTNET-ONLY. Never enable on a production network.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@tomatoishealthy
tomatoishealthy requested a review from a team as a code owner August 4, 2026 07:14
@tomatoishealthy
tomatoishealthy requested review from twcctop and removed request for a team August 4, 2026 07:14

@claude claude Bot 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.

Claude Code Review

Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Direct sequencer-mode startup

Layer / File(s) Summary
Startup hook and development flag
node/devtool/start_in_sequencer_mode.go, node/cmd/node/main.go
The node registers startInSequencerMode. When enabled, startup sets the upgrade block height to zero and logs that PBFT will be skipped.
Docker test configuration
ops/docker/docker-compose-cluster.yml, ops/docker/docker-compose-devnet.yml
HA cluster services and the devnet node enable sequencer-mode startup by default. The cluster configuration documents the opt-out setting and devnet enables local derivation verification.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Docker as Docker configuration
  participant Node as node startup
  participant Devtool as ApplyStartInSequencerMode
  participant Upgrade as upgrade state
  Docker->>Node: set MORPH_NODE_START_IN_SEQUENCER_MODE
  Node->>Devtool: apply startup mode
  Devtool->>Upgrade: set upgrade block height to zero
  Devtool->>Node: log direct sequencer-mode startup
Loading

Possibly related PRs

  • morph-l2/morph#939: Both changes modify node startup and sequencer behavior. This PR bypasses the PBFT-to-sequencer path affected by that PR.

Suggested reviewers: twcctop, panos-xyz, curryxbo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: adding a devnet switch to start nodes directly in sequencer mode.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/devnet-born-as-sequencer

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

Comment @coderabbitai help to get the list of available commands.

@tomatoishealthy tomatoishealthy changed the title feat(node): TEST-ONLY start-in-sequencer-mode devnet switch feat(devnet): Start-in-sequencer-mode devnet switch for devnet Aug 4, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@node/devtool/start_in_sequencer_mode.go`:
- Around line 49-53: Update ApplyStartInSequencerMode to reject the
startInSequencerModeFlag when running on a production network before calling
upgrade.SetUpgradeBlockHeight(0). Preserve the existing no-op behavior when the
flag is unset, and use the existing network/environment detection and
error-reporting mechanisms to prevent startup from continuing in production.

In `@ops/docker/docker-compose-devnet.yml`:
- Around line 188-193: Update the node-0 service configuration near
MORPH_NODE_DERIVATION_VERIFY_MODE so MORPH_NODE_SEQUENCER_PRIVATE_KEY is removed
or explicitly overridden, ensuring initL1SequencerComponents does not create a
LocalSigner and node-0 remains a local-verify P2P follower rather than starting
as a sequencer.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 076bcd49-b0f5-4289-9867-123c5ab7f2fa

📥 Commits

Reviewing files that changed from the base of the PR and between fc629c0 and d62afab.

📒 Files selected for processing (4)
  • node/cmd/node/main.go
  • node/devtool/start_in_sequencer_mode.go
  • ops/docker/docker-compose-cluster.yml
  • ops/docker/docker-compose-devnet.yml

Comment on lines +49 to +53
func ApplyStartInSequencerMode(ctx *cli.Context, logger tmlog.Logger) {
if !ctx.GlobalBool(startInSequencerModeFlag.Name) {
return
}
upgrade.SetUpgradeBlockHeight(0)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reject the test-only switch on production networks.

Line 50 accepts this switch for every network. Line 53 then bypasses the PBFT phase. Comments do not enforce the testnet-only restriction.

Reject startup when this switch is set for a production network before upgrade.SetUpgradeBlockHeight(0) runs. This prevents a deployment setting from changing production consensus behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@node/devtool/start_in_sequencer_mode.go` around lines 49 - 53, Update
ApplyStartInSequencerMode to reject the startInSequencerModeFlag when running on
a production network before calling upgrade.SetUpgradeBlockHeight(0). Preserve
the existing no-op behavior when the flag is unset, and use the existing
network/environment detection and error-reporting mechanisms to prevent startup
from continuing in production.

Comment on lines +188 to +193
# TEST-ONLY: make node-0 a local-verify follower of the start-in-sequencer-mode
# ha cluster. verify_mode=local drives P2P block-sync from the ha peers; born
# skips the PBFT/upgrade path so it matches the cluster's consensus mode.
# Never enable on a production network.
- MORPH_NODE_DERIVATION_VERIFY_MODE=local
- MORPH_NODE_START_IN_SEQUENCER_MODE=${START_IN_SEQUENCER_MODE:-true}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the startup and signer-construction symbols.
ast-grep outline node/cmd/node/main.go --items all --match 'L2NodeMain|initL1SequencerComponents'

# Inspect the private-key configuration path and signer creation.
rg -n -C 8 --glob '*.go' \
  'func initL1SequencerComponents\b|SequencerPrivateKey|SEQUENCER_PRIVATE_KEY|MORPH_NODE_SEQUENCER_PRIVATE_KEY' \
  node

# Confirm the effective node-0 configuration.
sed -n '174,200p' ops/docker/docker-compose-devnet.yml

Repository: morph-l2/morph

Length of output: 6204


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect how main.go uses the signer and sequencer mode flags, and how initL1SequencerComponents builds the signer.
sed -n '59,180p' node/cmd/node/main.go
sed -n '373,480p' node/cmd/node/main.go

# Map definitions for signer construction helpers and local-verify / sequencer mode behavior.
rg -n -C 6 --glob '*.go' \
  'DerivationVerifyMode|START_IN_SEQUENCER_MODE|StartInSequencerMode|local-verify|local_verify|SequencerPrivateKey|New.*Signer|signer|NewSigner' \
  node

Repository: morph-l2/morph

Length of output: 48725


Keep node-0 from becoming a sequencer.

MORPH_NODE_SEQUENCER_PRIVATE_KEY makes initL1SequencerComponents create a LocalSigner. A non-nil signer skips derivation and starts in sequencer mode, so node-0 is not the intended local-verify P2P follower. Remove or override this env var for this service.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ops/docker/docker-compose-devnet.yml` around lines 188 - 193, Update the
node-0 service configuration near MORPH_NODE_DERIVATION_VERIFY_MODE so
MORPH_NODE_SEQUENCER_PRIVATE_KEY is removed or explicitly overridden, ensuring
initL1SequencerComponents does not create a LocalSigner and node-0 remains a
local-verify P2P follower rather than starting as a sequencer.

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.

1 participant