-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eth/tracers: fix prestate tracer bug with create with value (#10961)
Cherry-pick adaptation for Erigon 3 based on Erigon 2 PR: #10960 Commit: 30cae52 --- fixes #9531 Changes: - fixes a bug with the prestate tracer where we were incorrectly subtracting the value of a transaction from the "to" address balance in the "pre" state (should not be done for CREATE calls) - fixes a bug with the prestate tracer where we were incorrectly adding the value of a transaction to the "from" address balance in the "pre" state (should not be done for CREATE calls) - fixes a bug with the prestate tracer where we were incorrectly decrementing the nonce value of a transaction's "from" address in the "pre" state (should not be done for CREATE calls) - adds a test generator that can generate the test files for us based on real life transaction hash and node rpc url - check README https://github.com/ledgerwatch/erigon/blob/fix-prestate-tracer-on-create-e2/eth/tracers/internal/tracetest/testgenerator/README.md - adds test cases - fixes some existing test cases that were setup with incorrect data
- Loading branch information
Showing
15 changed files
with
610 additions
and
43 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
86 changes: 86 additions & 0 deletions
86
eth/tracers/internal/tracetest/testdata/prestate_tracer/create_with_value.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
96 changes: 96 additions & 0 deletions
96
...tracers/internal/tracetest/testdata/prestate_tracer_with_diff_mode/create_with_value.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
build/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Background | ||
|
||
A tool for generating a test case for a given tracer. It communicates to a node via rpc to build: | ||
|
||
1. `genesis` using the parent block of the given `txnHash` and its pre-state | ||
2. `config` for the chain by using the node `admin_nodeInfo` API | ||
3. `input` which is the raw transaction bytes of the given `txnHash` | ||
4. `result` which is result of tracing the given `txnHash` with the given `tracerConfig` | ||
|
||
# Pre-requisites | ||
|
||
1. install node.js & npm: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm | ||
|
||
# Usage | ||
|
||
``` | ||
cd eth/tracers/internal/tracetest/testgenerator | ||
npm install | ||
npm start -- \ | ||
--rpcUrl=http://localhost:8545 \ | ||
--txnHash=0x5c08231a3c34bd1be6ac7df553d451246175f3dad3245ab5e4413cde35ace52e \ | ||
--traceConfig='{"tracer": "prestateTracer", "tracerConfig": { "diffMode": true } }' \ | ||
--outputFilePath=../testdata/prestate_tracer_with_diff_mode/create_with_value.json | ||
``` |
148 changes: 148 additions & 0 deletions
148
eth/tracers/internal/tracetest/testgenerator/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "testgenerator", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "src/index.ts", | ||
"scripts": { | ||
"start": "npm run build && node build/index.js", | ||
"build": "tsc" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"ethers": "^6.13.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.14.9", | ||
"typescript": "^5.5.2" | ||
} | ||
} |
Oops, something went wrong.