From 249fc0b83e17e11382f717b6cc3fb3b46432e300 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Tue, 3 Dec 2024 17:14:51 +0200 Subject: [PATCH] chore(consensus): use non zero values as validator id --- config/papyrus/default_config.json | 4 ++-- ...config__config_test__dump_default_config.snap | 2 +- .../sequencing/papyrus_consensus/src/config.rs | 2 +- .../papyrus_consensus/src/test_utils.rs | 2 +- .../src/papyrus_consensus_context_test.rs | 6 +++--- .../src/sequencer_consensus_context_test.rs | 16 ++++++++-------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/config/papyrus/default_config.json b/config/papyrus/default_config.json index ab8323e8ad..ca23decdbc 100644 --- a/config/papyrus/default_config.json +++ b/config/papyrus/default_config.json @@ -197,7 +197,7 @@ "consensus.validator_id": { "description": "The validator id of the node.", "privacy": "Public", - "value": "0x0" + "value": "0x64" }, "monitoring_gateway.collect_metrics": { "description": "If true, collect and return metrics in the monitoring gateway.", @@ -509,4 +509,4 @@ "privacy": "Public", "value": true } -} \ No newline at end of file +} 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 bc2248761a..8dba090377 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 @@ -238,7 +238,7 @@ expression: dumped_default_config }, "consensus.validator_id": { "description": "The validator id of the node.", - "value": "0x0", + "value": "0x64", "privacy": "Public" }, "monitoring_gateway.collect_metrics": { diff --git a/crates/sequencing/papyrus_consensus/src/config.rs b/crates/sequencing/papyrus_consensus/src/config.rs index 97ed7f4656..9567df8d70 100644 --- a/crates/sequencing/papyrus_consensus/src/config.rs +++ b/crates/sequencing/papyrus_consensus/src/config.rs @@ -90,7 +90,7 @@ impl Default for ConsensusConfig { ..Default::default() }; Self { - validator_id: ValidatorId::default(), + validator_id: ValidatorId::from(100_u32), network_topic: "consensus".to_string(), start_height: BlockNumber::default(), num_validators: 1, diff --git a/crates/sequencing/papyrus_consensus/src/test_utils.rs b/crates/sequencing/papyrus_consensus/src/test_utils.rs index 45dcb09fa8..d39e42c1ff 100644 --- a/crates/sequencing/papyrus_consensus/src/test_utils.rs +++ b/crates/sequencing/papyrus_consensus/src/test_utils.rs @@ -39,7 +39,7 @@ impl TryFrom for ProposalInit { Ok(ProposalInit { height: BlockNumber(part.0), round: 0, - proposer: ValidatorId::default(), + proposer: ValidatorId::from(100_u32), valid_round: None, }) } diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context_test.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context_test.rs index 0b6aa4feb4..19dc3fafc8 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context_test.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context_test.rs @@ -39,7 +39,7 @@ async fn build_proposal() { let proposal_init = ProposalInit { height: block_number, round: 0, - proposer: ValidatorId::default(), + proposer: ValidatorId::from(100_u32), valid_round: None, }; // TODO(Asmaa): Test proposal content. @@ -70,7 +70,7 @@ async fn validate_proposal_success() { .validate_proposal( block_number, 0, - ValidatorId::default(), + ValidatorId::from(100_u32), Duration::MAX, validate_receiver, ) @@ -101,7 +101,7 @@ async fn validate_proposal_fail() { .validate_proposal( block_number, 0, - ValidatorId::default(), + ValidatorId::from(100_u32), Duration::MAX, validate_receiver, ) diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs index 3fb1a632c6..f3814ba5a1 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs @@ -128,7 +128,7 @@ async fn build_proposal() { let init = ProposalInit { height: BlockNumber(0), round: 0, - proposer: ValidatorId::default(), + proposer: ValidatorId::from(100_u32), valid_round: None, }; // TODO(Asmaa): Test proposal content. @@ -208,7 +208,7 @@ async fn validate_proposal_success() { .await .unwrap(); let fin_receiver = context - .validate_proposal(BlockNumber(0), 0, ValidatorId::default(), TIMEOUT, content_receiver) + .validate_proposal(BlockNumber(0), 0, ValidatorId::from(100_u32), TIMEOUT, content_receiver) .await; content_sender.close_channel(); assert_eq!(fin_receiver.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); @@ -269,7 +269,7 @@ async fn repropose() { }); content_sender.send(prop_part).await.unwrap(); let fin_receiver = context - .validate_proposal(BlockNumber(0), 0, ValidatorId::default(), TIMEOUT, content_receiver) + .validate_proposal(BlockNumber(0), 0, ValidatorId::from(100_u32), TIMEOUT, content_receiver) .await; content_sender.close_channel(); assert_eq!(fin_receiver.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); @@ -351,7 +351,7 @@ async fn proposals_from_different_rounds() { content_sender.send(prop_part_txs.clone()).await.unwrap(); let fin_receiver_past_round = context - .validate_proposal(BlockNumber(0), 0, ValidatorId::default(), TIMEOUT, content_receiver) + .validate_proposal(BlockNumber(0), 0, ValidatorId::from(100_u32), TIMEOUT, content_receiver) .await; // No fin was sent, channel remains open. assert!(fin_receiver_past_round.await.is_err()); @@ -361,7 +361,7 @@ async fn proposals_from_different_rounds() { content_sender.send(prop_part_txs.clone()).await.unwrap(); content_sender.send(prop_part_fin.clone()).await.unwrap(); let fin_receiver_curr_round = context - .validate_proposal(BlockNumber(0), 1, ValidatorId::default(), TIMEOUT, content_receiver) + .validate_proposal(BlockNumber(0), 1, ValidatorId::from(100_u32), TIMEOUT, content_receiver) .await; assert_eq!(fin_receiver_curr_round.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); @@ -370,7 +370,7 @@ async fn proposals_from_different_rounds() { content_sender.send(prop_part_txs.clone()).await.unwrap(); content_sender.send(prop_part_fin.clone()).await.unwrap(); let fin_receiver_future_round = context - .validate_proposal(BlockNumber(0), 2, ValidatorId::default(), TIMEOUT, content_receiver) + .validate_proposal(BlockNumber(0), 2, ValidatorId::from(100_u32), TIMEOUT, content_receiver) .await; content_sender.close_channel(); // Even with sending fin and closing the channel. @@ -439,7 +439,7 @@ async fn interrupt_active_proposal() { // without needing interrupt. let (mut _content_sender_0, content_receiver) = mpsc::channel(CHANNEL_SIZE); let fin_receiver_0 = context - .validate_proposal(BlockNumber(0), 0, ValidatorId::default(), TIMEOUT, content_receiver) + .validate_proposal(BlockNumber(0), 0, ValidatorId::from(100_u32), TIMEOUT, content_receiver) .await; let (mut content_sender_1, content_receiver) = mpsc::channel(CHANNEL_SIZE); @@ -457,7 +457,7 @@ async fn interrupt_active_proposal() { .await .unwrap(); let fin_receiver_1 = context - .validate_proposal(BlockNumber(0), 1, ValidatorId::default(), TIMEOUT, content_receiver) + .validate_proposal(BlockNumber(0), 1, ValidatorId::from(100_u32), TIMEOUT, content_receiver) .await; // Move the context to the next round. context.set_height_and_round(BlockNumber(0), 1).await;