feat: introduce OpNetworkPrimitives (#13335)

This commit is contained in:
Dan Cline
2024-12-16 13:24:36 +02:00
committed by GitHub
parent 4405f1b3d3
commit 8b647d6ddf
10 changed files with 98 additions and 34 deletions

View File

@ -21,7 +21,7 @@ pub mod engine;
pub use engine::OpEngineTypes;
pub mod node;
pub use node::OpNode;
pub use node::{OpNetworkPrimitives, OpNode};
pub mod txpool;

View File

@ -11,7 +11,7 @@ use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGenera
use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks};
use reth_db::transaction::{DbTx, DbTxMut};
use reth_evm::{execute::BasicBlockExecutorProvider, ConfigureEvm};
use reth_network::{EthNetworkPrimitives, NetworkConfig, NetworkHandle, NetworkManager, PeersInfo};
use reth_network::{NetworkConfig, NetworkHandle, NetworkManager, NetworkPrimitives, PeersInfo};
use reth_node_api::{AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, TxTy};
use reth_node_builder::{
components::{
@ -621,7 +621,7 @@ impl OpNetworkBuilder {
pub fn network_config<Node>(
&self,
ctx: &BuilderContext<Node>,
) -> eyre::Result<NetworkConfig<<Node as FullNodeTypes>::Provider>>
) -> eyre::Result<NetworkConfig<<Node as FullNodeTypes>::Provider, OpNetworkPrimitives>>
where
Node: FullNodeTypes<Types: NodeTypes<ChainSpec: Hardforks>>,
{
@ -670,13 +670,13 @@ where
> + Unpin
+ 'static,
{
type Primitives = EthNetworkPrimitives;
type Primitives = OpNetworkPrimitives;
async fn build_network(
self,
ctx: &BuilderContext<Node>,
pool: Pool,
) -> eyre::Result<NetworkHandle> {
) -> eyre::Result<NetworkHandle<Self::Primitives>> {
let network_config = self.network_config(ctx)?;
let network = NetworkManager::builder(network_config).await?;
let handle = ctx.start_network(network, pool);
@ -722,3 +722,17 @@ where
Ok(OpEngineValidator::new(ctx.config.chain.clone()))
}
}
/// Network primitive types used by Optimism networks.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub struct OpNetworkPrimitives;
impl NetworkPrimitives for OpNetworkPrimitives {
type BlockHeader = alloy_consensus::Header;
type BlockBody = reth_primitives::BlockBody;
type Block = reth_primitives::Block;
type BroadcastedTransaction = reth_primitives::TransactionSigned;
type PooledTransaction = reth_primitives::PooledTransaction;
type Receipt = reth_primitives::Receipt;
}