diff --git a/node/actors/consensus/src/inner.rs b/node/actors/consensus/src/inner.rs index a52e5d95..56f8d57a 100644 --- a/node/actors/consensus/src/inner.rs +++ b/node/actors/consensus/src/inner.rs @@ -4,10 +4,10 @@ use crate::{ io::{InputMessage, OutputMessage}, misc, }; -use zksync_consensus_roles::validator; use tracing::instrument; -use zksync_consensus_utils::pipe::ActorPipe; +use zksync_consensus_roles::validator; use zksync_consensus_schema as schema; +use zksync_consensus_utils::pipe::ActorPipe; /// The ConsensusInner struct, it contains data to be shared with the state machines. This is never supposed /// to be modified, except by the Consensus struct. diff --git a/node/actors/consensus/src/leader/replica_commit.rs b/node/actors/consensus/src/leader/replica_commit.rs index feb2dd52..fa7ea5cf 100644 --- a/node/actors/consensus/src/leader/replica_commit.rs +++ b/node/actors/consensus/src/leader/replica_commit.rs @@ -1,9 +1,9 @@ use super::StateMachine; use crate::{inner::ConsensusInner, metrics}; +use tracing::instrument; use zksync_concurrency::{ctx, metrics::LatencyHistogramExt as _}; use zksync_consensus_network::io::{ConsensusInputMessage, Target}; use zksync_consensus_roles::validator; -use tracing::instrument; /// Errors that can occur when processing a "replica commit" message. #[derive(Debug, thiserror::Error)] diff --git a/node/actors/consensus/src/leader/replica_prepare.rs b/node/actors/consensus/src/leader/replica_prepare.rs index 4f7a5b73..e15c1626 100644 --- a/node/actors/consensus/src/leader/replica_prepare.rs +++ b/node/actors/consensus/src/leader/replica_prepare.rs @@ -1,11 +1,11 @@ use super::StateMachine; use crate::{inner::ConsensusInner, metrics}; -use zksync_concurrency::ctx; -use zksync_consensus_network::io::{ConsensusInputMessage, Target}; use rand::Rng; -use zksync_consensus_roles::validator; use std::collections::HashMap; use tracing::instrument; +use zksync_concurrency::ctx; +use zksync_consensus_network::io::{ConsensusInputMessage, Target}; +use zksync_consensus_roles::validator; /// Errors that can occur when processing a "replica prepare" message. #[derive(Debug, thiserror::Error)] diff --git a/node/actors/consensus/src/leader/state_machine.rs b/node/actors/consensus/src/leader/state_machine.rs index 9a847164..4380de83 100644 --- a/node/actors/consensus/src/leader/state_machine.rs +++ b/node/actors/consensus/src/leader/state_machine.rs @@ -1,11 +1,11 @@ use crate::{metrics, ConsensusInner}; -use zksync_concurrency::{ctx, metrics::LatencyHistogramExt as _, time}; -use zksync_consensus_roles::validator; use std::{ collections::{BTreeMap, HashMap}, unreachable, }; use tracing::instrument; +use zksync_concurrency::{ctx, metrics::LatencyHistogramExt as _, time}; +use zksync_consensus_roles::validator; /// The StateMachine struct contains the state of the leader. This is a simple state machine. We just store /// replica messages and produce leader messages (including proposing blocks) when we reach the threshold for diff --git a/node/actors/consensus/src/leader/tests.rs b/node/actors/consensus/src/leader/tests.rs index c5a5e145..dbdd156e 100644 --- a/node/actors/consensus/src/leader/tests.rs +++ b/node/actors/consensus/src/leader/tests.rs @@ -1,6 +1,6 @@ use crate::testonly; -use zksync_concurrency::ctx; use rand::{rngs::StdRng, Rng, SeedableRng}; +use zksync_concurrency::ctx; use zksync_consensus_roles::validator; // TODO(bruno): This only tests a particular case, not the whole method. diff --git a/node/actors/consensus/src/lib.rs b/node/actors/consensus/src/lib.rs index 5b25c5e8..dcc0b142 100644 --- a/node/actors/consensus/src/lib.rs +++ b/node/actors/consensus/src/lib.rs @@ -17,11 +17,11 @@ use crate::io::{InputMessage, OutputMessage}; use anyhow::Context as _; -use zksync_concurrency::ctx; use inner::ConsensusInner; +use tracing::{info, instrument}; +use zksync_concurrency::ctx; use zksync_consensus_roles::validator; use zksync_consensus_storage::FallbackReplicaStateStore; -use tracing::{info, instrument}; use zksync_consensus_utils::pipe::ActorPipe; mod inner; diff --git a/node/actors/consensus/src/replica/block.rs b/node/actors/consensus/src/replica/block.rs index f2aa8dd1..92985b74 100644 --- a/node/actors/consensus/src/replica/block.rs +++ b/node/actors/consensus/src/replica/block.rs @@ -1,7 +1,7 @@ use super::StateMachine; use crate::{inner::ConsensusInner, io::OutputMessage}; -use zksync_consensus_roles::validator; use tracing::{info, instrument}; +use zksync_consensus_roles::validator; impl StateMachine { /// Tries to build a finalized block from the given CommitQC. We simply search our diff --git a/node/actors/consensus/src/replica/leader_commit.rs b/node/actors/consensus/src/replica/leader_commit.rs index 3ff7dc38..ba0fd3e6 100644 --- a/node/actors/consensus/src/replica/leader_commit.rs +++ b/node/actors/consensus/src/replica/leader_commit.rs @@ -1,9 +1,9 @@ use super::StateMachine; use crate::inner::ConsensusInner; use anyhow::Context as _; +use tracing::instrument; use zksync_concurrency::ctx; use zksync_consensus_roles::validator; -use tracing::instrument; /// Errors that can occur when processing a "leader commit" message. #[derive(Debug, thiserror::Error)] diff --git a/node/actors/consensus/src/replica/leader_prepare.rs b/node/actors/consensus/src/replica/leader_prepare.rs index 601d22b5..47b21744 100644 --- a/node/actors/consensus/src/replica/leader_prepare.rs +++ b/node/actors/consensus/src/replica/leader_prepare.rs @@ -1,11 +1,11 @@ use super::StateMachine; use crate::inner::ConsensusInner; use anyhow::Context as _; +use std::collections::HashMap; +use tracing::instrument; use zksync_concurrency::ctx; use zksync_consensus_network::io::{ConsensusInputMessage, Target}; use zksync_consensus_roles::validator; -use std::collections::HashMap; -use tracing::instrument; /// Errors that can occur when processing a "leader prepare" message. #[derive(Debug, thiserror::Error)] diff --git a/node/actors/consensus/src/replica/new_view.rs b/node/actors/consensus/src/replica/new_view.rs index bc19c915..f9571f2c 100644 --- a/node/actors/consensus/src/replica/new_view.rs +++ b/node/actors/consensus/src/replica/new_view.rs @@ -1,10 +1,10 @@ use super::StateMachine; use crate::ConsensusInner; use anyhow::Context as _; +use tracing::instrument; use zksync_concurrency::ctx; use zksync_consensus_network::io::{ConsensusInputMessage, Target}; use zksync_consensus_roles::validator; -use tracing::instrument; impl StateMachine { /// This blocking method is used whenever we start a new view. diff --git a/node/actors/consensus/src/replica/state_machine.rs b/node/actors/consensus/src/replica/state_machine.rs index c20de207..a3a3e983 100644 --- a/node/actors/consensus/src/replica/state_machine.rs +++ b/node/actors/consensus/src/replica/state_machine.rs @@ -1,11 +1,11 @@ use crate::{metrics, ConsensusInner}; use anyhow::Context as _; -use zksync_concurrency::{ctx, metrics::LatencyHistogramExt as _, scope, time}; -use zksync_consensus_roles::validator; use std::collections::{BTreeMap, HashMap}; -use zksync_consensus_storage::{FallbackReplicaStateStore, StorageError}; use tracing::instrument; +use zksync_concurrency::{ctx, metrics::LatencyHistogramExt as _, scope, time}; +use zksync_consensus_roles::validator; use zksync_consensus_storage as storage; +use zksync_consensus_storage::{FallbackReplicaStateStore, StorageError}; /// The StateMachine struct contains the state of the replica. This is the most complex state machine and is responsible /// for validating and voting on blocks. When participating in consensus we are always a replica. diff --git a/node/actors/consensus/src/replica/tests.rs b/node/actors/consensus/src/replica/tests.rs index 732daf75..d7307b17 100644 --- a/node/actors/consensus/src/replica/tests.rs +++ b/node/actors/consensus/src/replica/tests.rs @@ -1,7 +1,8 @@ use crate::testonly; +use rand::Rng; +use zksync_concurrency as concurrency; use zksync_concurrency::{ctx, scope, time}; use zksync_consensus_network::io::{ConsensusInputMessage, Target}; -use rand::Rng; use zksync_consensus_roles::validator::{self, ViewNumber}; #[tokio::test] diff --git a/node/actors/consensus/src/replica/timer.rs b/node/actors/consensus/src/replica/timer.rs index 5bb4c98b..c5231fa8 100644 --- a/node/actors/consensus/src/replica/timer.rs +++ b/node/actors/consensus/src/replica/timer.rs @@ -1,7 +1,7 @@ use super::StateMachine; use crate::metrics; -use zksync_concurrency::{ctx, metrics::LatencyGaugeExt as _, time}; use tracing::instrument; +use zksync_concurrency::{ctx, metrics::LatencyGaugeExt as _, time}; impl StateMachine { /// The base duration of the timeout. diff --git a/node/actors/consensus/src/testonly/make.rs b/node/actors/consensus/src/testonly/make.rs index aad0b239..ca99edec 100644 --- a/node/actors/consensus/src/testonly/make.rs +++ b/node/actors/consensus/src/testonly/make.rs @@ -4,9 +4,9 @@ use crate::{ io::{InputMessage, OutputMessage}, Consensus, }; +use std::sync::Arc; use zksync_concurrency::ctx; use zksync_consensus_roles::validator; -use std::sync::Arc; use zksync_consensus_storage::{FallbackReplicaStateStore, InMemoryStorage}; use zksync_consensus_utils::pipe::{self, DispatcherPipe}; diff --git a/node/actors/consensus/src/testonly/mod.rs b/node/actors/consensus/src/testonly/mod.rs index 496b3611..ed47074d 100644 --- a/node/actors/consensus/src/testonly/mod.rs +++ b/node/actors/consensus/src/testonly/mod.rs @@ -1,9 +1,9 @@ //! This module contains utilities that are only meant for testing purposes. use crate::io::InputMessage; +use rand::{distributions::Standard, prelude::Distribution, Rng}; use zksync_concurrency::oneshot; use zksync_consensus_network::io::ConsensusReq; -use rand::{distributions::Standard, prelude::Distribution, Rng}; #[cfg(test)] mod fuzz; diff --git a/node/actors/consensus/src/testonly/node.rs b/node/actors/consensus/src/testonly/node.rs index a581089e..ae8b6f68 100644 --- a/node/actors/consensus/src/testonly/node.rs +++ b/node/actors/consensus/src/testonly/node.rs @@ -1,8 +1,9 @@ use super::Fuzz; use crate::io; +use rand::Rng; use zksync_concurrency::{ctx, ctx::channel, scope}; +use zksync_consensus_network as network; use zksync_consensus_network::io::ConsensusInputMessage; -use rand::Rng; use zksync_consensus_roles::validator; use zksync_consensus_utils::pipe::DispatcherPipe; diff --git a/node/actors/consensus/src/testonly/run.rs b/node/actors/consensus/src/testonly/run.rs index fc2ef02f..d0654712 100644 --- a/node/actors/consensus/src/testonly/run.rs +++ b/node/actors/consensus/src/testonly/run.rs @@ -1,14 +1,15 @@ use super::{Behavior, Metrics, Node}; use crate::{testonly, Consensus}; use anyhow::Context; -use zksync_concurrency::{ctx, ctx::channel, oneshot, scope, signal}; -use zksync_consensus_roles::validator; use std::{ collections::{HashMap, HashSet}, sync::Arc, }; -use zksync_consensus_storage::{FallbackReplicaStateStore, InMemoryStorage}; use tracing::Instrument as _; +use zksync_concurrency::{ctx, ctx::channel, oneshot, scope, signal}; +use zksync_consensus_network as network; +use zksync_consensus_roles::validator; +use zksync_consensus_storage::{FallbackReplicaStateStore, InMemoryStorage}; use zksync_consensus_utils::pipe; #[derive(Clone, Copy)] diff --git a/node/actors/consensus/src/tests.rs b/node/actors/consensus/src/tests.rs index 3e4b51fd..e5796389 100644 --- a/node/actors/consensus/src/tests.rs +++ b/node/actors/consensus/src/tests.rs @@ -2,6 +2,7 @@ use crate::{ misc::consensus_threshold, testonly::{Behavior, Network, Test}, }; +use zksync_concurrency as concurrency; use zksync_concurrency::ctx; async fn run_test(behavior: Behavior, network: Network) { diff --git a/node/actors/executor/src/config/mod.rs b/node/actors/executor/src/config/mod.rs index f0c58339..4ab296fa 100644 --- a/node/actors/executor/src/config/mod.rs +++ b/node/actors/executor/src/config/mod.rs @@ -1,14 +1,16 @@ //! Module to create the configuration for the consensus node. use anyhow::Context as _; -use zksync_consensus_crypto::{read_required_text, Text, TextFmt}; -use zksync_consensus_network::{consensus, gossip}; -use zksync_consensus_roles::{node, validator}; -use zksync_consensus_schema::{proto::executor::config as proto, read_required, required, ProtoFmt}; use std::{ collections::{HashMap, HashSet}, net, }; +use zksync_consensus_crypto::{read_required_text, Text, TextFmt}; +use zksync_consensus_network::{consensus, gossip}; +use zksync_consensus_roles::{node, validator}; +use zksync_consensus_schema::{ + proto::executor::config as proto, read_required, required, ProtoFmt, +}; #[cfg(test)] mod tests; diff --git a/node/actors/executor/src/config/tests.rs b/node/actors/executor/src/config/tests.rs index 47bbc8dd..7b1ab797 100644 --- a/node/actors/executor/src/config/tests.rs +++ b/node/actors/executor/src/config/tests.rs @@ -1,9 +1,9 @@ use super::{ConsensusConfig, ExecutorConfig, GossipConfig}; -use zksync_concurrency::ctx; use rand::{ distributions::{Distribution, Standard}, Rng, }; +use zksync_concurrency::ctx; use zksync_consensus_roles::{node, validator}; use zksync_consensus_schema::testonly::test_encode_random; diff --git a/node/actors/executor/src/io.rs b/node/actors/executor/src/io.rs index bd9a7df8..d6950a82 100644 --- a/node/actors/executor/src/io.rs +++ b/node/actors/executor/src/io.rs @@ -1,6 +1,7 @@ //! Module to manage the communication between actors. It simply converts and forwards messages from and to each different actor. use crate::metrics; +use tracing::instrument; use zksync_concurrency::{ ctx::{self, channel}, scope, @@ -8,12 +9,13 @@ use zksync_concurrency::{ use zksync_consensus_consensus::io::{ InputMessage as ConsensusInputMessage, OutputMessage as ConsensusOutputMessage, }; -use zksync_consensus_network::io::{InputMessage as NetworkInputMessage, OutputMessage as NetworkOutputMessage}; +use zksync_consensus_network::io::{ + InputMessage as NetworkInputMessage, OutputMessage as NetworkOutputMessage, +}; use zksync_consensus_roles::validator::FinalBlock; use zksync_consensus_sync_blocks::io::{ InputMessage as SyncBlocksInputMessage, OutputMessage as SyncBlocksOutputMessage, }; -use tracing::instrument; use zksync_consensus_utils::pipe::DispatcherPipe; /// The IO dispatcher, it is the main struct to handle actor messages. It simply contains a sender and a receiver for diff --git a/node/actors/executor/src/lib.rs b/node/actors/executor/src/lib.rs index 2a679b91..70a60e59 100644 --- a/node/actors/executor/src/lib.rs +++ b/node/actors/executor/src/lib.rs @@ -2,16 +2,16 @@ use crate::io::Dispatcher; use anyhow::Context as _; +use std::{mem, sync::Arc}; use zksync_concurrency::{ctx, ctx::channel, net, scope}; +use zksync_consensus_consensus as consensus; use zksync_consensus_consensus::Consensus; +use zksync_consensus_network as network; use zksync_consensus_roles::{node, validator, validator::FinalBlock}; -use std::{mem, sync::Arc}; use zksync_consensus_storage::{FallbackReplicaStateStore, ReplicaStateStore, WriteBlockStore}; +use zksync_consensus_sync_blocks as sync_blocks; use zksync_consensus_sync_blocks::SyncBlocks; use zksync_consensus_utils::pipe; -use zksync_consensus_network as network; -use zksync_consensus_sync_blocks as sync_blocks; -use zksync_consensus_consensus as consensus; mod config; mod io; diff --git a/node/actors/executor/src/tests.rs b/node/actors/executor/src/tests.rs index d0acaa8d..ddcb4795 100644 --- a/node/actors/executor/src/tests.rs +++ b/node/actors/executor/src/tests.rs @@ -1,12 +1,13 @@ //! High-level tests for `Executor`. use super::*; +use rand::Rng; +use std::collections::HashMap; +use zksync_concurrency as concurrency; use zksync_concurrency::sync; use zksync_consensus_consensus::testonly::make_genesis; use zksync_consensus_network::testonly::Instance; -use rand::Rng; use zksync_consensus_roles::validator::{BlockNumber, Payload}; -use std::collections::HashMap; use zksync_consensus_storage::{BlockStore, InMemoryStorage, StorageError}; async fn run_executor(ctx: &ctx::Ctx, executor: Executor) -> anyhow::Result<()> { diff --git a/node/actors/network/src/consensus/handshake/tests.rs b/node/actors/network/src/consensus/handshake/tests.rs index a53e663d..d53bc916 100644 --- a/node/actors/network/src/consensus/handshake/tests.rs +++ b/node/actors/network/src/consensus/handshake/tests.rs @@ -1,8 +1,10 @@ use super::*; use crate::{frame, noise, testonly}; -use zksync_concurrency::{ctx, io, scope}; use rand::Rng; +use zksync_concurrency as concurrency; +use zksync_concurrency::{ctx, io, scope}; use zksync_consensus_roles::validator; +use zksync_consensus_schema as schema; #[test] fn test_schema_encode_decode() { diff --git a/node/actors/network/src/consensus/runner.rs b/node/actors/network/src/consensus/runner.rs index 6d114950..9d1c9995 100644 --- a/node/actors/network/src/consensus/runner.rs +++ b/node/actors/network/src/consensus/runner.rs @@ -3,9 +3,9 @@ use super::handshake; use crate::{io, noise, preface, rpc, State}; use anyhow::Context as _; +use std::{collections::HashMap, sync::Arc}; use zksync_concurrency::{ctx, ctx::channel, oneshot, scope, sync, time}; use zksync_consensus_roles::validator; -use std::{collections::HashMap, sync::Arc}; /// How often we should retry to establish a connection to a validator. /// TODO(gprusak): once it becomes relevant, choose a more appropriate retry strategy. diff --git a/node/actors/network/src/consensus/state.rs b/node/actors/network/src/consensus/state.rs index a2571f3f..e8521283 100644 --- a/node/actors/network/src/consensus/state.rs +++ b/node/actors/network/src/consensus/state.rs @@ -1,6 +1,6 @@ use crate::pool::PoolWatch; -use zksync_consensus_roles::{validator, validator::ValidatorSet}; use std::collections::HashSet; +use zksync_consensus_roles::{validator, validator::ValidatorSet}; /// Configuration of the consensus network. #[derive(Debug, Clone)] diff --git a/node/actors/network/src/consensus/tests.rs b/node/actors/network/src/consensus/tests.rs index 1e281417..00e51782 100644 --- a/node/actors/network/src/consensus/tests.rs +++ b/node/actors/network/src/consensus/tests.rs @@ -1,10 +1,11 @@ use super::*; use crate::{io, preface, rpc, run_network, testonly}; use anyhow::Context as _; -use zksync_concurrency::{ctx, net, scope}; use rand::Rng; -use zksync_consensus_roles::validator; use tracing::Instrument as _; +use zksync_concurrency as concurrency; +use zksync_concurrency::{ctx, net, scope}; +use zksync_consensus_roles::validator; use zksync_consensus_utils::pipe; #[tokio::test] diff --git a/node/actors/network/src/gossip/handshake/tests.rs b/node/actors/network/src/gossip/handshake/tests.rs index 949e2970..7ea1fd14 100644 --- a/node/actors/network/src/gossip/handshake/tests.rs +++ b/node/actors/network/src/gossip/handshake/tests.rs @@ -1,9 +1,11 @@ use super::*; use crate::{frame, noise, testonly}; -use zksync_concurrency::{ctx, io, scope}; use rand::Rng; -use zksync_consensus_roles::node; use std::collections::{HashMap, HashSet}; +use zksync_concurrency as concurrency; +use zksync_concurrency::{ctx, io, scope}; +use zksync_consensus_roles::node; +use zksync_consensus_schema as schema; #[test] fn test_schema_encode_decode() { diff --git a/node/actors/network/src/gossip/runner.rs b/node/actors/network/src/gossip/runner.rs index bdbb4deb..d19d493b 100644 --- a/node/actors/network/src/gossip/runner.rs +++ b/node/actors/network/src/gossip/runner.rs @@ -6,6 +6,8 @@ use crate::{ }; use anyhow::Context; use async_trait::async_trait; +use std::sync::Arc; +use tracing::Instrument as _; use zksync_concurrency::{ ctx::{self, channel}, oneshot, scope, @@ -13,8 +15,6 @@ use zksync_concurrency::{ time, }; use zksync_consensus_roles::{node, validator}; -use std::sync::Arc; -use tracing::Instrument as _; /// How often we should retry to establish a connection to a validator. /// TODO(gprusak): once it becomes relevant, choose a more appropriate retry strategy. diff --git a/node/actors/network/src/gossip/state.rs b/node/actors/network/src/gossip/state.rs index e185c02c..c40f3cd6 100644 --- a/node/actors/network/src/gossip/state.rs +++ b/node/actors/network/src/gossip/state.rs @@ -1,10 +1,10 @@ use crate::{io::SyncState, pool::PoolWatch, rpc, watch::Watch}; -use zksync_concurrency::sync::{self, watch, Mutex}; -use zksync_consensus_roles::{node, validator}; use std::{ collections::{HashMap, HashSet}, sync::Arc, }; +use zksync_concurrency::sync::{self, watch, Mutex}; +use zksync_consensus_roles::{node, validator}; /// Mapping from validator::PublicKey to a signed validator::NetAddress. /// Represents the currents state of node's knowledge about the validator endpoints. diff --git a/node/actors/network/src/gossip/tests.rs b/node/actors/network/src/gossip/tests.rs index ffc11397..8b38d4cf 100644 --- a/node/actors/network/src/gossip/tests.rs +++ b/node/actors/network/src/gossip/tests.rs @@ -1,21 +1,23 @@ use super::*; use crate::{event::Event, io, preface, rpc, rpc::Rpc as _, run_network, testonly}; use anyhow::Context as _; -use zksync_concurrency::{ - ctx::{self, channel}, - oneshot, scope, - sync::{watch, Mutex}, - time, -}; use pretty_assertions::assert_eq; use rand::Rng; -use zksync_consensus_roles::validator::{self, BlockNumber, FinalBlock}; use std::{ collections::{HashMap, HashSet}, sync::Arc, }; use test_casing::{test_casing, Product}; use tracing::Instrument as _; +use zksync_concurrency as concurrency; +use zksync_concurrency::{ + ctx::{self, channel}, + oneshot, scope, + sync::{watch, Mutex}, + time, +}; +use zksync_consensus_roles as roles; +use zksync_consensus_roles::validator::{self, BlockNumber, FinalBlock}; use zksync_consensus_utils::pipe; #[tokio::test] diff --git a/node/actors/network/src/metrics.rs b/node/actors/network/src/metrics.rs index c5eff662..8503b7da 100644 --- a/node/actors/network/src/metrics.rs +++ b/node/actors/network/src/metrics.rs @@ -1,7 +1,6 @@ //! General-purpose network metrics. use crate::state::State; -use zksync_concurrency::{ctx, io, net}; use std::{ net::SocketAddr, pin::Pin, @@ -11,6 +10,7 @@ use std::{ use vise::{ Collector, Counter, EncodeLabelSet, EncodeLabelValue, Family, Gauge, GaugeGuard, Metrics, Unit, }; +use zksync_concurrency::{ctx, io, net}; /// Metered TCP stream. #[pin_project::pin_project] diff --git a/node/actors/network/src/mux/handshake.rs b/node/actors/network/src/mux/handshake.rs index 0557c651..83ac6a52 100644 --- a/node/actors/network/src/mux/handshake.rs +++ b/node/actors/network/src/mux/handshake.rs @@ -1,8 +1,8 @@ use super::CapabilityId; use anyhow::Context as _; -use zksync_consensus_schema::{proto::network::mux as proto, required}; use std::collections::HashMap; use zksync_consensus_schema as schema; +use zksync_consensus_schema::{proto::network::mux as proto, required}; pub(super) struct Handshake { /// Maximal supported number of the accept streams per capability. diff --git a/node/actors/network/src/mux/mod.rs b/node/actors/network/src/mux/mod.rs index 6a836f6d..fc3f021c 100644 --- a/node/actors/network/src/mux/mod.rs +++ b/node/actors/network/src/mux/mod.rs @@ -79,8 +79,8 @@ //! both sides of the connection can enforce. use crate::{frame, noise::bytes}; use anyhow::Context as _; -use zksync_concurrency::{ctx, ctx::channel, io, scope, sync}; use std::{collections::BTreeMap, sync::Arc}; +use zksync_concurrency::{ctx, ctx::channel, io, scope, sync}; mod config; mod handshake; diff --git a/node/actors/network/src/mux/reusable_stream.rs b/node/actors/network/src/mux/reusable_stream.rs index 9a23aea2..a0fe6a14 100644 --- a/node/actors/network/src/mux/reusable_stream.rs +++ b/node/actors/network/src/mux/reusable_stream.rs @@ -3,8 +3,8 @@ use super::{ Config, FrameKind, Header, ReadStream, RunError, Stream, StreamId, StreamKind, WriteStream, }; use crate::noise::bytes; -use zksync_concurrency::{ctx, ctx::channel, oneshot, scope, sync}; use std::sync::Arc; +use zksync_concurrency::{ctx, ctx::channel, oneshot, scope, sync}; /// Read frame allocation permit. #[derive(Debug)] diff --git a/node/actors/network/src/mux/tests.rs b/node/actors/network/src/mux/tests.rs index 86c166b0..a1b397fb 100644 --- a/node/actors/network/src/mux/tests.rs +++ b/node/actors/network/src/mux/tests.rs @@ -1,8 +1,6 @@ use crate::{frame, mux, noise, noise::bytes}; use anyhow::Context as _; -use zksync_concurrency::{ctx, scope}; use rand::Rng as _; -use zksync_consensus_schema::proto::network::mux_test as proto; use std::{ collections::BTreeMap, sync::{ @@ -10,6 +8,10 @@ use std::{ Arc, }, }; +use zksync_concurrency as concurrency; +use zksync_concurrency::{ctx, scope}; +use zksync_consensus_schema as schema; +use zksync_consensus_schema::proto::network::mux_test as proto; use zksync_consensus_utils::no_copy::NoCopy; fn assert_partition(sets: &[u16]) { diff --git a/node/actors/network/src/noise/stream.rs b/node/actors/network/src/noise/stream.rs index 81a1c3be..205edfaa 100644 --- a/node/actors/network/src/noise/stream.rs +++ b/node/actors/network/src/noise/stream.rs @@ -1,15 +1,15 @@ //! `tokio::io` stream using Noise encryption. use super::bytes; use crate::metrics::MeteredStream; +use std::{ + pin::Pin, + task::{ready, Context, Poll}, +}; use zksync_concurrency::{ ctx, io, io::{AsyncRead as _, AsyncWrite as _}, }; use zksync_consensus_crypto::{sha256::Sha256, ByteFmt}; -use std::{ - pin::Pin, - task::{ready, Context, Poll}, -}; /// Fixed noise configuration. Nodes need to use the same noise /// configuration to be able to connect to each other. diff --git a/node/actors/network/src/noise/tests.rs b/node/actors/network/src/noise/tests.rs index dffda0dd..c2372aa8 100644 --- a/node/actors/network/src/noise/tests.rs +++ b/node/actors/network/src/noise/tests.rs @@ -1,7 +1,8 @@ use crate::noise; -use zksync_concurrency::{ctx, io, scope}; use rand::Rng; use tracing::instrument::Instrument as _; +use zksync_concurrency as concurrency; +use zksync_concurrency::{ctx, io, scope}; #[tokio::test] async fn transmit_ok() { diff --git a/node/actors/network/src/pool.rs b/node/actors/network/src/pool.rs index 727cd4a8..92257993 100644 --- a/node/actors/network/src/pool.rs +++ b/node/actors/network/src/pool.rs @@ -1,8 +1,8 @@ //! An abstraction for a set of "connections" which constraints //! which peers are allowed to connect. use crate::watch::Watch; -use zksync_concurrency::sync; use std::collections::HashSet; +use zksync_concurrency::sync; /// Set of elements of type T. /// This set consists of an arbitrary subset of `allowed` + up to `extra_limit` elements outside of diff --git a/node/actors/network/src/preface.rs b/node/actors/network/src/preface.rs index 99232185..5cb53ac9 100644 --- a/node/actors/network/src/preface.rs +++ b/node/actors/network/src/preface.rs @@ -9,8 +9,8 @@ //! and multiplex between mutliple endpoints available on the same TCP port. use crate::{frame, metrics, noise}; use zksync_concurrency::{ctx, time}; -use zksync_consensus_schema::{proto::network::preface as proto, required, ProtoFmt}; use zksync_consensus_schema as schema; +use zksync_consensus_schema::{proto::network::preface as proto, required, ProtoFmt}; /// Timeout on executing the preface protocol. const TIMEOUT: time::Duration = time::Duration::seconds(5); diff --git a/node/actors/network/src/rpc/consensus.rs b/node/actors/network/src/rpc/consensus.rs index 43a9fa5a..86365eb0 100644 --- a/node/actors/network/src/rpc/consensus.rs +++ b/node/actors/network/src/rpc/consensus.rs @@ -2,8 +2,8 @@ use crate::mux; use zksync_concurrency::{limiter, time}; use zksync_consensus_roles::validator; -use zksync_consensus_schema::{proto::network::consensus as proto, read_required, ProtoFmt}; use zksync_consensus_schema as schema; +use zksync_consensus_schema::{proto::network::consensus as proto, read_required, ProtoFmt}; /// Consensus RPC. pub(crate) struct Rpc; diff --git a/node/actors/network/src/rpc/metrics.rs b/node/actors/network/src/rpc/metrics.rs index df0adab7..a9111cec 100644 --- a/node/actors/network/src/rpc/metrics.rs +++ b/node/actors/network/src/rpc/metrics.rs @@ -2,11 +2,11 @@ use super::Rpc; use std::{any::Any, time::Duration}; -use zksync_consensus_schema as schema; use vise::{ Buckets, EncodeLabelSet, EncodeLabelValue, Family, Gauge, Histogram, LabeledFamily, Metrics, Unit, }; +use zksync_consensus_schema as schema; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EncodeLabelValue)] #[metrics(rename_all = "snake_case")] diff --git a/node/actors/network/src/rpc/mod.rs b/node/actors/network/src/rpc/mod.rs index 5453f1ae..b3173821 100644 --- a/node/actors/network/src/rpc/mod.rs +++ b/node/actors/network/src/rpc/mod.rs @@ -18,8 +18,8 @@ use self::metrics::{CallLatencyType, CallType, RPC_METRICS}; use crate::{frame, mux}; use anyhow::Context as _; -use zksync_concurrency::{ctx, io, limiter, metrics::LatencyHistogramExt as _, scope}; use std::{collections::BTreeMap, sync::Arc}; +use zksync_concurrency::{ctx, io, limiter, metrics::LatencyHistogramExt as _, scope}; use zksync_consensus_schema as schema; pub(crate) mod consensus; diff --git a/node/actors/network/src/rpc/ping.rs b/node/actors/network/src/rpc/ping.rs index fc54b125..98a292bc 100644 --- a/node/actors/network/src/rpc/ping.rs +++ b/node/actors/network/src/rpc/ping.rs @@ -1,10 +1,10 @@ //! Defines an RPC for sending ping messages. use crate::{mux, rpc::Rpc as _}; use anyhow::Context as _; -use zksync_concurrency::{ctx, limiter, time}; use rand::Rng; -use zksync_consensus_schema::{proto::network::ping as proto, required, ProtoFmt}; +use zksync_concurrency::{ctx, limiter, time}; use zksync_consensus_schema as schema; +use zksync_consensus_schema::{proto::network::ping as proto, required, ProtoFmt}; /// Ping RPC. pub(crate) struct Rpc; diff --git a/node/actors/network/src/rpc/sync_blocks.rs b/node/actors/network/src/rpc/sync_blocks.rs index 31443f5c..26454b53 100644 --- a/node/actors/network/src/rpc/sync_blocks.rs +++ b/node/actors/network/src/rpc/sync_blocks.rs @@ -4,8 +4,8 @@ use crate::{io, mux}; use anyhow::Context; use zksync_concurrency::{limiter, time}; use zksync_consensus_roles::validator::{BlockNumber, FinalBlock}; -use zksync_consensus_schema::{proto::network::gossip as proto, read_required, ProtoFmt}; use zksync_consensus_schema as schema; +use zksync_consensus_schema::{proto::network::gossip as proto, read_required, ProtoFmt}; /// `get_sync_state` RPC. #[derive(Debug)] diff --git a/node/actors/network/src/rpc/sync_validator_addrs.rs b/node/actors/network/src/rpc/sync_validator_addrs.rs index 579923e9..587c4dbd 100644 --- a/node/actors/network/src/rpc/sync_validator_addrs.rs +++ b/node/actors/network/src/rpc/sync_validator_addrs.rs @@ -1,11 +1,11 @@ //! Defines an Rpc for synchronizing ValidatorAddrs data. use crate::mux; use anyhow::Context as _; +use std::sync::Arc; use zksync_concurrency::{limiter, time}; use zksync_consensus_roles::validator; -use zksync_consensus_schema::{proto::network::gossip as proto, ProtoFmt}; use zksync_consensus_schema as schema; -use std::sync::Arc; +use zksync_consensus_schema::{proto::network::gossip as proto, ProtoFmt}; /// SyncValidatorAddrs Rpc. pub(crate) struct Rpc; diff --git a/node/actors/network/src/rpc/tests.rs b/node/actors/network/src/rpc/tests.rs index 9c99f3f6..7a71e252 100644 --- a/node/actors/network/src/rpc/tests.rs +++ b/node/actors/network/src/rpc/tests.rs @@ -1,11 +1,12 @@ use super::*; use crate::noise; -use zksync_concurrency::{ctx, time}; use rand::Rng as _; use std::{ collections::HashSet, sync::atomic::{AtomicU64, Ordering}, }; +use zksync_concurrency as concurrency; +use zksync_concurrency::{ctx, time}; /// CAPABILITY_ID should uniquely identify the RPC. #[test] diff --git a/node/actors/network/src/state.rs b/node/actors/network/src/state.rs index 0fa566a2..ae9269c6 100644 --- a/node/actors/network/src/state.rs +++ b/node/actors/network/src/state.rs @@ -2,9 +2,9 @@ use super::{consensus, event::Event, gossip, metrics, preface}; use crate::io::{InputMessage, OutputMessage, SyncState}; use anyhow::Context as _; +use std::sync::Arc; use zksync_concurrency::{ctx, ctx::channel, net, scope, sync::watch}; use zksync_consensus_roles::validator; -use std::sync::Arc; use zksync_consensus_utils::pipe::ActorPipe; /// Network actor config. diff --git a/node/actors/network/src/testonly.rs b/node/actors/network/src/testonly.rs index 065ec9d4..6946a1a1 100644 --- a/node/actors/network/src/testonly.rs +++ b/node/actors/network/src/testonly.rs @@ -1,18 +1,18 @@ //! Testonly utilities. #![allow(dead_code)] use crate::{consensus, event::Event, gossip, io::SyncState, Config, State}; +use rand::Rng; +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, +}; use zksync_concurrency::{ ctx, ctx::channel, io, net, sync::{self, watch}, }; -use rand::Rng; use zksync_consensus_roles::validator; -use std::{ - collections::{HashMap, HashSet}, - sync::Arc, -}; /// Synchronously forwards data from one stream to another. pub(crate) async fn forward( diff --git a/node/actors/network/src/tests.rs b/node/actors/network/src/tests.rs index 5500c072..93269d1e 100644 --- a/node/actors/network/src/tests.rs +++ b/node/actors/network/src/tests.rs @@ -1,6 +1,7 @@ use crate::{run_network, testonly}; -use zksync_concurrency::{ctx, scope}; use tracing::Instrument as _; +use zksync_concurrency as concurrency; +use zksync_concurrency::{ctx, scope}; use zksync_consensus_utils::pipe; /// Test that metrics are correctly defined diff --git a/node/actors/sync_blocks/src/lib.rs b/node/actors/sync_blocks/src/lib.rs index 5e255ed1..54d71473 100644 --- a/node/actors/sync_blocks/src/lib.rs +++ b/node/actors/sync_blocks/src/lib.rs @@ -7,14 +7,14 @@ use crate::{ io::{InputMessage, OutputMessage}, message_handler::SyncBlocksMessageHandler, }; +use std::sync::Arc; +use tracing::instrument; use zksync_concurrency::{ ctx, scope, sync::{self, watch}, }; use zksync_consensus_network::io::SyncState; -use std::sync::Arc; use zksync_consensus_storage::WriteBlockStore; -use tracing::instrument; use zksync_consensus_utils::pipe::ActorPipe; mod config; diff --git a/node/actors/sync_blocks/src/message_handler.rs b/node/actors/sync_blocks/src/message_handler.rs index abd2369c..67412278 100644 --- a/node/actors/sync_blocks/src/message_handler.rs +++ b/node/actors/sync_blocks/src/message_handler.rs @@ -1,12 +1,12 @@ //! Inner details of `SyncBlocks` actor. use crate::{io::InputMessage, peers::PeerStatesHandle}; +use std::sync::Arc; +use tracing::instrument; use zksync_concurrency::ctx::{self, channel}; use zksync_consensus_network::io::{GetBlockError, GetBlockResponse, SyncBlocksRequest}; use zksync_consensus_roles::validator::BlockNumber; -use std::sync::Arc; use zksync_consensus_storage::WriteBlockStore; -use tracing::instrument; /// Inner details of `SyncBlocks` actor allowing to process messages. #[derive(Debug)] diff --git a/node/actors/sync_blocks/src/peers/mod.rs b/node/actors/sync_blocks/src/peers/mod.rs index 6c9f95d5..9bb6e4f6 100644 --- a/node/actors/sync_blocks/src/peers/mod.rs +++ b/node/actors/sync_blocks/src/peers/mod.rs @@ -3,6 +3,8 @@ use self::events::PeerStateEvent; use crate::{io, Config}; use anyhow::Context as _; +use std::{collections::HashMap, sync::Arc}; +use tracing::instrument; use zksync_concurrency::{ ctx::{self, channel}, oneshot, scope, @@ -13,9 +15,7 @@ use zksync_consensus_roles::{ node, validator::{BlockHeader, BlockNumber, FinalBlock, PayloadHash}, }; -use std::{collections::HashMap, sync::Arc}; use zksync_consensus_storage::WriteBlockStore; -use tracing::instrument; mod events; #[cfg(test)] diff --git a/node/actors/sync_blocks/src/peers/tests.rs b/node/actors/sync_blocks/src/peers/tests.rs index 0387902a..485c97dd 100644 --- a/node/actors/sync_blocks/src/peers/tests.rs +++ b/node/actors/sync_blocks/src/peers/tests.rs @@ -2,12 +2,13 @@ use super::*; use crate::tests::TestValidators; use assert_matches::assert_matches; use async_trait::async_trait; -use zksync_concurrency::time; use rand::{rngs::StdRng, seq::IteratorRandom, Rng}; -use zksync_consensus_roles::validator; use std::{collections::HashSet, fmt}; -use zksync_consensus_storage::{BlockStore, InMemoryStorage}; use test_casing::{test_casing, Product}; +use zksync_concurrency as concurrency; +use zksync_concurrency::time; +use zksync_consensus_roles::validator; +use zksync_consensus_storage::{BlockStore, InMemoryStorage}; const TEST_TIMEOUT: time::Duration = time::Duration::seconds(5); const BLOCK_SLEEP_INTERVAL: time::Duration = time::Duration::milliseconds(5); diff --git a/node/actors/sync_blocks/src/tests/end_to_end.rs b/node/actors/sync_blocks/src/tests/end_to_end.rs index 629ba2f1..a1ad1dbe 100644 --- a/node/actors/sync_blocks/src/tests/end_to_end.rs +++ b/node/actors/sync_blocks/src/tests/end_to_end.rs @@ -1,16 +1,17 @@ //! End-to-end tests that launch a network of nodes and the `SyncBlocks` actor for each node. - use super::*; use anyhow::Context as _; use async_trait::async_trait; -use zksync_concurrency::ctx::channel; -use zksync_consensus_network::testonly::Instance as NetworkInstance; use rand::seq::SliceRandom; -use zksync_consensus_roles::node; use std::fmt; -use zksync_consensus_storage::InMemoryStorage; use test_casing::test_casing; use tracing::Instrument; +use zksync_concurrency as concurrency; +use zksync_concurrency::ctx::channel; +use zksync_consensus_network as network; +use zksync_consensus_network::testonly::Instance as NetworkInstance; +use zksync_consensus_roles::node; +use zksync_consensus_storage::InMemoryStorage; type NetworkDispatcherPipe = pipe::DispatcherPipe; diff --git a/node/actors/sync_blocks/src/tests/mod.rs b/node/actors/sync_blocks/src/tests/mod.rs index 4d28fefe..a590ea3f 100644 --- a/node/actors/sync_blocks/src/tests/mod.rs +++ b/node/actors/sync_blocks/src/tests/mod.rs @@ -1,18 +1,18 @@ //! Tests for the block syncing actor. - use super::*; -use zksync_concurrency::{oneshot, time}; -use zksync_consensus_network::io::{GetBlockError, GetBlockResponse, SyncBlocksRequest}; use rand::{ distributions::{Distribution, Standard}, Rng, }; +use std::iter; +use zksync_concurrency as concurrency; +use zksync_concurrency::{oneshot, time}; +use zksync_consensus_network::io::{GetBlockError, GetBlockResponse, SyncBlocksRequest}; use zksync_consensus_roles::validator::{ self, testonly::{make_block, make_genesis_block}, BlockHeader, BlockNumber, CommitQC, FinalBlock, Payload, ValidatorSet, }; -use std::iter; use zksync_consensus_storage::InMemoryStorage; use zksync_consensus_utils::pipe; diff --git a/node/libs/crypto/benches/bench.rs b/node/libs/crypto/benches/bench.rs index 63386bc6..bc47f648 100644 --- a/node/libs/crypto/benches/bench.rs +++ b/node/libs/crypto/benches/bench.rs @@ -1,8 +1,6 @@ #![allow(clippy::missing_docs_in_private_items)] #![allow(missing_docs)] -extern crate crypto; - use criterion::{criterion_group, criterion_main, Criterion}; use rand::Rng; use std::iter::repeat_with; diff --git a/node/libs/crypto/src/bn254/tests.rs b/node/libs/crypto/src/bn254/tests.rs index 933b914b..d07afbfa 100644 --- a/node/libs/crypto/src/bn254/tests.rs +++ b/node/libs/crypto/src/bn254/tests.rs @@ -1,8 +1,6 @@ -use std::iter::repeat_with; - -use rand::{rngs::StdRng, Rng, SeedableRng}; - use crate::bn254::{AggregateSignature, PublicKey, SecretKey, Signature}; +use rand::{rngs::StdRng, Rng, SeedableRng}; +use std::iter::repeat_with; #[test] fn signature_smoke() { diff --git a/node/libs/roles/src/node/conv.rs b/node/libs/roles/src/node/conv.rs index 876b607d..52924ec6 100644 --- a/node/libs/roles/src/node/conv.rs +++ b/node/libs/roles/src/node/conv.rs @@ -1,7 +1,7 @@ use crate::node; -use zksync_consensus_schema::{read_required, required, ProtoFmt}; use anyhow::Context as _; use zksync_consensus_crypto::ByteFmt; +use zksync_consensus_schema::{read_required, required, ProtoFmt}; use zksync_consensus_utils::enum_util::Variant; impl ProtoFmt for node::Msg { diff --git a/node/libs/roles/src/node/keys.rs b/node/libs/roles/src/node/keys.rs index 924caefd..0d8447a8 100644 --- a/node/libs/roles/src/node/keys.rs +++ b/node/libs/roles/src/node/keys.rs @@ -3,9 +3,9 @@ //! Each node must have a different key. use super::{Msg, MsgHash, Signed}; -use zksync_consensus_crypto::{ed25519, ByteFmt, Text, TextFmt}; pub use ed25519::InvalidSignatureError; use std::{fmt, sync::Arc}; +use zksync_consensus_crypto::{ed25519, ByteFmt, Text, TextFmt}; use zksync_consensus_utils::enum_util::Variant; /// A node's secret key. diff --git a/node/libs/roles/src/node/messages.rs b/node/libs/roles/src/node/messages.rs index 664518ee..9c87f025 100644 --- a/node/libs/roles/src/node/messages.rs +++ b/node/libs/roles/src/node/messages.rs @@ -1,7 +1,7 @@ use crate::node; use zksync_consensus_crypto::{sha256, ByteFmt, Text, TextFmt}; -use zksync_consensus_utils::enum_util::{BadVariantError, Variant}; use zksync_consensus_schema as schema; +use zksync_consensus_utils::enum_util::{BadVariantError, Variant}; /// The ID for an authentication session. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/node/libs/roles/src/node/tests.rs b/node/libs/roles/src/node/tests.rs index 4dc61ff7..2d208796 100644 --- a/node/libs/roles/src/node/tests.rs +++ b/node/libs/roles/src/node/tests.rs @@ -1,8 +1,8 @@ use super::*; -use ::schema::testonly::{test_encode, test_encode_random}; +use rand::Rng; use zksync_concurrency::ctx; use zksync_consensus_crypto::{ByteFmt, Text, TextFmt}; -use rand::Rng; +use zksync_consensus_schema::testonly::{test_encode, test_encode_random}; #[test] fn test_byte_encoding() { diff --git a/node/libs/roles/src/validator/conv.rs b/node/libs/roles/src/validator/conv.rs index d7ddde31..69d5d179 100644 --- a/node/libs/roles/src/validator/conv.rs +++ b/node/libs/roles/src/validator/conv.rs @@ -5,13 +5,14 @@ use super::{ Signers, ViewNumber, }; use crate::node::SessionId; -use zksync_consensus_schema::{read_required, required, ProtoFmt}; use anyhow::Context as _; -use zksync_consensus_crypto::ByteFmt; -use zksync_consensus_schema::proto::roles::validator as proto; use std::collections::BTreeMap; -use zksync_consensus_utils::enum_util::Variant; +use zksync_consensus_crypto::ByteFmt; use zksync_consensus_schema as schema; +use zksync_consensus_schema::{ + proto::roles::validator as proto, read_required, required, ProtoFmt, +}; +use zksync_consensus_utils::enum_util::Variant; impl ProtoFmt for BlockHeaderHash { type Proto = proto::BlockHeaderHash; diff --git a/node/libs/roles/src/validator/keys/aggregate_signature.rs b/node/libs/roles/src/validator/keys/aggregate_signature.rs index ef10d72d..49e9cd62 100644 --- a/node/libs/roles/src/validator/keys/aggregate_signature.rs +++ b/node/libs/roles/src/validator/keys/aggregate_signature.rs @@ -1,7 +1,7 @@ use super::{Error, PublicKey, Signature}; use crate::validator::messages::{Msg, MsgHash}; -use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use std::fmt; +use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use zksync_consensus_utils::enum_util::Variant; /// An aggregate signature from a validator. diff --git a/node/libs/roles/src/validator/keys/public_key.rs b/node/libs/roles/src/validator/keys/public_key.rs index 2759057d..3eb086b9 100644 --- a/node/libs/roles/src/validator/keys/public_key.rs +++ b/node/libs/roles/src/validator/keys/public_key.rs @@ -1,5 +1,5 @@ -use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use std::fmt; +use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; /// A public key for a validator. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/node/libs/roles/src/validator/keys/secret_key.rs b/node/libs/roles/src/validator/keys/secret_key.rs index 5bee8826..f5126cbf 100644 --- a/node/libs/roles/src/validator/keys/secret_key.rs +++ b/node/libs/roles/src/validator/keys/secret_key.rs @@ -1,8 +1,8 @@ use super::{PublicKey, Signature}; use crate::validator::messages::{Msg, MsgHash, Signed}; -use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use rand::Rng; use std::{fmt, sync::Arc}; +use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use zksync_consensus_utils::enum_util::Variant; /// A secret key for the validator role. diff --git a/node/libs/roles/src/validator/keys/signature.rs b/node/libs/roles/src/validator/keys/signature.rs index 00f22989..7b05733f 100644 --- a/node/libs/roles/src/validator/keys/signature.rs +++ b/node/libs/roles/src/validator/keys/signature.rs @@ -1,7 +1,7 @@ use super::{Error, PublicKey}; use crate::validator::messages::{Msg, MsgHash}; -use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use std::fmt; +use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; /// A signature from a validator. #[derive(Clone, PartialEq, Eq)] diff --git a/node/libs/roles/src/validator/messages/block.rs b/node/libs/roles/src/validator/messages/block.rs index cac64e1c..48da8567 100644 --- a/node/libs/roles/src/validator/messages/block.rs +++ b/node/libs/roles/src/validator/messages/block.rs @@ -1,8 +1,8 @@ //! Messages related to blocks. use super::CommitQC; -use zksync_consensus_crypto::{sha256, ByteFmt, Text, TextFmt}; use std::fmt; +use zksync_consensus_crypto::{sha256, ByteFmt, Text, TextFmt}; use zksync_consensus_schema as schema; /// Payload of the block. Consensus algorithm does not interpret the payload diff --git a/node/libs/roles/src/validator/messages/discovery.rs b/node/libs/roles/src/validator/messages/discovery.rs index ffc7fa7f..ec8ea26c 100644 --- a/node/libs/roles/src/validator/messages/discovery.rs +++ b/node/libs/roles/src/validator/messages/discovery.rs @@ -1,5 +1,5 @@ -use zksync_concurrency::time; use std::net; +use zksync_concurrency::time; /// A message broadcasted by a validator /// over the gossip network announcing diff --git a/node/libs/roles/src/validator/messages/msg.rs b/node/libs/roles/src/validator/messages/msg.rs index 48621122..c740e9ed 100644 --- a/node/libs/roles/src/validator/messages/msg.rs +++ b/node/libs/roles/src/validator/messages/msg.rs @@ -1,10 +1,10 @@ //! Generic message types. use super::{ConsensusMsg, NetAddress}; use crate::{node::SessionId, validator, validator::Error}; -use zksync_consensus_crypto::{sha256, ByteFmt, Text, TextFmt}; use std::fmt; -use zksync_consensus_utils::enum_util::{BadVariantError, Variant}; +use zksync_consensus_crypto::{sha256, ByteFmt, Text, TextFmt}; use zksync_consensus_schema as schema; +use zksync_consensus_utils::enum_util::{BadVariantError, Variant}; /// Generic message type for a validator. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/node/libs/roles/src/validator/testonly.rs b/node/libs/roles/src/validator/testonly.rs index 4777131c..6952cc46 100644 --- a/node/libs/roles/src/validator/testonly.rs +++ b/node/libs/roles/src/validator/testonly.rs @@ -6,12 +6,12 @@ use super::{ Signed, Signers, ValidatorSet, ViewNumber, CURRENT_VERSION, }; use bit_vec::BitVec; -use zksync_concurrency::time; use rand::{ distributions::{Distribution, Standard}, Rng, }; use std::sync::Arc; +use zksync_concurrency::time; use zksync_consensus_utils::enum_util::Variant; /// Constructs a CommitQC with `CommitQC.message.proposal` matching header. diff --git a/node/libs/roles/src/validator/tests.rs b/node/libs/roles/src/validator/tests.rs index 946d1eee..8030afbf 100644 --- a/node/libs/roles/src/validator/tests.rs +++ b/node/libs/roles/src/validator/tests.rs @@ -1,9 +1,9 @@ use super::*; -use ::schema::testonly::test_encode_random; -use zksync_concurrency::ctx; -use zksync_consensus_crypto::{ByteFmt, Text, TextFmt}; use rand::Rng; use std::vec; +use zksync_concurrency::ctx; +use zksync_consensus_crypto::{ByteFmt, Text, TextFmt}; +use zksync_consensus_schema::testonly::test_encode_random; #[test] fn test_byte_encoding() { diff --git a/node/libs/schema/src/bin/conformance_test.rs b/node/libs/schema/src/bin/conformance_test.rs index 6d102f69..38b9d1bb 100644 --- a/node/libs/schema/src/bin/conformance_test.rs +++ b/node/libs/schema/src/bin/conformance_test.rs @@ -6,9 +6,9 @@ //! subset of original fields. Also we run only proto3 binary -> binary tests. //! conformance_test_failure_list.txt contains tests which are expected to fail. use anyhow::Context as _; -use zksync_concurrency::{ctx, io}; use prost::Message as _; use prost_reflect::ReflectMessage; +use zksync_concurrency::{ctx, io}; use zksync_consensus_schema as schema; use zksync_consensus_schema::proto::conformance as proto; diff --git a/node/libs/schema/src/std_conv.rs b/node/libs/schema/src/std_conv.rs index 8f403f8b..264969b5 100644 --- a/node/libs/schema/src/std_conv.rs +++ b/node/libs/schema/src/std_conv.rs @@ -1,8 +1,8 @@ //! Proto conversion for messages in std package. use crate::{proto::std as proto, required, ProtoFmt}; use anyhow::Context as _; -use zksync_concurrency::time; use std::net; +use zksync_concurrency::time; impl ProtoFmt for () { type Proto = proto::Void; diff --git a/node/libs/schema/src/tests.rs b/node/libs/schema/src/tests.rs index 36cfe0b9..ddd49783 100644 --- a/node/libs/schema/src/tests.rs +++ b/node/libs/schema/src/tests.rs @@ -1,7 +1,7 @@ use super::*; use anyhow::Context as _; -use zksync_concurrency::{ctx, time}; use std::net; +use zksync_concurrency::{ctx, time}; #[derive(Debug, PartialEq, Eq)] enum B { diff --git a/node/libs/storage/src/in_memory.rs b/node/libs/storage/src/in_memory.rs index 09fe32b5..9c81e123 100644 --- a/node/libs/storage/src/in_memory.rs +++ b/node/libs/storage/src/in_memory.rs @@ -6,12 +6,12 @@ use crate::{ StorageResult, }; use async_trait::async_trait; +use std::{collections::BTreeMap, ops}; use zksync_concurrency::{ ctx, sync::{self, watch, Mutex}, }; use zksync_consensus_roles::validator::{BlockNumber, FinalBlock}; -use std::{collections::BTreeMap, ops}; #[derive(Debug)] struct BlocksInMemoryStore { diff --git a/node/libs/storage/src/replica_state.rs b/node/libs/storage/src/replica_state.rs index f27e00f7..e10dc547 100644 --- a/node/libs/storage/src/replica_state.rs +++ b/node/libs/storage/src/replica_state.rs @@ -4,9 +4,9 @@ use crate::{ traits::{BlockStore, ReplicaStateStore}, types::{ReplicaState, StorageResult}, }; +use std::sync::Arc; use zksync_concurrency::ctx; use zksync_consensus_roles::validator; -use std::sync::Arc; impl From for ReplicaState { fn from(certificate: validator::CommitQC) -> Self { diff --git a/node/libs/storage/src/rocksdb.rs b/node/libs/storage/src/rocksdb.rs index 1936fb40..1a2ebe7b 100644 --- a/node/libs/storage/src/rocksdb.rs +++ b/node/libs/storage/src/rocksdb.rs @@ -9,10 +9,7 @@ use crate::{ }; use anyhow::Context as _; use async_trait::async_trait; -use zksync_concurrency::{ctx, scope, sync::watch}; use rocksdb::{Direction, IteratorMode, ReadOptions}; -use zksync_consensus_roles::validator::{BlockNumber, FinalBlock}; -use zksync_consensus_schema as schema; use std::{ fmt, ops, path::Path, @@ -21,6 +18,9 @@ use std::{ RwLock, }, }; +use zksync_concurrency::{ctx, scope, sync::watch}; +use zksync_consensus_roles::validator::{BlockNumber, FinalBlock}; +use zksync_consensus_schema as schema; /// Enum used to represent a key in the database. It also acts as a separator between different stores. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/node/libs/storage/src/tests/mod.rs b/node/libs/storage/src/tests/mod.rs index 23c25830..8cd28276 100644 --- a/node/libs/storage/src/tests/mod.rs +++ b/node/libs/storage/src/tests/mod.rs @@ -1,10 +1,13 @@ use super::*; use crate::types::ReplicaState; use async_trait::async_trait; -use zksync_concurrency::ctx; use rand::{seq::SliceRandom, Rng}; -use zksync_consensus_roles::validator::{testonly::make_block, BlockHeader, BlockNumber, FinalBlock, Payload}; use std::iter; +use zksync_concurrency::ctx; +use zksync_consensus_roles::validator::{ + testonly::make_block, BlockHeader, BlockNumber, FinalBlock, Payload, +}; +use zksync_consensus_schema as schema; #[cfg(feature = "rocksdb")] mod rocksdb; diff --git a/node/libs/storage/src/traits.rs b/node/libs/storage/src/traits.rs index c1b281bf..b53f6d4c 100644 --- a/node/libs/storage/src/traits.rs +++ b/node/libs/storage/src/traits.rs @@ -1,9 +1,9 @@ //! Traits for storage. use crate::{types::ReplicaState, StorageResult}; use async_trait::async_trait; +use std::{fmt, ops, sync::Arc}; use zksync_concurrency::{ctx, sync::watch}; use zksync_consensus_roles::validator::{BlockNumber, FinalBlock}; -use std::{fmt, ops, sync::Arc}; /// Storage of L2 blocks. /// diff --git a/node/libs/storage/src/types.rs b/node/libs/storage/src/types.rs index f5f15886..0217a4de 100644 --- a/node/libs/storage/src/types.rs +++ b/node/libs/storage/src/types.rs @@ -1,9 +1,9 @@ //! Defines the schema of the database. use anyhow::Context as _; +use std::{iter, ops}; use zksync_concurrency::ctx; use zksync_consensus_roles::validator::{self, BlockNumber}; use zksync_consensus_schema::{proto::storage as proto, read_required, required, ProtoFmt}; -use std::{iter, ops}; /// A payload of a proposed block which is not known to be finalized yet. /// Replicas have to persist such proposed payloads for liveness: diff --git a/node/libs/utils/src/pipe.rs b/node/libs/utils/src/pipe.rs index 18e0745d..e8db302c 100644 --- a/node/libs/utils/src/pipe.rs +++ b/node/libs/utils/src/pipe.rs @@ -1,8 +1,8 @@ //! This is a wrapper around channels to make it simpler and less error-prone to connect actors and the dispatcher. //! A Pipe is a basically a bi-directional unbounded channel. -use zksync_concurrency::ctx::{self, channel, Ctx}; use std::future::Future; +use zksync_concurrency::ctx::{self, channel, Ctx}; /// This is the end of the Pipe that should be held by the actor. pub type ActorPipe = Pipe; diff --git a/node/tools/src/bin/keys.rs b/node/tools/src/bin/keys.rs index 06de9d89..2f2a0bfd 100644 --- a/node/tools/src/bin/keys.rs +++ b/node/tools/src/bin/keys.rs @@ -1,8 +1,8 @@ //! This tool generates a validator key pair and prints it to stdout. #![allow(clippy::print_stdout)] -use zksync_consensus_roles::validator; use zksync_consensus_crypto as crypto; +use zksync_consensus_roles::validator; /// This tool generates a validator key pair and prints it to stdout. fn main() { diff --git a/node/tools/src/bin/localnet_config.rs b/node/tools/src/bin/localnet_config.rs index 2212370a..c867a512 100644 --- a/node/tools/src/bin/localnet_config.rs +++ b/node/tools/src/bin/localnet_config.rs @@ -1,14 +1,14 @@ //! This tool constructs collection of node configs for running tests. use anyhow::Context as _; use clap::Parser; +use rand::Rng; +use std::{fs, net::SocketAddr, path::PathBuf}; use zksync_consensus_consensus::testonly; use zksync_consensus_crypto::TextFmt; use zksync_consensus_executor::{ConsensusConfig, ExecutorConfig, GossipConfig}; -use rand::Rng; use zksync_consensus_roles::{node, validator}; -use std::{fs, net::SocketAddr, path::PathBuf}; -use zksync_consensus_tools::NodeConfig; use zksync_consensus_schema as schema; +use zksync_consensus_tools::NodeConfig; /// Replaces IP of the address with UNSPECIFIED (aka INADDR_ANY) of the corresponding IP type. /// Opening a listener socket with an UNSPECIFIED IP, means that the new connections diff --git a/node/tools/src/config.rs b/node/tools/src/config.rs index bfc7b70c..be7b4421 100644 --- a/node/tools/src/config.rs +++ b/node/tools/src/config.rs @@ -1,11 +1,13 @@ //! Node configuration. use anyhow::Context as _; +use std::{fs, net, path::Path}; use zksync_consensus_crypto::{read_optional_text, Text, TextFmt}; use zksync_consensus_executor::{ConsensusConfig, ExecutorConfig}; use zksync_consensus_roles::{node, validator}; -use zksync_consensus_schema::{proto::executor::config as proto, read_optional, read_required, ProtoFmt}; use zksync_consensus_schema as schema; -use std::{fs, net, path::Path}; +use zksync_consensus_schema::{ + proto::executor::config as proto, read_optional, read_required, ProtoFmt, +}; /// This struct holds the file path to each of the config files. #[derive(Debug)] diff --git a/node/tools/src/main.rs b/node/tools/src/main.rs index 1d6606fa..b781a248 100644 --- a/node/tools/src/main.rs +++ b/node/tools/src/main.rs @@ -2,23 +2,23 @@ //! manages communication between the actors. It is the main executable in this workspace. use anyhow::Context as _; use clap::Parser; -use zksync_concurrency::{ - ctx::{self, channel}, - scope, time, -}; -use zksync_consensus_executor::Executor; use std::{ fs, io::IsTerminal as _, path::{Path, PathBuf}, sync::Arc, }; -use zksync_consensus_storage::{BlockStore, RocksdbStorage}; -use zksync_consensus_tools::{ConfigPaths, Configs}; use tracing::metadata::LevelFilter; use tracing_subscriber::{prelude::*, Registry}; -use zksync_consensus_utils::no_copy::NoCopy; use vise_exporter::MetricsExporter; +use zksync_concurrency::{ + ctx::{self, channel}, + scope, time, +}; +use zksync_consensus_executor::Executor; +use zksync_consensus_storage::{BlockStore, RocksdbStorage}; +use zksync_consensus_tools::{ConfigPaths, Configs}; +use zksync_consensus_utils::no_copy::NoCopy; /// Command-line application launching a node executor. #[derive(Debug, Parser)]