Skip to content

Commit

Permalink
feat(hera): Rename bin to hera and allow standalone bin
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Aug 23, 2024
1 parent 187c835 commit d81b383
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 85 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion bin/kona-exex/Cargo.toml → bin/hera/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
77 changes: 73 additions & 4 deletions bin/kona-exex/src/cli.rs → bin/hera/src/hera.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,54 @@
//! CLI Extension module for Kona
//! Module for the Hera CLI and its subcommands.
use url::Url;
use std::sync::Arc;
use std::path::PathBuf;
use eyre::{bail, Result};
use reth::cli::Cli;
use reth_exex::ExExContext;
use reth_node_api::FullNodeComponents;
use superchain_registry::RollupConfig;
use clap::{Parser, Args, Subcommand};
use reth_node_ethereum::EthereumNode;
use superchain_registry::ROLLUP_CONFIGS;

use clap::Args;
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<HeraArgsExt>),
/// 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;
Expand All @@ -14,8 +59,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,
Expand Down Expand Up @@ -77,3 +123,26 @@ impl std::str::FromStr for ValidationMode {
}
}
}

/// The Hera Execution Extension.
#[derive(Debug)]
#[allow(unused)]
pub(crate) struct HeraExEx<Node: FullNodeComponents> {
/// The rollup configuration
cfg: Arc<RollupConfig>,
/// The context of the Execution Extension
ctx: ExExContext<Node>,
}

#[allow(unused)]
impl<Node: FullNodeComponents> HeraExEx<Node> {
/// Creates a new instance of the Hera Execution Extension.
pub async fn new(ctx: ExExContext<Node>, args: HeraArgsExt, cfg: Arc<RollupConfig>) -> Self {
Self { ctx, cfg }
}

/// Starts the Execution Extension loop.
pub async fn start(mut self) -> Result<()> {
unimplemented!()
}
}
12 changes: 12 additions & 0 deletions bin/hera/src/main.rs
Original file line number Diff line number Diff line change
@@ -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()
}
31 changes: 0 additions & 31 deletions bin/kona-exex/src/kona.rs

This file was deleted.

29 changes: 0 additions & 29 deletions bin/kona-exex/src/main.rs

This file was deleted.

0 comments on commit d81b383

Please sign in to comment.