From 40e81a6f3291ae1a0a6cab0120732c4eaf99820e Mon Sep 17 00:00:00 2001 From: Andreas Doerr Date: Fri, 16 Apr 2021 06:01:06 +0200 Subject: [PATCH] Add block_delta parameter to start_beefy_gadget (#151) * Add block_delta parameter * rename to min_block_delta --- client/beefy/src/lib.rs | 2 ++ client/beefy/src/worker.rs | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/beefy/src/lib.rs b/client/beefy/src/lib.rs index a33c391cfa87d..784c40cb4a75a 100644 --- a/client/beefy/src/lib.rs +++ b/client/beefy/src/lib.rs @@ -94,6 +94,7 @@ pub async fn start_beefy_gadget( network: N, signed_commitment_sender: notification::BeefySignedCommitmentSender, _sync_oracle: SO, + min_block_delta: u32, prometheus_registry: Option, ) where B: Block, @@ -129,6 +130,7 @@ pub async fn start_beefy_gadget( signed_commitment_sender, gossip_engine, gossip_validator, + min_block_delta, metrics, ); diff --git a/client/beefy/src/worker.rs b/client/beefy/src/worker.rs index a337109852514..05e6dc68b7f27 100644 --- a/client/beefy/src/worker.rs +++ b/client/beefy/src/worker.rs @@ -67,10 +67,10 @@ where signed_commitment_sender: notification::BeefySignedCommitmentSender, gossip_engine: Arc>>, gossip_validator: Arc>, + min_block_delta: u32, metrics: Option, rounds: round::Rounds, P::Public, P::Signature>, finality_notifications: FinalityNotifications, - min_interval: u32, /// Best block we received a GRANDPA notification for best_grandpa_block: NumberFor, /// Best block a BEEFY voting round has been concluded for @@ -103,6 +103,7 @@ where signed_commitment_sender: notification::BeefySignedCommitmentSender, gossip_engine: GossipEngine, gossip_validator: Arc>, + min_block_delta: u32, metrics: Option, ) -> Self { BeefyWorker { @@ -111,10 +112,10 @@ where signed_commitment_sender, gossip_engine: Arc::new(Mutex::new(gossip_engine)), gossip_validator, + min_block_delta, metrics, rounds: round::Rounds::new(ValidatorSet::empty()), finality_notifications: client.finality_notification_stream(), - min_interval: 2, best_grandpa_block: client.info().finalized_number, best_beefy_block: None, best_block_voted_on: Zero::zero(), @@ -148,7 +149,7 @@ where let diff = self.best_grandpa_block.saturating_sub(best_beefy_block); let diff = diff.saturated_into::(); let next_power_of_two = (diff / 2).next_power_of_two(); - let next_block_to_vote_on = self.best_block_voted_on + self.min_interval.max(next_power_of_two).into(); + let next_block_to_vote_on = self.best_block_voted_on + self.min_block_delta.max(next_power_of_two).into(); trace!( target: "beefy",