-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: gas and gasUsed in trace root only for ParityTrace (#171)
## Description This pull request is Part 1/2 of fixing the bug where the `gas` and `gasUsed` fields in Parity Trace root are incorrect. Part 2/2 paradigmxyz/reth#9761 ## Related Issues and Pull Requests - Follow: ethereum/go-ethereum#27029 - Improve: paradigmxyz/reth#3678 and paradigmxyz/reth#3719 - Fix: paradigmxyz/reth#9142 with #170 - Update: paradigmxyz/reth#3782 ## Problem The `gas` and `gasUsed` fields in Geth Debug Trace root should be the gas limit and gas used for the entire transaction. However, two fields in Parity Trace root should be the original ones. ### Reproducible Example With the latest version Reth v1.0.3, using `trace_transaction()` to trace the transaction `0x03128677ee3a9623d20f3c677f423ccc592d126374bf32e331343dd1bdf38b61` ``` curl http://localhost:8545 \ -X POST \ -H "Content-Type: application/json" \ --data '{"method":"trace_transaction","params":["0x03128677ee3a9623d20f3c677f423ccc592d126374bf32e331343dd1bdf38b61"],"id":1,"jsonrpc":"2.0"}' ``` **From Reth** ``` gas: 0x55493 (349331) gasUsed: 0x32d16 (208150) ``` **From [Etherscan](https://etherscan.io/vmtrace?txhash=0x03128677ee3a9623d20f3c677f423ccc592d126374bf32e331343dd1bdf38b61&type=parity#raw) and QuickNode** ``` gas: 0x4f227 (324135) gasUsed: 0x36622 (222754) ``` ## Solution for `revm-inspectors` 1. Not modify `gas_limit` and `gas_used` in the trace root ```diff - gas_limit = context.env.tx.gas_limit; - trace.set_root_trace_gas_used(gas_used); - trace.gas_used = gas_used(context.spec_id(), gas.spent(), gas.refunded() as u64); ``` 2. The modification in Step 1 will cause another problem The `gas` field for Geth Debug Trace root will also be reset (not the gas limitation for the entire transaction). therefore, can define `set_transaction_gas_limit()` and `with_transaction_gas_limit()` for Geth Debug, which is similar to current `set_transaction_gas_used()` and `with_transaction_gas_used()` for Parity. 3. Then, modify the Reth Part: `crates/rpc/rpc/src/trace.rs` and `crates/rpc/rpc/src/debug.rs` to completely fix the bug. ## Miscellaneous - Actually, I love the current design, but the results are inconsistent with those of others. - When I used `make pr` to test the Reth Part, the issue paradigmxyz/reth#9381 still exists for me. I should only skip tests for `lockfile` and test them seperately.
- Loading branch information
1 parent
403164c
commit 9a54f21
Showing
4 changed files
with
53 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters