mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(engine-api): additional shanghai methods and types (#1410)
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
|
||||
use reth_primitives::H64;
|
||||
use reth_primitives::{BlockHash, BlockNumber, H64};
|
||||
use reth_rpc_types::engine::{
|
||||
ExecutionPayload, ForkchoiceState, ForkchoiceUpdated, PayloadAttributes, PayloadStatus,
|
||||
TransitionConfiguration,
|
||||
ExecutionPayload, ExecutionPayloadBody, ForkchoiceState, ForkchoiceUpdated, PayloadAttributes,
|
||||
PayloadStatus, TransitionConfiguration,
|
||||
};
|
||||
|
||||
#[cfg_attr(not(feature = "client"), rpc(server))]
|
||||
@ -45,6 +45,21 @@ pub trait EngineApi {
|
||||
#[method(name = "engine_getPayloadV2")]
|
||||
async fn get_payload_v2(&self, payload_id: H64) -> Result<ExecutionPayload>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyhashv1>
|
||||
#[method(name = "engine_getPayloadBodiesByHashV1")]
|
||||
async fn get_payload_bodies_by_hash_v1(
|
||||
&self,
|
||||
block_hashes: Vec<BlockHash>,
|
||||
) -> Result<Vec<ExecutionPayloadBody>>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyrangev1>
|
||||
#[method(name = "engine_getPayloadBodiesByRangeV1")]
|
||||
async fn get_payload_bodies_by_range_v1(
|
||||
&self,
|
||||
start: BlockNumber,
|
||||
count: u64,
|
||||
) -> Result<Vec<ExecutionPayloadBody>>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_exchangetransitionconfigurationv1>
|
||||
#[method(name = "engine_exchangeTransitionConfigurationV1")]
|
||||
async fn exchange_transition_configuration(
|
||||
|
||||
@ -64,6 +64,15 @@ impl From<SealedBlock> for ExecutionPayload {
|
||||
}
|
||||
}
|
||||
|
||||
/// This structure contains a body of an execution payload.
|
||||
///
|
||||
/// See also: <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#executionpayloadbodyv1>
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ExecutionPayloadBody {
|
||||
transactions: Vec<Bytes>,
|
||||
withdrawals: Vec<Withdrawal>,
|
||||
}
|
||||
|
||||
/// This structure encapsulates the fork choice state
|
||||
#[derive(Default, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@ -82,7 +91,7 @@ pub struct PayloadAttributes {
|
||||
pub prev_randao: H256,
|
||||
pub suggested_fee_recipient: Address,
|
||||
/// Array of [`Withdrawal`] enabled with V2
|
||||
/// See <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/shanghai.md#executionpayloadv2>
|
||||
/// See <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#payloadattributesv2>
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub withdrawals: Option<Vec<Withdrawal>>,
|
||||
}
|
||||
|
||||
@ -2,11 +2,12 @@ use crate::result::{internal_rpc_err, rpc_err};
|
||||
use async_trait::async_trait;
|
||||
use jsonrpsee::core::{Error, RpcResult as Result};
|
||||
use reth_interfaces::consensus::ForkchoiceState;
|
||||
use reth_primitives::H64;
|
||||
use reth_primitives::{BlockHash, BlockNumber, H64};
|
||||
use reth_rpc_api::EngineApiServer;
|
||||
use reth_rpc_engine_api::{EngineApiError, EngineApiMessage, EngineApiResult};
|
||||
use reth_rpc_types::engine::{
|
||||
ExecutionPayload, ForkchoiceUpdated, PayloadAttributes, PayloadStatus, TransitionConfiguration,
|
||||
ExecutionPayload, ExecutionPayloadBody, ForkchoiceUpdated, PayloadAttributes, PayloadStatus,
|
||||
TransitionConfiguration,
|
||||
};
|
||||
use tokio::sync::{
|
||||
mpsc::UnboundedSender,
|
||||
@ -54,6 +55,7 @@ impl EngineApiServer for EngineApi {
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/8db51dcd2f4bdfbd9ad6e4a7560aac97010ad063/src/engine/specification.md#engine_newpayloadv1>
|
||||
async fn new_payload_v2(&self, _payload: ExecutionPayload) -> Result<PayloadStatus> {
|
||||
// TODO:
|
||||
Err(internal_rpc_err("unimplemented"))
|
||||
}
|
||||
|
||||
@ -79,6 +81,7 @@ impl EngineApiServer for EngineApi {
|
||||
_fork_choice_state: ForkchoiceState,
|
||||
_payload_attributes: Option<PayloadAttributes>,
|
||||
) -> Result<ForkchoiceUpdated> {
|
||||
// TODO:
|
||||
Err(internal_rpc_err("unimplemented"))
|
||||
}
|
||||
|
||||
@ -92,6 +95,26 @@ impl EngineApiServer for EngineApi {
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#engine_getpayloadv2>
|
||||
async fn get_payload_v2(&self, _payload_id: H64) -> Result<ExecutionPayload> {
|
||||
// TODO:
|
||||
Err(internal_rpc_err("unimplemented"))
|
||||
}
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyhashv1>
|
||||
async fn get_payload_bodies_by_hash_v1(
|
||||
&self,
|
||||
_block_hashes: Vec<BlockHash>,
|
||||
) -> Result<Vec<ExecutionPayloadBody>> {
|
||||
// TODO:
|
||||
Err(internal_rpc_err("unimplemented"))
|
||||
}
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyrangev1>
|
||||
async fn get_payload_bodies_by_range_v1(
|
||||
&self,
|
||||
_start: BlockNumber,
|
||||
_count: u64,
|
||||
) -> Result<Vec<ExecutionPayloadBody>> {
|
||||
// TODO:
|
||||
Err(internal_rpc_err("unimplemented"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user