chore: reuse raw transaction by hash for debug_getRawTransaction (#6845)

This commit is contained in:
Matthias Seitz
2024-02-28 14:59:15 +01:00
committed by GitHub
parent 72ffde43f5
commit 210d09023d
2 changed files with 9 additions and 8 deletions

View File

@@ -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")]

View File

@@ -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,
@@ -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`