Skip to content

Commit

Permalink
fix(consensus): add timeout when waiting for first proposal message
Browse files Browse the repository at this point in the history
  • Loading branch information
guy-starkware committed Dec 18, 2024
1 parent 8f9e194 commit e105b72
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/sequencing/papyrus_consensus/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ use crate::types::{
/// messages.
/// - `proposal_receiver`: The channel to receive proposals from the network. Proposals are
/// represented as streams (ProposalInit, Content.*, ProposalFin).
const NEW_RECEIVER_TIMEOUT: Duration = Duration::from_millis(100);

// TODO(dvir): add test for this.
// TODO(Asmaa): Update documentation when we update for the real sync.
#[instrument(skip_all, level = "info")]
Expand Down Expand Up @@ -203,7 +205,12 @@ impl<ContextT: ConsensusContext> MultiHeightManager<ContextT> {
context, height, &mut shc, message, broadcast_channels).await?
},
Some(content_receiver) = proposal_receiver.next() => {
self.handle_proposal(context, height, &mut shc, content_receiver).await?
match tokio::time::timeout(NEW_RECEIVER_TIMEOUT, self.handle_proposal(context, height, &mut shc, content_receiver)).await {
Ok(res) => res?,
Err(_) => {
panic!("Proposal receiver timed out while waiting for first message. ");
}
}
},
Some(shc_event) = shc_events.next() => {
shc.handle_event(context, shc_event).await?
Expand Down

0 comments on commit e105b72

Please sign in to comment.