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: make Eth node launcher generic #10218

Merged
merged 1 commit into from
Aug 8, 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
11 changes: 3 additions & 8 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions bin/reth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ pub struct EngineArgs {
fn main() {
use clap::Parser;
use reth::cli::Cli;
use reth_node_ethereum::{launch::EthNodeLauncher, node::EthereumAddOns, EthereumNode};
use reth_node_builder::EngineNodeLauncher;
use reth_node_ethereum::{node::EthereumAddOns, EthereumNode};
use reth_provider::providers::BlockchainProvider2;

reth_cli_util::sigsegv_handler::install();
Expand All @@ -43,7 +44,7 @@ fn main() {
.with_components(EthereumNode::components())
.with_add_ons::<EthereumAddOns>()
.launch_with_fn(|builder| {
let launcher = EthNodeLauncher::new(
let launcher = EngineNodeLauncher::new(
builder.task_executor().clone(),
builder.config().datadir(),
);
Expand Down
15 changes: 2 additions & 13 deletions crates/ethereum/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ workspace = true
# reth
reth-payload-builder.workspace = true
reth-ethereum-engine-primitives.workspace = true
reth-engine-service.workspace = true
reth-basic-payload-builder.workspace = true
reth-ethereum-payload-builder.workspace = true
reth-node-builder.workspace = true
Expand All @@ -27,22 +26,10 @@ reth-consensus.workspace = true
reth-auto-seal-consensus.workspace = true
reth-beacon-consensus.workspace = true
reth-rpc.workspace = true
reth-rpc-types.workspace = true
reth-rpc-engine-api.workspace = true
reth-node-api.workspace = true
reth-tasks.workspace = true
reth-tokio-util.workspace = true
reth-node-events.workspace = true
reth-node-core.workspace = true
reth-exex.workspace = true
reth-blockchain-tree.workspace = true
reth-engine-tree.workspace = true

# misc
eyre.workspace = true
tokio = { workspace = true , features = ["sync"]}
tokio-stream.workspace = true
futures.workspace = true

[dev-dependencies]
reth.workspace = true
Expand All @@ -52,6 +39,8 @@ reth-exex.workspace = true
reth-node-api.workspace = true
reth-node-core.workspace = true
reth-e2e-test-utils.workspace = true
reth-tasks.workspace = true
futures.workspace = true
alloy-primitives.workspace = true
alloy-genesis.workspace = true
tokio.workspace = true
Expand Down
2 changes: 0 additions & 2 deletions crates/ethereum/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ pub use evm::{EthEvmConfig, EthExecutorProvider};

pub mod node;
pub use node::EthereumNode;

pub mod launch;
9 changes: 3 additions & 6 deletions crates/ethereum/node/tests/it/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ use reth_db::{
test_utils::{create_test_rw_db, TempDatabase},
DatabaseEnv,
};
use reth_node_builder::{FullNodeComponents, NodeBuilder, NodeConfig};
use reth_node_ethereum::{
launch::EthNodeLauncher,
node::{EthereumAddOns, EthereumNode},
};
use reth_node_builder::{EngineNodeLauncher, FullNodeComponents, NodeBuilder, NodeConfig};
use reth_node_ethereum::node::{EthereumAddOns, EthereumNode};
use reth_provider::providers::BlockchainProvider2;
use reth_tasks::TaskManager;

Expand Down Expand Up @@ -55,7 +52,7 @@ async fn test_eth_launcher() {
.with_components(EthereumNode::components())
.with_add_ons::<EthereumAddOns>()
.launch_with_fn(|builder| {
let launcher = EthNodeLauncher::new(tasks.executor(), builder.config.datadir());
let launcher = EngineNodeLauncher::new(tasks.executor(), builder.config.datadir());
builder.launch_with(launcher)
});
}
Expand Down
3 changes: 3 additions & 0 deletions crates/node/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ reth-cli-util.workspace = true
reth-rpc-eth-types.workspace = true
reth-network-api.workspace = true
reth-payload-validator.workspace = true
reth-engine-service.workspace = true
reth-tokio-util.workspace = true
reth-engine-tree.workspace = true

## async
futures.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
//! Launch the Ethereum node.
//! Engine node related functionality.

use crate::{
components::NodeComponents,
hooks::NodeHooks,
launch::{LaunchContext, LaunchNode},
rpc::{launch_rpc_servers, EthApiBuilderProvider},
setup::build_networked_pipeline,
AddOns, ExExLauncher, FullNode, NodeAdapter, NodeBuilderWithComponents, NodeComponentsBuilder,
NodeHandle, NodeTypesAdapter,
};
use futures::{future::Either, stream, stream_select, StreamExt};
use reth_beacon_consensus::{
hooks::{EngineHooks, StaticFileHook},
Expand All @@ -8,18 +17,10 @@ use reth_beacon_consensus::{
use reth_blockchain_tree::BlockchainTreeConfig;
use reth_engine_service::service::{ChainEvent, EngineService};
use reth_engine_tree::tree::TreeConfig;
use reth_ethereum_engine_primitives::EthEngineTypes;
use reth_exex::ExExManagerHandle;
use reth_network::{
BlockDownloaderProvider, NetworkEventListenerProvider, NetworkSyncUpdater, SyncState,
};
use reth_network::{NetworkSyncUpdater, SyncState};
use reth_network_api::{BlockDownloaderProvider, NetworkEventListenerProvider};
use reth_node_api::{FullNodeTypes, NodeAddOns};
use reth_node_builder::{
hooks::NodeHooks,
rpc::{launch_rpc_servers, EthApiBuilderProvider},
AddOns, ExExLauncher, FullNode, LaunchContext, LaunchNode, NodeAdapter,
NodeBuilderWithComponents, NodeComponents, NodeComponentsBuilder, NodeHandle, NodeTypesAdapter,
};
use reth_node_core::{
dirs::{ChainPath, DataDirPath},
exit::NodeExitFuture,
Expand All @@ -37,26 +38,23 @@ use reth_tracing::tracing::{debug, error, info};
use tokio::sync::{mpsc::unbounded_channel, oneshot};
use tokio_stream::wrappers::UnboundedReceiverStream;

/// The Ethereum node launcher.
/// The engine node launcher.
#[derive(Debug)]
pub struct EthNodeLauncher {
pub struct EngineNodeLauncher {
/// The task executor for the node.
pub ctx: LaunchContext,
}

impl EthNodeLauncher {
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) }
}
}

impl<T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EthNodeLauncher
impl<T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeLauncher
where
T: FullNodeTypes<
Provider = BlockchainProvider2<<T as FullNodeTypes>::DB>,
Engine = EthEngineTypes,
>,
T: FullNodeTypes<Provider = BlockchainProvider2<<T as FullNodeTypes>::DB>>,
CB: NodeComponentsBuilder<T>,
AO: NodeAddOns<NodeAdapter<T, CB::Components>>,
AO::EthApi:
Expand Down Expand Up @@ -146,7 +144,7 @@ where
// Configure the pipeline
let pipeline_exex_handle =
exex_manager_handle.clone().unwrap_or_else(ExExManagerHandle::empty);
let pipeline = reth_node_builder::setup::build_networked_pipeline(
let pipeline = build_networked_pipeline(
&ctx.toml_config().stages,
network_client.clone(),
ctx.consensus(),
Expand Down
2 changes: 2 additions & 0 deletions crates/node/builder/src/launch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
pub mod common;
mod exex;

pub(crate) mod engine;

pub use common::LaunchContext;
pub use exex::ExExLauncher;

Expand Down
2 changes: 1 addition & 1 deletion crates/node/builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub use builder::{
};

mod launch;
pub use launch::*;
pub use launch::{engine::EngineNodeLauncher, *};

mod handle;
pub use handle::NodeHandle;
Expand Down
Loading