diff --git a/crates/papyrus_node/src/bin/dump_config.rs b/crates/papyrus_node/src/bin/dump_config.rs index 9047229fb6..5d4b7ec070 100644 --- a/crates/papyrus_node/src/bin/dump_config.rs +++ b/crates/papyrus_node/src/bin/dump_config.rs @@ -3,46 +3,50 @@ #![cfg_attr(coverage_nightly, feature(coverage_attribute))] #[cfg(feature = "rpc")] -use lazy_static::lazy_static; -#[cfg(feature = "rpc")] -use papyrus_config::dumping::{ser_pointer_target_param, SerializeConfig}; -#[cfg(feature = "rpc")] -use papyrus_config::{ParamPath, SerializedParam}; -#[cfg(feature = "rpc")] -use papyrus_node::config::{NodeConfig, DEFAULT_CONFIG_PATH}; -#[cfg(feature = "rpc")] -use starknet_api::core::ChainId; +mod with_rpc { -#[cfg(feature = "rpc")] -lazy_static! { - /// Returns vector of (pointer target name, pointer target serialized param, vec) - /// to be applied on the dumped node config. - /// The config updates will be performed on the shared pointer targets, and finally, the values - /// will be propagated to the pointer params. - static ref CONFIG_POINTERS: Vec<((ParamPath, SerializedParam), Vec)> = vec![( - ser_pointer_target_param( - "chain_id", - &ChainId("SN_MAIN".to_string()), - "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.", - ), - vec!["storage.db_config.chain_id".to_owned(), "rpc.chain_id".to_owned()], - ), - ( - ser_pointer_target_param( - "starknet_url", - &"https://alpha-mainnet.starknet.io/".to_string(), - "The URL of a centralized Starknet gateway.", + use lazy_static::lazy_static; + use papyrus_config::dumping::{ser_pointer_target_param, SerializeConfig}; + use papyrus_config::{ParamPath, SerializedParam}; + use papyrus_node::config::{NodeConfig, DEFAULT_CONFIG_PATH}; + use starknet_api::core::ChainId; + + lazy_static! { + /// Returns vector of (pointer target name, pointer target serialized param, vec) + /// to be applied on the dumped node config. + /// The config updates will be performed on the shared pointer targets, and finally, the values + /// will be propagated to the pointer params. + static ref CONFIG_POINTERS: Vec<((ParamPath, SerializedParam), Vec)> = vec![( + ser_pointer_target_param( + "chain_id", + &ChainId("SN_MAIN".to_string()), + "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.", + ), + vec!["storage.db_config.chain_id".to_owned(), "rpc.chain_id".to_owned()], ), - vec!["rpc.starknet_url".to_owned(), "central.url".to_owned(), "monitoring_gateway.starknet_url".to_owned()], - ), - ( - ser_pointer_target_param( - "collect_metrics", - &false, - "If true, collect metrics for the node.", + ( + ser_pointer_target_param( + "starknet_url", + &"https://alpha-mainnet.starknet.io/".to_string(), + "The URL of a centralized Starknet gateway.", + ), + vec!["rpc.starknet_url".to_owned(), "central.url".to_owned(), "monitoring_gateway.starknet_url".to_owned()], ), - vec!["rpc.collect_metrics".to_owned(), "monitoring_gateway.collect_metrics".to_owned()], - )]; + ( + ser_pointer_target_param( + "collect_metrics", + &false, + "If true, collect metrics for the node.", + ), + vec!["rpc.collect_metrics".to_owned(), "monitoring_gateway.collect_metrics".to_owned()], + )]; + } + + pub fn dump_config() { + NodeConfig::default() + .dump_to_file(&CONFIG_POINTERS, DEFAULT_CONFIG_PATH) + .expect("dump to file error"); + } } /// Updates the default config file by: @@ -50,9 +54,7 @@ lazy_static! { #[cfg_attr(coverage_nightly, coverage_attribute)] fn main() { #[cfg(feature = "rpc")] - NodeConfig::default() - .dump_to_file(&CONFIG_POINTERS, DEFAULT_CONFIG_PATH) - .expect("dump to file error"); + with_rpc::dump_config(); // TODO(shahak): Try to find a way to remove this binary altogether when the feature rpc is // turned off. #[cfg(not(feature = "rpc"))]