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

perf(rpc): Use block_with_senders in tracing #5630

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Changes from 1 commit
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
28 changes: 11 additions & 17 deletions crates/rpc/rpc/src/eth/api/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ use crate::{
EthApi,
};
use reth_network_api::NetworkInfo;
use reth_primitives::{
revm::env::tx_env_with_recovered, BlockId, BlockNumberOrTag, Bytes,
TransactionSignedEcRecovered, U256,
};
use reth_primitives::{revm::env::tx_env_with_recovered, BlockId, BlockNumberOrTag, Bytes, U256};
use reth_provider::{
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProvider, StateProviderFactory,
};
Expand Down Expand Up @@ -94,8 +91,7 @@ where
self.block_with_senders(target_block)
)?;

let (block, senders) =
block.ok_or_else(|| EthApiError::UnknownBlockNumber)?.into_components();
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
Expand All @@ -117,17 +113,15 @@ 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
for (idx, tx) in transactions.enumerate() {
let tx =
TransactionSignedEcRecovered::from_signed_transaction(tx, senders[idx]);
let tx = tx_env_with_recovered(&tx);
let env = Env { cfg: cfg.clone(), block: block_env.clone(), tx };
let (res, _) = transact(&mut db, env)?;
db.commit(res.state);
}
let _transactions =
block.into_transactions_ecrecovered().take(num_txs).enumerate().map(
yash-atreya marked this conversation as resolved.
Show resolved Hide resolved
|(_idx, tx)| {
let tx = tx_env_with_recovered(&tx);
let env = Env { cfg: cfg.clone(), block: block_env.clone(), tx };
let (res, _) = transact(&mut db, env).unwrap();
db.commit(res.state);
},
);
}

let block_overrides = block_override.map(Box::new);
Expand Down
Loading