Skip to content

Commit

Permalink
chore(sequencer_node): set chain_id as required param
Browse files Browse the repository at this point in the history
commit-id:a52a7e16
  • Loading branch information
Itay-Tsabary-Starkware committed Oct 30, 2024
1 parent bdb72e6 commit 1545731
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
6 changes: 3 additions & 3 deletions config/mempool/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@
"value": "StateOnly"
},
"chain_id": {
"description": "The chain to follow.",
"privacy": "TemporaryValue",
"value": "SN_MAIN"
"description": "A required param! The chain to follow.",
"param_type": "String",
"privacy": "TemporaryValue"
},
"compiler_config.max_bytecode_size": {
"description": "Limitation of contract bytecode size.",
Expand Down
3 changes: 1 addition & 2 deletions crates/mempool_node/src/config/component_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ impl Default for ComponentConfig {

impl SerializeConfig for ComponentConfig {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
#[allow(unused_mut)]
let mut sub_configs = vec![
let sub_configs = vec![
append_sub_config_name(self.batcher.dump(), "batcher"),
append_sub_config_name(self.consensus_manager.dump(), "consensus_manager"),
append_sub_config_name(self.gateway.dump(), "gateway"),
Expand Down
9 changes: 3 additions & 6 deletions crates/mempool_node/src/config/config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use starknet_sequencer_infra::component_definitions::{
use validator::Validate;

use crate::config::{
node_command,
create_test_config_load_args,
ComponentExecutionConfig,
ComponentExecutionMode,
SequencerNodeConfig,
Expand Down Expand Up @@ -93,11 +93,8 @@ fn test_default_config_file_is_up_to_date() {
/// Tests parsing a node config without additional args.
#[test]
fn test_config_parsing() {
let config_file_name = get_absolute_path(DEFAULT_CONFIG_PATH);
let config = SequencerNodeConfig::load_and_process_file(
vec![node_command().to_string()],
config_file_name.to_str().unwrap(),
);
let args = create_test_config_load_args(&CONFIG_POINTERS);
let config = SequencerNodeConfig::load_and_process(args);
let config = config.expect("Parsing function failed.");

let result = config_validate(&config);
Expand Down
17 changes: 12 additions & 5 deletions crates/mempool_node/src/config/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ use std::path::Path;
use std::sync::LazyLock;

use clap::Command;
use papyrus_config::dumping::{append_sub_config_name, ser_pointer_target_param, SerializeConfig};
use papyrus_config::dumping::{
append_sub_config_name,
ser_pointer_target_required_param,
SerializeConfig,
};
use papyrus_config::loading::load_and_process_config;
use papyrus_config::validators::validate_ascii;
#[cfg(any(feature = "testing", test))]
use papyrus_config::SerializationType;
#[cfg(any(feature = "testing", test))]
use papyrus_config::SerializedContent;
use papyrus_config::{ConfigError, ParamPath, SerializedParam};
use papyrus_config::{ConfigError, ParamPath, SerializationType, SerializedParam};
use serde::{Deserialize, Serialize};
use starknet_api::core::ChainId;
use starknet_batcher::config::BatcherConfig;
Expand All @@ -33,9 +35,14 @@ pub const DEFAULT_CONFIG_PATH: &str = "config/mempool/default_config.json";
// Configuration parameters that share the same value across multiple components.
type ConfigPointers = Vec<((ParamPath, SerializedParam), Vec<ParamPath>)>;
pub const DEFAULT_CHAIN_ID: ChainId = ChainId::Mainnet;
// TODO(Tsabary/AlonH): Discuss testing of required parameters.
pub static CONFIG_POINTERS: LazyLock<ConfigPointers> = LazyLock::new(|| {
vec![(
ser_pointer_target_param("chain_id", &DEFAULT_CHAIN_ID, "The chain to follow."),
ser_pointer_target_required_param(
"chain_id",
SerializationType::String,
"The chain to follow.",
),
vec![
"batcher_config.block_builder_config.chain_info.chain_id".to_owned(),
"batcher_config.storage.db_config.chain_id".to_owned(),
Expand Down
7 changes: 5 additions & 2 deletions crates/tests-integration/src/integration_test_config_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ pub fn dump_config_file_changes(config: SequencerNodeConfig) -> anyhow::Result<(
dump_json_data(json_data, NODE_CONFIG_CHANGES_FILE_PATH)?;

// Dump config changes file for the transaction generator.
let json_data =
config_fields_to_json!(config.http_server_config.ip, config.http_server_config.port,);
let json_data = config_fields_to_json!(
config.chain_id,
config.http_server_config.ip,
config.http_server_config.port,
);
dump_json_data(json_data, TX_GEN_CONFIG_CHANGES_FILE_PATH)?;

Ok(())
Expand Down

0 comments on commit 1545731

Please sign in to comment.