diff --git a/bin/keth/src/cli/mod.rs b/bin/keth/src/cli/mod.rs index b1d66962..376653fa 100644 --- a/bin/keth/src/cli/mod.rs +++ b/bin/keth/src/cli/mod.rs @@ -1,4 +1,9 @@ +use alloy_genesis::Genesis; use clap::Parser; +use reth_chainspec::{Chain, ChainSpec}; +use reth_node_core::args::DevArgs; +use reth_primitives::Address; +use std::{str::FromStr, time::Duration}; use tracing_subscriber::EnvFilter; #[derive(Debug, Parser)] @@ -24,6 +29,32 @@ impl LogArgs { #[derive(Debug, Parser)] pub struct ChainArgs { - #[clap(short, long, default_value = "1")] + #[clap(short, long, default_value = "1802203764")] pub id: u64, + #[clap(short, long, default_value = "12")] + pub block_time: u64, +} + +impl From<&ChainArgs> for ChainSpec { + fn from(args: &ChainArgs) -> Self { + let chain_id = args.id; + ChainSpec::builder() + .cancun_activated() + .chain(Chain::from_id(chain_id)) + .genesis(Genesis::clique_genesis( + chain_id, + Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(), + )) + .build() + } +} + +impl From<&ChainArgs> for DevArgs { + fn from(args: &ChainArgs) -> Self { + DevArgs { + dev: true, + block_time: Some(Duration::from_secs(args.block_time)), + ..Default::default() + } + } } diff --git a/bin/keth/src/main.rs b/bin/keth/src/main.rs index 005e7b3d..1befc6c2 100644 --- a/bin/keth/src/main.rs +++ b/bin/keth/src/main.rs @@ -1,31 +1,26 @@ -use alloy_genesis::Genesis; use clap::Parser; use kakarot_node::node::KakarotNode; use keth::cli::Cli; -use reth_chainspec::{Chain, ChainSpec}; +use reth_chainspec::ChainSpec; use reth_cli_runner::CliRunner; use reth_db::init_db; use reth_node_builder::{NodeBuilder, NodeConfig}; use reth_node_core::args::RpcServerArgs; -use reth_primitives::Address; -use std::{str::FromStr, sync::Arc}; +use std::sync::Arc; fn main() { let args = Cli::parse(); args.log.init_tracing(); - let chain_id = args.chain.id; - let chain = ChainSpec::builder() - .cancun_activated() - .chain(Chain::from_id(chain_id)) - .genesis(Genesis::clique_genesis( - chain_id, - Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(), - )) - .build(); - - let config = - NodeConfig::default().with_chain(chain).with_rpc(RpcServerArgs::default().with_http()); + let chain_args = args.chain; + + let chain_spec: ChainSpec = (&chain_args).into(); + let dev_args = (&chain_args).into(); + + let config = NodeConfig::default() + .with_chain(chain_spec) + .with_rpc(RpcServerArgs::default().with_http()) + .with_dev(dev_args); let data_dir = config.datadir(); let db_path = data_dir.db();