fix: don't account for refunds after call (#3065)

This commit is contained in:
Matthias Seitz
2023-06-08 16:18:02 +02:00
committed by GitHub
parent 0f14da756f
commit 7a63d97b40
2 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,6 @@
use crate::tracing::{
types::{CallKind, LogCallOrder, RawLog},
utils::{gas_used, get_create_address},
utils::get_create_address,
};
pub use arena::CallTraceArena;
use reth_primitives::{bytes::Bytes, Address, H256, U256};
@ -149,7 +149,7 @@ impl TracingInspector {
/// This expects an existing trace [Self::start_trace_on_call]
fn fill_trace_on_call_end<DB: Database>(
&mut self,
data: &EVMData<'_, DB>,
_data: &EVMData<'_, DB>,
status: InstructionResult,
gas: &Gas,
output: Bytes,
@ -158,9 +158,7 @@ impl TracingInspector {
let trace_idx = self.pop_trace_idx();
let trace = &mut self.traces.arena[trace_idx].trace;
let gas_used = gas_used(data.env.cfg.spec_id, gas.spend(), gas.refunded() as u64);
trace.gas_used = gas_used;
trace.gas_used = gas.spend();
trace.gas_limit = gas.limit();
trace.status = status;
trace.success = matches!(status, return_ok!());

View File

@ -23,6 +23,7 @@ pub(crate) fn convert_memory(data: &[u8]) -> Vec<String> {
/// Get the gas used, accounting for refunds
#[inline]
#[allow(unused)]
pub(crate) fn gas_used(spec: SpecId, spent: u64, refunded: u64) -> u64 {
let refund_quotient = if SpecId::enabled(spec, SpecId::LONDON) { 5 } else { 2 };
spent - (refunded).min(spent / refund_quotient)