Skip to content

Commit

Permalink
consensus: do not call collect_from_past for Candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
fed-franz committed Aug 22, 2024
1 parent 13fea3e commit 1c628ea
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 40 deletions.
69 changes: 35 additions & 34 deletions consensus/src/execution_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,44 +248,45 @@ impl<'a, DB: Database, T: Operations + 'static> ExecutionCtx<'a, DB, T> {
async fn on_emergency_mode(&mut self, msg: Message) {
self.outbound.try_send(msg.clone());

// Try to cast validation vote for a candidate block from former
// iteration
// Try to vote for a candidate block from former iteration
if let Payload::Candidate(p) = &msg.payload {
self.try_cast_validation_vote(&p.candidate).await;
}

let msg_iteration = msg.header.iteration;

// Collect message from a previous iteration/step.
if let Some(m) = self
.iter_ctx
.collect_past_event(&self.round_update, msg)
.await
{
match &m.payload {
Payload::Quorum(q) => {
debug!(
event = "quorum",
src = "prev_step",
msg_step = m.get_step(),
vote = ?q.vote(),
);

self.quorum_sender.send_quorum(m).await;
}

Payload::ValidationResult(validation_result) => {
self.try_cast_ratification_vote(
msg_iteration,
validation_result,
)
.await
}
_ => {
// Not supported.
}
}
else {
let msg_iteration = msg.header.iteration;

// Collect message from a previous iteration/step.
if let Some(m) = self
.iter_ctx
.collect_past_event(&self.round_update, msg)
.await
{
match &m.payload {
Payload::Quorum(q) => {
debug!(
event = "quorum",
src = "prev_step",
msg_step = m.get_step(),
vote = ?q.vote(),
);

self.quorum_sender.send_quorum(m).await;
}

Payload::ValidationResult(validation_result) => {
self.try_cast_ratification_vote(
msg_iteration,
validation_result,
)
.await
}
_ => {
// Not supported.
}
}
}
}

}

/// Delegates the received message to the Phase handler for further
Expand Down
6 changes: 0 additions & 6 deletions consensus/src/iteration_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ impl<D: Database> IterationCtx<D> {
let generator = self.get_generator(msg.header.iteration);

match msg.topic() {
node_data::message::Topics::Candidate => {
let mut handler = self.proposal_handler.lock().await;
_ = handler
.collect_from_past(msg, ru, committee, generator)
.await;
}
node_data::message::Topics::Validation => {
let mut handler = self.validation_handler.lock().await;
if let Ok(HandleMsgOutput::Ready(m)) = handler
Expand Down

0 comments on commit 1c628ea

Please sign in to comment.