Skip to content

Commit

Permalink
fix(hotstuff): fix bug where decide state was listening for wrong mes…
Browse files Browse the repository at this point in the history
…sage (#4160)

Description
---
Fixes the decide state listening for the wrong message type

Motivation and Context
---
I noticed that views were timing out and that the decide state would log  "Already received this message". This was happening because the leader would read the message that the replica was meant to, and then the replica would miss the message and the state would time out

How Has This Been Tested?
---
Manually
  • Loading branch information
stringhandler committed Jun 6, 2022
1 parent 736ec3e commit fe7b304
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
Empty file.
2 changes: 1 addition & 1 deletion dan_layer/core/src/models/hot_stuff_message.rs
Expand Up @@ -172,7 +172,7 @@ impl<TPayload: Payload> HotStuffMessage<TPayload> {
asset_public_key: PublicKey,
) -> Self {
Self {
message_type: HotStuffMessageType::Commit,
message_type: HotStuffMessageType::Decide,
node,
justify: commit_qc,
view_number,
Expand Down
3 changes: 3 additions & 0 deletions dan_layer/core/src/models/mod.rs
Expand Up @@ -165,6 +165,7 @@ pub enum HotStuffMessageType {
Prepare,
PreCommit,
Commit,
Decide,
// Special type
Genesis,
}
Expand All @@ -176,6 +177,7 @@ impl HotStuffMessageType {
HotStuffMessageType::Prepare => 2,
HotStuffMessageType::PreCommit => 3,
HotStuffMessageType::Commit => 4,
HotStuffMessageType::Decide => 5,
HotStuffMessageType::Genesis => 255,
}
}
Expand All @@ -190,6 +192,7 @@ impl TryFrom<u8> for HotStuffMessageType {
2 => Ok(HotStuffMessageType::Prepare),
3 => Ok(HotStuffMessageType::PreCommit),
4 => Ok(HotStuffMessageType::Commit),
5 => Ok(HotStuffMessageType::Decide),
255 => Ok(HotStuffMessageType::Genesis),
_ => Err("Not a value message type".to_string()),
}
Expand Down
2 changes: 1 addition & 1 deletion dan_layer/core/src/workers/states/decide_state.rs
Expand Up @@ -85,7 +85,7 @@ impl<TSpecification: ServiceSpecification> DecideState<TSpecification> {
}
}
},
r = inbound_services.wait_for_qc(HotStuffMessageType::Prepare, current_view.view_id()) => {
r = inbound_services.wait_for_qc(HotStuffMessageType::Commit, current_view.view_id()) => {
let (from, message) = r?;
let leader= self.committee.leader_for_view(current_view.view_id).clone();
if let Some(event) = self.process_replica_message(&message, current_view, &from, &leader, &mut unit_of_work, payload_provider).await? {
Expand Down

0 comments on commit fe7b304

Please sign in to comment.