-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add version_specific_fields method to EngineTypes (#6050)
- Loading branch information
Showing
9 changed files
with
135 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ serde.workspace = true | |
reth-payload-builder.workspace = true | ||
|
||
[features] | ||
optimism = [] | ||
optimism = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ reth-node-api.workspace = true | |
|
||
# io | ||
serde.workspace = true | ||
|
||
[features] | ||
optimism = ["reth-node-api/optimism"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,54 @@ | ||
use reth_node_api::EngineTypes; | ||
use reth_payload_builder::{ | ||
EthBuiltPayload, EthPayloadBuilderAttributes, OptimismPayloadBuilderAttributes, | ||
#[cfg(feature = "optimism")] | ||
use reth_node_api::optimism_validate_version_specific_fields; | ||
use reth_node_api::{ | ||
validate_version_specific_fields, AttributesValidationError, EngineApiMessageVersion, | ||
EngineTypes, PayloadOrAttributes, | ||
}; | ||
use reth_rpc_types::engine::{OptimismPayloadAttributes, PayloadAttributes}; | ||
#[cfg(feature = "optimism")] | ||
use reth_payload_builder::OptimismPayloadBuilderAttributes; | ||
use reth_payload_builder::{EthBuiltPayload, EthPayloadBuilderAttributes}; | ||
use reth_primitives::ChainSpec; | ||
#[cfg(feature = "optimism")] | ||
use reth_rpc_types::engine::OptimismPayloadAttributes; | ||
use reth_rpc_types::engine::PayloadAttributes as EthPayloadAttributes; | ||
|
||
/// The types used in the default mainnet ethereum beacon consensus engine. | ||
#[derive(Debug, Default, Clone)] | ||
#[non_exhaustive] | ||
pub struct EthEngineTypes; | ||
|
||
impl EngineTypes for EthEngineTypes { | ||
type PayloadAttributes = PayloadAttributes; | ||
type PayloadAttributes = EthPayloadAttributes; | ||
type PayloadBuilderAttributes = EthPayloadBuilderAttributes; | ||
type BuiltPayload = EthBuiltPayload; | ||
|
||
fn validate_version_specific_fields( | ||
chain_spec: &ChainSpec, | ||
version: EngineApiMessageVersion, | ||
payload_or_attrs: PayloadOrAttributes<'_, EthPayloadAttributes>, | ||
) -> Result<(), AttributesValidationError> { | ||
validate_version_specific_fields(chain_spec, version, payload_or_attrs) | ||
} | ||
} | ||
|
||
#[cfg(feature = "optimism")] | ||
/// The types used in the optimism beacon consensus engine. | ||
#[derive(Debug, Default, Clone)] | ||
#[non_exhaustive] | ||
pub struct OptimismEngineTypes; | ||
|
||
// TODO: remove cfg once Hardfork::Canyon can be used without the flag | ||
#[cfg(feature = "optimism")] | ||
impl EngineTypes for OptimismEngineTypes { | ||
type PayloadAttributes = OptimismPayloadAttributes; | ||
type PayloadBuilderAttributes = OptimismPayloadBuilderAttributes; | ||
type BuiltPayload = EthBuiltPayload; | ||
|
||
fn validate_version_specific_fields( | ||
chain_spec: &ChainSpec, | ||
version: EngineApiMessageVersion, | ||
payload_or_attrs: PayloadOrAttributes<'_, OptimismPayloadAttributes>, | ||
) -> Result<(), AttributesValidationError> { | ||
optimism_validate_version_specific_fields(chain_spec, version, payload_or_attrs) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters