Skip to content

Commit

Permalink
feat: expose additional eth functions on engine api (#13837)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jan 17, 2025
1 parent 12d3fbe commit 0cc1ff0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
12 changes: 11 additions & 1 deletion crates/rpc/rpc-api/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,12 @@ pub trait EngineApi<Engine: EngineTypes> {

/// A subset of the ETH rpc interface: <https://ethereum.github.io/execution-apis/api-documentation/>
///
/// This also includes additional eth functions required by optimism.
///
/// Specifically for the engine auth server: <https://github.com/ethereum/execution-apis/blob/main/src/engine/common.md#underlying-protocol>
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))]
#[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))]
pub trait EngineEthApi<B: RpcObject> {
pub trait EngineEthApi<B: RpcObject, R: RpcObject> {
/// Returns an object with data about the sync status or false.
#[method(name = "syncing")]
fn syncing(&self) -> RpcResult<SyncStatus>;
Expand Down Expand Up @@ -259,10 +261,18 @@ pub trait EngineEthApi<B: RpcObject> {
#[method(name = "getBlockByNumber")]
async fn block_by_number(&self, number: BlockNumberOrTag, full: bool) -> RpcResult<Option<B>>;

/// Returns all transaction receipts for a given block.
#[method(name = "getBlockReceipts")]
async fn block_receipts(&self, block_id: BlockId) -> RpcResult<Option<Vec<R>>>;

/// Sends signed transaction, returning its hash.
#[method(name = "sendRawTransaction")]
async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult<B256>;

/// Returns the receipt of a transaction by transaction hash.
#[method(name = "getTransactionReceipt")]
async fn transaction_receipt(&self, hash: B256) -> RpcResult<Option<R>>;

/// Returns logs matching given filter object.
#[method(name = "getLogs")]
async fn logs(&self, filter: Filter) -> RpcResult<Vec<Log>>;
Expand Down
16 changes: 15 additions & 1 deletion crates/rpc/rpc/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<Eth, EthFilter> EngineEthApi<Eth, EthFilter> {
}

#[async_trait::async_trait]
impl<Eth, EthFilter> EngineEthApiServer<RpcBlock<Eth::NetworkTypes>>
impl<Eth, EthFilter> EngineEthApiServer<RpcBlock<Eth::NetworkTypes>, RpcReceipt<Eth::NetworkTypes>>
for EngineEthApi<Eth, EthFilter>
where
Eth: EthApiServer<
Expand Down Expand Up @@ -103,11 +103,25 @@ where
self.eth.block_by_number(number, full).instrument(engine_span!()).await
}

async fn block_receipts(
&self,
block_id: BlockId,
) -> Result<Option<Vec<RpcReceipt<Eth::NetworkTypes>>>> {
self.eth.block_receipts(block_id).instrument(engine_span!()).await
}

/// Handler for: `eth_sendRawTransaction`
async fn send_raw_transaction(&self, bytes: Bytes) -> Result<B256> {
self.eth.send_raw_transaction(bytes).instrument(engine_span!()).await
}

async fn transaction_receipt(
&self,
hash: B256,
) -> Result<Option<RpcReceipt<Eth::NetworkTypes>>> {
self.eth.transaction_receipt(hash).instrument(engine_span!()).await
}

/// Handler for `eth_getLogs`
async fn logs(&self, filter: Filter) -> Result<Vec<Log>> {
self.eth_filter.logs(filter).instrument(engine_span!()).await
Expand Down

0 comments on commit 0cc1ff0

Please sign in to comment.