From 15da463a1e7aa16ce83e74b70e214047f604e371 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Mon, 6 Nov 2023 11:46:20 +0100 Subject: [PATCH 1/7] snapshot --- node/Cargo.lock | 412 +++++++++--------- node/Cargo.toml | 14 +- node/actors/consensus/Cargo.toml | 19 +- node/actors/consensus/src/inner.rs | 5 +- node/actors/consensus/src/io.rs | 4 +- .../consensus/src/leader/replica_commit.rs | 6 +- .../consensus/src/leader/replica_prepare.rs | 6 +- .../consensus/src/leader/state_machine.rs | 4 +- node/actors/consensus/src/leader/tests.rs | 4 +- node/actors/consensus/src/lib.rs | 8 +- node/actors/consensus/src/metrics.rs | 1 + node/actors/consensus/src/replica/block.rs | 2 +- .../consensus/src/replica/leader_commit.rs | 4 +- .../consensus/src/replica/leader_prepare.rs | 6 +- node/actors/consensus/src/replica/new_view.rs | 6 +- .../consensus/src/replica/state_machine.rs | 7 +- node/actors/consensus/src/replica/tests.rs | 6 +- node/actors/consensus/src/replica/timer.rs | 2 +- node/actors/consensus/src/testonly/fuzz.rs | 2 +- node/actors/consensus/src/testonly/make.rs | 8 +- node/actors/consensus/src/testonly/mod.rs | 4 +- node/actors/consensus/src/testonly/node.rs | 8 +- node/actors/consensus/src/testonly/run.rs | 10 +- node/actors/consensus/src/tests.rs | 2 +- node/actors/executor/Cargo.toml | 23 +- node/actors/executor/src/config/mod.rs | 8 +- node/actors/executor/src/config/tests.rs | 6 +- node/actors/executor/src/io.rs | 12 +- node/actors/executor/src/lib.rs | 15 +- node/actors/executor/src/tests.rs | 10 +- node/actors/network/Cargo.toml | 14 +- .../network/src/consensus/handshake/mod.rs | 8 +- .../src/consensus/handshake/testonly.rs | 2 +- .../network/src/consensus/handshake/tests.rs | 4 +- node/actors/network/src/consensus/runner.rs | 4 +- node/actors/network/src/consensus/state.rs | 2 +- node/actors/network/src/consensus/tests.rs | 6 +- node/actors/network/src/event.rs | 2 +- node/actors/network/src/frame.rs | 3 +- .../network/src/gossip/handshake/mod.rs | 8 +- .../network/src/gossip/handshake/testonly.rs | 2 +- .../network/src/gossip/handshake/tests.rs | 4 +- node/actors/network/src/gossip/runner.rs | 4 +- node/actors/network/src/gossip/state.rs | 4 +- node/actors/network/src/gossip/tests.rs | 6 +- node/actors/network/src/io.rs | 4 +- node/actors/network/src/metrics.rs | 2 +- node/actors/network/src/mux/config.rs | 2 +- node/actors/network/src/mux/handshake.rs | 3 +- node/actors/network/src/mux/mod.rs | 2 +- .../actors/network/src/mux/reusable_stream.rs | 2 +- node/actors/network/src/mux/tests.rs | 6 +- .../network/src/mux/transient_stream.rs | 2 +- node/actors/network/src/noise/stream.rs | 4 +- node/actors/network/src/noise/testonly.rs | 2 +- node/actors/network/src/noise/tests.rs | 2 +- node/actors/network/src/pool.rs | 2 +- node/actors/network/src/preface.rs | 5 +- node/actors/network/src/rpc/consensus.rs | 7 +- node/actors/network/src/rpc/metrics.rs | 1 + node/actors/network/src/rpc/mod.rs | 3 +- node/actors/network/src/rpc/ping.rs | 5 +- node/actors/network/src/rpc/sync_blocks.rs | 7 +- .../network/src/rpc/sync_validator_addrs.rs | 8 +- node/actors/network/src/rpc/testonly.rs | 2 +- node/actors/network/src/rpc/tests.rs | 2 +- node/actors/network/src/state.rs | 6 +- node/actors/network/src/testonly.rs | 4 +- node/actors/network/src/tests.rs | 4 +- node/actors/network/src/watch.rs | 2 +- node/actors/sync_blocks/Cargo.toml | 15 +- node/actors/sync_blocks/src/config.rs | 4 +- node/actors/sync_blocks/src/io.rs | 2 +- node/actors/sync_blocks/src/lib.rs | 8 +- .../actors/sync_blocks/src/message_handler.rs | 8 +- node/actors/sync_blocks/src/peers/events.rs | 2 +- node/actors/sync_blocks/src/peers/mod.rs | 8 +- node/actors/sync_blocks/src/peers/tests.rs | 6 +- .../sync_blocks/src/tests/end_to_end.rs | 8 +- node/actors/sync_blocks/src/tests/mod.rs | 10 +- node/libs/concurrency/Cargo.toml | 2 +- node/libs/crypto/Cargo.toml | 2 +- node/libs/crypto/benches/bench.rs | 4 +- node/libs/roles/Cargo.toml | 12 +- node/libs/roles/src/node/conv.rs | 6 +- node/libs/roles/src/node/keys.rs | 4 +- node/libs/roles/src/node/messages.rs | 5 +- node/libs/roles/src/node/mod.rs | 2 +- node/libs/roles/src/node/testonly.rs | 2 +- node/libs/roles/src/node/tests.rs | 4 +- node/libs/roles/src/validator/conv.rs | 9 +- .../src/validator/keys/aggregate_signature.rs | 4 +- node/libs/roles/src/validator/keys/mod.rs | 2 +- .../roles/src/validator/keys/public_key.rs | 2 +- .../roles/src/validator/keys/secret_key.rs | 4 +- .../roles/src/validator/keys/signature.rs | 2 +- .../roles/src/validator/messages/block.rs | 7 +- .../roles/src/validator/messages/consensus.rs | 2 +- .../roles/src/validator/messages/discovery.rs | 2 +- node/libs/roles/src/validator/messages/msg.rs | 6 +- node/libs/roles/src/validator/testonly.rs | 4 +- node/libs/roles/src/validator/tests.rs | 4 +- node/libs/schema/Cargo.toml | 6 +- node/libs/schema/src/bin/conformance_test.rs | 7 +- node/libs/schema/src/std_conv.rs | 2 +- node/libs/schema/src/tests.rs | 2 +- node/libs/storage/Cargo.toml | 10 +- node/libs/storage/src/in_memory.rs | 4 +- node/libs/storage/src/replica_state.rs | 4 +- node/libs/storage/src/rocksdb.rs | 6 +- node/libs/storage/src/tests/mod.rs | 4 +- node/libs/storage/src/traits.rs | 5 +- node/libs/storage/src/types.rs | 7 +- node/libs/utils/Cargo.toml | 5 +- node/libs/utils/src/pipe.rs | 2 +- node/tools/Cargo.toml | 21 +- node/tools/src/bin/keys.rs | 3 +- node/tools/src/bin/localnet_config.rs | 11 +- node/tools/src/config.rs | 10 +- node/tools/src/main.rs | 11 +- 120 files changed, 547 insertions(+), 521 deletions(-) diff --git a/node/Cargo.lock b/node/Cargo.lock index bbd75b91..ad547be2 100644 --- a/node/Cargo.lock +++ b/node/Cargo.lock @@ -558,43 +558,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "concurrency" -version = "0.1.0" -dependencies = [ - "anyhow", - "once_cell", - "pin-project", - "rand", - "sha2", - "thiserror", - "time", - "tokio", - "tracing", - "tracing-subscriber", - "vise", -] - -[[package]] -name = "consensus" -version = "0.1.0" -dependencies = [ - "anyhow", - "concurrency", - "crypto", - "network", - "once_cell", - "rand", - "roles", - "schema", - "storage", - "thiserror", - "tokio", - "tracing", - "utils", - "vise", -] - [[package]] name = "const-oid" version = "0.9.5" @@ -679,25 +642,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crypto" -version = "0.1.0" -dependencies = [ - "anyhow", - "ark-bn254", - "ark-ec", - "ark-serialize", - "blst", - "criterion", - "ed25519-dalek", - "hex", - "num-traits", - "rand", - "sha2", - "thiserror", - "tracing", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -856,26 +800,6 @@ dependencies = [ "libc", ] -[[package]] -name = "executor" -version = "0.1.0" -dependencies = [ - "anyhow", - "concurrency", - "consensus", - "crypto", - "network", - "rand", - "roles", - "schema", - "storage", - "sync_blocks", - "tokio", - "tracing", - "utils", - "vise", -] - [[package]] name = "fastrand" version = "2.0.0" @@ -1359,31 +1283,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" -[[package]] -name = "network" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-trait", - "concurrency", - "crypto", - "futures", - "im", - "once_cell", - "pin-project", - "pretty_assertions", - "rand", - "roles", - "schema", - "snow", - "test-casing", - "thiserror", - "tokio", - "tracing", - "utils", - "vise", -] - [[package]] name = "nom" version = "7.1.3" @@ -1984,22 +1883,6 @@ dependencies = [ "librocksdb-sys", ] -[[package]] -name = "roles" -version = "0.1.0" -dependencies = [ - "anyhow", - "bit-vec", - "concurrency", - "crypto", - "hex", - "rand", - "schema", - "serde", - "tracing", - "utils", -] - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2049,28 +1932,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schema" -version = "0.1.0" -dependencies = [ - "anyhow", - "bit-vec", - "concurrency", - "once_cell", - "prettyplease 0.2.12", - "prost", - "prost-build", - "prost-reflect", - "prost-reflect-build", - "protoc-bin-vendored", - "quick-protobuf", - "rand", - "serde", - "serde_json", - "syn 2.0.32", - "tokio", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -2242,25 +2103,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "storage" -version = "0.1.0" -dependencies = [ - "anyhow", - "assert_matches", - "async-trait", - "concurrency", - "rand", - "rocksdb", - "roles", - "schema", - "tempfile", - "test-casing", - "thiserror", - "tokio", - "tracing", -] - [[package]] name = "strsim" version = "0.10.0" @@ -2295,25 +2137,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_blocks" -version = "0.1.0" -dependencies = [ - "anyhow", - "assert_matches", - "async-trait", - "concurrency", - "network", - "rand", - "roles", - "storage", - "test-casing", - "thiserror", - "tokio", - "tracing", - "utils", -] - [[package]] name = "tempfile" version = "3.7.1" @@ -2443,27 +2266,6 @@ dependencies = [ "syn 2.0.32", ] -[[package]] -name = "tools" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "concurrency", - "consensus", - "crypto", - "executor", - "rand", - "roles", - "schema", - "storage", - "tokio", - "tracing", - "tracing-subscriber", - "utils", - "vise-exporter", -] - [[package]] name = "tower-service" version = "0.3.2" @@ -2566,14 +2368,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "utils" -version = "0.1.0" -dependencies = [ - "concurrency", - "thiserror", -] - [[package]] name = "valuable" version = "0.1.0" @@ -2869,6 +2663,212 @@ dependencies = [ "syn 2.0.32", ] +[[package]] +name = "zksync_concurrency" +version = "0.1.0" +dependencies = [ + "anyhow", + "once_cell", + "pin-project", + "rand", + "sha2", + "thiserror", + "time", + "tokio", + "tracing", + "tracing-subscriber", + "vise", +] + +[[package]] +name = "zksync_consensus_consensus" +version = "0.1.0" +dependencies = [ + "anyhow", + "once_cell", + "rand", + "thiserror", + "tokio", + "tracing", + "vise", + "zksync_concurrency", + "zksync_consensus_crypto", + "zksync_consensus_network", + "zksync_consensus_roles", + "zksync_consensus_schema", + "zksync_consensus_storage", + "zksync_consensus_utils", +] + +[[package]] +name = "zksync_consensus_crypto" +version = "0.1.0" +dependencies = [ + "anyhow", + "ark-bn254", + "ark-ec", + "ark-serialize", + "blst", + "criterion", + "ed25519-dalek", + "hex", + "num-traits", + "rand", + "sha2", + "thiserror", + "tracing", +] + +[[package]] +name = "zksync_consensus_executor" +version = "0.1.0" +dependencies = [ + "anyhow", + "rand", + "tokio", + "tracing", + "vise", + "zksync_concurrency", + "zksync_consensus_consensus", + "zksync_consensus_crypto", + "zksync_consensus_network", + "zksync_consensus_roles", + "zksync_consensus_schema", + "zksync_consensus_storage", + "zksync_consensus_sync_blocks", + "zksync_consensus_utils", +] + +[[package]] +name = "zksync_consensus_network" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "futures", + "im", + "once_cell", + "pin-project", + "pretty_assertions", + "rand", + "snow", + "test-casing", + "thiserror", + "tokio", + "tracing", + "vise", + "zksync_concurrency", + "zksync_consensus_crypto", + "zksync_consensus_roles", + "zksync_consensus_schema", + "zksync_consensus_utils", +] + +[[package]] +name = "zksync_consensus_roles" +version = "0.1.0" +dependencies = [ + "anyhow", + "bit-vec", + "hex", + "rand", + "serde", + "tracing", + "zksync_concurrency", + "zksync_consensus_crypto", + "zksync_consensus_schema", + "zksync_consensus_utils", +] + +[[package]] +name = "zksync_consensus_schema" +version = "0.1.0" +dependencies = [ + "anyhow", + "bit-vec", + "once_cell", + "prettyplease 0.2.12", + "prost", + "prost-build", + "prost-reflect", + "prost-reflect-build", + "protoc-bin-vendored", + "quick-protobuf", + "rand", + "serde", + "serde_json", + "syn 2.0.32", + "tokio", + "zksync_concurrency", +] + +[[package]] +name = "zksync_consensus_storage" +version = "0.1.0" +dependencies = [ + "anyhow", + "assert_matches", + "async-trait", + "rand", + "rocksdb", + "tempfile", + "test-casing", + "thiserror", + "tokio", + "tracing", + "zksync_concurrency", + "zksync_consensus_roles", + "zksync_consensus_schema", +] + +[[package]] +name = "zksync_consensus_sync_blocks" +version = "0.1.0" +dependencies = [ + "anyhow", + "assert_matches", + "async-trait", + "rand", + "test-casing", + "thiserror", + "tokio", + "tracing", + "zksync_concurrency", + "zksync_consensus_network", + "zksync_consensus_roles", + "zksync_consensus_storage", + "zksync_consensus_utils", +] + +[[package]] +name = "zksync_consensus_tools" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "rand", + "tokio", + "tracing", + "tracing-subscriber", + "vise-exporter", + "zksync_concurrency", + "zksync_consensus_consensus", + "zksync_consensus_crypto", + "zksync_consensus_executor", + "zksync_consensus_roles", + "zksync_consensus_schema", + "zksync_consensus_storage", + "zksync_consensus_utils", +] + +[[package]] +name = "zksync_consensus_utils" +version = "0.1.0" +dependencies = [ + "thiserror", + "zksync_concurrency", +] + [[package]] name = "zstd-sys" version = "2.0.8+zstd.1.5.5" diff --git a/node/Cargo.toml b/node/Cargo.toml index b22a7fb6..c1842e6d 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -21,6 +21,18 @@ homepage = "https://matter-labs.io/" license = "MIT" [workspace.dependencies] +zksync_concurrency = { path = "libs/concurrency" } +zksync_consensus_consensus = { path = "actors/consensus" } +zksync_consensus_crypto = { path = "libs/crypto" } +zksync_consensus_executor = { path = "actors/executor" } +zksync_consensus_network = { path = "actors/network" } +zksync_consensus_sync_blocks = { path = "actors/sync_blocks" } +zksync_consensus_roles = { path = "libs/roles" } +zksync_consensus_schema = { path = "libs/schema" } +zksync_consensus_storage = { path = "libs/storage" } +zksync_consensus_tools = { path = "tools" } +zksync_consensus_utils = { path = "libs/utils" } + anyhow = "1" assert_matches = "1.5.0" async-trait = "0.1.71" @@ -80,7 +92,7 @@ panic = 'abort' [profile.release] panic = 'abort' -[profile.dev.package.crypto] +[profile.dev.package.zksync_consensus_crypto] opt-level = 3 # Compile all the external dependencies with optimizations, because diff --git a/node/actors/consensus/Cargo.toml b/node/actors/consensus/Cargo.toml index b47c0d4f..ccefe4e0 100644 --- a/node/actors/consensus/Cargo.toml +++ b/node/actors/consensus/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "consensus" +name = "zksync_consensus_consensus" version = "0.1.0" edition.workspace = true authors.workspace = true @@ -7,6 +7,14 @@ homepage.workspace = true license.workspace = true [dependencies] +zksync_concurrency.workspace = true +zksync_consensus_crypto.workspace = true +zksync_consensus_network.workspace = true +zksync_consensus_roles.workspace = true +zksync_consensus_schema.workspace = true +zksync_consensus_storage.workspace = true +zksync_consensus_utils.workspace = true + anyhow.workspace = true once_cell.workspace = true rand.workspace = true @@ -14,14 +22,5 @@ thiserror.workspace = true tracing.workspace = true vise.workspace = true -concurrency = { path = "../../libs/concurrency" } -crypto = { path = "../../libs/crypto" } -roles = { path = "../../libs/roles" } -schema = { path = "../../libs/schema" } -storage = { path = "../../libs/storage" } -utils = { path = "../../libs/utils" } - -network = { path = "../network" } - [dev-dependencies] tokio.workspace = true diff --git a/node/actors/consensus/src/inner.rs b/node/actors/consensus/src/inner.rs index 57acc7a5..a52e5d95 100644 --- a/node/actors/consensus/src/inner.rs +++ b/node/actors/consensus/src/inner.rs @@ -4,9 +4,10 @@ use crate::{ io::{InputMessage, OutputMessage}, misc, }; -use roles::validator; +use zksync_consensus_roles::validator; use tracing::instrument; -use utils::pipe::ActorPipe; +use zksync_consensus_utils::pipe::ActorPipe; +use zksync_consensus_schema as schema; /// 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/io.rs b/node/actors/consensus/src/io.rs index 775920b0..3636e051 100644 --- a/node/actors/consensus/src/io.rs +++ b/node/actors/consensus/src/io.rs @@ -1,7 +1,7 @@ //! Input and output messages for the Consensus actor. These are processed by the executor actor. -use network::io::{ConsensusInputMessage, ConsensusReq}; -use roles::validator; +use zksync_consensus_network::io::{ConsensusInputMessage, ConsensusReq}; +use zksync_consensus_roles::validator; /// All the messages that other actors can send to the Consensus actor. #[derive(Debug)] diff --git a/node/actors/consensus/src/leader/replica_commit.rs b/node/actors/consensus/src/leader/replica_commit.rs index dd676f8c..feb2dd52 100644 --- a/node/actors/consensus/src/leader/replica_commit.rs +++ b/node/actors/consensus/src/leader/replica_commit.rs @@ -1,8 +1,8 @@ use super::StateMachine; use crate::{inner::ConsensusInner, metrics}; -use concurrency::{ctx, metrics::LatencyHistogramExt as _}; -use network::io::{ConsensusInputMessage, Target}; -use roles::validator; +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. diff --git a/node/actors/consensus/src/leader/replica_prepare.rs b/node/actors/consensus/src/leader/replica_prepare.rs index 275f31f8..4f7a5b73 100644 --- a/node/actors/consensus/src/leader/replica_prepare.rs +++ b/node/actors/consensus/src/leader/replica_prepare.rs @@ -1,9 +1,9 @@ use super::StateMachine; use crate::{inner::ConsensusInner, metrics}; -use concurrency::ctx; -use network::io::{ConsensusInputMessage, Target}; +use zksync_concurrency::ctx; +use zksync_consensus_network::io::{ConsensusInputMessage, Target}; use rand::Rng; -use roles::validator; +use zksync_consensus_roles::validator; use std::collections::HashMap; use tracing::instrument; diff --git a/node/actors/consensus/src/leader/state_machine.rs b/node/actors/consensus/src/leader/state_machine.rs index a92ed26f..9a847164 100644 --- a/node/actors/consensus/src/leader/state_machine.rs +++ b/node/actors/consensus/src/leader/state_machine.rs @@ -1,6 +1,6 @@ use crate::{metrics, ConsensusInner}; -use concurrency::{ctx, metrics::LatencyHistogramExt as _, time}; -use roles::validator; +use zksync_concurrency::{ctx, metrics::LatencyHistogramExt as _, time}; +use zksync_consensus_roles::validator; use std::{ collections::{BTreeMap, HashMap}, unreachable, diff --git a/node/actors/consensus/src/leader/tests.rs b/node/actors/consensus/src/leader/tests.rs index 2010b08f..c5a5e145 100644 --- a/node/actors/consensus/src/leader/tests.rs +++ b/node/actors/consensus/src/leader/tests.rs @@ -1,7 +1,7 @@ use crate::testonly; -use concurrency::ctx; +use zksync_concurrency::ctx; use rand::{rngs::StdRng, Rng, SeedableRng}; -use roles::validator; +use zksync_consensus_roles::validator; // TODO(bruno): This only tests a particular case, not the whole method. #[tokio::test] diff --git a/node/actors/consensus/src/lib.rs b/node/actors/consensus/src/lib.rs index db5c02c5..5b25c5e8 100644 --- a/node/actors/consensus/src/lib.rs +++ b/node/actors/consensus/src/lib.rs @@ -17,12 +17,12 @@ use crate::io::{InputMessage, OutputMessage}; use anyhow::Context as _; -use concurrency::ctx; +use zksync_concurrency::ctx; use inner::ConsensusInner; -use roles::validator; -use storage::FallbackReplicaStateStore; +use zksync_consensus_roles::validator; +use zksync_consensus_storage::FallbackReplicaStateStore; use tracing::{info, instrument}; -use utils::pipe::ActorPipe; +use zksync_consensus_utils::pipe::ActorPipe; mod inner; pub mod io; diff --git a/node/actors/consensus/src/metrics.rs b/node/actors/consensus/src/metrics.rs index 46d61dfb..461403f7 100644 --- a/node/actors/consensus/src/metrics.rs +++ b/node/actors/consensus/src/metrics.rs @@ -2,6 +2,7 @@ use std::time::Duration; use vise::{Buckets, EncodeLabelSet, EncodeLabelValue, Family, Gauge, Histogram, Metrics, Unit}; +use zksync_consensus_schema as schema; const PAYLOAD_SIZE_BUCKETS: Buckets = Buckets::exponential((4 * schema::kB) as f64..=(4 * schema::MB) as f64, 4.0); diff --git a/node/actors/consensus/src/replica/block.rs b/node/actors/consensus/src/replica/block.rs index 5591bf4b..f2aa8dd1 100644 --- a/node/actors/consensus/src/replica/block.rs +++ b/node/actors/consensus/src/replica/block.rs @@ -1,6 +1,6 @@ use super::StateMachine; use crate::{inner::ConsensusInner, io::OutputMessage}; -use roles::validator; +use zksync_consensus_roles::validator; use tracing::{info, instrument}; impl StateMachine { diff --git a/node/actors/consensus/src/replica/leader_commit.rs b/node/actors/consensus/src/replica/leader_commit.rs index f5bcd1da..3ff7dc38 100644 --- a/node/actors/consensus/src/replica/leader_commit.rs +++ b/node/actors/consensus/src/replica/leader_commit.rs @@ -1,8 +1,8 @@ use super::StateMachine; use crate::inner::ConsensusInner; use anyhow::Context as _; -use concurrency::ctx; -use roles::validator; +use zksync_concurrency::ctx; +use zksync_consensus_roles::validator; use tracing::instrument; /// Errors that can occur when processing a "leader commit" message. diff --git a/node/actors/consensus/src/replica/leader_prepare.rs b/node/actors/consensus/src/replica/leader_prepare.rs index 74501136..601d22b5 100644 --- a/node/actors/consensus/src/replica/leader_prepare.rs +++ b/node/actors/consensus/src/replica/leader_prepare.rs @@ -1,9 +1,9 @@ use super::StateMachine; use crate::inner::ConsensusInner; use anyhow::Context as _; -use concurrency::ctx; -use network::io::{ConsensusInputMessage, Target}; -use roles::validator; +use zksync_concurrency::ctx; +use zksync_consensus_network::io::{ConsensusInputMessage, Target}; +use zksync_consensus_roles::validator; use std::collections::HashMap; use tracing::instrument; diff --git a/node/actors/consensus/src/replica/new_view.rs b/node/actors/consensus/src/replica/new_view.rs index 078fe488..bc19c915 100644 --- a/node/actors/consensus/src/replica/new_view.rs +++ b/node/actors/consensus/src/replica/new_view.rs @@ -1,9 +1,9 @@ use super::StateMachine; use crate::ConsensusInner; use anyhow::Context as _; -use concurrency::ctx; -use network::io::{ConsensusInputMessage, Target}; -use roles::validator; +use zksync_concurrency::ctx; +use zksync_consensus_network::io::{ConsensusInputMessage, Target}; +use zksync_consensus_roles::validator; use tracing::instrument; impl StateMachine { diff --git a/node/actors/consensus/src/replica/state_machine.rs b/node/actors/consensus/src/replica/state_machine.rs index ecc846ce..c20de207 100644 --- a/node/actors/consensus/src/replica/state_machine.rs +++ b/node/actors/consensus/src/replica/state_machine.rs @@ -1,10 +1,11 @@ use crate::{metrics, ConsensusInner}; use anyhow::Context as _; -use concurrency::{ctx, metrics::LatencyHistogramExt as _, scope, time}; -use roles::validator; +use zksync_concurrency::{ctx, metrics::LatencyHistogramExt as _, scope, time}; +use zksync_consensus_roles::validator; use std::collections::{BTreeMap, HashMap}; -use storage::{FallbackReplicaStateStore, StorageError}; +use zksync_consensus_storage::{FallbackReplicaStateStore, StorageError}; use tracing::instrument; +use zksync_consensus_storage as storage; /// 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 09fd17b7..732daf75 100644 --- a/node/actors/consensus/src/replica/tests.rs +++ b/node/actors/consensus/src/replica/tests.rs @@ -1,8 +1,8 @@ use crate::testonly; -use concurrency::{ctx, scope, time}; -use network::io::{ConsensusInputMessage, Target}; +use zksync_concurrency::{ctx, scope, time}; +use zksync_consensus_network::io::{ConsensusInputMessage, Target}; use rand::Rng; -use roles::validator::{self, ViewNumber}; +use zksync_consensus_roles::validator::{self, ViewNumber}; #[tokio::test] async fn start_new_view_not_leader() { diff --git a/node/actors/consensus/src/replica/timer.rs b/node/actors/consensus/src/replica/timer.rs index 4df7b7da..5bb4c98b 100644 --- a/node/actors/consensus/src/replica/timer.rs +++ b/node/actors/consensus/src/replica/timer.rs @@ -1,6 +1,6 @@ use super::StateMachine; use crate::metrics; -use concurrency::{ctx, metrics::LatencyGaugeExt as _, time}; +use zksync_concurrency::{ctx, metrics::LatencyGaugeExt as _, time}; use tracing::instrument; impl StateMachine { diff --git a/node/actors/consensus/src/testonly/fuzz.rs b/node/actors/consensus/src/testonly/fuzz.rs index e4b95c78..ce6c155c 100644 --- a/node/actors/consensus/src/testonly/fuzz.rs +++ b/node/actors/consensus/src/testonly/fuzz.rs @@ -1,5 +1,5 @@ use rand::{seq::SliceRandom, Rng}; -use roles::validator; +use zksync_consensus_roles::validator; /// Trait that allows us to mutate types. It's an approach to fuzzing that instead of starting with completely random inputs /// (which will basically always fail on the first check), starts from a real valid message and modifies a single value to diff --git a/node/actors/consensus/src/testonly/make.rs b/node/actors/consensus/src/testonly/make.rs index f13fb425..aad0b239 100644 --- a/node/actors/consensus/src/testonly/make.rs +++ b/node/actors/consensus/src/testonly/make.rs @@ -4,11 +4,11 @@ use crate::{ io::{InputMessage, OutputMessage}, Consensus, }; -use concurrency::ctx; -use roles::validator; +use zksync_concurrency::ctx; +use zksync_consensus_roles::validator; use std::sync::Arc; -use storage::{FallbackReplicaStateStore, InMemoryStorage}; -use utils::pipe::{self, DispatcherPipe}; +use zksync_consensus_storage::{FallbackReplicaStateStore, InMemoryStorage}; +use zksync_consensus_utils::pipe::{self, DispatcherPipe}; /// This creates a mock Consensus struct for unit tests. pub async fn make_consensus( diff --git a/node/actors/consensus/src/testonly/mod.rs b/node/actors/consensus/src/testonly/mod.rs index 6b47b7cb..496b3611 100644 --- a/node/actors/consensus/src/testonly/mod.rs +++ b/node/actors/consensus/src/testonly/mod.rs @@ -1,8 +1,8 @@ //! This module contains utilities that are only meant for testing purposes. use crate::io::InputMessage; -use concurrency::oneshot; -use network::io::ConsensusReq; +use zksync_concurrency::oneshot; +use zksync_consensus_network::io::ConsensusReq; use rand::{distributions::Standard, prelude::Distribution, Rng}; #[cfg(test)] diff --git a/node/actors/consensus/src/testonly/node.rs b/node/actors/consensus/src/testonly/node.rs index 6d93a7f8..a581089e 100644 --- a/node/actors/consensus/src/testonly/node.rs +++ b/node/actors/consensus/src/testonly/node.rs @@ -1,10 +1,10 @@ use super::Fuzz; use crate::io; -use concurrency::{ctx, ctx::channel, scope}; -use network::io::ConsensusInputMessage; +use zksync_concurrency::{ctx, ctx::channel, scope}; +use zksync_consensus_network::io::ConsensusInputMessage; use rand::Rng; -use roles::validator; -use utils::pipe::DispatcherPipe; +use zksync_consensus_roles::validator; +use zksync_consensus_utils::pipe::DispatcherPipe; /// A struct containing metrics information. Right now it's just a finalized block. #[derive(Debug)] diff --git a/node/actors/consensus/src/testonly/run.rs b/node/actors/consensus/src/testonly/run.rs index a5d09c7a..fc2ef02f 100644 --- a/node/actors/consensus/src/testonly/run.rs +++ b/node/actors/consensus/src/testonly/run.rs @@ -1,15 +1,15 @@ use super::{Behavior, Metrics, Node}; use crate::{testonly, Consensus}; use anyhow::Context; -use concurrency::{ctx, ctx::channel, oneshot, scope, signal}; -use roles::validator; +use zksync_concurrency::{ctx, ctx::channel, oneshot, scope, signal}; +use zksync_consensus_roles::validator; use std::{ collections::{HashMap, HashSet}, sync::Arc, }; -use storage::{FallbackReplicaStateStore, InMemoryStorage}; +use zksync_consensus_storage::{FallbackReplicaStateStore, InMemoryStorage}; use tracing::Instrument as _; -use utils::pipe; +use zksync_consensus_utils::pipe; #[derive(Clone, Copy)] pub(crate) enum Network { @@ -154,7 +154,7 @@ async fn run_nodes( for (_, recv) in network_recv { s.spawn(async { let mut recv = recv; - use network::io; + use zksync_consensus_network::io; while let Ok(io::InputMessage::Consensus(message)) = recv.recv(ctx).await { let msg = || { diff --git a/node/actors/consensus/src/tests.rs b/node/actors/consensus/src/tests.rs index 41723316..3e4b51fd 100644 --- a/node/actors/consensus/src/tests.rs +++ b/node/actors/consensus/src/tests.rs @@ -2,7 +2,7 @@ use crate::{ misc::consensus_threshold, testonly::{Behavior, Network, Test}, }; -use concurrency::ctx; +use zksync_concurrency::ctx; async fn run_test(behavior: Behavior, network: Network) { concurrency::testonly::abort_on_panic(); diff --git a/node/actors/executor/Cargo.toml b/node/actors/executor/Cargo.toml index 574cc456..9a2e3c90 100644 --- a/node/actors/executor/Cargo.toml +++ b/node/actors/executor/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "executor" +name = "zksync_consensus_executor" version = "0.1.0" edition.workspace = true authors.workspace = true @@ -7,21 +7,20 @@ homepage.workspace = true license.workspace = true [dependencies] +zksync_concurrency.workspace = true +zksync_consensus_consensus.workspace = true +zksync_consensus_crypto.workspace = true +zksync_consensus_network.workspace = true +zksync_consensus_roles.workspace = true +zksync_consensus_schema.workspace = true +zksync_consensus_storage.workspace = true +zksync_consensus_sync_blocks.workspace = true +zksync_consensus_utils.workspace = true + anyhow.workspace = true tracing.workspace = true vise.workspace = true -concurrency = { path = "../../libs/concurrency" } -crypto = { path = "../../libs/crypto" } -roles = { path = "../../libs/roles" } -schema = { path = "../../libs/schema" } -storage = { path = "../../libs/storage" } -utils = { path = "../../libs/utils" } - -consensus = { path = "../consensus" } -network = { path = "../network" } -sync_blocks = { path = "../sync_blocks" } - [dev-dependencies] rand.workspace = true tokio.workspace = true diff --git a/node/actors/executor/src/config/mod.rs b/node/actors/executor/src/config/mod.rs index 178728ac..f0c58339 100644 --- a/node/actors/executor/src/config/mod.rs +++ b/node/actors/executor/src/config/mod.rs @@ -1,10 +1,10 @@ //! Module to create the configuration for the consensus node. use anyhow::Context as _; -use crypto::{read_required_text, Text, TextFmt}; -use network::{consensus, gossip}; -use roles::{node, validator}; -use schema::{proto::executor::config as proto, read_required, required, ProtoFmt}; +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, diff --git a/node/actors/executor/src/config/tests.rs b/node/actors/executor/src/config/tests.rs index d296ea8a..47bbc8dd 100644 --- a/node/actors/executor/src/config/tests.rs +++ b/node/actors/executor/src/config/tests.rs @@ -1,11 +1,11 @@ use super::{ConsensusConfig, ExecutorConfig, GossipConfig}; -use concurrency::ctx; +use zksync_concurrency::ctx; use rand::{ distributions::{Distribution, Standard}, Rng, }; -use roles::{node, validator}; -use schema::testonly::test_encode_random; +use zksync_consensus_roles::{node, validator}; +use zksync_consensus_schema::testonly::test_encode_random; fn make_addr(rng: &mut R) -> std::net::SocketAddr { std::net::SocketAddr::new(std::net::IpAddr::from(rng.gen::<[u8; 16]>()), rng.gen()) diff --git a/node/actors/executor/src/io.rs b/node/actors/executor/src/io.rs index b659fec9..bd9a7df8 100644 --- a/node/actors/executor/src/io.rs +++ b/node/actors/executor/src/io.rs @@ -1,20 +1,20 @@ //! Module to manage the communication between actors. It simply converts and forwards messages from and to each different actor. use crate::metrics; -use concurrency::{ +use zksync_concurrency::{ ctx::{self, channel}, scope, }; -use consensus::io::{ +use zksync_consensus_consensus::io::{ InputMessage as ConsensusInputMessage, OutputMessage as ConsensusOutputMessage, }; -use network::io::{InputMessage as NetworkInputMessage, OutputMessage as NetworkOutputMessage}; -use roles::validator::FinalBlock; -use sync_blocks::io::{ +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 utils::pipe::DispatcherPipe; +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 /// a pair of channels for each actor. This of course allows us to send and receive messages to and from each actor. diff --git a/node/actors/executor/src/lib.rs b/node/actors/executor/src/lib.rs index 93e987de..2a679b91 100644 --- a/node/actors/executor/src/lib.rs +++ b/node/actors/executor/src/lib.rs @@ -2,13 +2,16 @@ use crate::io::Dispatcher; use anyhow::Context as _; -use concurrency::{ctx, ctx::channel, net, scope}; -use consensus::Consensus; -use roles::{node, validator, validator::FinalBlock}; +use zksync_concurrency::{ctx, ctx::channel, net, scope}; +use zksync_consensus_consensus::Consensus; +use zksync_consensus_roles::{node, validator, validator::FinalBlock}; use std::{mem, sync::Arc}; -use storage::{FallbackReplicaStateStore, ReplicaStateStore, WriteBlockStore}; -use sync_blocks::SyncBlocks; -use utils::pipe; +use zksync_consensus_storage::{FallbackReplicaStateStore, ReplicaStateStore, WriteBlockStore}; +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 ac335e8c..d0acaa8d 100644 --- a/node/actors/executor/src/tests.rs +++ b/node/actors/executor/src/tests.rs @@ -1,13 +1,13 @@ //! High-level tests for `Executor`. use super::*; -use concurrency::sync; -use consensus::testonly::make_genesis; -use network::testonly::Instance; +use zksync_concurrency::sync; +use zksync_consensus_consensus::testonly::make_genesis; +use zksync_consensus_network::testonly::Instance; use rand::Rng; -use roles::validator::{BlockNumber, Payload}; +use zksync_consensus_roles::validator::{BlockNumber, Payload}; use std::collections::HashMap; -use storage::{BlockStore, InMemoryStorage, StorageError}; +use zksync_consensus_storage::{BlockStore, InMemoryStorage, StorageError}; async fn run_executor(ctx: &ctx::Ctx, executor: Executor) -> anyhow::Result<()> { executor.run(ctx).await.or_else(|err| { diff --git a/node/actors/network/Cargo.toml b/node/actors/network/Cargo.toml index 7d24287a..5217aadb 100644 --- a/node/actors/network/Cargo.toml +++ b/node/actors/network/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "network" +name = "zksync_consensus_network" version = "0.1.0" edition.workspace = true authors.workspace = true @@ -7,6 +7,12 @@ homepage.workspace = true license.workspace = true [dependencies] +zksync_concurrency.workspace = true +zksync_consensus_crypto.workspace = true +zksync_consensus_roles.workspace = true +zksync_consensus_schema.workspace = true +zksync_consensus_utils.workspace = true + anyhow.workspace = true async-trait.workspace = true im.workspace = true @@ -18,12 +24,6 @@ thiserror.workspace = true tracing.workspace = true vise.workspace = true -concurrency = { path = "../../libs/concurrency" } -crypto = { path = "../../libs/crypto" } -roles = { path = "../../libs/roles" } -schema = { path = "../../libs/schema" } -utils = { path = "../../libs/utils" } - [dev-dependencies] futures.workspace = true pretty_assertions.workspace = true diff --git a/node/actors/network/src/consensus/handshake/mod.rs b/node/actors/network/src/consensus/handshake/mod.rs index 5d6d309f..fa304488 100644 --- a/node/actors/network/src/consensus/handshake/mod.rs +++ b/node/actors/network/src/consensus/handshake/mod.rs @@ -1,9 +1,9 @@ use crate::{frame, noise}; use anyhow::Context as _; -use concurrency::{ctx, time}; -use crypto::ByteFmt; -use roles::{node, validator}; -use schema::{proto::network::consensus as proto, read_required, ProtoFmt}; +use zksync_concurrency::{ctx, time}; +use zksync_consensus_crypto::ByteFmt; +use zksync_consensus_roles::{node, validator}; +use zksync_consensus_schema::{proto::network::consensus as proto, read_required, ProtoFmt}; #[cfg(test)] mod testonly; diff --git a/node/actors/network/src/consensus/handshake/testonly.rs b/node/actors/network/src/consensus/handshake/testonly.rs index 2b346bc6..d05848df 100644 --- a/node/actors/network/src/consensus/handshake/testonly.rs +++ b/node/actors/network/src/consensus/handshake/testonly.rs @@ -7,7 +7,7 @@ use rand::{ distributions::{Distribution, Standard}, Rng, }; -use roles::{node, validator}; +use zksync_consensus_roles::{node, validator}; impl Distribution for Standard { fn sample(&self, rng: &mut R) -> Handshake { diff --git a/node/actors/network/src/consensus/handshake/tests.rs b/node/actors/network/src/consensus/handshake/tests.rs index f4960826..a53e663d 100644 --- a/node/actors/network/src/consensus/handshake/tests.rs +++ b/node/actors/network/src/consensus/handshake/tests.rs @@ -1,8 +1,8 @@ use super::*; use crate::{frame, noise, testonly}; -use concurrency::{ctx, io, scope}; +use zksync_concurrency::{ctx, io, scope}; use rand::Rng; -use roles::validator; +use zksync_consensus_roles::validator; #[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 d6098fe9..6d114950 100644 --- a/node/actors/network/src/consensus/runner.rs +++ b/node/actors/network/src/consensus/runner.rs @@ -3,8 +3,8 @@ use super::handshake; use crate::{io, noise, preface, rpc, State}; use anyhow::Context as _; -use concurrency::{ctx, ctx::channel, oneshot, scope, sync, time}; -use roles::validator; +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. diff --git a/node/actors/network/src/consensus/state.rs b/node/actors/network/src/consensus/state.rs index 07c2c65b..a2571f3f 100644 --- a/node/actors/network/src/consensus/state.rs +++ b/node/actors/network/src/consensus/state.rs @@ -1,5 +1,5 @@ use crate::pool::PoolWatch; -use roles::{validator, validator::ValidatorSet}; +use zksync_consensus_roles::{validator, validator::ValidatorSet}; use std::collections::HashSet; /// Configuration of the consensus network. diff --git a/node/actors/network/src/consensus/tests.rs b/node/actors/network/src/consensus/tests.rs index faf83064..1e281417 100644 --- a/node/actors/network/src/consensus/tests.rs +++ b/node/actors/network/src/consensus/tests.rs @@ -1,11 +1,11 @@ use super::*; use crate::{io, preface, rpc, run_network, testonly}; use anyhow::Context as _; -use concurrency::{ctx, net, scope}; +use zksync_concurrency::{ctx, net, scope}; use rand::Rng; -use roles::validator; +use zksync_consensus_roles::validator; use tracing::Instrument as _; -use utils::pipe; +use zksync_consensus_utils::pipe; #[tokio::test] async fn test_one_connection_per_validator() { diff --git a/node/actors/network/src/event.rs b/node/actors/network/src/event.rs index 48a317a6..68d9ab6a 100644 --- a/node/actors/network/src/event.rs +++ b/node/actors/network/src/event.rs @@ -1,7 +1,7 @@ //! Mechanism for network State to report internal events. //! It is used in tests to await a specific state. use crate::State; -use roles::{node, validator}; +use zksync_consensus_roles::{node, validator}; impl State { /// Sends an event to the `self.events` channel. diff --git a/node/actors/network/src/frame.rs b/node/actors/network/src/frame.rs index d88fa8ef..f865be95 100644 --- a/node/actors/network/src/frame.rs +++ b/node/actors/network/src/frame.rs @@ -1,7 +1,8 @@ //! Simple frame encoding format (length ++ value) for protobuf messages, //! since protobuf messages do not have delimiters. use crate::{mux, noise::bytes}; -use concurrency::{ctx, io}; +use zksync_concurrency::{ctx, io}; +use zksync_consensus_schema as schema; /// Reads a raw frame of bytes from the stream and interprets it as proto. /// A `frame : [u8]` is encoded as `L ++ frame`, where `L` is diff --git a/node/actors/network/src/gossip/handshake/mod.rs b/node/actors/network/src/gossip/handshake/mod.rs index f8d8ba83..9114ac0d 100644 --- a/node/actors/network/src/gossip/handshake/mod.rs +++ b/node/actors/network/src/gossip/handshake/mod.rs @@ -1,10 +1,10 @@ use super::Config; use crate::{frame, noise}; use anyhow::Context as _; -use concurrency::{ctx, time}; -use crypto::ByteFmt; -use roles::node; -use schema::{proto::network::gossip as proto, read_required, required, ProtoFmt}; +use zksync_concurrency::{ctx, time}; +use zksync_consensus_crypto::ByteFmt; +use zksync_consensus_roles::node; +use zksync_consensus_schema::{proto::network::gossip as proto, read_required, required, ProtoFmt}; #[cfg(test)] mod testonly; diff --git a/node/actors/network/src/gossip/handshake/testonly.rs b/node/actors/network/src/gossip/handshake/testonly.rs index c11d4d39..d45531d2 100644 --- a/node/actors/network/src/gossip/handshake/testonly.rs +++ b/node/actors/network/src/gossip/handshake/testonly.rs @@ -7,7 +7,7 @@ use rand::{ distributions::{Distribution, Standard}, Rng, }; -use roles::node; +use zksync_consensus_roles::node; impl Distribution for Standard { fn sample(&self, rng: &mut R) -> Handshake { diff --git a/node/actors/network/src/gossip/handshake/tests.rs b/node/actors/network/src/gossip/handshake/tests.rs index 3807e3e4..949e2970 100644 --- a/node/actors/network/src/gossip/handshake/tests.rs +++ b/node/actors/network/src/gossip/handshake/tests.rs @@ -1,8 +1,8 @@ use super::*; use crate::{frame, noise, testonly}; -use concurrency::{ctx, io, scope}; +use zksync_concurrency::{ctx, io, scope}; use rand::Rng; -use roles::node; +use zksync_consensus_roles::node; use std::collections::{HashMap, HashSet}; #[test] diff --git a/node/actors/network/src/gossip/runner.rs b/node/actors/network/src/gossip/runner.rs index dcc79baf..bdbb4deb 100644 --- a/node/actors/network/src/gossip/runner.rs +++ b/node/actors/network/src/gossip/runner.rs @@ -6,13 +6,13 @@ use crate::{ }; use anyhow::Context; use async_trait::async_trait; -use concurrency::{ +use zksync_concurrency::{ ctx::{self, channel}, oneshot, scope, sync::{self, watch}, time, }; -use roles::{node, validator}; +use zksync_consensus_roles::{node, validator}; use std::sync::Arc; use tracing::Instrument as _; diff --git a/node/actors/network/src/gossip/state.rs b/node/actors/network/src/gossip/state.rs index 49bd4bb5..e185c02c 100644 --- a/node/actors/network/src/gossip/state.rs +++ b/node/actors/network/src/gossip/state.rs @@ -1,6 +1,6 @@ use crate::{io::SyncState, pool::PoolWatch, rpc, watch::Watch}; -use concurrency::sync::{self, watch, Mutex}; -use roles::{node, validator}; +use zksync_concurrency::sync::{self, watch, Mutex}; +use zksync_consensus_roles::{node, validator}; use std::{ collections::{HashMap, HashSet}, sync::Arc, diff --git a/node/actors/network/src/gossip/tests.rs b/node/actors/network/src/gossip/tests.rs index 77ad9f63..ffc11397 100644 --- a/node/actors/network/src/gossip/tests.rs +++ b/node/actors/network/src/gossip/tests.rs @@ -1,7 +1,7 @@ use super::*; use crate::{event::Event, io, preface, rpc, rpc::Rpc as _, run_network, testonly}; use anyhow::Context as _; -use concurrency::{ +use zksync_concurrency::{ ctx::{self, channel}, oneshot, scope, sync::{watch, Mutex}, @@ -9,14 +9,14 @@ use concurrency::{ }; use pretty_assertions::assert_eq; use rand::Rng; -use roles::validator::{self, BlockNumber, FinalBlock}; +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 utils::pipe; +use zksync_consensus_utils::pipe; #[tokio::test] async fn test_one_connection_per_node() { diff --git a/node/actors/network/src/io.rs b/node/actors/network/src/io.rs index ab0a4f36..1f7a3c7e 100644 --- a/node/actors/network/src/io.rs +++ b/node/actors/network/src/io.rs @@ -1,6 +1,6 @@ #![allow(missing_docs)] -use concurrency::oneshot; -use roles::{node, validator}; +use zksync_concurrency::oneshot; +use zksync_consensus_roles::{node, validator}; /// All the messages that other actors can send to the Network actor. #[derive(Debug)] diff --git a/node/actors/network/src/metrics.rs b/node/actors/network/src/metrics.rs index 77cda040..c5eff662 100644 --- a/node/actors/network/src/metrics.rs +++ b/node/actors/network/src/metrics.rs @@ -1,7 +1,7 @@ //! General-purpose network metrics. use crate::state::State; -use concurrency::{ctx, io, net}; +use zksync_concurrency::{ctx, io, net}; use std::{ net::SocketAddr, pin::Pin, diff --git a/node/actors/network/src/mux/config.rs b/node/actors/network/src/mux/config.rs index 88066f2d..62ef1e20 100644 --- a/node/actors/network/src/mux/config.rs +++ b/node/actors/network/src/mux/config.rs @@ -1,5 +1,5 @@ use super::StreamId; -use concurrency::sync; +use zksync_concurrency::sync; /// Maximal frame size. pub(crate) const MAX_FRAME_SIZE: u64 = u16::MAX as u64; diff --git a/node/actors/network/src/mux/handshake.rs b/node/actors/network/src/mux/handshake.rs index 08450864..0557c651 100644 --- a/node/actors/network/src/mux/handshake.rs +++ b/node/actors/network/src/mux/handshake.rs @@ -1,7 +1,8 @@ use super::CapabilityId; use anyhow::Context as _; -use schema::{proto::network::mux as proto, required}; +use zksync_consensus_schema::{proto::network::mux as proto, required}; use std::collections::HashMap; +use zksync_consensus_schema as schema; 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 472d61ba..6a836f6d 100644 --- a/node/actors/network/src/mux/mod.rs +++ b/node/actors/network/src/mux/mod.rs @@ -79,7 +79,7 @@ //! both sides of the connection can enforce. use crate::{frame, noise::bytes}; use anyhow::Context as _; -use concurrency::{ctx, ctx::channel, io, scope, sync}; +use zksync_concurrency::{ctx, ctx::channel, io, scope, sync}; use std::{collections::BTreeMap, sync::Arc}; mod config; diff --git a/node/actors/network/src/mux/reusable_stream.rs b/node/actors/network/src/mux/reusable_stream.rs index c196827e..9a23aea2 100644 --- a/node/actors/network/src/mux/reusable_stream.rs +++ b/node/actors/network/src/mux/reusable_stream.rs @@ -3,7 +3,7 @@ use super::{ Config, FrameKind, Header, ReadStream, RunError, Stream, StreamId, StreamKind, WriteStream, }; use crate::noise::bytes; -use concurrency::{ctx, ctx::channel, oneshot, scope, sync}; +use zksync_concurrency::{ctx, ctx::channel, oneshot, scope, sync}; use std::sync::Arc; /// Read frame allocation permit. diff --git a/node/actors/network/src/mux/tests.rs b/node/actors/network/src/mux/tests.rs index 83986a9c..86c166b0 100644 --- a/node/actors/network/src/mux/tests.rs +++ b/node/actors/network/src/mux/tests.rs @@ -1,8 +1,8 @@ use crate::{frame, mux, noise, noise::bytes}; use anyhow::Context as _; -use concurrency::{ctx, scope}; +use zksync_concurrency::{ctx, scope}; use rand::Rng as _; -use schema::proto::network::mux_test as proto; +use zksync_consensus_schema::proto::network::mux_test as proto; use std::{ collections::BTreeMap, sync::{ @@ -10,7 +10,7 @@ use std::{ Arc, }, }; -use utils::no_copy::NoCopy; +use zksync_consensus_utils::no_copy::NoCopy; fn assert_partition(sets: &[u16]) { let mut sum = 0; diff --git a/node/actors/network/src/mux/transient_stream.rs b/node/actors/network/src/mux/transient_stream.rs index 4fe33539..e4736f69 100644 --- a/node/actors/network/src/mux/transient_stream.rs +++ b/node/actors/network/src/mux/transient_stream.rs @@ -9,7 +9,7 @@ //! or convenience of use. use super::{FrameKind, ReadReusableStream, WriteReusableStream}; use crate::noise::bytes; -use concurrency::{ctx, sync}; +use zksync_concurrency::{ctx, sync}; /// Read half of the transient stream. #[derive(Debug)] diff --git a/node/actors/network/src/noise/stream.rs b/node/actors/network/src/noise/stream.rs index d3b97544..81a1c3be 100644 --- a/node/actors/network/src/noise/stream.rs +++ b/node/actors/network/src/noise/stream.rs @@ -1,11 +1,11 @@ //! `tokio::io` stream using Noise encryption. use super::bytes; use crate::metrics::MeteredStream; -use concurrency::{ +use zksync_concurrency::{ ctx, io, io::{AsyncRead as _, AsyncWrite as _}, }; -use crypto::{sha256::Sha256, ByteFmt}; +use zksync_consensus_crypto::{sha256::Sha256, ByteFmt}; use std::{ pin::Pin, task::{ready, Context, Poll}, diff --git a/node/actors/network/src/noise/testonly.rs b/node/actors/network/src/noise/testonly.rs index 9304c6d2..ea4856e9 100644 --- a/node/actors/network/src/noise/testonly.rs +++ b/node/actors/network/src/noise/testonly.rs @@ -1,5 +1,5 @@ use crate::{metrics, noise}; -use concurrency::{ctx, scope}; +use zksync_concurrency::{ctx, scope}; pub(crate) async fn pipe(ctx: &ctx::Ctx) -> (noise::Stream, noise::Stream) { scope::run!(ctx, |ctx, s| async { diff --git a/node/actors/network/src/noise/tests.rs b/node/actors/network/src/noise/tests.rs index 8ef5b71f..dffda0dd 100644 --- a/node/actors/network/src/noise/tests.rs +++ b/node/actors/network/src/noise/tests.rs @@ -1,5 +1,5 @@ use crate::noise; -use concurrency::{ctx, io, scope}; +use zksync_concurrency::{ctx, io, scope}; use rand::Rng; use tracing::instrument::Instrument as _; diff --git a/node/actors/network/src/pool.rs b/node/actors/network/src/pool.rs index d694c543..727cd4a8 100644 --- a/node/actors/network/src/pool.rs +++ b/node/actors/network/src/pool.rs @@ -1,7 +1,7 @@ //! An abstraction for a set of "connections" which constraints //! which peers are allowed to connect. use crate::watch::Watch; -use concurrency::sync; +use zksync_concurrency::sync; use std::collections::HashSet; /// Set of elements of type T. diff --git a/node/actors/network/src/preface.rs b/node/actors/network/src/preface.rs index 37542746..99232185 100644 --- a/node/actors/network/src/preface.rs +++ b/node/actors/network/src/preface.rs @@ -8,8 +8,9 @@ //! Hence, the preface protocol is used to enable encryption //! and multiplex between mutliple endpoints available on the same TCP port. use crate::{frame, metrics, noise}; -use concurrency::{ctx, time}; -use schema::{proto::network::preface as proto, required, ProtoFmt}; +use zksync_concurrency::{ctx, time}; +use zksync_consensus_schema::{proto::network::preface as proto, required, ProtoFmt}; +use zksync_consensus_schema as schema; /// 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 3df4e58e..43a9fa5a 100644 --- a/node/actors/network/src/rpc/consensus.rs +++ b/node/actors/network/src/rpc/consensus.rs @@ -1,8 +1,9 @@ //! Defines RPC for passing consensus messages. use crate::mux; -use concurrency::{limiter, time}; -use roles::validator; -use schema::{proto::network::consensus as proto, read_required, ProtoFmt}; +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; /// 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 a8770168..df0adab7 100644 --- a/node/actors/network/src/rpc/metrics.rs +++ b/node/actors/network/src/rpc/metrics.rs @@ -2,6 +2,7 @@ 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, diff --git a/node/actors/network/src/rpc/mod.rs b/node/actors/network/src/rpc/mod.rs index a4609016..5453f1ae 100644 --- a/node/actors/network/src/rpc/mod.rs +++ b/node/actors/network/src/rpc/mod.rs @@ -18,8 +18,9 @@ use self::metrics::{CallLatencyType, CallType, RPC_METRICS}; use crate::{frame, mux}; use anyhow::Context as _; -use concurrency::{ctx, io, limiter, metrics::LatencyHistogramExt as _, scope}; +use zksync_concurrency::{ctx, io, limiter, metrics::LatencyHistogramExt as _, scope}; use std::{collections::BTreeMap, sync::Arc}; +use zksync_consensus_schema as schema; pub(crate) mod consensus; mod metrics; diff --git a/node/actors/network/src/rpc/ping.rs b/node/actors/network/src/rpc/ping.rs index 5f95def5..fc54b125 100644 --- a/node/actors/network/src/rpc/ping.rs +++ b/node/actors/network/src/rpc/ping.rs @@ -1,9 +1,10 @@ //! Defines an RPC for sending ping messages. use crate::{mux, rpc::Rpc as _}; use anyhow::Context as _; -use concurrency::{ctx, limiter, time}; +use zksync_concurrency::{ctx, limiter, time}; use rand::Rng; -use schema::{proto::network::ping as proto, required, ProtoFmt}; +use zksync_consensus_schema::{proto::network::ping as proto, required, ProtoFmt}; +use zksync_consensus_schema as schema; /// 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 84fa071b..31443f5c 100644 --- a/node/actors/network/src/rpc/sync_blocks.rs +++ b/node/actors/network/src/rpc/sync_blocks.rs @@ -2,9 +2,10 @@ use crate::{io, mux}; use anyhow::Context; -use concurrency::{limiter, time}; -use roles::validator::{BlockNumber, FinalBlock}; -use schema::{proto::network::gossip as proto, read_required, ProtoFmt}; +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; /// `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 b1441355..579923e9 100644 --- a/node/actors/network/src/rpc/sync_validator_addrs.rs +++ b/node/actors/network/src/rpc/sync_validator_addrs.rs @@ -1,10 +1,10 @@ //! Defines an Rpc for synchronizing ValidatorAddrs data. - use crate::mux; use anyhow::Context as _; -use concurrency::{limiter, time}; -use roles::validator; -use schema::{proto::network::gossip as proto, ProtoFmt}; +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; /// SyncValidatorAddrs Rpc. diff --git a/node/actors/network/src/rpc/testonly.rs b/node/actors/network/src/rpc/testonly.rs index 972d380a..d176790e 100644 --- a/node/actors/network/src/rpc/testonly.rs +++ b/node/actors/network/src/rpc/testonly.rs @@ -7,7 +7,7 @@ use rand::{ distributions::{Distribution, Standard}, Rng, }; -use roles::validator; +use zksync_consensus_roles::validator; impl Distribution for Standard { fn sample(&self, rng: &mut R) -> consensus::Req { diff --git a/node/actors/network/src/rpc/tests.rs b/node/actors/network/src/rpc/tests.rs index 69f3e8e2..9c99f3f6 100644 --- a/node/actors/network/src/rpc/tests.rs +++ b/node/actors/network/src/rpc/tests.rs @@ -1,6 +1,6 @@ use super::*; use crate::noise; -use concurrency::{ctx, time}; +use zksync_concurrency::{ctx, time}; use rand::Rng as _; use std::{ collections::HashSet, diff --git a/node/actors/network/src/state.rs b/node/actors/network/src/state.rs index 4d6edbdc..0fa566a2 100644 --- a/node/actors/network/src/state.rs +++ b/node/actors/network/src/state.rs @@ -2,10 +2,10 @@ use super::{consensus, event::Event, gossip, metrics, preface}; use crate::io::{InputMessage, OutputMessage, SyncState}; use anyhow::Context as _; -use concurrency::{ctx, ctx::channel, net, scope, sync::watch}; -use roles::validator; +use zksync_concurrency::{ctx, ctx::channel, net, scope, sync::watch}; +use zksync_consensus_roles::validator; use std::sync::Arc; -use utils::pipe::ActorPipe; +use zksync_consensus_utils::pipe::ActorPipe; /// Network actor config. #[derive(Debug, Clone)] diff --git a/node/actors/network/src/testonly.rs b/node/actors/network/src/testonly.rs index fd047daf..065ec9d4 100644 --- a/node/actors/network/src/testonly.rs +++ b/node/actors/network/src/testonly.rs @@ -1,14 +1,14 @@ //! Testonly utilities. #![allow(dead_code)] use crate::{consensus, event::Event, gossip, io::SyncState, Config, State}; -use concurrency::{ +use zksync_concurrency::{ ctx, ctx::channel, io, net, sync::{self, watch}, }; use rand::Rng; -use roles::validator; +use zksync_consensus_roles::validator; use std::{ collections::{HashMap, HashSet}, sync::Arc, diff --git a/node/actors/network/src/tests.rs b/node/actors/network/src/tests.rs index fda4675c..5500c072 100644 --- a/node/actors/network/src/tests.rs +++ b/node/actors/network/src/tests.rs @@ -1,7 +1,7 @@ use crate::{run_network, testonly}; -use concurrency::{ctx, scope}; +use zksync_concurrency::{ctx, scope}; use tracing::Instrument as _; -use utils::pipe; +use zksync_consensus_utils::pipe; /// Test that metrics are correctly defined /// (won't panic during registration). diff --git a/node/actors/network/src/watch.rs b/node/actors/network/src/watch.rs index ef5a15ce..459d46d4 100644 --- a/node/actors/network/src/watch.rs +++ b/node/actors/network/src/watch.rs @@ -1,5 +1,5 @@ //! Wrapper of the tokio::sync::Watch for easier usage. -use concurrency::sync; +use zksync_concurrency::sync; /// Wrapper of the tokio::sync::Watch. pub(crate) struct Watch { diff --git a/node/actors/sync_blocks/Cargo.toml b/node/actors/sync_blocks/Cargo.toml index 646132d2..be4f696c 100644 --- a/node/actors/sync_blocks/Cargo.toml +++ b/node/actors/sync_blocks/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sync_blocks" +name = "zksync_consensus_sync_blocks" version = "0.1.0" edition.workspace = true authors.workspace = true @@ -7,17 +7,16 @@ homepage.workspace = true license.workspace = true [dependencies] +zksync_concurrency.workspace = true +zksync_consensus_network.workspace = true +zksync_consensus_roles.workspace = true +zksync_consensus_storage.workspace = true +zksync_consensus_utils.workspace = true + anyhow.workspace = true thiserror.workspace = true tracing.workspace = true -concurrency = { path = "../../libs/concurrency" } -roles = { path = "../../libs/roles" } -storage = { path = "../../libs/storage" } -utils = { path = "../../libs/utils" } - -network = { path = "../network" } - [dev-dependencies] assert_matches.workspace = true async-trait.workspace = true diff --git a/node/actors/sync_blocks/src/config.rs b/node/actors/sync_blocks/src/config.rs index a279a808..3bc44839 100644 --- a/node/actors/sync_blocks/src/config.rs +++ b/node/actors/sync_blocks/src/config.rs @@ -1,7 +1,7 @@ //! Configuration for the `SyncBlocks` actor. -use concurrency::time; -use roles::validator::ValidatorSet; +use zksync_concurrency::time; +use zksync_consensus_roles::validator::ValidatorSet; /// Configuration for the `SyncBlocks` actor. #[derive(Debug)] diff --git a/node/actors/sync_blocks/src/io.rs b/node/actors/sync_blocks/src/io.rs index 9a83494e..cb4a9225 100644 --- a/node/actors/sync_blocks/src/io.rs +++ b/node/actors/sync_blocks/src/io.rs @@ -1,6 +1,6 @@ //! Input and output messages for the [`SyncBlocks`](crate::SyncBlocks) actor. -use network::io::{SyncBlocksInputMessage, SyncBlocksRequest}; +use zksync_consensus_network::io::{SyncBlocksInputMessage, SyncBlocksRequest}; /// All the messages that other actors can send to the `SyncBlocks` actor. #[derive(Debug)] diff --git a/node/actors/sync_blocks/src/lib.rs b/node/actors/sync_blocks/src/lib.rs index a8028b51..5e255ed1 100644 --- a/node/actors/sync_blocks/src/lib.rs +++ b/node/actors/sync_blocks/src/lib.rs @@ -7,15 +7,15 @@ use crate::{ io::{InputMessage, OutputMessage}, message_handler::SyncBlocksMessageHandler, }; -use concurrency::{ +use zksync_concurrency::{ ctx, scope, sync::{self, watch}, }; -use network::io::SyncState; +use zksync_consensus_network::io::SyncState; use std::sync::Arc; -use storage::WriteBlockStore; +use zksync_consensus_storage::WriteBlockStore; use tracing::instrument; -use utils::pipe::ActorPipe; +use zksync_consensus_utils::pipe::ActorPipe; mod config; pub mod io; diff --git a/node/actors/sync_blocks/src/message_handler.rs b/node/actors/sync_blocks/src/message_handler.rs index e3779c54..abd2369c 100644 --- a/node/actors/sync_blocks/src/message_handler.rs +++ b/node/actors/sync_blocks/src/message_handler.rs @@ -1,11 +1,11 @@ //! Inner details of `SyncBlocks` actor. use crate::{io::InputMessage, peers::PeerStatesHandle}; -use concurrency::ctx::{self, channel}; -use network::io::{GetBlockError, GetBlockResponse, SyncBlocksRequest}; -use roles::validator::BlockNumber; +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 storage::WriteBlockStore; +use zksync_consensus_storage::WriteBlockStore; use tracing::instrument; /// Inner details of `SyncBlocks` actor allowing to process messages. diff --git a/node/actors/sync_blocks/src/peers/events.rs b/node/actors/sync_blocks/src/peers/events.rs index 97980d2a..186099be 100644 --- a/node/actors/sync_blocks/src/peers/events.rs +++ b/node/actors/sync_blocks/src/peers/events.rs @@ -1,6 +1,6 @@ //! Events emitted by `PeerStates` actor. Useful for testing. -use roles::{node, validator::BlockNumber}; +use zksync_consensus_roles::{node, validator::BlockNumber}; /// Events emitted by `PeerStates` actor. Only used for tests so far. #[derive(Debug)] diff --git a/node/actors/sync_blocks/src/peers/mod.rs b/node/actors/sync_blocks/src/peers/mod.rs index 4485a386..6c9f95d5 100644 --- a/node/actors/sync_blocks/src/peers/mod.rs +++ b/node/actors/sync_blocks/src/peers/mod.rs @@ -3,18 +3,18 @@ use self::events::PeerStateEvent; use crate::{io, Config}; use anyhow::Context as _; -use concurrency::{ +use zksync_concurrency::{ ctx::{self, channel}, oneshot, scope, sync::{self, watch, Mutex, Semaphore}, }; -use network::io::{SyncBlocksInputMessage, SyncState}; -use roles::{ +use zksync_consensus_network::io::{SyncBlocksInputMessage, SyncState}; +use zksync_consensus_roles::{ node, validator::{BlockHeader, BlockNumber, FinalBlock, PayloadHash}, }; use std::{collections::HashMap, sync::Arc}; -use storage::WriteBlockStore; +use zksync_consensus_storage::WriteBlockStore; use tracing::instrument; mod events; diff --git a/node/actors/sync_blocks/src/peers/tests.rs b/node/actors/sync_blocks/src/peers/tests.rs index 9dcf01ad..0387902a 100644 --- a/node/actors/sync_blocks/src/peers/tests.rs +++ b/node/actors/sync_blocks/src/peers/tests.rs @@ -2,11 +2,11 @@ use super::*; use crate::tests::TestValidators; use assert_matches::assert_matches; use async_trait::async_trait; -use concurrency::time; +use zksync_concurrency::time; use rand::{rngs::StdRng, seq::IteratorRandom, Rng}; -use roles::validator; +use zksync_consensus_roles::validator; use std::{collections::HashSet, fmt}; -use storage::{BlockStore, InMemoryStorage}; +use zksync_consensus_storage::{BlockStore, InMemoryStorage}; use test_casing::{test_casing, Product}; const TEST_TIMEOUT: time::Duration = time::Duration::seconds(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 7bb78b1f..629ba2f1 100644 --- a/node/actors/sync_blocks/src/tests/end_to_end.rs +++ b/node/actors/sync_blocks/src/tests/end_to_end.rs @@ -3,12 +3,12 @@ use super::*; use anyhow::Context as _; use async_trait::async_trait; -use concurrency::ctx::channel; -use network::testonly::Instance as NetworkInstance; +use zksync_concurrency::ctx::channel; +use zksync_consensus_network::testonly::Instance as NetworkInstance; use rand::seq::SliceRandom; -use roles::node; +use zksync_consensus_roles::node; use std::fmt; -use storage::InMemoryStorage; +use zksync_consensus_storage::InMemoryStorage; use test_casing::test_casing; use tracing::Instrument; diff --git a/node/actors/sync_blocks/src/tests/mod.rs b/node/actors/sync_blocks/src/tests/mod.rs index 9d361189..4d28fefe 100644 --- a/node/actors/sync_blocks/src/tests/mod.rs +++ b/node/actors/sync_blocks/src/tests/mod.rs @@ -1,20 +1,20 @@ //! Tests for the block syncing actor. use super::*; -use concurrency::{oneshot, time}; -use network::io::{GetBlockError, GetBlockResponse, SyncBlocksRequest}; +use zksync_concurrency::{oneshot, time}; +use zksync_consensus_network::io::{GetBlockError, GetBlockResponse, SyncBlocksRequest}; use rand::{ distributions::{Distribution, Standard}, Rng, }; -use roles::validator::{ +use zksync_consensus_roles::validator::{ self, testonly::{make_block, make_genesis_block}, BlockHeader, BlockNumber, CommitQC, FinalBlock, Payload, ValidatorSet, }; use std::iter; -use storage::InMemoryStorage; -use utils::pipe; +use zksync_consensus_storage::InMemoryStorage; +use zksync_consensus_utils::pipe; mod end_to_end; diff --git a/node/libs/concurrency/Cargo.toml b/node/libs/concurrency/Cargo.toml index 81e73352..7cfb3e9f 100644 --- a/node/libs/concurrency/Cargo.toml +++ b/node/libs/concurrency/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "concurrency" +name = "zksync_concurrency" version = "0.1.0" edition.workspace = true authors.workspace = true diff --git a/node/libs/crypto/Cargo.toml b/node/libs/crypto/Cargo.toml index 4b8f96f3..117dfae2 100644 --- a/node/libs/crypto/Cargo.toml +++ b/node/libs/crypto/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "crypto" +name = "zksync_consensus_crypto" version = "0.1.0" edition.workspace = true authors.workspace = true diff --git a/node/libs/crypto/benches/bench.rs b/node/libs/crypto/benches/bench.rs index 99d6c477..63386bc6 100644 --- a/node/libs/crypto/benches/bench.rs +++ b/node/libs/crypto/benches/bench.rs @@ -8,7 +8,7 @@ use rand::Rng; use std::iter::repeat_with; fn bench_bn254(c: &mut Criterion) { - use crypto::bn254::{AggregateSignature, PublicKey, SecretKey, Signature}; + use zksync_consensus_crypto::bn254::{AggregateSignature, PublicKey, SecretKey, Signature}; let mut rng = rand::thread_rng(); let mut group = c.benchmark_group("bn254"); group.bench_function("100 sig aggregation", |b| { @@ -27,7 +27,7 @@ fn bench_bn254(c: &mut Criterion) { #[allow(missing_docs)] fn bench_bls12_381(c: &mut Criterion) { - use crypto::bls12_381::{AggregateSignature, PublicKey, SecretKey, Signature}; + use zksync_consensus_crypto::bls12_381::{AggregateSignature, PublicKey, SecretKey, Signature}; let mut rng = rand::thread_rng(); let mut group = c.benchmark_group("bls12_381"); group.bench_function("100 sig aggregation", |b| { diff --git a/node/libs/roles/Cargo.toml b/node/libs/roles/Cargo.toml index d63b5eab..fdd1bb84 100644 --- a/node/libs/roles/Cargo.toml +++ b/node/libs/roles/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "roles" +name = "zksync_consensus_roles" version = "0.1.0" edition.workspace = true authors.workspace = true @@ -7,14 +7,14 @@ homepage.workspace = true license.workspace = true [dependencies] +zksync_concurrency.workspace = true +zksync_consensus_crypto.workspace = true +zksync_consensus_schema.workspace = true +zksync_consensus_utils.workspace = true + anyhow.workspace = true bit-vec.workspace = true hex.workspace = true rand.workspace = true serde.workspace = true tracing.workspace = true - -concurrency = { path = "../concurrency" } -crypto = { path = "../crypto" } -schema = { path = "../schema" } -utils = { path = "../utils" } diff --git a/node/libs/roles/src/node/conv.rs b/node/libs/roles/src/node/conv.rs index aad1edde..876b607d 100644 --- a/node/libs/roles/src/node/conv.rs +++ b/node/libs/roles/src/node/conv.rs @@ -1,8 +1,8 @@ use crate::node; -use ::schema::{read_required, required, ProtoFmt}; +use zksync_consensus_schema::{read_required, required, ProtoFmt}; use anyhow::Context as _; -use crypto::ByteFmt; -use utils::enum_util::Variant; +use zksync_consensus_crypto::ByteFmt; +use zksync_consensus_utils::enum_util::Variant; impl ProtoFmt for node::Msg { type Proto = node::schema::Msg; diff --git a/node/libs/roles/src/node/keys.rs b/node/libs/roles/src/node/keys.rs index ab58fa4d..924caefd 100644 --- a/node/libs/roles/src/node/keys.rs +++ b/node/libs/roles/src/node/keys.rs @@ -3,10 +3,10 @@ //! Each node must have a different key. use super::{Msg, MsgHash, Signed}; -use crypto::{ed25519, ByteFmt, Text, TextFmt}; +use zksync_consensus_crypto::{ed25519, ByteFmt, Text, TextFmt}; pub use ed25519::InvalidSignatureError; use std::{fmt, sync::Arc}; -use utils::enum_util::Variant; +use zksync_consensus_utils::enum_util::Variant; /// A node's secret key. #[derive(Clone)] diff --git a/node/libs/roles/src/node/messages.rs b/node/libs/roles/src/node/messages.rs index 18c815d5..664518ee 100644 --- a/node/libs/roles/src/node/messages.rs +++ b/node/libs/roles/src/node/messages.rs @@ -1,6 +1,7 @@ use crate::node; -use crypto::{sha256, ByteFmt, Text, TextFmt}; -use utils::enum_util::{BadVariantError, Variant}; +use zksync_consensus_crypto::{sha256, ByteFmt, Text, TextFmt}; +use zksync_consensus_utils::enum_util::{BadVariantError, Variant}; +use zksync_consensus_schema as schema; /// The ID for an authentication session. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/node/libs/roles/src/node/mod.rs b/node/libs/roles/src/node/mod.rs index a11eb6c9..e22bfd04 100644 --- a/node/libs/roles/src/node/mod.rs +++ b/node/libs/roles/src/node/mod.rs @@ -7,7 +7,7 @@ mod testonly; pub use keys::*; pub use messages::*; -pub use schema::proto::roles::node as schema; +pub use zksync_consensus_schema::proto::roles::node as schema; #[cfg(test)] mod tests; diff --git a/node/libs/roles/src/node/testonly.rs b/node/libs/roles/src/node/testonly.rs index f2798188..1d712ebb 100644 --- a/node/libs/roles/src/node/testonly.rs +++ b/node/libs/roles/src/node/testonly.rs @@ -4,7 +4,7 @@ use rand::{ Rng, }; use std::sync::Arc; -use utils::enum_util::Variant; +use zksync_consensus_utils::enum_util::Variant; impl Distribution for Standard { fn sample(&self, rng: &mut R) -> MsgHash { diff --git a/node/libs/roles/src/node/tests.rs b/node/libs/roles/src/node/tests.rs index b8cbfb4f..4dc61ff7 100644 --- a/node/libs/roles/src/node/tests.rs +++ b/node/libs/roles/src/node/tests.rs @@ -1,7 +1,7 @@ use super::*; use ::schema::testonly::{test_encode, test_encode_random}; -use concurrency::ctx; -use crypto::{ByteFmt, Text, TextFmt}; +use zksync_concurrency::ctx; +use zksync_consensus_crypto::{ByteFmt, Text, TextFmt}; use rand::Rng; #[test] diff --git a/node/libs/roles/src/validator/conv.rs b/node/libs/roles/src/validator/conv.rs index c96fc2f7..d7ddde31 100644 --- a/node/libs/roles/src/validator/conv.rs +++ b/node/libs/roles/src/validator/conv.rs @@ -5,12 +5,13 @@ use super::{ Signers, ViewNumber, }; use crate::node::SessionId; -use ::schema::{read_required, required, ProtoFmt}; +use zksync_consensus_schema::{read_required, required, ProtoFmt}; use anyhow::Context as _; -use crypto::ByteFmt; -use schema::proto::roles::validator as proto; +use zksync_consensus_crypto::ByteFmt; +use zksync_consensus_schema::proto::roles::validator as proto; use std::collections::BTreeMap; -use utils::enum_util::Variant; +use zksync_consensus_utils::enum_util::Variant; +use zksync_consensus_schema as schema; 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 7f1d6ee8..ef10d72d 100644 --- a/node/libs/roles/src/validator/keys/aggregate_signature.rs +++ b/node/libs/roles/src/validator/keys/aggregate_signature.rs @@ -1,8 +1,8 @@ use super::{Error, PublicKey, Signature}; use crate::validator::messages::{Msg, MsgHash}; -use crypto::{bn254, ByteFmt, Text, TextFmt}; +use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use std::fmt; -use utils::enum_util::Variant; +use zksync_consensus_utils::enum_util::Variant; /// An aggregate signature from a validator. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] diff --git a/node/libs/roles/src/validator/keys/mod.rs b/node/libs/roles/src/validator/keys/mod.rs index 77e23ff9..43069397 100644 --- a/node/libs/roles/src/validator/keys/mod.rs +++ b/node/libs/roles/src/validator/keys/mod.rs @@ -11,4 +11,4 @@ pub use secret_key::SecretKey; pub use signature::Signature; /// Error type returned by validator key operations. -pub type Error = crypto::bn254::Error; +pub type Error = zksync_consensus_crypto::bn254::Error; diff --git a/node/libs/roles/src/validator/keys/public_key.rs b/node/libs/roles/src/validator/keys/public_key.rs index 40f8edfc..2759057d 100644 --- a/node/libs/roles/src/validator/keys/public_key.rs +++ b/node/libs/roles/src/validator/keys/public_key.rs @@ -1,4 +1,4 @@ -use crypto::{bn254, ByteFmt, Text, TextFmt}; +use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use std::fmt; /// A public key for a validator. diff --git a/node/libs/roles/src/validator/keys/secret_key.rs b/node/libs/roles/src/validator/keys/secret_key.rs index 4029ea23..5bee8826 100644 --- a/node/libs/roles/src/validator/keys/secret_key.rs +++ b/node/libs/roles/src/validator/keys/secret_key.rs @@ -1,9 +1,9 @@ use super::{PublicKey, Signature}; use crate::validator::messages::{Msg, MsgHash, Signed}; -use crypto::{bn254, ByteFmt, Text, TextFmt}; +use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use rand::Rng; use std::{fmt, sync::Arc}; -use utils::enum_util::Variant; +use zksync_consensus_utils::enum_util::Variant; /// A secret key for the validator role. /// SecretKey is put into an Arc, so that we can clone it, diff --git a/node/libs/roles/src/validator/keys/signature.rs b/node/libs/roles/src/validator/keys/signature.rs index d35ec6d6..00f22989 100644 --- a/node/libs/roles/src/validator/keys/signature.rs +++ b/node/libs/roles/src/validator/keys/signature.rs @@ -1,6 +1,6 @@ use super::{Error, PublicKey}; use crate::validator::messages::{Msg, MsgHash}; -use crypto::{bn254, ByteFmt, Text, TextFmt}; +use zksync_consensus_crypto::{bn254, ByteFmt, Text, TextFmt}; use std::fmt; /// A signature from a validator. diff --git a/node/libs/roles/src/validator/messages/block.rs b/node/libs/roles/src/validator/messages/block.rs index 770361d3..cac64e1c 100644 --- a/node/libs/roles/src/validator/messages/block.rs +++ b/node/libs/roles/src/validator/messages/block.rs @@ -1,8 +1,9 @@ //! Messages related to blocks. use super::CommitQC; -use crypto::{sha256, ByteFmt, Text, TextFmt}; +use zksync_consensus_crypto::{sha256, ByteFmt, Text, TextFmt}; use std::fmt; +use zksync_consensus_schema as schema; /// Payload of the block. Consensus algorithm does not interpret the payload /// (except for imposing a size limit for the payload). Proposing a payload @@ -145,10 +146,10 @@ impl FinalBlock { impl ByteFmt for FinalBlock { fn decode(bytes: &[u8]) -> anyhow::Result { - ::schema::decode(bytes) + schema::decode(bytes) } fn encode(&self) -> Vec { - ::schema::encode(self) + schema::encode(self) } } diff --git a/node/libs/roles/src/validator/messages/consensus.rs b/node/libs/roles/src/validator/messages/consensus.rs index 743e12f0..a6603ddb 100644 --- a/node/libs/roles/src/validator/messages/consensus.rs +++ b/node/libs/roles/src/validator/messages/consensus.rs @@ -5,7 +5,7 @@ use crate::validator; use anyhow::{bail, Context}; use bit_vec::BitVec; use std::collections::{BTreeMap, BTreeSet, HashMap}; -use utils::enum_util::{BadVariantError, Variant}; +use zksync_consensus_utils::enum_util::{BadVariantError, Variant}; /// Version of the consensus algorithm that the validator is using. /// It allows to prevent misinterpretation of messages signed by validators diff --git a/node/libs/roles/src/validator/messages/discovery.rs b/node/libs/roles/src/validator/messages/discovery.rs index c70f67ab..ffc7fa7f 100644 --- a/node/libs/roles/src/validator/messages/discovery.rs +++ b/node/libs/roles/src/validator/messages/discovery.rs @@ -1,4 +1,4 @@ -use concurrency::time; +use zksync_concurrency::time; use std::net; /// A message broadcasted by a validator diff --git a/node/libs/roles/src/validator/messages/msg.rs b/node/libs/roles/src/validator/messages/msg.rs index ac0e3bf8..48621122 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 crypto::{sha256, ByteFmt, Text, TextFmt}; +use zksync_consensus_crypto::{sha256, ByteFmt, Text, TextFmt}; use std::fmt; -use utils::enum_util::{BadVariantError, Variant}; +use zksync_consensus_utils::enum_util::{BadVariantError, Variant}; +use zksync_consensus_schema as schema; /// 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 dad8d8e8..4777131c 100644 --- a/node/libs/roles/src/validator/testonly.rs +++ b/node/libs/roles/src/validator/testonly.rs @@ -6,13 +6,13 @@ use super::{ Signed, Signers, ValidatorSet, ViewNumber, CURRENT_VERSION, }; use bit_vec::BitVec; -use concurrency::time; +use zksync_concurrency::time; use rand::{ distributions::{Distribution, Standard}, Rng, }; use std::sync::Arc; -use utils::enum_util::Variant; +use zksync_consensus_utils::enum_util::Variant; /// Constructs a CommitQC with `CommitQC.message.proposal` matching header. /// WARNING: it is not a fully correct CommitQC. diff --git a/node/libs/roles/src/validator/tests.rs b/node/libs/roles/src/validator/tests.rs index 9309ea64..946d1eee 100644 --- a/node/libs/roles/src/validator/tests.rs +++ b/node/libs/roles/src/validator/tests.rs @@ -1,7 +1,7 @@ use super::*; use ::schema::testonly::test_encode_random; -use concurrency::ctx; -use crypto::{ByteFmt, Text, TextFmt}; +use zksync_concurrency::ctx; +use zksync_consensus_crypto::{ByteFmt, Text, TextFmt}; use rand::Rng; use std::vec; diff --git a/node/libs/schema/Cargo.toml b/node/libs/schema/Cargo.toml index ea9c6941..bdb3ac1c 100644 --- a/node/libs/schema/Cargo.toml +++ b/node/libs/schema/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "schema" +name = "zksync_consensus_schema" version = "0.1.0" edition.workspace = true authors.workspace = true @@ -10,6 +10,8 @@ license.workspace = true name = "conformance_test" [dependencies] +zksync_concurrency.workspace = true + anyhow.workspace = true bit-vec.workspace = true serde.workspace = true @@ -21,8 +23,6 @@ rand.workspace = true serde_json.workspace = true tokio.workspace = true -concurrency = { path = "../concurrency" } - [build-dependencies] anyhow.workspace = true syn.workspace = true diff --git a/node/libs/schema/src/bin/conformance_test.rs b/node/libs/schema/src/bin/conformance_test.rs index e6de4eaa..6d102f69 100644 --- a/node/libs/schema/src/bin/conformance_test.rs +++ b/node/libs/schema/src/bin/conformance_test.rs @@ -6,10 +6,11 @@ //! 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 concurrency::{ctx, io}; +use zksync_concurrency::{ctx, io}; use prost::Message as _; use prost_reflect::ReflectMessage; -use schema::proto::conformance as proto; +use zksync_consensus_schema as schema; +use zksync_consensus_schema::proto::conformance as proto; #[tokio::main] async fn main() -> anyhow::Result<()> { @@ -36,7 +37,7 @@ async fn main() -> anyhow::Result<()> { // Decode. let payload = req.payload.context("missing payload")?; - use schema::proto::protobuf_test_messages::proto3::TestAllTypesProto3 as T; + use zksync_consensus_schema::proto::protobuf_test_messages::proto3::TestAllTypesProto3 as T; let p = match payload { proto::conformance_request::Payload::JsonPayload(payload) => { match schema::decode_json_proto(&payload) { diff --git a/node/libs/schema/src/std_conv.rs b/node/libs/schema/src/std_conv.rs index 2f2fa89b..8f403f8b 100644 --- a/node/libs/schema/src/std_conv.rs +++ b/node/libs/schema/src/std_conv.rs @@ -1,7 +1,7 @@ //! Proto conversion for messages in std package. use crate::{proto::std as proto, required, ProtoFmt}; use anyhow::Context as _; -use concurrency::time; +use zksync_concurrency::time; use std::net; impl ProtoFmt for () { diff --git a/node/libs/schema/src/tests.rs b/node/libs/schema/src/tests.rs index d4d8366e..36cfe0b9 100644 --- a/node/libs/schema/src/tests.rs +++ b/node/libs/schema/src/tests.rs @@ -1,6 +1,6 @@ use super::*; use anyhow::Context as _; -use concurrency::{ctx, time}; +use zksync_concurrency::{ctx, time}; use std::net; #[derive(Debug, PartialEq, Eq)] diff --git a/node/libs/storage/Cargo.toml b/node/libs/storage/Cargo.toml index 9629ee2b..67b685e6 100644 --- a/node/libs/storage/Cargo.toml +++ b/node/libs/storage/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "storage" +name = "zksync_consensus_storage" version = "0.1.0" edition.workspace = true authors.workspace = true @@ -7,6 +7,10 @@ homepage.workspace = true license.workspace = true [dependencies] +zksync_concurrency.workspace = true +zksync_consensus_roles.workspace = true +zksync_consensus_schema.workspace = true + anyhow.workspace = true async-trait.workspace = true rand.workspace = true @@ -14,10 +18,6 @@ rocksdb = { workspace = true, optional = true } thiserror.workspace = true tracing.workspace = true -concurrency = { path = "../concurrency" } -roles = { path = "../roles" } -schema = { path = "../schema" } - [dev-dependencies] assert_matches.workspace = true tempfile.workspace = true diff --git a/node/libs/storage/src/in_memory.rs b/node/libs/storage/src/in_memory.rs index c4a45e7c..09fe32b5 100644 --- a/node/libs/storage/src/in_memory.rs +++ b/node/libs/storage/src/in_memory.rs @@ -6,11 +6,11 @@ use crate::{ StorageResult, }; use async_trait::async_trait; -use concurrency::{ +use zksync_concurrency::{ ctx, sync::{self, watch, Mutex}, }; -use roles::validator::{BlockNumber, FinalBlock}; +use zksync_consensus_roles::validator::{BlockNumber, FinalBlock}; use std::{collections::BTreeMap, ops}; #[derive(Debug)] diff --git a/node/libs/storage/src/replica_state.rs b/node/libs/storage/src/replica_state.rs index 69335e4f..f27e00f7 100644 --- a/node/libs/storage/src/replica_state.rs +++ b/node/libs/storage/src/replica_state.rs @@ -4,8 +4,8 @@ use crate::{ traits::{BlockStore, ReplicaStateStore}, types::{ReplicaState, StorageResult}, }; -use concurrency::ctx; -use roles::validator; +use zksync_concurrency::ctx; +use zksync_consensus_roles::validator; use std::sync::Arc; impl From for ReplicaState { diff --git a/node/libs/storage/src/rocksdb.rs b/node/libs/storage/src/rocksdb.rs index 7a8b0937..1936fb40 100644 --- a/node/libs/storage/src/rocksdb.rs +++ b/node/libs/storage/src/rocksdb.rs @@ -2,7 +2,6 @@ //! chain of blocks, not a tree (assuming we have all blocks and not have any gap). It allows for basic functionality like inserting a block, //! getting a block, checking if a block is contained in the DB. We also store the head of the chain. Storing it explicitly allows us to fetch //! the current head quickly. - use crate::{ traits::{BlockStore, ReplicaStateStore, WriteBlockStore}, types::{MissingBlockNumbers, ReplicaState}, @@ -10,9 +9,10 @@ use crate::{ }; use anyhow::Context as _; use async_trait::async_trait; -use concurrency::{ctx, scope, sync::watch}; +use zksync_concurrency::{ctx, scope, sync::watch}; use rocksdb::{Direction, IteratorMode, ReadOptions}; -use roles::validator::{BlockNumber, FinalBlock}; +use zksync_consensus_roles::validator::{BlockNumber, FinalBlock}; +use zksync_consensus_schema as schema; use std::{ fmt, ops, path::Path, diff --git a/node/libs/storage/src/tests/mod.rs b/node/libs/storage/src/tests/mod.rs index 1190ff2c..23c25830 100644 --- a/node/libs/storage/src/tests/mod.rs +++ b/node/libs/storage/src/tests/mod.rs @@ -1,9 +1,9 @@ use super::*; use crate::types::ReplicaState; use async_trait::async_trait; -use concurrency::ctx; +use zksync_concurrency::ctx; use rand::{seq::SliceRandom, Rng}; -use roles::validator::{testonly::make_block, BlockHeader, BlockNumber, FinalBlock, Payload}; +use zksync_consensus_roles::validator::{testonly::make_block, BlockHeader, BlockNumber, FinalBlock, Payload}; use std::iter; #[cfg(feature = "rocksdb")] diff --git a/node/libs/storage/src/traits.rs b/node/libs/storage/src/traits.rs index 0d0b544f..c1b281bf 100644 --- a/node/libs/storage/src/traits.rs +++ b/node/libs/storage/src/traits.rs @@ -1,9 +1,8 @@ //! Traits for storage. - use crate::{types::ReplicaState, StorageResult}; use async_trait::async_trait; -use concurrency::{ctx, sync::watch}; -use roles::validator::{BlockNumber, FinalBlock}; +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 1b437ac5..f5f15886 100644 --- a/node/libs/storage/src/types.rs +++ b/node/libs/storage/src/types.rs @@ -1,9 +1,8 @@ //! Defines the schema of the database. - use anyhow::Context as _; -use concurrency::ctx; -use roles::validator::{self, BlockNumber}; -use schema::{proto::storage as proto, read_required, required, ProtoFmt}; +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. diff --git a/node/libs/utils/Cargo.toml b/node/libs/utils/Cargo.toml index 1fd234b3..83c2694e 100644 --- a/node/libs/utils/Cargo.toml +++ b/node/libs/utils/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "utils" +name = "zksync_consensus_utils" version = "0.1.0" edition.workspace = true authors.workspace = true @@ -7,6 +7,7 @@ homepage.workspace = true license.workspace = true [dependencies] +zksync_concurrency.workspace = true + thiserror.workspace = true -concurrency = { path = "../concurrency" } diff --git a/node/libs/utils/src/pipe.rs b/node/libs/utils/src/pipe.rs index 8eedab43..18e0745d 100644 --- a/node/libs/utils/src/pipe.rs +++ b/node/libs/utils/src/pipe.rs @@ -1,7 +1,7 @@ //! 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 concurrency::ctx::{self, channel, Ctx}; +use zksync_concurrency::ctx::{self, channel, Ctx}; use std::future::Future; /// This is the end of the Pipe that should be held by the actor. diff --git a/node/tools/Cargo.toml b/node/tools/Cargo.toml index 4129497f..526f41e7 100644 --- a/node/tools/Cargo.toml +++ b/node/tools/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "tools" +name = "zksync_consensus_tools" version = "0.1.0" edition.workspace = true authors.workspace = true @@ -9,6 +9,15 @@ publish = false default-run = "executor" [dependencies] +zksync_concurrency.workspace = true +zksync_consensus_consensus.workspace = true +zksync_consensus_crypto.workspace = true +zksync_consensus_executor.workspace = true +zksync_consensus_roles.workspace = true +zksync_consensus_storage = { workspace = true, features = ["rocksdb"] } +zksync_consensus_schema.workspace = true +zksync_consensus_utils.workspace = true + anyhow.workspace = true clap.workspace = true rand.workspace = true @@ -17,16 +26,6 @@ tracing.workspace = true tracing-subscriber.workspace = true vise-exporter.workspace = true -concurrency = { path = "../libs/concurrency" } -crypto = { path = "../libs/crypto" } -roles = { path = "../libs/roles" } -storage = { path = "../libs/storage", features = ["rocksdb"] } -schema = { path = "../libs/schema" } -utils = { path = "../libs/utils" } - -consensus = { path = "../actors/consensus" } -executor = { path = "../actors/executor" } - [[bin]] name = "executor" path = "src/main.rs" diff --git a/node/tools/src/bin/keys.rs b/node/tools/src/bin/keys.rs index 63d5ec9e..06de9d89 100644 --- a/node/tools/src/bin/keys.rs +++ b/node/tools/src/bin/keys.rs @@ -1,7 +1,8 @@ //! This tool generates a validator key pair and prints it to stdout. #![allow(clippy::print_stdout)] -use roles::validator; +use zksync_consensus_roles::validator; +use zksync_consensus_crypto as crypto; /// 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 20862ef5..2212370a 100644 --- a/node/tools/src/bin/localnet_config.rs +++ b/node/tools/src/bin/localnet_config.rs @@ -1,13 +1,14 @@ //! This tool constructs collection of node configs for running tests. use anyhow::Context as _; use clap::Parser; -use consensus::testonly; -use crypto::TextFmt; -use executor::{ConsensusConfig, ExecutorConfig, GossipConfig}; +use zksync_consensus_consensus::testonly; +use zksync_consensus_crypto::TextFmt; +use zksync_consensus_executor::{ConsensusConfig, ExecutorConfig, GossipConfig}; use rand::Rng; -use roles::{node, validator}; +use zksync_consensus_roles::{node, validator}; use std::{fs, net::SocketAddr, path::PathBuf}; -use tools::NodeConfig; +use zksync_consensus_tools::NodeConfig; +use zksync_consensus_schema as schema; /// 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 0776659d..bfc7b70c 100644 --- a/node/tools/src/config.rs +++ b/node/tools/src/config.rs @@ -1,10 +1,10 @@ //! Node configuration. - use anyhow::Context as _; -use crypto::{read_optional_text, Text, TextFmt}; -use executor::{ConsensusConfig, ExecutorConfig}; -use roles::{node, validator}; -use schema::{proto::executor::config as proto, read_optional, read_required, ProtoFmt}; +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}; /// This struct holds the file path to each of the config files. diff --git a/node/tools/src/main.rs b/node/tools/src/main.rs index 936b6dae..1d6606fa 100644 --- a/node/tools/src/main.rs +++ b/node/tools/src/main.rs @@ -1,24 +1,23 @@ //! Main binary for the consensus node. It reads the configuration, initializes all parts of the node and //! manages communication between the actors. It is the main executable in this workspace. - use anyhow::Context as _; use clap::Parser; -use concurrency::{ +use zksync_concurrency::{ ctx::{self, channel}, scope, time, }; -use executor::Executor; +use zksync_consensus_executor::Executor; use std::{ fs, io::IsTerminal as _, path::{Path, PathBuf}, sync::Arc, }; -use storage::{BlockStore, RocksdbStorage}; -use tools::{ConfigPaths, Configs}; +use zksync_consensus_storage::{BlockStore, RocksdbStorage}; +use zksync_consensus_tools::{ConfigPaths, Configs}; use tracing::metadata::LevelFilter; use tracing_subscriber::{prelude::*, Registry}; -use utils::no_copy::NoCopy; +use zksync_consensus_utils::no_copy::NoCopy; use vise_exporter::MetricsExporter; /// Command-line application launching a node executor. From e04d4e98bb75a46ff3dca86baa838892c9a6564d Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Mon, 6 Nov 2023 11:54:59 +0100 Subject: [PATCH 2/7] snapshot --- node/actors/consensus/src/inner.rs | 4 ++-- .../consensus/src/leader/replica_commit.rs | 2 +- .../consensus/src/leader/replica_prepare.rs | 6 +++--- .../actors/consensus/src/leader/state_machine.rs | 4 ++-- node/actors/consensus/src/leader/tests.rs | 2 +- node/actors/consensus/src/lib.rs | 4 ++-- node/actors/consensus/src/replica/block.rs | 2 +- .../consensus/src/replica/leader_commit.rs | 2 +- .../consensus/src/replica/leader_prepare.rs | 4 ++-- node/actors/consensus/src/replica/new_view.rs | 2 +- .../consensus/src/replica/state_machine.rs | 6 +++--- node/actors/consensus/src/replica/tests.rs | 3 ++- node/actors/consensus/src/replica/timer.rs | 2 +- node/actors/consensus/src/testonly/make.rs | 2 +- node/actors/consensus/src/testonly/mod.rs | 2 +- node/actors/consensus/src/testonly/node.rs | 3 ++- node/actors/consensus/src/testonly/run.rs | 7 ++++--- node/actors/consensus/src/tests.rs | 1 + node/actors/executor/src/config/mod.rs | 10 ++++++---- node/actors/executor/src/config/tests.rs | 2 +- node/actors/executor/src/io.rs | 6 ++++-- node/actors/executor/src/lib.rs | 8 ++++---- node/actors/executor/src/tests.rs | 5 +++-- .../network/src/consensus/handshake/tests.rs | 4 +++- node/actors/network/src/consensus/runner.rs | 2 +- node/actors/network/src/consensus/state.rs | 2 +- node/actors/network/src/consensus/tests.rs | 5 +++-- .../actors/network/src/gossip/handshake/tests.rs | 6 ++++-- node/actors/network/src/gossip/runner.rs | 4 ++-- node/actors/network/src/gossip/state.rs | 4 ++-- node/actors/network/src/gossip/tests.rs | 16 +++++++++------- node/actors/network/src/metrics.rs | 2 +- node/actors/network/src/mux/handshake.rs | 2 +- node/actors/network/src/mux/mod.rs | 2 +- node/actors/network/src/mux/reusable_stream.rs | 2 +- node/actors/network/src/mux/tests.rs | 6 ++++-- node/actors/network/src/noise/stream.rs | 8 ++++---- node/actors/network/src/noise/tests.rs | 3 ++- node/actors/network/src/pool.rs | 2 +- node/actors/network/src/preface.rs | 2 +- node/actors/network/src/rpc/consensus.rs | 2 +- node/actors/network/src/rpc/metrics.rs | 2 +- node/actors/network/src/rpc/mod.rs | 2 +- node/actors/network/src/rpc/ping.rs | 4 ++-- node/actors/network/src/rpc/sync_blocks.rs | 2 +- .../network/src/rpc/sync_validator_addrs.rs | 4 ++-- node/actors/network/src/rpc/tests.rs | 3 ++- node/actors/network/src/state.rs | 2 +- node/actors/network/src/testonly.rs | 10 +++++----- node/actors/network/src/tests.rs | 3 ++- node/actors/sync_blocks/src/lib.rs | 4 ++-- node/actors/sync_blocks/src/message_handler.rs | 4 ++-- node/actors/sync_blocks/src/peers/mod.rs | 4 ++-- node/actors/sync_blocks/src/peers/tests.rs | 7 ++++--- node/actors/sync_blocks/src/tests/end_to_end.rs | 11 ++++++----- node/actors/sync_blocks/src/tests/mod.rs | 8 ++++---- node/libs/crypto/benches/bench.rs | 2 -- node/libs/crypto/src/bn254/tests.rs | 6 ++---- node/libs/roles/src/node/conv.rs | 2 +- node/libs/roles/src/node/keys.rs | 2 +- node/libs/roles/src/node/messages.rs | 2 +- node/libs/roles/src/node/tests.rs | 4 ++-- node/libs/roles/src/validator/conv.rs | 9 +++++---- .../src/validator/keys/aggregate_signature.rs | 2 +- node/libs/roles/src/validator/keys/public_key.rs | 2 +- node/libs/roles/src/validator/keys/secret_key.rs | 2 +- node/libs/roles/src/validator/keys/signature.rs | 2 +- node/libs/roles/src/validator/messages/block.rs | 2 +- .../roles/src/validator/messages/discovery.rs | 2 +- node/libs/roles/src/validator/messages/msg.rs | 4 ++-- node/libs/roles/src/validator/testonly.rs | 2 +- node/libs/roles/src/validator/tests.rs | 6 +++--- node/libs/schema/src/bin/conformance_test.rs | 2 +- node/libs/schema/src/std_conv.rs | 2 +- node/libs/schema/src/tests.rs | 2 +- node/libs/storage/src/in_memory.rs | 2 +- node/libs/storage/src/replica_state.rs | 2 +- node/libs/storage/src/rocksdb.rs | 6 +++--- node/libs/storage/src/tests/mod.rs | 7 +++++-- node/libs/storage/src/traits.rs | 2 +- node/libs/storage/src/types.rs | 2 +- node/libs/utils/src/pipe.rs | 2 +- node/tools/src/bin/keys.rs | 2 +- node/tools/src/bin/localnet_config.rs | 6 +++--- node/tools/src/config.rs | 6 ++++-- node/tools/src/main.rs | 16 ++++++++-------- 86 files changed, 184 insertions(+), 159 deletions(-) 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)] From c35c261fe684022694c7d943417e55cc8d29cc4a Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Mon, 6 Nov 2023 12:10:23 +0100 Subject: [PATCH 3/7] fix CI --- .github/workflows/protobuf_conformance.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/protobuf_conformance.yaml b/.github/workflows/protobuf_conformance.yaml index 6027b84f..eac65e28 100644 --- a/.github/workflows/protobuf_conformance.yaml +++ b/.github/workflows/protobuf_conformance.yaml @@ -28,7 +28,7 @@ jobs: path: "protobuf" - uses: mozilla-actions/sccache-action@v0.0.3 - name: build test - run: cargo build -p schema --bin conformance_test + run: cargo build -p zksync_consensus_schema --bin conformance_test working-directory: "this/node" - name: Cache Bazel uses: actions/cache@v3 From 762aa97286a36a1a87de25245a7fc39dea5c3cb8 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Mon, 6 Nov 2023 15:53:55 +0100 Subject: [PATCH 4/7] snapshot --- node/actors/consensus/src/replica/tests.rs | 4 ++-- node/actors/consensus/src/tests.rs | 4 ++-- node/actors/executor/src/tests.rs | 6 +++--- .../network/src/consensus/handshake/tests.rs | 8 ++++---- node/actors/network/src/consensus/tests.rs | 8 ++++---- .../network/src/gossip/handshake/tests.rs | 8 ++++---- node/actors/network/src/gossip/tests.rs | 18 +++++++++--------- node/actors/network/src/mux/tests.rs | 8 ++++---- node/actors/network/src/noise/tests.rs | 8 ++++---- node/actors/network/src/rpc/tests.rs | 8 ++++---- node/actors/network/src/tests.rs | 4 ++-- node/actors/sync_blocks/src/peers/tests.rs | 4 ++-- .../actors/sync_blocks/src/tests/end_to_end.rs | 4 ++-- node/actors/sync_blocks/src/tests/mod.rs | 6 +++--- 14 files changed, 49 insertions(+), 49 deletions(-) diff --git a/node/actors/consensus/src/replica/tests.rs b/node/actors/consensus/src/replica/tests.rs index d7307b17..6c9e6e12 100644 --- a/node/actors/consensus/src/replica/tests.rs +++ b/node/actors/consensus/src/replica/tests.rs @@ -1,13 +1,13 @@ use crate::testonly; use rand::Rng; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ctx, scope, time}; use zksync_consensus_network::io::{ConsensusInputMessage, Target}; use zksync_consensus_roles::validator::{self, ViewNumber}; #[tokio::test] async fn start_new_view_not_leader() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::ManualClock::new()); let rng = &mut ctx.rng(); diff --git a/node/actors/consensus/src/tests.rs b/node/actors/consensus/src/tests.rs index e5796389..54fa7f9a 100644 --- a/node/actors/consensus/src/tests.rs +++ b/node/actors/consensus/src/tests.rs @@ -2,11 +2,11 @@ use crate::{ misc::consensus_threshold, testonly::{Behavior, Network, Test}, }; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::ctx; async fn run_test(behavior: Behavior, network: Network) { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::AffineClock::new(1.)); const NODES: usize = 11; diff --git a/node/actors/executor/src/tests.rs b/node/actors/executor/src/tests.rs index ddcb4795..dc69b267 100644 --- a/node/actors/executor/src/tests.rs +++ b/node/actors/executor/src/tests.rs @@ -3,7 +3,7 @@ use super::*; use rand::Rng; use std::collections::HashMap; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::sync; use zksync_consensus_consensus::testonly::make_genesis; use zksync_consensus_network::testonly::Instance; @@ -95,7 +95,7 @@ impl FullValidatorConfig { #[tokio::test] async fn executing_single_validator() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::root(); let rng = &mut ctx.rng(); @@ -123,7 +123,7 @@ async fn executing_single_validator() { #[tokio::test] async fn executing_validator_and_external_node() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::AffineClock::new(20.0)); let rng = &mut ctx.rng(); diff --git a/node/actors/network/src/consensus/handshake/tests.rs b/node/actors/network/src/consensus/handshake/tests.rs index d53bc916..c32228bc 100644 --- a/node/actors/network/src/consensus/handshake/tests.rs +++ b/node/actors/network/src/consensus/handshake/tests.rs @@ -1,7 +1,7 @@ use super::*; use crate::{frame, noise, testonly}; use rand::Rng; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ctx, io, scope}; use zksync_consensus_roles::validator; use zksync_consensus_schema as schema; @@ -14,7 +14,7 @@ fn test_schema_encode_decode() { #[tokio::test] async fn test_session_id_mismatch() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); @@ -81,7 +81,7 @@ async fn test_session_id_mismatch() { #[tokio::test] async fn test_peer_mismatch() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); @@ -111,7 +111,7 @@ async fn test_peer_mismatch() { #[tokio::test] async fn test_invalid_signature() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); diff --git a/node/actors/network/src/consensus/tests.rs b/node/actors/network/src/consensus/tests.rs index 00e51782..fe628bb3 100644 --- a/node/actors/network/src/consensus/tests.rs +++ b/node/actors/network/src/consensus/tests.rs @@ -3,14 +3,14 @@ use crate::{io, preface, rpc, run_network, testonly}; use anyhow::Context as _; use rand::Rng; use tracing::Instrument as _; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ctx, net, scope}; use zksync_consensus_roles::validator; use zksync_consensus_utils::pipe; #[tokio::test] async fn test_one_connection_per_validator() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); @@ -67,7 +67,7 @@ async fn test_one_connection_per_validator() { #[tokio::test(flavor = "multi_thread")] async fn test_address_change() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::AffineClock::new(20.)); let rng = &mut ctx.rng(); @@ -145,7 +145,7 @@ async fn test_address_change() { /// encrypted authenticated multiplexed stream. #[tokio::test] async fn test_transmission() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); diff --git a/node/actors/network/src/gossip/handshake/tests.rs b/node/actors/network/src/gossip/handshake/tests.rs index 7ea1fd14..8894fc1f 100644 --- a/node/actors/network/src/gossip/handshake/tests.rs +++ b/node/actors/network/src/gossip/handshake/tests.rs @@ -2,7 +2,7 @@ use super::*; use crate::{frame, noise, testonly}; use rand::Rng; use std::collections::{HashMap, HashSet}; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ctx, io, scope}; use zksync_consensus_roles::node; use zksync_consensus_schema as schema; @@ -25,7 +25,7 @@ fn make_cfg(rng: &mut R) -> Config { #[tokio::test] async fn test_session_id_mismatch() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); @@ -93,7 +93,7 @@ async fn test_session_id_mismatch() { #[tokio::test] async fn test_peer_mismatch() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); @@ -123,7 +123,7 @@ async fn test_peer_mismatch() { #[tokio::test] async fn test_invalid_signature() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); diff --git a/node/actors/network/src/gossip/tests.rs b/node/actors/network/src/gossip/tests.rs index 8b38d4cf..8a09524e 100644 --- a/node/actors/network/src/gossip/tests.rs +++ b/node/actors/network/src/gossip/tests.rs @@ -9,7 +9,7 @@ use std::{ }; use test_casing::{test_casing, Product}; use tracing::Instrument as _; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ ctx::{self, channel}, oneshot, scope, @@ -22,7 +22,7 @@ use zksync_consensus_utils::pipe; #[tokio::test] async fn test_one_connection_per_node() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); @@ -150,7 +150,7 @@ impl View { #[tokio::test] async fn test_validator_addrs() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let rng = &mut ctx::test_root(&ctx::RealClock).rng(); let keys: Vec = (0..8).map(|_| rng.gen()).collect(); @@ -233,7 +233,7 @@ fn to_addr_map(addrs: &ValidatorAddrs) -> HashMap = testonly::Instance::new(rng, 10, 1); @@ -277,7 +277,7 @@ const NETWORK_CONNECTIVITY_CASES: [(usize, usize); 5] = [(2, 1), (3, 2), (5, 3), #[tokio::test(flavor = "multi_thread")] #[tracing::instrument(level = "trace")] async fn syncing_blocks(node_count: usize, gossip_peers: usize) { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::AffineClock::new(20.0)); let ctx = &ctx.with_timeout(time::Duration::seconds(200)); @@ -398,7 +398,7 @@ async fn uncoordinated_block_syncing( (node_count, gossip_peers): (usize, usize), state_generation_interval: time::Duration, ) { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::AffineClock::new(20.0)); let ctx = &ctx.with_timeout(time::Duration::seconds(200)); @@ -482,7 +482,7 @@ async fn run_mock_uncoordinated_dispatcher( #[test_casing(5, NETWORK_CONNECTIVITY_CASES)] #[tokio::test] async fn getting_blocks_from_peers(node_count: usize, gossip_peers: usize) { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::ManualClock::new()); let rng = &mut ctx.rng(); @@ -595,7 +595,7 @@ async fn run_get_block_dispatcher( /// the AccountData that is present in the network from the previous run. #[tokio::test] async fn validator_node_restart() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let clock = &ctx::ManualClock::new(); let ctx = &ctx::test_root(clock); let rng = &mut ctx.rng(); @@ -679,7 +679,7 @@ async fn validator_node_restart() { /// to receive all updates in 2 rounds of communication. #[tokio::test] async fn rate_limiting() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let clock = &ctx::ManualClock::new(); let ctx = &ctx::test_root(clock); let rng = &mut ctx.rng(); diff --git a/node/actors/network/src/mux/tests.rs b/node/actors/network/src/mux/tests.rs index a1b397fb..3bea05f6 100644 --- a/node/actors/network/src/mux/tests.rs +++ b/node/actors/network/src/mux/tests.rs @@ -8,7 +8,7 @@ use std::{ Arc, }, }; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ctx, scope}; use zksync_consensus_schema as schema; use zksync_consensus_schema::proto::network::mux_test as proto; @@ -195,8 +195,8 @@ fn expected(res: Result<(), mux::RunError>) -> Result<(), mux::RunError> { // checking 1 property at a time should be added. #[test] fn mux_with_noise() { - concurrency::testonly::abort_on_panic(); - concurrency::testonly::with_runtimes(|| async { + abort_on_panic(); + zksync_concurrency::testonly::with_runtimes(|| async { let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); @@ -285,7 +285,7 @@ fn mux_with_noise() { #[tokio::test] async fn test_transport_closed() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let cap: mux::CapabilityId = 0; let cfg = Arc::new(mux::Config { diff --git a/node/actors/network/src/noise/tests.rs b/node/actors/network/src/noise/tests.rs index c2372aa8..cacfbbca 100644 --- a/node/actors/network/src/noise/tests.rs +++ b/node/actors/network/src/noise/tests.rs @@ -1,12 +1,12 @@ use crate::noise; use rand::Rng; use tracing::instrument::Instrument as _; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ctx, io, scope}; #[tokio::test] async fn transmit_ok() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let (mut s1, mut s2) = noise::testonly::pipe(ctx).await; let msg = "hello"; @@ -45,7 +45,7 @@ async fn transmit_ok() { #[tokio::test] async fn transmit_sender_dies() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let (mut s1, mut s2) = noise::testonly::pipe(ctx).await; let msg = "hello"; @@ -75,7 +75,7 @@ async fn transmit_sender_dies() { #[tokio::test] async fn transmit_receiver_dies() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); let (s1, s2) = noise::testonly::pipe(ctx).await; diff --git a/node/actors/network/src/rpc/tests.rs b/node/actors/network/src/rpc/tests.rs index 7a71e252..e79aea03 100644 --- a/node/actors/network/src/rpc/tests.rs +++ b/node/actors/network/src/rpc/tests.rs @@ -5,7 +5,7 @@ use std::{ collections::HashSet, sync::atomic::{AtomicU64, Ordering}, }; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ctx, time}; /// CAPABILITY_ID should uniquely identify the RPC. @@ -35,7 +35,7 @@ fn expected(res: Result<(), mux::RunError>) -> Result<(), mux::RunError> { #[tokio::test] async fn test_ping() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let clock = ctx::ManualClock::new(); let ctx = &ctx::test_root(&clock); let (s1, s2) = noise::testonly::pipe(ctx).await; @@ -87,7 +87,7 @@ impl Handler for PingServer { #[tokio::test] async fn test_ping_loop() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let clock = ctx::ManualClock::new(); clock.set_advance_on_sleep(); let ctx = &ctx::test_root(&clock); @@ -151,7 +151,7 @@ impl Handler for ExampleServer { #[tokio::test] async fn test_inflight() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let (s1, s2) = noise::testonly::pipe(ctx).await; let client = Client::::new(ctx); diff --git a/node/actors/network/src/tests.rs b/node/actors/network/src/tests.rs index 93269d1e..2226219f 100644 --- a/node/actors/network/src/tests.rs +++ b/node/actors/network/src/tests.rs @@ -1,6 +1,6 @@ use crate::{run_network, testonly}; use tracing::Instrument as _; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ctx, scope}; use zksync_consensus_utils::pipe; @@ -8,7 +8,7 @@ use zksync_consensus_utils::pipe; /// (won't panic during registration). #[tokio::test] async fn test_metrics() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &mut ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); let nodes = testonly::Instance::new(rng, 3, 1); diff --git a/node/actors/sync_blocks/src/peers/tests.rs b/node/actors/sync_blocks/src/peers/tests.rs index 485c97dd..57e9cd4d 100644 --- a/node/actors/sync_blocks/src/peers/tests.rs +++ b/node/actors/sync_blocks/src/peers/tests.rs @@ -5,7 +5,7 @@ use async_trait::async_trait; use rand::{rngs::StdRng, seq::IteratorRandom, Rng}; use std::{collections::HashSet, fmt}; use test_casing::{test_casing, Product}; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::time; use zksync_consensus_roles::validator; use zksync_consensus_storage::{BlockStore, InMemoryStorage}; @@ -85,7 +85,7 @@ async fn wait_for_peer_update( #[instrument(level = "trace")] async fn test_peer_states(test: T) { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock).with_timeout(TEST_TIMEOUT); let clock = ctx::ManualClock::new(); 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 a1ad1dbe..c54bfdd6 100644 --- a/node/actors/sync_blocks/src/tests/end_to_end.rs +++ b/node/actors/sync_blocks/src/tests/end_to_end.rs @@ -6,7 +6,7 @@ use rand::seq::SliceRandom; use std::fmt; use test_casing::test_casing; use tracing::Instrument; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::ctx::channel; use zksync_consensus_network as network; use zksync_consensus_network::testonly::Instance as NetworkInstance; @@ -229,7 +229,7 @@ trait GossipNetworkTest: fmt::Debug + Send { async fn test_sync_blocks(test: T) { const CLOCK_SPEEDUP: u32 = 25; - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::AffineClock::new(CLOCK_SPEEDUP as f64)) .with_timeout(TEST_TIMEOUT * CLOCK_SPEEDUP); diff --git a/node/actors/sync_blocks/src/tests/mod.rs b/node/actors/sync_blocks/src/tests/mod.rs index a590ea3f..6fc7b445 100644 --- a/node/actors/sync_blocks/src/tests/mod.rs +++ b/node/actors/sync_blocks/src/tests/mod.rs @@ -5,7 +5,7 @@ use rand::{ Rng, }; use std::iter; -use zksync_concurrency as concurrency; +use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{oneshot, time}; use zksync_consensus_network::io::{GetBlockError, GetBlockResponse, SyncBlocksRequest}; use zksync_consensus_roles::validator::{ @@ -104,7 +104,7 @@ impl TestValidators { #[tokio::test] async fn subscribing_to_state_updates() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); @@ -179,7 +179,7 @@ async fn subscribing_to_state_updates() { #[tokio::test] async fn getting_blocks() { - concurrency::testonly::abort_on_panic(); + abort_on_panic(); let ctx = &ctx::test_root(&ctx::RealClock); let rng = &mut ctx.rng(); From 4d946d970814e8cd13477d025aa46e1e58a893a1 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Mon, 6 Nov 2023 16:05:06 +0100 Subject: [PATCH 5/7] applied comments --- node/actors/consensus/src/replica/tests.rs | 3 +-- node/actors/consensus/src/tests.rs | 3 +-- node/actors/executor/src/lib.rs | 8 +++----- node/actors/executor/src/tests.rs | 3 +-- node/actors/network/src/consensus/handshake/tests.rs | 7 +++---- node/actors/network/src/consensus/tests.rs | 3 +-- node/actors/network/src/gossip/handshake/tests.rs | 7 +++---- node/actors/network/src/gossip/tests.rs | 2 +- node/actors/network/src/mux/tests.rs | 3 +-- node/actors/network/src/noise/tests.rs | 3 +-- node/actors/network/src/rpc/tests.rs | 8 ++++---- node/actors/network/src/tests.rs | 3 +-- node/actors/sync_blocks/src/peers/tests.rs | 3 +-- node/actors/sync_blocks/src/tests/end_to_end.rs | 3 +-- node/actors/sync_blocks/src/tests/mod.rs | 3 +-- 15 files changed, 24 insertions(+), 38 deletions(-) diff --git a/node/actors/consensus/src/replica/tests.rs b/node/actors/consensus/src/replica/tests.rs index 6c9e6e12..8fb3aedc 100644 --- a/node/actors/consensus/src/replica/tests.rs +++ b/node/actors/consensus/src/replica/tests.rs @@ -1,7 +1,6 @@ use crate::testonly; use rand::Rng; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, scope, time}; +use zksync_concurrency::{ctx, scope, testonly::abort_on_panic, time}; use zksync_consensus_network::io::{ConsensusInputMessage, Target}; use zksync_consensus_roles::validator::{self, ViewNumber}; diff --git a/node/actors/consensus/src/tests.rs b/node/actors/consensus/src/tests.rs index 54fa7f9a..a7f65479 100644 --- a/node/actors/consensus/src/tests.rs +++ b/node/actors/consensus/src/tests.rs @@ -2,8 +2,7 @@ use crate::{ misc::consensus_threshold, testonly::{Behavior, Network, Test}, }; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::ctx; +use zksync_concurrency::{ctx, testonly::abort_on_panic}; async fn run_test(behavior: Behavior, network: Network) { abort_on_panic(); diff --git a/node/actors/executor/src/lib.rs b/node/actors/executor/src/lib.rs index 70a60e59..c303056d 100644 --- a/node/actors/executor/src/lib.rs +++ b/node/actors/executor/src/lib.rs @@ -4,12 +4,10 @@ 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_consensus::{misc::consensus_threshold, Consensus}; use zksync_consensus_network as network; use zksync_consensus_roles::{node, validator, validator::FinalBlock}; 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; @@ -182,9 +180,9 @@ impl Executor { None }; - let sync_blocks_config = sync_blocks::Config::new( + let sync_blocks_config = zksync_consensus_sync_blocks::Config::new( validator_set.clone(), - consensus::misc::consensus_threshold(validator_set.len()), + consensus_threshold(validator_set.len()), )?; let sync_blocks = SyncBlocks::new( ctx, diff --git a/node/actors/executor/src/tests.rs b/node/actors/executor/src/tests.rs index dc69b267..87c4a9d1 100644 --- a/node/actors/executor/src/tests.rs +++ b/node/actors/executor/src/tests.rs @@ -3,8 +3,7 @@ use super::*; use rand::Rng; use std::collections::HashMap; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::sync; +use zksync_concurrency::{sync, testonly::abort_on_panic}; use zksync_consensus_consensus::testonly::make_genesis; use zksync_consensus_network::testonly::Instance; use zksync_consensus_roles::validator::{BlockNumber, Payload}; diff --git a/node/actors/network/src/consensus/handshake/tests.rs b/node/actors/network/src/consensus/handshake/tests.rs index c32228bc..ed49c14d 100644 --- a/node/actors/network/src/consensus/handshake/tests.rs +++ b/node/actors/network/src/consensus/handshake/tests.rs @@ -1,15 +1,14 @@ use super::*; use crate::{frame, noise, testonly}; use rand::Rng; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, io, scope}; +use zksync_concurrency::{ctx, io, scope, testonly::abort_on_panic}; use zksync_consensus_roles::validator; -use zksync_consensus_schema as schema; +use zksync_consensus_schema::testonly::test_encode_random; #[test] fn test_schema_encode_decode() { let rng = &mut ctx::test_root(&ctx::RealClock).rng(); - schema::testonly::test_encode_random::<_, Handshake>(rng); + test_encode_random::<_, Handshake>(rng); } #[tokio::test] diff --git a/node/actors/network/src/consensus/tests.rs b/node/actors/network/src/consensus/tests.rs index fe628bb3..4ec52fcc 100644 --- a/node/actors/network/src/consensus/tests.rs +++ b/node/actors/network/src/consensus/tests.rs @@ -3,8 +3,7 @@ use crate::{io, preface, rpc, run_network, testonly}; use anyhow::Context as _; use rand::Rng; use tracing::Instrument as _; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, net, scope}; +use zksync_concurrency::{ctx, net, scope, testonly::abort_on_panic}; use zksync_consensus_roles::validator; use zksync_consensus_utils::pipe; diff --git a/node/actors/network/src/gossip/handshake/tests.rs b/node/actors/network/src/gossip/handshake/tests.rs index 8894fc1f..39c26457 100644 --- a/node/actors/network/src/gossip/handshake/tests.rs +++ b/node/actors/network/src/gossip/handshake/tests.rs @@ -2,15 +2,14 @@ use super::*; use crate::{frame, noise, testonly}; use rand::Rng; use std::collections::{HashMap, HashSet}; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, io, scope}; +use zksync_concurrency::{ctx, io, scope, testonly::abort_on_panic}; use zksync_consensus_roles::node; -use zksync_consensus_schema as schema; +use zksync_consensus_schema::testonly::test_encode_random; #[test] fn test_schema_encode_decode() { let rng = &mut ctx::test_root(&ctx::RealClock).rng(); - schema::testonly::test_encode_random::<_, Handshake>(rng); + test_encode_random::<_, Handshake>(rng); } fn make_cfg(rng: &mut R) -> Config { diff --git a/node/actors/network/src/gossip/tests.rs b/node/actors/network/src/gossip/tests.rs index 8a09524e..14f73183 100644 --- a/node/actors/network/src/gossip/tests.rs +++ b/node/actors/network/src/gossip/tests.rs @@ -9,11 +9,11 @@ use std::{ }; use test_casing::{test_casing, Product}; use tracing::Instrument as _; -use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ ctx::{self, channel}, oneshot, scope, sync::{watch, Mutex}, + testonly::abort_on_panic, time, }; use zksync_consensus_roles as roles; diff --git a/node/actors/network/src/mux/tests.rs b/node/actors/network/src/mux/tests.rs index 3bea05f6..19a82458 100644 --- a/node/actors/network/src/mux/tests.rs +++ b/node/actors/network/src/mux/tests.rs @@ -8,8 +8,7 @@ use std::{ Arc, }, }; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, scope}; +use zksync_concurrency::{ctx, scope, testonly::abort_on_panic}; use zksync_consensus_schema as schema; use zksync_consensus_schema::proto::network::mux_test as proto; use zksync_consensus_utils::no_copy::NoCopy; diff --git a/node/actors/network/src/noise/tests.rs b/node/actors/network/src/noise/tests.rs index cacfbbca..7ad33fcd 100644 --- a/node/actors/network/src/noise/tests.rs +++ b/node/actors/network/src/noise/tests.rs @@ -1,8 +1,7 @@ use crate::noise; use rand::Rng; use tracing::instrument::Instrument as _; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, io, scope}; +use zksync_concurrency::{ctx, io, scope, testonly::abort_on_panic}; #[tokio::test] async fn transmit_ok() { diff --git a/node/actors/network/src/rpc/tests.rs b/node/actors/network/src/rpc/tests.rs index e79aea03..d2e98851 100644 --- a/node/actors/network/src/rpc/tests.rs +++ b/node/actors/network/src/rpc/tests.rs @@ -5,8 +5,8 @@ use std::{ collections::HashSet, sync::atomic::{AtomicU64, Ordering}, }; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, time}; +use zksync_concurrency::{ctx, testonly::abort_on_panic, time}; +use zksync_consensus_schema::testonly::test_encode_random; /// CAPABILITY_ID should uniquely identify the RPC. #[test] @@ -22,8 +22,8 @@ fn test_capability_rpc_correspondence() { #[test] fn test_schema_encode_decode() { let rng = &mut ctx::test_root(&ctx::RealClock).rng(); - schema::testonly::test_encode_random::<_, consensus::Req>(rng); - schema::testonly::test_encode_random::<_, sync_validator_addrs::Resp>(rng); + test_encode_random::<_, consensus::Req>(rng); + test_encode_random::<_, sync_validator_addrs::Resp>(rng); } fn expected(res: Result<(), mux::RunError>) -> Result<(), mux::RunError> { diff --git a/node/actors/network/src/tests.rs b/node/actors/network/src/tests.rs index 2226219f..f283c393 100644 --- a/node/actors/network/src/tests.rs +++ b/node/actors/network/src/tests.rs @@ -1,7 +1,6 @@ use crate::{run_network, testonly}; use tracing::Instrument as _; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, scope}; +use zksync_concurrency::{ctx, scope, testonly::abort_on_panic}; use zksync_consensus_utils::pipe; /// Test that metrics are correctly defined diff --git a/node/actors/sync_blocks/src/peers/tests.rs b/node/actors/sync_blocks/src/peers/tests.rs index 57e9cd4d..6248bfb4 100644 --- a/node/actors/sync_blocks/src/peers/tests.rs +++ b/node/actors/sync_blocks/src/peers/tests.rs @@ -5,8 +5,7 @@ use async_trait::async_trait; use rand::{rngs::StdRng, seq::IteratorRandom, Rng}; use std::{collections::HashSet, fmt}; use test_casing::{test_casing, Product}; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::time; +use zksync_concurrency::{testonly::abort_on_panic, time}; use zksync_consensus_roles::validator; use zksync_consensus_storage::{BlockStore, InMemoryStorage}; 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 c54bfdd6..5bfc9bf3 100644 --- a/node/actors/sync_blocks/src/tests/end_to_end.rs +++ b/node/actors/sync_blocks/src/tests/end_to_end.rs @@ -6,8 +6,7 @@ use rand::seq::SliceRandom; use std::fmt; use test_casing::test_casing; use tracing::Instrument; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::ctx::channel; +use zksync_concurrency::{ctx::channel, testonly::abort_on_panic}; use zksync_consensus_network as network; use zksync_consensus_network::testonly::Instance as NetworkInstance; use zksync_consensus_roles::node; diff --git a/node/actors/sync_blocks/src/tests/mod.rs b/node/actors/sync_blocks/src/tests/mod.rs index 6fc7b445..fe0fe2b2 100644 --- a/node/actors/sync_blocks/src/tests/mod.rs +++ b/node/actors/sync_blocks/src/tests/mod.rs @@ -5,8 +5,7 @@ use rand::{ Rng, }; use std::iter; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{oneshot, time}; +use zksync_concurrency::{oneshot, testonly::abort_on_panic, time}; use zksync_consensus_network::io::{GetBlockError, GetBlockResponse, SyncBlocksRequest}; use zksync_consensus_roles::validator::{ self, From d4775693b8f92b02683157968dd7f51d0d04a05f Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Tue, 7 Nov 2023 11:09:41 +0100 Subject: [PATCH 6/7] applied comment --- node/actors/consensus/src/testonly/run.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/actors/consensus/src/testonly/run.rs b/node/actors/consensus/src/testonly/run.rs index d0654712..d1eb3eae 100644 --- a/node/actors/consensus/src/testonly/run.rs +++ b/node/actors/consensus/src/testonly/run.rs @@ -154,8 +154,8 @@ async fn run_nodes( } for (_, recv) in network_recv { s.spawn(async { - let mut recv = recv; use zksync_consensus_network::io; + let mut recv = recv; while let Ok(io::InputMessage::Consensus(message)) = recv.recv(ctx).await { let msg = || { From bd16efea691b91a9aba10d14ad56e70c367cdf6c Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Tue, 7 Nov 2023 14:51:50 +0100 Subject: [PATCH 7/7] renamed consensus crate to bft --- docs/architecture.md | 6 +++--- node/Cargo.lock | 6 +++--- node/Cargo.toml | 4 ++-- node/actors/{consensus => bft}/Cargo.toml | 2 +- node/actors/{consensus => bft}/src/inner.rs | 0 node/actors/{consensus => bft}/src/io.rs | 0 node/actors/{consensus => bft}/src/leader/mod.rs | 0 node/actors/{consensus => bft}/src/leader/replica_commit.rs | 0 .../actors/{consensus => bft}/src/leader/replica_prepare.rs | 0 node/actors/{consensus => bft}/src/leader/state_machine.rs | 0 node/actors/{consensus => bft}/src/leader/tests.rs | 0 node/actors/{consensus => bft}/src/lib.rs | 0 node/actors/{consensus => bft}/src/metrics.rs | 0 node/actors/{consensus => bft}/src/misc.rs | 0 node/actors/{consensus => bft}/src/replica/block.rs | 0 node/actors/{consensus => bft}/src/replica/leader_commit.rs | 0 .../actors/{consensus => bft}/src/replica/leader_prepare.rs | 0 node/actors/{consensus => bft}/src/replica/mod.rs | 0 node/actors/{consensus => bft}/src/replica/new_view.rs | 0 node/actors/{consensus => bft}/src/replica/state_machine.rs | 0 node/actors/{consensus => bft}/src/replica/tests.rs | 0 node/actors/{consensus => bft}/src/replica/timer.rs | 0 node/actors/{consensus => bft}/src/testonly/fuzz.rs | 0 node/actors/{consensus => bft}/src/testonly/make.rs | 0 node/actors/{consensus => bft}/src/testonly/mod.rs | 0 node/actors/{consensus => bft}/src/testonly/node.rs | 0 node/actors/{consensus => bft}/src/testonly/run.rs | 0 node/actors/{consensus => bft}/src/tests.rs | 0 node/actors/executor/Cargo.toml | 2 +- node/actors/executor/src/io.rs | 2 +- node/actors/executor/src/lib.rs | 2 +- node/actors/executor/src/tests.rs | 2 +- node/tools/Cargo.toml | 2 +- node/tools/src/bin/localnet_config.rs | 2 +- 34 files changed, 15 insertions(+), 15 deletions(-) rename node/actors/{consensus => bft}/Cargo.toml (94%) rename node/actors/{consensus => bft}/src/inner.rs (100%) rename node/actors/{consensus => bft}/src/io.rs (100%) rename node/actors/{consensus => bft}/src/leader/mod.rs (100%) rename node/actors/{consensus => bft}/src/leader/replica_commit.rs (100%) rename node/actors/{consensus => bft}/src/leader/replica_prepare.rs (100%) rename node/actors/{consensus => bft}/src/leader/state_machine.rs (100%) rename node/actors/{consensus => bft}/src/leader/tests.rs (100%) rename node/actors/{consensus => bft}/src/lib.rs (100%) rename node/actors/{consensus => bft}/src/metrics.rs (100%) rename node/actors/{consensus => bft}/src/misc.rs (100%) rename node/actors/{consensus => bft}/src/replica/block.rs (100%) rename node/actors/{consensus => bft}/src/replica/leader_commit.rs (100%) rename node/actors/{consensus => bft}/src/replica/leader_prepare.rs (100%) rename node/actors/{consensus => bft}/src/replica/mod.rs (100%) rename node/actors/{consensus => bft}/src/replica/new_view.rs (100%) rename node/actors/{consensus => bft}/src/replica/state_machine.rs (100%) rename node/actors/{consensus => bft}/src/replica/tests.rs (100%) rename node/actors/{consensus => bft}/src/replica/timer.rs (100%) rename node/actors/{consensus => bft}/src/testonly/fuzz.rs (100%) rename node/actors/{consensus => bft}/src/testonly/make.rs (100%) rename node/actors/{consensus => bft}/src/testonly/mod.rs (100%) rename node/actors/{consensus => bft}/src/testonly/node.rs (100%) rename node/actors/{consensus => bft}/src/testonly/run.rs (100%) rename node/actors/{consensus => bft}/src/tests.rs (100%) diff --git a/docs/architecture.md b/docs/architecture.md index e2e5e863..15fc4cd5 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -8,7 +8,7 @@ The architecture of era-bft loosely follows the [Actor model](https://en.wikiped The actor crates are where the vast majority of the work is done. Each of them maintains its own separate state and communicate with each other through message passing. We have the following actor crates: -- the `consensus` crate implements the logic for the consensus algorithm. +- the `bft` crate implements the logic for the consensus algorithm. - the `executor` crate is responsible for parsing the configuration parameters given by the user, and initializing the actors and the storage. It's basically the bootloader for the node. It also dispatches messages between the rest of the actors. They all send messages to the executor and it then converts and forwards the messages to the desired destination. This improves the encapsulation of the actors. @@ -44,7 +44,7 @@ This section provides a physical map of folders & files in this repository. - `/actors`: Crates that implement specific actor components. - - `/consensus`: The consensus actor. + - `/bft`: The consensus actor. - `/executor`: The actor orchestrator. - `/network`: The networking actor. - `/sync_blocks`: The block syncing actor. @@ -58,4 +58,4 @@ This section provides a physical map of folders & files in this repository. - `/storage`: Storage layer for the node. - `/utils`: Collection of small utilities. - - `/tools`: Utility binaries needed to work with and test the node. \ No newline at end of file + - `/tools`: Utility binaries needed to work with and test the node. diff --git a/node/Cargo.lock b/node/Cargo.lock index ad547be2..38f571e7 100644 --- a/node/Cargo.lock +++ b/node/Cargo.lock @@ -2681,7 +2681,7 @@ dependencies = [ ] [[package]] -name = "zksync_consensus_consensus" +name = "zksync_consensus_bft" version = "0.1.0" dependencies = [ "anyhow", @@ -2729,7 +2729,7 @@ dependencies = [ "tracing", "vise", "zksync_concurrency", - "zksync_consensus_consensus", + "zksync_consensus_bft", "zksync_consensus_crypto", "zksync_consensus_network", "zksync_consensus_roles", @@ -2852,7 +2852,7 @@ dependencies = [ "tracing-subscriber", "vise-exporter", "zksync_concurrency", - "zksync_consensus_consensus", + "zksync_consensus_bft", "zksync_consensus_crypto", "zksync_consensus_executor", "zksync_consensus_roles", diff --git a/node/Cargo.toml b/node/Cargo.toml index c1842e6d..90cb4f6d 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,7 +1,7 @@ [workspace] members = [ "libs/concurrency", - "actors/consensus", + "actors/bft", "libs/crypto", "actors/executor", "actors/network", @@ -22,7 +22,7 @@ license = "MIT" [workspace.dependencies] zksync_concurrency = { path = "libs/concurrency" } -zksync_consensus_consensus = { path = "actors/consensus" } +zksync_consensus_bft = { path = "actors/bft" } zksync_consensus_crypto = { path = "libs/crypto" } zksync_consensus_executor = { path = "actors/executor" } zksync_consensus_network = { path = "actors/network" } diff --git a/node/actors/consensus/Cargo.toml b/node/actors/bft/Cargo.toml similarity index 94% rename from node/actors/consensus/Cargo.toml rename to node/actors/bft/Cargo.toml index ccefe4e0..5f61f2cf 100644 --- a/node/actors/consensus/Cargo.toml +++ b/node/actors/bft/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "zksync_consensus_consensus" +name = "zksync_consensus_bft" version = "0.1.0" edition.workspace = true authors.workspace = true diff --git a/node/actors/consensus/src/inner.rs b/node/actors/bft/src/inner.rs similarity index 100% rename from node/actors/consensus/src/inner.rs rename to node/actors/bft/src/inner.rs diff --git a/node/actors/consensus/src/io.rs b/node/actors/bft/src/io.rs similarity index 100% rename from node/actors/consensus/src/io.rs rename to node/actors/bft/src/io.rs diff --git a/node/actors/consensus/src/leader/mod.rs b/node/actors/bft/src/leader/mod.rs similarity index 100% rename from node/actors/consensus/src/leader/mod.rs rename to node/actors/bft/src/leader/mod.rs diff --git a/node/actors/consensus/src/leader/replica_commit.rs b/node/actors/bft/src/leader/replica_commit.rs similarity index 100% rename from node/actors/consensus/src/leader/replica_commit.rs rename to node/actors/bft/src/leader/replica_commit.rs diff --git a/node/actors/consensus/src/leader/replica_prepare.rs b/node/actors/bft/src/leader/replica_prepare.rs similarity index 100% rename from node/actors/consensus/src/leader/replica_prepare.rs rename to node/actors/bft/src/leader/replica_prepare.rs diff --git a/node/actors/consensus/src/leader/state_machine.rs b/node/actors/bft/src/leader/state_machine.rs similarity index 100% rename from node/actors/consensus/src/leader/state_machine.rs rename to node/actors/bft/src/leader/state_machine.rs diff --git a/node/actors/consensus/src/leader/tests.rs b/node/actors/bft/src/leader/tests.rs similarity index 100% rename from node/actors/consensus/src/leader/tests.rs rename to node/actors/bft/src/leader/tests.rs diff --git a/node/actors/consensus/src/lib.rs b/node/actors/bft/src/lib.rs similarity index 100% rename from node/actors/consensus/src/lib.rs rename to node/actors/bft/src/lib.rs diff --git a/node/actors/consensus/src/metrics.rs b/node/actors/bft/src/metrics.rs similarity index 100% rename from node/actors/consensus/src/metrics.rs rename to node/actors/bft/src/metrics.rs diff --git a/node/actors/consensus/src/misc.rs b/node/actors/bft/src/misc.rs similarity index 100% rename from node/actors/consensus/src/misc.rs rename to node/actors/bft/src/misc.rs diff --git a/node/actors/consensus/src/replica/block.rs b/node/actors/bft/src/replica/block.rs similarity index 100% rename from node/actors/consensus/src/replica/block.rs rename to node/actors/bft/src/replica/block.rs diff --git a/node/actors/consensus/src/replica/leader_commit.rs b/node/actors/bft/src/replica/leader_commit.rs similarity index 100% rename from node/actors/consensus/src/replica/leader_commit.rs rename to node/actors/bft/src/replica/leader_commit.rs diff --git a/node/actors/consensus/src/replica/leader_prepare.rs b/node/actors/bft/src/replica/leader_prepare.rs similarity index 100% rename from node/actors/consensus/src/replica/leader_prepare.rs rename to node/actors/bft/src/replica/leader_prepare.rs diff --git a/node/actors/consensus/src/replica/mod.rs b/node/actors/bft/src/replica/mod.rs similarity index 100% rename from node/actors/consensus/src/replica/mod.rs rename to node/actors/bft/src/replica/mod.rs diff --git a/node/actors/consensus/src/replica/new_view.rs b/node/actors/bft/src/replica/new_view.rs similarity index 100% rename from node/actors/consensus/src/replica/new_view.rs rename to node/actors/bft/src/replica/new_view.rs diff --git a/node/actors/consensus/src/replica/state_machine.rs b/node/actors/bft/src/replica/state_machine.rs similarity index 100% rename from node/actors/consensus/src/replica/state_machine.rs rename to node/actors/bft/src/replica/state_machine.rs diff --git a/node/actors/consensus/src/replica/tests.rs b/node/actors/bft/src/replica/tests.rs similarity index 100% rename from node/actors/consensus/src/replica/tests.rs rename to node/actors/bft/src/replica/tests.rs diff --git a/node/actors/consensus/src/replica/timer.rs b/node/actors/bft/src/replica/timer.rs similarity index 100% rename from node/actors/consensus/src/replica/timer.rs rename to node/actors/bft/src/replica/timer.rs diff --git a/node/actors/consensus/src/testonly/fuzz.rs b/node/actors/bft/src/testonly/fuzz.rs similarity index 100% rename from node/actors/consensus/src/testonly/fuzz.rs rename to node/actors/bft/src/testonly/fuzz.rs diff --git a/node/actors/consensus/src/testonly/make.rs b/node/actors/bft/src/testonly/make.rs similarity index 100% rename from node/actors/consensus/src/testonly/make.rs rename to node/actors/bft/src/testonly/make.rs diff --git a/node/actors/consensus/src/testonly/mod.rs b/node/actors/bft/src/testonly/mod.rs similarity index 100% rename from node/actors/consensus/src/testonly/mod.rs rename to node/actors/bft/src/testonly/mod.rs diff --git a/node/actors/consensus/src/testonly/node.rs b/node/actors/bft/src/testonly/node.rs similarity index 100% rename from node/actors/consensus/src/testonly/node.rs rename to node/actors/bft/src/testonly/node.rs diff --git a/node/actors/consensus/src/testonly/run.rs b/node/actors/bft/src/testonly/run.rs similarity index 100% rename from node/actors/consensus/src/testonly/run.rs rename to node/actors/bft/src/testonly/run.rs diff --git a/node/actors/consensus/src/tests.rs b/node/actors/bft/src/tests.rs similarity index 100% rename from node/actors/consensus/src/tests.rs rename to node/actors/bft/src/tests.rs diff --git a/node/actors/executor/Cargo.toml b/node/actors/executor/Cargo.toml index 9a2e3c90..11fdb865 100644 --- a/node/actors/executor/Cargo.toml +++ b/node/actors/executor/Cargo.toml @@ -8,7 +8,7 @@ license.workspace = true [dependencies] zksync_concurrency.workspace = true -zksync_consensus_consensus.workspace = true +zksync_consensus_bft.workspace = true zksync_consensus_crypto.workspace = true zksync_consensus_network.workspace = true zksync_consensus_roles.workspace = true diff --git a/node/actors/executor/src/io.rs b/node/actors/executor/src/io.rs index d6950a82..76b1df00 100644 --- a/node/actors/executor/src/io.rs +++ b/node/actors/executor/src/io.rs @@ -6,7 +6,7 @@ use zksync_concurrency::{ ctx::{self, channel}, scope, }; -use zksync_consensus_consensus::io::{ +use zksync_consensus_bft::io::{ InputMessage as ConsensusInputMessage, OutputMessage as ConsensusOutputMessage, }; use zksync_consensus_network::io::{ diff --git a/node/actors/executor/src/lib.rs b/node/actors/executor/src/lib.rs index c303056d..822a0165 100644 --- a/node/actors/executor/src/lib.rs +++ b/node/actors/executor/src/lib.rs @@ -4,7 +4,7 @@ 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::{misc::consensus_threshold, Consensus}; +use zksync_consensus_bft::{misc::consensus_threshold, Consensus}; use zksync_consensus_network as network; use zksync_consensus_roles::{node, validator, validator::FinalBlock}; use zksync_consensus_storage::{FallbackReplicaStateStore, ReplicaStateStore, WriteBlockStore}; diff --git a/node/actors/executor/src/tests.rs b/node/actors/executor/src/tests.rs index 87c4a9d1..b1bc55f8 100644 --- a/node/actors/executor/src/tests.rs +++ b/node/actors/executor/src/tests.rs @@ -4,7 +4,7 @@ use super::*; use rand::Rng; use std::collections::HashMap; use zksync_concurrency::{sync, testonly::abort_on_panic}; -use zksync_consensus_consensus::testonly::make_genesis; +use zksync_consensus_bft::testonly::make_genesis; use zksync_consensus_network::testonly::Instance; use zksync_consensus_roles::validator::{BlockNumber, Payload}; use zksync_consensus_storage::{BlockStore, InMemoryStorage, StorageError}; diff --git a/node/tools/Cargo.toml b/node/tools/Cargo.toml index 526f41e7..3102f33d 100644 --- a/node/tools/Cargo.toml +++ b/node/tools/Cargo.toml @@ -10,7 +10,7 @@ default-run = "executor" [dependencies] zksync_concurrency.workspace = true -zksync_consensus_consensus.workspace = true +zksync_consensus_bft.workspace = true zksync_consensus_crypto.workspace = true zksync_consensus_executor.workspace = true zksync_consensus_roles.workspace = true diff --git a/node/tools/src/bin/localnet_config.rs b/node/tools/src/bin/localnet_config.rs index c867a512..95f74f5a 100644 --- a/node/tools/src/bin/localnet_config.rs +++ b/node/tools/src/bin/localnet_config.rs @@ -3,7 +3,7 @@ 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_bft::testonly; use zksync_consensus_crypto::TextFmt; use zksync_consensus_executor::{ConsensusConfig, ExecutorConfig, GossipConfig}; use zksync_consensus_roles::{node, validator};