Skip to content

feat(code): Implement Solution 2 for the RoundSync #1032

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

Merged
merged 7 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion code/crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,9 @@ impl TimeoutConfig {
TimeoutKind::PrevoteTimeLimit => self.timeout_step,
TimeoutKind::PrecommitTimeLimit => self.timeout_step,
// TODO - clarify the rebroadcast timeout duration
TimeoutKind::Rebroadcast => self.timeout_prevote,
TimeoutKind::Rebroadcast => {
self.timeout_propose + self.timeout_prevote + self.timeout_precommit
}
}
}

Expand Down
16 changes: 9 additions & 7 deletions code/crates/core-consensus/src/handle/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ where
co,
Effect::StartRound(*height, *round, proposer.clone(), Default::default())
);

#[cfg(feature = "metrics")]
metrics.rebroadcast_timeouts.inc();

// Schedule rebroadcast timer if necessary
if state.params.vote_sync_mode == VoteSyncMode::Rebroadcast {
let timeout = Timeout::rebroadcast(*round);
perform!(co, Effect::ScheduleTimeout(timeout, Default::default()));
}
}

DriverInput::ProposeValue(round, _) => {
Expand Down Expand Up @@ -396,13 +405,6 @@ where
);

state.set_last_vote(signed_vote);

// Schedule rebroadcast timer if necessary
if state.params.vote_sync_mode == VoteSyncMode::Rebroadcast {
let timeout = Timeout::rebroadcast(state.driver.round());

perform!(co, Effect::ScheduleTimeout(timeout, Default::default()));
}
}

Ok(())
Expand Down
6 changes: 5 additions & 1 deletion code/crates/core-consensus/src/handle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ pub async fn on_round_certificate<Ctx>(
where
Ctx: Context,
{
info!(%certificate.height, %certificate.round, "Received round certificate");
info!(
%certificate.height,
%certificate.round,
"Received round certificate"
);

if certificate.height != state.height() {
warn!(
Expand Down
10 changes: 5 additions & 5 deletions code/crates/core-consensus/src/handle/rebroadcast_timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub async fn on_rebroadcast_timeout<Ctx>(
co: &Co<Ctx>,
state: &mut State<Ctx>,
metrics: &Metrics,
timeout: Timeout,
) -> Result<(), Error<Ctx>>
where
Ctx: Context,
Expand All @@ -19,8 +18,8 @@ where
if let Some(vote) = state.last_signed_prevote.as_ref() {
warn!(
%height, %round, vote_height = %vote.height(), vote_round = %vote.round(),
"Rebroadcasting vote at {:?} step after {:?} timeout",
state.driver.step(), timeout.kind,
"Rebroadcasting vote at {:?} step",
state.driver.step()
);

perform!(
Expand All @@ -32,8 +31,8 @@ where
if let Some(vote) = state.last_signed_precommit.as_ref() {
warn!(
%height, %round, vote_height = %vote.height(), vote_round = %vote.round(),
"Rebroadcasting vote at {:?} step after {:?} timeout",
state.driver.step(), timeout.kind,
"Rebroadcasting vote at {:?} step",
state.driver.step()
);
perform!(
co,
Expand All @@ -60,6 +59,7 @@ where
#[cfg(feature = "metrics")]
metrics.rebroadcast_timeouts.inc();

let timeout = Timeout::rebroadcast(round);
perform!(co, Effect::ScheduleTimeout(timeout, Default::default()));

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion code/crates/core-consensus/src/handle/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ where
apply_driver_input(co, state, metrics, DriverInput::TimeoutElapsed(timeout)).await?;

match timeout.kind {
TimeoutKind::Rebroadcast => on_rebroadcast_timeout(co, state, metrics, timeout).await,
TimeoutKind::Rebroadcast => on_rebroadcast_timeout(co, state, metrics).await,
TimeoutKind::PrevoteTimeLimit | TimeoutKind::PrecommitTimeLimit => {
on_step_limit_timeout(co, state, metrics, timeout.round).await
}
Expand Down
6 changes: 5 additions & 1 deletion code/crates/engine/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ impl Timeouts {
TimeoutKind::Precommit => self.config.timeout_precommit,
TimeoutKind::PrevoteTimeLimit => self.config.timeout_step,
TimeoutKind::PrecommitTimeLimit => self.config.timeout_step,
TimeoutKind::Rebroadcast => self.config.timeout_prevote,
TimeoutKind::Rebroadcast => {
self.config.timeout_propose
+ self.config.timeout_prevote
+ self.config.timeout_precommit
}
}
}

Expand Down
Loading