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

Revert "Avoid unnecessary calculations in propose_batch" #3273

Merged
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
23 changes: 9 additions & 14 deletions node/bft/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,6 @@ impl<N: Network> Primary<N> {
// Compute the previous round.
let previous_round = round.saturating_sub(1);

// If the current round is 0, return early.
ensure!(round > 0, "Round 0 cannot have transaction batches");

// If the current storage round is below the latest proposal round, then return early.
if round < *lock_guard {
warn!("Cannot propose a batch for round {round} - the latest proposal cache round is {}", *lock_guard);
Expand Down Expand Up @@ -422,16 +419,6 @@ impl<N: Network> Primary<N> {
return Ok(());
}

// Determine if the current round has been proposed.
// Note: Do NOT make this judgment in advance before rebroadcast and round update. Rebroadcasting is
// good for network reliability and should not be prevented for the already existing proposed_batch.
// If a certificate already exists for the current round, an attempt should be made to advance the
// round as early as possible.
if round == *lock_guard {
warn!("Primary is safely skipping a batch proposal - round {round} already proposed");
return Ok(());
}

// Retrieve the committee to check against.
let committee_lookback = self.ledger.get_committee_lookback_for_round(round)?;
// Check if the primary is connected to enough validators to reach quorum threshold.
Expand Down Expand Up @@ -540,9 +527,17 @@ impl<N: Network> Primary<N> {
}
}
}

// Ditto if the batch had already been proposed and not expired.
ensure!(round > 0, "Round 0 cannot have transaction batches");
// Determine the current timestamp.
let current_timestamp = now();
// Determine if the current proposal is expired.
if *lock_guard == round {
warn!("Primary is safely skipping a batch proposal - round {round} already proposed");
// Reinsert the transmissions back into the ready queue for the next proposal.
self.reinsert_transmissions_into_workers(transmissions)?;
return Ok(());
}

*lock_guard = round;

Expand Down