diff --git a/src/tracing/mod.rs b/src/tracing/mod.rs index b6e212ac..e5b6a36e 100644 --- a/src/tracing/mod.rs +++ b/src/tracing/mod.rs @@ -448,13 +448,13 @@ impl TracingInspector { memory, returndata, gas_remaining: interp.control.gas().remaining(), - gas_refund_counter: interp.control.gas().refunded() as u64, gas_used, decoded: None, immediate_bytes, // fields will be populated end of call gas_cost: 0, + gas_refund_counter: 0, storage_change: None, status: InstructionResult::Continue, }); @@ -518,6 +518,8 @@ impl TracingInspector { // TODO: Figure out why this can overflow. https://github.com/paradigmxyz/revm-inspectors/pull/38 step.gas_cost = step.gas_remaining.saturating_sub(interp.control.gas().remaining()); + step.gas_refund_counter = interp.control.gas().refunded(); + // set the status step.status = interp.control.instruction_result(); } diff --git a/src/tracing/types.rs b/src/tracing/types.rs index 438f9df1..a56c5c6d 100644 --- a/src/tracing/types.rs +++ b/src/tracing/types.rs @@ -97,6 +97,8 @@ pub struct CallTrace { pub steps: Vec, /// Optional complementary decoded call data. pub decoded: DecodedCallTrace, + /// The total gas refunded in the call. + pub gas_refunded: u64 } impl CallTrace { @@ -675,7 +677,7 @@ pub struct CallTraceStep { /// Remaining gas before step execution pub gas_remaining: u64, /// Gas refund counter before step execution - pub gas_refund_counter: u64, + pub gas_refund_counter: i64, /// Total gas used before step execution pub gas_used: u64, // Fields filled in `step_end` @@ -707,7 +709,7 @@ impl CallTraceStep { gas_cost: self.gas_cost, op: self.op.to_string(), pc: self.pc as u64, - refund_counter: (self.gas_refund_counter > 0).then_some(self.gas_refund_counter), + refund_counter: (self.gas_refund_counter > 0).then_some(self.gas_refund_counter as u64), // Filled, if not disabled manually stack: None, // Filled in `CallTraceArena::geth_trace` as a result of compounding all slot changes