From dfbe41f2e21125f45c9b6e9f13e99131c80f4344 Mon Sep 17 00:00:00 2001 From: matan-starkware <97523054+matan-starkware@users.noreply.github.com> Date: Fri, 27 Dec 2024 10:32:51 +0200 Subject: [PATCH] chore(consensus): all tasks must be awaited to propogate panics (#2958) --- .../src/sequencer_consensus_context.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs index 835c1767f2..c2d3f200e3 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs @@ -174,6 +174,7 @@ impl ConsensusContext for SequencerConsensusContext { self.cende_ambassador.write_prev_height_blob(proposal_init.height); // Handles interrupting an active proposal from a previous height/round self.set_height_and_round(proposal_init.height, proposal_init.round).await; + let (fin_sender, fin_receiver) = oneshot::channel(); let batcher = Arc::clone(&self.batcher); let valid_proposals = Arc::clone(&self.valid_proposals); @@ -187,7 +188,7 @@ impl ConsensusContext for SequencerConsensusContext { .await .expect("Failed to send proposal receiver"); - tokio::spawn( + let handle = tokio::spawn( async move { build_proposal( timeout, @@ -203,6 +204,9 @@ impl ConsensusContext for SequencerConsensusContext { } .instrument(debug_span!("consensus_build_proposal")), ); + assert!(self.active_proposal.is_none()); + // The cancellation token is unused by the spawned build. + self.active_proposal = Some((CancellationToken::new(), handle)); fin_receiver }