From 2e874c2ba8f423fe529930413a30a94cbe0c1259 Mon Sep 17 00:00:00 2001 From: Yael Doweck Date: Tue, 3 Dec 2024 15:31:15 +0200 Subject: [PATCH] chore(starknet_consensus_manager): add chain_id to config --- config/sequencer/default_config.json | 5 +++++ crates/sequencing/papyrus_consensus/src/config.rs | 10 ++++++++++ .../starknet_sequencer_node/src/config/node_config.rs | 1 + 3 files changed, 16 insertions(+) diff --git a/config/sequencer/default_config.json b/config/sequencer/default_config.json index dfbb72e416..46bc4a586c 100644 --- a/config/sequencer/default_config.json +++ b/config/sequencer/default_config.json @@ -614,6 +614,11 @@ "privacy": "Public", "value": "0.0.0.0:8080" }, + "consensus_manager_config.consensus_config.chain_id": { + "description": "The chain id of the Starknet chain.", + "pointer_target": "chain_id", + "privacy": "Public" + }, "consensus_manager_config.consensus_config.consensus_delay": { "description": "Delay (seconds) before starting consensus to give time for network peering.", "privacy": "Public", diff --git a/crates/sequencing/papyrus_consensus/src/config.rs b/crates/sequencing/papyrus_consensus/src/config.rs index 97ed7f4656..771f502572 100644 --- a/crates/sequencing/papyrus_consensus/src/config.rs +++ b/crates/sequencing/papyrus_consensus/src/config.rs @@ -14,6 +14,7 @@ use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_network::NetworkConfig; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; +use starknet_api::core::ChainId; use super::types::ValidatorId; @@ -23,6 +24,8 @@ const CONSENSUS_QUIC_PORT: u16 = 10101; /// Configuration for consensus. #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct ConsensusConfig { + /// The chain id of the Starknet chain. + pub chain_id: ChainId, /// The validator ID of the node. pub validator_id: ValidatorId, /// The network topic of the consensus. @@ -45,6 +48,12 @@ pub struct ConsensusConfig { impl SerializeConfig for ConsensusConfig { fn dump(&self) -> BTreeMap { let mut config = BTreeMap::from_iter([ + ser_param( + "chain_id", + &self.chain_id, + "The chain id of the Starknet chain.", + ParamPrivacyInput::Public, + ), ser_param( "validator_id", &self.validator_id, @@ -90,6 +99,7 @@ impl Default for ConsensusConfig { ..Default::default() }; Self { + chain_id: ChainId::Other("0x0".to_string()), validator_id: ValidatorId::default(), network_topic: "consensus".to_string(), start_height: BlockNumber::default(), diff --git a/crates/starknet_sequencer_node/src/config/node_config.rs b/crates/starknet_sequencer_node/src/config/node_config.rs index 2679e234e7..10ad06ce24 100644 --- a/crates/starknet_sequencer_node/src/config/node_config.rs +++ b/crates/starknet_sequencer_node/src/config/node_config.rs @@ -46,6 +46,7 @@ pub static CONFIG_POINTERS: LazyLock = LazyLock::new(|| { set_pointing_param_paths(&[ "batcher_config.block_builder_config.chain_info.chain_id", "batcher_config.storage.db_config.chain_id", + "consensus_manager_config.consensus_config.chain_id", "consensus_manager_config.consensus_config.network_config.chain_id", "gateway_config.chain_info.chain_id", "mempool_p2p_config.network_config.chain_id",