From a0bc9dc3e55dcc232b555a40446203d46ca4e6d1 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 16 Oct 2022 09:16:44 -0400 Subject: [PATCH] Misc cleanup --- substrate/tendermint/src/lib.rs | 9 +++++++-- substrate/tendermint/src/message_log.rs | 18 ------------------ substrate/tendermint/tests/ext.rs | 3 +-- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/substrate/tendermint/src/lib.rs b/substrate/tendermint/src/lib.rs index f5d62e8e..f0abb0dd 100644 --- a/substrate/tendermint/src/lib.rs +++ b/substrate/tendermint/src/lib.rs @@ -124,15 +124,18 @@ impl TendermintMachine { // 11-13 async fn round(&mut self, round: Round) { - // Clear timeouts - self.timeouts = HashMap::new(); + dbg!(round); // Correct the start time for _ in self.round.0 .. round.0 { self.start_time = self.timeout(Step::Precommit); } + // Clear timeouts + self.timeouts = HashMap::new(); + self.round = round; + self.step = Step::Propose; self.round_propose().await; } @@ -151,6 +154,7 @@ impl TendermintMachine { } // 10 + #[allow(clippy::new_ret_no_self)] pub fn new( network: N, proposer: N::ValidatorId, @@ -284,6 +288,7 @@ impl TendermintMachine { } // Else, check if we need to jump ahead + #[allow(clippy::comparison_chain)] if msg.round.0 < self.round.0 { return Ok(None); } else if msg.round.0 > self.round.0 { diff --git a/substrate/tendermint/src/message_log.rs b/substrate/tendermint/src/message_log.rs index 45505db4..f367cb91 100644 --- a/substrate/tendermint/src/message_log.rs +++ b/substrate/tendermint/src/message_log.rs @@ -72,24 +72,6 @@ impl MessageLog { weight } - // Get the participation in a given round for a given step. - pub(crate) fn participation(&self, round: Round, step: Step) -> u64 { - let (participating, _) = self.message_instances( - round, - match step { - Step::Propose => panic!("Checking for participation on Propose"), - Step::Prevote => Data::Prevote(None), - Step::Precommit => Data::Precommit(None), - }, - ); - participating - } - - // Check if there's been a BFT level of participation - pub(crate) fn has_participation(&self, round: Round, step: Step) -> bool { - self.participation(round, step) >= self.weights.threshold() - } - // Check if consensus has been reached on a specific piece of data pub(crate) fn has_consensus(&self, round: Round, data: Data) -> bool { let (_, weight) = self.message_instances(round, data); diff --git a/substrate/tendermint/tests/ext.rs b/substrate/tendermint/tests/ext.rs index fb1949da..ce15507f 100644 --- a/substrate/tendermint/tests/ext.rs +++ b/substrate/tendermint/tests/ext.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use tokio::sync::{RwLock, mpsc}; +use tokio::sync::RwLock; use tendermint_machine::{ext::*, Message, TendermintMachine, TendermintHandle}; @@ -87,7 +87,6 @@ impl TestNetwork { )); } } - dbg!("Created all machines"); arc } }