Skip to content

Commit

Permalink
feat(consensus): abort batcher on timeout, interrupt, or validation f…
Browse files Browse the repository at this point in the history
…ailure
  • Loading branch information
asmaastarkware committed Dec 18, 2024
1 parent f3276c7 commit 52de796
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,13 @@ impl SequencerConsensusContext {
let (built_block, received_fin) = loop {
tokio::select! {
_ = notify_clone.notified() => {
// TODO(Asmaa): Tell the batcher to abort.
warn!("Proposal interrupted: {:?}", proposal_id);
batcher_abort_proposal(batcher.as_ref(), proposal_id).await;
return;
}
_ = tokio::time::sleep(timeout) => {
// TODO(Asmaa): Tell the batcher to abort.
warn!("Validation timed out");
batcher_abort_proposal(batcher.as_ref(), proposal_id).await;
return;
}
proposal_part = content_receiver.next() => {
Expand All @@ -425,8 +425,8 @@ impl SequencerConsensusContext {
}
HandledProposalPart::Continue => {continue;}
HandledProposalPart::Failed(fail_reason) => {
// TODO(Asmaa): Tell the batcher to abort.
warn!("Failed to handle proposal part: {proposal_id:?}, {fail_reason}");
batcher_abort_proposal(batcher.as_ref(), proposal_id).await;
return;
}
}
Expand Down Expand Up @@ -600,3 +600,11 @@ async fn handle_proposal_part(
_ => panic!("Invalid proposal part: {:?}", proposal_part),
}
}

async fn batcher_abort_proposal(batcher: &dyn BatcherClient, proposal_id: ProposalId) {
let input = SendProposalContentInput { proposal_id, content: SendProposalContent::Abort };
batcher
.send_proposal_content(input)
.await
.unwrap_or_else(|e| panic!("Failed to send Abort to batcher: {proposal_id:?}. {e:?}"));
}

0 comments on commit 52de796

Please sign in to comment.