Skip to content

Commit

Permalink
refactor: move EngineValidator setup to addons
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Oct 17, 2024
1 parent 76edc38 commit 2e30eee
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 219 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

20 changes: 10 additions & 10 deletions crates/ethereum/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ use reth_ethereum_engine_primitives::{
};
use reth_evm_ethereum::execute::EthExecutorProvider;
use reth_network::NetworkHandle;
use reth_node_api::{ConfigureEvm, EngineValidator, FullNodeComponents, NodeTypesWithDB};
use reth_node_api::{
AddOnsContext, ConfigureEvm, EngineValidator, FullNodeComponents, NodeTypesWithDB,
};
use reth_node_builder::{
components::{
ComponentsBuilder, ConsensusBuilder, EngineValidatorBuilder, ExecutorBuilder,
NetworkBuilder, PayloadServiceBuilder, PoolBuilder,
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder,
PayloadServiceBuilder, PoolBuilder,
},
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
rpc::RpcAddOns,
rpc::{EngineValidatorBuilder, RpcAddOns},
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadBuilderConfig, PayloadTypes,
};
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
Expand Down Expand Up @@ -47,7 +49,6 @@ impl EthereumNode {
EthereumNetworkBuilder,
EthereumExecutorBuilder,
EthereumConsensusBuilder,
EthereumEngineValidatorBuilder,
>
where
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec>>,
Expand All @@ -64,7 +65,6 @@ impl EthereumNode {
.network(EthereumNetworkBuilder::default())
.executor(EthereumExecutorBuilder::default())
.consensus(EthereumConsensusBuilder::default())
.engine_validator(EthereumEngineValidatorBuilder::default())
}
}

Expand All @@ -86,6 +86,7 @@ pub type EthereumAddOns<N> = RpcAddOns<
NetworkHandle,
<N as FullNodeComponents>::Evm,
>,
EthereumEngineValidatorBuilder,
>;

impl<Types, N> Node<N> for EthereumNode
Expand All @@ -100,7 +101,6 @@ where
EthereumNetworkBuilder,
EthereumExecutorBuilder,
EthereumConsensusBuilder,
EthereumEngineValidatorBuilder,
>;

type AddOns = EthereumAddOns<
Expand Down Expand Up @@ -337,12 +337,12 @@ pub struct EthereumEngineValidatorBuilder;
impl<Node, Types> EngineValidatorBuilder<Node> for EthereumEngineValidatorBuilder
where
Types: NodeTypesWithEngine<ChainSpec = ChainSpec>,
Node: FullNodeTypes<Types = Types>,
Node: FullNodeComponents<Types = Types>,
EthereumEngineValidator: EngineValidator<Types::Engine>,
{
type Validator = EthereumEngineValidator;

async fn build_validator(self, ctx: &BuilderContext<Node>) -> eyre::Result<Self::Validator> {
Ok(EthereumEngineValidator::new(ctx.chain_spec()))
async fn build(self, ctx: &AddOnsContext<'_, Node>) -> eyre::Result<Self::Validator> {
Ok(EthereumEngineValidator::new(ctx.config.chain.clone()))
}
}
1 change: 0 additions & 1 deletion crates/exex/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ reth-primitives.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] }
reth-tasks.workspace = true
reth-transaction-pool = { workspace = true, features = ["test-utils"] }
reth-ethereum-engine-primitives.workspace = true

## async
futures-util.workspace = true
Expand Down
11 changes: 1 addition & 10 deletions crates/exex/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use reth_db::{
DatabaseEnv,
};
use reth_db_common::init::init_genesis;
use reth_ethereum_engine_primitives::EthereumEngineValidator;
use reth_evm::test_utils::MockExecutorProvider;
use reth_execution_types::Chain;
use reth_exex::{ExExContext, ExExEvent, ExExNotification, ExExNotifications, Wal};
Expand All @@ -41,10 +40,7 @@ use reth_node_builder::{
};
use reth_node_core::node_config::NodeConfig;
use reth_node_ethereum::{
node::{
EthereumAddOns, EthereumEngineValidatorBuilder, EthereumNetworkBuilder,
EthereumPayloadBuilder,
},
node::{EthereumAddOns, EthereumNetworkBuilder, EthereumPayloadBuilder},
EthEngineTypes, EthEvmConfig,
};
use reth_payload_builder::noop::NoopPayloadBuilderService;
Expand Down Expand Up @@ -140,7 +136,6 @@ where
EthereumNetworkBuilder,
TestExecutorBuilder,
TestConsensusBuilder,
EthereumEngineValidatorBuilder,
>;
type AddOns = EthereumAddOns<
NodeAdapter<N, <Self::ComponentsBuilder as NodeComponentsBuilder<N>>::Components>,
Expand All @@ -154,7 +149,6 @@ where
.network(EthereumNetworkBuilder::default())
.executor(TestExecutorBuilder::default())
.consensus(TestConsensusBuilder::default())
.engine_validator(EthereumEngineValidatorBuilder::default())
}

fn add_ons(&self) -> Self::AddOns {
Expand Down Expand Up @@ -284,8 +278,6 @@ pub async fn test_exex_context_with_chain_spec(
let tasks = TaskManager::current();
let task_executor = tasks.executor();

let engine_validator = EthereumEngineValidator::new(chain_spec.clone());

let components = NodeAdapter::<FullNodeTypesAdapter<NodeTypesWithDBAdapter<TestNode, _>, _>, _> {
components: Components {
transaction_pool,
Expand All @@ -294,7 +286,6 @@ pub async fn test_exex_context_with_chain_spec(
consensus,
network,
payload_builder,
engine_validator,
},
task_executor,
provider,
Expand Down
7 changes: 0 additions & 7 deletions crates/node/api/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down
5 changes: 0 additions & 5 deletions crates/node/builder/src/builder/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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> {
Expand Down
Loading

0 comments on commit 2e30eee

Please sign in to comment.