Skip to content

Commit

Permalink
Merge branch 'main' into weighted_validators
Browse files Browse the repository at this point in the history
  • Loading branch information
ElFantasma committed Mar 27, 2024
2 parents 6a650e7 + ce92795 commit a4dbbf6
Show file tree
Hide file tree
Showing 53 changed files with 811 additions and 471 deletions.
193 changes: 101 additions & 92 deletions node/Cargo.lock

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ zksync_protobuf = { path = "libs/protobuf" }
zksync_protobuf_build = { path = "libs/protobuf_build" }

# Crates from Matter Labs.
pairing = { package = "pairing_ce", git = "https://github.com/matter-labs/pairing.git", rev = "f55393fd366596eac792d78525d26e9c4d6ed1ca" }
pairing = { package = "pairing_ce", git = "https://github.com/matter-labs/pairing.git", rev = "d24f2c5871089c4cd4f54c0ca266bb9fef6115eb" }
vise = { version = "0.1.0", git = "https://github.com/matter-labs/vise.git", rev = "1c9cc500e92cf9ea052b230e114a6f9cce4fb2c1" }
vise-exporter = { version = "0.1.0", git = "https://github.com/matter-labs/vise.git", rev = "1c9cc500e92cf9ea052b230e114a6f9cce4fb2c1" }

Expand All @@ -54,7 +54,7 @@ clap = { version = "4.3.3", features = ["derive"] }
criterion = "0.5.1"
ed25519-dalek = { version = "2.0.0", features = ["rand_core"] }
ff_ce = "0.14.3"
heck = "0.4.1"
heck = "0.5.0"
hex = "0.4.3"
im = "15.1.0"
once_cell = "1.17.1"
Expand All @@ -73,6 +73,7 @@ rand04 = { package = "rand", version = "0.4" }
rocksdb = "0.21.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.95"
serde_yaml = "0.9"
sha3 = "0.10.8"
snow = "0.9.3"
syn = "2.0.17"
Expand Down Expand Up @@ -117,11 +118,9 @@ opt-level = 3

[workspace.lints.rust]
unsafe_code = "deny"
noop_method_call = "warn"
missing_docs = "warn"
unreachable_pub = "warn"
unused_qualifications = "warn"
unused_tuple_struct_fields = "warn"

