diff --git a/narwhal/primary/src/proposer.rs b/narwhal/primary/src/proposer.rs index 57bf46d05e9c2..a5279a0cec71f 100644 --- a/narwhal/primary/src/proposer.rs +++ b/narwhal/primary/src/proposer.rs @@ -470,6 +470,9 @@ impl Proposer { } } + // Reset advance flag. + advance = false; + // Reschedule the timer. let timer_start = Instant::now(); max_delay_timer @@ -478,6 +481,9 @@ impl Proposer { min_delay_timer .as_mut() .reset(timer_start + self.min_delay()); + + // Recheck condition and reset time out flags. + continue; } tokio::select! { @@ -581,16 +587,28 @@ impl Proposer { let _ = self.tx_narwhal_round_updates.send(self.round); self.last_parents = parents; - // we re-calculate the timeout to give the opportunity to the node - // to propose earlier if it's a leader for the round - // Reschedule the timer. + // Reset advance flag. + advance = false; + + // Extend max_delay_timer to properly wait for leader from the + // previous round. + // + // But min_delay_timer should not be extended: the network moves at + // the interval of min_header_delay. Delaying header creation for + // another min_header_delay after receiving parents from a higher + // round and cancelling proposing, makes it very likely that higher + // round parents will be received and header creation will be cancelled + // again. So min_delay_timer is disabled to get the proposer in sync + // with the quorum. + // If the node becomes leader, disabling min_delay_timer to propose as + // soon as possible is the right thing to do as well. let timer_start = Instant::now(); max_delay_timer .as_mut() .reset(timer_start + self.max_delay()); min_delay_timer .as_mut() - .reset(timer_start + self.min_delay()); + .reset(timer_start); }, Ordering::Less => { // Ignore parents from older rounds. @@ -624,9 +642,9 @@ impl Proposer { }; self.metrics - .proposer_ready_to_advance - .with_label_values(&[&advance.to_string(), round_type]) - .inc(); + .proposer_ready_to_advance + .with_label_values(&[&advance.to_string(), round_type]) + .inc(); } // Receive digests from our workers.