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

comments about quorum threshold changed from (2f + 1) to (N - f) #3373

Merged
merged 1 commit into from
Oct 18, 2024
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
4 changes: 3 additions & 1 deletion node/bft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Each round runs until one of two conditions is met:

#### Advancing Rounds

As described in the paper, the BFT advances rounds whenever n − f vertices are delivered.
As described in the paper [Bullshark: The Partially Synchronous Version](https://arxiv.org/abs/2209.05633),
the BFT generally advances rounds when `n − f` vertices are delivered, however:
```
The problem in advancing rounds whenever n − f vertices are delivered is that parties
might not vote for the anchor even if the party that broadcast it is just slightly slower
Expand All @@ -28,6 +29,7 @@ do not include the anchor of round r, then p sets a timer and waits for the anch
until the timer expires. Similarly, in an odd-numbered round, parties wait for either
f + 1 vertices that vote for the anchor, or 2f + 1 vertices that do not, or a timeout.
```
Note that in this quote `2f + 1` should really be `n - f`.

## Workers

Expand Down
6 changes: 3 additions & 3 deletions node/bft/src/bft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl<N: Network> BFT<N> {
self.is_even_round_ready_for_next_round(current_certificates, committee_lookback, current_round)
}

/// Returns 'true' if the quorum threshold `(2f + 1)` is reached for this round under one of the following conditions:
/// Returns 'true' if the quorum threshold `(N - f)` is reached for this round under one of the following conditions:
/// - If the leader certificate is set for the current even round.
/// - The timer for the leader certificate has expired.
fn is_even_round_ready_for_next_round(
Expand All @@ -347,7 +347,7 @@ impl<N: Network> BFT<N> {
return true;
}
}
// If the timer has expired, and we can achieve quorum threshold (2f + 1) without the leader, return 'true'.
// If the timer has expired, and we can achieve quorum threshold (N - f) without the leader, return 'true'.
if self.is_timer_expired() {
debug!("BFT (timer expired) - Advancing from round {current_round} to the next round (without the leader)");
return true;
Expand All @@ -361,7 +361,7 @@ impl<N: Network> BFT<N> {
self.leader_certificate_timer.load(Ordering::SeqCst) + MAX_LEADER_CERTIFICATE_DELAY_IN_SECS <= now()
}

/// Returns 'true' if the quorum threshold `(2f + 1)` is reached for this round under one of the following conditions:
/// Returns 'true' if the quorum threshold `(N - f)` is reached for this round under one of the following conditions:
/// - The leader certificate is `None`.
/// - The leader certificate is not included up to availability threshold `(f + 1)` (in the previous certificates of the current round).
/// - The leader certificate timer has expired.
Expand Down
8 changes: 4 additions & 4 deletions node/bft/src/helpers/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ impl<N: Network> Storage<N> {
/// - All previous certificates declared in the certificate exist in storage (up to GC).
/// - All previous certificates are for the previous round (i.e. round - 1).
/// - All previous certificates contain a unique author.
/// - The previous certificates reached the quorum threshold (2f+1).
/// - The previous certificates reached the quorum threshold (N - f).
pub fn check_batch_header(
&self,
batch_header: &BatchHeader<N>,
Expand Down Expand Up @@ -458,9 +458,9 @@ impl<N: Network> Storage<N> {
/// - All transmissions declared in the batch header are provided or exist in storage (up to GC).
/// - All previous certificates declared in the certificate exist in storage (up to GC).
/// - All previous certificates are for the previous round (i.e. round - 1).
/// - The previous certificates reached the quorum threshold (2f+1).
/// - The previous certificates reached the quorum threshold (N - f).
/// - The timestamps from the signers are all within the allowed time range.
/// - The signers have reached the quorum threshold (2f+1).
/// - The signers have reached the quorum threshold (N - f).
pub fn check_certificate(
&self,
certificate: &BatchCertificate<N>,
Expand Down Expand Up @@ -530,7 +530,7 @@ impl<N: Network> Storage<N> {
/// - All transmissions declared in the certificate are provided or exist in storage (up to GC).
/// - All previous certificates declared in the certificate exist in storage (up to GC).
/// - All previous certificates are for the previous round (i.e. round - 1).
/// - The previous certificates reached the quorum threshold (2f+1).
/// - The previous certificates reached the quorum threshold (N - f).
pub fn insert_certificate(
&self,
certificate: BatchCertificate<N>,
Expand Down
4 changes: 2 additions & 2 deletions node/bft/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,8 +1549,8 @@ impl<N: Network> Primary<N> {

// Check if our primary should move to the next round.
// Note: Checking that quorum threshold is reached is important for mitigating a race condition,
// whereby Narwhal requires 2f+1, however the BFT only requires f+1. Without this check, the primary
// will advance to the next round assuming f+1, not 2f+1, which can lead to a network stall.
// whereby Narwhal requires N-f, however the BFT only requires f+1. Without this check, the primary
// will advance to the next round assuming f+1, not N-f, which can lead to a network stall.
let is_behind_schedule = is_quorum_threshold_reached && batch_round > self.current_round();
// Check if our primary is far behind the peer.
let is_peer_far_in_future = batch_round > self.current_round() + self.storage.max_gc_rounds();
Expand Down