Skip to content

Commit

Permalink
fix(mempool_node): fix gateway config to point to chain_id
Browse files Browse the repository at this point in the history
commit-id:24ddd75d
  • Loading branch information
Itay-Tsabary-Starkware committed Oct 9, 2024
1 parent 64d981b commit 0df28d4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
6 changes: 3 additions & 3 deletions config/mempool/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"components.consensus_manager.execute": {
"description": "The component execution flag.",
"privacy": "Public",
"value": true
"value": false
},
"components.consensus_manager.execution_mode": {
"description": "The component execution mode.",
Expand Down Expand Up @@ -306,8 +306,8 @@
},
"gateway_config.chain_info.chain_id": {
"description": "The chain ID of the StarkNet chain.",
"privacy": "Public",
"value": "0x0"
"pointer_target": "chain_id",
"privacy": "Public"
},
"gateway_config.chain_info.fee_token_addresses.eth_fee_token_address": {
"description": "Address of the ETH fee token.",
Expand Down
31 changes: 27 additions & 4 deletions crates/mempool_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use papyrus_config::dumping::{
SerializeConfig,
};
use papyrus_config::loading::load_and_process_config;
use papyrus_config::validators::validate_ascii;
use papyrus_config::{ConfigError, ParamPath, ParamPrivacyInput, SerializedParam};
use serde::{Deserialize, Serialize};
use starknet_api::core::ChainId;
Expand All @@ -36,10 +37,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;
pub static CONFIG_POINTERS: LazyLock<ConfigPointers> = LazyLock::new(|| {
vec![(
ser_pointer_target_param("chain_id", &ChainId::Mainnet, "The chain to follow."),
vec!["batcher_config.storage.db_config.chain_id".to_owned()],
ser_pointer_target_param("chain_id", &DEFAULT_CHAIN_ID, "The chain to follow."),
vec![
"batcher_config.storage.db_config.chain_id".to_owned(),
"gateway_config.chain_info.chain_id".to_owned(),
],
)]
});

Expand Down Expand Up @@ -144,7 +149,7 @@ impl ComponentExecutionConfig {

pub fn consensus_manager_default_config() -> Self {
Self {
execute: true,
execute: false,
execution_mode: ComponentExecutionMode::Local,
local_config: Some(LocalComponentCommunicationConfig::default()),
remote_config: None,
Expand Down Expand Up @@ -237,8 +242,11 @@ pub fn validate_components_config(components: &ComponentConfig) -> Result<(), Va
}

/// The configurations of the various components of the node.
#[derive(Debug, Deserialize, Default, Serialize, Clone, PartialEq, Validate)]
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Validate)]
pub struct SequencerNodeConfig {
/// The [chain id](https://docs.rs/starknet_api/latest/starknet_api/core/struct.ChainId.html) of the Starknet network.
#[validate(custom = "validate_ascii")]
pub chain_id: ChainId,
#[validate]
pub components: ComponentConfig,
#[validate]
Expand Down Expand Up @@ -275,6 +283,21 @@ impl SerializeConfig for SequencerNodeConfig {
}
}

impl Default for SequencerNodeConfig {
fn default() -> Self {
Self {
chain_id: DEFAULT_CHAIN_ID,
components: Default::default(),
batcher_config: Default::default(),
consensus_manager_config: Default::default(),
gateway_config: Default::default(),
http_server_config: Default::default(),
rpc_state_reader_config: Default::default(),
compiler_config: Default::default(),
}
}
}

impl SequencerNodeConfig {
/// Creates a config object. Selects the values from the default file and from resources with
/// higher priority.
Expand Down

0 comments on commit 0df28d4

Please sign in to comment.