refactor: move EngineValidator setup to RpcAddOns (#11850)

This commit is contained in:
Arsenii Kulikov
2024-10-19 14:08:34 +04:00
committed by GitHub
parent da5079d11f
commit 2ae93682b4
12 changed files with 140 additions and 219 deletions

View File

@ -5,7 +5,6 @@ use std::{future::Future, marker::PhantomData};
use alloy_rpc_types_engine::JwtSecret;
use reth_beacon_consensus::BeaconConsensusEngineHandle;
use reth_consensus::Consensus;
use reth_engine_primitives::EngineValidator;
use reth_evm::execute::BlockExecutorProvider;
use reth_network_api::FullNetwork;
use reth_node_core::node_config::NodeConfig;
@ -64,9 +63,6 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
/// Network API.
type Network: FullNetwork;
/// Validator for the engine API.
type EngineValidator: EngineValidator<<Self::Types as NodeTypesWithEngine>::Engine>;
/// Returns the transaction pool of the node.
fn pool(&self) -> &Self::Pool;
@ -87,9 +83,6 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
&self,
) -> &PayloadBuilderHandle<<Self::Types as NodeTypesWithEngine>::Engine>;
/// Returns the engine validator.
fn engine_validator(&self) -> &Self::EngineValidator;
/// Returns the provider of the node.
fn provider(&self) -> &Self::Provider;

View File

