From 38d7da875c89b34afc04c6ffa27f53e314146ec8 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Thu, 28 Nov 2024 15:42:41 +0200 Subject: [PATCH] chore(starknet_consensus_manager): set proposer address in propose block input --- .../papyrus_consensus/src/manager_test.rs | 27 ++++++---- .../src/single_height_consensus.rs | 25 +++++++-- .../src/single_height_consensus_test.rs | 14 ++--- .../papyrus_consensus/src/test_utils.rs | 8 ++- .../sequencing/papyrus_consensus/src/types.rs | 8 ++- .../src/papyrus_consensus_context.rs | 11 ++-- .../src/papyrus_consensus_context_test.rs | 21 ++++++-- .../src/sequencer_consensus_context.rs | 32 ++++++++--- .../src/sequencer_consensus_context_test.rs | 53 +++++++++++-------- 9 files changed, 136 insertions(+), 63 deletions(-) diff --git a/crates/sequencing/papyrus_consensus/src/manager_test.rs b/crates/sequencing/papyrus_consensus/src/manager_test.rs index 4f03cc0a8a..b27b17ecae 100644 --- a/crates/sequencing/papyrus_consensus/src/manager_test.rs +++ b/crates/sequencing/papyrus_consensus/src/manager_test.rs @@ -58,6 +58,7 @@ mock! { &mut self, height: BlockNumber, round: Round, + proposer: ValidatorId, timeout: Duration, content: mpsc::Receiver ) -> oneshot::Receiver<(ProposalContentId, ProposalFin)>; @@ -80,8 +81,12 @@ mock! { precommits: Vec, ) -> Result<(), ConsensusError>; - async fn set_height_and_round(&mut self, height: BlockNumber, round: Round); - + async fn set_height_and_round( + &mut self, + height: BlockNumber, + round: Round, + proposer: ValidatorId + ); } } @@ -123,7 +128,7 @@ async fn manager_multiple_heights_unordered() { // Run the manager for height 1. context .expect_validate_proposal() - .return_once(move |_, _, _, _| { + .return_once(move |_, _, _, _, _| { let (block_sender, block_receiver) = oneshot::channel(); block_sender .send(( @@ -136,7 +141,7 @@ async fn manager_multiple_heights_unordered() { .times(1); context.expect_validators().returning(move |_| vec![*PROPOSER_ID, *VALIDATOR_ID]); context.expect_proposer().returning(move |_, _| *PROPOSER_ID); - context.expect_set_height_and_round().returning(move |_, _| ()); + context.expect_set_height_and_round().returning(move |_, _, _| ()); context.expect_broadcast().returning(move |_| Ok(())); let mut manager = MultiHeightManager::new(*VALIDATOR_ID, TIMEOUTS.clone()); @@ -155,7 +160,7 @@ async fn manager_multiple_heights_unordered() { // Run the manager for height 2. context .expect_validate_proposal() - .return_once(move |_, _, _, _| { + .return_once(move |_, _, _, _, _| { let (block_sender, block_receiver) = oneshot::channel(); block_sender .send(( @@ -188,7 +193,7 @@ async fn run_consensus_sync() { // TODO(guyn): refactor this test to pass proposals through the correct channels. let (mut proposal_receiver_sender, proposal_receiver_receiver) = mpsc::channel(CHANNEL_SIZE); - context.expect_validate_proposal().return_once(move |_, _, _, _| { + context.expect_validate_proposal().return_once(move |_, _, _, _, _| { let (block_sender, block_receiver) = oneshot::channel(); block_sender .send((BlockHash(Felt::TWO), ProposalFin { proposal_content_id: BlockHash(Felt::TWO) })) @@ -197,7 +202,7 @@ async fn run_consensus_sync() { }); context.expect_validators().returning(move |_| vec![*PROPOSER_ID, *VALIDATOR_ID]); context.expect_proposer().returning(move |_, _| *PROPOSER_ID); - context.expect_set_height_and_round().returning(move |_, _| ()); + context.expect_set_height_and_round().returning(move |_, _, _| ()); context.expect_broadcast().returning(move |_| Ok(())); context.expect_decision_reached().return_once(move |block, votes| { assert_eq!(block, BlockHash(Felt::TWO)); @@ -258,7 +263,7 @@ async fn run_consensus_sync_cancellation_safety() { // TODO(guyn): refactor this test to pass proposals through the correct channels. let (mut proposal_receiver_sender, proposal_receiver_receiver) = mpsc::channel(CHANNEL_SIZE); - context.expect_validate_proposal().return_once(move |_, _, _, _| { + context.expect_validate_proposal().return_once(move |_, _, _, _, _| { let (block_sender, block_receiver) = oneshot::channel(); block_sender .send((BlockHash(Felt::ONE), ProposalFin { proposal_content_id: BlockHash(Felt::ONE) })) @@ -267,7 +272,7 @@ async fn run_consensus_sync_cancellation_safety() { }); context.expect_validators().returning(move |_| vec![*PROPOSER_ID, *VALIDATOR_ID]); context.expect_proposer().returning(move |_, _| *PROPOSER_ID); - context.expect_set_height_and_round().returning(move |_, _| ()); + context.expect_set_height_and_round().returning(move |_, _, _| ()); context.expect_broadcast().with(eq(prevote(Some(Felt::ONE), 1, 0, *VALIDATOR_ID))).return_once( move |_| { proposal_handled_tx.send(()).unwrap(); @@ -345,8 +350,8 @@ async fn test_timeouts() { send(&mut sender, precommit(None, 1, 0, *VALIDATOR_ID_3)).await; let mut context = MockTestContext::new(); - context.expect_set_height_and_round().returning(move |_, _| ()); - context.expect_validate_proposal().returning(move |_, _, _, _| { + context.expect_set_height_and_round().returning(move |_, _, _| ()); + context.expect_validate_proposal().returning(move |_, _, _, _, _| { let (block_sender, block_receiver) = oneshot::channel(); block_sender .send((BlockHash(Felt::ONE), ProposalFin { proposal_content_id: BlockHash(Felt::ONE) })) diff --git a/crates/sequencing/papyrus_consensus/src/single_height_consensus.rs b/crates/sequencing/papyrus_consensus/src/single_height_consensus.rs index c36c3d7e79..e4c55f3b73 100644 --- a/crates/sequencing/papyrus_consensus/src/single_height_consensus.rs +++ b/crates/sequencing/papyrus_consensus/src/single_height_consensus.rs @@ -183,11 +183,15 @@ impl SingleHeightConsensus { context: &mut ContextT, ) -> Result { info!("Starting consensus with validators {:?}", self.validators); - context.set_height_and_round(self.height, self.state_machine.round()).await; + context + .set_height_and_round(self.height, self.state_machine.round(), ValidatorId::default()) + .await; let leader_fn = |round: Round| -> ValidatorId { context.proposer(self.height, round) }; let events = self.state_machine.start(&leader_fn); let ret = self.handle_state_machine_events(context, events).await; - context.set_height_and_round(self.height, self.state_machine.round()).await; + context + .set_height_and_round(self.height, self.state_machine.round(), ValidatorId::default()) + .await; ret } @@ -229,11 +233,14 @@ impl SingleHeightConsensus { .validate_proposal( self.height, init.round, + init.proposer, self.timeouts.proposal_timeout, p2p_messages_receiver, ) .await; - context.set_height_and_round(self.height, self.state_machine.round()).await; + context + .set_height_and_round(self.height, self.state_machine.round(), ValidatorId::default()) + .await; Ok(ShcReturn::Tasks(vec![ShcTask::ValidateProposal(init, block_receiver)])) } @@ -261,7 +268,13 @@ impl SingleHeightConsensus { } ConsensusMessage::Vote(vote) => { let ret = self.handle_vote(context, vote).await; - context.set_height_and_round(self.height, self.state_machine.round()).await; + context + .set_height_and_round( + self.height, + self.state_machine.round(), + ValidatorId::default(), + ) + .await; ret } } @@ -354,7 +367,9 @@ impl SingleHeightConsensus { } _ => unimplemented!("Unexpected event: {:?}", event), }; - context.set_height_and_round(self.height, self.state_machine.round()).await; + context + .set_height_and_round(self.height, self.state_machine.round(), ValidatorId::default()) + .await; ret } diff --git a/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs b/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs index 2d3d14fac4..c236d8b599 100644 --- a/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs +++ b/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs @@ -91,7 +91,7 @@ async fn proposer() { block_sender.send(BLOCK.id).unwrap(); block_receiver }); - context.expect_set_height_and_round().returning(move |_, _| ()); + context.expect_set_height_and_round().returning(move |_, _, _| ()); context .expect_broadcast() .times(1) @@ -171,12 +171,12 @@ async fn validator(repeat_proposal: bool) { ); context.expect_proposer().returning(move |_, _| *PROPOSER_ID); - context.expect_validate_proposal().times(1).returning(move |_, _, _, _| { + context.expect_validate_proposal().times(1).returning(move |_, _, _, _, _| { let (block_sender, block_receiver) = oneshot::channel(); block_sender.send((BLOCK.id, PROPOSAL_FIN.clone())).unwrap(); block_receiver }); - context.expect_set_height_and_round().returning(move |_, _| ()); + context.expect_set_height_and_round().returning(move |_, _, _| ()); context .expect_broadcast() .times(1) @@ -250,12 +250,12 @@ async fn vote_twice(same_vote: bool) { ); context.expect_proposer().times(1).returning(move |_, _| *PROPOSER_ID); - context.expect_validate_proposal().times(1).returning(move |_, _, _, _| { + context.expect_validate_proposal().times(1).returning(move |_, _, _, _, _| { let (block_sender, block_receiver) = oneshot::channel(); block_sender.send((BLOCK.id, PROPOSAL_FIN.clone())).unwrap(); block_receiver }); - context.expect_set_height_and_round().returning(move |_, _| ()); + context.expect_set_height_and_round().returning(move |_, _, _| ()); context .expect_broadcast() .times(1) // Shows the repeat vote is ignored. @@ -324,7 +324,7 @@ async fn rebroadcast_votes() { block_sender.send(BLOCK.id).unwrap(); block_receiver }); - context.expect_set_height_and_round().returning(move |_, _| ()); + context.expect_set_height_and_round().returning(move |_, _, _| ()); context .expect_broadcast() .times(1) @@ -386,7 +386,7 @@ async fn repropose() { block_sender.send(BLOCK.id).unwrap(); block_receiver }); - context.expect_set_height_and_round().returning(move |_, _| ()); + context.expect_set_height_and_round().returning(move |_, _, _| ()); context .expect_broadcast() .times(1) diff --git a/crates/sequencing/papyrus_consensus/src/test_utils.rs b/crates/sequencing/papyrus_consensus/src/test_utils.rs index 66d128b117..7168af5d1c 100644 --- a/crates/sequencing/papyrus_consensus/src/test_utils.rs +++ b/crates/sequencing/papyrus_consensus/src/test_utils.rs @@ -78,6 +78,7 @@ mock! { &mut self, height: BlockNumber, round: Round, + proposer: ValidatorId, timeout: Duration, content: mpsc::Receiver ) -> oneshot::Receiver<(ProposalContentId, ProposalFin)>; @@ -100,7 +101,12 @@ mock! { precommits: Vec, ) -> Result<(), ConsensusError>; - async fn set_height_and_round(&mut self, height: BlockNumber, round: Round); + async fn set_height_and_round( + &mut self, + height: BlockNumber, + round: Round, + proposer: ValidatorId + ); } } diff --git a/crates/sequencing/papyrus_consensus/src/types.rs b/crates/sequencing/papyrus_consensus/src/types.rs index 282185ed47..20897b6ec4 100644 --- a/crates/sequencing/papyrus_consensus/src/types.rs +++ b/crates/sequencing/papyrus_consensus/src/types.rs @@ -77,6 +77,7 @@ pub trait ConsensusContext { &mut self, height: BlockNumber, round: Round, + proposer: ValidatorId, timeout: Duration, content: mpsc::Receiver, ) -> oneshot::Receiver<(ProposalContentId, ProposalFin)>; @@ -113,7 +114,12 @@ pub trait ConsensusContext { /// Update the context with the current height and round. /// Must be called at the beginning of each height. - async fn set_height_and_round(&mut self, height: BlockNumber, round: Round); + async fn set_height_and_round( + &mut self, + height: BlockNumber, + round: Round, + proposer: ValidatorId, + ); } #[derive(PartialEq)] diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context.rs index ad3f6fa0ec..a14e7f2391 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context.rs @@ -36,7 +36,6 @@ use papyrus_storage::body::BodyStorageReader; use papyrus_storage::header::HeaderStorageReader; use papyrus_storage::{StorageError, StorageReader}; use starknet_api::block::BlockNumber; -use starknet_api::core::ContractAddress; use starknet_api::transaction::Transaction; use tracing::{debug, debug_span, info, warn, Instrument}; @@ -70,7 +69,7 @@ impl PapyrusConsensusContext { storage_reader, network_broadcast_client, network_proposal_sender, - validators: (0..num_validators).map(ContractAddress::from).collect(), + validators: (0..num_validators).map(ValidatorId::from).collect(), sync_broadcast_sender, valid_proposals: Arc::new(Mutex::new(BTreeMap::new())), } @@ -167,6 +166,7 @@ impl ConsensusContext for PapyrusConsensusContext { &mut self, height: BlockNumber, _round: Round, + _proposer: ValidatorId, _timeout: Duration, mut content: mpsc::Receiver, ) -> oneshot::Receiver<(ProposalContentId, ProposalFin)> { @@ -305,7 +305,12 @@ impl ConsensusContext for PapyrusConsensusContext { Ok(()) } - async fn set_height_and_round(&mut self, _height: BlockNumber, _round: Round) { + async fn set_height_and_round( + &mut self, + _height: BlockNumber, + _round: Round, + _proposer: ValidatorId, + ) { // No-op } } 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 49b1c5c7ff..0b6aa4feb4 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 @@ -3,7 +3,7 @@ use std::time::Duration; use futures::channel::{mpsc, oneshot}; use futures::StreamExt; use papyrus_consensus::stream_handler::StreamHandler; -use papyrus_consensus::types::ConsensusContext; +use papyrus_consensus::types::{ConsensusContext, ValidatorId}; use papyrus_network::network_manager::test_utils::{ mock_register_broadcast_topic, BroadcastNetworkMock, @@ -24,7 +24,6 @@ use papyrus_storage::header::HeaderStorageWriter; use papyrus_storage::test_utils::get_test_storage; use papyrus_test_utils::get_test_block; use starknet_api::block::{Block, BlockHash}; -use starknet_api::core::ContractAddress; use crate::papyrus_consensus_context::PapyrusConsensusContext; @@ -40,7 +39,7 @@ async fn build_proposal() { let proposal_init = ProposalInit { height: block_number, round: 0, - proposer: ContractAddress::default(), + proposer: ValidatorId::default(), valid_round: None, }; // TODO(Asmaa): Test proposal content. @@ -68,7 +67,13 @@ async fn validate_proposal_success() { validate_sender.close_channel(); let fin = papyrus_context - .validate_proposal(block_number, 0, Duration::MAX, validate_receiver) + .validate_proposal( + block_number, + 0, + ValidatorId::default(), + Duration::MAX, + validate_receiver, + ) .await .await .unwrap(); @@ -93,7 +98,13 @@ async fn validate_proposal_fail() { validate_sender.close_channel(); let fin = papyrus_context - .validate_proposal(block_number, 0, Duration::MAX, validate_receiver) + .validate_proposal( + block_number, + 0, + ValidatorId::default(), + Duration::MAX, + validate_receiver, + ) .await .await; assert_eq!(fin, Err(oneshot::Canceled)); diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs index 7ffe207133..bdceb70875 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs @@ -141,7 +141,12 @@ impl ConsensusContext for SequencerConsensusContext { timeout: Duration, ) -> oneshot::Receiver { // Handles interrupting an active proposal from a previous height/round - self.set_height_and_round(proposal_init.height, proposal_init.round).await; + self.set_height_and_round( + proposal_init.height, + proposal_init.round, + proposal_init.proposer, + ) + .await; debug!( "Building proposal for height: {} with timeout: {:?}", proposal_init.height, timeout @@ -173,7 +178,7 @@ impl ConsensusContext for SequencerConsensusContext { now.timestamp().try_into().expect("Failed to convert timestamp"), ), use_kzg_da: true, - ..Default::default() + sequencer_address: proposal_init.proposer, }, }; // TODO: Should we be returning an error? @@ -219,6 +224,7 @@ impl ConsensusContext for SequencerConsensusContext { &mut self, height: BlockNumber, round: Round, + proposer: ValidatorId, timeout: Duration, content_receiver: mpsc::Receiver, ) -> oneshot::Receiver<(ProposalContentId, ProposalFin)> { @@ -232,8 +238,14 @@ impl ConsensusContext for SequencerConsensusContext { fin_receiver } std::cmp::Ordering::Equal => { - self.validate_current_round_proposal(height, timeout, content_receiver, fin_sender) - .await; + self.validate_current_round_proposal( + height, + proposer, + timeout, + content_receiver, + fin_sender, + ) + .await; fin_receiver } } @@ -295,7 +307,12 @@ impl ConsensusContext for SequencerConsensusContext { Ok(()) } - async fn set_height_and_round(&mut self, height: BlockNumber, round: Round) { + async fn set_height_and_round( + &mut self, + height: BlockNumber, + round: Round, + proposer: ValidatorId, + ) { if self.current_height.map(|h| height > h).unwrap_or(true) { self.current_height = Some(height); assert_eq!(round, 0); @@ -337,7 +354,7 @@ impl ConsensusContext for SequencerConsensusContext { let Some(((height, timeout, content), fin_sender)) = to_process else { return; }; - self.validate_current_round_proposal(height, timeout, content, fin_sender).await; + self.validate_current_round_proposal(height, proposer, timeout, content, fin_sender).await; } } @@ -345,6 +362,7 @@ impl SequencerConsensusContext { async fn validate_current_round_proposal( &mut self, height: BlockNumber, + proposer: ValidatorId, timeout: Duration, content_receiver: mpsc::Receiver, fin_sender: oneshot::Sender<(ProposalContentId, ProposalFin)>, @@ -374,7 +392,7 @@ impl SequencerConsensusContext { now.timestamp().try_into().expect("Failed to convert timestamp"), ), use_kzg_da: true, - ..Default::default() + sequencer_address: proposer, }, }; batcher.validate_block(input).await.expect("Failed to initiate proposal validation"); 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 b6c1b0788f..fac88a0050 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 @@ -6,7 +6,7 @@ use futures::channel::mpsc; use futures::{FutureExt, SinkExt}; use lazy_static::lazy_static; use papyrus_consensus::stream_handler::StreamHandler; -use papyrus_consensus::types::ConsensusContext; +use papyrus_consensus::types::{ConsensusContext, ValidatorId}; use papyrus_network::network_manager::test_utils::{ mock_register_broadcast_topic, BroadcastNetworkMock, @@ -21,7 +21,7 @@ use papyrus_protobuf::consensus::{ TransactionBatch, }; use starknet_api::block::{BlockHash, BlockNumber}; -use starknet_api::core::{ContractAddress, StateDiffCommitment}; +use starknet_api::core::StateDiffCommitment; use starknet_api::executable_transaction::{ AccountTransaction, Transaction as ExecutableTransaction, @@ -128,7 +128,7 @@ async fn build_proposal() { let init = ProposalInit { height: BlockNumber(0), round: 0, - proposer: ContractAddress::default(), + proposer: ValidatorId::default(), valid_round: None, }; // TODO(Asmaa): Test proposal content. @@ -188,7 +188,7 @@ async fn validate_proposal_success() { NUM_VALIDATORS, ); // Initialize the context for a specific height, starting with round 0. - context.set_height_and_round(BlockNumber(0), 0).await; + context.set_height_and_round(BlockNumber(0), 0, ValidatorId::default()).await; let (mut content_sender, content_receiver) = mpsc::channel(CHANNEL_SIZE); let tx_hash = TX_BATCH.first().unwrap().tx_hash(); @@ -207,8 +207,9 @@ async fn validate_proposal_success() { })) .await .unwrap(); - let fin_receiver = - context.validate_proposal(BlockNumber(0), 0, TIMEOUT, content_receiver).await; + let fin_receiver = context + .validate_proposal(BlockNumber(0), 0, ValidatorId::default(), TIMEOUT, content_receiver) + .await; content_sender.close_channel(); assert_eq!(fin_receiver.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); } @@ -254,7 +255,7 @@ async fn repropose() { NUM_VALIDATORS, ); // Initialize the context for a specific height, starting with round 0. - context.set_height_and_round(BlockNumber(0), 0).await; + context.set_height_and_round(BlockNumber(0), 0, ValidatorId::default()).await; // Receive a valid proposal. let (mut content_sender, content_receiver) = mpsc::channel(CHANNEL_SIZE); @@ -267,8 +268,9 @@ async fn repropose() { proposal_content_id: BlockHash(STATE_DIFF_COMMITMENT.0.0), }); content_sender.send(prop_part).await.unwrap(); - let fin_receiver = - context.validate_proposal(BlockNumber(0), 0, TIMEOUT, content_receiver).await; + let fin_receiver = context + .validate_proposal(BlockNumber(0), 0, ValidatorId::default(), TIMEOUT, content_receiver) + .await; content_sender.close_channel(); assert_eq!(fin_receiver.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); @@ -332,8 +334,8 @@ async fn proposals_from_different_rounds() { NUM_VALIDATORS, ); // Initialize the context for a specific height, starting with round 0. - context.set_height_and_round(BlockNumber(0), 0).await; - context.set_height_and_round(BlockNumber(0), 1).await; + context.set_height_and_round(BlockNumber(0), 0, ValidatorId::default()).await; + context.set_height_and_round(BlockNumber(0), 1, ValidatorId::default()).await; // Proposal parts sent in the proposals. let prop_part_txs = ProposalPart::Transactions(TransactionBatch { @@ -348,8 +350,9 @@ async fn proposals_from_different_rounds() { let (mut content_sender, content_receiver) = mpsc::channel(CHANNEL_SIZE); content_sender.send(prop_part_txs.clone()).await.unwrap(); - let fin_receiver_past_round = - context.validate_proposal(BlockNumber(0), 0, TIMEOUT, content_receiver).await; + let fin_receiver_past_round = context + .validate_proposal(BlockNumber(0), 0, ValidatorId::default(), TIMEOUT, content_receiver) + .await; // No fin was sent, channel remains open. assert!(fin_receiver_past_round.await.is_err()); @@ -357,16 +360,18 @@ async fn proposals_from_different_rounds() { let (mut content_sender, content_receiver) = mpsc::channel(CHANNEL_SIZE); 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, TIMEOUT, content_receiver).await; + let fin_receiver_curr_round = context + .validate_proposal(BlockNumber(0), 1, ValidatorId::default(), TIMEOUT, content_receiver) + .await; assert_eq!(fin_receiver_curr_round.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); // The proposal from the future round should not be processed. let (mut content_sender, content_receiver) = mpsc::channel(CHANNEL_SIZE); 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, TIMEOUT, content_receiver).await; + let fin_receiver_future_round = context + .validate_proposal(BlockNumber(0), 2, ValidatorId::default(), TIMEOUT, content_receiver) + .await; content_sender.close_channel(); // Even with sending fin and closing the channel. assert!(fin_receiver_future_round.now_or_never().is_none()); @@ -428,13 +433,14 @@ async fn interrupt_active_proposal() { NUM_VALIDATORS, ); // Initialize the context for a specific height, starting with round 0. - context.set_height_and_round(BlockNumber(0), 0).await; + context.set_height_and_round(BlockNumber(0), 0, ValidatorId::default()).await; // Keep the sender open, as closing it or sending Fin would cause the validate to complete // without needing interrupt. let (mut _content_sender_0, content_receiver) = mpsc::channel(CHANNEL_SIZE); - let fin_receiver_0 = - context.validate_proposal(BlockNumber(0), 0, TIMEOUT, content_receiver).await; + let fin_receiver_0 = context + .validate_proposal(BlockNumber(0), 0, ValidatorId::default(), TIMEOUT, content_receiver) + .await; let (mut content_sender_1, content_receiver) = mpsc::channel(CHANNEL_SIZE); content_sender_1 @@ -450,10 +456,11 @@ async fn interrupt_active_proposal() { })) .await .unwrap(); - let fin_receiver_1 = - context.validate_proposal(BlockNumber(0), 1, TIMEOUT, content_receiver).await; + let fin_receiver_1 = context + .validate_proposal(BlockNumber(0), 1, ValidatorId::default(), TIMEOUT, content_receiver) + .await; // Move the context to the next round. - context.set_height_and_round(BlockNumber(0), 1).await; + context.set_height_and_round(BlockNumber(0), 1, ValidatorId::default()).await; // Interrupt active proposal. assert!(fin_receiver_0.await.is_err());