Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle HighQcSend #3919

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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