mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Upstream ExecutionData to alloy (#14188)
This commit is contained in:
@ -12,9 +12,9 @@
|
||||
extern crate alloc;
|
||||
|
||||
use alloy_consensus::BlockHeader;
|
||||
use alloy_eips::{eip7685::Requests, Decodable2718};
|
||||
use alloy_eips::eip7685::Requests;
|
||||
use alloy_primitives::B256;
|
||||
use alloy_rpc_types_engine::{ExecutionPayloadSidecar, PayloadError};
|
||||
use alloy_rpc_types_engine::{ExecutionData, PayloadError};
|
||||
use core::fmt::{self, Debug};
|
||||
use reth_payload_primitives::{
|
||||
validate_execution_requests, BuiltPayload, EngineApiMessageVersion,
|
||||
@ -23,7 +23,7 @@ use reth_payload_primitives::{
|
||||
};
|
||||
use reth_primitives::{NodePrimitives, SealedBlock};
|
||||
use reth_primitives_traits::Block;
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
mod error;
|
||||
pub use error::*;
|
||||
@ -40,41 +40,6 @@ pub use event::*;
|
||||
mod invalid_block_hook;
|
||||
pub use invalid_block_hook::InvalidBlockHook;
|
||||
|
||||
/// Struct aggregating [`alloy_rpc_types_engine::ExecutionPayload`] and [`ExecutionPayloadSidecar`]
|
||||
/// and encapsulating complete payload supplied for execution.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ExecutionData {
|
||||
/// Execution payload.
|
||||
pub payload: alloy_rpc_types_engine::ExecutionPayload,
|
||||
/// Additional fork-specific fields.
|
||||
pub sidecar: ExecutionPayloadSidecar,
|
||||
}
|
||||
|
||||
impl ExecutionData {
|
||||
/// Creates new instance of [`ExecutionData`].
|
||||
pub const fn new(
|
||||
payload: alloy_rpc_types_engine::ExecutionPayload,
|
||||
sidecar: ExecutionPayloadSidecar,
|
||||
) -> Self {
|
||||
Self { payload, sidecar }
|
||||
}
|
||||
|
||||
/// Tries to create a new unsealed block from the given payload and payload sidecar.
|
||||
///
|
||||
/// Performs additional validation of `extra_data` and `base_fee_per_gas` fields.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// The log bloom is assumed to be validated during serialization.
|
||||
///
|
||||
/// See <https://github.com/ethereum/go-ethereum/blob/79a478bb6176425c2400e949890e668a3d9a3d05/core/beacon/types.go#L145>
|
||||
pub fn try_into_block<T: Decodable2718>(
|
||||
self,
|
||||
) -> Result<alloy_consensus::Block<T>, PayloadError> {
|
||||
self.payload.try_into_block_with_sidecar(&self.sidecar)
|
||||
}
|
||||
}
|
||||
|
||||
/// An execution payload.
|
||||
pub trait ExecutionPayload:
|
||||
Serialize + DeserializeOwned + Debug + Clone + Send + Sync + 'static
|
||||
@ -152,7 +117,7 @@ pub trait EngineTypes:
|
||||
/// Execution data.
|
||||
type ExecutionData: ExecutionPayload;
|
||||
|
||||
/// Converts a [`BuiltPayload`] into an [`ExecutionPayload`] and [`ExecutionPayloadSidecar`].
|
||||
/// Converts a [`BuiltPayload`] into an [`ExecutionData`].
|
||||
fn block_to_payload(
|
||||
block: SealedBlock<
|
||||
<<Self::BuiltPayload as BuiltPayload>::Primitives as NodePrimitives>::Block,
|
||||
|
||||
Reference in New Issue
Block a user