From 5b1906e1d3c7afabd6cc690b0e687767024c25f3 Mon Sep 17 00:00:00 2001 From: timorleph Date: Mon, 15 Apr 2024 16:39:05 +0200 Subject: [PATCH] Compute order extension last Probably doesn't actually impact sending delays, but it also doesn't hurt. --- consensus/src/extension/mod.rs | 2 +- consensus/src/runway/mod.rs | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/consensus/src/extension/mod.rs b/consensus/src/extension/mod.rs index f205ec96..708a0df5 100644 --- a/consensus/src/extension/mod.rs +++ b/consensus/src/extension/mod.rs @@ -11,7 +11,7 @@ mod units; use extender::Extender; /// A struct responsible for executing the Consensus protocol on a local copy of the Dag. -/// It receives units which are guaranteed to be eventually in the Dags +/// It receives units which are guaranteed to eventually appear in the Dags /// of all honest nodes. The static Aleph Consensus algorithm is then run on this Dag in order /// to finalize subsequent rounds of the Dag. More specifically whenever a new unit is received /// this process checks whether a new round can be finalized and if so, it computes the batch of diff --git a/consensus/src/runway/mod.rs b/consensus/src/runway/mod.rs index 49c04660..7dcf0243 100644 --- a/consensus/src/runway/mod.rs +++ b/consensus/src/runway/mod.rs @@ -462,7 +462,6 @@ where self.dag.finished_processing(&unit_hash); self.resolve_missing_parents(&unit_hash); self.resolve_missing_coord(&unit.coord()); - self.ordering.add_unit(unit.clone()); if self .parents_for_creator .unbounded_send(unit.clone()) @@ -471,13 +470,16 @@ where warn!(target: "AlephBFT-runway", "Creator channel should be open."); self.exiting = true; } - let unit = unit.unpack(); - self.send_message_for_network(RunwayNotificationOut::NewAnyUnit(unit.clone().into())); - - if unit.as_signable().creator() == self.index() { - trace!(target: "AlephBFT-runway", "{:?} Sending a unit {:?}.", self.index(), unit.as_signable().hash()); - self.send_message_for_network(RunwayNotificationOut::NewSelfUnit(unit.into())); + let unpacked_unit = unit.clone().unpack(); + self.send_message_for_network(RunwayNotificationOut::NewAnyUnit( + unpacked_unit.clone().into(), + )); + + if unit.creator() == self.index() { + trace!(target: "AlephBFT-runway", "{:?} Sending a unit {:?}.", self.index(), unit.hash()); + self.send_message_for_network(RunwayNotificationOut::NewSelfUnit(unpacked_unit.into())); } + self.ordering.add_unit(unit.clone()); } fn on_missing_coord(&mut self, coord: UnitCoord) {