-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ exclude = [".github/"] | |
|
||
[workspace] | ||
members = [ | ||
"bin/keth", | ||
"crates/node", | ||
"crates/pool", | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[package] | ||
name = "keth" | ||
version.workspace = true | ||
edition.workspace = true | ||
description.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
readme.workspace = true | ||
license.workspace = true | ||
rust-version.workspace = true | ||
exclude.workspace = true | ||
|
||
[dependencies] | ||
#Alloy | ||
alloy-genesis = { version = "0.1.2", default-features = false } | ||
|
||
# Kakarot | ||
kakarot-node.workspace = true | ||
|
||
# Reth | ||
reth-db = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.0.0", default-features = false } | ||
reth-chainspec = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.0.0", default-features = false } | ||
reth-cli-runner = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.0.0", default-features = false } | ||
reth-node-builder.workspace = true | ||
reth-node-core = { git = "https://github.com/paradigmxyz/reth.git", tag = "v1.0.0", default-features = false } | ||
reth-primitives.workspace = true | ||
|
||
# Tracing | ||
tracing = { version = "0.1.40", default-features = false } | ||
tracing-subscriber = { version = "0.3.18", default-features = false } | ||
|
||
# Other | ||
clap = { version = "4.5.9", features = ["derive"] } | ||
|
||
[lints] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
use clap::Parser; | ||
use tracing_subscriber::EnvFilter; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct Cli { | ||
#[command(flatten)] | ||
log: LogArgs, | ||
pub chain: ChainArgs, | ||
#[command(flatten)] | ||
pub log: LogArgs, | ||
} | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct LogArgs { | ||
#[clap(short, long, default_value = "info")] | ||
pub filter: String, | ||
} | ||
|
||
impl LogArgs { | ||
pub fn init_tracing(&self) { | ||
let filter = EnvFilter::builder().parse(&self.filter).expect("failed to parse filter"); | ||
tracing_subscriber::fmt().with_env_filter(filter).init(); | ||
} | ||
} | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct ChainArgs { | ||
#[clap(short, long, default_value = "1")] | ||
pub id: u64, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use alloy_genesis::Genesis; | ||
use clap::Parser; | ||
use kakarot_node::node::KakarotNode; | ||
use keth::cli::Cli; | ||
use reth_chainspec::{Chain, 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; | ||
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 data_dir = config.datadir(); | ||
let db_path = data_dir.db(); | ||
|
||
tracing::info!(target: "kkrt::cli", ?db_path, "Starting DB"); | ||
let database = | ||
Arc::new(init_db(db_path, config.db.database_args()).expect("failed to init db")); | ||
|
||
let builder = NodeBuilder::new(config).with_database(database); | ||
|
||
let runner = CliRunner::default(); | ||
runner | ||
.run_command_until_exit(|ctx| async { | ||
let builder = builder.with_launch_context(ctx.task_executor); | ||
let handle = builder.launch_node(KakarotNode::default()).await?; | ||
handle.node_exit_future.await | ||
}) | ||
.expect("failed to run command until exit") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters