mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
perf(rpc): Use block_with_senders in tracing (#5630)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -19,8 +19,7 @@ use reth_provider::{
|
||||
};
|
||||
use reth_revm::{access_list::AccessListInspector, database::StateProviderDatabase};
|
||||
use reth_rpc_types::{
|
||||
state::StateOverride, AccessListWithGasUsed, BlockError, Bundle, CallRequest, EthCallResponse,
|
||||
StateContext,
|
||||
state::StateOverride, AccessListWithGasUsed, Bundle, CallRequest, EthCallResponse, StateContext,
|
||||
};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use revm::{
|
||||
@ -93,10 +92,12 @@ where
|
||||
|
||||
let target_block = block_number.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest));
|
||||
|
||||
let ((cfg, block_env, _), block) =
|
||||
futures::try_join!(self.evm_env_at(target_block), self.block_by_id(target_block))?;
|
||||
let ((cfg, block_env, _), block) = futures::try_join!(
|
||||
self.evm_env_at(target_block),
|
||||
self.block_with_senders(target_block)
|
||||
)?;
|
||||
|
||||
let block = block.ok_or_else(|| EthApiError::UnknownBlockNumber)?;
|
||||
let Some(block) = block else { return Err(EthApiError::UnknownBlockNumber) };
|
||||
let gas_limit = self.inner.gas_cap;
|
||||
|
||||
// we're essentially replaying the transactions in the block here, hence we need the state
|
||||
@ -118,11 +119,8 @@ where
|
||||
if replay_block_txs {
|
||||
// only need to replay the transactions in the block if not all transactions are
|
||||
// to be replayed
|
||||
let transactions = block.body.into_iter().take(num_txs);
|
||||
|
||||
// Execute all transactions until index
|
||||
let transactions = block.into_transactions_ecrecovered().take(num_txs);
|
||||
for tx in transactions {
|
||||
let tx = tx.into_ecrecovered().ok_or(BlockError::InvalidSignature)?;
|
||||
let tx = tx_env_with_recovered(&tx);
|
||||
let env = Env { cfg: cfg.clone(), block: block_env.clone(), tx };
|
||||
let (res, _) = transact(&mut db, env)?;
|
||||
|
||||
@ -1038,19 +1038,16 @@ where
|
||||
block_id: impl Into<BlockId>,
|
||||
index: Index,
|
||||
) -> EthResult<Option<Transaction>> {
|
||||
let block_id = block_id.into();
|
||||
|
||||
if let Some(block) = self.block(block_id).await? {
|
||||
if let Some(block) = self.block_with_senders(block_id.into()).await? {
|
||||
let block_hash = block.hash;
|
||||
let block = block.unseal();
|
||||
if let Some(tx_signed) = block.body.into_iter().nth(index.into()) {
|
||||
let tx =
|
||||
tx_signed.into_ecrecovered().ok_or(EthApiError::InvalidTransactionSignature)?;
|
||||
let block_number = block.number;
|
||||
let base_fee_per_gas = block.base_fee_per_gas;
|
||||
if let Some(tx) = block.into_transactions_ecrecovered().nth(index.into()) {
|
||||
return Ok(Some(from_recovered_with_block_context(
|
||||
tx,
|
||||
block_hash,
|
||||
block.header.number,
|
||||
block.header.base_fee_per_gas,
|
||||
block_number,
|
||||
base_fee_per_gas,
|
||||
index.into(),
|
||||
)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user