From f8ffc0223b3d2f69cb88bac4ef8a049a5e49af92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kami=C5=84ski?= Date: Thu, 31 Oct 2024 13:33:50 +0100 Subject: [PATCH] Only set a timer once per round to avoid timeouts blowing up while network is stalled --- .../src/components/consensus/protocols/zug.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/node/src/components/consensus/protocols/zug.rs b/node/src/components/consensus/protocols/zug.rs index 121169410b..706a667752 100644 --- a/node/src/components/consensus/protocols/zug.rs +++ b/node/src/components/consensus/protocols/zug.rs @@ -1664,8 +1664,13 @@ impl Zug { .current_round_start .saturating_add(self.proposal_timeout()); if now >= current_timeout { - outcomes.extend(self.create_and_gossip_message(round_id, Content::Vote(false))); - self.update_proposal_timeout(now); + let msg_outcomes = self.create_and_gossip_message(round_id, Content::Vote(false)); + // Only update the proposal timeout if this is the first time we timed out in this + // round + if !msg_outcomes.is_empty() { + self.update_proposal_timeout(now); + } + outcomes.extend(msg_outcomes); } else if self.faults.contains_key(&self.leader(round_id)) { outcomes.extend(self.create_and_gossip_message(round_id, Content::Vote(false))); } @@ -1685,12 +1690,10 @@ impl Zug { // that time. debug!(our_idx, %now, %timestamp, "update_round - schedule update 1"); outcomes.extend(self.schedule_update(timestamp)); - } else { - if self.current_round_start > now { - // A proposal could be made now. Start the timer and propose if leader. - self.current_round_start = now; - outcomes.extend(self.propose_if_leader(maybe_parent_round_id, now)); - } + } else if self.current_round_start > now { + // A proposal could be made now. Start the timer and propose if leader. + self.current_round_start = now; + outcomes.extend(self.propose_if_leader(maybe_parent_round_id, now)); let current_timeout = self .current_round_start .saturating_add(self.proposal_timeout());