From 4c0033c3834a6e02c4a62197faf12cc55edb83f9 Mon Sep 17 00:00:00 2001 From: clabby Date: Sat, 28 Jun 2025 23:02:55 -0400 Subject: [PATCH] feat(bin/mode): Change `sequencer.enabled` -> `mode` ## Overview Changes the `sequencer.enabled` flag to a more generic `mode` flag that can be used to specify different modes of operation for the node. Also wires this flag up to the `NodeBuilder`. --- bin/node/src/commands/node.rs | 12 +++++++++++- bin/node/src/flags/sequencer.rs | 9 --------- crates/node/service/src/service/mode.rs | 4 +++- crates/node/service/src/service/standard/builder.rs | 7 ++++++- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/bin/node/src/commands/node.rs b/bin/node/src/commands/node.rs index 131f7747d9..7e5de8be9d 100644 --- a/bin/node/src/commands/node.rs +++ b/bin/node/src/commands/node.rs @@ -11,7 +11,7 @@ use clap::Parser; use kona_cli::metrics_args::MetricsArgs; use kona_engine::EngineKind; use kona_genesis::RollupConfig; -use kona_node_service::{RollupNode, RollupNodeService}; +use kona_node_service::{NodeMode, RollupNode, RollupNodeService}; use op_alloy_provider::ext::engine::OpEngineApi; use serde_json::from_reader; use std::{fs::File, path::PathBuf, sync::Arc}; @@ -27,6 +27,14 @@ use url::Url; #[derive(Parser, PartialEq, Debug, Clone)] #[command(about = "Runs the consensus node")] pub struct NodeCommand { + /// The mode to run the node in. + #[arg( + long = "mode", + default_value_t = NodeMode::Validator, + env = "KONA_NODE_MODE", + help = "The mode to run the node in. Supported modes are: [\"validator\", \"sequencer\"]" + )] + pub node_mode: NodeMode, /// URL of the L1 execution client RPC API. #[arg(long, visible_alias = "l1", env = "KONA_NODE_L1_ETH_RPC")] pub l1_eth_rpc: Url, @@ -90,6 +98,7 @@ impl Default for NodeCommand { l2_engine_jwt_secret: None, l2_config_file: None, l1_runtime_config_reload_interval: 600, + node_mode: NodeMode::Validator, p2p_flags: P2PArgs::default(), rpc_flags: RpcArgs::default(), sequencer_flags: SequencerArgs::default(), @@ -221,6 +230,7 @@ impl NodeCommand { } RollupNode::builder(cfg) + .with_mode(self.node_mode) .with_jwt_secret(jwt_secret) .with_l1_provider_rpc_url(self.l1_eth_rpc) .with_l1_beacon_api_url(self.l1_beacon) diff --git a/bin/node/src/flags/sequencer.rs b/bin/node/src/flags/sequencer.rs index db750aaad8..626dae0074 100644 --- a/bin/node/src/flags/sequencer.rs +++ b/bin/node/src/flags/sequencer.rs @@ -10,15 +10,6 @@ use std::{net::SocketAddr, num::ParseIntError, time::Duration}; /// Sequencer CLI Flags #[derive(Parser, Clone, Debug, PartialEq, Eq)] pub struct SequencerArgs { - /// Enable sequencing of new L2 blocks. A separate batch submitter has to be deployed to - /// publish the data for verifiers. - #[arg( - long = "sequencer.enabled", - default_value = "false", - env = "KONA_NODE_SEQUENCER_ENABLED" - )] - pub enabled: bool, - /// Initialize the sequencer in a stopped state. The sequencer can be started using the /// admin_startSequencer RPC. #[arg( diff --git a/crates/node/service/src/service/mode.rs b/crates/node/service/src/service/mode.rs index 8f70681ad1..8fe4acb90c 100644 --- a/crates/node/service/src/service/mode.rs +++ b/crates/node/service/src/service/mode.rs @@ -3,7 +3,9 @@ /// The [`NodeMode`] enum represents the modes of operation for the [`RollupNodeService`]. /// /// [`RollupNodeService`]: crate::RollupNodeService -#[derive(Debug, derive_more::Display, Default, Clone, Copy, PartialEq, Eq)] +#[derive( + Debug, derive_more::Display, derive_more::FromStr, Default, Clone, Copy, PartialEq, Eq, +)] pub enum NodeMode { /// Validator mode. #[display("Validator")] diff --git a/crates/node/service/src/service/standard/builder.rs b/crates/node/service/src/service/standard/builder.rs index 45081b2faf..cb8542d82e 100644 --- a/crates/node/service/src/service/standard/builder.rs +++ b/crates/node/service/src/service/standard/builder.rs @@ -60,6 +60,11 @@ impl RollupNodeBuilder { Self { interop_mode, ..self } } + /// Sets the [`NodeMode`] on the [`RollupNodeBuilder`]. + pub fn with_mode(self, mode: NodeMode) -> Self { + Self { mode, ..self } + } + /// Appends the [`SupervisorRpcConfig`] to the builder. pub fn with_supervisor_rpc_config(self, config: SupervisorRpcConfig) -> Self { Self { supervisor_rpc_config: config, ..self } @@ -160,6 +165,7 @@ impl RollupNodeBuilder { }; RollupNode { + mode: self.mode, config: rollup_config, interop_mode, l1_provider, @@ -171,7 +177,6 @@ impl RollupNodeBuilder { p2p_config, // By default, the supervisor rpc config is disabled. supervisor_rpc: self.supervisor_rpc_config, - mode: self.mode, } } }