Skip to content

Commit

Permalink
snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
pompon0 committed Nov 6, 2023
1 parent 15da463 commit e04d4e9
Show file tree
Hide file tree
Showing 86 changed files with 184 additions and 159 deletions.
4 changes: 2 additions & 2 deletions node/actors/consensus/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion node/actors/consensus/src/leader/replica_commit.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions node/actors/consensus/src/leader/replica_prepare.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions node/actors/consensus/src/leader/state_machine.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion node/actors/consensus/src/leader/tests.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions node/actors/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion node/actors/consensus/src/replica/block.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion node/actors/consensus/src/replica/leader_commit.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions node/actors/consensus/src/replica/leader_prepare.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion node/actors/consensus/src/replica/new_view.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 3 additions & 3 deletions node/actors/consensus/src/replica/state_machine.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 2 additions & 1 deletion node/actors/consensus/src/replica/tests.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
2 changes: 1 addition & 1 deletion node/actors/consensus/src/replica/timer.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion node/actors/consensus/src/testonly/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion node/actors/consensus/src/testonly/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion node/actors/consensus/src/testonly/node.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
7 changes: 4 additions & 3 deletions node/actors/consensus/src/testonly/run.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
1 change: 1 addition & 0 deletions node/actors/consensus/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions node/actors/executor/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion node/actors/executor/src/config/tests.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
6 changes: 4 additions & 2 deletions node/actors/executor/src/io.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
//! 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,
};
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
Expand Down
8 changes: 4 additions & 4 deletions node/actors/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions node/actors/executor/src/tests.rs
Original file line number Diff line number Diff line change
@@ -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<InMemoryStorage>) -> anyhow::Result<()> {
Expand Down
4 changes: 3 additions & 1 deletion node/actors/network/src/consensus/handshake/tests.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion node/actors/network/src/consensus/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion node/actors/network/src/consensus/state.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
5 changes: 3 additions & 2 deletions node/actors/network/src/consensus/tests.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
6 changes: 4 additions & 2 deletions node/actors/network/src/gossip/handshake/tests.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions node/actors/network/src/gossip/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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,
sync::{self, watch},
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.
Expand Down
4 changes: 2 additions & 2 deletions node/actors/network/src/gossip/state.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Loading

0 comments on commit e04d4e9

Please sign in to comment.