Skip to content

Commit

Permalink
Update constants
Browse files Browse the repository at this point in the history
  • Loading branch information
matias-gonz committed Sep 11, 2024
1 parent e3b4052 commit fabd6b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
12 changes: 6 additions & 6 deletions zk_toolbox/crates/zk_inception/src/consts.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::net::Ipv4Addr;
use std::net::{IpAddr, Ipv4Addr};

pub const AMOUNT_FOR_DISTRIBUTION_TO_WALLETS: u128 = 1000000000000000000000;

Expand All @@ -14,9 +14,9 @@ pub const L2_BASE_TOKEN_ADDRESS: &str = "0x0000000000000000000000000000000000008
#[allow(non_upper_case_globals)]
const kB: usize = 1024;

/// Max payload size for consensus
/// Max payload size for consensus in bytes
pub const MAX_PAYLOAD_SIZE: usize = 2_500_000;
/// Max batch size for consensus
/// Max batch size for consensus in bytes
/// Compute a default batch size, so operators are not caught out by the missing setting
/// while we're still working on batch syncing. The batch interval is ~1 minute,
/// so there will be ~60 blocks, and an Ethereum Merkle proof is ~1kB, but under high
Expand All @@ -25,12 +25,12 @@ pub const MAX_PAYLOAD_SIZE: usize = 2_500_000;
/// limit so as not to prevent any legitimate batch from being transmitted.
pub const MAX_BATCH_SIZE: usize = MAX_PAYLOAD_SIZE * 5000 + kB;
/// Gossip dynamic inbound limit for consensus
pub const GOSSIP_DYNAMIC_INBOUND_LIMIT: usize = 1;
pub const GOSSIP_DYNAMIC_INBOUND_LIMIT: usize = 100;

/// Public address for consensus
pub const CONSENSUS_PUBLIC_ADDRESS_HOST: Ipv4Addr = Ipv4Addr::new(0, 0, 0, 0);
pub const CONSENSUS_PUBLIC_ADDRESS_HOST: IpAddr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
/// Server address for consensus
pub const CONSENSUS_SERVER_ADDRESS_HOST: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1);
pub const CONSENSUS_SERVER_ADDRESS_HOST: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));

/// Path to the JS runtime config for the block-explorer-app docker container to be mounted to
pub const EXPLORER_APP_DOCKER_CONFIG_PATH: &str = "/usr/src/app/packages/app/dist/config.js";
Expand Down
29 changes: 10 additions & 19 deletions zk_toolbox/crates/zk_inception/src/utils/consensus.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::{BTreeMap, BTreeSet},
net::{IpAddr, SocketAddr},
net::SocketAddr,
};

use config::{ChainConfig, PortsConfig};
Expand All @@ -19,7 +19,7 @@ use crate::consts::{
};

#[derive(Debug, Clone)]
pub struct ConsensusKeys {
pub struct SecretKeys {
validator_key: roles::validator::SecretKey,
attester_key: roles::attester::SecretKey,
node_key: roles::node::SecretKey,
Expand All @@ -33,7 +33,7 @@ pub struct ConsensusPublicKeys {
pub fn get_consensus_config(
chain_config: &ChainConfig,
ports: PortsConfig,
consensus_keys: Option<ConsensusKeys>,
consensus_keys: Option<SecretKeys>,
gossip_static_outbound: Option<BTreeMap<NodePublicKey, Host>>,
) -> anyhow::Result<ConsensusConfig> {
let genesis_spec = if let Some(consensus_keys) = consensus_keys {
Expand All @@ -42,14 +42,8 @@ pub fn get_consensus_config(
None
};

let public_addr = SocketAddr::new(
IpAddr::V4(CONSENSUS_PUBLIC_ADDRESS_HOST),
ports.consensus_port,
);
let server_addr = SocketAddr::new(
IpAddr::V4(CONSENSUS_SERVER_ADDRESS_HOST),
ports.consensus_port,
);
let public_addr = SocketAddr::new(CONSENSUS_PUBLIC_ADDRESS_HOST, ports.consensus_port);
let server_addr = SocketAddr::new(CONSENSUS_SERVER_ADDRESS_HOST, ports.consensus_port);

Ok(ConsensusConfig {
server_addr,
Expand All @@ -64,25 +58,22 @@ pub fn get_consensus_config(
})
}

pub fn generate_consensus_keys() -> ConsensusKeys {
ConsensusKeys {
pub fn generate_consensus_keys() -> SecretKeys {
SecretKeys {
validator_key: roles::validator::SecretKey::generate(),
attester_key: roles::attester::SecretKey::generate(),
node_key: roles::node::SecretKey::generate(),
}
}

fn get_consensus_public_keys(consensus_keys: &ConsensusKeys) -> ConsensusPublicKeys {
fn get_consensus_public_keys(consensus_keys: &SecretKeys) -> ConsensusPublicKeys {
ConsensusPublicKeys {
validator_key: consensus_keys.validator_key.public(),
attester_key: consensus_keys.attester_key.public(),
}
}

pub fn get_genesis_specs(
chain_config: &ChainConfig,
consensus_keys: &ConsensusKeys,
) -> GenesisSpec {
pub fn get_genesis_specs(chain_config: &ChainConfig, consensus_keys: &SecretKeys) -> GenesisSpec {
let public_keys = get_consensus_public_keys(consensus_keys);
let validator_key = public_keys.validator_key.encode();
let attester_key = public_keys.attester_key.encode();
Expand All @@ -107,7 +98,7 @@ pub fn get_genesis_specs(
}
}

pub fn get_consensus_secrets(consensus_keys: &ConsensusKeys) -> ConsensusSecrets {
pub fn get_consensus_secrets(consensus_keys: &SecretKeys) -> ConsensusSecrets {
let validator_key = consensus_keys.validator_key.encode();
let attester_key = consensus_keys.attester_key.encode();
let node_key = consensus_keys.node_key.encode();
Expand Down

0 comments on commit fabd6b9

Please sign in to comment.