Skip to content

Commit

Permalink
set node by default in dev mode with 12 sec block time
Browse files Browse the repository at this point in the history
  • Loading branch information
greged93 committed Jul 25, 2024
1 parent 512ade2 commit 124798d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
33 changes: 32 additions & 1 deletion bin/keth/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -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()
}
}
}
27 changes: 11 additions & 16 deletions bin/keth/src/main.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit 124798d

Please sign in to comment.