forked from paradigmxyz/reth
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate taiko support by adding L1 origin traits and updating…
… Cargo.toml configurations
- Loading branch information
Showing
40 changed files
with
518 additions
and
2,593 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#![allow(missing_docs)] | ||
|
||
#[global_allocator] | ||
static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::new_allocator(); | ||
|
||
use std::sync::Arc; | ||
|
||
use clap::{Args, Parser}; | ||
use reth::cli::Cli; | ||
use reth_chainspec::ChainSpec; | ||
use reth_cli::chainspec::{parse_genesis, ChainSpecParser}; | ||
use reth_node_builder::{ | ||
engine_tree_config::{ | ||
TreeConfig, DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD, | ||
}, | ||
EngineNodeLauncher, | ||
}; | ||
use reth_node_ethereum::{node::EthereumAddOns, EthereumNode}; | ||
use reth_provider::providers::BlockchainProvider2; | ||
use reth_taiko_chainspec::{get_taiko_genesis, TaikoChainSpec}; | ||
use reth_taiko_forks::{ | ||
CHAIN_HEKLA_TESTNET, CHAIN_INTERNAL_TESTNET, CHAIN_KATLA_TESTNET, CHAIN_MAINNET, | ||
}; | ||
use reth_tracing::tracing::warn; | ||
use tracing::info; | ||
|
||
/// Parameters for configuring the engine | ||
#[derive(Debug, Clone, Args, PartialEq, Eq)] | ||
#[command(next_help_heading = "Engine")] | ||
pub struct EngineArgs { | ||
/// Enable the experimental engine features on reth binary | ||
/// | ||
/// DEPRECATED: experimental engine is default now, use --engine.legacy to enable the legacy | ||
/// functionality | ||
#[arg(long = "engine.experimental", default_value = "false")] | ||
pub experimental: bool, | ||
|
||
/// Enable the legacy engine on reth binary | ||
#[arg(long = "engine.legacy", default_value = "false")] | ||
pub legacy: bool, | ||
|
||
/// Configure persistence threshold for engine experimental. | ||
#[arg(long = "engine.persistence-threshold", conflicts_with = "legacy", default_value_t = DEFAULT_PERSISTENCE_THRESHOLD)] | ||
pub persistence_threshold: u64, | ||
|
||
/// Configure the target number of blocks to keep in memory. | ||
#[arg(long = "engine.memory-block-buffer-target", conflicts_with = "legacy", default_value_t = DEFAULT_MEMORY_BLOCK_BUFFER_TARGET)] | ||
pub memory_block_buffer_target: u64, | ||
} | ||
|
||
impl Default for EngineArgs { | ||
fn default() -> Self { | ||
Self { | ||
experimental: false, | ||
legacy: false, | ||
persistence_threshold: DEFAULT_PERSISTENCE_THRESHOLD, | ||
memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
reth_cli_util::sigsegv_handler::install(); | ||
|
||
// Enable backtraces unless a RUST_BACKTRACE value has already been explicitly provided. | ||
if std::env::var_os("RUST_BACKTRACE").is_none() { | ||
std::env::set_var("RUST_BACKTRACE", "1"); | ||
} | ||
|
||
if let Err(err) = | ||
Cli::<TaikoChainSpecParser, EngineArgs>::parse().run(|builder, engine_args| async move { | ||
if engine_args.experimental { | ||
warn!(target: "reth::cli", "Experimental engine is default now, and the --engine.experimental flag is deprecated. To enable the legacy functionality, use --engine.legacy."); | ||
} | ||
|
||
let use_legacy_engine = engine_args.legacy; | ||
match use_legacy_engine { | ||
false => { | ||
let engine_tree_config = TreeConfig::default() | ||
.with_persistence_threshold(engine_args.persistence_threshold) | ||
.with_memory_block_buffer_target(engine_args.memory_block_buffer_target); | ||
let handle = builder | ||
.with_types_and_provider::<EthereumNode, BlockchainProvider2<_>>() | ||
.with_components(EthereumNode::components()) | ||
.with_add_ons(EthereumAddOns::default()) | ||
.launch_with_fn(|builder| { | ||
let launcher = EngineNodeLauncher::new( | ||
builder.task_executor().clone(), | ||
builder.config().datadir(), | ||
engine_tree_config, | ||
); | ||
builder.launch_with(launcher) | ||
}) | ||
.await?; | ||
handle.node_exit_future.await | ||
} | ||
true => { | ||
info!(target: "reth::cli", "Running with legacy engine"); | ||
let handle = builder.launch_node(EthereumNode::default()).await?; | ||
handle.node_exit_future.await | ||
} | ||
} | ||
}) | ||
{ | ||
eprintln!("Error: {err:?}"); | ||
std::process::exit(1); | ||
} | ||
} | ||
|
||
/// Optimism chain specification parser. | ||
#[derive(Debug, Clone, Default)] | ||
#[non_exhaustive] | ||
pub struct TaikoChainSpecParser; | ||
|
||
impl ChainSpecParser for TaikoChainSpecParser { | ||
type ChainSpec = ChainSpec; | ||
|
||
const SUPPORTED_CHAINS: &'static [&'static str] = | ||
&["hekla", "internal-a", "mainnet", "testnet"]; | ||
|
||
fn parse(s: &str) -> eyre::Result<Arc<Self::ChainSpec>> { | ||
chain_value_parser(s).map(|spec| Arc::new(spec.inner.clone())) | ||
} | ||
} | ||
|
||
/// Clap value parser for [`OpChainSpec`]s. | ||
/// | ||
/// The value parser matches either a known chain, the path | ||
/// to a json file, or a json formatted string in-memory. The json needs to be a Genesis struct. | ||
pub fn chain_value_parser(s: &str) -> eyre::Result<Arc<TaikoChainSpec>, eyre::Error> { | ||
Ok(Arc::new(match s { | ||
"hekla" => get_taiko_genesis(CHAIN_HEKLA_TESTNET).into(), | ||
"internal-a" => get_taiko_genesis(CHAIN_INTERNAL_TESTNET).into(), | ||
"mainnet" => get_taiko_genesis(CHAIN_MAINNET).into(), | ||
_ => parse_genesis(s)?.into(), | ||
})) | ||
} |
Oops, something went wrong.