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: split reth and hera binaries #23

Merged
merged 7 commits into from
Aug 25, 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
31 changes: 28 additions & 3 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ categories = ["cryptography", "cryptography::cryptocurrencies"]
[workspace]
members = [
"bin/hera",
"bin/op-rs",
"crates/rollup",
"crates/kona-providers",
"crates/ser",
]
Expand Down
7 changes: 0 additions & 7 deletions bin/hera/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
# Local Dependencies
kona-providers = { path = "../../crates/kona-providers" }

# Workspace
eyre.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
Expand All @@ -28,10 +25,6 @@ reth-node-ethereum.workspace = true

# OP Stack Dependencies
superchain-registry = { workspace = true, default-features = false }
kona-derive = { workspace = true, features = ["online", "serde"] }

# Needed for compatibility with Kona's ChainProvider trait
anyhow = { version = "1.0.86", default-features = false }

# Misc
url = "2.5.2"
175 changes: 0 additions & 175 deletions bin/hera/src/hera.rs

This file was deleted.

11 changes: 3 additions & 8 deletions bin/hera/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
//! Hera OP Stack Rollup node

#![doc = include_str!("../README.md")]
#![doc(issue_tracker_base_url = "https://github.com/paradigmxyz/op-rs/issues/")]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

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()
unimplemented!()
}
26 changes: 26 additions & 0 deletions bin/op-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "op-rs"
version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true

[dependencies]
# Local Dependencies
rollup = { path = "../../crates/rollup" }

# Workspace
eyre.workspace = true
tracing.workspace = true
clap.workspace = true

# Reth Dependencies
reth.workspace = true
reth-node-ethereum.workspace = true

# OP Stack Dependencies
superchain-registry = { workspace = true, default-features = false }
1 change: 1 addition & 0 deletions bin/op-rs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# `op-rs` binary
56 changes: 56 additions & 0 deletions bin/op-rs/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//! Runner for OP-RS execution extensions

#![doc = include_str!("../README.md")]
#![doc(issue_tracker_base_url = "https://github.com/paradigmxyz/op-rs/issues/")]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use std::sync::Arc;

use clap::Parser;
use eyre::{bail, Result};
use reth::cli::Cli;
use reth_node_ethereum::EthereumNode;
use rollup::{Driver, HeraArgsExt, HERA_EXEX_ID};
use superchain_registry::ROLLUP_CONFIGS;
use tracing::{info, warn};

/// The Reth CLI arguments with optional Hera Execution Extension support.
#[derive(Debug, Clone, Parser)]
pub(crate) struct RethArgsExt {
/// Whether to install the Hera Execution Extension.
///
/// Additional Hera-specific flags will be parsed if this flag is set.
#[clap(long, default_value_t = false)]
pub hera: bool,
/// The Hera Execution Extension configuration.
///
/// This is only used if the `hera` flag is set.
#[clap(flatten)]
pub hera_config: Option<HeraArgsExt>,
}

fn main() -> Result<()> {
Cli::<RethArgsExt>::parse().run(|builder, args| async move {
if args.hera {
info!("Running Reth with the Hera Execution Extension");
let Some(hera_args) = args.hera_config else {
bail!("Hera Execution Extension configuration is required when the `hera` flag is set");
};

let Some(cfg) = ROLLUP_CONFIGS.get(&hera_args.l2_chain_id).cloned().map(Arc::new) else {
bail!("Rollup configuration not found for L2 chain ID: {}", hera_args.l2_chain_id);
};

let node = EthereumNode::default();
let hera = move |ctx| async { Ok(Driver::new(ctx, hera_args, cfg).await.start()) };
let handle = builder.node(node).install_exex(HERA_EXEX_ID, hera).launch().await?;
handle.wait_for_node_exit().await
} else {
warn!("Running Reth without the Hera Execution Extension");
let node = EthereumNode::default();
let handle = builder.node(node).launch().await?;
handle.wait_for_node_exit().await
}
})
}
8 changes: 3 additions & 5 deletions crates/kona-providers/src/chain_provider.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Chain Provider

use alloc::{collections::vec_deque::VecDeque, sync::Arc};
use alloy_rlp::Decodable;
use hashbrown::HashMap;

use alloy::{
Expand All @@ -9,6 +10,7 @@ use alloy::{
TxLegacy,
},
primitives::B256,
signers::Signature,
};
use async_trait::async_trait;
use kona_derive::traits::ChainProvider;
Expand Down Expand Up @@ -188,11 +190,7 @@ impl InMemoryChainProviderInner {
.flat_map(|tx| {
let mut buf = Vec::new();
tx.signature.encode(&mut buf);
use alloy_rlp::Decodable;
let sig = match alloy::primitives::Signature::decode(&mut buf.as_slice()) {
Ok(s) => s,
Err(_) => return None,
};
let sig = Signature::decode(&mut buf.as_slice()).ok()?;
let new = match &tx.transaction {
Transaction::Legacy(l) => {
let legacy_tx = TxLegacy {
Expand Down
Loading