mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(rpc): commit call state in trace call many (#3437)
This commit is contained in:
@ -193,7 +193,9 @@ where
|
|||||||
let mut results = Vec::with_capacity(calls.len());
|
let mut results = Vec::with_capacity(calls.len());
|
||||||
let mut db = SubState::new(State::new(state));
|
let mut db = SubState::new(State::new(state));
|
||||||
|
|
||||||
for (call, trace_types) in calls {
|
let mut calls = calls.into_iter().peekable();
|
||||||
|
|
||||||
|
while let Some((call, trace_types)) = calls.next() {
|
||||||
let env = prepare_call_env(
|
let env = prepare_call_env(
|
||||||
cfg.clone(),
|
cfg.clone(),
|
||||||
block_env.clone(),
|
block_env.clone(),
|
||||||
@ -204,12 +206,30 @@ where
|
|||||||
let config = tracing_config(&trace_types);
|
let config = tracing_config(&trace_types);
|
||||||
let mut inspector = TracingInspector::new(config);
|
let mut inspector = TracingInspector::new(config);
|
||||||
let (res, _) = inspect(&mut db, env, &mut inspector)?;
|
let (res, _) = inspect(&mut db, env, &mut inspector)?;
|
||||||
let trace_res = inspector.into_parity_builder().into_trace_results_with_state(
|
let ResultAndState { result, state } = res;
|
||||||
res,
|
|
||||||
&trace_types,
|
let mut trace_res =
|
||||||
&db,
|
inspector.into_parity_builder().into_trace_results(result, &trace_types);
|
||||||
)?;
|
|
||||||
|
// If statediffs were requested, populate them with the account balance and
|
||||||
|
// nonce from pre-state
|
||||||
|
if let Some(ref mut state_diff) = trace_res.state_diff {
|
||||||
|
populate_account_balance_nonce_diffs(
|
||||||
|
state_diff,
|
||||||
|
&db,
|
||||||
|
state.iter().map(|(addr, acc)| (*addr, acc.info.clone())),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
results.push(trace_res);
|
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(state)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(results)
|
Ok(results)
|
||||||
@ -403,6 +423,9 @@ where
|
|||||||
move |tx_info, inspector, res, state, db| {
|
move |tx_info, inspector, res, state, db| {
|
||||||
let mut full_trace =
|
let mut full_trace =
|
||||||
inspector.into_parity_builder().into_trace_results(res, &trace_types);
|
inspector.into_parity_builder().into_trace_results(res, &trace_types);
|
||||||
|
|
||||||
|
// If statediffs were requested, populate them with the account balance and nonce
|
||||||
|
// from pre-state
|
||||||
if let Some(ref mut state_diff) = full_trace.state_diff {
|
if let Some(ref mut state_diff) = full_trace.state_diff {
|
||||||
populate_account_balance_nonce_diffs(
|
populate_account_balance_nonce_diffs(
|
||||||
state_diff,
|
state_diff,
|
||||||
|
|||||||
Reference in New Issue
Block a user