Skip to content

Commit

Permalink
Fix PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoffranca committed Dec 13, 2024
1 parent 2a03c27 commit 22a0b65
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions node/components/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion node/components/executor/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
5 changes: 4 additions & 1 deletion node/tools/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
3 changes: 2 additions & 1 deletion node/tools/src/bin/deployer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -48,7 +49,7 @@ fn generate_consensus_nodes(nodes: usize, seed_nodes_amount: Option<usize>) -> 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(),
Expand Down
3 changes: 2 additions & 1 deletion node/tools/src/bin/localnet_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
12 changes: 4 additions & 8 deletions node/tools/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<validator::SecretKey>,
pub attester_key: Option<attester::SecretKey>,

Expand Down Expand Up @@ -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()),
Expand All @@ -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")?,
Expand All @@ -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),

Expand Down
3 changes: 2 additions & 1 deletion node/tools/src/proto/mod.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 22a0b65

Please sign in to comment.