Skip to content

Commit

Permalink
chore(sequencer_node): separate config pointers to required and optional
Browse files Browse the repository at this point in the history
commit-id:0c02cd67
  • Loading branch information
Itay-Tsabary-Starkware committed Nov 1, 2024
1 parent 693475b commit 63d4a98
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
3 changes: 2 additions & 1 deletion crates/mempool_node/src/config/config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::config::{
SequencerNodeConfig,
CONFIG_POINTERS,
DEFAULT_CONFIG_PATH,
REQUIRED_PARAM_CONFIG_POINTERS,
};

/// Test the validation of the struct ComponentExecutionConfig.
Expand Down Expand Up @@ -93,7 +94,7 @@ fn test_default_config_file_is_up_to_date() {
/// Tests parsing a node config without additional args.
#[test]
fn test_config_parsing() {
let args = create_test_config_load_args(&CONFIG_POINTERS);
let args = create_test_config_load_args(&REQUIRED_PARAM_CONFIG_POINTERS);
let config = SequencerNodeConfig::load_and_process(args);
let config = config.expect("Parsing function failed.");

Expand Down
29 changes: 24 additions & 5 deletions crates/mempool_node/src/config/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::BTreeMap;
use std::fs::File;
use std::path::Path;
use std::sync::LazyLock;
use std::vec::Vec;

use clap::Command;
use papyrus_config::dumping::{
Expand Down Expand Up @@ -34,12 +35,30 @@ pub const DEFAULT_CONFIG_PATH: &str = "config/mempool/default_config.json";

// Configuration parameters that share the same value across multiple components.
pub const DEFAULT_CHAIN_ID: ChainId = ChainId::Mainnet;

// Required target parameters.
pub static REQUIRED_PARAM_CONFIG_POINTERS: LazyLock<Vec<(ParamPath, SerializedParam)>> =
LazyLock::new(|| {
vec![ser_pointer_target_required_param(
"chain_id",
SerializationType::String,
"The chain to follow.",
)]
});

// TODO(Tsabary): Create a struct detailing all the required parameters and their types. Add a macro
// that verifies the correctness of the required parameters compared to
// REQUIRED_PARAM_CONFIG_POINTERS.

// Optional target parameters, i.e., target parameters with default values.
pub static DEFAULT_PARAM_CONFIG_POINTERS: LazyLock<Vec<(ParamPath, SerializedParam)>> =
LazyLock::new(Vec::new);

// All target parameters.
pub static CONFIG_POINTERS: LazyLock<Vec<(ParamPath, SerializedParam)>> = LazyLock::new(|| {
vec![ser_pointer_target_required_param(
"chain_id",
SerializationType::String,
"The chain to follow.",
)]
let mut combined = REQUIRED_PARAM_CONFIG_POINTERS.clone();
combined.extend(DEFAULT_PARAM_CONFIG_POINTERS.clone());
combined
});

// TODO(Tsabary): Bundle required config values in a struct, detailing whether they are pointer
Expand Down

0 comments on commit 63d4a98

Please sign in to comment.