feat(devnet): Start-in-sequencer-mode devnet switch for devnet - #1030
feat(devnet): Start-in-sequencer-mode devnet switch for devnet#1030tomatoishealthy wants to merge 1 commit into
Conversation
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]>
There was a problem hiding this comment.
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.
📝 WalkthroughWalkthroughChangesDirect sequencer-mode startup
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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
node/cmd/node/main.gonode/devtool/start_in_sequencer_mode.goops/docker/docker-compose-cluster.ymlops/docker/docker-compose-devnet.yml
| func ApplyStartInSequencerMode(ctx *cli.Context, logger tmlog.Logger) { | ||
| if !ctx.GlobalBool(startInSequencerModeFlag.Name) { | ||
| return | ||
| } | ||
| upgrade.SetUpgradeBlockHeight(0) |
There was a problem hiding this comment.
🎯 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.
| # 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} |
There was a problem hiding this comment.
🎯 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.ymlRepository: 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' \
nodeRepository: 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.
What
Adds an isolated, test-only
node/devtoolpackage 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
ApplyStartInSequencerModepre-sets the consensus upgrade block height to 0, soIsUpgraded(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 viainit()sonode/flags/flags.gois untouched.node/cmd/node/main.go: one guarded call beforeSetupNode.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
Documentation