fix: prevent child call out of bounds (#3920)

This commit is contained in:
Matthias Seitz
2023-07-31 15:01:58 +02:00
committed by GitHub
parent 56b2ef19b5
commit da3bc64fb4
2 changed files with 9 additions and 5 deletions

View File

@ -395,7 +395,6 @@ where
if self.config.record_steps {
self.gas_inspector.step_end(interp, data, is_static, eval);
self.fill_step_on_step_end(interp, data, eval);
return eval
}
InstructionResult::Continue
}

View File

@ -267,9 +267,12 @@ impl CallTraceNode {
opcode::CALL |
opcode::STATICCALL |
opcode::CALLCODE => {
let call_id = self.children[child_id];
item.call_child_id = Some(call_id);
child_id += 1;
// The opcode of this step is a call but it's possible that this step resulted
// in a revert or out of gas error in which case there's no actual child call executed and recorded: <https://github.com/paradigmxyz/reth/issues/3915>
if let Some(call_id) = self.children.get(child_id).copied() {
item.call_child_id = Some(call_id);
child_id += 1;
}
}
_ => {}
}
@ -532,7 +535,9 @@ pub(crate) struct CallTraceStep {
pub(crate) gas_cost: u64,
/// Change of the contract state after step execution (effect of the SLOAD/SSTORE instructions)
pub(crate) storage_change: Option<StorageChange>,
/// Final status of the call
/// Final status of the step
///
/// This is set after the step was executed.
pub(crate) status: InstructionResult,
}