From 7b14a5691fff713b3316e39e8ee6cbeb8ff703d1 Mon Sep 17 00:00:00 2001 From: Moshe Shababo <17073733+moshababo@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:30:14 -0600 Subject: [PATCH] clippy --- node/actors/bft/src/leader/replica_prepare.rs | 11 ++++------- node/actors/bft/src/leader/state_machine.rs | 4 ++-- node/libs/crypto/src/bn254/mod.rs | 2 +- .../roles/src/validator/keys/aggregate_signature.rs | 2 +- node/libs/roles/src/validator/messages/consensus.rs | 7 +------ node/libs/roles/src/validator/testonly.rs | 2 +- 6 files changed, 10 insertions(+), 18 deletions(-) diff --git a/node/actors/bft/src/leader/replica_prepare.rs b/node/actors/bft/src/leader/replica_prepare.rs index 27a88cc01..a3a77d236 100644 --- a/node/actors/bft/src/leader/replica_prepare.rs +++ b/node/actors/bft/src/leader/replica_prepare.rs @@ -150,13 +150,10 @@ impl StateMachine { // ----------- All checks finished. Now we process the message. -------------- // We add the message to the incrementally-constructed QC. - self.prepare_qcs - .entry(message.view) - .or_insert(PrepareQC::new()) - .add( - &signed_message, - (validator_index, self.inner.validator_set.len()), - ); + self.prepare_qcs.entry(message.view).or_default().add( + &signed_message, + (validator_index, self.inner.validator_set.len()), + ); // We store the message in our cache. self.prepare_message_cache diff --git a/node/actors/bft/src/leader/state_machine.rs b/node/actors/bft/src/leader/state_machine.rs index fe6151b72..53d93836e 100644 --- a/node/actors/bft/src/leader/state_machine.rs +++ b/node/actors/bft/src/leader/state_machine.rs @@ -129,7 +129,7 @@ impl StateMachine { ctx: &ctx::Ctx, inner: &ConsensusInner, payload_source: &dyn PayloadSource, - justification: validator::PrepareQC, + justification: PrepareQC, ) -> ctx::Result<()> { // Get the highest block voted for and check if there's a quorum of votes for it. To have a quorum // in this situation, we require 2*f+1 votes, where f is the maximum number of faulty replicas. @@ -145,7 +145,7 @@ impl StateMachine { .cloned(); // Get the highest CommitQC. - let highest_qc: &validator::CommitQC = justification + let highest_qc: &CommitQC = justification .map .keys() .map(|s| &s.high_qc) diff --git a/node/libs/crypto/src/bn254/mod.rs b/node/libs/crypto/src/bn254/mod.rs index 5d4371771..66592b678 100644 --- a/node/libs/crypto/src/bn254/mod.rs +++ b/node/libs/crypto/src/bn254/mod.rs @@ -177,7 +177,7 @@ impl Default for AggregateSignature { } impl AggregateSignature { - // Add a signature to the aggregation. + /// Add a signature to the aggregation. pub fn add(&mut self, sig: &Signature) { self.0.add_assign(&sig.0) } diff --git a/node/libs/roles/src/validator/keys/aggregate_signature.rs b/node/libs/roles/src/validator/keys/aggregate_signature.rs index 0e6d022eb..ebf2903a3 100644 --- a/node/libs/roles/src/validator/keys/aggregate_signature.rs +++ b/node/libs/roles/src/validator/keys/aggregate_signature.rs @@ -9,7 +9,7 @@ use zksync_consensus_utils::enum_util::Variant; pub struct AggregateSignature(pub(crate) bn254::AggregateSignature); impl AggregateSignature { - // Add a signature to the aggregation. + /// Add a signature to the aggregation. pub fn add(&mut self, sig: &Signature) { self.0.add(&sig.0) } diff --git a/node/libs/roles/src/validator/messages/consensus.rs b/node/libs/roles/src/validator/messages/consensus.rs index 35b76b4f1..f2175ba8c 100644 --- a/node/libs/roles/src/validator/messages/consensus.rs +++ b/node/libs/roles/src/validator/messages/consensus.rs @@ -181,11 +181,6 @@ pub struct PrepareQC { } impl PrepareQC { - /// Create a new empty instance. (added on top of `Default` for compatibility with `CommitQC`.) - pub fn new() -> Self { - Default::default() - } - /// View of the QC. pub fn view(&self) -> ViewNumber { self.map @@ -302,7 +297,7 @@ impl CommitQC { Self { message, signers: Signers(BitVec::from_elem(validator_set_size, false)), - signature: Default::default(), + signature: validator::AggregateSignature::default(), } } diff --git a/node/libs/roles/src/validator/testonly.rs b/node/libs/roles/src/validator/testonly.rs index fa9cc691a..201504058 100644 --- a/node/libs/roles/src/validator/testonly.rs +++ b/node/libs/roles/src/validator/testonly.rs @@ -88,7 +88,7 @@ impl PrepareQC { .view; // Create the messages map. - let mut prepare_qc = PrepareQC::new(); + let mut prepare_qc = PrepareQC::default(); for signed_message in signed_messages { if signed_message.msg.view != view {