diff --git a/Cargo.lock b/Cargo.lock index 31e1f38..4bb1056 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2612,6 +2612,24 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hera" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "eyre", + "kona-derive", + "reth", + "reth-exex", + "reth-node-api", + "reth-node-ethereum", + "superchain-registry", + "tokio", + "tracing", + "url", +] + [[package]] name = "hermit-abi" version = "0.3.9" @@ -3342,24 +3360,6 @@ dependencies = [ "unsigned-varint 0.8.0", ] -[[package]] -name = "kona-exex" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "eyre", - "kona-derive", - "reth", - "reth-exex", - "reth-node-api", - "reth-node-ethereum", - "superchain-registry", - "tokio", - "tracing", - "url", -] - [[package]] name = "kona-primitives" version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index b1a6126..0bbdda9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,10 @@ categories = ["cryptography", "cryptography::cryptocurrencies"] [workspace] members = [ - "bin/kona-exex", + "bin/hera", "crates/kona-providers", ] -default-members = ["bin/kona-exex"] +default-members = ["bin/hera"] # Explicitly set the resolver to version 2, which is the default for packages with edition >= 2021 # https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html diff --git a/bin/kona-exex/Cargo.toml b/bin/hera/Cargo.toml similarity index 90% rename from bin/kona-exex/Cargo.toml rename to bin/hera/Cargo.toml index b33755f..4cfb709 100644 --- a/bin/kona-exex/Cargo.toml +++ b/bin/hera/Cargo.toml @@ -1,6 +1,7 @@ [package] -name = "kona-exex" +name = "hera" version = "0.1.0" +description = "Hera is a Rust implementation of the OP Stack Rollup Node" edition.workspace = true rust-version.workspace = true authors.workspace = true diff --git a/bin/kona-exex/src/cli.rs b/bin/hera/src/hera.rs similarity index 54% rename from bin/kona-exex/src/cli.rs rename to bin/hera/src/hera.rs index 3c9e7d8..38caaa0 100644 --- a/bin/kona-exex/src/cli.rs +++ b/bin/hera/src/hera.rs @@ -1,10 +1,54 @@ -//! CLI Extension module for Kona +//! Module for the Hera CLI and its subcommands. -use std::path::PathBuf; - -use clap::Args; +use clap::{Args, Parser, Subcommand}; +use eyre::{bail, Result}; +use reth::cli::Cli; +use reth_exex::ExExContext; +use reth_node_api::FullNodeComponents; +use reth_node_ethereum::EthereumNode; +use std::{path::PathBuf, sync::Arc}; +use superchain_registry::{RollupConfig, ROLLUP_CONFIGS}; use url::Url; +/// The top-level Hera CLI Command +#[derive(Debug, Parser)] +#[command(author, about = "Hera", long_about = None)] +pub struct HeraCli { + /// Hera's subcommands + #[command(subcommand)] + pub subcmd: HeraSubCmd, +} + +impl HeraCli { + /// Runs the Hera CLI + pub fn run(self) -> Result<()> { + match self.subcmd { + HeraSubCmd::ExEx(cli) => cli.run(|builder, args| async move { + let Some(cfg) = ROLLUP_CONFIGS.get(&args.l2_chain_id).cloned() else { + bail!("Rollup configuration not found for L2 chain ID: {}", args.l2_chain_id); + }; + let node = EthereumNode::default(); + let kona = + move |ctx| async { Ok(HeraExEx::new(ctx, args, Arc::new(cfg)).await.start()) }; + let handle = builder.node(node).install_exex(crate::EXEX_ID, kona).launch().await?; + handle.wait_for_node_exit().await + }), + HeraSubCmd::Bin => unimplemented!(), + } + } +} + +/// The Hera subcommands +#[derive(Debug, Subcommand)] +pub enum HeraSubCmd { + /// The Execution Extension + #[clap(name = "exex")] + ExEx(Cli), + /// A standalone rollup node binary. + #[clap(name = "bin")] + Bin, +} + /// The default L2 chain ID to use. This corresponds to OP Mainnet. pub const DEFAULT_L2_CHAIN_ID: u64 = 10; @@ -14,8 +58,9 @@ pub const DEFAULT_L2_RPC_URL: &str = "https://optimism.llamarpc.com/"; /// The default L1 Beacon Client RPC URL to use. pub const DEFAULT_L1_BEACON_CLIENT_URL: &str = "http://localhost:5052/"; +/// The Hera Execution Extension CLI Arguments. #[derive(Debug, Clone, Args)] -pub(crate) struct KonaArgsExt { +pub(crate) struct HeraArgsExt { /// Chain ID of the L2 network #[clap(long = "kona.l2-chain-id", default_value_t = DEFAULT_L2_CHAIN_ID)] pub l2_chain_id: u64, @@ -77,3 +122,26 @@ impl std::str::FromStr for ValidationMode { } } } + +/// The Hera Execution Extension. +#[derive(Debug)] +#[allow(unused)] +pub(crate) struct HeraExEx { + /// The rollup configuration + cfg: Arc, + /// The context of the Execution Extension + ctx: ExExContext, +} + +#[allow(unused)] +impl HeraExEx { + /// Creates a new instance of the Hera Execution Extension. + pub async fn new(ctx: ExExContext, args: HeraArgsExt, cfg: Arc) -> Self { + Self { ctx, cfg } + } + + /// Starts the Execution Extension loop. + pub async fn start(mut self) -> Result<()> { + unimplemented!() + } +} diff --git a/bin/hera/src/main.rs b/bin/hera/src/main.rs new file mode 100644 index 0000000..7abe6b0 --- /dev/null +++ b/bin/hera/src/main.rs @@ -0,0 +1,12 @@ +use clap::Parser; +use eyre::Result; + +mod hera; +use hera::HeraCli; + +/// The identifier of the Hera Execution Extension. +const EXEX_ID: &str = "hera"; + +fn main() -> Result<()> { + HeraCli::parse().run() +} diff --git a/bin/kona-exex/src/kona.rs b/bin/kona-exex/src/kona.rs deleted file mode 100644 index 1d099ff..0000000 --- a/bin/kona-exex/src/kona.rs +++ /dev/null @@ -1,31 +0,0 @@ -use std::sync::Arc; - -use eyre::Result; -use reth_exex::ExExContext; -use reth_node_api::FullNodeComponents; -use superchain_registry::RollupConfig; - -use crate::cli::KonaArgsExt; - -/// The Kona Execution Extension. -#[derive(Debug)] -#[allow(unused)] -pub(crate) struct KonaExEx { - /// The rollup configuration - cfg: Arc, - /// The context of the Execution Extension - ctx: ExExContext, -} - -#[allow(unused)] -impl KonaExEx { - /// Creates a new instance of the Kona Execution Extension. - pub async fn new(ctx: ExExContext, args: KonaArgsExt, cfg: Arc) -> Self { - Self { ctx, cfg } - } - - /// Starts the Kona Execution Extension loop. - pub async fn start(mut self) -> Result<()> { - unimplemented!() - } -} diff --git a/bin/kona-exex/src/main.rs b/bin/kona-exex/src/main.rs deleted file mode 100644 index 023a564..0000000 --- a/bin/kona-exex/src/main.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::sync::Arc; - -use clap::Parser; -use eyre::{bail, Result}; -use reth::cli::Cli; -use reth_node_ethereum::EthereumNode; -use superchain_registry::ROLLUP_CONFIGS; - -mod kona; -use kona::KonaExEx; - -mod cli; -use cli::KonaArgsExt; - -/// The identifier of the Kona Execution Extension. -const EXEX_ID: &str = "kona"; - -fn main() -> Result<()> { - Cli::::parse().run(|builder, args| async move { - let Some(cfg) = ROLLUP_CONFIGS.get(&args.l2_chain_id).cloned() else { - bail!("Rollup configuration not found for L2 chain ID: {}", args.l2_chain_id); - }; - - let node = EthereumNode::default(); - let kona = move |ctx| async { Ok(KonaExEx::new(ctx, args, Arc::new(cfg)).await.start()) }; - let handle = builder.node(node).install_exex(EXEX_ID, kona).launch().await?; - handle.wait_for_node_exit().await - }) -}