Skip to content

Commit

Permalink
justification for round change
Browse files Browse the repository at this point in the history
  • Loading branch information
jking-aus committed Oct 15, 2024
1 parent 840bb5d commit 83ccd63
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
11 changes: 6 additions & 5 deletions anchor/qbft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,9 @@ where
{
if max_value.pr >= 1 && self.validate_data(max_value.pv.clone()).is_some() {
debug!(
"The maximum pr value is {} from RoundChange with operator_id {}",
max_value.pr, operator_id
"ID{}: The previouly stored maximum pr value is {} from operator_id {} with pv value {:?}",
self.operator_id(), max_value.pr, operator_id, max_value.pv
);
debug!("The corresponding pv value is: {:?}", max_value.pv);
self.set_pr_pv(max_value.pr, max_value.pv.clone());
} else {
debug!("ID{}: Prepare consensus not reached previously and/or consensus data is none" , self.operator_id());
Expand All @@ -417,6 +416,7 @@ where
if matches!(self.config.state, InstanceState::SentRoundChange) {
self.check_round_change_quorum(self.current_round, self.config.quorum_size);
}
self.set_state(InstanceState::AwaitingProposal);
if self.config.pr >= 1 && self.validate_data(self.config.pv.clone()).is_some() {
debug!(
"ID{}: pr: {} and pv: {:?} are set from previous round",
Expand All @@ -434,8 +434,9 @@ where
round: self.current_round,
}));
}
};
self.set_state(InstanceState::AwaitingProposal);
} else {
self.set_state(InstanceState::AwaitingProposal);
}
}

/// Received message functions
Expand Down
21 changes: 11 additions & 10 deletions anchor/qbft/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,17 @@ fn emulate_broadcast_network<D: Default + Debug + Clone + Send + Sync + 'static
});
}
OutMessage::Commit(commit_message) => {
senders
.iter_mut()
.enumerate()
.for_each(|(current_index, sender)| {
if current_index != index {
let _ = sender.send(InMessage::Commit(commit_message.clone()));
}
});
// Ignoring commits in round 2 for testing
if commit_message.round != 2 {
senders
.iter_mut()
.enumerate()
.for_each(|(current_index, sender)| {
if current_index != index {
let _ = sender.send(InMessage::Commit(commit_message.clone()));
}
})
};
}
OutMessage::RoundChange(round_change) => {
senders
Expand Down Expand Up @@ -417,8 +420,6 @@ async fn test_basic_committee() {

let mut test_instance = TestQBFTCommitteeBuilder::<usize>::default().run(21);

// assert_eq!(1, 2);

// Wait until consensus is reached or all the instances have ended
test_instance.wait_until_end().await;
}

0 comments on commit 83ccd63

Please sign in to comment.