mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add --engine.experimental flag to enable engine2 (#10051)
This commit is contained in:
@ -152,10 +152,6 @@ ethereum = []
|
|||||||
name = "reth"
|
name = "reth"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "engine2"
|
|
||||||
path = "src/engine2.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "op-reth"
|
name = "op-reth"
|
||||||
path = "src/optimism.rs"
|
path = "src/optimism.rs"
|
||||||
|
|||||||
@ -1,40 +0,0 @@
|
|||||||
#![allow(missing_docs)]
|
|
||||||
#![allow(rustdoc::missing_crate_level_docs)]
|
|
||||||
|
|
||||||
// We use jemalloc for performance reasons.
|
|
||||||
#[cfg(all(feature = "jemalloc", unix))]
|
|
||||||
#[global_allocator]
|
|
||||||
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "optimism"))]
|
|
||||||
fn main() {
|
|
||||||
use reth::cli::Cli;
|
|
||||||
use reth_node_ethereum::{launch::EthNodeLauncher, node::EthereumAddOns, EthereumNode};
|
|
||||||
use reth_provider::providers::BlockchainProvider2;
|
|
||||||
|
|
||||||
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::parse_args().run(|builder, _| async {
|
|
||||||
let handle = builder
|
|
||||||
.with_types_and_provider::<EthereumNode, BlockchainProvider2<_>>()
|
|
||||||
.with_components(EthereumNode::components())
|
|
||||||
.with_add_ons::<EthereumAddOns>()
|
|
||||||
.launch_with_fn(|builder| {
|
|
||||||
let launcher = EthNodeLauncher::new(
|
|
||||||
builder.task_executor().clone(),
|
|
||||||
builder.config().datadir(),
|
|
||||||
);
|
|
||||||
builder.launch_with(launcher)
|
|
||||||
})
|
|
||||||
.await?;
|
|
||||||
handle.node_exit_future.await
|
|
||||||
}) {
|
|
||||||
eprintln!("Error: {err:?}");
|
|
||||||
std::process::exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -8,10 +8,24 @@ static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
|||||||
#[cfg(all(feature = "optimism", not(test)))]
|
#[cfg(all(feature = "optimism", not(test)))]
|
||||||
compile_error!("Cannot build the `reth` binary with the `optimism` feature flag enabled. Did you mean to build `op-reth`?");
|
compile_error!("Cannot build the `reth` binary with the `optimism` feature flag enabled. Did you mean to build `op-reth`?");
|
||||||
|
|
||||||
|
/// clap [Args] for Engine related arguments.
|
||||||
|
use clap::Args;
|
||||||
|
|
||||||
|
/// Parameters for configuring the engine
|
||||||
|
#[derive(Debug, Clone, Args, PartialEq, Eq, Default)]
|
||||||
|
#[command(next_help_heading = "Engine")]
|
||||||
|
pub struct EngineArgs {
|
||||||
|
/// Enable the engine2 experimental features on reth binary
|
||||||
|
#[arg(long = "engine.experimental", default_value = "false")]
|
||||||
|
pub experimental: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "optimism"))]
|
#[cfg(not(feature = "optimism"))]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
use clap::Parser;
|
||||||
use reth::cli::Cli;
|
use reth::cli::Cli;
|
||||||
use reth_node_ethereum::EthereumNode;
|
use reth_node_ethereum::{launch::EthNodeLauncher, node::EthereumAddOns, EthereumNode};
|
||||||
|
use reth_provider::providers::BlockchainProvider2;
|
||||||
|
|
||||||
reth_cli_util::sigsegv_handler::install();
|
reth_cli_util::sigsegv_handler::install();
|
||||||
|
|
||||||
@ -20,11 +34,51 @@ fn main() {
|
|||||||
std::env::set_var("RUST_BACKTRACE", "1");
|
std::env::set_var("RUST_BACKTRACE", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = Cli::parse_args().run(|builder, _| async {
|
if let Err(err) = Cli::<EngineArgs>::parse().run(|builder, engine_args| async move {
|
||||||
let handle = builder.launch_node(EthereumNode::default()).await?;
|
let enable_engine2 = engine_args.experimental;
|
||||||
handle.node_exit_future.await
|
match enable_engine2 {
|
||||||
|
true => {
|
||||||
|
let handle = builder
|
||||||
|
.with_types_and_provider::<EthereumNode, BlockchainProvider2<_>>()
|
||||||
|
.with_components(EthereumNode::components())
|
||||||
|
.with_add_ons::<EthereumAddOns>()
|
||||||
|
.launch_with_fn(|builder| {
|
||||||
|
let launcher = EthNodeLauncher::new(
|
||||||
|
builder.task_executor().clone(),
|
||||||
|
builder.config().datadir(),
|
||||||
|
);
|
||||||
|
builder.launch_with(launcher)
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
handle.node_exit_future.await
|
||||||
|
}
|
||||||
|
false => {
|
||||||
|
let handle = builder.launch_node(EthereumNode::default()).await?;
|
||||||
|
handle.node_exit_future.await
|
||||||
|
}
|
||||||
|
}
|
||||||
}) {
|
}) {
|
||||||
eprintln!("Error: {err:?}");
|
eprintln!("Error: {err:?}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
/// A helper type to parse Args more easily
|
||||||
|
#[derive(Parser)]
|
||||||
|
struct CommandParser<T: Args> {
|
||||||
|
#[command(flatten)]
|
||||||
|
args: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_engine_args() {
|
||||||
|
let default_args = EngineArgs::default();
|
||||||
|
let args = CommandParser::<EngineArgs>::parse_from(["reth"]).args;
|
||||||
|
assert_eq!(args, default_args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
4
book/cli/reth/node.md
vendored
4
book/cli/reth/node.md
vendored
@ -525,6 +525,10 @@ Pruning:
|
|||||||
--full
|
--full
|
||||||
Run full node. Only the most recent [`MINIMUM_PRUNING_DISTANCE`] block states are stored. This flag takes priority over pruning configuration in reth.toml
|
Run full node. Only the most recent [`MINIMUM_PRUNING_DISTANCE`] block states are stored. This flag takes priority over pruning configuration in reth.toml
|
||||||
|
|
||||||
|
Engine:
|
||||||
|
--engine.experimental
|
||||||
|
Enable the engine2 experimental features on reth binary
|
||||||
|
|
||||||
Logging:
|
Logging:
|
||||||
--log.stdout.format <FORMAT>
|
--log.stdout.format <FORMAT>
|
||||||
The format to use for logs written to stdout
|
The format to use for logs written to stdout
|
||||||
|
|||||||
Reference in New Issue
Block a user