Skip to content

Commit

Permalink
Added to tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoffranca committed Dec 12, 2024
1 parent c421ff6 commit 2a03c27
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion node/components/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions node/tools/src/bin/deployer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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,
validator_key: Some(validator_keys[i].clone()),
attester_key: Some(attester_keys[i].clone()),
node_key: node_keys[i].clone(),
Expand Down
1 change: 1 addition & 0 deletions node/tools/src/bin/localnet_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 8 additions & 0 deletions node/tools/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub struct App {

pub genesis: validator::Genesis,
pub max_payload_size: usize,
pub view_timeout: usize,
pub validator_key: Option<validator::SecretKey>,
pub attester_key: Option<attester::SecretKey>,

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

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

Expand Down
1 change: 1 addition & 0 deletions node/tools/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl Distribution<config::App> 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()),

Expand Down

0 comments on commit 2a03c27

Please sign in to comment.