Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize accumulator logic #2030

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions crates/task-impls/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
18 changes: 9 additions & 9 deletions crates/task-impls/src/da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),

Expand Down
17 changes: 9 additions & 8 deletions crates/task-impls/src/vid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),

Expand Down