From 22a0b659a33839e1f35be9f6198ebf45cd713721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 13 Dec 2024 16:51:09 +0000 Subject: [PATCH] Fix PR comments. --- node/components/executor/src/lib.rs | 4 ++-- node/components/executor/src/tests.rs | 2 +- node/tools/build.rs | 5 ++++- node/tools/src/bin/deployer.rs | 3 ++- node/tools/src/bin/localnet_config.rs | 3 ++- node/tools/src/config.rs | 12 ++++-------- node/tools/src/proto/mod.proto | 3 ++- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/node/components/executor/src/lib.rs b/node/components/executor/src/lib.rs index e83f24d5..4f025c3d 100644 --- a/node/components/executor/src/lib.rs +++ b/node/components/executor/src/lib.rs @@ -40,7 +40,7 @@ pub struct Config { /// Maximal size of the block payload. pub max_payload_size: usize, /// The duration of the view timeout, in milliseconds. - pub view_timeout: usize, + pub view_timeout: time::Duration, /// Key of this node. It uniquely identifies the node. /// It should match the secret key provided in the `node_key` file. pub node_key: node::SecretKey, @@ -159,7 +159,7 @@ impl Executor { replica_store: validator.replica_store, payload_manager: validator.payload_manager, max_payload_size: self.config.max_payload_size, - view_timeout: time::Duration::milliseconds(self.config.view_timeout as i64), + view_timeout: self.config.view_timeout, } .run(ctx, network_send, consensus_recv) .await diff --git a/node/components/executor/src/tests.rs b/node/components/executor/src/tests.rs index 39f21c2e..3c3fcee3 100644 --- a/node/components/executor/src/tests.rs +++ b/node/components/executor/src/tests.rs @@ -18,7 +18,7 @@ fn config(cfg: &network::Config) -> Config { server_addr: *cfg.server_addr, public_addr: cfg.public_addr.clone(), max_payload_size: usize::MAX, - view_timeout: 1000, + view_timeout: time::Duration::milliseconds(1000), node_key: cfg.gossip.key.clone(), gossip_dynamic_inbound_limit: cfg.gossip.dynamic_inbound_limit, gossip_static_inbound: cfg.gossip.static_inbound.clone(), diff --git a/node/tools/build.rs b/node/tools/build.rs index f4cfa5df..b4d62f2c 100644 --- a/node/tools/build.rs +++ b/node/tools/build.rs @@ -3,7 +3,10 @@ fn main() { zksync_protobuf_build::Config { input_root: "src/proto".into(), proto_root: "zksync/tools".into(), - dependencies: vec!["::zksync_consensus_roles::proto".parse().unwrap()], + dependencies: vec![ + "::zksync_protobuf::proto".parse().unwrap(), + "::zksync_consensus_roles::proto".parse().unwrap(), + ], protobuf_crate: "::zksync_protobuf".parse().unwrap(), is_public: false, } diff --git a/node/tools/src/bin/deployer.rs b/node/tools/src/bin/deployer.rs index 3a35b038..addbffc2 100644 --- a/node/tools/src/bin/deployer.rs +++ b/node/tools/src/bin/deployer.rs @@ -4,6 +4,7 @@ use std::{ collections::HashMap, net::{Ipv4Addr, SocketAddr}, }; +use zksync_concurrency::time; use zksync_consensus_roles::{node::SecretKey, validator}; use zksync_consensus_tools::{config, k8s, k8s::ConsensusNode}; @@ -48,7 +49,7 @@ fn generate_consensus_nodes(nodes: usize, seed_nodes_amount: Option) -> V metrics_server_addr: None, genesis: setup.genesis.clone(), max_payload_size: 1000000, - view_timeout: 2000, + view_timeout: time::Duration::milliseconds(2000), validator_key: Some(validator_keys[i].clone()), attester_key: Some(attester_keys[i].clone()), node_key: node_keys[i].clone(), diff --git a/node/tools/src/bin/localnet_config.rs b/node/tools/src/bin/localnet_config.rs index c42c6a31..a35841f4 100644 --- a/node/tools/src/bin/localnet_config.rs +++ b/node/tools/src/bin/localnet_config.rs @@ -9,6 +9,7 @@ use std::{ os::unix::fs::PermissionsExt, path::PathBuf, }; +use zksync_concurrency::time; use zksync_consensus_roles::{node, validator}; use zksync_consensus_tools::config; use zksync_protobuf::serde::Serialize; @@ -76,7 +77,7 @@ fn main() -> anyhow::Result<()> { .map(|port| SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), port)), genesis: setup.genesis.clone(), max_payload_size: 1000000, - view_timeout: 2000, + view_timeout: time::Duration::milliseconds(2000), node_key: node_keys[i].clone(), validator_key: validator_keys.get(i).cloned(), attester_key: attester_keys.get(i).cloned(), diff --git a/node/tools/src/config.rs b/node/tools/src/config.rs index 48b62a96..b8cef4b7 100644 --- a/node/tools/src/config.rs +++ b/node/tools/src/config.rs @@ -9,7 +9,7 @@ use std::{ sync::Arc, }; use tokio_rustls::rustls::pki_types::{CertificateDer, PrivateKeyDer}; -use zksync_concurrency::{ctx, net}; +use zksync_concurrency::{ctx, net, time}; use zksync_consensus_bft as bft; use zksync_consensus_crypto::{read_optional_text, read_required_text, Text, TextFmt}; use zksync_consensus_executor::{self as executor, attestation}; @@ -76,7 +76,7 @@ pub struct App { pub genesis: validator::Genesis, pub max_payload_size: usize, - pub view_timeout: usize, + pub view_timeout: time::Duration, pub validator_key: Option, pub attester_key: Option, @@ -168,10 +168,6 @@ impl ProtoFmt for App { .and_then(|x| Ok((*x).try_into()?)) .context("max_payload_size")?; - let view_timeout = required(&r.view_timeout) - .and_then(|x| Ok((*x).try_into()?)) - .context("view_timeout")?; - Ok(Self { server_addr: read_required_text(&r.server_addr).context("server_addr")?, public_addr: net::Host(required(&r.public_addr).context("public_addr")?.clone()), @@ -181,7 +177,7 @@ impl ProtoFmt for App { genesis: read_required(&r.genesis).context("genesis")?, max_payload_size, - view_timeout, + view_timeout: read_required(&r.view_timeout).context("view_timeout")?, // TODO: read secret. validator_key: read_optional_secret_text(&r.validator_secret_key) .context("validator_secret_key")?, @@ -207,7 +203,7 @@ impl ProtoFmt for App { genesis: Some(self.genesis.build()), max_payload_size: Some(self.max_payload_size.try_into().unwrap()), - view_timeout: Some(self.view_timeout.try_into().unwrap()), + view_timeout: Some(self.view_timeout.build()), validator_secret_key: self.validator_key.as_ref().map(TextFmt::encode), attester_secret_key: self.attester_key.as_ref().map(TextFmt::encode), diff --git a/node/tools/src/proto/mod.proto b/node/tools/src/proto/mod.proto index a8a3514d..5e9c85a1 100644 --- a/node/tools/src/proto/mod.proto +++ b/node/tools/src/proto/mod.proto @@ -41,6 +41,7 @@ syntax = "proto3"; package zksync.tools; import "zksync/roles/validator.proto"; +import "zksync/std.proto"; // (public key, ip address) of a gossip network node. message NodeAddr { @@ -99,7 +100,7 @@ message AppConfig { optional uint64 max_payload_size = 5; // required; bytes // The duration of the view timeout. - optional uint64 view_timeout = 19; // required; milliseconds + optional std.Duration view_timeout = 19; // required; milliseconds // Validator secret key. optional string validator_secret_key = 10; // optional; ValidatorSecretKey