mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(cli): expose tree engine persistence configuration (#10999)
This commit is contained in:
@ -5,17 +5,40 @@ static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::ne
|
||||
|
||||
use clap::{Args, Parser};
|
||||
use reth::{args::utils::DefaultChainSpecParser, cli::Cli};
|
||||
use reth_node_builder::EngineNodeLauncher;
|
||||
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;
|
||||
|
||||
/// Parameters for configuring the engine
|
||||
#[derive(Debug, Clone, Args, PartialEq, Eq, Default)]
|
||||
#[derive(Debug, Clone, Args, PartialEq, Eq)]
|
||||
#[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,
|
||||
|
||||
/// Configure persistence threshold for engine experimental.
|
||||
#[arg(long = "engine.persistence-threshold", requires = "experimental", 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", requires = "experimental", default_value_t = DEFAULT_MEMORY_BLOCK_BUFFER_TARGET)]
|
||||
pub memory_block_buffer_target: u64,
|
||||
}
|
||||
|
||||
impl Default for EngineArgs {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
experimental: false,
|
||||
persistence_threshold: DEFAULT_PERSISTENCE_THRESHOLD,
|
||||
memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -31,6 +54,9 @@ fn main() {
|
||||
let enable_engine2 = engine_args.experimental;
|
||||
match enable_engine2 {
|
||||
true => {
|
||||
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())
|
||||
@ -39,6 +65,7 @@ fn main() {
|
||||
let launcher = EngineNodeLauncher::new(
|
||||
builder.task_executor().clone(),
|
||||
builder.config().datadir(),
|
||||
engine_tree_config,
|
||||
);
|
||||
builder.launch_with(launcher)
|
||||
})
|
||||
|
||||
10
book/cli/reth/node.md
vendored
10
book/cli/reth/node.md
vendored
@ -665,6 +665,16 @@ Engine:
|
||||
--engine.experimental
|
||||
Enable the engine2 experimental features on reth binary
|
||||
|
||||
--engine.persistence-threshold <PERSISTENCE_THRESHOLD>
|
||||
Configure persistence threshold for engine experimental
|
||||
|
||||
[default: 2]
|
||||
|
||||
--engine.memory-block-buffer-target <MEMORY_BLOCK_BUFFER_TARGET>
|
||||
Configure the target number of blocks to keep in memory
|
||||
|
||||
[default: 2]
|
||||
|
||||
Logging:
|
||||
--log.stdout.format <FORMAT>
|
||||
The format to use for logs written to stdout
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
//! Engine tree configuration.
|
||||
|
||||
/// Triggers persistence when the number of canonical blocks in memory exceeds this threshold.
|
||||
const DEFAULT_PERSISTENCE_THRESHOLD: u64 = 2;
|
||||
pub const DEFAULT_PERSISTENCE_THRESHOLD: u64 = 2;
|
||||
|
||||
/// How close to the canonical head we persist blocks.
|
||||
const DEFAULT_MEMORY_BLOCK_BUFFER_TARGET: u64 = 2;
|
||||
pub const DEFAULT_MEMORY_BLOCK_BUFFER_TARGET: u64 = 2;
|
||||
|
||||
const DEFAULT_BLOCK_BUFFER_LIMIT: u32 = 256;
|
||||
const DEFAULT_MAX_INVALID_HEADER_CACHE_LENGTH: u32 = 256;
|
||||
|
||||
@ -60,7 +60,7 @@ use tokio::sync::{
|
||||
};
|
||||
use tracing::*;
|
||||
|
||||
mod config;
|
||||
pub mod config;
|
||||
mod invalid_block_hook;
|
||||
mod metrics;
|
||||
use crate::{engine::EngineApiRequest, tree::metrics::EngineApiMetrics};
|
||||
|
||||
@ -56,7 +56,11 @@ async fn test_eth_launcher() {
|
||||
.with_components(EthereumNode::components())
|
||||
.with_add_ons::<EthereumAddOns>()
|
||||
.launch_with_fn(|builder| {
|
||||
let launcher = EngineNodeLauncher::new(tasks.executor(), builder.config.datadir());
|
||||
let launcher = EngineNodeLauncher::new(
|
||||
tasks.executor(),
|
||||
builder.config.datadir(),
|
||||
Default::default(),
|
||||
);
|
||||
builder.launch_with(launcher)
|
||||
});
|
||||
}
|
||||
|
||||
@ -54,12 +54,20 @@ use crate::{
|
||||
pub struct EngineNodeLauncher {
|
||||
/// The task executor for the node.
|
||||
pub ctx: LaunchContext,
|
||||
|
||||
/// Temporary configuration for engine tree.
|
||||
/// After engine is stabilized, this should be configured through node builder.
|
||||
pub engine_tree_config: TreeConfig,
|
||||
}
|
||||
|
||||
impl EngineNodeLauncher {
|
||||
/// Create a new instance of the ethereum node launcher.
|
||||
pub const fn new(task_executor: TaskExecutor, data_dir: ChainPath<DataDirPath>) -> Self {
|
||||
Self { ctx: LaunchContext::new(task_executor, data_dir) }
|
||||
pub const fn new(
|
||||
task_executor: TaskExecutor,
|
||||
data_dir: ChainPath<DataDirPath>,
|
||||
engine_tree_config: TreeConfig,
|
||||
) -> Self {
|
||||
Self { ctx: LaunchContext::new(task_executor, data_dir), engine_tree_config }
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +93,7 @@ where
|
||||
self,
|
||||
target: NodeBuilderWithComponents<T, CB, AO>,
|
||||
) -> eyre::Result<Self::Node> {
|
||||
let Self { ctx } = self;
|
||||
let Self { ctx, engine_tree_config } = self;
|
||||
let NodeBuilderWithComponents {
|
||||
adapter: NodeTypesAdapter { database },
|
||||
components_builder,
|
||||
@ -221,7 +229,7 @@ where
|
||||
ctx.blockchain_db().clone(),
|
||||
pruner,
|
||||
ctx.components().payload_builder().clone(),
|
||||
TreeConfig::default(),
|
||||
engine_tree_config,
|
||||
ctx.invalid_block_hook()?,
|
||||
ctx.sync_metrics_tx(),
|
||||
);
|
||||
|
||||
@ -28,6 +28,9 @@ pub use builder::{
|
||||
mod launch;
|
||||
pub use launch::{engine::EngineNodeLauncher, *};
|
||||
|
||||
/// Temporarily re-export engine tree config.
|
||||
pub use reth_engine_tree::tree::config as engine_tree_config;
|
||||
|
||||
mod handle;
|
||||
pub use handle::NodeHandle;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#![cfg(feature = "optimism")]
|
||||
|
||||
use clap::Parser;
|
||||
use reth_node_builder::EngineNodeLauncher;
|
||||
use reth_node_builder::{engine_tree_config::TreeConfig, EngineNodeLauncher};
|
||||
use reth_node_optimism::{args::RollupArgs, node::OptimismAddOns, OptimismNode};
|
||||
use reth_optimism_cli::{chainspec::OpChainSpecParser, Cli};
|
||||
use reth_optimism_rpc::SequencerClient;
|
||||
@ -27,6 +27,9 @@ fn main() {
|
||||
let sequencer_http_arg = rollup_args.sequencer_http.clone();
|
||||
match enable_engine2 {
|
||||
true => {
|
||||
let engine_tree_config = TreeConfig::default()
|
||||
.with_persistence_threshold(rollup_args.persistence_threshold)
|
||||
.with_memory_block_buffer_target(rollup_args.memory_block_buffer_target);
|
||||
let handle = builder
|
||||
.with_types_and_provider::<OptimismNode, BlockchainProvider2<_>>()
|
||||
.with_components(OptimismNode::components(rollup_args))
|
||||
@ -45,6 +48,7 @@ fn main() {
|
||||
let launcher = EngineNodeLauncher::new(
|
||||
builder.task_executor().clone(),
|
||||
builder.config().datadir(),
|
||||
engine_tree_config,
|
||||
);
|
||||
builder.launch_with(launcher)
|
||||
})
|
||||
|
||||
@ -2,8 +2,12 @@
|
||||
|
||||
//! clap [Args](clap::Args) for optimism rollup configuration
|
||||
|
||||
use reth_node_builder::engine_tree_config::{
|
||||
DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD,
|
||||
};
|
||||
|
||||
/// Parameters for rollup configuration
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, clap::Args)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
|
||||
#[command(next_help_heading = "Rollup")]
|
||||
pub struct RollupArgs {
|
||||
/// HTTP endpoint for the sequencer mempool
|
||||
@ -37,6 +41,29 @@ pub struct RollupArgs {
|
||||
/// Enable the engine2 experimental features on op-reth binary
|
||||
#[arg(long = "engine.experimental", default_value = "false")]
|
||||
pub experimental: bool,
|
||||
|
||||
/// Configure persistence threshold for engine experimental.
|
||||
#[arg(long = "engine.persistence-threshold", requires = "experimental", 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", requires = "experimental", default_value_t = DEFAULT_MEMORY_BLOCK_BUFFER_TARGET)]
|
||||
pub memory_block_buffer_target: u64,
|
||||
}
|
||||
|
||||
impl Default for RollupArgs {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
sequencer_http: None,
|
||||
disable_txpool_gossip: false,
|
||||
enable_genesis_walkback: false,
|
||||
compute_pending_block: false,
|
||||
discovery_v4: false,
|
||||
experimental: false,
|
||||
persistence_threshold: DEFAULT_PERSISTENCE_THRESHOLD,
|
||||
memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user