From 2a03c2744331a15bb67b1f2f685884adc62fa411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Thu, 12 Dec 2024 16:27:27 +0000 Subject: [PATCH] Added to tools. --- node/components/executor/src/lib.rs | 2 +- node/tools/src/bin/deployer.rs | 1 + node/tools/src/bin/localnet_config.rs | 1 + node/tools/src/config.rs | 8 ++++++++ node/tools/src/proto/mod.proto | 3 +++ node/tools/src/tests.rs | 1 + 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/node/components/executor/src/lib.rs b/node/components/executor/src/lib.rs index f3c4fb44..e83f24d5 100644 --- a/node/components/executor/src/lib.rs +++ b/node/components/executor/src/lib.rs @@ -39,7 +39,7 @@ pub struct Config { pub public_addr: net::Host, /// Maximal size of the block payload. pub max_payload_size: usize, - /// The duration of the view timeout, in milliseconds + /// The duration of the view timeout, in milliseconds. pub view_timeout: usize, /// Key of this node. It uniquely identifies the node. /// It should match the secret key provided in the `node_key` file. diff --git a/node/tools/src/bin/deployer.rs b/node/tools/src/bin/deployer.rs index bd5ee64f..3a35b038 100644 --- a/node/tools/src/bin/deployer.rs +++ b/node/tools/src/bin/deployer.rs @@ -48,6 +48,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, 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 0769a62f..c42c6a31 100644 --- a/node/tools/src/bin/localnet_config.rs +++ b/node/tools/src/bin/localnet_config.rs @@ -76,6 +76,7 @@ fn main() -> anyhow::Result<()> { .map(|port| SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), port)), genesis: setup.genesis.clone(), max_payload_size: 1000000, + view_timeout: 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 8399e036..48b62a96 100644 --- a/node/tools/src/config.rs +++ b/node/tools/src/config.rs @@ -76,6 +76,7 @@ pub struct App { pub genesis: validator::Genesis, pub max_payload_size: usize, + pub view_timeout: usize, pub validator_key: Option, pub attester_key: Option, @@ -167,6 +168,10 @@ 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()), @@ -176,6 +181,7 @@ impl ProtoFmt for App { genesis: read_required(&r.genesis).context("genesis")?, max_payload_size, + view_timeout, // TODO: read secret. validator_key: read_optional_secret_text(&r.validator_secret_key) .context("validator_secret_key")?, @@ -201,6 +207,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()), validator_secret_key: self.validator_key.as_ref().map(TextFmt::encode), attester_secret_key: self.attester_key.as_ref().map(TextFmt::encode), @@ -270,6 +277,7 @@ impl Configs { gossip_static_inbound: self.app.gossip_static_inbound.clone(), gossip_static_outbound: self.app.gossip_static_outbound.clone(), max_payload_size: self.app.max_payload_size, + view_timeout: self.app.view_timeout, rpc: executor::RpcConfig::default(), debug_page: self .app diff --git a/node/tools/src/proto/mod.proto b/node/tools/src/proto/mod.proto index 95091d77..a8a3514d 100644 --- a/node/tools/src/proto/mod.proto +++ b/node/tools/src/proto/mod.proto @@ -98,6 +98,9 @@ message AppConfig { // Maximal size of the block payload. optional uint64 max_payload_size = 5; // required; bytes + // The duration of the view timeout. + optional uint64 view_timeout = 19; // required; milliseconds + // Validator secret key. optional string validator_secret_key = 10; // optional; ValidatorSecretKey diff --git a/node/tools/src/tests.rs b/node/tools/src/tests.rs index 9381700c..9bd7b4fc 100644 --- a/node/tools/src/tests.rs +++ b/node/tools/src/tests.rs @@ -18,6 +18,7 @@ impl Distribution for EncodeDist { genesis: rng.gen(), max_payload_size: rng.gen(), + view_timeout: rng.gen(), validator_key: self.sample_opt(|| rng.gen()), attester_key: self.sample_opt(|| rng.gen()),