Skip to content

Commit 0cc1ff0

Browse files
authored
feat: expose additional eth functions on engine api (#13837)
1 parent 12d3fbe commit 0cc1ff0

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

crates/rpc/rpc-api/src/engine.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,12 @@ pub trait EngineApi<Engine: EngineTypes> {
221221

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

264+
/// Returns all transaction receipts for a given block.
265+
#[method(name = "getBlockReceipts")]
266+
async fn block_receipts(&self, block_id: BlockId) -> RpcResult<Option<Vec<R>>>;
267+
262268
/// Sends signed transaction, returning its hash.
263269
#[method(name = "sendRawTransaction")]
264270
async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult<B256>;
265271

272+
/// Returns the receipt of a transaction by transaction hash.
273+
#[method(name = "getTransactionReceipt")]
274+
async fn transaction_receipt(&self, hash: B256) -> RpcResult<Option<R>>;
275+
266276
/// Returns logs matching given filter object.
267277
#[method(name = "getLogs")]
268278
async fn logs(&self, filter: Filter) -> RpcResult<Vec<Log>>;

crates/rpc/rpc/src/engine.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<Eth, EthFilter> EngineEthApi<Eth, EthFilter> {
3434
}
3535

3636
#[async_trait::async_trait]
37-
impl<Eth, EthFilter> EngineEthApiServer<RpcBlock<Eth::NetworkTypes>>
37+
impl<Eth, EthFilter> EngineEthApiServer<RpcBlock<Eth::NetworkTypes>, RpcReceipt<Eth::NetworkTypes>>
3838
for EngineEthApi<Eth, EthFilter>
3939
where
4040
Eth: EthApiServer<
@@ -103,11 +103,25 @@ where
103103
self.eth.block_by_number(number, full).instrument(engine_span!()).await
104104
}
105105

106+
async fn block_receipts(
107+
&self,
108+
block_id: BlockId,
109+
) -> Result<Option<Vec<RpcReceipt<Eth::NetworkTypes>>>> {
110+
self.eth.block_receipts(block_id).instrument(engine_span!()).await
111+
}
112+
106113
/// Handler for: `eth_sendRawTransaction`
107114
async fn send_raw_transaction(&self, bytes: Bytes) -> Result<B256> {
108115
self.eth.send_raw_transaction(bytes).instrument(engine_span!()).await
109116
}
110117

118+
async fn transaction_receipt(
119+
&self,
120+
hash: B256,
121+
) -> Result<Option<RpcReceipt<Eth::NetworkTypes>>> {
122+
self.eth.transaction_receipt(hash).instrument(engine_span!()).await
123+
}
124+
111125
/// Handler for `eth_getLogs`
112126
async fn logs(&self, filter: Filter) -> Result<Vec<Log>> {
113127
self.eth_filter.logs(filter).instrument(engine_span!()).await

0 commit comments

Comments
 (0)