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: correct gas limit and gas used results in trace API #13767

Closed
wants to merge 1 commit into from

Conversation

pythonberg1997
Copy link
Contributor

Due to the revm inspector's inability to record a transaction's initial gas used, all trace-related methods were returning incorrect gas and gas used values. To properly handle this situation, the gas and gas used values for the root trace should be manually set after the transaction completes. While this fix was implemented in the debug API, it was missing from the trace API.

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial gas used

can you clarify what you mean here exactly

@mattsse mattsse added the A-rpc Related to the RPC implementation label Jan 10, 2025
@pythonberg1997
Copy link
Contributor Author

pythonberg1997 commented Jan 10, 2025

initial gas used

can you clarify what you mean here exactly

I mean this in revm:

    pub fn transact(&mut self) -> EVMResult<DB::Error> {
        let initial_gas_spend = self
            .preverify_transaction_inner()
            .inspect_err(|_e| self.clear())?;

        let output = self.transact_preverified_inner(initial_gas_spend);
        let output = self.handler.post_execution().end(&mut self.context, output);
        self.clear();
        output
    }

Generally, the initial_gas_spend will be 21064. This portion is not recorded because it is not consumed by a call frame.

@pythonberg1997
Copy link
Contributor Author

pythonberg1997 commented Jan 10, 2025

Related code in debug API:

.with_transaction_gas_limit(env.tx.gas_limit)
.into_geth_builder()
.geth_call_traces(call_config, res.result.gas_used());

And in revm-inspector:
https://github.com/paradigmxyz/revm-inspectors/blob/ceef3f3624ca51bf3c41c97d6c013606db3a6019/src/tracing/builder/geth.rs#L141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants