mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-11 00:08:13 -05:00
chore: relax bounds from EngineTypes to PayloadTypes (#15239)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use alloy_consensus::Sealable;
|
||||
use alloy_primitives::B256;
|
||||
use reth_node_api::{
|
||||
BeaconConsensusEngineHandle, BuiltPayload, EngineApiMessageVersion, EngineTypes,
|
||||
ExecutionPayload, NodePrimitives,
|
||||
BeaconConsensusEngineHandle, BuiltPayload, EngineApiMessageVersion, ExecutionPayload,
|
||||
NodePrimitives, PayloadTypes,
|
||||
};
|
||||
use reth_primitives_traits::{Block, SealedBlock};
|
||||
use reth_tracing::tracing::warn;
|
||||
@@ -60,14 +60,14 @@ pub trait BlockProvider: Send + Sync + 'static {
|
||||
/// Debug consensus client that sends FCUs and new payloads using recent blocks from an external
|
||||
/// provider like Etherscan or an RPC endpoint.
|
||||
#[derive(Debug)]
|
||||
pub struct DebugConsensusClient<P: BlockProvider, T: EngineTypes> {
|
||||
pub struct DebugConsensusClient<P: BlockProvider, T: PayloadTypes> {
|
||||
/// Handle to execution client.
|
||||
engine_handle: BeaconConsensusEngineHandle<T>,
|
||||
/// Provider to get consensus blocks from.
|
||||
block_provider: P,
|
||||
}
|
||||
|
||||
impl<P: BlockProvider, T: EngineTypes> DebugConsensusClient<P, T> {
|
||||
impl<P: BlockProvider, T: PayloadTypes> DebugConsensusClient<P, T> {
|
||||
/// Create a new debug consensus client with the given handle to execution
|
||||
/// client and block provider.
|
||||
pub const fn new(engine_handle: BeaconConsensusEngineHandle<T>, block_provider: P) -> Self {
|
||||
@@ -78,7 +78,7 @@ impl<P: BlockProvider, T: EngineTypes> DebugConsensusClient<P, T> {
|
||||
impl<P, T> DebugConsensusClient<P, T>
|
||||
where
|
||||
P: BlockProvider + Clone,
|
||||
T: EngineTypes<BuiltPayload: BuiltPayload<Primitives: NodePrimitives<Block = P::Block>>>,
|
||||
T: PayloadTypes<BuiltPayload: BuiltPayload<Primitives: NodePrimitives<Block = P::Block>>>,
|
||||
{
|
||||
/// Spawn the client to start sending FCUs and new payloads by periodically fetching recent
|
||||
/// blocks.
|
||||
|
||||
@@ -5,7 +5,7 @@ use alloy_primitives::{TxHash, B256};
|
||||
use alloy_rpc_types_engine::ForkchoiceState;
|
||||
use eyre::OptionExt;
|
||||
use futures_util::{stream::Fuse, StreamExt};
|
||||
use reth_engine_primitives::{BeaconEngineMessage, EngineTypes};
|
||||
use reth_engine_primitives::BeaconEngineMessage;
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_payload_primitives::{
|
||||
BuiltPayload, EngineApiMessageVersion, PayloadAttributesBuilder, PayloadKind, PayloadTypes,
|
||||
@@ -74,33 +74,33 @@ impl Future for MiningMode {
|
||||
|
||||
/// Local miner advancing the chain/
|
||||
#[derive(Debug)]
|
||||
pub struct LocalMiner<EngineT: EngineTypes, B> {
|
||||
pub struct LocalMiner<T: PayloadTypes, B> {
|
||||
/// The payload attribute builder for the engine
|
||||
payload_attributes_builder: B,
|
||||
/// Sender for events to engine.
|
||||
to_engine: UnboundedSender<BeaconEngineMessage<EngineT>>,
|
||||
to_engine: UnboundedSender<BeaconEngineMessage<T>>,
|
||||
/// The mining mode for the engine
|
||||
mode: MiningMode,
|
||||
/// The payload builder for the engine
|
||||
payload_builder: PayloadBuilderHandle<EngineT>,
|
||||
payload_builder: PayloadBuilderHandle<T>,
|
||||
/// Timestamp for the next block.
|
||||
last_timestamp: u64,
|
||||
/// Stores latest mined blocks.
|
||||
last_block_hashes: Vec<B256>,
|
||||
}
|
||||
|
||||
impl<EngineT, B> LocalMiner<EngineT, B>
|
||||
impl<T, B> LocalMiner<T, B>
|
||||
where
|
||||
EngineT: EngineTypes,
|
||||
B: PayloadAttributesBuilder<<EngineT as PayloadTypes>::PayloadAttributes>,
|
||||
T: PayloadTypes,
|
||||
B: PayloadAttributesBuilder<<T as PayloadTypes>::PayloadAttributes>,
|
||||
{
|
||||
/// Spawns a new [`LocalMiner`] with the given parameters.
|
||||
pub fn spawn_new(
|
||||
provider: impl BlockReader,
|
||||
payload_attributes_builder: B,
|
||||
to_engine: UnboundedSender<BeaconEngineMessage<EngineT>>,
|
||||
to_engine: UnboundedSender<BeaconEngineMessage<T>>,
|
||||
mode: MiningMode,
|
||||
payload_builder: PayloadBuilderHandle<EngineT>,
|
||||
payload_builder: PayloadBuilderHandle<T>,
|
||||
) {
|
||||
let latest_header =
|
||||
provider.sealed_header(provider.best_block_number().unwrap()).unwrap().unwrap();
|
||||
@@ -207,7 +207,7 @@ where
|
||||
let block = payload.block();
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let payload = EngineT::block_to_payload(payload.block().clone());
|
||||
let payload = T::block_to_payload(payload.block().clone());
|
||||
self.to_engine.send(BeaconEngineMessage::NewPayload { payload, tx })?;
|
||||
|
||||
let res = rx.await??;
|
||||
|
||||
@@ -8,8 +8,9 @@ use crate::{
|
||||
use alloy_primitives::B256;
|
||||
use futures::{Stream, StreamExt};
|
||||
use reth_chain_state::ExecutedBlockWithTrieUpdates;
|
||||
use reth_engine_primitives::{BeaconConsensusEngineEvent, BeaconEngineMessage, EngineTypes};
|
||||
use reth_engine_primitives::{BeaconConsensusEngineEvent, BeaconEngineMessage};
|
||||
use reth_ethereum_primitives::EthPrimitives;
|
||||
use reth_payload_primitives::PayloadTypes;
|
||||
use reth_primitives_traits::{Block, NodePrimitives, RecoveredBlock};
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
@@ -241,14 +242,14 @@ impl EngineApiKind {
|
||||
|
||||
/// The request variants that the engine API handler can receive.
|
||||
#[derive(Debug)]
|
||||
pub enum EngineApiRequest<T: EngineTypes, N: NodePrimitives> {
|
||||
pub enum EngineApiRequest<T: PayloadTypes, N: NodePrimitives> {
|
||||
/// A request received from the consensus engine.
|
||||
Beacon(BeaconEngineMessage<T>),
|
||||
/// Request to insert an already executed block, e.g. via payload building.
|
||||
InsertExecutedBlock(ExecutedBlockWithTrieUpdates<N>),
|
||||
}
|
||||
|
||||
impl<T: EngineTypes, N: NodePrimitives> Display for EngineApiRequest<T, N> {
|
||||
impl<T: PayloadTypes, N: NodePrimitives> Display for EngineApiRequest<T, N> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Beacon(msg) => msg.fmt(f),
|
||||
@@ -259,13 +260,13 @@ impl<T: EngineTypes, N: NodePrimitives> Display for EngineApiRequest<T, N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EngineTypes, N: NodePrimitives> From<BeaconEngineMessage<T>> for EngineApiRequest<T, N> {
|
||||
impl<T: PayloadTypes, N: NodePrimitives> From<BeaconEngineMessage<T>> for EngineApiRequest<T, N> {
|
||||
fn from(msg: BeaconEngineMessage<T>) -> Self {
|
||||
Self::Beacon(msg)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EngineTypes, N: NodePrimitives> From<EngineApiRequest<T, N>>
|
||||
impl<T: PayloadTypes, N: NodePrimitives> From<EngineApiRequest<T, N>>
|
||||
for FromEngine<EngineApiRequest<T, N>, N::Block>
|
||||
{
|
||||
fn from(req: EngineApiRequest<T, N>) -> Self {
|
||||
|
||||
@@ -26,14 +26,14 @@ use reth_chain_state::{
|
||||
use reth_consensus::{Consensus, FullConsensus};
|
||||
pub use reth_engine_primitives::InvalidBlockHook;
|
||||
use reth_engine_primitives::{
|
||||
BeaconConsensusEngineEvent, BeaconEngineMessage, BeaconOnNewPayloadError, EngineTypes,
|
||||
EngineValidator, ExecutionPayload, ForkchoiceStateTracker, OnForkChoiceUpdated,
|
||||
BeaconConsensusEngineEvent, BeaconEngineMessage, BeaconOnNewPayloadError, EngineValidator,
|
||||
ExecutionPayload, ForkchoiceStateTracker, OnForkChoiceUpdated,
|
||||
};
|
||||
use reth_errors::{ConsensusError, ProviderResult};
|
||||
use reth_ethereum_primitives::EthPrimitives;
|
||||
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvm};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_payload_primitives::{EngineApiMessageVersion, PayloadBuilderAttributes};
|
||||
use reth_payload_primitives::{EngineApiMessageVersion, PayloadBuilderAttributes, PayloadTypes};
|
||||
use reth_primitives_traits::{
|
||||
Block, GotExpected, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader,
|
||||
};
|
||||
@@ -562,7 +562,7 @@ pub enum TreeAction {
|
||||
pub struct EngineApiTreeHandler<N, P, E, T, V, C>
|
||||
where
|
||||
N: NodePrimitives,
|
||||
T: EngineTypes,
|
||||
T: PayloadTypes,
|
||||
{
|
||||
provider: P,
|
||||
executor_provider: E,
|
||||
@@ -608,7 +608,7 @@ where
|
||||
payload_processor: PayloadProcessor<N, C>,
|
||||
}
|
||||
|
||||
impl<N, P: Debug, E: Debug, T: EngineTypes + Debug, V: Debug, C: Debug> std::fmt::Debug
|
||||
impl<N, P: Debug, E: Debug, T: PayloadTypes + Debug, V: Debug, C: Debug> std::fmt::Debug
|
||||
for EngineApiTreeHandler<N, P, E, T, V, C>
|
||||
where
|
||||
N: NodePrimitives,
|
||||
@@ -650,7 +650,7 @@ where
|
||||
BlockReader<Block = N::Block, Header = N::BlockHeader>,
|
||||
E: BlockExecutorProvider<Primitives = N>,
|
||||
C: ConfigureEvm<Primitives = N> + 'static,
|
||||
T: EngineTypes,
|
||||
T: PayloadTypes,
|
||||
V: EngineValidator<T, Block = N::Block>,
|
||||
{
|
||||
/// Creates a new [`EngineApiTreeHandler`].
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
use alloy_rpc_types_engine::ForkchoiceState;
|
||||
use futures::{Stream, StreamExt};
|
||||
use reth_engine_primitives::{BeaconEngineMessage, EngineTypes, ExecutionPayload};
|
||||
use reth_engine_primitives::{BeaconEngineMessage, ExecutionPayload};
|
||||
use reth_fs_util as fs;
|
||||
use reth_payload_primitives::PayloadTypes;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
@@ -17,19 +18,19 @@ use tracing::*;
|
||||
/// A message from the engine API that has been stored to disk.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum StoredEngineApiMessage<EngineT: EngineTypes> {
|
||||
pub enum StoredEngineApiMessage<T: PayloadTypes> {
|
||||
/// The on-disk representation of an `engine_forkchoiceUpdated` method call.
|
||||
ForkchoiceUpdated {
|
||||
/// The [`ForkchoiceState`] sent in the persisted call.
|
||||
state: ForkchoiceState,
|
||||
/// The payload attributes sent in the persisted call, if any.
|
||||
payload_attrs: Option<EngineT::PayloadAttributes>,
|
||||
payload_attrs: Option<T::PayloadAttributes>,
|
||||
},
|
||||
/// The on-disk representation of an `engine_newPayload` method call.
|
||||
NewPayload {
|
||||
/// The [`PayloadTypes::ExecutionData`](reth_payload_primitives::PayloadTypes::ExecutionData) sent in the persisted call.
|
||||
/// The [`PayloadTypes::ExecutionData`] sent in the persisted call.
|
||||
#[serde(flatten)]
|
||||
payload: EngineT::ExecutionData,
|
||||
payload: T::ExecutionData,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -50,13 +51,13 @@ impl EngineMessageStore {
|
||||
|
||||
/// Stores the received [`BeaconEngineMessage`] to disk, appending the `received_at` time to the
|
||||
/// path.
|
||||
pub fn on_message<Engine>(
|
||||
pub fn on_message<T>(
|
||||
&self,
|
||||
msg: &BeaconEngineMessage<Engine>,
|
||||
msg: &BeaconEngineMessage<T>,
|
||||
received_at: SystemTime,
|
||||
) -> eyre::Result<()>
|
||||
where
|
||||
Engine: EngineTypes,
|
||||
T: PayloadTypes,
|
||||
{
|
||||
fs::create_dir_all(&self.path)?; // ensure that store path had been created
|
||||
let timestamp = received_at.duration_since(SystemTime::UNIX_EPOCH).unwrap().as_millis();
|
||||
@@ -70,7 +71,7 @@ impl EngineMessageStore {
|
||||
let filename = format!("{}-fcu-{}.json", timestamp, state.head_block_hash);
|
||||
fs::write(
|
||||
self.path.join(filename),
|
||||
serde_json::to_vec(&StoredEngineApiMessage::<Engine>::ForkchoiceUpdated {
|
||||
serde_json::to_vec(&StoredEngineApiMessage::<T>::ForkchoiceUpdated {
|
||||
state: *state,
|
||||
payload_attrs: payload_attrs.clone(),
|
||||
})?,
|
||||
@@ -80,7 +81,7 @@ impl EngineMessageStore {
|
||||
let filename = format!("{}-new_payload-{}.json", timestamp, payload.block_hash());
|
||||
fs::write(
|
||||
self.path.join(filename),
|
||||
serde_json::to_vec(&StoredEngineApiMessage::<Engine>::NewPayload {
|
||||
serde_json::to_vec(&StoredEngineApiMessage::<T>::NewPayload {
|
||||
payload: payload.clone(),
|
||||
})?,
|
||||
)?;
|
||||
@@ -131,10 +132,10 @@ impl<S> EngineStoreStream<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, Engine> Stream for EngineStoreStream<S>
|
||||
impl<S, T> Stream for EngineStoreStream<S>
|
||||
where
|
||||
S: Stream<Item = BeaconEngineMessage<Engine>>,
|
||||
Engine: EngineTypes,
|
||||
S: Stream<Item = BeaconEngineMessage<T>>,
|
||||
T: PayloadTypes,
|
||||
{
|
||||
type Item = S::Item;
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
|
||||
use futures::Stream;
|
||||
use reth_engine_primitives::{BeaconEngineMessage, EngineTypes};
|
||||
use reth_engine_primitives::BeaconEngineMessage;
|
||||
use reth_payload_primitives::PayloadTypes;
|
||||
use std::path::PathBuf;
|
||||
use tokio_util::either::Either;
|
||||
|
||||
@@ -26,9 +27,7 @@ pub mod reorg;
|
||||
use reorg::EngineReorg;
|
||||
|
||||
/// The collection of stream extensions for engine API message stream.
|
||||
pub trait EngineMessageStreamExt<Engine: EngineTypes>:
|
||||
Stream<Item = BeaconEngineMessage<Engine>>
|
||||
{
|
||||
pub trait EngineMessageStreamExt<T: PayloadTypes>: Stream<Item = BeaconEngineMessage<T>> {
|
||||
/// Skips the specified number of [`BeaconEngineMessage::ForkchoiceUpdated`] messages from the
|
||||
/// engine message stream.
|
||||
fn skip_fcu(self, count: usize) -> EngineSkipFcu<Self>
|
||||
@@ -108,7 +107,7 @@ pub trait EngineMessageStreamExt<Engine: EngineTypes>:
|
||||
payload_validator: Validator,
|
||||
frequency: usize,
|
||||
depth: Option<usize>,
|
||||
) -> EngineReorg<Self, Engine, Provider, Evm, Validator>
|
||||
) -> EngineReorg<Self, T, Provider, Evm, Validator>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
@@ -131,7 +130,7 @@ pub trait EngineMessageStreamExt<Engine: EngineTypes>:
|
||||
payload_validator: Validator,
|
||||
frequency: Option<usize>,
|
||||
depth: Option<usize>,
|
||||
) -> Either<EngineReorg<Self, Engine, Provider, Evm, Validator>, Self>
|
||||
) -> Either<EngineReorg<Self, T, Provider, Evm, Validator>, Self>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
@@ -150,9 +149,9 @@ pub trait EngineMessageStreamExt<Engine: EngineTypes>:
|
||||
}
|
||||
}
|
||||
|
||||
impl<Engine, T> EngineMessageStreamExt<Engine> for T
|
||||
impl<T, S> EngineMessageStreamExt<T> for S
|
||||
where
|
||||
Engine: EngineTypes,
|
||||
T: Stream<Item = BeaconEngineMessage<Engine>>,
|
||||
T: PayloadTypes,
|
||||
S: Stream<Item = BeaconEngineMessage<T>>,
|
||||
{
|
||||
}
|
||||
|
||||
@@ -6,15 +6,15 @@ use futures::{stream::FuturesUnordered, Stream, StreamExt, TryFutureExt};
|
||||
use itertools::Either;
|
||||
use reth_chainspec::{ChainSpecProvider, EthChainSpec};
|
||||
use reth_engine_primitives::{
|
||||
BeaconEngineMessage, BeaconOnNewPayloadError, EngineTypes, ExecutionPayload as _,
|
||||
OnForkChoiceUpdated, PayloadValidator,
|
||||
BeaconEngineMessage, BeaconOnNewPayloadError, ExecutionPayload as _, OnForkChoiceUpdated,
|
||||
PayloadValidator,
|
||||
};
|
||||
use reth_errors::{BlockExecutionError, BlockValidationError, RethError, RethResult};
|
||||
use reth_evm::{
|
||||
execute::{BlockBuilder, BlockBuilderOutcome},
|
||||
ConfigureEvm,
|
||||
};
|
||||
use reth_payload_primitives::{BuiltPayload, EngineApiMessageVersion};
|
||||
use reth_payload_primitives::{BuiltPayload, EngineApiMessageVersion, PayloadTypes};
|
||||
use reth_primitives_traits::{
|
||||
block::Block as _, BlockBody as _, BlockTy, HeaderTy, SealedBlock, SignedTransaction,
|
||||
};
|
||||
@@ -30,9 +30,9 @@ use tokio::sync::oneshot;
|
||||
use tracing::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum EngineReorgState<Engine: EngineTypes> {
|
||||
enum EngineReorgState<T: PayloadTypes> {
|
||||
Forward,
|
||||
Reorg { queue: VecDeque<BeaconEngineMessage<Engine>> },
|
||||
Reorg { queue: VecDeque<BeaconEngineMessage<T>> },
|
||||
}
|
||||
|
||||
type EngineReorgResponse = Result<
|
||||
@@ -45,7 +45,7 @@ type ReorgResponseFut = Pin<Box<dyn Future<Output = EngineReorgResponse> + Send
|
||||
/// Engine API stream wrapper that simulates reorgs with specified frequency.
|
||||
#[derive(Debug)]
|
||||
#[pin_project::pin_project]
|
||||
pub struct EngineReorg<S, Engine: EngineTypes, Provider, Evm, Validator> {
|
||||
pub struct EngineReorg<S, T: PayloadTypes, Provider, Evm, Validator> {
|
||||
/// Underlying stream
|
||||
#[pin]
|
||||
stream: S,
|
||||
@@ -63,16 +63,14 @@ pub struct EngineReorg<S, Engine: EngineTypes, Provider, Evm, Validator> {
|
||||
/// This is reset after a reorg.
|
||||
forkchoice_states_forwarded: usize,
|
||||
/// Current state of the stream.
|
||||
state: EngineReorgState<Engine>,
|
||||
state: EngineReorgState<T>,
|
||||
/// Last forkchoice state.
|
||||
last_forkchoice_state: Option<ForkchoiceState>,
|
||||
/// Pending engine responses to reorg messages.
|
||||
reorg_responses: FuturesUnordered<ReorgResponseFut>,
|
||||
}
|
||||
|
||||
impl<S, Engine: EngineTypes, Provider, Evm, Validator>
|
||||
EngineReorg<S, Engine, Provider, Evm, Validator>
|
||||
{
|
||||
impl<S, T: PayloadTypes, Provider, Evm, Validator> EngineReorg<S, T, Provider, Evm, Validator> {
|
||||
/// Creates new [`EngineReorg`] stream wrapper.
|
||||
pub fn new(
|
||||
stream: S,
|
||||
@@ -97,17 +95,15 @@ impl<S, Engine: EngineTypes, Provider, Evm, Validator>
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, Engine, Provider, Evm, Validator> Stream
|
||||
for EngineReorg<S, Engine, Provider, Evm, Validator>
|
||||
impl<S, T, Provider, Evm, Validator> Stream for EngineReorg<S, T, Provider, Evm, Validator>
|
||||
where
|
||||
S: Stream<Item = BeaconEngineMessage<Engine>>,
|
||||
Engine: EngineTypes<BuiltPayload: BuiltPayload<Primitives = Evm::Primitives>>,
|
||||
S: Stream<Item = BeaconEngineMessage<T>>,
|
||||
T: PayloadTypes<BuiltPayload: BuiltPayload<Primitives = Evm::Primitives>>,
|
||||
Provider: BlockReader<Header = HeaderTy<Evm::Primitives>, Block = BlockTy<Evm::Primitives>>
|
||||
+ StateProviderFactory
|
||||
+ ChainSpecProvider,
|
||||
Evm: ConfigureEvm,
|
||||
Validator:
|
||||
PayloadValidator<ExecutionData = Engine::ExecutionData, Block = BlockTy<Evm::Primitives>>,
|
||||
Validator: PayloadValidator<ExecutionData = T::ExecutionData, Block = BlockTy<Evm::Primitives>>,
|
||||
{
|
||||
type Item = S::Item;
|
||||
|
||||
@@ -198,7 +194,7 @@ where
|
||||
BeaconEngineMessage::NewPayload { payload, tx },
|
||||
// Reorg payload
|
||||
BeaconEngineMessage::NewPayload {
|
||||
payload: Engine::block_to_payload(reorg_block),
|
||||
payload: T::block_to_payload(reorg_block),
|
||||
tx: reorg_payload_tx,
|
||||
},
|
||||
// Reorg forkchoice state
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! Stream wrapper that skips specified number of FCUs.
|
||||
|
||||
use futures::{Stream, StreamExt};
|
||||
use reth_engine_primitives::{BeaconEngineMessage, EngineTypes, OnForkChoiceUpdated};
|
||||
use reth_engine_primitives::{BeaconEngineMessage, OnForkChoiceUpdated};
|
||||
use reth_payload_primitives::PayloadTypes;
|
||||
use std::{
|
||||
pin::Pin,
|
||||
task::{ready, Context, Poll},
|
||||
@@ -31,10 +32,10 @@ impl<S> EngineSkipFcu<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, Engine> Stream for EngineSkipFcu<S>
|
||||
impl<S, T> Stream for EngineSkipFcu<S>
|
||||
where
|
||||
S: Stream<Item = BeaconEngineMessage<Engine>>,
|
||||
Engine: EngineTypes,
|
||||
S: Stream<Item = BeaconEngineMessage<T>>,
|
||||
T: PayloadTypes,
|
||||
{
|
||||
type Item = S::Item;
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
use alloy_rpc_types_engine::{PayloadStatus, PayloadStatusEnum};
|
||||
use futures::{Stream, StreamExt};
|
||||
use reth_engine_primitives::{BeaconEngineMessage, EngineTypes, ExecutionPayload};
|
||||
use reth_engine_primitives::{BeaconEngineMessage, ExecutionPayload};
|
||||
use reth_payload_primitives::PayloadTypes;
|
||||
use std::{
|
||||
pin::Pin,
|
||||
task::{ready, Context, Poll},
|
||||
@@ -27,10 +28,10 @@ impl<S> EngineSkipNewPayload<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, Engine> Stream for EngineSkipNewPayload<S>
|
||||
impl<S, T> Stream for EngineSkipNewPayload<S>
|
||||
where
|
||||
S: Stream<Item = BeaconEngineMessage<Engine>>,
|
||||
Engine: EngineTypes,
|
||||
S: Stream<Item = BeaconEngineMessage<T>>,
|
||||
T: PayloadTypes,
|
||||
{
|
||||
type Item = S::Item;
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ pub use alloy_rpc_types_engine::{
|
||||
ExecutionPayloadV1, PayloadAttributes as EthPayloadAttributes,
|
||||
};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_engine_primitives::{EngineTypes, EngineValidator, PayloadValidator};
|
||||
use reth_engine_primitives::{EngineValidator, PayloadValidator};
|
||||
use reth_ethereum_payload_builder::EthereumExecutionPayloadValidator;
|
||||
use reth_ethereum_primitives::Block;
|
||||
use reth_node_api::PayloadTypes;
|
||||
use reth_payload_primitives::{
|
||||
validate_execution_requests, validate_version_specific_fields, EngineApiMessageVersion,
|
||||
EngineObjectValidationError, NewPayloadError, PayloadOrAttributes,
|
||||
@@ -50,7 +51,7 @@ impl PayloadValidator for EthereumEngineValidator {
|
||||
|
||||
impl<Types> EngineValidator<Types> for EthereumEngineValidator
|
||||
where
|
||||
Types: EngineTypes<PayloadAttributes = EthPayloadAttributes, ExecutionData = ExecutionData>,
|
||||
Types: PayloadTypes<PayloadAttributes = EthPayloadAttributes, ExecutionData = ExecutionData>,
|
||||
{
|
||||
fn validate_version_specific_fields(
|
||||
&self,
|
||||
|
||||
@@ -165,7 +165,7 @@ where
|
||||
|
||||
impl<Types, P> EngineValidator<Types> for OpEngineValidator<P>
|
||||
where
|
||||
Types: EngineTypes<PayloadAttributes = OpPayloadAttributes, ExecutionData = OpExecutionData>,
|
||||
Types: PayloadTypes<PayloadAttributes = OpPayloadAttributes, ExecutionData = OpExecutionData>,
|
||||
P: StateProviderFactory + Unpin + 'static,
|
||||
{
|
||||
fn validate_version_specific_fields(
|
||||
|
||||
@@ -22,7 +22,7 @@ use reth_engine_primitives::{BeaconConsensusEngineHandle, EngineTypes, EngineVal
|
||||
use reth_payload_builder::PayloadStore;
|
||||
use reth_payload_primitives::{
|
||||
validate_payload_timestamp, EngineApiMessageVersion, ExecutionPayload,
|
||||
PayloadBuilderAttributes, PayloadOrAttributes,
|
||||
PayloadBuilderAttributes, PayloadOrAttributes, PayloadTypes,
|
||||
};
|
||||
use reth_primitives_traits::{Block, BlockBody};
|
||||
use reth_rpc_api::{EngineApiServer, IntoEngineApiRpcModule};
|
||||
@@ -55,19 +55,19 @@ const MAX_BLOB_LIMIT: usize = 128;
|
||||
/// Implementing support for an engine API jsonrpsee RPC handler is done by defining the engine API
|
||||
/// server trait and implementing it on a type that can wrap this [`EngineApi`] type.
|
||||
/// See also [`EngineApiServer`] implementation for this type which is the L1 implementation.
|
||||
pub struct EngineApi<Provider, EngineT: EngineTypes, Pool, Validator, ChainSpec> {
|
||||
inner: Arc<EngineApiInner<Provider, EngineT, Pool, Validator, ChainSpec>>,
|
||||
pub struct EngineApi<Provider, PayloadT: PayloadTypes, Pool, Validator, ChainSpec> {
|
||||
inner: Arc<EngineApiInner<Provider, PayloadT, Pool, Validator, ChainSpec>>,
|
||||
}
|
||||
|
||||
struct EngineApiInner<Provider, EngineT: EngineTypes, Pool, Validator, ChainSpec> {
|
||||
struct EngineApiInner<Provider, PayloadT: PayloadTypes, Pool, Validator, ChainSpec> {
|
||||
/// The provider to interact with the chain.
|
||||
provider: Provider,
|
||||
/// Consensus configuration
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
/// The channel to send messages to the beacon consensus engine.
|
||||
beacon_consensus: BeaconConsensusEngineHandle<EngineT>,
|
||||
beacon_consensus: BeaconConsensusEngineHandle<PayloadT>,
|
||||
/// The type that can communicate with the payload service to retrieve payloads.
|
||||
payload_store: PayloadStore<EngineT>,
|
||||
payload_store: PayloadStore<PayloadT>,
|
||||
/// For spawning and executing async tasks
|
||||
task_spawner: Box<dyn TaskSpawner>,
|
||||
/// The latency and response type metrics for engine api calls
|
||||
@@ -865,10 +865,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Provider, EngineT, Pool, Validator, ChainSpec>
|
||||
EngineApiInner<Provider, EngineT, Pool, Validator, ChainSpec>
|
||||
impl<Provider, PayloadT, Pool, Validator, ChainSpec>
|
||||
EngineApiInner<Provider, PayloadT, Pool, Validator, ChainSpec>
|
||||
where
|
||||
EngineT: EngineTypes,
|
||||
PayloadT: PayloadTypes,
|
||||
{
|
||||
/// Tracks the elapsed time between the new payload response and the received forkchoice update
|
||||
/// request.
|
||||
@@ -1161,10 +1161,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Provider, EngineT, Pool, Validator, ChainSpec> std::fmt::Debug
|
||||
for EngineApi<Provider, EngineT, Pool, Validator, ChainSpec>
|
||||
impl<Provider, PayloadT, Pool, Validator, ChainSpec> std::fmt::Debug
|
||||
for EngineApi<Provider, PayloadT, Pool, Validator, ChainSpec>
|
||||
where
|
||||
EngineT: EngineTypes,
|
||||
PayloadT: PayloadTypes,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("EngineApi").finish_non_exhaustive()
|
||||
|
||||
@@ -210,7 +210,7 @@ impl PayloadValidator for CustomEngineValidator {
|
||||
|
||||
impl<T> EngineValidator<T> for CustomEngineValidator
|
||||
where
|
||||
T: EngineTypes<PayloadAttributes = CustomPayloadAttributes, ExecutionData = ExecutionData>,
|
||||
T: PayloadTypes<PayloadAttributes = CustomPayloadAttributes, ExecutionData = ExecutionData>,
|
||||
{
|
||||
fn validate_version_specific_fields(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user