@ -97,7 +97,6 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
type Executor = C::Executor;
type Network = C::Network;
type Consensus = C::Consensus;
type EngineValidator = C::EngineValidator;
fn pool(&self) -> &Self::Pool {
self.components.pool()
@ -130,10 +129,6 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
fn consensus(&self) -> &Self::Consensus {
self.components.consensus()
}
fn engine_validator(&self) -> &Self::EngineValidator {
self.components.engine_validator()
}
}
impl<T: FullNodeTypes, C: NodeComponents<T>> Clone for NodeAdapter<T, C> {

View File

@ -4,7 +4,6 @@ use std::{future::Future, marker::PhantomData};
use reth_consensus::Consensus;
use reth_evm::execute::BlockExecutorProvider;
use reth_node_api::{EngineValidator, NodeTypesWithEngine};
use reth_primitives::Header;
use reth_transaction_pool::TransactionPool;
@ -16,8 +15,6 @@ use crate::{
BuilderContext, ConfigureEvm, FullNodeTypes,
};
use super::EngineValidatorBuilder;
/// A generic, general purpose and customizable [`NodeComponentsBuilder`] implementation.
///
/// This type is stateful and captures the configuration of the node's components.
@ -38,23 +35,22 @@ use super::EngineValidatorBuilder;
/// All component builders are captured in the builder state and will be consumed once the node is
/// launched.
#[derive(Debug)]
pub struct ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB> {
pub struct ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB> {
pool_builder: PoolB,
payload_builder: PayloadB,
network_builder: NetworkB,
executor_builder: ExecB,
consensus_builder: ConsB,
engine_validator_builder: EVB,
_marker: PhantomData<Node>,
}
impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB>
ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB>
{
/// Configures the node types.
pub fn node_types<Types>(
self,
) -> ComponentsBuilder<Types, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
) -> ComponentsBuilder<Types, PoolB, PayloadB, NetworkB, ExecB, ConsB>
where
Types: FullNodeTypes,
{
@ -64,7 +60,6 @@ impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
network_builder,
executor_builder: evm_builder,
consensus_builder,
engine_validator_builder,
_marker,
} = self;
ComponentsBuilder {
@ -73,7 +68,6 @@ impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
payload_builder,
network_builder,
consensus_builder,
engine_validator_builder,
_marker: Default::default(),
}
}
@ -86,7 +80,6 @@ impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
network_builder: self.network_builder,
executor_builder: self.executor_builder,
consensus_builder: self.consensus_builder,
engine_validator_builder: self.engine_validator_builder,
_marker: self._marker,
}
}
@ -99,7 +92,6 @@ impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
network_builder: self.network_builder,
executor_builder: self.executor_builder,
consensus_builder: self.consensus_builder,
engine_validator_builder: self.engine_validator_builder,
_marker: self._marker,
}
}
@ -112,7 +104,6 @@ impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
network_builder: f(self.network_builder),
executor_builder: self.executor_builder,
consensus_builder: self.consensus_builder,
engine_validator_builder: self.engine_validator_builder,
_marker: self._marker,
}
}
@ -125,7 +116,6 @@ impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
network_builder: self.network_builder,
executor_builder: f(self.executor_builder),
consensus_builder: self.consensus_builder,
engine_validator_builder: self.engine_validator_builder,
_marker: self._marker,
}
}
@ -138,14 +128,13 @@ impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
network_builder: self.network_builder,
executor_builder: self.executor_builder,
consensus_builder: f(self.consensus_builder),
engine_validator_builder: self.engine_validator_builder,
_marker: self._marker,
}
}
}
impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB>
ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB>
where
Node: FullNodeTypes,
{
@ -156,7 +145,7 @@ where
pub fn pool<PB>(
self,
pool_builder: PB,
) -> ComponentsBuilder<Node, PB, PayloadB, NetworkB, ExecB, ConsB, EVB>
) -> ComponentsBuilder<Node, PB, PayloadB, NetworkB, ExecB, ConsB>
where
PB: PoolBuilder<Node>,
{
@ -166,7 +155,6 @@ where
network_builder,
executor_builder: evm_builder,
consensus_builder,
engine_validator_builder,
_marker,
} = self;
ComponentsBuilder {
@ -175,14 +163,13 @@ where
network_builder,
executor_builder: evm_builder,
consensus_builder,
engine_validator_builder,
_marker,
}
}
}
impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB>
ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB>
where
Node: FullNodeTypes,
PoolB: PoolBuilder<Node>,
@ -194,7 +181,7 @@ where
pub fn network<NB>(
self,
network_builder: NB,
) -> ComponentsBuilder<Node, PoolB, PayloadB, NB, ExecB, ConsB, EVB>
) -> ComponentsBuilder<Node, PoolB, PayloadB, NB, ExecB, ConsB>
where
NB: NetworkBuilder<Node, PoolB::Pool>,
{
@ -204,7 +191,6 @@ where
network_builder: _,
executor_builder: evm_builder,
consensus_builder,
engine_validator_builder,
_marker,
} = self;
ComponentsBuilder {
@ -213,7 +199,6 @@ where
network_builder,
executor_builder: evm_builder,
consensus_builder,
engine_validator_builder,
_marker,
}
}
@ -225,7 +210,7 @@ where
pub fn payload<PB>(
self,
payload_builder: PB,
) -> ComponentsBuilder<Node, PoolB, PB, NetworkB, ExecB, ConsB, EVB>
) -> ComponentsBuilder<Node, PoolB, PB, NetworkB, ExecB, ConsB>
where
PB: PayloadServiceBuilder<Node, PoolB::Pool>,
{
@ -235,7 +220,6 @@ where
network_builder,
executor_builder: evm_builder,
consensus_builder,
engine_validator_builder,
_marker,
} = self;
ComponentsBuilder {
@ -244,7 +228,6 @@ where
network_builder,
executor_builder: evm_builder,
consensus_builder,
engine_validator_builder,
_marker,
}
}
@ -256,7 +239,7 @@ where
pub fn executor<EB>(
self,
executor_builder: EB,
) -> ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, EB, ConsB, EVB>
) -> ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, EB, ConsB>
where
EB: ExecutorBuilder<Node>,
{
@ -266,7 +249,6 @@ where
network_builder,
executor_builder: _,
consensus_builder,
engine_validator_builder,
_marker,
} = self;
ComponentsBuilder {
@ -275,7 +257,6 @@ where
network_builder,
executor_builder,
consensus_builder,
engine_validator_builder,
_marker,
}
}
@ -287,7 +268,7 @@ where
pub fn consensus<CB>(
self,
consensus_builder: CB,
) -> ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, CB, EVB>
) -> ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, CB>
where
CB: ConsensusBuilder<Node>,
{
@ -297,38 +278,7 @@ where
network_builder,
executor_builder,
consensus_builder: _,
engine_validator_builder,
_marker,
} = self;
ComponentsBuilder {
pool_builder,
payload_builder,
network_builder,
executor_builder,
consensus_builder,
engine_validator_builder,
_marker,
}
}
/// Configures the consensus builder.
///
/// This accepts a [`ConsensusBuilder`] instance that will be used to create the node's
/// components for consensus.
pub fn engine_validator<EngineVB>(
self,
engine_validator_builder: EngineVB,
) -> ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EngineVB>
where
EngineVB: EngineValidatorBuilder<Node>,
{
let Self {
pool_builder,
payload_builder,
network_builder,
executor_builder,
consensus_builder,
engine_validator_builder: _,
_marker,
} = self;
ComponentsBuilder {
@ -337,14 +287,13 @@ where
network_builder,
executor_builder,
consensus_builder,
engine_validator_builder,
_marker,
}
}
}
impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB> NodeComponentsBuilder<Node>
for ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB, EVB>
impl<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB> NodeComponentsBuilder<Node>
for ComponentsBuilder<Node, PoolB, PayloadB, NetworkB, ExecB, ConsB>
where
Node: FullNodeTypes,
PoolB: PoolBuilder<Node>,
@ -352,16 +301,8 @@ where
PayloadB: PayloadServiceBuilder<Node, PoolB::Pool>,
ExecB: ExecutorBuilder<Node>,
ConsB: ConsensusBuilder<Node>,
EVB: EngineValidatorBuilder<Node>,
{
type Components = Components<
Node,
PoolB::Pool,
ExecB::EVM,
ExecB::Executor,
ConsB::Consensus,
EVB::Validator,
>;
type Components = Components<Node, PoolB::Pool, ExecB::EVM, ExecB::Executor, ConsB::Consensus>;
async fn build_components(
self,
@ -373,7 +314,6 @@ where
network_builder,
executor_builder: evm_builder,
consensus_builder,
engine_validator_builder,
_marker,
} = self;
@ -382,7 +322,6 @@ where
let network = network_builder.build_network(context, pool.clone()).await?;
let payload_builder = payload_builder.spawn_payload_service(context, pool.clone()).await?;
let consensus = consensus_builder.build_consensus(context).await?;
let engine_validator = engine_validator_builder.build_validator(context).await?;
Ok(Components {
transaction_pool: pool,
@ -391,12 +330,11 @@ where
payload_builder,
executor,
consensus,
engine_validator,
})
}
}
impl Default for ComponentsBuilder<(), (), (), (), (), (), ()> {
impl Default for ComponentsBuilder<(), (), (), (), (), ()> {
fn default() -> Self {
Self {
pool_builder: (),
@ -404,7 +342,6 @@ impl Default for ComponentsBuilder<(), (), (), (), (), (), ()> {
network_builder: (),
executor_builder: (),
consensus_builder: (),
engine_validator_builder: (),
_marker: Default::default(),
}
}
@ -430,18 +367,17 @@ pub trait NodeComponentsBuilder<Node: FullNodeTypes>: Send {
) -> impl Future<Output = eyre::Result<Self::Components>> + Send;
}
impl<Node, F, Fut, Pool, EVM, Executor, Cons, Val> NodeComponentsBuilder<Node> for F
impl<Node, F, Fut, Pool, EVM, Executor, Cons> NodeComponentsBuilder<Node> for F
where
Node: FullNodeTypes,
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
Fut: Future<Output = eyre::Result<Components<Node, Pool, EVM, Executor, Cons, Val>>> + Send,
Fut: Future<Output = eyre::Result<Components<Node, Pool, EVM, Executor, Cons>>> + Send,
Pool: TransactionPool + Unpin + 'static,
EVM: ConfigureEvm<Header = Header>,
Executor: BlockExecutorProvider,
Cons: Consensus + Clone + Unpin + 'static,
Val: EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine> + Clone + Unpin + 'static,
{
type Components = Components<Node, Pool, EVM, Executor, Cons, Val>;
type Components = Components<Node, Pool, EVM, Executor, Cons>;
fn build_components(
self,

View File

@ -1,38 +0,0 @@
//! Consensus component for the node builder.
use reth_node_api::{EngineValidator, NodeTypesWithEngine};
use crate::{BuilderContext, FullNodeTypes};
use std::future::Future;
/// A type that knows how to build the engine validator.
pub trait EngineValidatorBuilder<Node: FullNodeTypes>: Send {
/// The consensus implementation to build.
type Validator: EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine>
+ Clone
+ Unpin
+ 'static;
/// Creates the engine validator.
fn build_validator(
self,
ctx: &BuilderContext<Node>,
) -> impl Future<Output = eyre::Result<Self::Validator>> + Send;
}
impl<Node, F, Fut, Validator> EngineValidatorBuilder<Node> for F
where
Node: FullNodeTypes,
Validator:
EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine> + Clone + Unpin + 'static,
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
Fut: Future<Output = eyre::Result<Validator>> + Send,
{
type Validator = Validator;
fn build_validator(
self,
ctx: &BuilderContext<Node>,
) -> impl Future<Output = eyre::Result<Self::Validator>> {
self(ctx)
}
}

View File

@ -9,7 +9,6 @@
mod builder;
mod consensus;
mod engine;
mod execute;
mod network;
mod payload;
@ -17,7 +16,6 @@ mod pool;
pub use builder::*;
pub use consensus::*;
pub use engine::*;
pub use execute::*;
pub use network::*;
pub use payload::*;
@ -27,7 +25,7 @@ use reth_consensus::Consensus;
use reth_evm::execute::BlockExecutorProvider;
use reth_network::NetworkHandle;
use reth_network_api::FullNetwork;
use reth_node_api::{EngineValidator, NodeTypesWithEngine};
use reth_node_api::NodeTypesWithEngine;
use reth_payload_builder::PayloadBuilderHandle;
use reth_primitives::Header;
use reth_transaction_pool::TransactionPool;
@ -55,9 +53,6 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
/// Network API.
type Network: FullNetwork;
/// Validator for the engine API.
type EngineValidator: EngineValidator<<T::Types as NodeTypesWithEngine>::Engine>;
/// Returns the transaction pool of the node.
fn pool(&self) -> &Self::Pool;
@ -75,16 +70,13 @@ pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'stati
/// Returns the handle to the payload builder service.
fn payload_builder(&self) -> &PayloadBuilderHandle<<T::Types as NodeTypesWithEngine>::Engine>;
/// Returns the engine validator.
fn engine_validator(&self) -> &Self::EngineValidator;
}
/// All the components of the node.
///
/// This provides access to all the components of the node.
#[derive(Debug)]
pub struct Components<Node: FullNodeTypes, Pool, EVM, Executor, Consensus, Validator> {
pub struct Components<Node: FullNodeTypes, Pool, EVM, Executor, Consensus> {
/// The transaction pool of the node.
pub transaction_pool: Pool,
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
@ -97,26 +89,22 @@ pub struct Components<Node: FullNodeTypes, Pool, EVM, Executor, Consensus, Valid
pub network: NetworkHandle,
/// The handle to the payload builder service.
pub payload_builder: PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
/// The validator for the engine API.
pub engine_validator: Validator,
}
impl<Node, Pool, EVM, Executor, Cons, Val> NodeComponents<Node>
for Components<Node, Pool, EVM, Executor, Cons, Val>
impl<Node, Pool, EVM, Executor, Cons> NodeComponents<Node>
for Components<Node, Pool, EVM, Executor, Cons>
where
Node: FullNodeTypes,
Pool: TransactionPool + Unpin + 'static,
EVM: ConfigureEvm<Header = Header>,
Executor: BlockExecutorProvider,
Cons: Consensus + Clone + Unpin + 'static,
Val: EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine> + Clone + Unpin + 'static,
{
type Pool = Pool;
type Evm = EVM;
type Executor = Executor;
type Consensus = Cons;
type Network = NetworkHandle;
type EngineValidator = Val;
fn pool(&self) -> &Self::Pool {
&self.transaction_pool
@ -143,21 +131,15 @@ where
) -> &PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine> {
&self.payload_builder
}
fn engine_validator(&self) -> &Self::EngineValidator {
&self.engine_validator
}
}
impl<Node, Pool, EVM, Executor, Cons, Val> Clone
for Components<Node, Pool, EVM, Executor, Cons, Val>
impl<Node, Pool, EVM, Executor, Cons> Clone for Components<Node, Pool, EVM, Executor, Cons>
where
Node: FullNodeTypes,
Pool: TransactionPool,
EVM: ConfigureEvm<Header = Header>,
Executor: BlockExecutorProvider,
Cons: Consensus + Clone,
Val: EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine>,
{
fn clone(&self) -> Self {
Self {
@ -167,7 +149,6 @@ where
consensus: self.consensus.clone(),
network: self.network.clone(),
payload_builder: self.payload_builder.clone(),
engine_validator: self.engine_validator.clone(),
}
}
}

View File

@ -2,6 +2,7 @@
use std::{
fmt::{self, Debug},
future::Future,
marker::PhantomData,
ops::{Deref, DerefMut},
};
@ -9,7 +10,7 @@ use std::{
use alloy_rpc_types::engine::ClientVersionV1;
use futures::TryFutureExt;
use reth_node_api::{
AddOnsContext, FullNodeComponents, NodeAddOns, NodeTypes, NodeTypesWithEngine,
AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, NodeTypes, NodeTypesWithEngine,
};
use reth_node_core::{
node_config::NodeConfig,
@ -327,31 +328,38 @@ where
/// Node add-ons containing RPC server configuration, with customizable eth API handler.
#[allow(clippy::type_complexity)]
pub struct RpcAddOns<Node: FullNodeComponents, EthApi: EthApiTypes> {
pub struct RpcAddOns<Node: FullNodeComponents, EthApi: EthApiTypes, EV> {
/// Additional RPC add-ons.
pub hooks: RpcHooks<Node, EthApi>,
/// Builder for `EthApi`
eth_api_builder: Box<dyn FnOnce(&EthApiBuilderCtx<Node>) -> EthApi + Send + Sync>,
/// Engine validator
engine_validator_builder: EV,
_pd: PhantomData<(Node, EthApi)>,
}
impl<Node: FullNodeComponents, EthApi: EthApiTypes> Debug for RpcAddOns<Node, EthApi> {
impl<Node: FullNodeComponents, EthApi: EthApiTypes, EV: Debug> Debug
for RpcAddOns<Node, EthApi, EV>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RpcAddOns")
.field("hooks", &self.hooks)
.field("eth_api_builder", &"...")
.field("engine_validator_builder", &self.engine_validator_builder)
.finish()
}
}
impl<Node: FullNodeComponents, EthApi: EthApiTypes> RpcAddOns<Node, EthApi> {
impl<Node: FullNodeComponents, EthApi: EthApiTypes, EV> RpcAddOns<Node, EthApi, EV> {
/// Creates a new instance of the RPC add-ons.
pub fn new(
eth_api_builder: impl FnOnce(&EthApiBuilderCtx<Node>) -> EthApi + Send + Sync + 'static,
engine_validator_builder: EV,
) -> Self {
Self {
hooks: RpcHooks::default(),
eth_api_builder: Box::new(eth_api_builder),
engine_validator_builder,
_pd: PhantomData,
}
}
@ -377,23 +385,28 @@ impl<Node: FullNodeComponents, EthApi: EthApiTypes> RpcAddOns<Node, EthApi> {
}
}
impl<Node: FullNodeComponents, EthApi: EthApiTypes + EthApiBuilder<Node>> Default
for RpcAddOns<Node, EthApi>
impl<Node, EthApi, EV> Default for RpcAddOns<Node, EthApi, EV>
where
Node: FullNodeComponents,
EthApi: EthApiTypes + EthApiBuilder<Node>,
EV: Default,
{
fn default() -> Self {
Self::new(EthApi::build)
Self::new(EthApi::build, EV::default())
}
}
impl<N, EthApi> NodeAddOns<N> for RpcAddOns<N, EthApi>
impl<N, EthApi, EV> NodeAddOns<N> for RpcAddOns<N, EthApi, EV>
where
N: FullNodeComponents<Types: ProviderNodeTypes>,
EthApi: EthApiTypes + FullEthApiServer + AddDevSigners + Unpin + 'static,
EV: EngineValidatorBuilder<N>,
{
type Handle = RpcHandle<N, EthApi>;
async fn launch_add_ons(self, ctx: AddOnsContext<'_, N>) -> eyre::Result<Self::Handle> {
let AddOnsContext { node, config, beacon_engine_handle, jwt_secret } = ctx;
let Self { eth_api_builder, engine_validator_builder, hooks, _pd: _ } = self;
let client = ClientVersionV1 {
code: CLIENT_CODE,
@ -411,7 +424,7 @@ where
Box::new(node.task_executor().clone()),
client,
EngineCapabilities::default(),
node.engine_validator().clone(),
engine_validator_builder.build(&ctx).await?,
);
info!(target: "reth::cli", "Engine API handler initialized");
@ -427,7 +440,7 @@ where
.with_executor(node.task_executor().clone())
.with_evm_config(node.evm_config().clone())
.with_block_executor(node.block_executor().clone())
.build_with_auth_server(module_config, engine_api, self.eth_api_builder);
.build_with_auth_server(module_config, engine_api, eth_api_builder);
// in dev mode we generate 20 random dev-signer accounts
if config.dev.dev {
@ -443,7 +456,7 @@ where
auth_module: &mut auth_module,
};
let RpcHooks { on_rpc_started, extend_rpc_modules } = self.hooks;
let RpcHooks { on_rpc_started, extend_rpc_modules } = hooks;
extend_rpc_modules.extend_rpc_modules(ctx)?;
@ -503,7 +516,7 @@ pub trait RethRpcAddOns<N: FullNodeComponents>:
fn hooks_mut(&mut self) -> &mut RpcHooks<N, Self::EthApi>;
}
impl<N: FullNodeComponents, EthApi: EthApiTypes> RethRpcAddOns<N> for RpcAddOns<N, EthApi>
impl<N: FullNodeComponents, EthApi: EthApiTypes, EV> RethRpcAddOns<N> for RpcAddOns<N, EthApi, EV>
where
Self: NodeAddOns<N, Handle = RpcHandle<N, EthApi>>,
{
@ -525,3 +538,36 @@ impl<N: FullNodeComponents> EthApiBuilder<N> for EthApi<N::Provider, N::Pool, N:
Self::with_spawner(ctx)
}
}
/// A type that knows how to build the engine validator.
pub trait EngineValidatorBuilder<Node: FullNodeComponents>: Send {
/// The consensus implementation to build.
type Validator: EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine>
+ Clone
+ Unpin
+ 'static;
/// Creates the engine validator.
fn build(
self,
ctx: &AddOnsContext<'_, Node>,
) -> impl Future<Output = eyre::Result<Self::Validator>> + Send;
}
impl<Node, F, Fut, Validator> EngineValidatorBuilder<Node> for F
where
Node: FullNodeComponents,
Validator:
EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine> + Clone + Unpin + 'static,
F: FnOnce(&AddOnsContext<'_, Node>) -> Fut + Send,
Fut: Future<Output = eyre::Result<Validator>> + Send,
{
type Validator = Validator;
fn build(
self,
ctx: &AddOnsContext<'_, Node>,
) -> impl Future<Output = eyre::Result<Self::Validator>> {
self(ctx)
}
}