mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(node): Refactor node builder wrt stable 1.79.0 (#10367)
This commit is contained in:
@ -317,17 +317,20 @@ where
|
||||
>
|
||||
where
|
||||
N: Node<RethFullAdapter<DB, N>>,
|
||||
<N::AddOns as NodeAddOns<
|
||||
N::AddOns: NodeAddOns<
|
||||
NodeAdapter<
|
||||
RethFullAdapter<DB, N>,
|
||||
<N::ComponentsBuilder as NodeComponentsBuilder<RethFullAdapter<DB, N>>>::Components,
|
||||
>,
|
||||
>>::EthApi: EthApiBuilderProvider<
|
||||
NodeAdapter<
|
||||
RethFullAdapter<DB, N>,
|
||||
<N::ComponentsBuilder as NodeComponentsBuilder<RethFullAdapter<DB, N>>>::Components,
|
||||
>,
|
||||
> + FullEthApiServer + AddDevSigners,
|
||||
EthApi: EthApiBuilderProvider<
|
||||
NodeAdapter<
|
||||
RethFullAdapter<DB, N>,
|
||||
<N::ComponentsBuilder as NodeComponentsBuilder<RethFullAdapter<DB, N>>>::Components,
|
||||
>
|
||||
>
|
||||
+ FullEthApiServer
|
||||
+ AddDevSigners
|
||||
>,
|
||||
{
|
||||
self.node(node).launch().await
|
||||
}
|
||||
@ -371,8 +374,7 @@ impl<T, CB, AO> WithLaunchContext<NodeBuilderWithComponents<T, CB, AO>>
|
||||
where
|
||||
T: FullNodeTypes,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
AO: NodeAddOns<NodeAdapter<T, CB::Components>>,
|
||||
AO::EthApi: FullEthApiServer + AddDevSigners,
|
||||
AO: NodeAddOns<NodeAdapter<T, CB::Components>, EthApi: FullEthApiServer + AddDevSigners>,
|
||||
{
|
||||
/// Returns a reference to the node builder's config.
|
||||
pub const fn config(&self) -> &NodeConfig {
|
||||
@ -469,10 +471,12 @@ where
|
||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
||||
T: NodeTypes,
|
||||
CB: NodeComponentsBuilder<RethFullAdapter<DB, T>>,
|
||||
AO: NodeAddOns<NodeAdapter<RethFullAdapter<DB, T>, CB::Components>>,
|
||||
AO::EthApi: EthApiBuilderProvider<NodeAdapter<RethFullAdapter<DB, T>, CB::Components>>
|
||||
+ FullEthApiServer
|
||||
+ AddDevSigners,
|
||||
AO: NodeAddOns<
|
||||
NodeAdapter<RethFullAdapter<DB, T>, CB::Components>,
|
||||
EthApi: EthApiBuilderProvider<NodeAdapter<RethFullAdapter<DB, T>, CB::Components>>
|
||||
+ FullEthApiServer
|
||||
+ AddDevSigners,
|
||||
>,
|
||||
{
|
||||
/// Launches the node with the [`DefaultNodeLauncher`] that sets up engine API consensus and rpc
|
||||
pub async fn launch(
|
||||
|
||||
@ -273,9 +273,12 @@ impl<T, CB, AO> NodeBuilderWithComponents<T, CB, AO>
|
||||
where
|
||||
T: FullNodeTypes,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
AO: NodeAddOns<NodeAdapter<T, CB::Components>>,
|
||||
AO::EthApi:
|
||||
EthApiBuilderProvider<NodeAdapter<T, CB::Components>> + FullEthApiServer + AddDevSigners,
|
||||
AO: NodeAddOns<
|
||||
NodeAdapter<T, CB::Components>,
|
||||
EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>>
|
||||
+ FullEthApiServer
|
||||
+ AddDevSigners,
|
||||
>,
|
||||
{
|
||||
/// Launches the node with the given launcher.
|
||||
pub async fn launch_with<L>(self, launcher: L) -> eyre::Result<L::Node>
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
//! Network component for the node builder.
|
||||
|
||||
use crate::{BuilderContext, FullNodeTypes};
|
||||
use std::future::Future;
|
||||
|
||||
use reth_network::NetworkHandle;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use std::future::Future;
|
||||
|
||||
use crate::{BuilderContext, FullNodeTypes};
|
||||
|
||||
/// A type that knows how to build the network implementation.
|
||||
pub trait NetworkBuilder<Node: FullNodeTypes, Pool: TransactionPool>: Send {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
//! Payload service component for the node builder.
|
||||
|
||||
use crate::{BuilderContext, FullNodeTypes};
|
||||
use std::future::Future;
|
||||
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use std::future::Future;
|
||||
|
||||
use crate::{BuilderContext, FullNodeTypes};
|
||||
|
||||
/// A type that knows how to spawn the payload service.
|
||||
pub trait PayloadServiceBuilder<Node: FullNodeTypes, Pool: TransactionPool>: Send {
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
//! Pool component for the node builder.
|
||||
use crate::{BuilderContext, FullNodeTypes};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
|
||||
use crate::{BuilderContext, FullNodeTypes};
|
||||
|
||||
/// A type that knows how to build the transaction pool.
|
||||
pub trait PoolBuilder<Node: FullNodeTypes>: Send {
|
||||
/// The transaction pool to build.
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
//! Types for launching execution extensions (ExEx).
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
use futures::{future::BoxFuture, FutureExt};
|
||||
use reth_exex::ExExContext;
|
||||
use reth_node_api::FullNodeComponents;
|
||||
use std::future::Future;
|
||||
|
||||
/// A trait for launching an `ExEx`.
|
||||
pub trait LaunchExEx<Node: FullNodeComponents>: Send {
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
//! Helper types that can be used by launchers.
|
||||
|
||||
use crate::{
|
||||
components::{NodeComponents, NodeComponentsBuilder},
|
||||
hooks::OnComponentInitializedHook,
|
||||
BuilderContext, NodeAdapter,
|
||||
};
|
||||
use std::{marker::PhantomData, sync::Arc, thread::available_parallelism};
|
||||
|
||||
use eyre::Context;
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use reth_auto_seal_consensus::MiningMode;
|
||||
@ -47,12 +44,17 @@ use reth_stages::{sets::DefaultStages, MetricEvent, Pipeline, PipelineTarget, St
|
||||
use reth_static_file::StaticFileProducer;
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_tracing::tracing::{debug, error, info, warn};
|
||||
use std::{marker::PhantomData, sync::Arc, thread::available_parallelism};
|
||||
use tokio::sync::{
|
||||
mpsc::{unbounded_channel, Receiver, UnboundedSender},
|
||||
oneshot, watch,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
components::{NodeComponents, NodeComponentsBuilder},
|
||||
hooks::OnComponentInitializedHook,
|
||||
BuilderContext, NodeAdapter,
|
||||
};
|
||||
|
||||
/// Allows to set a tree viewer for a configured blockchain provider.
|
||||
// TODO: remove this helper trait once the engine revamp is done, the new
|
||||
// blockchain provider won't require a TreeViewer.
|
||||
@ -596,8 +598,7 @@ where
|
||||
impl<DB, T> LaunchContextWith<Attached<WithConfigs, WithMeteredProviders<DB, T>>>
|
||||
where
|
||||
DB: Database + DatabaseMetrics + Send + Sync + Clone + 'static,
|
||||
T: FullNodeTypes,
|
||||
T::Provider: FullProvider<DB> + WithTree,
|
||||
T: FullNodeTypes<Provider: FullProvider<DB> + WithTree>,
|
||||
{
|
||||
/// Returns access to the underlying database.
|
||||
pub fn database(&self) -> &DB {
|
||||
@ -716,8 +717,7 @@ where
|
||||
impl<DB, T, CB> LaunchContextWith<Attached<WithConfigs, WithComponents<DB, T, CB>>>
|
||||
where
|
||||
DB: Database + DatabaseMetrics + Send + Sync + Clone + 'static,
|
||||
T: FullNodeTypes,
|
||||
T::Provider: FullProvider<DB> + WithTree,
|
||||
T: FullNodeTypes<Provider: FullProvider<DB> + WithTree>,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
{
|
||||
/// Returns the configured `ProviderFactory`.
|
||||
@ -915,8 +915,7 @@ pub struct WithMeteredProvider<DB> {
|
||||
pub struct WithMeteredProviders<DB, T>
|
||||
where
|
||||
DB: Database,
|
||||
T: FullNodeTypes,
|
||||
T::Provider: FullProvider<DB>,
|
||||
T: FullNodeTypes<Provider: FullProvider<DB>>,
|
||||
{
|
||||
db_provider_container: WithMeteredProvider<DB>,
|
||||
blockchain_db: T::Provider,
|
||||
@ -932,8 +931,7 @@ where
|
||||
pub struct WithComponents<DB, T, CB>
|
||||
where
|
||||
DB: Database,
|
||||
T: FullNodeTypes,
|
||||
T::Provider: FullProvider<DB>,
|
||||
T: FullNodeTypes<Provider: FullProvider<DB>>,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
{
|
||||
db_provider_container: WithMeteredProvider<DB>,
|
||||
|
||||
@ -1,14 +1,5 @@
|
||||
//! 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},
|
||||
@ -42,6 +33,16 @@ use reth_tracing::tracing::{debug, error, info};
|
||||
use tokio::sync::{mpsc::unbounded_channel, oneshot};
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
/// The engine node launcher.
|
||||
#[derive(Debug)]
|
||||
pub struct EngineNodeLauncher {
|
||||
@ -60,9 +61,12 @@ impl<T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeL
|
||||
where
|
||||
T: FullNodeTypes<Provider = BlockchainProvider2<<T as FullNodeTypes>::DB>>,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
AO: NodeAddOns<NodeAdapter<T, CB::Components>>,
|
||||
AO::EthApi:
|
||||
EthApiBuilderProvider<NodeAdapter<T, CB::Components>> + FullEthApiServer + AddDevSigners,
|
||||
AO: NodeAddOns<
|
||||
NodeAdapter<T, CB::Components>,
|
||||
EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>>
|
||||
+ FullEthApiServer
|
||||
+ AddDevSigners,
|
||||
>,
|
||||
{
|
||||
type Node = NodeHandle<NodeAdapter<T, CB::Components>, AO>;
|
||||
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
//! Support for launching execution extensions.
|
||||
|
||||
use crate::{common::WithConfigs, exex::BoxedLaunchExEx};
|
||||
use std::{fmt, fmt::Debug};
|
||||
|
||||
use futures::future;
|
||||
use reth_exex::{ExExContext, ExExHandle, ExExManager, ExExManagerHandle};
|
||||
use reth_node_api::FullNodeComponents;
|
||||
use reth_primitives::Head;
|
||||
use reth_provider::CanonStateSubscriptions;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
use std::{fmt, fmt::Debug};
|
||||
|
||||
use crate::{common::WithConfigs, exex::BoxedLaunchExEx};
|
||||
|
||||
/// Can launch execution extensions.
|
||||
pub struct ExExLauncher<Node: FullNodeComponents> {
|
||||
|
||||
@ -8,6 +8,8 @@ pub(crate) mod engine;
|
||||
pub use common::LaunchContext;
|
||||
pub use exex::ExExLauncher;
|
||||
|
||||
use std::{future::Future, sync::Arc};
|
||||
|
||||
use futures::{future::Either, stream, stream_select, StreamExt};
|
||||
use reth_beacon_consensus::{
|
||||
hooks::{EngineHooks, PruneHook, StaticFileHook},
|
||||
@ -33,7 +35,6 @@ use reth_rpc_types::engine::ClientVersionV1;
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use std::{future::Future, sync::Arc};
|
||||
use tokio::sync::{mpsc::unbounded_channel, oneshot};
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
|
||||
@ -102,9 +103,12 @@ impl<T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for DefaultNode
|
||||
where
|
||||
T: FullNodeTypes<Provider = BlockchainProvider<<T as FullNodeTypes>::DB>>,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
AO: NodeAddOns<NodeAdapter<T, CB::Components>>,
|
||||
AO::EthApi:
|
||||
EthApiBuilderProvider<NodeAdapter<T, CB::Components>> + FullEthApiServer + AddDevSigners,
|
||||
AO: NodeAddOns<
|
||||
NodeAdapter<T, CB::Components>,
|
||||
EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>>
|
||||
+ FullEthApiServer
|
||||
+ AddDevSigners,
|
||||
>,
|
||||
{
|
||||
type Node = NodeHandle<NodeAdapter<T, CB::Components>, AO>;
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
//! Helpers for setting up parts of the node.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use reth_config::{config::StageConfig, PruneConfig};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_db_api::database::Database;
|
||||
@ -18,7 +20,6 @@ use reth_stages::{prelude::DefaultStages, stages::ExecutionStage, Pipeline, Stag
|
||||
use reth_static_file::StaticFileProducer;
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_tracing::tracing::debug;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::watch;
|
||||
|
||||
/// Constructs a [Pipeline] that's wired to the network
|
||||
|
||||
Reference in New Issue
Block a user