Skip to content

Commit

Permalink
fix(consensus): handle nil quorum on different round and enable proto…
Browse files Browse the repository at this point in the history
…buf nil votes
  • Loading branch information
asmaastarkware committed Aug 5, 2024
1 parent fa2ecf4 commit 3db1655
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 2 additions & 5 deletions crates/papyrus_protobuf/src/converters/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ impl TryFrom<protobuf::Vote> for Vote {

let height = value.height;
let round = value.round;
let block_hash: StarkHash = value
.block_hash
.ok_or(ProtobufConversionError::MissingField { field_description: "block_hash" })?
.try_into()?;
let block_hash = Some(BlockHash(block_hash));
let block_hash: Option<BlockHash> =
value.block_hash.map(|block_hash| block_hash.try_into()).transpose()?.map(BlockHash);
let voter = value
.voter
.ok_or(ProtobufConversionError::MissingField { field_description: "voter" })?
Expand Down
9 changes: 7 additions & 2 deletions crates/sequencing/papyrus_consensus/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,13 @@ impl StateMachine {
if *count < self.quorum {
return VecDeque::new();
}
if block_hash.is_none() && round == self.round {
return self.advance_to_round(round + 1, leader_fn);
if block_hash.is_none() {
if round == self.round {
return self.advance_to_round(round + 1, leader_fn);
} else {
// NIL quorum reached on a different round.
return VecDeque::new();
}
}
let Some(proposed_value) = self.proposals.get(&round) else {
return VecDeque::new();
Expand Down

0 comments on commit 3db1655

Please sign in to comment.