Skip to content

Commit

Permalink
chore(consensus): move network parameters into consensus config
Browse files Browse the repository at this point in the history
  • Loading branch information
guy-starkware committed Jan 12, 2025
1 parent 8d4f147 commit 22c3068
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 9 deletions.
15 changes: 15 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.broadcast_buffer_size": {
"description": "The buffer size of each channel, for votes channel and proposals channel.",
"privacy": "Public",
"value": 100
},
"consensus.chain_id": {
"description": "The chain id of the Starknet chain.",
"pointer_target": "chain_id",
Expand Down Expand Up @@ -174,6 +179,11 @@
"privacy": "Public",
"value": 1
},
"consensus.proposals_topic": {
"description": "Name of the topic for streaming proposals.",
"privacy": "Public",
"value": "consensus_proposals"
},
"consensus.start_height": {
"description": "The height to start the consensus from.",
"privacy": "Public",
Expand Down Expand Up @@ -204,6 +214,11 @@
"privacy": "Public",
"value": "0x64"
},
"consensus.votes_topic": {
"description": "Name of the topic for vote messages.",
"privacy": "Public",
"value": "consensus_votes"
},
"monitoring_gateway.collect_metrics": {
"description": "If true, collect and return metrics in the monitoring gateway.",
"pointer_target": "collect_metrics",
Expand Down
15 changes: 15 additions & 0 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@
"pointer_target": "recorder_url",
"privacy": "Private"
},
"consensus_manager_config.consensus_config.broadcast_buffer_size": {
"description": "The buffer size of each channel, for votes channel and proposals channel.",
"privacy": "Public",
"value": 100
},
"consensus_manager_config.consensus_config.chain_id": {
"description": "The chain id of the Starknet chain.",
"pointer_target": "chain_id",
Expand Down Expand Up @@ -669,6 +674,11 @@
"privacy": "Public",
"value": 1
},
"consensus_manager_config.consensus_config.proposals_topic": {
"description": "Name of the topic for streaming proposals.",
"privacy": "Public",
"value": "consensus_proposals"
},
"consensus_manager_config.consensus_config.start_height": {
"description": "The height to start the consensus from.",
"privacy": "Public",
Expand Down Expand Up @@ -699,6 +709,11 @@
"pointer_target": "validator_id",
"privacy": "Public"
},
"consensus_manager_config.consensus_config.votes_topic": {
"description": "Name of the topic for vote messages.",
"privacy": "Public",
"value": "consensus_votes"
},
"eth_fee_token_address": {
"description": "A required param! Address of the ETH fee token.",
"param_type": "String",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ expression: dumped_default_config
"value": true,
"privacy": "TemporaryValue"
},
"consensus.broadcast_buffer_size": {
"description": "The buffer size of each channel, for votes channel and proposals channel.",
"value": {
"$serde_json::private::Number": "100"
},
"privacy": "Public"
},
"consensus.chain_id": {
"description": "The chain id of the Starknet chain.",
"value": "0x0",
Expand Down Expand Up @@ -206,6 +213,11 @@ expression: dumped_default_config
},
"privacy": "Public"
},
"consensus.proposals_topic": {
"description": "Name of the topic for streaming proposals.",
"value": "consensus_proposals",
"privacy": "Public"
},
"consensus.start_height": {
"description": "The height to start the consensus from.",
"value": {
Expand Down Expand Up @@ -246,6 +258,11 @@ expression: dumped_default_config
"value": "0x64",
"privacy": "Public"
},
"consensus.votes_topic": {
"description": "Name of the topic for vote messages.",
"value": "consensus_votes",
"privacy": "Public"
},
"monitoring_gateway.collect_metrics": {
"description": "If true, collect and return metrics in the monitoring gateway.",
"value": false,
Expand Down
27 changes: 27 additions & 0 deletions crates/sequencing/papyrus_consensus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ pub struct ConsensusConfig {
/// The network configuration for the consensus.
#[validate]
pub network_config: NetworkConfig,
/// The buffer size of each channel, for votes channel and proposals channel.
pub broadcast_buffer_size: usize,
/// Name of the topic for streaming proposals.
pub proposals_topic: String,
/// Name of the topic for vote messages.
pub votes_topic: String,
}

impl SerializeConfig for ConsensusConfig {
Expand Down Expand Up @@ -94,6 +100,24 @@ impl SerializeConfig for ConsensusConfig {
"The duration (seconds) between sync attempts.",
ParamPrivacyInput::Public,
),
ser_param(
"broadcast_buffer_size",
&self.broadcast_buffer_size,
"The buffer size of each channel, for votes channel and proposals channel.",
ParamPrivacyInput::Public,
),
ser_param(
"proposals_topic",
&self.proposals_topic,
"Name of the topic for streaming proposals.",
ParamPrivacyInput::Public,
),
ser_param(
"votes_topic",
&self.votes_topic,
"Name of the topic for vote messages.",
ParamPrivacyInput::Public,
),
]);
config.extend(append_sub_config_name(self.timeouts.dump(), "timeouts"));
config.extend(append_sub_config_name(self.network_config.dump(), "network_config"));
Expand All @@ -114,6 +138,9 @@ impl Default for ConsensusConfig {
timeouts: TimeoutsConfig::default(),
sync_retry_interval: Duration::from_secs_f64(1.0),
network_config,
broadcast_buffer_size: 100,
proposals_topic: "consensus_proposals".to_string(),
votes_topic: "consensus_votes".to_string(),
}
}
}
Expand Down
13 changes: 4 additions & 9 deletions crates/starknet_consensus_manager/src/consensus_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ use tracing::{error, info};

use crate::config::ConsensusManagerConfig;

// TODO(Dan, Guy): move to config.
pub const BROADCAST_BUFFER_SIZE: usize = 100;
pub const CONSENSUS_PROPOSALS_TOPIC: &str = "consensus_proposals";
pub const CONSENSUS_VOTES_TOPIC: &str = "consensus_votes";

#[derive(Clone)]
pub struct ConsensusManager {
pub config: ConsensusManagerConfig,
Expand All @@ -45,15 +40,15 @@ impl ConsensusManager {

let proposals_broadcast_channels = network_manager
.register_broadcast_topic::<StreamMessage<ProposalPart, HeightAndRound>>(
Topic::new(CONSENSUS_PROPOSALS_TOPIC),
BROADCAST_BUFFER_SIZE,
Topic::new(self.config.consensus_config.proposals_topic.clone()),
self.config.consensus_config.broadcast_buffer_size,
)
.expect("Failed to register broadcast topic");

let votes_broadcast_channels = network_manager
.register_broadcast_topic::<Vote>(
Topic::new(CONSENSUS_VOTES_TOPIC),
BROADCAST_BUFFER_SIZE,
Topic::new(self.config.consensus_config.votes_topic.clone()),
self.config.consensus_config.broadcast_buffer_size,
)
.expect("Failed to register broadcast topic");

Expand Down
1 change: 1 addition & 0 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub const UNDEPLOYED_ACCOUNT_ID: AccountId = 2;
// Transactions per second sent to the gateway. This rate makes each block contain ~10 transactions
// with the set [TimeoutsConfig] .
pub const TPS: u64 = 2;
const TEST_CONSENSUS_PROPOSALS_TOPIC: &str = "consensus_proposals";

pub fn create_chain_info() -> ChainInfo {
let mut chain_info = ChainInfo::create_for_testing();
Expand Down

0 comments on commit 22c3068

Please sign in to comment.