Skip to content

Reuse evm tracing utils for trace_call_many #17484

@mattsse

Description

@mattsse

Describe the feature

This currently creates a new evm instance per call

while let Some((call, trace_types)) = calls.next() {
let (evm_env, tx_env) = this.eth_api().prepare_call_env(
evm_env.clone(),
call,
&mut db,
Default::default(),
)?;
let config = TracingInspectorConfig::from_parity_config(&trace_types);
let mut inspector = TracingInspector::new(config);
let (res, _) =
this.eth_api().inspect(&mut db, evm_env, tx_env, &mut inspector)?;
let trace_res = inspector
.into_parity_builder()
.into_trace_results_with_state(&res, &trace_types, &db)
.map_err(Eth::Error::from_eth_err)?;
results.push(trace_res);
// need to apply the state changes of this call before executing the
// next call
if calls.peek().is_some() {
// need to apply the state changes of this call before executing
// the next call
db.commit(res.state)
}
}

but we can likely reuse the helpers:

let results = this
.evm_config()
.evm_factory()
.create_tracer(StateCacheDbRefMutWrapper(&mut db), evm_env, inspector_setup())
.try_trace_many(block.transactions_recovered().take(max_transactions), |ctx| {
let tx_info = TransactionInfo {
hash: Some(*ctx.tx.tx_hash()),
index: Some(idx),
block_hash: Some(block_hash),
block_number: Some(block_number),
base_fee: Some(base_fee),
};
idx += 1;
f(tx_info, ctx)
})
.collect::<Result<_, _>>()?;

maybe we'd need another trait fn for this that just traces calls

Additional context

assigned to @ongyimeng

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions