From 13e68822f8e50a89b956aefbc6f26e6817b196d3 Mon Sep 17 00:00:00 2001 From: Morty Date: Thu, 4 Dec 2025 13:21:49 +0800 Subject: [PATCH 1/9] feat: improve rpc namespace --- crates/node/src/add_ons/mod.rs | 27 ++++++++-- crates/node/src/add_ons/rpc.rs | 92 +++++++++++++++++++++------------- crates/node/src/args.rs | 7 ++- 3 files changed, 88 insertions(+), 38 deletions(-) diff --git a/crates/node/src/add_ons/mod.rs b/crates/node/src/add_ons/mod.rs index 4dbb797d..c6c44a9e 100644 --- a/crates/node/src/add_ons/mod.rs +++ b/crates/node/src/add_ons/mod.rs @@ -32,7 +32,10 @@ mod handle; pub use handle::ScrollAddOnsHandle; mod rpc; -pub use rpc::{RollupNodeExtApiClient, RollupNodeExtApiServer, RollupNodeRpcExt}; +pub use rpc::{ + RollupNodeAdminApiClient, RollupNodeAdminApiServer, RollupNodeApiClient, RollupNodeApiServer, + RollupNodeRpcExt, +}; mod rollup; pub use rollup::IsDevChain; @@ -128,10 +131,22 @@ where ); let (tx, rx) = tokio::sync::oneshot::channel(); + let (tx_admin, rx_admin) = tokio::sync::oneshot::channel(); + + // Register rollupNode API (always enabled for status and query methods) let rollup_node_rpc_ext = RollupNodeRpcExt::::new(rx); - if rollup_node_manager_addon.config().rpc_args.enabled { + rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| { + ctx.modules.merge_configured(RollupNodeApiServer::into_rpc(rollup_node_rpc_ext))?; + Ok(()) + }); + + // Register rollupNodeAdmin API (only if admin flag is enabled) + let rpc_config = rollup_node_manager_addon.config().rpc_args.clone(); + if rpc_config.admin_enabled || rpc_config.enabled { + // Support both --rpc.rollup-node-admin and legacy --rpc.rollup-node + let rollup_node_admin_ext = RollupNodeRpcExt::::new(rx_admin); rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| { - ctx.modules.merge_configured(rollup_node_rpc_ext.into_rpc())?; + ctx.modules.merge_configured(RollupNodeAdminApiServer::into_rpc(rollup_node_admin_ext))?; Ok(()) }); } @@ -142,6 +157,12 @@ where tx.send(rollup_manager_handle.clone()) .map_err(|_| eyre::eyre!("failed to send rollup manager handle"))?; + + // Send handle to admin API if it was registered + let rpc_config = rollup_node_manager_addon.config().rpc_args.clone(); + if rpc_config.admin_enabled || rpc_config.enabled { + let _ = tx_admin.send(rollup_manager_handle.clone()); + } Ok(ScrollAddOnsHandle { rollup_manager_handle, diff --git a/crates/node/src/add_ons/rpc.rs b/crates/node/src/add_ons/rpc.rs index cf254c3e..8e4c1faf 100644 --- a/crates/node/src/add_ons/rpc.rs +++ b/crates/node/src/add_ons/rpc.rs @@ -53,31 +53,23 @@ where } } -/// Defines the `rollupNode` JSON-RPC namespace for rollup management operations. +/// Defines the `rollupNode` JSON-RPC namespace for read-only operations. /// -/// This trait provides a custom RPC namespace that exposes rollup node management -/// functionality to external clients. The namespace is exposed as `rollupNode` and -/// provides methods for controlling automatic sequencing behavior. +/// This trait provides a custom RPC namespace that exposes rollup node status +/// and query functionality to external clients. The namespace is exposed as `rollupNode` +/// and is enabled by default. /// /// # Usage /// These methods can be called via JSON-RPC using the `rollupNode` namespace: /// ```json -/// {"jsonrpc": "2.0", "method": "rollupNode_enableAutomaticSequencing", "params": [], "id": 1} +/// {"jsonrpc": "2.0", "method": "rollupNode_status", "params": [], "id": 1} /// ``` /// or using cast: /// ```bash -/// cast rpc rollupNode_enableAutomaticSequencing +/// cast rpc rollupNode_status /// ``` #[rpc(server, client, namespace = "rollupNode")] -pub trait RollupNodeExtApi { - /// Enables automatic sequencing in the rollup node. - #[method(name = "enableAutomaticSequencing")] - async fn enable_automatic_sequencing(&self) -> RpcResult; - - /// Disables automatic sequencing in the rollup node. - #[method(name = "disableAutomaticSequencing")] - async fn disable_automatic_sequencing(&self) -> RpcResult; - +pub trait RollupNodeApi { /// Returns the current status of the rollup node. #[method(name = "status")] async fn status(&self) -> RpcResult; @@ -94,12 +86,38 @@ pub trait RollupNodeExtApi { ) -> RpcResult>; } +/// Defines the `rollupNodeAdmin` JSON-RPC namespace for administrative operations. +/// +/// This trait provides a custom RPC namespace that exposes rollup node administrative +/// functionality to external clients. The namespace is exposed as `rollupNodeAdmin` and +/// requires the `--rpc.rollup-node-admin` flag to be enabled. +/// +/// # Usage +/// These methods can be called via JSON-RPC using the `rollupNodeAdmin` namespace: +/// ```json +/// {"jsonrpc": "2.0", "method": "rollupNodeAdmin_enableAutomaticSequencing", "params": [], "id": 1} +/// ``` +/// or using cast: +/// ```bash +/// cast rpc rollupNodeAdmin_enableAutomaticSequencing +/// ``` +#[rpc(server, client, namespace = "rollupNodeAdmin")] +pub trait RollupNodeAdminApi { + /// Enables automatic sequencing in the rollup node. + #[method(name = "enableAutomaticSequencing")] + async fn enable_automatic_sequencing(&self) -> RpcResult; + + /// Disables automatic sequencing in the rollup node. + #[method(name = "disableAutomaticSequencing")] + async fn disable_automatic_sequencing(&self) -> RpcResult; +} + #[async_trait] -impl RollupNodeExtApiServer for RollupNodeRpcExt +impl RollupNodeApiServer for RollupNodeRpcExt where N: FullNetwork, { - async fn enable_automatic_sequencing(&self) -> RpcResult { + async fn status(&self) -> RpcResult { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -108,16 +126,16 @@ where ) })?; - handle.enable_automatic_sequencing().await.map_err(|e| { + handle.status().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to enable automatic sequencing: {}", e), + format!("Failed to get rollup node status: {}", e), None::<()>, ) }) } - async fn disable_automatic_sequencing(&self) -> RpcResult { + async fn get_l1_message_by_index(&self, index: u64) -> RpcResult> { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -126,16 +144,19 @@ where ) })?; - handle.disable_automatic_sequencing().await.map_err(|e| { + handle.get_l1_message_by_key(L1MessageKey::from_queue_index(index)).await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to disable automatic sequencing: {}", e), + format!("Failed to get L1 message by index: {}", e), None::<()>, ) }) } - async fn status(&self) -> RpcResult { + async fn get_l1_message_by_key( + &self, + l1_message_key: L1MessageKey, + ) -> RpcResult> { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -144,16 +165,22 @@ where ) })?; - handle.status().await.map_err(|e| { + handle.get_l1_message_by_key(l1_message_key).await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to get rollup node status: {}", e), + format!("Failed to get L1 message by key: {}", e), None::<()>, ) }) } +} - async fn get_l1_message_by_index(&self, index: u64) -> RpcResult> { +#[async_trait] +impl RollupNodeAdminApiServer for RollupNodeRpcExt +where + N: FullNetwork, +{ + async fn enable_automatic_sequencing(&self) -> RpcResult { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -162,19 +189,16 @@ where ) })?; - handle.get_l1_message_by_key(L1MessageKey::from_queue_index(index)).await.map_err(|e| { + handle.enable_automatic_sequencing().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to get L1 message by index: {}", e), + format!("Failed to enable automatic sequencing: {}", e), None::<()>, ) }) } - async fn get_l1_message_by_key( - &self, - l1_message_key: L1MessageKey, - ) -> RpcResult> { + async fn disable_automatic_sequencing(&self) -> RpcResult { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -183,10 +207,10 @@ where ) })?; - handle.get_l1_message_by_key(l1_message_key).await.map_err(|e| { + handle.disable_automatic_sequencing().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to get L1 message by key: {}", e), + format!("Failed to disable automatic sequencing: {}", e), None::<()>, ) }) diff --git a/crates/node/src/args.rs b/crates/node/src/args.rs index 348849e7..4059c7b3 100644 --- a/crates/node/src/args.rs +++ b/crates/node/src/args.rs @@ -752,8 +752,13 @@ pub struct SignerArgs { #[derive(Debug, Default, Clone, clap::Args)] pub struct RpcArgs { /// A boolean to represent if the rollup node rpc should be enabled. - #[arg(long = "rpc.rollup-node", help = "Enable the rollup node RPC namespace")] + /// This is kept for backward compatibility but is now always enabled by default. + #[arg(long = "rpc.rollup-node", help = "Enable the rollup node RPC namespace (deprecated: now enabled by default)")] pub enabled: bool, + + /// A boolean to represent if the rollup node admin rpc should be enabled. + #[arg(long = "rpc.rollup-node-admin", help = "Enable the rollup node admin RPC namespace (for enable/disable sequencing)")] + pub admin_enabled: bool, } impl SignerArgs { From 95201c4ff86ff7ce49303746f5b8a11aa9f5b575 Mon Sep 17 00:00:00 2001 From: Morty Date: Thu, 4 Dec 2025 15:50:02 +0800 Subject: [PATCH 2/9] Revert "feat: improve rpc namespace" This reverts commit 13e68822f8e50a89b956aefbc6f26e6817b196d3. --- crates/node/src/add_ons/mod.rs | 27 ++-------- crates/node/src/add_ons/rpc.rs | 92 +++++++++++++--------------------- crates/node/src/args.rs | 7 +-- 3 files changed, 38 insertions(+), 88 deletions(-) diff --git a/crates/node/src/add_ons/mod.rs b/crates/node/src/add_ons/mod.rs index c6c44a9e..4dbb797d 100644 --- a/crates/node/src/add_ons/mod.rs +++ b/crates/node/src/add_ons/mod.rs @@ -32,10 +32,7 @@ mod handle; pub use handle::ScrollAddOnsHandle; mod rpc; -pub use rpc::{ - RollupNodeAdminApiClient, RollupNodeAdminApiServer, RollupNodeApiClient, RollupNodeApiServer, - RollupNodeRpcExt, -}; +pub use rpc::{RollupNodeExtApiClient, RollupNodeExtApiServer, RollupNodeRpcExt}; mod rollup; pub use rollup::IsDevChain; @@ -131,22 +128,10 @@ where ); let (tx, rx) = tokio::sync::oneshot::channel(); - let (tx_admin, rx_admin) = tokio::sync::oneshot::channel(); - - // Register rollupNode API (always enabled for status and query methods) let rollup_node_rpc_ext = RollupNodeRpcExt::::new(rx); - rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| { - ctx.modules.merge_configured(RollupNodeApiServer::into_rpc(rollup_node_rpc_ext))?; - Ok(()) - }); - - // Register rollupNodeAdmin API (only if admin flag is enabled) - let rpc_config = rollup_node_manager_addon.config().rpc_args.clone(); - if rpc_config.admin_enabled || rpc_config.enabled { - // Support both --rpc.rollup-node-admin and legacy --rpc.rollup-node - let rollup_node_admin_ext = RollupNodeRpcExt::::new(rx_admin); + if rollup_node_manager_addon.config().rpc_args.enabled { rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| { - ctx.modules.merge_configured(RollupNodeAdminApiServer::into_rpc(rollup_node_admin_ext))?; + ctx.modules.merge_configured(rollup_node_rpc_ext.into_rpc())?; Ok(()) }); } @@ -157,12 +142,6 @@ where tx.send(rollup_manager_handle.clone()) .map_err(|_| eyre::eyre!("failed to send rollup manager handle"))?; - - // Send handle to admin API if it was registered - let rpc_config = rollup_node_manager_addon.config().rpc_args.clone(); - if rpc_config.admin_enabled || rpc_config.enabled { - let _ = tx_admin.send(rollup_manager_handle.clone()); - } Ok(ScrollAddOnsHandle { rollup_manager_handle, diff --git a/crates/node/src/add_ons/rpc.rs b/crates/node/src/add_ons/rpc.rs index 8e4c1faf..cf254c3e 100644 --- a/crates/node/src/add_ons/rpc.rs +++ b/crates/node/src/add_ons/rpc.rs @@ -53,23 +53,31 @@ where } } -/// Defines the `rollupNode` JSON-RPC namespace for read-only operations. +/// Defines the `rollupNode` JSON-RPC namespace for rollup management operations. /// -/// This trait provides a custom RPC namespace that exposes rollup node status -/// and query functionality to external clients. The namespace is exposed as `rollupNode` -/// and is enabled by default. +/// This trait provides a custom RPC namespace that exposes rollup node management +/// functionality to external clients. The namespace is exposed as `rollupNode` and +/// provides methods for controlling automatic sequencing behavior. /// /// # Usage /// These methods can be called via JSON-RPC using the `rollupNode` namespace: /// ```json -/// {"jsonrpc": "2.0", "method": "rollupNode_status", "params": [], "id": 1} +/// {"jsonrpc": "2.0", "method": "rollupNode_enableAutomaticSequencing", "params": [], "id": 1} /// ``` /// or using cast: /// ```bash -/// cast rpc rollupNode_status +/// cast rpc rollupNode_enableAutomaticSequencing /// ``` #[rpc(server, client, namespace = "rollupNode")] -pub trait RollupNodeApi { +pub trait RollupNodeExtApi { + /// Enables automatic sequencing in the rollup node. + #[method(name = "enableAutomaticSequencing")] + async fn enable_automatic_sequencing(&self) -> RpcResult; + + /// Disables automatic sequencing in the rollup node. + #[method(name = "disableAutomaticSequencing")] + async fn disable_automatic_sequencing(&self) -> RpcResult; + /// Returns the current status of the rollup node. #[method(name = "status")] async fn status(&self) -> RpcResult; @@ -86,38 +94,12 @@ pub trait RollupNodeApi { ) -> RpcResult>; } -/// Defines the `rollupNodeAdmin` JSON-RPC namespace for administrative operations. -/// -/// This trait provides a custom RPC namespace that exposes rollup node administrative -/// functionality to external clients. The namespace is exposed as `rollupNodeAdmin` and -/// requires the `--rpc.rollup-node-admin` flag to be enabled. -/// -/// # Usage -/// These methods can be called via JSON-RPC using the `rollupNodeAdmin` namespace: -/// ```json -/// {"jsonrpc": "2.0", "method": "rollupNodeAdmin_enableAutomaticSequencing", "params": [], "id": 1} -/// ``` -/// or using cast: -/// ```bash -/// cast rpc rollupNodeAdmin_enableAutomaticSequencing -/// ``` -#[rpc(server, client, namespace = "rollupNodeAdmin")] -pub trait RollupNodeAdminApi { - /// Enables automatic sequencing in the rollup node. - #[method(name = "enableAutomaticSequencing")] - async fn enable_automatic_sequencing(&self) -> RpcResult; - - /// Disables automatic sequencing in the rollup node. - #[method(name = "disableAutomaticSequencing")] - async fn disable_automatic_sequencing(&self) -> RpcResult; -} - #[async_trait] -impl RollupNodeApiServer for RollupNodeRpcExt +impl RollupNodeExtApiServer for RollupNodeRpcExt where N: FullNetwork, { - async fn status(&self) -> RpcResult { + async fn enable_automatic_sequencing(&self) -> RpcResult { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -126,16 +108,16 @@ where ) })?; - handle.status().await.map_err(|e| { + handle.enable_automatic_sequencing().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to get rollup node status: {}", e), + format!("Failed to enable automatic sequencing: {}", e), None::<()>, ) }) } - async fn get_l1_message_by_index(&self, index: u64) -> RpcResult> { + async fn disable_automatic_sequencing(&self) -> RpcResult { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -144,19 +126,16 @@ where ) })?; - handle.get_l1_message_by_key(L1MessageKey::from_queue_index(index)).await.map_err(|e| { + handle.disable_automatic_sequencing().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to get L1 message by index: {}", e), + format!("Failed to disable automatic sequencing: {}", e), None::<()>, ) }) } - async fn get_l1_message_by_key( - &self, - l1_message_key: L1MessageKey, - ) -> RpcResult> { + async fn status(&self) -> RpcResult { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -165,22 +144,16 @@ where ) })?; - handle.get_l1_message_by_key(l1_message_key).await.map_err(|e| { + handle.status().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to get L1 message by key: {}", e), + format!("Failed to get rollup node status: {}", e), None::<()>, ) }) } -} -#[async_trait] -impl RollupNodeAdminApiServer for RollupNodeRpcExt -where - N: FullNetwork, -{ - async fn enable_automatic_sequencing(&self) -> RpcResult { + async fn get_l1_message_by_index(&self, index: u64) -> RpcResult> { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -189,16 +162,19 @@ where ) })?; - handle.enable_automatic_sequencing().await.map_err(|e| { + handle.get_l1_message_by_key(L1MessageKey::from_queue_index(index)).await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to enable automatic sequencing: {}", e), + format!("Failed to get L1 message by index: {}", e), None::<()>, ) }) } - async fn disable_automatic_sequencing(&self) -> RpcResult { + async fn get_l1_message_by_key( + &self, + l1_message_key: L1MessageKey, + ) -> RpcResult> { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -207,10 +183,10 @@ where ) })?; - handle.disable_automatic_sequencing().await.map_err(|e| { + handle.get_l1_message_by_key(l1_message_key).await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to disable automatic sequencing: {}", e), + format!("Failed to get L1 message by key: {}", e), None::<()>, ) }) diff --git a/crates/node/src/args.rs b/crates/node/src/args.rs index 4059c7b3..348849e7 100644 --- a/crates/node/src/args.rs +++ b/crates/node/src/args.rs @@ -752,13 +752,8 @@ pub struct SignerArgs { #[derive(Debug, Default, Clone, clap::Args)] pub struct RpcArgs { /// A boolean to represent if the rollup node rpc should be enabled. - /// This is kept for backward compatibility but is now always enabled by default. - #[arg(long = "rpc.rollup-node", help = "Enable the rollup node RPC namespace (deprecated: now enabled by default)")] + #[arg(long = "rpc.rollup-node", help = "Enable the rollup node RPC namespace")] pub enabled: bool, - - /// A boolean to represent if the rollup node admin rpc should be enabled. - #[arg(long = "rpc.rollup-node-admin", help = "Enable the rollup node admin RPC namespace (for enable/disable sequencing)")] - pub admin_enabled: bool, } impl SignerArgs { From 7d2336294d076af441889a65c7be3e23499cd7ec Mon Sep 17 00:00:00 2001 From: Morty Date: Thu, 4 Dec 2025 20:45:23 +0800 Subject: [PATCH 3/9] fit --- crates/node/src/add_ons/mod.rs | 30 ++++-- crates/node/src/add_ons/rpc.rs | 143 +++++++++++++++++++------- crates/node/src/args.rs | 3 + crates/node/src/test_utils/fixture.rs | 2 +- crates/node/src/test_utils/mod.rs | 4 +- 5 files changed, 136 insertions(+), 46 deletions(-) diff --git a/crates/node/src/add_ons/mod.rs b/crates/node/src/add_ons/mod.rs index 4dbb797d..c9171d1c 100644 --- a/crates/node/src/add_ons/mod.rs +++ b/crates/node/src/add_ons/mod.rs @@ -32,7 +32,10 @@ mod handle; pub use handle::ScrollAddOnsHandle; mod rpc; -pub use rpc::{RollupNodeExtApiClient, RollupNodeExtApiServer, RollupNodeRpcExt}; +pub use rpc::{ + RollupNodeAdminApiClient, RollupNodeAdminApiServer, RollupNodeApiClient, RollupNodeApiServer, + RollupNodeRpcExt, +}; mod rollup; pub use rollup::IsDevChain; @@ -128,10 +131,22 @@ where ); let (tx, rx) = tokio::sync::oneshot::channel(); - let rollup_node_rpc_ext = RollupNodeRpcExt::::new(rx); - if rollup_node_manager_addon.config().rpc_args.enabled { + let rpc_config = rollup_node_manager_addon.config().rpc_args.clone(); + + // Register rollupNode API and optionally rollupNodeAdmin API + if rpc_config.enabled { + // Create a single RPC extension that implements both APIs + let rollup_node_rpc_ext = RollupNodeRpcExt::::new(rx); + + let admin_enabled = rpc_config.admin_enabled; rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| { - ctx.modules.merge_configured(rollup_node_rpc_ext.into_rpc())?; + // Always register rollupNode API (read-only operations) + // ctx.modules.merge_configured(RollupNodeApiServer::into_rpc(rollup_node_rpc_ext))?; + + // Only register rollupNodeAdmin API if enabled (administrative operations) + if admin_enabled { + ctx.modules.merge_configured(RollupNodeAdminApiServer::into_rpc(rollup_node_rpc_ext))?; + } Ok(()) }); } @@ -140,8 +155,11 @@ where let (rollup_manager_handle, l1_watcher_tx) = rollup_node_manager_addon.launch(ctx.clone(), rpc_handle.clone()).await?; - tx.send(rollup_manager_handle.clone()) - .map_err(|_| eyre::eyre!("failed to send rollup manager handle"))?; + // Only send handle if RPC is enabled + if rpc_config.enabled { + tx.send(rollup_manager_handle.clone()) + .map_err(|_| eyre::eyre!("failed to send rollup manager handle"))?; + } Ok(ScrollAddOnsHandle { rollup_manager_handle, diff --git a/crates/node/src/add_ons/rpc.rs b/crates/node/src/add_ons/rpc.rs index cf254c3e..130753cb 100644 --- a/crates/node/src/add_ons/rpc.rs +++ b/crates/node/src/add_ons/rpc.rs @@ -13,9 +13,12 @@ use tokio::sync::{oneshot, Mutex, OnceCell}; /// RPC extension for rollup node management operations. /// -/// This struct provides a custom JSON-RPC namespace (`rollupNode`) that exposes -/// rollup management functionality to RPC clients. It manages a connection to the +/// This struct provides custom JSON-RPC namespaces (`rollupNode` and `rollupNodeAdmin`) +/// that expose rollup management functionality to RPC clients. It manages a connection to the /// rollup manager through a handle that is initialized lazily via a oneshot channel. +/// +/// Both `RollupNodeApiServer` and `RollupNodeAdminApiServer` traits are implemented. +/// You can control which APIs to expose by selectively registering them in the RPC modules. #[derive(Debug)] pub struct RollupNodeRpcExt where @@ -32,8 +35,14 @@ where N: FullNetwork, { /// Creates a new RPC extension with a receiver for the rollup manager handle. + /// + /// This struct implements both `RollupNodeApiServer` and `RollupNodeAdminApiServer`. + /// Control which APIs are exposed by selectively registering them when extending RPC modules. pub fn new(rx: oneshot::Receiver>) -> Self { - Self { rx: Mutex::new(Some(rx)), handle: OnceCell::new() } + Self { + rx: Mutex::new(Some(rx)), + handle: OnceCell::new(), + } } /// Gets or initializes the rollup manager handle. @@ -53,31 +62,22 @@ where } } -/// Defines the `rollupNode` JSON-RPC namespace for rollup management operations. +/// Defines the `rollupNode` JSON-RPC namespace for read-only operations. /// -/// This trait provides a custom RPC namespace that exposes rollup node management -/// functionality to external clients. The namespace is exposed as `rollupNode` and -/// provides methods for controlling automatic sequencing behavior. +/// This trait provides a custom RPC namespace that exposes rollup node status +/// and query functionality to external clients. The namespace is exposed as `rollupNode`. /// /// # Usage /// These methods can be called via JSON-RPC using the `rollupNode` namespace: /// ```json -/// {"jsonrpc": "2.0", "method": "rollupNode_enableAutomaticSequencing", "params": [], "id": 1} +/// {"jsonrpc": "2.0", "method": "rollupNode_status", "params": [], "id": 1} /// ``` /// or using cast: /// ```bash -/// cast rpc rollupNode_enableAutomaticSequencing +/// cast rpc rollupNode_status /// ``` #[rpc(server, client, namespace = "rollupNode")] -pub trait RollupNodeExtApi { - /// Enables automatic sequencing in the rollup node. - #[method(name = "enableAutomaticSequencing")] - async fn enable_automatic_sequencing(&self) -> RpcResult; - - /// Disables automatic sequencing in the rollup node. - #[method(name = "disableAutomaticSequencing")] - async fn disable_automatic_sequencing(&self) -> RpcResult; - +pub trait RollupNodeApi { /// Returns the current status of the rollup node. #[method(name = "status")] async fn status(&self) -> RpcResult; @@ -94,12 +94,38 @@ pub trait RollupNodeExtApi { ) -> RpcResult>; } +/// Defines the `rollupNodeAdmin` JSON-RPC namespace for administrative operations. +/// +/// This trait provides a custom RPC namespace that exposes rollup node administrative +/// functionality to external clients. The namespace is exposed as `rollupNodeAdmin` and +/// requires the `--rpc.rollup-node-admin` flag to be enabled. +/// +/// # Usage +/// These methods can be called via JSON-RPC using the `rollupNodeAdmin` namespace: +/// ```json +/// {"jsonrpc": "2.0", "method": "rollupNodeAdmin_enableAutomaticSequencing", "params": [], "id": 1} +/// ``` +/// or using cast: +/// ```bash +/// cast rpc rollupNodeAdmin_enableAutomaticSequencing +/// ``` +#[rpc(server, client, namespace = "rollupNodeAdmin")] +pub trait RollupNodeAdminApi { + /// Enables automatic sequencing in the rollup node. + #[method(name = "enableAutomaticSequencing")] + async fn enable_automatic_sequencing(&self) -> RpcResult; + + /// Disables automatic sequencing in the rollup node. + #[method(name = "disableAutomaticSequencing")] + async fn disable_automatic_sequencing(&self) -> RpcResult; +} + #[async_trait] -impl RollupNodeExtApiServer for RollupNodeRpcExt +impl RollupNodeApiServer for RollupNodeRpcExt where N: FullNetwork, { - async fn enable_automatic_sequencing(&self) -> RpcResult { + async fn status(&self) -> RpcResult { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -108,16 +134,16 @@ where ) })?; - handle.enable_automatic_sequencing().await.map_err(|e| { + handle.status().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to enable automatic sequencing: {}", e), + format!("Failed to get rollup node status: {}", e), None::<()>, ) }) } - async fn disable_automatic_sequencing(&self) -> RpcResult { + async fn get_l1_message_by_index(&self, index: u64) -> RpcResult> { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -126,16 +152,19 @@ where ) })?; - handle.disable_automatic_sequencing().await.map_err(|e| { + handle.get_l1_message_by_key(L1MessageKey::from_queue_index(index)).await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to disable automatic sequencing: {}", e), + format!("Failed to get L1 message by index: {}", e), None::<()>, ) }) } - async fn status(&self) -> RpcResult { + async fn get_l1_message_by_key( + &self, + l1_message_key: L1MessageKey, + ) -> RpcResult> { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -144,16 +173,22 @@ where ) })?; - handle.status().await.map_err(|e| { + handle.get_l1_message_by_key(l1_message_key).await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to get rollup node status: {}", e), + format!("Failed to get L1 message by key: {}", e), None::<()>, ) }) } +} - async fn get_l1_message_by_index(&self, index: u64) -> RpcResult> { +#[async_trait] +impl RollupNodeAdminApiServer for RollupNodeRpcExt +where + N: FullNetwork, +{ + async fn enable_automatic_sequencing(&self) -> RpcResult { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -162,19 +197,16 @@ where ) })?; - handle.get_l1_message_by_key(L1MessageKey::from_queue_index(index)).await.map_err(|e| { + handle.enable_automatic_sequencing().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to get L1 message by index: {}", e), + format!("Failed to enable automatic sequencing: {}", e), None::<()>, ) }) } - async fn get_l1_message_by_key( - &self, - l1_message_key: L1MessageKey, - ) -> RpcResult> { + async fn disable_automatic_sequencing(&self) -> RpcResult { let handle = self.rollup_manager_handle().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, @@ -183,12 +215,49 @@ where ) })?; - handle.get_l1_message_by_key(l1_message_key).await.map_err(|e| { + handle.disable_automatic_sequencing().await.map_err(|e| { ErrorObjectOwned::owned( error::INTERNAL_ERROR_CODE, - format!("Failed to get L1 message by key: {}", e), + format!("Failed to disable automatic sequencing: {}", e), None::<()>, ) }) } } + +// Implement RollupNodeApiServer for Arc> to allow shared ownership +#[async_trait] +impl RollupNodeApiServer for std::sync::Arc> +where + N: FullNetwork, +{ + async fn status(&self) -> RpcResult { + (**self).status().await + } + + async fn get_l1_message_by_index(&self, index: u64) -> RpcResult> { + (**self).get_l1_message_by_index(index).await + } + + async fn get_l1_message_by_key( + &self, + l1_message_key: L1MessageKey, + ) -> RpcResult> { + (**self).get_l1_message_by_key(l1_message_key).await + } +} + +// Implement RollupNodeAdminApiServer for Arc> to allow shared ownership +#[async_trait] +impl RollupNodeAdminApiServer for std::sync::Arc> +where + N: FullNetwork, +{ + async fn enable_automatic_sequencing(&self) -> RpcResult { + (**self).enable_automatic_sequencing().await + } + + async fn disable_automatic_sequencing(&self) -> RpcResult { + (**self).disable_automatic_sequencing().await + } +} diff --git a/crates/node/src/args.rs b/crates/node/src/args.rs index 348849e7..d82a4d4f 100644 --- a/crates/node/src/args.rs +++ b/crates/node/src/args.rs @@ -754,6 +754,9 @@ pub struct RpcArgs { /// A boolean to represent if the rollup node rpc should be enabled. #[arg(long = "rpc.rollup-node", help = "Enable the rollup node RPC namespace")] pub enabled: bool, + /// A boolean to represent if the rollup node admin rpc should be enabled. + #[arg(long = "rpc.rollup-node-admin", help = "Enable the rollup node admin RPC namespace")] + pub admin_enabled: bool, } impl SignerArgs { diff --git a/crates/node/src/test_utils/fixture.rs b/crates/node/src/test_utils/fixture.rs index 2ae50eb9..52f0d3bf 100644 --- a/crates/node/src/test_utils/fixture.rs +++ b/crates/node/src/test_utils/fixture.rs @@ -253,7 +253,7 @@ impl TestFixtureBuilder { gas_price_oracle_args: RollupNodeGasPriceOracleArgs::default(), consensus_args: ConsensusArgs::noop(), database: None, - rpc_args: RpcArgs { enabled: true }, + rpc_args: RpcArgs { enabled: true, admin_enabled: true }, } } diff --git a/crates/node/src/test_utils/mod.rs b/crates/node/src/test_utils/mod.rs index 00f075c5..9d7e467c 100644 --- a/crates/node/src/test_utils/mod.rs +++ b/crates/node/src/test_utils/mod.rs @@ -239,7 +239,7 @@ pub fn default_test_scroll_rollup_node_config() -> ScrollRollupNodeConfig { gas_price_oracle_args: crate::RollupNodeGasPriceOracleArgs::default(), consensus_args: ConsensusArgs::noop(), database: None, - rpc_args: RpcArgs { enabled: true }, + rpc_args: RpcArgs { enabled: true, admin_enabled: true }, } } @@ -279,6 +279,6 @@ pub fn default_sequencer_test_scroll_rollup_node_config() -> ScrollRollupNodeCon gas_price_oracle_args: crate::RollupNodeGasPriceOracleArgs::default(), consensus_args: ConsensusArgs::noop(), database: None, - rpc_args: RpcArgs { enabled: true }, + rpc_args: RpcArgs { enabled: true, admin_enabled: true }, } } From 04283c543e97e62481f4d5e9a81edd8c1d251a6d Mon Sep 17 00:00:00 2001 From: Morty Date: Thu, 4 Dec 2025 23:55:43 +0800 Subject: [PATCH 4/9] feat: improve rpc namespace --- crates/node/src/add_ons/mod.rs | 34 +++++++++++++++++----------------- crates/node/src/add_ons/rpc.rs | 5 +---- crates/node/src/args.rs | 2 +- crates/node/tests/e2e.rs | 6 +++--- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/crates/node/src/add_ons/mod.rs b/crates/node/src/add_ons/mod.rs index c9171d1c..ebaab6aa 100644 --- a/crates/node/src/add_ons/mod.rs +++ b/crates/node/src/add_ons/mod.rs @@ -27,6 +27,7 @@ use reth_scroll_primitives::ScrollPrimitives; use reth_scroll_rpc::{eth::ScrollEthApiBuilder, ScrollEthApiError}; use scroll_alloy_evm::ScrollTransactionIntoTxEnv; use scroll_wire::ScrollWireEvent; +use std::sync::Arc; mod handle; pub use handle::ScrollAddOnsHandle; @@ -134,29 +135,28 @@ where let rpc_config = rollup_node_manager_addon.config().rpc_args.clone(); // Register rollupNode API and optionally rollupNodeAdmin API - if rpc_config.enabled { - // Create a single RPC extension that implements both APIs - let rollup_node_rpc_ext = RollupNodeRpcExt::::new(rx); - - let admin_enabled = rpc_config.admin_enabled; - rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| { - // Always register rollupNode API (read-only operations) - // ctx.modules.merge_configured(RollupNodeApiServer::into_rpc(rollup_node_rpc_ext))?; - - // Only register rollupNodeAdmin API if enabled (administrative operations) - if admin_enabled { - ctx.modules.merge_configured(RollupNodeAdminApiServer::into_rpc(rollup_node_rpc_ext))?; - } - Ok(()) - }); - } + let rollup_node_rpc_ext = Arc::new(RollupNodeRpcExt::::new(rx)); + + rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| { + // Always register rollupNode API (read-only operations) + if rpc_config.enabled { + ctx.modules + .merge_configured(RollupNodeApiServer::into_rpc(rollup_node_rpc_ext.clone()))?; + } + // Only register rollupNodeAdmin API if enabled (administrative operations) + if rpc_config.admin_enabled { + ctx.modules + .merge_configured(RollupNodeAdminApiServer::into_rpc(rollup_node_rpc_ext))?; + } + Ok(()) + }); let rpc_handle = rpc_add_ons.launch_add_ons_with(ctx.clone(), |_| Ok(())).await?; let (rollup_manager_handle, l1_watcher_tx) = rollup_node_manager_addon.launch(ctx.clone(), rpc_handle.clone()).await?; // Only send handle if RPC is enabled - if rpc_config.enabled { + if rpc_config.enabled || rpc_config.admin_enabled { tx.send(rollup_manager_handle.clone()) .map_err(|_| eyre::eyre!("failed to send rollup manager handle"))?; } diff --git a/crates/node/src/add_ons/rpc.rs b/crates/node/src/add_ons/rpc.rs index 130753cb..f53ddd24 100644 --- a/crates/node/src/add_ons/rpc.rs +++ b/crates/node/src/add_ons/rpc.rs @@ -39,10 +39,7 @@ where /// This struct implements both `RollupNodeApiServer` and `RollupNodeAdminApiServer`. /// Control which APIs are exposed by selectively registering them when extending RPC modules. pub fn new(rx: oneshot::Receiver>) -> Self { - Self { - rx: Mutex::new(Some(rx)), - handle: OnceCell::new(), - } + Self { rx: Mutex::new(Some(rx)), handle: OnceCell::new() } } /// Gets or initializes the rollup manager handle. diff --git a/crates/node/src/args.rs b/crates/node/src/args.rs index d82a4d4f..03bd148c 100644 --- a/crates/node/src/args.rs +++ b/crates/node/src/args.rs @@ -752,7 +752,7 @@ pub struct SignerArgs { #[derive(Debug, Default, Clone, clap::Args)] pub struct RpcArgs { /// A boolean to represent if the rollup node rpc should be enabled. - #[arg(long = "rpc.rollup-node", help = "Enable the rollup node RPC namespace")] + #[arg(long = "rpc.rollup-node", num_args=0..=1, default_value_t = true, help = "Enable the rollup node RPC namespace(default: true)")] pub enabled: bool, /// A boolean to represent if the rollup node admin rpc should be enabled. #[arg(long = "rpc.rollup-node-admin", help = "Enable the rollup node admin RPC namespace")] diff --git a/crates/node/tests/e2e.rs b/crates/node/tests/e2e.rs index ccdf805c..ba5c296b 100644 --- a/crates/node/tests/e2e.rs +++ b/crates/node/tests/e2e.rs @@ -22,7 +22,7 @@ use rollup_node::{ generate_tx, setup_engine, EventAssertions, NetworkHelperProvider, ReputationChecks, TestFixture, }, - RollupNodeContext, RollupNodeExtApiClient, + RollupNodeAdminApiClient, RollupNodeContext, }; use rollup_node_chain_orchestrator::ChainOrchestratorEvent; use rollup_node_primitives::{sig_encode_hash, BatchCommitData, BlockInfo}; @@ -1504,7 +1504,7 @@ async fn can_rpc_enable_disable_sequencing() -> eyre::Result<()> { // Disable automatic sequencing via RPC let client = fixture.sequencer().node.rpc_client().expect("Should have rpc client"); - let result = RollupNodeExtApiClient::disable_automatic_sequencing(&client).await?; + let result = RollupNodeAdminApiClient::disable_automatic_sequencing(&client).await?; assert!(result, "Disable automatic sequencing should return true"); // Wait a bit and verify no more blocks are produced automatically. @@ -1532,7 +1532,7 @@ async fn can_rpc_enable_disable_sequencing() -> eyre::Result<()> { fixture.expect_event_on(1).chain_extended(block_num_after_wait + 1).await?; // Enable sequencing again - let result = RollupNodeExtApiClient::enable_automatic_sequencing(&client).await?; + let result = RollupNodeAdminApiClient::enable_automatic_sequencing(&client).await?; assert!(result, "Enable automatic sequencing should return true"); // Make sure automatic sequencing resumes From 8ff01e432fa84eab873239319bf6f8c908225047 Mon Sep 17 00:00:00 2001 From: Morty Date: Fri, 5 Dec 2025 00:04:18 +0800 Subject: [PATCH 5/9] feat: improve rpc namespace --- crates/node/src/add_ons/mod.rs | 6 +++--- crates/node/src/add_ons/rpc.rs | 2 +- crates/node/src/args.rs | 6 +++--- crates/node/src/test_utils/fixture.rs | 2 +- crates/node/src/test_utils/mod.rs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/node/src/add_ons/mod.rs b/crates/node/src/add_ons/mod.rs index ebaab6aa..12535fe0 100644 --- a/crates/node/src/add_ons/mod.rs +++ b/crates/node/src/add_ons/mod.rs @@ -134,12 +134,12 @@ where let (tx, rx) = tokio::sync::oneshot::channel(); let rpc_config = rollup_node_manager_addon.config().rpc_args.clone(); - // Register rollupNode API and optionally rollupNodeAdmin API + // Register rollupNode API and rollupNodeAdmin API if enabled let rollup_node_rpc_ext = Arc::new(RollupNodeRpcExt::::new(rx)); rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| { // Always register rollupNode API (read-only operations) - if rpc_config.enabled { + if rpc_config.basic_enabled { ctx.modules .merge_configured(RollupNodeApiServer::into_rpc(rollup_node_rpc_ext.clone()))?; } @@ -156,7 +156,7 @@ where rollup_node_manager_addon.launch(ctx.clone(), rpc_handle.clone()).await?; // Only send handle if RPC is enabled - if rpc_config.enabled || rpc_config.admin_enabled { + if rpc_config.basic_enabled || rpc_config.admin_enabled { tx.send(rollup_manager_handle.clone()) .map_err(|_| eyre::eyre!("failed to send rollup manager handle"))?; } diff --git a/crates/node/src/add_ons/rpc.rs b/crates/node/src/add_ons/rpc.rs index f53ddd24..4d0c8226 100644 --- a/crates/node/src/add_ons/rpc.rs +++ b/crates/node/src/add_ons/rpc.rs @@ -59,7 +59,7 @@ where } } -/// Defines the `rollupNode` JSON-RPC namespace for read-only operations. +/// Defines the `rollupNode` JSON-RPC namespace for basic operations. /// /// This trait provides a custom RPC namespace that exposes rollup node status /// and query functionality to external clients. The namespace is exposed as `rollupNode`. diff --git a/crates/node/src/args.rs b/crates/node/src/args.rs index 03bd148c..8b6f8262 100644 --- a/crates/node/src/args.rs +++ b/crates/node/src/args.rs @@ -751,9 +751,9 @@ pub struct SignerArgs { /// The arguments for the rpc. #[derive(Debug, Default, Clone, clap::Args)] pub struct RpcArgs { - /// A boolean to represent if the rollup node rpc should be enabled. - #[arg(long = "rpc.rollup-node", num_args=0..=1, default_value_t = true, help = "Enable the rollup node RPC namespace(default: true)")] - pub enabled: bool, + /// A boolean to represent if the rollup node basic rpc should be enabled. + #[arg(long = "rpc.rollup-node", num_args=0..=1, default_value_t = true, help = "Enable the rollup node basic RPC namespace(default: true)")] + pub basic_enabled: bool, /// A boolean to represent if the rollup node admin rpc should be enabled. #[arg(long = "rpc.rollup-node-admin", help = "Enable the rollup node admin RPC namespace")] pub admin_enabled: bool, diff --git a/crates/node/src/test_utils/fixture.rs b/crates/node/src/test_utils/fixture.rs index 52f0d3bf..5616aca4 100644 --- a/crates/node/src/test_utils/fixture.rs +++ b/crates/node/src/test_utils/fixture.rs @@ -253,7 +253,7 @@ impl TestFixtureBuilder { gas_price_oracle_args: RollupNodeGasPriceOracleArgs::default(), consensus_args: ConsensusArgs::noop(), database: None, - rpc_args: RpcArgs { enabled: true, admin_enabled: true }, + rpc_args: RpcArgs { basic_enabled: true, admin_enabled: true }, } } diff --git a/crates/node/src/test_utils/mod.rs b/crates/node/src/test_utils/mod.rs index 9d7e467c..0411862f 100644 --- a/crates/node/src/test_utils/mod.rs +++ b/crates/node/src/test_utils/mod.rs @@ -239,7 +239,7 @@ pub fn default_test_scroll_rollup_node_config() -> ScrollRollupNodeConfig { gas_price_oracle_args: crate::RollupNodeGasPriceOracleArgs::default(), consensus_args: ConsensusArgs::noop(), database: None, - rpc_args: RpcArgs { enabled: true, admin_enabled: true }, + rpc_args: RpcArgs { basic_enabled: true, admin_enabled: true }, } } @@ -279,6 +279,6 @@ pub fn default_sequencer_test_scroll_rollup_node_config() -> ScrollRollupNodeCon gas_price_oracle_args: crate::RollupNodeGasPriceOracleArgs::default(), consensus_args: ConsensusArgs::noop(), database: None, - rpc_args: RpcArgs { enabled: true, admin_enabled: true }, + rpc_args: RpcArgs { basic_enabled: true, admin_enabled: true }, } } From e5392dc40a683d7b98d6b01d313e41727aa35b53 Mon Sep 17 00:00:00 2001 From: Morty Date: Fri, 5 Dec 2025 02:16:59 +0800 Subject: [PATCH 6/9] add --rpc.rollup-node-admin to test --- tests/launch_rollup_node_sequencer.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/launch_rollup_node_sequencer.bash b/tests/launch_rollup_node_sequencer.bash index 0410dfbf..f0aaa2c8 100644 --- a/tests/launch_rollup_node_sequencer.bash +++ b/tests/launch_rollup_node_sequencer.bash @@ -16,6 +16,7 @@ exec rollup-node node --chain /l2reth/l2reth-genesis-e2e.json --datadir=/l2reth --http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ --ws --ws.addr=0.0.0.0 --ws.port=8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ --rpc.rollup-node \ + --rpc.rollup-node-admin \ --log.stdout.format log-fmt -vvv \ --sequencer.enabled \ --sequencer.allow-empty-blocks \ From 24d70f8df4dfc89b4f536d7b955badb1448c315b Mon Sep 17 00:00:00 2001 From: Morty Date: Fri, 5 Dec 2025 02:41:11 +0800 Subject: [PATCH 7/9] address comment --- crates/node/src/args.rs | 2 +- sequencer-migration/common-functions.sh | 4 ++-- sequencer-migration/switch-to-l2reth.sh | 2 +- tests/launch_rollup_node_follower.bash | 1 - tests/launch_rollup_node_sequencer.bash | 1 - tests/src/utils.rs | 4 ++-- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/node/src/args.rs b/crates/node/src/args.rs index 8b6f8262..a5f2c71d 100644 --- a/crates/node/src/args.rs +++ b/crates/node/src/args.rs @@ -752,7 +752,7 @@ pub struct SignerArgs { #[derive(Debug, Default, Clone, clap::Args)] pub struct RpcArgs { /// A boolean to represent if the rollup node basic rpc should be enabled. - #[arg(long = "rpc.rollup-node", num_args=0..=1, default_value_t = true, help = "Enable the rollup node basic RPC namespace(default: true)")] + #[arg(long = "rpc.rollup-node", default_value_t = true, action = ArgAction::Set, help = "Enable the rollup node basic RPC namespace(default: true)")] pub basic_enabled: bool, /// A boolean to represent if the rollup node admin rpc should be enabled. #[arg(long = "rpc.rollup-node-admin", help = "Enable the rollup node admin RPC namespace")] diff --git a/sequencer-migration/common-functions.sh b/sequencer-migration/common-functions.sh index 3b51eeeb..33e3bb14 100644 --- a/sequencer-migration/common-functions.sh +++ b/sequencer-migration/common-functions.sh @@ -129,7 +129,7 @@ stop_l2geth_mining() { # Enable l2reth automatic sequencing enable_l2reth_sequencing() { log_info "Enabling L2RETH automatic sequencing..." - if cast rpc rollupNode_enableAutomaticSequencing --rpc-url "$L2RETH_RPC_URL" >/dev/null 2>&1; then + if cast rpc rollupNodeAdmin_enableAutomaticSequencing --rpc-url "$L2RETH_RPC_URL" >/dev/null 2>&1; then log_success "L2RETH automatic sequencing enabled" return 0 else @@ -141,7 +141,7 @@ enable_l2reth_sequencing() { # Disable l2reth automatic sequencing disable_l2reth_sequencing() { log_info "Disabling L2RETH automatic sequencing..." - if cast rpc rollupNode_disableAutomaticSequencing --rpc-url "$L2RETH_RPC_URL" >/dev/null 2>&1; then + if cast rpc rollupNodeAdmin_disableAutomaticSequencing --rpc-url "$L2RETH_RPC_URL" >/dev/null 2>&1; then log_success "L2RETH automatic sequencing disabled" return 0 else diff --git a/sequencer-migration/switch-to-l2reth.sh b/sequencer-migration/switch-to-l2reth.sh index d06785f9..a7a263ad 100755 --- a/sequencer-migration/switch-to-l2reth.sh +++ b/sequencer-migration/switch-to-l2reth.sh @@ -18,7 +18,7 @@ perform_sequencing_switch() { # Phase 1: Disable L2GETH sequencing log_info "--- Phase 1: Disabling L2GETH sequencing ---" stop_l2geth_mining - + # wait for l2reth to catch up with l2geth log_info "-- Phase 1.5: Waiting for L2RETH to catch up with L2GETH ---" wait_for_l2reth_to_catch_up_with_l2geth diff --git a/tests/launch_rollup_node_follower.bash b/tests/launch_rollup_node_follower.bash index b5304e03..e5e51354 100644 --- a/tests/launch_rollup_node_follower.bash +++ b/tests/launch_rollup_node_follower.bash @@ -8,7 +8,6 @@ exec rollup-node node --chain /l2reth/l2reth-genesis-e2e.json --datadir=/l2reth --network.valid_signer "0xb674ff99cca262c99d3eab5b32796a99188543da" \ --http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ --ws --ws.addr=0.0.0.0 --ws.port=8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ - --rpc.rollup-node \ --log.stdout.format log-fmt -vvv \ --txpool.pending-max-count=1000 \ --builder.gaslimit=30000000 \ diff --git a/tests/launch_rollup_node_sequencer.bash b/tests/launch_rollup_node_sequencer.bash index f0aaa2c8..9ef15170 100644 --- a/tests/launch_rollup_node_sequencer.bash +++ b/tests/launch_rollup_node_sequencer.bash @@ -15,7 +15,6 @@ exec rollup-node node --chain /l2reth/l2reth-genesis-e2e.json --datadir=/l2reth --network.valid_signer "0xb674ff99cca262c99d3eab5b32796a99188543da" \ --http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ --ws --ws.addr=0.0.0.0 --ws.port=8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ - --rpc.rollup-node \ --rpc.rollup-node-admin \ --log.stdout.format log-fmt -vvv \ --sequencer.enabled \ diff --git a/tests/src/utils.rs b/tests/src/utils.rs index 4a6ff0bc..0a415b05 100644 --- a/tests/src/utils.rs +++ b/tests/src/utils.rs @@ -66,7 +66,7 @@ sol! { pub async fn enable_automatic_sequencing(provider: &NamedProvider) -> Result { provider .client() - .request("rollupNode_enableAutomaticSequencing", ()) + .request("rollupNodeAdminAdmin_enableAutomaticSequencing", ()) .await .map_err(|e| eyre::eyre!("Failed to enable automatic sequencing: {}", e)) } @@ -75,7 +75,7 @@ pub async fn enable_automatic_sequencing(provider: &NamedProvider) -> Result Result { provider .client() - .request("rollupNode_disableAutomaticSequencing", ()) + .request("rollupNodeAdmin_disableAutomaticSequencing", ()) .await .map_err(|e| eyre::eyre!("Failed to disable automatic sequencing: {}", e)) } From 9f67b77d983ab22b21652b37869f3f9d2fc20e1c Mon Sep 17 00:00:00 2001 From: Morty Date: Fri, 5 Dec 2025 03:49:58 +0800 Subject: [PATCH 8/9] fix: ci docker --- book/src/running-a-node.md | 3 ++- docker-compose/launch_rollup_node.bash | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/book/src/running-a-node.md b/book/src/running-a-node.md index fc2469f6..702c0154 100644 --- a/book/src/running-a-node.md +++ b/book/src/running-a-node.md @@ -130,7 +130,8 @@ These can be used as reliable blob sources without requiring your own beacon nod #### Rollup Node RPC -- `--rpc.rollup-node`: Enable the rollup node RPC namespace (provides rollup-specific methods) +- `--rpc.rollup-node=false`: Disable the rollup node basic RPC namespace(default: enabled) (provides rollup-specific methods) +- `--rpc.rollup-node-admin`: Enable the rollup node admin RPC namespace (provides rollup-specific methods) ### Example Configurations diff --git a/docker-compose/launch_rollup_node.bash b/docker-compose/launch_rollup_node.bash index bc93bad4..c40266a8 100644 --- a/docker-compose/launch_rollup_node.bash +++ b/docker-compose/launch_rollup_node.bash @@ -48,7 +48,6 @@ elif [ "${ENV:-}" = "sepolia" ]; then exec rollup-node node --chain scroll-sepolia --datadir=/l2reth --metrics=0.0.0.0:6060 --disable-discovery \ --http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ --ws --ws.addr=0.0.0.0 --ws.port=8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ - --rpc.rollup-node \ --log.stdout.format log-fmt -vvv $URL_PARAMS $BEACON_PARAMS $BLOB_S3_PARAMS \ --trusted-peers "enode://29cee709c400533ae038a875b9ca975c8abef9eade956dcf3585e940acd5c0ae916968f514bd37d1278775aad1b7db30f7032a70202a87fd7365bd8de3c9f5fc@44.242.39.33:30303,enode://ceb1636bac5cbb262e5ad5b2cd22014bdb35ffe7f58b3506970d337a63099481814a338dbcd15f2d28757151e3ecd40ba38b41350b793cd0d910ff0436654f8c@35.85.84.250:30303,enode://dd1ac5433c5c2b04ca3166f4cb726f8ff6d2da83dbc16d9b68b1ea83b7079b371eb16ef41c00441b6e85e32e33087f3b7753ea9e8b1e3f26d3e4df9208625e7f@54.148.111.168:30303" elif [ "${ENV:-}" = "mainnet" ]; then @@ -82,7 +81,6 @@ elif [ "${ENV:-}" = "mainnet" ]; then exec rollup-node node --chain scroll-mainnet --datadir=/l2reth --metrics=0.0.0.0:6060 --disable-discovery \ --http --http.addr=0.0.0.0 --http.port=8545 --http.corsdomain "*" --http.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ --ws --ws.addr=0.0.0.0 --ws.port=8546 --ws.api admin,debug,eth,net,trace,txpool,web3,rpc,reth,ots,flashbots,miner,mev \ - --rpc.rollup-node \ --log.stdout.format log-fmt -vvv $URL_PARAMS $BEACON_PARAMS $BLOB_S3_PARAMS \ --trusted-peers "enode://c6ac91f43df3d63916ac1ae411cdd5ba249d55d48a7bec7f8cd5bb351a31aba437e5a69e8a1de74d73fdfeba8af1cfe9caf9846ecd3abf60d1ffdf4925b55b23@54.186.123.248:30303,enode://fdcc807b5d1353f3a1e98b90208ce6ef1b7d446136e51eaa8ad657b55518a2f8b37655e42375d61622e6ea18f3faf9d070c9bbdf012cf5484bcbad33b7a15fb1@44.227.91.206:30303,enode://6beb5a3efbb39be73d17630b6da48e94c0ce7ec665172111463cb470197b20c12faa1fa6f835b81c28571277d1017e65c4e426cc92a46141cf69118ecf28ac03@44.237.194.52:30303,enode://7cf893d444eb8e129dca0f6485b3df579911606e7c728be4fa55fcc5f155a37c3ce07d217ccec5447798bde465ac2bdba2cb8763d107e9f3257e787579e9f27e@52.35.203.107:30303,enode://c7b2d94e95da343db6e667a01cef90376a592f2d277fbcbf6e9c9186734ed8003d01389571bd10cdbab7a6e5adfa6f0c7b55644d0db24e0b9deb4ec80f842075@54.70.236.187:30303" -fi \ No newline at end of file +fi \ No newline at end of file From 04151ee8d042587a9c29638516a781eb194af0c8 Mon Sep 17 00:00:00 2001 From: Morty Date: Fri, 5 Dec 2025 07:32:50 +0800 Subject: [PATCH 9/9] fix: ci docker --- tests/src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/utils.rs b/tests/src/utils.rs index 0a415b05..40c072e4 100644 --- a/tests/src/utils.rs +++ b/tests/src/utils.rs @@ -66,7 +66,7 @@ sol! { pub async fn enable_automatic_sequencing(provider: &NamedProvider) -> Result { provider .client() - .request("rollupNodeAdminAdmin_enableAutomaticSequencing", ()) + .request("rollupNodeAdmin_enableAutomaticSequencing", ()) .await .map_err(|e| eyre::eyre!("Failed to enable automatic sequencing: {}", e)) }