Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use tx gas limit for root trace #3719

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions crates/revm/revm-inspectors/src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ impl TracingInspector {
///
/// Invoked on [Inspector::call].
#[allow(clippy::too_many_arguments)]
fn start_trace_on_call(
fn start_trace_on_call<DB: Database>(
&mut self,
depth: usize,
data: &EVMData<'_, DB>,
address: Address,
data: Bytes,
input_data: Bytes,
value: U256,
kind: CallKind,
caller: Address,
gas_limit: u64,
mut gas_limit: u64,
maybe_precompile: Option<bool>,
) {
// This will only be true if the inspector is configured to exclude precompiles and the call
Expand All @@ -166,14 +166,20 @@ impl TracingInspector {
PushTraceKind::PushAndAttachToParent
};

if self.trace_stack.is_empty() {
// this is the root call which should get the original gas limit of the transaction,
// because initialization costs are already subtracted from gas_limit
gas_limit = data.env.tx.gas_limit;
}

self.trace_stack.push(self.traces.push_trace(
0,
push_kind,
CallTrace {
depth,
depth: data.journaled_state.depth() as usize,
address,
kind,
data,
data: input_data,
value,
status: InstructionResult::Continue,
caller,
Expand Down Expand Up @@ -421,7 +427,7 @@ where
self.config.exclude_precompile_calls.then(|| self.is_precompile_call(data, &to, value));

self.start_trace_on_call(
data.journaled_state.depth() as usize,
data,
to,
inputs.input.clone(),
value,
Expand Down Expand Up @@ -460,7 +466,7 @@ where
let _ = data.journaled_state.load_account(inputs.caller, data.db);
let nonce = data.journaled_state.account(inputs.caller).info.nonce;
self.start_trace_on_call(
data.journaled_state.depth() as usize,
data,
get_create_address(inputs, nonce),
inputs.init_code.clone(),
inputs.value,
Expand Down
Loading