Skip to content

Commit

Permalink
Handle quorum certificate failure gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
moshababo committed Dec 5, 2023
1 parent a7c953d commit fbed5d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 9 additions & 6 deletions node/actors/bft/src/leader/replica_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub(crate) enum Error {
/// Invalid message signature.
#[error("invalid signature: {0:#}")]
InvalidSignature(#[source] validator::Error),
/// Unexpected error when creating justification from received messages.
#[error("create justification unexpected error: {0:#}")]
CreateJustificationUnexpectedError(#[source] anyhow::Error),
}

impl StateMachine {
Expand Down Expand Up @@ -157,9 +160,14 @@ impl StateMachine {
.cloned()
.collect::<Vec<_>>();

// Clean the caches.
self.block_proposal_cache = None;
self.prepare_message_cache.retain(|k, _| k >= &self.view);
self.commit_message_cache.retain(|k, _| k >= &self.view);

// Create the justification for our message.
let justification = validator::CommitQC::from(&replica_messages, &consensus.validator_set)
.expect("Couldn't create justification from valid replica messages!");
.map_err(Error::CreateJustificationUnexpectedError)?;

// Broadcast the leader commit message to all replicas (ourselves included).
let output_message = ConsensusInputMessage {
Expand All @@ -175,11 +183,6 @@ impl StateMachine {
};
consensus.pipe.send(output_message.into());

// Clean the caches.
self.block_proposal_cache = None;
self.prepare_message_cache.retain(|k, _| k >= &self.view);
self.commit_message_cache.retain(|k, _| k >= &self.view);

Ok(())
}
}
5 changes: 4 additions & 1 deletion node/actors/bft/src/leader/replica_prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ pub(crate) enum Error {
/// Invalid `HighQC` message.
#[error("invalid high QC: {0:#}")]
InvalidHighQC(#[source] anyhow::Error),
/// Unexpected error when creating justification from received messages.
#[error("create justification unexpected error: {0:#}")]
CreateJustificationUnexpectedError(#[source] anyhow::Error),
}

impl StateMachine {
Expand Down Expand Up @@ -225,7 +228,7 @@ impl StateMachine {

// Create the justification for our message.
let justification = validator::PrepareQC::from(&replica_messages, &consensus.validator_set)
.expect("Couldn't create justification from valid replica messages!");
.map_err(Error::CreateJustificationUnexpectedError)?;

// Broadcast the leader prepare message to all replicas (ourselves included).
let output_message = ConsensusInputMessage {
Expand Down

0 comments on commit fbed5d3

Please sign in to comment.