Skip to content

Commit

Permalink
Handle HighQcSend (#3919)
Browse files Browse the repository at this point in the history
* Handle HighQcSend

* Use the new quorum cert struct
  • Loading branch information
lukaszrzasik authored Dec 2, 2024
1 parent 320ebe3 commit 7ccea8b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
10 changes: 9 additions & 1 deletion crates/task-impls/src/consensus/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ pub async fn send_high_qc<TYPES: NodeType, V: Versions, I: NodeImplementation<TY
let leader = task_state
.membership
.leader(new_view_number, TYPES::Epoch::new(0))?;
broadcast_event(Arc::new(HotShotEvent::HighQcSend(high_qc, leader)), sender).await;
broadcast_event(
Arc::new(HotShotEvent::HighQcSend(
high_qc,
leader,
task_state.public_key.clone(),
)),
sender,
)
.await;
Ok(())
}

Expand Down
10 changes: 7 additions & 3 deletions crates/task-impls/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ pub enum HotShotEvent<TYPES: NodeType> {
HighQcRecv(QuorumCertificate2<TYPES>, TYPES::SignatureKey),

/// Send our HighQc to the next leader, should go to the same leader as our vote
HighQcSend(QuorumCertificate2<TYPES>, TYPES::SignatureKey),
HighQcSend(
QuorumCertificate2<TYPES>,
TYPES::SignatureKey,
TYPES::SignatureKey,
),
}

impl<TYPES: NodeType> HotShotEvent<TYPES> {
Expand Down Expand Up @@ -322,7 +326,7 @@ impl<TYPES: NodeType> HotShotEvent<TYPES> {
| HotShotEvent::VidRequestRecv(request, _) => Some(request.view),
HotShotEvent::VidResponseSend(_, _, proposal)
| HotShotEvent::VidResponseRecv(_, proposal) => Some(proposal.data.view_number),
HotShotEvent::HighQcRecv(qc, _) | HotShotEvent::HighQcSend(qc, _) => {
HotShotEvent::HighQcRecv(qc, _) | HotShotEvent::HighQcSend(qc, ..) => {
Some(qc.view_number())
}
}
Expand Down Expand Up @@ -590,7 +594,7 @@ impl<TYPES: NodeType> Display for HotShotEvent<TYPES> {
HotShotEvent::HighQcRecv(qc, _) => {
write!(f, "HighQcRecv(view_number={:?}", qc.view_number())
}
HotShotEvent::HighQcSend(qc, _) => {
HotShotEvent::HighQcSend(qc, ..) => {
write!(f, "HighQcSend(view_number={:?}", qc.view_number())
}
}
Expand Down
11 changes: 8 additions & 3 deletions crates/task-impls/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ impl<TYPES: NodeType> NetworkMessageTaskState<TYPES> {
tracing::error!("Received upgrade vote!");
HotShotEvent::UpgradeVoteRecv(message)
}
GeneralConsensusMessage::HighQc(qc) => {
HotShotEvent::HighQcRecv(qc.to_qc2(), sender)
}
GeneralConsensusMessage::HighQc(qc) => HotShotEvent::HighQcRecv(qc, sender),
},
SequencingMessage::Da(da_message) => match da_message {
DaConsensusMessage::DaProposal(proposal) => {
Expand Down Expand Up @@ -650,6 +648,13 @@ impl<
TransmitType::Direct(to),
))
}
HotShotEvent::HighQcSend(quorum_cert, leader, sender) => Some((
sender,
MessageKind::Consensus(SequencingMessage::General(
GeneralConsensusMessage::HighQc(quorum_cert),
)),
TransmitType::Direct(leader),
)),
_ => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/task-impls/src/quorum_proposal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions>
HotShotEvent::ViewChange(view, _) | HotShotEvent::Timeout(view) => {
self.cancel_tasks(*view);
}
HotShotEvent::HighQcSend(qc, _sender) => {
HotShotEvent::HighQcSend(qc, ..) => {
ensure!(qc.view_number() > self.highest_qc.view_number());
let epoch_number = self.consensus.read().await.cur_epoch();
ensure!(
Expand Down
4 changes: 2 additions & 2 deletions crates/types/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
},
request_response::ProposalRequestPayload,
simple_certificate::{
DaCertificate, QuorumCertificate, UpgradeCertificate, ViewSyncCommitCertificate2,
DaCertificate, QuorumCertificate2, UpgradeCertificate, ViewSyncCommitCertificate2,
ViewSyncFinalizeCertificate2, ViewSyncPreCommitCertificate2,
},
simple_vote::{
Expand Down Expand Up @@ -210,7 +210,7 @@ pub enum GeneralConsensusMessage<TYPES: NodeType> {
ProposalResponse(Proposal<TYPES, QuorumProposal<TYPES>>),

/// Message for the next leader containing our highest QC
HighQc(QuorumCertificate<TYPES>),
HighQc(QuorumCertificate2<TYPES>),
}

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Hash, Eq)]
Expand Down

0 comments on commit 7ccea8b

Please sign in to comment.