Skip to content

Commit

Permalink
feat: _V3 engine api skeletons
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jul 26, 2023
1 parent caa2683 commit 29e859d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
16 changes: 16 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,14 @@ pub trait EngineApi {
#[method(name = "newPayloadV2")]
async fn new_payload_v2(&self, payload: ExecutionPayload) -> RpcResult<PayloadStatus>;

/// Post Cancun payload handler
#[method(name = "newPayloadV3")]
async fn new_payload_v3(
&self,
payload: ExecutionPayload,
versioned_hashes: Vec<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 +67,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
14 changes: 13 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,14 @@ where
Ok(EngineApi::new_payload_v2(self, payload).await?)
}

async fn new_payload_v3(
&self,
_payload: ExecutionPayload,
_versioned_hashes: Vec<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 +417,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

0 comments on commit 29e859d

Please sign in to comment.