use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use reth_primitives::{Address, BlockHash, BlockId, BlockNumberOrTag, Bytes, H256, U256, U64}; use reth_rpc_types::{ engine::{ ExecutionPayload, ExecutionPayloadBodiesV1, ExecutionPayloadEnvelope, ForkchoiceState, ForkchoiceUpdated, PayloadAttributes, PayloadId, PayloadStatus, TransitionConfiguration, }, state::StateOverride, BlockOverrides, CallRequest, Filter, Log, RichBlock, SyncStatus, }; #[cfg_attr(not(feature = "client"), rpc(server, namespace = "engine"))] #[cfg_attr(feature = "client", rpc(server, client, namespace = "engine"))] pub trait EngineApi { /// See also /// Caution: This should not accept the `withdrawals` field #[method(name = "newPayloadV1")] async fn new_payload_v1(&self, payload: ExecutionPayload) -> RpcResult; /// See also #[method(name = "newPayloadV2")] async fn new_payload_v2(&self, payload: ExecutionPayload) -> RpcResult; /// See also /// /// Caution: This should not accept the `withdrawals` field #[method(name = "forkchoiceUpdatedV1")] async fn fork_choice_updated_v1( &self, fork_choice_state: ForkchoiceState, payload_attributes: Option, ) -> RpcResult; /// See also #[method(name = "forkchoiceUpdatedV2")] async fn fork_choice_updated_v2( &self, fork_choice_state: ForkchoiceState, payload_attributes: Option, ) -> RpcResult; /// See also /// /// Returns the most recent version of the payload that is available in the corresponding /// payload build process at the time of receiving this call. /// /// Caution: This should not return the `withdrawals` field /// /// Note: /// > Provider software MAY stop the corresponding build process after serving this call. #[method(name = "getPayloadV1")] async fn get_payload_v1(&self, payload_id: PayloadId) -> RpcResult; /// See also /// /// 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 = "getPayloadV2")] async fn get_payload_v2(&self, payload_id: PayloadId) -> RpcResult; /// See also #[method(name = "getPayloadBodiesByHashV1")] async fn get_payload_bodies_by_hash_v1( &self, block_hashes: Vec, ) -> RpcResult; /// See also /// /// Returns the execution payload bodies by the range starting at `start`, containing `count` /// blocks. /// /// WARNING: This method is associated with the BeaconBlocksByRange message in the consensus /// layer p2p specification, meaning the input should be treated as untrusted or potentially /// adversarial. /// /// Implementors should take care when acting on the input to this method, specifically /// ensuring that the range is limited properly, and that the range boundaries are computed /// correctly and without panics. #[method(name = "getPayloadBodiesByRangeV1")] async fn get_payload_bodies_by_range_v1( &self, start: U64, count: U64, ) -> RpcResult; /// See also #[method(name = "exchangeTransitionConfigurationV1")] async fn exchange_transition_configuration( &self, transition_configuration: TransitionConfiguration, ) -> RpcResult; /// See also #[method(name = "exchangeCapabilities")] async fn exchange_capabilities(&self, capabilities: Vec) -> RpcResult>; } /// A subset of the ETH rpc interface: /// /// Specifically for the engine auth server: #[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))] #[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))] #[async_trait] pub trait EngineEthApi { /// Returns an object with data about the sync status or false. #[method(name = "syncing")] fn syncing(&self) -> RpcResult; /// Returns the chain ID of the current network. #[method(name = "chainId")] async fn chain_id(&self) -> RpcResult>; /// Returns the number of most recent block. #[method(name = "blockNumber")] fn block_number(&self) -> RpcResult; /// Executes a new message call immediately without creating a transaction on the block chain. #[method(name = "call")] async fn call( &self, request: CallRequest, block_number: Option, state_overrides: Option, block_overrides: Option>, ) -> RpcResult; /// Returns code at a given address at given block number. #[method(name = "getCode")] async fn get_code(&self, address: Address, block_number: Option) -> RpcResult; /// Returns information about a block by hash. #[method(name = "getBlockByHash")] async fn block_by_hash(&self, hash: H256, full: bool) -> RpcResult>; /// Returns information about a block by number. #[method(name = "getBlockByNumber")] async fn block_by_number( &self, number: BlockNumberOrTag, full: bool, ) -> RpcResult>; /// Sends signed transaction, returning its hash. #[method(name = "sendRawTransaction")] async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult; /// Returns logs matching given filter object. #[method(name = "getLogs")] async fn logs(&self, filter: Filter) -> RpcResult>; }