From 2b24aa7dbcab2b840d783cba6270c45c40ae5a3c Mon Sep 17 00:00:00 2001 From: Rob Date: Thu, 9 Nov 2023 14:29:59 -0500 Subject: [PATCH] fix hanging votes --- crates/task-impls/src/consensus.rs | 70 +++++++++++++++--------------- crates/task-impls/src/da.rs | 18 ++++---- crates/task-impls/src/vid.rs | 17 ++++---- 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/crates/task-impls/src/consensus.rs b/crates/task-impls/src/consensus.rs index efb43212cf..abcbfe43a0 100644 --- a/crates/task-impls/src/consensus.rs +++ b/crates/task-impls/src/consensus.rs @@ -978,27 +978,27 @@ where TYPES::Time::new(0) }; - // Todo check if we are the leader - let new_accumulator = VoteAccumulator2 { - vote_outcomes: HashMap::new(), - sig_lists: Vec::new(), - signers: bitvec![0; self.quorum_exchange.total_nodes()], - phantom: PhantomData, - }; + if vote.get_view_number() > collection_view { + // Todo check if we are the leader + let new_accumulator = VoteAccumulator2 { + vote_outcomes: HashMap::new(), + sig_lists: Vec::new(), + signers: bitvec![0; self.quorum_exchange.total_nodes()], + phantom: PhantomData, + }; - let accumulator = - new_accumulator.accumulate(&vote, self.quorum_exchange.membership()); + let accumulator = + new_accumulator.accumulate(&vote, self.quorum_exchange.membership()); - // TODO Create default functions for accumulators - // https://github.com/EspressoSystems/HotShot/issues/1797 - let timeout_accumulator = VoteAccumulator2 { - vote_outcomes: HashMap::new(), - sig_lists: Vec::new(), - signers: bitvec![0; self.timeout_exchange.total_nodes()], - phantom: PhantomData, - }; + // TODO Create default functions for accumulators + // https://github.com/EspressoSystems/HotShot/issues/1797 + let timeout_accumulator = VoteAccumulator2 { + vote_outcomes: HashMap::new(), + sig_lists: Vec::new(), + signers: bitvec![0; self.timeout_exchange.total_nodes()], + phantom: PhantomData, + }; - if vote.get_view_number() > collection_view { let state = VoteCollectionTaskState { quorum_exchange: self.quorum_exchange.clone(), timeout_exchange: self.timeout_exchange.clone(), @@ -1063,27 +1063,27 @@ where TYPES::Time::new(0) }; - // // Todo check if we are the leader - let new_accumulator = VoteAccumulator2 { - vote_outcomes: HashMap::new(), - sig_lists: Vec::new(), - signers: bitvec![0; self.timeout_exchange.total_nodes()], - phantom: PhantomData, - }; + if vote.get_view_number() > collection_view { + // Todo check if we are the leader + let new_accumulator = VoteAccumulator2 { + vote_outcomes: HashMap::new(), + sig_lists: Vec::new(), + signers: bitvec![0; self.timeout_exchange.total_nodes()], + phantom: PhantomData, + }; - let timeout_accumulator = - new_accumulator.accumulate(&vote, self.quorum_exchange.membership()); + let timeout_accumulator = + new_accumulator.accumulate(&vote, self.quorum_exchange.membership()); - let quorum_accumulator = VoteAccumulator2 { - vote_outcomes: HashMap::new(), - sig_lists: Vec::new(), - signers: bitvec![0; self.quorum_exchange.total_nodes()], - phantom: PhantomData, - }; + let quorum_accumulator = VoteAccumulator2 { + vote_outcomes: HashMap::new(), + sig_lists: Vec::new(), + signers: bitvec![0; self.quorum_exchange.total_nodes()], + phantom: PhantomData, + }; - // self.timeout_accumulator = accumulator; + // self.timeout_accumulator = accumulator; - if vote.get_view_number() > collection_view { let state = VoteCollectionTaskState { quorum_exchange: self.quorum_exchange.clone(), timeout_exchange: self.timeout_exchange.clone(), diff --git a/crates/task-impls/src/da.rs b/crates/task-impls/src/da.rs index 0679540b29..b29dab50d5 100644 --- a/crates/task-impls/src/da.rs +++ b/crates/task-impls/src/da.rs @@ -299,17 +299,17 @@ where TYPES::Time::new(0) }; - let new_accumulator = VoteAccumulator2 { - vote_outcomes: HashMap::new(), - sig_lists: Vec::new(), - signers: bitvec![0; self.committee_exchange.total_nodes()], - phantom: PhantomData, - }; + if view > collection_view { + let new_accumulator = VoteAccumulator2 { + vote_outcomes: HashMap::new(), + sig_lists: Vec::new(), + signers: bitvec![0; self.committee_exchange.total_nodes()], + phantom: PhantomData, + }; - let accumulator = - new_accumulator.accumulate(&vote, self.committee_exchange.membership()); + let accumulator = + new_accumulator.accumulate(&vote, self.committee_exchange.membership()); - if view > collection_view { let state = DAVoteCollectionTaskState { committee_exchange: self.committee_exchange.clone(), diff --git a/crates/task-impls/src/vid.rs b/crates/task-impls/src/vid.rs index 56e829c33f..b92b50d8e8 100644 --- a/crates/task-impls/src/vid.rs +++ b/crates/task-impls/src/vid.rs @@ -224,16 +224,17 @@ where TYPES::Time::new(0) }; - let new_accumulator = VoteAccumulator2 { - vote_outcomes: HashMap::new(), - sig_lists: Vec::new(), - signers: bitvec![0; self.vid_exchange.total_nodes()], - phantom: PhantomData, - }; + if view > collection_view { + let new_accumulator = VoteAccumulator2 { + vote_outcomes: HashMap::new(), + sig_lists: Vec::new(), + signers: bitvec![0; self.vid_exchange.total_nodes()], + phantom: PhantomData, + }; - let accumulator = new_accumulator.accumulate(&vote, self.vid_exchange.membership()); + let accumulator = + new_accumulator.accumulate(&vote, self.vid_exchange.membership()); - if view > collection_view { let state = VIDVoteCollectionTaskState { vid_exchange: self.vid_exchange.clone(),