Skip to content

Commit

Permalink
extend engine api trait
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Dec 2, 2024
1 parent e57cbd4 commit 756a6e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion crates/engine/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use alloy_provider::{ReqwestProvider, RootProvider};
use alloy_rpc_client::RpcClient;
use alloy_rpc_types_engine::{
ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, JwtSecret, PayloadId, PayloadStatus,
ExecutionPayloadEnvelopeV2,
};
use alloy_transport_http::{
hyper_util::{
Expand Down Expand Up @@ -64,13 +65,21 @@ impl EngineClient {
impl Engine for EngineClient {
type Error = EngineError;

async fn get_payload(
async fn get_payload_v2(
&self,
payload_id: PayloadId,
) -> Result<ExecutionPayloadEnvelopeV2, Self::Error> {
self.engine.get_payload_v2(payload_id).await.map_err(|_| EngineError::PayloadError)
}

async fn get_payload_v3(
&self,
payload_id: PayloadId,
) -> Result<OpExecutionPayloadEnvelopeV3, Self::Error> {
self.engine.get_payload_v3(payload_id).await.map_err(|_| EngineError::PayloadError)
}


async fn forkchoice_update(
&self,
state: ForkchoiceState,
Expand Down
9 changes: 8 additions & 1 deletion crates/engine/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use alloy_eips::eip1898::BlockNumberOrTag;
use alloy_primitives::B256;
use alloy_rpc_types_engine::{
ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus,
ExecutionPayloadEnvelopeV2,
};
use async_trait::async_trait;
use op_alloy_protocol::L2BlockInfo;
Expand All @@ -17,7 +18,13 @@ pub trait Engine {
type Error: core::fmt::Debug;

/// Gets a payload for the given payload id.
async fn get_payload(
async fn get_payload_v2(
&self,
payload_id: PayloadId,
) -> Result<ExecutionPayloadEnvelopeV2, Self::Error>;

/// Gets a payload for the given payload id.
async fn get_payload_v3(
&self,
payload_id: PayloadId,
) -> Result<OpExecutionPayloadEnvelopeV3, Self::Error>;
Expand Down

0 comments on commit 756a6e0

Please sign in to comment.