integrate FullNodeComponents in exexcomponents (#8051)

This commit is contained in:
Darshan Kathiriya
2024-05-02 13:45:34 -04:00
committed by GitHub
parent 29be4072cb
commit 9eb7d961d7
4 changed files with 48 additions and 10 deletions

2
Cargo.lock generated
View File

@ -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",

View File

@ -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

View File

@ -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<Node: FullNodeComponents> {
/// 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<DataDirPath>,
/// 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<Node: FullNodeComponents> {
/// Once a an [`ExExNotification`] is sent over the channel, it is considered delivered by the
/// node.
pub notifications: Receiver<ExExNotification>,
/// node components
pub components: Node,
}
impl<Node: FullNodeComponents> NodeTypes for ExExContext<Node> {
type Primitives = Node::Primitives;
type Engine = Node::Engine;
}
impl<Node: FullNodeComponents> FullNodeTypes for ExExContext<Node> {
type DB = Node::DB;
type Provider = Node::Provider;
}
impl<Node: FullNodeComponents> FullNodeComponents for ExExContext<Node> {
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::Engine> {
self.components.payload_builder()
}
fn task_executor(&self) -> &TaskExecutor {
self.components.task_executor()
}
fn evm_config(&self) -> &Self::Evm {
self.components.evm_config()
}
}

View File

@ -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,
};