diff --git a/config/example-config.toml b/config/example-config.toml index 5a25940cc..6783ed912 100644 --- a/config/example-config.toml +++ b/config/example-config.toml @@ -30,7 +30,9 @@ GlobalQueue = 1024 L2GasPriceSuggesterFactor = 0.5 [Layer1] -URL = "http://localhost:8545" +ChainID = 1337 +NodeURL = "http://localhost:8545" +RollupManagerContract = "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e" ForkIDChunkSize = 20000 [EthTxManager] diff --git a/crates/cdk-config/src/lib.rs b/crates/cdk-config/src/lib.rs index 5be52619c..eda855242 100644 --- a/crates/cdk-config/src/lib.rs +++ b/crates/cdk-config/src/lib.rs @@ -3,15 +3,10 @@ //! The agglayer is configured via its TOML configuration file, `agglayer.toml` //! by default, which is deserialized into the [`Config`] struct. -use std::collections::HashMap; - use auth::deserialize_auth; use outbound::OutboundConfig; use serde::Deserialize; use shutdown::ShutdownConfig; -use url::Url; - -use self::{rpc::deserialize_rpc_map, telemetry::TelemetryConfig}; pub(crate) const DEFAULT_IP: std::net::Ipv4Addr = std::net::Ipv4Addr::new(0, 0, 0, 0); @@ -37,10 +32,6 @@ pub use rpc::RpcConfig; pub struct Config { /// A map of Zkevm node RPC endpoints for each rollup. /// - /// The key is the rollup ID, and the value is the URL of the associated RPC - /// endpoint. - #[serde(rename = "FullNodeRPCs", deserialize_with = "deserialize_rpc_map")] - pub full_node_rpcs: HashMap, /// The log configuration. #[serde(rename = "Log")] pub log: Log, @@ -56,10 +47,9 @@ pub struct Config { /// The authentication configuration. #[serde(alias = "EthTxManager", default, deserialize_with = "deserialize_auth")] pub auth: AuthConfig, - /// Telemetry configuration. - #[serde(rename = "Telemetry")] - pub telemetry: TelemetryConfig, - + // /// Telemetry configuration. + // #[serde(rename = "Telemetry")] + // pub telemetry: TelemetryConfig, /// The Epoch configuration. #[serde(rename = "Epoch", default = "Epoch::default")] pub epoch: Epoch, diff --git a/crates/cdk/build.rs b/crates/cdk/build.rs new file mode 100644 index 000000000..ad3430a59 --- /dev/null +++ b/crates/cdk/build.rs @@ -0,0 +1,37 @@ +use std::env; +use std::path::PathBuf; +use std::process::Command; + +fn main() { + // Determine the directory where the build script is located + let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let build_path = PathBuf::from(dir + "../../"); + + // Optionally, specify the directory where your Makefile is located + // For this example, it's assumed to be the same as the build script's directory + // If your Makefile is in a different directory, adjust `build_path` accordingly + + // Call the make command + let output = Command::new("make") + .current_dir(build_path) // Set the current directory for the command + .output() // Execute the command and capture the output + .expect("Failed to execute make command"); + + // Check the output and react accordingly + if !output.status.success() { + // If the make command failed, print the error and exit + let error_message = String::from_utf8_lossy(&output.stderr); + panic!("Make command failed with error: {}", error_message); + } + + // Optionally, print the output of the make command + println!( + "Make command output: {}", + String::from_utf8_lossy(&output.stdout) + ); + + // Here you can also add additional commands to inform Cargo about + // how to rerun the build script. For example, to rerun this script + // only when a specific file changes: + // println!("cargo:rerun-if-changed=path/to/file"); +} diff --git a/crates/cdk/src/cli.rs b/crates/cdk/src/cli.rs index 3e3c3d404..c3fc11c4b 100644 --- a/crates/cdk/src/cli.rs +++ b/crates/cdk/src/cli.rs @@ -14,7 +14,7 @@ pub(crate) struct Cli { pub(crate) enum Commands { Run { /// The path to the configuration file. - #[arg(long, short, value_hint = ValueHint::FilePath, default_value = "config/example-config.toml", env = "CONFIG_PATH")] + #[arg(long, short, value_hint = ValueHint::FilePath, default_value = "config/example-config.toml", env = "CDK_CONFIG_PATH")] cfg: PathBuf, }, } diff --git a/crates/cdk/src/main.rs b/crates/cdk/src/main.rs index 9e219cd95..0538a961c 100644 --- a/crates/cdk/src/main.rs +++ b/crates/cdk/src/main.rs @@ -2,12 +2,17 @@ use cdk_config::Config; use clap::Parser; use cli::Cli; +use execute::Execute; use std::path::PathBuf; +use std::process::Command; use std::sync::Arc; mod cli; mod logging; +const CDK_CLIENT_PATH: &str = "cdk-client"; +const CDK_ERIGON_PATH: &str = "cdk-erigon"; + fn main() -> anyhow::Result<()> { dotenvy::dotenv().ok(); @@ -32,6 +37,21 @@ pub fn run(cfg: PathBuf) -> anyhow::Result<()> { // Load the configuration file let config: Arc = Arc::new(toml::from_str(&std::fs::read_to_string(cfg)?)?); + // Run the node passing the parsed config values as flags + let mut command = Command::new(CDK_CLIENT_PATH); + + let output = command.execute_output().unwrap(); + + if let Some(exit_code) = output.status.code() { + if exit_code == 0 { + println!("Ok."); + } else { + eprintln!("Failed."); + } + } else { + eprintln!("Interrupted!"); + } + // Initialize the logger logging::tracing(&config.log);