From 683884aaafc2c9779f7b2f27161e9fec8e3b1c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Tue, 26 Mar 2024 17:03:50 +0000 Subject: [PATCH] CI fixes --- node/Cargo.lock | 10 +++++----- node/Cargo.toml | 2 +- node/actors/bft/src/leader/replica_commit.rs | 4 ++-- node/actors/bft/src/leader/replica_prepare.rs | 2 +- node/actors/bft/src/replica/leader_commit.rs | 2 +- node/actors/bft/src/replica/leader_prepare.rs | 2 +- node/actors/network/src/consensus/handshake/mod.rs | 2 +- node/actors/sync_blocks/src/peers/events.rs | 2 +- node/deny.toml | 1 + node/libs/concurrency/src/testonly.rs | 2 +- .../roles/src/validator/keys/aggregate_signature.rs | 6 +++--- node/libs/roles/src/validator/keys/mod.rs | 3 --- node/libs/roles/src/validator/keys/signature.rs | 6 +++--- .../libs/roles/src/validator/messages/leader_commit.rs | 2 +- .../roles/src/validator/messages/leader_prepare.rs | 2 +- node/libs/roles/src/validator/messages/msg.rs | 4 ++-- 16 files changed, 25 insertions(+), 27 deletions(-) diff --git a/node/Cargo.lock b/node/Cargo.lock index 147256c1..de720d3b 100644 --- a/node/Cargo.lock +++ b/node/Cargo.lock @@ -1295,9 +1295,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" @@ -2689,9 +2689,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", @@ -3923,7 +3923,7 @@ name = "zksync_protobuf_build" version = "0.1.0" dependencies = [ "anyhow", - "heck 0.4.1", + "heck 0.5.0", "prettyplease", "proc-macro2", "prost-build", diff --git a/node/Cargo.toml b/node/Cargo.toml index 55a17825..3f9f8496 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -54,7 +54,7 @@ clap = { version = "4.3.3", features = ["derive"] } criterion = "0.5.1" ed25519-dalek = { version = "2.0.0", features = ["rand_core"] } ff_ce = "0.14.3" -heck = "0.4.1" +heck = "0.5.0" hex = "0.4.3" im = "15.1.0" once_cell = "1.17.1" diff --git a/node/actors/bft/src/leader/replica_commit.rs b/node/actors/bft/src/leader/replica_commit.rs index 2a794bd8..f212cdc1 100644 --- a/node/actors/bft/src/leader/replica_commit.rs +++ b/node/actors/bft/src/leader/replica_commit.rs @@ -37,7 +37,7 @@ pub(crate) enum Error { NotLeaderInView, /// Invalid message. #[error("invalid message: {0:#}")] - InvalidMessage(anyhow::Error), + InvalidMessage(#[source] anyhow::Error), /// Duplicate message from a replica. #[error("duplicate message from a replica (existing message: {existing_message:?}")] DuplicateMessage { @@ -46,7 +46,7 @@ pub(crate) enum Error { }, /// Invalid message signature. #[error("invalid signature: {0:#}")] - InvalidSignature(#[source] validator::Error), + InvalidSignature(#[source] anyhow::Error), } impl StateMachine { diff --git a/node/actors/bft/src/leader/replica_prepare.rs b/node/actors/bft/src/leader/replica_prepare.rs index 4694f682..1f52e4f4 100644 --- a/node/actors/bft/src/leader/replica_prepare.rs +++ b/node/actors/bft/src/leader/replica_prepare.rs @@ -40,7 +40,7 @@ pub(crate) enum Error { }, /// Invalid message signature. #[error("invalid signature: {0:#}")] - InvalidSignature(#[source] validator::Error), + InvalidSignature(#[source] anyhow::Error), /// Invalid message. #[error(transparent)] InvalidMessage(validator::ReplicaPrepareVerifyError), diff --git a/node/actors/bft/src/replica/leader_commit.rs b/node/actors/bft/src/replica/leader_commit.rs index 926ac6e8..cb7e96f6 100644 --- a/node/actors/bft/src/replica/leader_commit.rs +++ b/node/actors/bft/src/replica/leader_commit.rs @@ -33,7 +33,7 @@ pub(crate) enum Error { }, /// Invalid message signature. #[error("invalid signature: {0:#}")] - InvalidSignature(validator::Error), + InvalidSignature(#[source] anyhow::Error), /// Invalid message. #[error("invalid message: {0:#}")] InvalidMessage(validator::CommitQCVerifyError), diff --git a/node/actors/bft/src/replica/leader_prepare.rs b/node/actors/bft/src/replica/leader_prepare.rs index daa57825..c4d55de8 100644 --- a/node/actors/bft/src/replica/leader_prepare.rs +++ b/node/actors/bft/src/replica/leader_prepare.rs @@ -38,7 +38,7 @@ pub(crate) enum Error { }, /// Invalid message signature. #[error("invalid signature: {0:#}")] - InvalidSignature(#[source] validator::Error), + InvalidSignature(#[source] anyhow::Error), /// Invalid message. #[error("invalid message: {0:#}")] InvalidMessage(#[source] validator::LeaderPrepareVerifyError), diff --git a/node/actors/network/src/consensus/handshake/mod.rs b/node/actors/network/src/consensus/handshake/mod.rs index 06de4a4e..5c96c74d 100644 --- a/node/actors/network/src/consensus/handshake/mod.rs +++ b/node/actors/network/src/consensus/handshake/mod.rs @@ -50,7 +50,7 @@ pub(super) enum Error { #[error("unexpected peer")] PeerMismatch, #[error("validator signature {0}")] - Signature(#[from] validator::Error), + Signature(#[from] anyhow::Error), #[error("stream {0}")] Stream(#[source] anyhow::Error), } diff --git a/node/actors/sync_blocks/src/peers/events.rs b/node/actors/sync_blocks/src/peers/events.rs index 5f7ee949..36c00bed 100644 --- a/node/actors/sync_blocks/src/peers/events.rs +++ b/node/actors/sync_blocks/src/peers/events.rs @@ -4,7 +4,7 @@ use zksync_consensus_roles::{node, validator::BlockNumber}; /// Events emitted by `PeerStates` actor. Only used for tests so far. #[derive(Debug)] -#[allow(dead_code, unused_tuple_struct_fields)] // Variant fields are only read in tests +#[allow(dead_code)] // Variant fields are only read in tests pub(super) enum PeerStateEvent { /// Node has successfully downloaded the specified block. GotBlock(BlockNumber), diff --git a/node/deny.toml b/node/deny.toml index 6bda1f83..83b52921 100644 --- a/node/deny.toml +++ b/node/deny.toml @@ -59,6 +59,7 @@ multiple-versions = "deny" skip = [ # Old versions required by tempfile and prost-build. { name = "bitflags", version = "1.3.2" }, + { name = "heck", version = "0.4.1" }, # Old version required by tracing-subscriber. { name = "regex-automata", version = "0.1.10" }, diff --git a/node/libs/concurrency/src/testonly.rs b/node/libs/concurrency/src/testonly.rs index 67870101..ca07a0b2 100644 --- a/node/libs/concurrency/src/testonly.rs +++ b/node/libs/concurrency/src/testonly.rs @@ -37,7 +37,7 @@ pub fn abort_on_panic() { /// Guard which has to be dropped before timeout is reached. /// Otherwise the test will panic. -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] #[must_use] pub struct TimeoutGuard(std::sync::mpsc::Sender<()>); diff --git a/node/libs/roles/src/validator/keys/aggregate_signature.rs b/node/libs/roles/src/validator/keys/aggregate_signature.rs index ebf2903a..d19290d9 100644 --- a/node/libs/roles/src/validator/keys/aggregate_signature.rs +++ b/node/libs/roles/src/validator/keys/aggregate_signature.rs @@ -1,4 +1,4 @@ -use super::{Error, PublicKey, Signature}; +use super::{PublicKey, Signature}; use crate::validator::messages::{Msg, MsgHash}; use std::fmt; use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; @@ -18,7 +18,7 @@ impl AggregateSignature { pub(crate) fn verify_messages<'a, V: Variant>( &self, messages_and_keys: impl Iterator, - ) -> Result<(), Error> { + ) -> anyhow::Result<()> { let hashes_and_keys = messages_and_keys.map(|(message, key)| (message.insert().hash(), key)); self.verify_hash(hashes_and_keys) @@ -28,7 +28,7 @@ impl AggregateSignature { pub(crate) fn verify_hash<'a>( &self, hashes_and_keys: impl Iterator, - ) -> Result<(), Error> { + ) -> anyhow::Result<()> { let bytes_and_pks: Vec<_> = hashes_and_keys .map(|(hash, pk)| (hash.0.as_bytes().to_owned(), &pk.0)) .collect(); diff --git a/node/libs/roles/src/validator/keys/mod.rs b/node/libs/roles/src/validator/keys/mod.rs index 43069397..44c56289 100644 --- a/node/libs/roles/src/validator/keys/mod.rs +++ b/node/libs/roles/src/validator/keys/mod.rs @@ -9,6 +9,3 @@ pub use aggregate_signature::AggregateSignature; pub use public_key::PublicKey; pub use secret_key::SecretKey; pub use signature::Signature; - -/// Error type returned by validator key operations. -pub type Error = zksync_consensus_crypto::bn254::Error; diff --git a/node/libs/roles/src/validator/keys/signature.rs b/node/libs/roles/src/validator/keys/signature.rs index 7b05733f..78afd04a 100644 --- a/node/libs/roles/src/validator/keys/signature.rs +++ b/node/libs/roles/src/validator/keys/signature.rs @@ -1,4 +1,4 @@ -use super::{Error, PublicKey}; +use super::PublicKey; use crate::validator::messages::{Msg, MsgHash}; use std::fmt; use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; @@ -9,12 +9,12 @@ pub struct Signature(pub(crate) bn254::Signature); impl Signature { /// Verify a message against a public key. - pub fn verify_msg(&self, msg: &Msg, pk: &PublicKey) -> Result<(), Error> { + pub fn verify_msg(&self, msg: &Msg, pk: &PublicKey) -> anyhow::Result<()> { self.verify_hash(&msg.hash(), pk) } /// Verify a message hash against a public key. - pub fn verify_hash(&self, msg_hash: &MsgHash, pk: &PublicKey) -> Result<(), Error> { + pub fn verify_hash(&self, msg_hash: &MsgHash, pk: &PublicKey) -> anyhow::Result<()> { self.0.verify(&ByteFmt::encode(msg_hash), &pk.0) } } diff --git a/node/libs/roles/src/validator/messages/leader_commit.rs b/node/libs/roles/src/validator/messages/leader_commit.rs index f9eb7aa9..1349e143 100644 --- a/node/libs/roles/src/validator/messages/leader_commit.rs +++ b/node/libs/roles/src/validator/messages/leader_commit.rs @@ -51,7 +51,7 @@ pub enum CommitQCVerifyError { }, /// Bad signature. #[error("bad signature: {0:#}")] - BadSignature(#[source] validator::Error), + BadSignature(#[source] anyhow::Error), } impl CommitQC { diff --git a/node/libs/roles/src/validator/messages/leader_prepare.rs b/node/libs/roles/src/validator/messages/leader_prepare.rs index 37d07e14..323cea6a 100644 --- a/node/libs/roles/src/validator/messages/leader_prepare.rs +++ b/node/libs/roles/src/validator/messages/leader_prepare.rs @@ -40,7 +40,7 @@ pub enum PrepareQCVerifyError { }, /// Bad signature. #[error("bad signature: {0:#}")] - BadSignature(validator::Error), + BadSignature(#[source] anyhow::Error), } impl PrepareQC { diff --git a/node/libs/roles/src/validator/messages/msg.rs b/node/libs/roles/src/validator/messages/msg.rs index a2da4fa4..ea0c2778 100644 --- a/node/libs/roles/src/validator/messages/msg.rs +++ b/node/libs/roles/src/validator/messages/msg.rs @@ -1,6 +1,6 @@ //! Generic message types. use super::{ConsensusMsg, NetAddress}; -use crate::{node::SessionId, validator, validator::Error}; +use crate::{node::SessionId, validator}; use std::fmt; use zksync_consensus_crypto::{keccak256, ByteFmt, Text, TextFmt}; use zksync_consensus_utils::enum_util::{BadVariantError, Variant}; @@ -108,7 +108,7 @@ pub struct Signed> { impl + Clone> Signed { /// Verify the signature on the message. - pub fn verify(&self) -> Result<(), Error> { + pub fn verify(&self) -> anyhow::Result<()> { self.sig.verify_msg(&self.msg.clone().insert(), &self.key) } }