Skip to content

Commit

Permalink
chore: reuse raw transaction by hash for debug_getRawTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Feb 28, 2024
1 parent ecba340 commit c9578aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 3 additions & 1 deletion crates/rpc/rpc-api/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ pub trait DebugApi {
async fn raw_block(&self, block_id: BlockId) -> RpcResult<Bytes>;

/// Returns a EIP-2718 binary-encoded transaction.
///
/// If this is a pooled EIP-4844 transaction, the blob sidecar is included.
#[method(name = "getRawTransaction")]
async fn raw_transaction(&self, hash: B256) -> RpcResult<Bytes>;
async fn raw_transaction(&self, hash: B256) -> RpcResult<Option<Bytes>>;

/// Returns an array of EIP-2718 binary-encoded transactions for the given [BlockId].
#[method(name = "getRawTransactions")]
Expand Down
13 changes: 6 additions & 7 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
inspect, inspect_and_return_db, prepare_call_env, replay_transactions_until, transact,
EvmOverrides,
},
EthTransactions, TransactionSource,
EthTransactions,
},
result::{internal_rpc_err, ToRpcResult},
BlockingTaskGuard, EthApiSpec,
Expand Down Expand Up @@ -635,13 +635,12 @@ where
}

/// Handler for `debug_getRawTransaction`
///
/// If this is a pooled EIP-4844 transaction, the blob sidecar is included.
///
/// Returns the bytes of the transaction for the given hash.
async fn raw_transaction(&self, hash: B256) -> RpcResult<Bytes> {
let tx = self.inner.eth_api.transaction_by_hash(hash).await?;
Ok(tx
.map(TransactionSource::into_recovered)
.map(|tx| tx.envelope_encoded())
.unwrap_or_default())
async fn raw_transaction(&self, hash: B256) -> RpcResult<Option<Bytes>> {
Ok(self.inner.eth_api.raw_transaction_by_hash(hash).await?)
}

/// Handler for `debug_getRawTransactions`
Expand Down

0 comments on commit c9578aa

Please sign in to comment.