From 08fd054fcddafd6fa9868be8cb203e2876096973 Mon Sep 17 00:00:00 2001 From: Matan Markind Date: Mon, 12 Aug 2024 13:00:07 +0300 Subject: [PATCH] refactor(consensus): rename topic in config to network_topic This is prep for adding sync_topic. --- config/papyrus/default_config.json | 10 +++++----- ..._config__config_test__dump_default_config.snap | 10 +++++----- crates/papyrus_node/src/main.rs | 15 ++++++++------- crates/sequencing/papyrus_consensus/src/config.rs | 10 +++++----- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/config/papyrus/default_config.json b/config/papyrus/default_config.json index 67d6a0427df..a35bffc1074 100644 --- a/config/papyrus/default_config.json +++ b/config/papyrus/default_config.json @@ -84,6 +84,11 @@ "privacy": "Public", "value": 5 }, + "consensus.network_topic": { + "description": "The network topic of the consensus.", + "privacy": "Public", + "value": "consensus" + }, "consensus.num_validators": { "description": "The number of validators in the consensus.", "privacy": "Public", @@ -119,11 +124,6 @@ "privacy": "Public", "value": 0 }, - "consensus.topic": { - "description": "The topic of the consensus.", - "privacy": "Public", - "value": "consensus" - }, "consensus.validator_id": { "description": "A required param! The validator id of the node.", "param_type": "String", diff --git a/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap b/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap index 8329b8ee614..b0288f85cee 100644 --- a/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap +++ b/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap @@ -96,6 +96,11 @@ expression: dumped_default_config }, "privacy": "Public" }, + "consensus.network_topic": { + "description": "The network topic of the consensus.", + "value": "consensus", + "privacy": "Public" + }, "consensus.num_validators": { "description": "The number of validators in the consensus.", "value": { @@ -143,11 +148,6 @@ expression: dumped_default_config }, "privacy": "Public" }, - "consensus.topic": { - "description": "The topic of the consensus.", - "value": "consensus", - "privacy": "Public" - }, "consensus.validator_id": { "description": "A required param! The validator id of the node.", "param_type": "String", diff --git a/crates/papyrus_node/src/main.rs b/crates/papyrus_node/src/main.rs index 79105414285..3817b2b9971 100644 --- a/crates/papyrus_node/src/main.rs +++ b/crates/papyrus_node/src/main.rs @@ -364,13 +364,14 @@ fn run_network( let event_server_channel = network_manager.register_sqmr_protocol_server(Protocol::Event.into(), BUFFER_SIZE); - let consensus_channels = match consensus_config { - Some(consensus_config) => Some( - network_manager - .register_broadcast_topic(Topic::new(consensus_config.topic), BUFFER_SIZE)?, - ), - None => None, - }; + let consensus_channels = + match consensus_config { + Some(consensus_config) => Some(network_manager.register_broadcast_topic( + Topic::new(consensus_config.network_topic), + BUFFER_SIZE, + )?), + None => None, + }; let p2p_sync_client_channels = P2PSyncClientChannels::new( header_client_sender, state_diff_client_sender, diff --git a/crates/sequencing/papyrus_consensus/src/config.rs b/crates/sequencing/papyrus_consensus/src/config.rs index 8253fea50ee..6994bcf547a 100644 --- a/crates/sequencing/papyrus_consensus/src/config.rs +++ b/crates/sequencing/papyrus_consensus/src/config.rs @@ -24,7 +24,7 @@ pub struct ConsensusConfig { /// The validator ID of the node. pub validator_id: ValidatorId, /// The network topic of the consensus. - pub topic: String, + pub network_topic: String, /// The height to start the consensus from. pub start_height: BlockNumber, /// The number of validators in the consensus. @@ -47,9 +47,9 @@ impl SerializeConfig for ConsensusConfig { ParamPrivacyInput::Public, ), ser_param( - "topic", - &self.topic, - "The topic of the consensus.", + "network_topic", + &self.network_topic, + "The network topic of the consensus.", ParamPrivacyInput::Public, ), ser_param( @@ -80,7 +80,7 @@ impl Default for ConsensusConfig { fn default() -> Self { Self { validator_id: ValidatorId::default(), - topic: "consensus".to_string(), + network_topic: "consensus".to_string(), start_height: BlockNumber::default(), num_validators: 4, consensus_delay: Duration::from_secs(5),