Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
moshababo committed Dec 19, 2023
1 parent c3a5d91 commit a274fc5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 19 deletions.
13 changes: 5 additions & 8 deletions node/actors/bft/src/leader/replica_prepare.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::StateMachine;
use tracing::instrument;
use zksync_concurrency::{ctx, error::Wrap};
use zksync_consensus_roles::validator::{self, PrepareQC, ProtocolVersion};
use zksync_consensus_roles::validator::{self, ProtocolVersion};

/// Errors that can occur when processing a "replica prepare" message.
#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions node/actors/bft/src/leader/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion node/libs/crypto/src/bn254/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion node/libs/roles/src/validator/keys/aggregate_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
7 changes: 1 addition & 6 deletions node/libs/roles/src/validator/messages/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -302,7 +297,7 @@ impl CommitQC {
Self {
message,
signers: Signers(BitVec::from_elem(validator_set_size, false)),
signature: Default::default(),
signature: validator::AggregateSignature::default(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion node/libs/roles/src/validator/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a274fc5

Please sign in to comment.