Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hera): kona-exex Rename and Standalone Binary #17

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
78 changes: 73 additions & 5 deletions bin/kona-exex/src/cli.rs → bin/hera/src/hera.rs
Original file line number Diff line number Diff line change
@@ -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<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 +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,
Expand Down Expand Up @@ -77,3 +122,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.