[workspace.lints.clippy]
# restriction group
Expand Down
4 changes: 2 additions & 2 deletions node/actors/bft/src/leader/replica_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) enum Error {
NotLeaderInView,
/// Invalid message.
#[error("invalid message: {0:#}")]
InvalidMessage(anyhow::Error),
InvalidMessage(#[source] anyhow::Error),
/// Duplicate message from a replica.
#[error("duplicate message from a replica (existing message: {existing_message:?}")]
DuplicateMessage {
Expand All @@ -45,7 +45,7 @@ pub(crate) enum Error {
},
/// Invalid message signature.
#[error("invalid signature: {0:#}")]
InvalidSignature(#[source] validator::Error),
InvalidSignature(#[source] anyhow::Error),
}

impl StateMachine {
Expand Down
2 changes: 1 addition & 1 deletion node/actors/bft/src/leader/replica_prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub(crate) enum Error {
},
/// Invalid message signature.
#[error("invalid signature: {0:#}")]
InvalidSignature(#[source] validator::Error),
InvalidSignature(#[source] anyhow::Error),
/// Invalid message.
#[error(transparent)]
InvalidMessage(validator::ReplicaPrepareVerifyError),
Expand Down
2 changes: 1 addition & 1 deletion node/actors/bft/src/replica/leader_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub(crate) enum Error {
},
/// Invalid message signature.
#[error("invalid signature: {0:#}")]
InvalidSignature(validator::Error),
InvalidSignature(#[source] anyhow::Error),
/// Invalid message.
#[error("invalid message: {0:#}")]
InvalidMessage(validator::CommitQCVerifyError),
Expand Down
2 changes: 1 addition & 1 deletion node/actors/bft/src/replica/leader_prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub(crate) enum Error {
},
/// Invalid message signature.
#[error("invalid signature: {0:#}")]
InvalidSignature(#[source] validator::Error),
InvalidSignature(#[source] anyhow::Error),
/// Invalid message.
#[error("invalid message: {0:#}")]
InvalidMessage(#[source] validator::LeaderPrepareVerifyError),
Expand Down
1 change: 0 additions & 1 deletion node/actors/bft/src/testonly/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ async fn run_nodes(ctx: &ctx::Ctx, network: Network, specs: &[Node]) -> anyhow::
let mut nodes = vec![];
for (i, spec) in specs.iter().enumerate() {
let (node, runner) = network::testonly::Instance::new(
ctx,
spec.net.clone(),
spec.block_store.clone(),
);
Expand Down
4 changes: 2 additions & 2 deletions node/actors/bft/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use zksync_concurrency::{ctx, scope, time};
use zksync_consensus_roles::validator;

async fn run_test(behavior: Behavior, network: Network) {
let _guard = zksync_concurrency::testonly::set_timeout(time::Duration::seconds(20));
let _guard = zksync_concurrency::testonly::set_timeout(time::Duration::seconds(30));
zksync_concurrency::testonly::abort_on_panic();
let ctx = &ctx::test_root(&ctx::RealClock);

Expand All @@ -18,7 +18,7 @@ async fn run_test(behavior: Behavior, network: Network) {
Test {
network,
nodes,
blocks_to_finalize: 15,
blocks_to_finalize: 10,
}
.run(ctx)
.await
Expand Down
7 changes: 3 additions & 4 deletions node/actors/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct Config {
pub server_addr: std::net::SocketAddr,
/// Public TCP address that other nodes are expected to connect to.
/// It is announced over gossip network.
pub public_addr: std::net::SocketAddr,
pub public_addr: net::Host,
/// Maximal size of the block payload.
pub max_payload_size: usize,

Expand All @@ -59,7 +59,7 @@ pub struct Config {
pub gossip_static_inbound: HashSet<node::PublicKey>,
/// Outbound connections that the node should actively try to
/// establish and maintain.
pub gossip_static_outbound: HashMap<node::PublicKey, std::net::SocketAddr>,
pub gossip_static_outbound: HashMap<node::PublicKey, net::Host>,
}

impl Config {
Expand Down Expand Up @@ -90,7 +90,7 @@ impl Executor {
fn network_config(&self) -> network::Config {
network::Config {
server_addr: net::tcp::ListenerAddr::new(self.config.server_addr),
public_addr: self.config.public_addr,
public_addr: self.config.public_addr.clone(),
gossip: self.config.gossip(),
validator_key: self.validator.as_ref().map(|v| v.key.clone()),
ping_timeout: Some(time::Duration::seconds(10)),
Expand Down Expand Up @@ -136,7 +136,6 @@ impl Executor {
s.spawn_blocking(|| dispatcher.run(ctx).context("IO Dispatcher stopped"));
s.spawn(async {
let (net, runner) = network::Network::new(
ctx,
network_config,
self.block_store.clone(),
network_actor_pipe,
Expand Down
2 changes: 1 addition & 1 deletion node/actors/executor/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use zksync_consensus_storage::{
fn config(cfg: &network::Config) -> Config {
Config {
server_addr: *cfg.server_addr,
public_addr: cfg.public_addr,
public_addr: cfg.public_addr.clone(),
max_payload_size: usize::MAX,
node_key: cfg.gossip.key.clone(),
gossip_dynamic_inbound_limit: cfg.gossip.dynamic_inbound_limit,
Expand Down
7 changes: 5 additions & 2 deletions node/actors/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct GossipConfig {
pub static_inbound: HashSet<node::PublicKey>,
/// Outbound connections that the node should actively try to
/// establish and maintain.
pub static_outbound: HashMap<node::PublicKey, std::net::SocketAddr>,
pub static_outbound: HashMap<node::PublicKey, net::Host>,
}

/// Network actor config.
Expand All @@ -65,7 +65,10 @@ pub struct Config {
pub server_addr: net::tcp::ListenerAddr,
/// Public TCP address that other nodes are expected to connect to.
/// It is announced over gossip network.
pub public_addr: std::net::SocketAddr,
/// In case public_addr is a domain instead of ip, DNS resolution is
/// performed and a loopback connection is established before announcing
/// the IP address over the gossip network.
pub public_addr: net::Host,
/// Gossip network config.
pub gossip: GossipConfig,
/// Private key of the validator.
Expand Down
2 changes: 1 addition & 1 deletion node/actors/network/src/consensus/handshake/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub(super) enum Error {
#[error("unexpected peer")]
PeerMismatch,
#[error("validator signature {0}")]
Signature(#[from] validator::Error),
Signature(#[from] anyhow::Error),
#[error("stream {0}")]
Stream(#[source] anyhow::Error),
}
Expand Down
Loading

0 comments on commit a4dbbf6

Please sign in to comment.