From 3e7eba38bcf95ac925e7f68d7c6470d7943d93fe Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:57:07 -0400 Subject: [PATCH 1/2] feat: add engine API v4 methods --- crates/provider/src/ext/engine.rs | 45 +++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/crates/provider/src/ext/engine.rs b/crates/provider/src/ext/engine.rs index 803f1f1ccba..5516a2038c9 100644 --- a/crates/provider/src/ext/engine.rs +++ b/crates/provider/src/ext/engine.rs @@ -2,8 +2,9 @@ use alloy_network::Network; use alloy_primitives::{BlockHash, B256}; use alloy_rpc_types_engine::{ ClientVersionV1, ExecutionPayloadBodiesV1, ExecutionPayloadEnvelopeV2, - ExecutionPayloadEnvelopeV3, ExecutionPayloadInputV2, ExecutionPayloadV1, ExecutionPayloadV3, - ForkchoiceState, ForkchoiceUpdated, PayloadAttributes, PayloadId, PayloadStatus, + ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4, ExecutionPayloadInputV2, + ExecutionPayloadV1, ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, PayloadAttributes, + PayloadId, PayloadStatus, }; use alloy_transport::{Transport, TransportResult}; @@ -41,6 +42,16 @@ pub trait EngineApi: Send + Sync { parent_beacon_block_root: B256, ) -> TransportResult; + /// Sends the given payload to the execution layer client, as specified for the Prague fork. + /// + /// See also + async fn new_payload_v4( + &self, + payload: ExecutionPayloadV4, + versioned_hashes: Vec, + parent_beacon_block_root: B256, + ) -> TransportResult; + /// Updates the execution layer client with the given fork choice, as specified for the Paris /// fork. /// @@ -110,6 +121,18 @@ pub trait EngineApi: Send + Sync { payload_id: PayloadId, ) -> TransportResult; + /// Returns the most recent version of the payload that is available in the corresponding + /// payload build process at the time of receiving this call. + /// + /// See also + /// + /// Note: + /// > Provider software MAY stop the corresponding build process after serving this call. + async fn get_payload_v4( + &self, + payload_id: PayloadId, + ) -> TransportResult; + /// Returns the execution payload bodies by the given hash. /// /// See also @@ -186,6 +209,17 @@ where .await } + async fn new_payload_v4( + &self, + payload: ExecutionPayloadV4, + versioned_hashes: Vec, + parent_beacon_block_root: B256, + ) -> TransportResult { + self.client() + .request("engine_newPayloadV4", (payload, versioned_hashes, parent_beacon_block_root)) + .await + } + async fn fork_choice_updated_v1( &self, fork_choice_state: ForkchoiceState, @@ -234,6 +268,13 @@ where self.client().request("engine_getPayloadV3", (payload_id,)).await } + async fn get_payload_v4( + &self, + payload_id: PayloadId, + ) -> TransportResult { + self.client().request("engine_getPayloadV4", (payload_id,)).await + } + async fn get_payload_bodies_by_hash_v1( &self, block_hashes: Vec, From a0ab20c25c5bd16421cb15409b08d192b64bb6b9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 8 Jun 2024 10:19:30 +0200 Subject: [PATCH 2/2] fix import --- crates/provider/src/ext/engine.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/provider/src/ext/engine.rs b/crates/provider/src/ext/engine.rs index 5516a2038c9..b5c00cf80f5 100644 --- a/crates/provider/src/ext/engine.rs +++ b/crates/provider/src/ext/engine.rs @@ -1,15 +1,14 @@ +use crate::Provider; use alloy_network::Network; use alloy_primitives::{BlockHash, B256}; use alloy_rpc_types_engine::{ ClientVersionV1, ExecutionPayloadBodiesV1, ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4, ExecutionPayloadInputV2, - ExecutionPayloadV1, ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, PayloadAttributes, - PayloadId, PayloadStatus, + ExecutionPayloadV1, ExecutionPayloadV3, ExecutionPayloadV4, ForkchoiceState, ForkchoiceUpdated, + PayloadAttributes, PayloadId, PayloadStatus, }; use alloy_transport::{Transport, TransportResult}; -use crate::Provider; - /// Extension trait that gives access to engine API RPC methods. /// /// Note: