Skip to content

Commit

Permalink
chore(starknet_consensus_manager): add chain_id to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware committed Dec 5, 2024
1 parent a6a227b commit 215b58a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/papyrus/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
"privacy": "TemporaryValue",
"value": true
},
"consensus.chain_id": {
"description": "The chain id of the Starknet chain.",
"pointer_target": "chain_id",
"privacy": "Public"
},
"consensus.consensus_delay": {
"description": "Delay (seconds) before starting consensus to give time for network peering.",
"privacy": "Public",
Expand Down
5 changes: 5 additions & 0 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions crates/papyrus_node/src/config/pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub static CONFIG_POINTERS: LazyLock<ConfigPointers> = LazyLock::new(|| {
"The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.",
),
set_pointing_param_paths(&[
"consensus.chain_id",
"consensus.network_config.chain_id",
"network.chain_id",
"rpc.chain_id",
Expand Down
10 changes: 10 additions & 0 deletions crates/sequencing/papyrus_consensus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
Expand All @@ -45,6 +48,12 @@ pub struct ConsensusConfig {
impl SerializeConfig for ConsensusConfig {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
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,
Expand Down Expand Up @@ -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(),
Expand Down
3 changes: 2 additions & 1 deletion crates/starknet_sequencer_node/src/config/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ pub static CONFIG_POINTERS: LazyLock<ConfigPointers> = LazyLock::new(|| {
ser_pointer_target_required_param(
"chain_id",
SerializationType::String,
"The chain to follow.",
"The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.",
),
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",
Expand Down

0 comments on commit 215b58a

Please sign in to comment.