From 9eb7d961d71757bad3efa6270c4d8c3b1d9c208d Mon Sep 17 00:00:00 2001 From: Darshan Kathiriya <8559992+lakshya-sky@users.noreply.github.com> Date: Thu, 2 May 2024 13:45:34 -0400 Subject: [PATCH] integrate FullNodeComponents in exexcomponents (#8051) --- Cargo.lock | 2 ++ crates/exex/Cargo.toml | 2 ++ crates/exex/src/context.rs | 50 +++++++++++++++++++++++---- crates/node/builder/src/launch/mod.rs | 4 +-- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcb0dfa5e..ffb669d5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6910,8 +6910,10 @@ dependencies = [ "metrics", "reth-config", "reth-metrics", + "reth-network", "reth-node-api", "reth-node-core", + "reth-payload-builder", "reth-primitives", "reth-provider", "reth-tasks", diff --git a/crates/exex/Cargo.toml b/crates/exex/Cargo.toml index 71f9c8bde..d16cb53f7 100644 --- a/crates/exex/Cargo.toml +++ b/crates/exex/Cargo.toml @@ -21,6 +21,8 @@ reth-primitives.workspace = true reth-provider.workspace = true reth-tasks.workspace = true reth-tracing.workspace = true +reth-network.workspace = true +reth-payload-builder.workspace = true ## async tokio.workspace = true diff --git a/crates/exex/src/context.rs b/crates/exex/src/context.rs index df2b51377..733047400 100644 --- a/crates/exex/src/context.rs +++ b/crates/exex/src/context.rs @@ -1,4 +1,4 @@ -use reth_node_api::FullNodeComponents; +use reth_node_api::{FullNodeComponents, FullNodeTypes, NodeTypes}; use reth_node_core::{ dirs::{ChainPath, DataDirPath}, node_config::NodeConfig, @@ -14,18 +14,12 @@ use crate::{ExExEvent, ExExNotification}; pub struct ExExContext { /// The current head of the blockchain at launch. pub head: Head, - /// The configured provider to interact with the blockchain. - pub provider: Node::Provider, - /// The task executor of the node. - pub task_executor: TaskExecutor, /// The data dir of the node. pub data_dir: ChainPath, /// The config of the node pub config: NodeConfig, /// The loaded node config pub reth_config: reth_config::Config, - /// The transaction pool of the node. - pub pool: Node::Pool, /// Channel used to send [`ExExEvent`]s to the rest of the node. /// /// # Important @@ -41,4 +35,46 @@ pub struct ExExContext { /// Once a an [`ExExNotification`] is sent over the channel, it is considered delivered by the /// node. pub notifications: Receiver, + + /// node components + pub components: Node, +} + +impl NodeTypes for ExExContext { + type Primitives = Node::Primitives; + type Engine = Node::Engine; +} + +impl FullNodeTypes for ExExContext { + type DB = Node::DB; + type Provider = Node::Provider; +} + +impl FullNodeComponents for ExExContext { + type Pool = Node::Pool; + type Evm = Node::Evm; + + fn pool(&self) -> &Self::Pool { + self.components.pool() + } + + fn provider(&self) -> &Self::Provider { + self.components.provider() + } + + fn network(&self) -> &reth_network::NetworkHandle { + self.components.network() + } + + fn payload_builder(&self) -> &reth_payload_builder::PayloadBuilderHandle { + self.components.payload_builder() + } + + fn task_executor(&self) -> &TaskExecutor { + self.components.task_executor() + } + + fn evm_config(&self) -> &Self::Evm { + self.components.evm_config() + } } diff --git a/crates/node/builder/src/launch/mod.rs b/crates/node/builder/src/launch/mod.rs index cd93dbe5e..201965fa9 100644 --- a/crates/node/builder/src/launch/mod.rs +++ b/crates/node/builder/src/launch/mod.rs @@ -196,12 +196,10 @@ where // create the launch context for the exex let context = ExExContext { head, - provider: blockchain_db.clone(), - task_executor: ctx.task_executor().clone(), data_dir: ctx.data_dir().clone(), config: ctx.node_config().clone(), reth_config: ctx.toml_config().clone(), - pool: node_adapter.components.pool().clone(), + components: node_adapter.clone(), events, notifications, };