mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add ChainSpec AT to EngineTypes (#11054)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -6990,7 +6990,6 @@ name = "reth-engine-primitives"
|
|||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"reth-chainspec",
|
|
||||||
"reth-execution-types",
|
"reth-execution-types",
|
||||||
"reth-payload-primitives",
|
"reth-payload-primitives",
|
||||||
"reth-primitives",
|
"reth-primitives",
|
||||||
|
|||||||
@ -12,7 +12,6 @@ workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# reth
|
# reth
|
||||||
reth-chainspec.workspace = true
|
|
||||||
reth-execution-types.workspace = true
|
reth-execution-types.workspace = true
|
||||||
reth-payload-primitives.workspace = true
|
reth-payload-primitives.workspace = true
|
||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
mod invalid_block_hook;
|
mod invalid_block_hook;
|
||||||
pub use invalid_block_hook::InvalidBlockHook;
|
pub use invalid_block_hook::InvalidBlockHook;
|
||||||
|
|
||||||
use reth_chainspec::ChainSpec;
|
|
||||||
pub use reth_payload_primitives::{
|
pub use reth_payload_primitives::{
|
||||||
BuiltPayload, EngineApiMessageVersion, EngineObjectValidationError, PayloadOrAttributes,
|
BuiltPayload, EngineApiMessageVersion, EngineObjectValidationError, PayloadOrAttributes,
|
||||||
PayloadTypes,
|
PayloadTypes,
|
||||||
@ -32,6 +31,9 @@ pub trait EngineTypes:
|
|||||||
+ Serialize
|
+ Serialize
|
||||||
+ 'static
|
+ 'static
|
||||||
{
|
{
|
||||||
|
/// The chain specification of the node.
|
||||||
|
type ChainSpec: Send + Sync;
|
||||||
|
|
||||||
/// Execution Payload V1 type.
|
/// Execution Payload V1 type.
|
||||||
type ExecutionPayloadV1: DeserializeOwned + Serialize + Clone + Unpin + Send + Sync + 'static;
|
type ExecutionPayloadV1: DeserializeOwned + Serialize + Clone + Unpin + Send + Sync + 'static;
|
||||||
/// Execution Payload V2 type.
|
/// Execution Payload V2 type.
|
||||||
@ -44,7 +46,7 @@ pub trait EngineTypes:
|
|||||||
/// Validates the presence or exclusion of fork-specific fields based on the payload attributes
|
/// Validates the presence or exclusion of fork-specific fields based on the payload attributes
|
||||||
/// and the message version.
|
/// and the message version.
|
||||||
fn validate_version_specific_fields(
|
fn validate_version_specific_fields(
|
||||||
chain_spec: &ChainSpec,
|
chain_spec: &Self::ChainSpec,
|
||||||
version: EngineApiMessageVersion,
|
version: EngineApiMessageVersion,
|
||||||
payload_or_attrs: PayloadOrAttributes<'_, Self::PayloadAttributes>,
|
payload_or_attrs: PayloadOrAttributes<'_, Self::PayloadAttributes>,
|
||||||
) -> Result<(), EngineObjectValidationError>;
|
) -> Result<(), EngineObjectValidationError>;
|
||||||
|
|||||||
@ -36,6 +36,8 @@ impl PayloadTypes for EthEngineTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl EngineTypes for EthEngineTypes {
|
impl EngineTypes for EthEngineTypes {
|
||||||
|
type ChainSpec = ChainSpec;
|
||||||
|
|
||||||
type ExecutionPayloadV1 = ExecutionPayloadV1;
|
type ExecutionPayloadV1 = ExecutionPayloadV1;
|
||||||
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
|
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
|
||||||
type ExecutionPayloadV3 = ExecutionPayloadEnvelopeV3;
|
type ExecutionPayloadV3 = ExecutionPayloadEnvelopeV3;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ pub trait NodeTypes: Send + Sync + Unpin + 'static {
|
|||||||
/// The type that configures an Ethereum-like node with an engine for consensus.
|
/// The type that configures an Ethereum-like node with an engine for consensus.
|
||||||
pub trait NodeTypesWithEngine: NodeTypes {
|
pub trait NodeTypesWithEngine: NodeTypes {
|
||||||
/// The node's engine types, defining the interaction with the consensus engine.
|
/// The node's engine types, defining the interaction with the consensus engine.
|
||||||
type Engine: EngineTypes;
|
type Engine: EngineTypes<ChainSpec = Self::ChainSpec>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A helper trait that is downstream of the [`NodeTypesWithEngine`] trait and adds database to the
|
/// A helper trait that is downstream of the [`NodeTypesWithEngine`] trait and adds database to the
|
||||||
@ -166,7 +166,7 @@ where
|
|||||||
impl<P, E, C> NodeTypesWithEngine for AnyNodeTypesWithEngine<P, E, C>
|
impl<P, E, C> NodeTypesWithEngine for AnyNodeTypesWithEngine<P, E, C>
|
||||||
where
|
where
|
||||||
P: NodePrimitives + Send + Sync + Unpin + 'static,
|
P: NodePrimitives + Send + Sync + Unpin + 'static,
|
||||||
E: EngineTypes + Send + Sync + Unpin,
|
E: EngineTypes<ChainSpec = C> + Send + Sync + Unpin,
|
||||||
C: EthChainSpec,
|
C: EthChainSpec,
|
||||||
{
|
{
|
||||||
type Engine = E;
|
type Engine = E;
|
||||||
|
|||||||
@ -27,6 +27,8 @@ impl PayloadTypes for OptimismEngineTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl EngineTypes for OptimismEngineTypes {
|
impl EngineTypes for OptimismEngineTypes {
|
||||||
|
type ChainSpec = ChainSpec;
|
||||||
|
|
||||||
type ExecutionPayloadV1 = ExecutionPayloadV1;
|
type ExecutionPayloadV1 = ExecutionPayloadV1;
|
||||||
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
|
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
|
||||||
type ExecutionPayloadV3 = OptimismExecutionPayloadEnvelopeV3;
|
type ExecutionPayloadV3 = OptimismExecutionPayloadEnvelopeV3;
|
||||||
|
|||||||
@ -71,7 +71,7 @@ struct EngineApiInner<Provider, EngineT: EngineTypes, Pool> {
|
|||||||
impl<Provider, EngineT, Pool> EngineApi<Provider, EngineT, Pool>
|
impl<Provider, EngineT, Pool> EngineApi<Provider, EngineT, Pool>
|
||||||
where
|
where
|
||||||
Provider: HeaderProvider + BlockReader + StateProviderFactory + EvmEnvProvider + 'static,
|
Provider: HeaderProvider + BlockReader + StateProviderFactory + EvmEnvProvider + 'static,
|
||||||
EngineT: EngineTypes,
|
EngineT: EngineTypes<ChainSpec = ChainSpec>,
|
||||||
Pool: TransactionPool + 'static,
|
Pool: TransactionPool + 'static,
|
||||||
{
|
{
|
||||||
/// Create new instance of [`EngineApi`].
|
/// Create new instance of [`EngineApi`].
|
||||||
@ -622,7 +622,7 @@ where
|
|||||||
impl<Provider, EngineT, Pool> EngineApiServer<EngineT> for EngineApi<Provider, EngineT, Pool>
|
impl<Provider, EngineT, Pool> EngineApiServer<EngineT> for EngineApi<Provider, EngineT, Pool>
|
||||||
where
|
where
|
||||||
Provider: HeaderProvider + BlockReader + StateProviderFactory + EvmEnvProvider + 'static,
|
Provider: HeaderProvider + BlockReader + StateProviderFactory + EvmEnvProvider + 'static,
|
||||||
EngineT: EngineTypes,
|
EngineT: EngineTypes<ChainSpec = ChainSpec>,
|
||||||
Pool: TransactionPool + 'static,
|
Pool: TransactionPool + 'static,
|
||||||
{
|
{
|
||||||
/// Handler for `engine_newPayloadV1`
|
/// Handler for `engine_newPayloadV1`
|
||||||
|
|||||||
@ -167,6 +167,8 @@ impl PayloadTypes for CustomEngineTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl EngineTypes for CustomEngineTypes {
|
impl EngineTypes for CustomEngineTypes {
|
||||||
|
type ChainSpec = ChainSpec;
|
||||||
|
|
||||||
type ExecutionPayloadV1 = ExecutionPayloadV1;
|
type ExecutionPayloadV1 = ExecutionPayloadV1;
|
||||||
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
|
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
|
||||||
type ExecutionPayloadV3 = ExecutionPayloadEnvelopeV3;
|
type ExecutionPayloadV3 = ExecutionPayloadEnvelopeV3;
|
||||||
|
|||||||
Reference in New Issue
Block a user