Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/rpc/rpc-api/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ pub trait EngineApi {
#[method(name = "newPayloadV2")]
async fn new_payload_v2(&self, payload: ExecutionPayload) -> RpcResult<PayloadStatus>;

/// Post Cancun payload handler
///
/// See also <https://github.com/ethereum/execution-apis/blob/main/src/engine/cancun.md#engine_newpayloadv3>
#[method(name = "newPayloadV3")]
async fn new_payload_v3(
&self,
payload: ExecutionPayload,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll need to modify ExecutionPayload to include dataGasUsed and excessGasUsed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do this after we have this added to the header as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

versioned_hashes: Vec<H256>,
parent_beacon_block_root: H256,
) -> RpcResult<PayloadStatus>;

/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_forkchoiceupdatedv1>
///
/// Caution: This should not accept the `withdrawals` field
Expand Down Expand Up @@ -59,6 +70,14 @@ pub trait EngineApi {
#[method(name = "getPayloadV2")]
async fn get_payload_v2(&self, payload_id: PayloadId) -> RpcResult<ExecutionPayloadEnvelope>;

/// Post Cancun payload handler which also returns a blobs bundle.
///
/// Returns the most recent version of the payload that is available in the corresponding
/// payload build process at the time of receiving this call. Note:
/// > Provider software MAY stop the corresponding build process after serving this call.
#[method(name = "getPayloadV3")]
async fn get_payload_v3(&self, payload_id: PayloadId) -> RpcResult<ExecutionPayloadEnvelope>;

/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyhashv1>
#[method(name = "getPayloadBodiesByHashV1")]
async fn get_payload_bodies_by_hash_v1(
Expand Down
15 changes: 14 additions & 1 deletion crates/rpc/rpc-engine-api/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use jsonrpsee_core::RpcResult;
use reth_beacon_consensus::BeaconConsensusEngineHandle;
use reth_interfaces::consensus::ForkchoiceState;
use reth_payload_builder::PayloadStore;
use reth_primitives::{BlockHash, BlockHashOrNumber, BlockNumber, ChainSpec, Hardfork, U64};
use reth_primitives::{BlockHash, BlockHashOrNumber, BlockNumber, ChainSpec, Hardfork, H256, U64};
use reth_provider::{BlockReader, EvmEnvProvider, HeaderProvider, StateProviderFactory};
use reth_rpc_api::EngineApiServer;
use reth_rpc_types::engine::{
Expand Down Expand Up @@ -355,6 +355,15 @@ where
Ok(EngineApi::new_payload_v2(self, payload).await?)
}

async fn new_payload_v3(
&self,
_payload: ExecutionPayload,
_versioned_hashes: Vec<H256>,
_parent_beacon_block_root: H256,
) -> RpcResult<PayloadStatus> {
Err(jsonrpsee_types::error::ErrorCode::MethodNotFound.into())
}

/// Handler for `engine_forkchoiceUpdatedV1`
/// See also <https://github.com/ethereum/execution-apis/blob/3d627c95a4d3510a8187dd02e0250ecb4331d27e/src/engine/paris.md#engine_forkchoiceupdatedv1>
///
Expand Down Expand Up @@ -409,6 +418,10 @@ where
Ok(EngineApi::get_payload_v2(self, payload_id).await?)
}

async fn get_payload_v3(&self, _payload_id: PayloadId) -> RpcResult<ExecutionPayloadEnvelope> {
Err(jsonrpsee_types::error::ErrorCode::MethodNotFound.into())
}

/// Handler for `engine_getPayloadBodiesByHashV1`
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyhashv1>
async fn get_payload_bodies_by_hash_v1(
Expand Down
12 changes: 12 additions & 0 deletions crates/rpc/rpc-types/src/eth/engine/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pub struct ExecutionPayloadEnvelope {
/// The expected value to be received by the feeRecipient in wei
#[serde(rename = "blockValue")]
pub block_value: U256,
//
// // TODO(mattsse): for V3
// #[serde(rename = "blobsBundle", skip_serializing_if = "Option::is_none")]
// pub blobs_bundle: Option<BlobsBundleV1>,
}

impl ExecutionPayloadEnvelope {
Expand Down Expand Up @@ -187,6 +191,14 @@ impl TryFrom<ExecutionPayload> for SealedBlock {
}
}

/// This includes all bundled blob related data of an executed payload.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BlobsBundleV1 {
pub commitments: Vec<Bytes>,
pub proofs: Vec<Bytes>,
pub blobs: Vec<Bytes>,
}

/// Error that can occur when handling payloads.
#[derive(thiserror::Error, Debug)]
pub enum PayloadError {
Expand Down