Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use proper type for engine_newPayloadV2 #4630

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions crates/rpc/rpc-api/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use reth_primitives::{Address, BlockHash, BlockId, BlockNumberOrTag, Bytes, H256
use reth_rpc_types::{
engine::{
ExecutionPayloadBodiesV1, ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3,
ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, ForkchoiceState,
ExecutionPayloadFieldV2, ExecutionPayloadV1, ExecutionPayloadV3, ForkchoiceState,
ForkchoiceUpdated, PayloadAttributes, PayloadId, PayloadStatus, TransitionConfiguration,
},
state::StateOverride,
Expand All @@ -20,7 +20,7 @@ pub trait EngineApi {

/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/shanghai.md#engine_newpayloadv2>
#[method(name = "newPayloadV2")]
async fn new_payload_v2(&self, payload: ExecutionPayloadV2) -> RpcResult<PayloadStatus>;
async fn new_payload_v2(&self, payload: ExecutionPayloadFieldV2) -> RpcResult<PayloadStatus>;

/// Post Cancun payload handler
///
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc/rpc-engine-api/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use reth_provider::{BlockReader, EvmEnvProvider, HeaderProvider, StateProviderFa
use reth_rpc_api::EngineApiServer;
use reth_rpc_types::engine::{
CancunPayloadFields, ExecutionPayload, ExecutionPayloadBodiesV1, ExecutionPayloadEnvelopeV2,
ExecutionPayloadEnvelopeV3, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3,
ExecutionPayloadEnvelopeV3, ExecutionPayloadFieldV2, ExecutionPayloadV1, ExecutionPayloadV3,
ForkchoiceUpdated, PayloadAttributes, PayloadId, PayloadStatus, TransitionConfiguration,
CAPABILITIES,
};
Expand Down Expand Up @@ -82,7 +82,7 @@ where
/// See also <https://github.com/ethereum/execution-apis/blob/3d627c95a4d3510a8187dd02e0250ecb4331d27e/src/engine/shanghai.md#engine_newpayloadv2>
pub async fn new_payload_v2(
&self,
payload: ExecutionPayloadV2,
payload: ExecutionPayloadFieldV2,
) -> EngineApiResult<PayloadStatus> {
let payload = ExecutionPayload::from(payload);
let payload_or_attrs = PayloadOrAttributes::from_execution_payload(&payload, None);
Expand Down Expand Up @@ -593,7 +593,7 @@ where

/// Handler for `engine_newPayloadV2`
/// See also <https://github.com/ethereum/execution-apis/blob/3d627c95a4d3510a8187dd02e0250ecb4331d27e/src/engine/shanghai.md#engine_newpayloadv2>
async fn new_payload_v2(&self, payload: ExecutionPayloadV2) -> RpcResult<PayloadStatus> {
async fn new_payload_v2(&self, payload: ExecutionPayloadFieldV2) -> RpcResult<PayloadStatus> {
trace!(target: "rpc::engine", "Serving engine_newPayloadV2");
Ok(EngineApi::new_payload_v2(self, payload).await?)
}
Expand Down
9 changes: 9 additions & 0 deletions crates/rpc/rpc-types/src/eth/engine/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ impl From<SealedBlock> for ExecutionPayloadFieldV2 {
}
}

impl From<ExecutionPayloadFieldV2> for ExecutionPayload {
fn from(value: ExecutionPayloadFieldV2) -> Self {
match value {
ExecutionPayloadFieldV2::V1(payload) => ExecutionPayload::V1(payload),
ExecutionPayloadFieldV2::V2(payload) => ExecutionPayload::V2(payload),
}
}
}

/// This structure maps for the return value of `engine_getPayload` of the beacon chain spec, for
/// V2.
///
Expand Down
Loading