Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reuse raw transaction by hash for debug_getRawTransaction #6845

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading