diff --git a/crates/cdk-config/src/aggregator.rs b/crates/cdk-config/src/aggregator.rs index c38446b3..3a22a382 100644 --- a/crates/cdk-config/src/aggregator.rs +++ b/crates/cdk-config/src/aggregator.rs @@ -6,11 +6,11 @@ use url::Url; #[derive(Deserialize, Debug, Clone)] pub struct Aggregator { #[serde(rename = "ChainID")] - pub chain_id: u64, + pub chain_id: String, #[serde(rename = "Host")] pub host: String, #[serde(rename = "Port")] - pub port: u16, + pub port: String, #[serde(rename = "RetryTime")] pub retry_time: String, #[serde(rename = "VerifyProofInterval")] @@ -58,9 +58,9 @@ impl Default for Aggregator { fn default() -> Self { // Values are coming from https://github.com/0xPolygon/agglayer/blob/main/config/default.go#L11 Self { - chain_id: 1, + chain_id: "1".to_string(), host: "localhost".to_string(), - port: 8545, + port: "8545".to_string(), retry_time: "10s".to_string(), verify_proof_interval: "1m".to_string(), proof_state_polling_interval: "10s".to_string(), diff --git a/crates/cdk-config/src/l1.rs b/crates/cdk-config/src/l1.rs index 8add81f2..55fb2fb6 100644 --- a/crates/cdk-config/src/l1.rs +++ b/crates/cdk-config/src/l1.rs @@ -5,7 +5,7 @@ use serde::Deserialize; #[derive(Deserialize, Debug, Clone)] pub struct L1 { #[serde(rename = "L1ChainID")] - pub l1_chain_id: u64, + pub l1_chain_id: String, #[serde(rename = "PolAddr")] pub pol_addr: Address, #[serde(rename = "ZkEVMAddr")] @@ -21,7 +21,7 @@ impl Default for L1 { fn default() -> Self { // Values are coming from https://github.com/0xPolygon/agglayer/blob/main/config/default.go#L11 Self { - l1_chain_id: 1337, + l1_chain_id: "1337".to_string(), pol_addr: "0x5b06837A43bdC3dD9F114558DAf4B26ed49842Ed" .parse() .unwrap(), diff --git a/crates/cdk/src/cli.rs b/crates/cdk/src/cli.rs index 8087eb8b..2b18d92e 100644 --- a/crates/cdk/src/cli.rs +++ b/crates/cdk/src/cli.rs @@ -11,8 +11,7 @@ pub(crate) struct Cli { long, short, value_hint = ValueHint::FilePath, - global = true, - required = true, + // global = true, env = "CDK_CONFIG_PATH" )] pub(crate) config: PathBuf, @@ -22,8 +21,7 @@ pub(crate) struct Cli { long, short = 'g', value_hint = ValueHint::FilePath, - global = true, - required = true, + // global = true, env = "CDK_GENESIS_PATH" )] pub(crate) chain: PathBuf, diff --git a/crates/cdk/src/config_render.rs b/crates/cdk/src/config_render.rs index 69fc2e57..1eda037f 100644 --- a/crates/cdk/src/config_render.rs +++ b/crates/cdk/src/config_render.rs @@ -3,42 +3,41 @@ use std::fs; use std::path::PathBuf; use tempfile::{tempdir, TempDir}; -pub fn render(chain_id: u64, _genesis_file: PathBuf) -> Result { +pub fn render(chain_id: String, _genesis_file: PathBuf) -> Result { // Create a temporary directory let tmp_dir = tempdir()?; let res = crate::allocs_render::render_allocs("./tmp/cdk/genesis/genesis.json")?; // Write the three files to disk fs::write( - tmp_dir.path().join(format!( - "dynamic-{}-allocs.json", - chain_id.to_string().clone() - )), + tmp_dir + .path() + .join(format!("dynamic-{}-allocs.json", chain_id.clone())), res.output, )?; fs::write( tmp_dir .path() - .join(format!("dynamic-{}-chainspec.json", chain_id.to_string())), - render_chainspec(chain_id), + .join(format!("dynamic-{}-chainspec.json", chain_id.clone())), + render_chainspec(chain_id.clone()), )?; fs::write( tmp_dir .path() - .join(format!("dynamic-{}-conf.json", chain_id.to_string())), + .join(format!("dynamic-{}-conf.json", chain_id.clone())), render_conf(res.wrapper.root, 1000000000000000000), )?; fs::write( tmp_dir .path() - .join(format!("dynamic-{}.yaml", chain_id.to_string())), + .join(format!("dynamic-{}.yaml", chain_id.clone())), render_yaml(chain_id), )?; Ok(tmp_dir) } -fn render_chainspec(chain_id: u64) -> String { +fn render_chainspec(chain_id: String) -> String { format!( r#" {{ @@ -85,7 +84,7 @@ fn render_conf(root: String, gas_limit: u64) -> String { } // render_config renders the configuration file for the Erigon node. -fn render_yaml(chain_id: u64) -> String { +fn render_yaml(chain_id: String) -> String { format!( r#" datadir: ./data/dynamic-{} diff --git a/crates/cdk/src/main.rs b/crates/cdk/src/main.rs index e7917f1c..ef474298 100644 --- a/crates/cdk/src/main.rs +++ b/crates/cdk/src/main.rs @@ -94,7 +94,8 @@ pub fn node(config_path: PathBuf) -> anyhow::Result<()> { /// This function starts everything needed to run an Erigon node. pub fn erigon(config: Config, genesis_file: PathBuf) -> anyhow::Result<()> { // Render configuration files - let erigon_config_path = config_render::render(config.aggregator.chain_id, genesis_file)?; + let erigon_config_path = + config_render::render(config.aggregator.chain_id.clone(), genesis_file)?; debug!("Starting erigon with config: {:?}", erigon_config_path);