Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

Commit

Permalink
build(node): separate dump config exe to module
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahakShama committed Feb 14, 2024
1 parent 0801a30 commit dd3a245
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 36 deletions.
41 changes: 5 additions & 36 deletions crates/papyrus_node/src/bin/dump_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,16 @@
#![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};
#[path = "dump_config/with_rpc.rs"]
mod with_rpc;

#[cfg(feature = "rpc")]
use papyrus_config::{ParamPath, SerializedParam};
use papyrus_config::dumping::SerializeConfig;
#[cfg(feature = "rpc")]
use papyrus_node::config::{NodeConfig, DEFAULT_CONFIG_PATH};
#[cfg(feature = "rpc")]
use starknet_api::core::ChainId;

#[cfg(feature = "rpc")]
lazy_static! {
/// Returns vector of (pointer target name, pointer target serialized param, vec<pointer param path>)
/// 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<ParamPath>)> = 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.",
),
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.",
),
vec!["rpc.collect_metrics".to_owned(), "monitoring_gateway.collect_metrics".to_owned()],
)];
}
use self::with_rpc::CONFIG_POINTERS;

/// Updates the default config file by:
/// cargo run --bin dump_config -q
Expand Down
35 changes: 35 additions & 0 deletions crates/papyrus_node/src/bin/dump_config/with_rpc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use lazy_static::lazy_static;
use papyrus_config::dumping::ser_pointer_target_param;
use papyrus_config::{ParamPath, SerializedParam};
use starknet_api::core::ChainId;

lazy_static! {
/// Returns vector of (pointer target name, pointer target serialized param, vec<pointer param path>)
/// 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.
pub static ref CONFIG_POINTERS: Vec<((ParamPath, SerializedParam), Vec<ParamPath>)> = 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.",
),
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.",
),
vec!["rpc.collect_metrics".to_owned(), "monitoring_gateway.collect_metrics".to_owned()],
)];
}

0 comments on commit dd3a245

Please sign in to comment.