Skip to content

Commit 9edd11c

Browse files
authored
feat: disable scroll rpc by default (#329)
* refactor cli args * clean up
1 parent f4fc6e0 commit 9edd11c

File tree

9 files changed

+137
-95
lines changed

9 files changed

+137
-95
lines changed

crates/node/Cargo.toml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,8 @@ alloy-rpc-types-eth = { workspace = true }
120120
[features]
121121
js-tracer = ["reth-scroll-node/js-tracer", "reth-scroll-rpc/js-tracer"]
122122
test-utils = [
123-
"reth-chainspec/test-utils",
124-
"reth-evm/test-utils",
125-
"reth-e2e-test-utils",
126123
"reth-engine-local",
127-
"reth-network/test-utils",
128-
"reth-node-builder/test-utils",
129-
"reth-provider/test-utils",
130-
"reth-revm/test-utils",
131-
"reth-scroll-node/test-utils",
132-
"reth-transaction-pool/test-utils",
133124
"reth-trie-db/test-utils",
134-
"rollup-node-providers/test-utils",
135-
"rollup-node-watcher/test-utils",
136-
"scroll-db/test-utils",
137-
"scroll-engine/test-utils",
138125
"reth-chainspec/test-utils",
139126
"reth-evm/test-utils",
140127
"reth-network/test-utils",
@@ -143,7 +130,6 @@ test-utils = [
143130
"reth-revm/test-utils",
144131
"reth-scroll-node/test-utils",
145132
"reth-transaction-pool/test-utils",
146-
"reth-trie-db/test-utils",
147133
"rollup-node-providers/test-utils",
148134
"rollup-node-watcher/test-utils",
149135
"scroll-db/test-utils",
@@ -155,5 +141,4 @@ test-utils = [
155141
"alloy-rpc-types-engine",
156142
"scroll-derivation-pipeline",
157143
"reth-primitives-traits/test-utils",
158-
"reth-primitives-traits/test-utils",
159144
]

crates/node/src/add_ons/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@ where
129129

130130
let (tx, rx) = tokio::sync::oneshot::channel();
131131
let rollup_node_rpc_ext = RollupNodeRpcExt::<N::Network>::new(rx);
132-
rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| {
133-
ctx.modules.merge_configured(rollup_node_rpc_ext.into_rpc())?;
134-
Ok(())
135-
});
132+
if rollup_node_manager_addon.config().rpc_args.enabled {
133+
rpc_add_ons = rpc_add_ons.extend_rpc_modules(move |ctx| {
134+
ctx.modules.merge_configured(rollup_node_rpc_ext.into_rpc())?;
135+
Ok(())
136+
});
137+
}
136138

137139
let rpc_handle = rpc_add_ons.launch_add_ons_with(ctx.clone(), |_| Ok(())).await?;
138140
let (rollup_manager_handle, l1_watcher_tx) =

crates/node/src/add_ons/rollup.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ impl RollupManagerAddOn {
4545
Self { config, scroll_wire_event }
4646
}
4747

48+
/// Returns a reference to the scroll rollup node config.
49+
pub const fn config(&self) -> &ScrollRollupNodeConfig {
50+
&self.config
51+
}
52+
4853
/// Launch the rollup node manager addon.
4954
pub async fn launch<N: FullNodeComponents, EthApi: EthApiTypes>(
5055
self,

crates/node/src/args.rs

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub struct ScrollRollupNodeConfig {
5858
pub consensus_args: ConsensusArgs,
5959
/// Database args
6060
#[command(flatten)]
61-
pub database_args: DatabaseArgs,
61+
pub database_args: RollupNodeDatabaseArgs,
6262
/// Chain orchestrator args.
6363
#[command(flatten)]
6464
pub chain_orchestrator_args: ChainOrchestratorArgs,
@@ -76,13 +76,16 @@ pub struct ScrollRollupNodeConfig {
7676
pub sequencer_args: SequencerArgs,
7777
/// The network arguments
7878
#[command(flatten)]
79-
pub network_args: NetworkArgs,
79+
pub network_args: RollupNodeNetworkArgs,
80+
/// The rpc arguments
81+
#[command(flatten)]
82+
pub rpc_args: RpcArgs,
8083
/// The signer arguments
8184
#[command(flatten)]
8285
pub signer_args: SignerArgs,
8386
/// The gas price oracle args
8487
#[command(flatten)]
85-
pub gas_price_oracle_args: GasPriceOracleArgs,
88+
pub gas_price_oracle_args: RollupNodeGasPriceOracleArgs,
8689
/// The database connection (not parsed via CLI but hydrated after validation).
8790
#[arg(skip)]
8891
pub database: Option<Arc<Database>>,
@@ -127,7 +130,7 @@ impl ScrollRollupNodeConfig {
127130
) -> eyre::Result<()> {
128131
// Instantiate the database
129132
let db_path = node_config.datadir().db();
130-
let database_path = if let Some(database_path) = &self.database_args.path {
133+
let database_path = if let Some(database_path) = &self.database_args.rn_db_path {
131134
database_path.to_string_lossy().to_string()
132135
} else {
133136
// append the path using strings as using `join(...)` overwrites "sqlite://"
@@ -408,10 +411,14 @@ impl ScrollRollupNodeConfig {
408411

409412
/// The database arguments.
410413
#[derive(Debug, Default, Clone, clap::Args)]
411-
pub struct DatabaseArgs {
414+
pub struct RollupNodeDatabaseArgs {
412415
/// Database path
413-
#[arg(long)]
414-
pub path: Option<PathBuf>,
416+
#[arg(
417+
long = "rollup-node-db.path",
418+
value_name = "DB_PATH",
419+
help = "The database path for the rollup node database"
420+
)]
421+
pub rn_db_path: Option<PathBuf>,
415422
}
416423

417424
/// The database arguments.
@@ -510,7 +517,7 @@ impl Default for ChainOrchestratorArgs {
510517

511518
/// The network arguments.
512519
#[derive(Debug, Clone, clap::Args)]
513-
pub struct NetworkArgs {
520+
pub struct RollupNodeNetworkArgs {
514521
/// A bool to represent if new blocks should be bridged from the eth wire protocol to the
515522
/// scroll wire protocol.
516523
#[arg(long = "network.bridge")]
@@ -530,7 +537,7 @@ pub struct NetworkArgs {
530537
pub signer_address: Option<Address>,
531538
}
532539

533-
impl Default for NetworkArgs {
540+
impl Default for RollupNodeNetworkArgs {
534541
fn default() -> Self {
535542
Self {
536543
enable_eth_scroll_wire_bridge: true,
@@ -541,7 +548,7 @@ impl Default for NetworkArgs {
541548
}
542549
}
543550

544-
impl NetworkArgs {
551+
impl RollupNodeNetworkArgs {
545552
/// Get the default authorized signer address for the given chain.
546553
pub const fn default_authorized_signer(chain: Option<NamedChain>) -> Option<Address> {
547554
match chain {
@@ -673,6 +680,14 @@ pub struct SignerArgs {
673680
pub private_key: Option<PrivateKeySigner>,
674681
}
675682

683+
/// The arguments for the rpc.
684+
#[derive(Debug, Default, Clone, clap::Args)]
685+
pub struct RpcArgs {
686+
/// A boolean to represent if the rollup node rpc should be enabled.
687+
#[arg(long = "rpc.rollup-node", help = "Enable the rollup node RPC namespace")]
688+
pub enabled: bool,
689+
}
690+
676691
impl SignerArgs {
677692
/// Create a signer based on the configured arguments
678693
pub async fn signer(
@@ -740,7 +755,7 @@ impl SignerArgs {
740755

741756
/// The arguments for the sequencer.
742757
#[derive(Debug, Default, Clone, clap::Args)]
743-
pub struct GasPriceOracleArgs {
758+
pub struct RollupNodeGasPriceOracleArgs {
744759
/// Minimum suggested priority fee (tip) in wei, default `100`
745760
#[arg(long, default_value_t = 100)]
746761
#[arg(long = "gpo.default-suggest-priority-fee", id = "default_suggest_priority_fee", value_name = "DEFAULT_SUGGEST_PRIORITY_FEE", default_value_t = constants::DEFAULT_SUGGEST_PRIORITY_FEE)]
@@ -773,20 +788,22 @@ mod tests {
773788
#[test]
774789
fn test_network_args_default_authorized_signer() {
775790
// Test Scroll mainnet
776-
let mainnet_signer = NetworkArgs::default_authorized_signer(Some(NamedChain::Scroll));
791+
let mainnet_signer =
792+
RollupNodeNetworkArgs::default_authorized_signer(Some(NamedChain::Scroll));
777793
assert_eq!(mainnet_signer, Some(constants::SCROLL_MAINNET_SIGNER));
778794

779795
// Test Scroll Sepolia
780796
let sepolia_signer =
781-
NetworkArgs::default_authorized_signer(Some(NamedChain::ScrollSepolia));
797+
RollupNodeNetworkArgs::default_authorized_signer(Some(NamedChain::ScrollSepolia));
782798
assert_eq!(sepolia_signer, Some(constants::SCROLL_SEPOLIA_SIGNER));
783799

784800
// Test other chains
785-
let other_signer = NetworkArgs::default_authorized_signer(Some(NamedChain::Mainnet));
801+
let other_signer =
802+
RollupNodeNetworkArgs::default_authorized_signer(Some(NamedChain::Mainnet));
786803
assert_eq!(other_signer, None);
787804

788805
// Test None chain
789-
let none_signer = NetworkArgs::default_authorized_signer(None);
806+
let none_signer = RollupNodeNetworkArgs::default_authorized_signer(None);
790807
assert_eq!(none_signer, None);
791808
}
792809

@@ -796,11 +813,11 @@ mod tests {
796813

797814
// Test with configured signer
798815
let network_args =
799-
NetworkArgs { signer_address: Some(custom_signer), ..Default::default() };
816+
RollupNodeNetworkArgs { signer_address: Some(custom_signer), ..Default::default() };
800817
assert_eq!(network_args.effective_signer(Some(NamedChain::Scroll)), Some(custom_signer));
801818

802819
// Test without configured signer, fallback to default
803-
let network_args_default = NetworkArgs::default();
820+
let network_args_default = RollupNodeNetworkArgs::default();
804821
assert_eq!(
805822
network_args_default.effective_signer(Some(NamedChain::Scroll)),
806823
Some(constants::SCROLL_MAINNET_SIGNER)
@@ -818,18 +835,19 @@ mod tests {
818835
test: false,
819836
sequencer_args: SequencerArgs { sequencer_enabled: true, ..Default::default() },
820837
signer_args: SignerArgs { key_file: None, aws_kms_key_id: None, private_key: None },
821-
database_args: DatabaseArgs::default(),
838+
database_args: RollupNodeDatabaseArgs::default(),
822839
engine_driver_args: EngineDriverArgs::default(),
823840
chain_orchestrator_args: ChainOrchestratorArgs::default(),
824841
l1_provider_args: L1ProviderArgs::default(),
825842
blob_provider_args: BlobProviderArgs::default(),
826-
network_args: NetworkArgs::default(),
827-
gas_price_oracle_args: GasPriceOracleArgs::default(),
843+
network_args: RollupNodeNetworkArgs::default(),
844+
gas_price_oracle_args: RollupNodeGasPriceOracleArgs::default(),
828845
consensus_args: ConsensusArgs {
829846
algorithm: ConsensusAlgorithm::SystemContract,
830847
authorized_signer: None,
831848
},
832849
database: None,
850+
rpc_args: RpcArgs::default(),
833851
};
834852

835853
let result = config.validate();
@@ -849,18 +867,19 @@ mod tests {
849867
aws_kms_key_id: Some("key-id".to_string()),
850868
private_key: None,
851869
},
852-
database_args: DatabaseArgs::default(),
870+
database_args: RollupNodeDatabaseArgs::default(),
853871
engine_driver_args: EngineDriverArgs::default(),
854872
chain_orchestrator_args: ChainOrchestratorArgs::default(),
855873
l1_provider_args: L1ProviderArgs::default(),
856874
blob_provider_args: BlobProviderArgs::default(),
857-
network_args: NetworkArgs::default(),
858-
gas_price_oracle_args: GasPriceOracleArgs::default(),
875+
network_args: RollupNodeNetworkArgs::default(),
876+
gas_price_oracle_args: RollupNodeGasPriceOracleArgs::default(),
859877
consensus_args: ConsensusArgs {
860878
algorithm: ConsensusAlgorithm::SystemContract,
861879
authorized_signer: None,
862880
},
863881
database: None,
882+
rpc_args: RpcArgs::default(),
864883
};
865884

866885
let result = config.validate();
@@ -878,15 +897,16 @@ mod tests {
878897
aws_kms_key_id: None,
879898
private_key: None,
880899
},
881-
database_args: DatabaseArgs::default(),
900+
database_args: RollupNodeDatabaseArgs::default(),
882901
chain_orchestrator_args: ChainOrchestratorArgs::default(),
883902
engine_driver_args: EngineDriverArgs::default(),
884903
l1_provider_args: L1ProviderArgs::default(),
885904
blob_provider_args: BlobProviderArgs::default(),
886-
network_args: NetworkArgs::default(),
887-
gas_price_oracle_args: GasPriceOracleArgs::default(),
905+
network_args: RollupNodeNetworkArgs::default(),
906+
gas_price_oracle_args: RollupNodeGasPriceOracleArgs::default(),
888907
consensus_args: ConsensusArgs::noop(),
889908
database: None,
909+
rpc_args: RpcArgs::default(),
890910
};
891911

892912
assert!(config.validate().is_ok());
@@ -902,15 +922,16 @@ mod tests {
902922
aws_kms_key_id: Some("key-id".to_string()),
903923
private_key: None,
904924
},
905-
database_args: DatabaseArgs::default(),
925+
database_args: RollupNodeDatabaseArgs::default(),
906926
engine_driver_args: EngineDriverArgs::default(),
907927
chain_orchestrator_args: ChainOrchestratorArgs::default(),
908928
l1_provider_args: L1ProviderArgs::default(),
909929
blob_provider_args: BlobProviderArgs::default(),
910-
network_args: NetworkArgs::default(),
911-
gas_price_oracle_args: GasPriceOracleArgs::default(),
930+
network_args: RollupNodeNetworkArgs::default(),
931+
gas_price_oracle_args: RollupNodeGasPriceOracleArgs::default(),
912932
consensus_args: ConsensusArgs::noop(),
913933
database: None,
934+
rpc_args: RpcArgs::default(),
914935
};
915936

916937
assert!(config.validate().is_ok());
@@ -922,15 +943,16 @@ mod tests {
922943
test: false,
923944
sequencer_args: SequencerArgs { sequencer_enabled: false, ..Default::default() },
924945
signer_args: SignerArgs { key_file: None, aws_kms_key_id: None, private_key: None },
925-
database_args: DatabaseArgs::default(),
946+
database_args: RollupNodeDatabaseArgs::default(),
926947
engine_driver_args: EngineDriverArgs::default(),
927948
chain_orchestrator_args: ChainOrchestratorArgs::default(),
928949
l1_provider_args: L1ProviderArgs::default(),
929950
blob_provider_args: BlobProviderArgs::default(),
930-
network_args: NetworkArgs::default(),
931-
gas_price_oracle_args: GasPriceOracleArgs::default(),
951+
network_args: RollupNodeNetworkArgs::default(),
952+
gas_price_oracle_args: RollupNodeGasPriceOracleArgs::default(),
932953
consensus_args: ConsensusArgs::noop(),
933954
database: None,
955+
rpc_args: RpcArgs::default(),
934956
};
935957

936958
assert!(config.validate().is_ok());

crates/node/src/builder/network.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use scroll_db::{
2323
use std::{fmt, fmt::Debug, sync::Arc};
2424
use tracing::{debug, info, trace, warn};
2525

26-
use crate::args::NetworkArgs;
26+
use crate::args::RollupNodeNetworkArgs;
2727

2828
/// The network builder for Scroll.
2929
#[derive(Debug)]
@@ -78,7 +78,7 @@ where
7878
// get the header transform.
7979
let chain_spec = ctx.chain_spec();
8080
let authorized_signer = if self.signer.is_none() {
81-
NetworkArgs::default_authorized_signer(chain_spec.chain().named())
81+
RollupNodeNetworkArgs::default_authorized_signer(chain_spec.chain().named())
8282
} else {
8383
self.signer
8484
};

crates/node/src/test_utils.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! This crate contains utilities for running end-to-end tests for the scroll reth node.
22
3-
use crate::{ConsensusArgs, GasPriceOracleArgs};
3+
use crate::{ConsensusArgs, RollupNodeGasPriceOracleArgs};
44

55
use super::{
6-
BlobProviderArgs, ChainOrchestratorArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs,
7-
ScrollRollupNode, ScrollRollupNodeConfig, SequencerArgs,
6+
BlobProviderArgs, ChainOrchestratorArgs, EngineDriverArgs, L1ProviderArgs,
7+
RollupNodeDatabaseArgs, RpcArgs, ScrollRollupNode, ScrollRollupNodeConfig, SequencerArgs,
88
};
99
use alloy_primitives::Bytes;
1010
use reth_chainspec::EthChainSpec;
@@ -141,8 +141,8 @@ pub async fn generate_tx(wallet: Arc<Mutex<Wallet>>) -> Bytes {
141141
pub fn default_test_scroll_rollup_node_config() -> ScrollRollupNodeConfig {
142142
ScrollRollupNodeConfig {
143143
test: true,
144-
network_args: crate::args::NetworkArgs::default(),
145-
database_args: DatabaseArgs::default(),
144+
network_args: crate::args::RollupNodeNetworkArgs::default(),
145+
database_args: RollupNodeDatabaseArgs::default(),
146146
l1_provider_args: L1ProviderArgs::default(),
147147
engine_driver_args: EngineDriverArgs { sync_at_startup: true },
148148
chain_orchestrator_args: ChainOrchestratorArgs {
@@ -156,9 +156,10 @@ pub fn default_test_scroll_rollup_node_config() -> ScrollRollupNodeConfig {
156156
},
157157
blob_provider_args: BlobProviderArgs { mock: true, ..Default::default() },
158158
signer_args: Default::default(),
159-
gas_price_oracle_args: GasPriceOracleArgs::default(),
159+
gas_price_oracle_args: RollupNodeGasPriceOracleArgs::default(),
160160
consensus_args: ConsensusArgs::noop(),
161161
database: None,
162+
rpc_args: RpcArgs { enabled: true },
162163
}
163164
}
164165

@@ -173,8 +174,10 @@ pub fn default_test_scroll_rollup_node_config() -> ScrollRollupNodeConfig {
173174
pub fn default_sequencer_test_scroll_rollup_node_config() -> ScrollRollupNodeConfig {
174175
ScrollRollupNodeConfig {
175176
test: true,
176-
network_args: crate::args::NetworkArgs::default(),
177-
database_args: DatabaseArgs { path: Some(PathBuf::from("sqlite::memory:")) },
177+
network_args: crate::args::RollupNodeNetworkArgs::default(),
178+
database_args: RollupNodeDatabaseArgs {
179+
rn_db_path: Some(PathBuf::from("sqlite::memory:")),
180+
},
178181
l1_provider_args: L1ProviderArgs::default(),
179182
engine_driver_args: EngineDriverArgs { sync_at_startup: true },
180183
chain_orchestrator_args: ChainOrchestratorArgs {
@@ -193,8 +196,9 @@ pub fn default_sequencer_test_scroll_rollup_node_config() -> ScrollRollupNodeCon
193196
},
194197
blob_provider_args: BlobProviderArgs { mock: true, ..Default::default() },
195198
signer_args: Default::default(),
196-
gas_price_oracle_args: GasPriceOracleArgs::default(),
199+
gas_price_oracle_args: RollupNodeGasPriceOracleArgs::default(),
197200
consensus_args: ConsensusArgs::noop(),
198201
database: None,
202+
rpc_args: RpcArgs { enabled: true },
199203
}
200204
}

0 commit comments

Comments
 (0)