use SealedBlockedWithSenders in block-level tracing (#5620)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Yash Atreya
2023-11-29 11:12:59 -05:00
committed by GitHub
parent 320deb6a43
commit a6ad5ac421

View File

@ -30,8 +30,8 @@ use reth_revm::{
tracing::{TracingInspector, TracingInspectorConfig}, tracing::{TracingInspector, TracingInspectorConfig},
}; };
use reth_rpc_types::{ use reth_rpc_types::{
BlockError, CallRequest, Index, Log, Transaction, TransactionInfo, TransactionReceipt, CallRequest, Index, Log, Transaction, TransactionInfo, TransactionReceipt, TransactionRequest,
TransactionRequest, TypedTransactionRequest, TypedTransactionRequest,
}; };
use reth_rpc_types_compat::transaction::from_recovered_with_block_context; use reth_rpc_types_compat::transaction::from_recovered_with_block_context;
use reth_transaction_pool::{TransactionOrigin, TransactionPool}; use reth_transaction_pool::{TransactionOrigin, TransactionPool};
@ -779,12 +779,9 @@ where
R: Send + 'static, R: Send + 'static,
{ {
let ((cfg, block_env, _), block) = let ((cfg, block_env, _), block) =
futures::try_join!(self.evm_env_at(block_id), self.block_by_id(block_id),)?; futures::try_join!(self.evm_env_at(block_id), self.block_with_senders(block_id))?;
let block = match block { let Some(block) = block else { return Ok(None) };
Some(block) => block,
None => return Ok(None),
};
// replay all transactions of the block // replay all transactions of the block
self.spawn_tracing_task_with(move |this| { self.spawn_tracing_task_with(move |this| {
@ -799,13 +796,13 @@ where
// prepare transactions, we do everything upfront to reduce time spent with open state // prepare transactions, we do everything upfront to reduce time spent with open state
let max_transactions = let max_transactions =
highest_index.map_or(block.body.len(), |highest| highest as usize); highest_index.map_or(block.body.len(), |highest| highest as usize);
let transactions = block let mut results = Vec::with_capacity(max_transactions);
.body
.into_iter() let mut transactions = block
.into_transactions_ecrecovered()
.take(max_transactions) .take(max_transactions)
.enumerate() .enumerate()
.map(|(idx, tx)| -> EthResult<_> { .map(|(idx, tx)| {
let tx = tx.into_ecrecovered().ok_or(BlockError::InvalidSignature)?;
let tx_info = TransactionInfo { let tx_info = TransactionInfo {
hash: Some(tx.hash()), hash: Some(tx.hash()),
index: Some(idx as u64), index: Some(idx as u64),
@ -814,19 +811,14 @@ where
base_fee: Some(base_fee), base_fee: Some(base_fee),
}; };
let tx_env = tx_env_with_recovered(&tx); let tx_env = tx_env_with_recovered(&tx);
(tx_info, tx_env)
Ok((tx_info, tx_env))
}) })
.collect::<Result<Vec<_>, _>>()?; .peekable();
let mut results = Vec::with_capacity(transactions.len());
// now get the state // now get the state
let state = this.state_at(state_at.into())?; let state = this.state_at(state_at.into())?;
let mut db = CacheDB::new(StateProviderDatabase::new(state)); let mut db = CacheDB::new(StateProviderDatabase::new(state));
let mut transactions = transactions.into_iter().peekable();
while let Some((tx_info, tx)) = transactions.next() { while let Some((tx_info, tx)) = transactions.next() {
let env = Env { cfg: cfg.clone(), block: block_env.clone(), tx }; let env = Env { cfg: cfg.clone(), block: block_env.clone(), tx };