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

eth/tracers: add diffMode to prestateTracer #25422

Merged
merged 37 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c97352a
eth/tracers: add a simple diffstate implemention
jsvisa Jul 27, 2022
7acf179
eth/tracers/native: rename diffstateTracer to stateDiffTracer
jsvisa Jul 28, 2022
f27afc9
eth/tracers/internal: add stateDiffTracer testcase
jsvisa Jul 28, 2022
9184369
eth/tracers/statediff: change the diff in CaptureTxEnd
jsvisa Jul 28, 2022
a95eeaa
eth/tracers/statediff: don't exclude the created contracts
jsvisa Jul 28, 2022
76e04ff
eth/tracers/native: refund the from address with rest gas
jsvisa Jul 28, 2022
810df7f
eth/tracers/native: statediff add miner's state
jsvisa Jul 28, 2022
60b0bf1
eth/tracers/internal: don't repeat yourself
jsvisa Jul 29, 2022
aaffa05
eth/tracers/internal: move common func into util.go
jsvisa Jul 29, 2022
2fa7b17
eth/tracers/native: merge statediff into prestate
jsvisa Aug 9, 2022
bdcd832
eth/tracers/internal: test prestate
jsvisa Aug 9, 2022
73ad31d
eth/tracers/native: post in prestate as optional
jsvisa Aug 9, 2022
2d95b35
eth/tracer/internal/tracetest: test prestate with collectPost
jsvisa Aug 9, 2022
1592d53
eth/tracers/native: pre/post prestate
jsvisa Sep 21, 2022
ce9f84b
eth/tracers/native: prestate calculate the post state pre txend
jsvisa Sep 21, 2022
f6401a2
eth/tracers/native: rm notused from/miner balance calculate
jsvisa Sep 21, 2022
f6b148d
eth/tracers/native: omitempty prestate
jsvisa Sep 21, 2022
0ed11f2
eth/tracers/native: keep the modified fields
jsvisa Sep 21, 2022
81b6a4d
eth/tracers/tracetest: test with pre && post trace
jsvisa Sep 21, 2022
6cc9770
eth/tracers/tracetest: move collectPost into indepent dir
jsvisa Sep 21, 2022
43d6612
eth/tracers/tracetest: omitempty
jsvisa Sep 21, 2022
90fb1ac
eth/tracers: rm not used t.from
jsvisa Sep 23, 2022
9b0e264
eth/tracers: missing the tx's created contract
jsvisa Sep 23, 2022
a39764d
eth/tracers/internal: fix the issue nonce maybe null
jsvisa Sep 23, 2022
e18711a
eth/tracers: clear empty slot in prestate
jsvisa Sep 23, 2022
30f509a
eth/traces: remove the not empty contracts in pre
jsvisa Sep 23, 2022
47eaf6c
eth/tracers: add create prestate testcase
jsvisa Sep 23, 2022
d4c3be5
eth/tracers: delete the not modified address in pre
jsvisa Sep 23, 2022
0e97016
eth/traces: add suicide,inner_create testcase
jsvisa Sep 23, 2022
48a3f3d
eth/tracers: add create_suicide testcase
jsvisa Sep 23, 2022
6bca612
eth/tracers: fix the issue of pointer compare
jsvisa Sep 28, 2022
37370ee
eth/tracers/native: collectPost -> diffMode
jsvisa Sep 28, 2022
c4e26ed
eth/tracers/internal: rename collectPost to diffMode
jsvisa Sep 28, 2022
c7a9093
eth/tracers: prestate omitempty
jsvisa Sep 28, 2022
7913c47
eth/tracers: fix the test folder name
jsvisa Sep 28, 2022
388789b
eth/tracers: omitempty of prestate's code,storage
jsvisa Sep 28, 2022
d572f7e
eth/tracers: fix the testcase of empty code
jsvisa Sep 28, 2022
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
Prev Previous commit
eth/tracers: fix the testcase of empty code
Signed-off-by: Delweng <[email protected]>
  • Loading branch information
jsvisa committed Sep 29, 2022
commit d572f7e63fd3dbed21bb626cdf321b315031e6a0
2 changes: 1 addition & 1 deletion eth/tracers/internal/tracetest/prestate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestPrestateTracer(t *testing.T) {
testPrestateDiffTracer("prestateTracer", "prestate_tracer", t, func() interface{} { return new(prestateTrace) })
}

func TestPrestateWithCollectPostTracer(t *testing.T) {
func TestPrestateWithDiffModeTracer(t *testing.T) {
testPrestateDiffTracer("prestateTracer", "prestate_tracer_with_diff_mode", t, func() interface{} { return new(prePostStateTrace) })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
"result": {
"0x0024f658a46fbb89d8ac105e98d7ac7cbbaf27c5": {
"balance": "0x0",
"nonce": 22,
"code": "0x"
"nonce": 22
},
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
"balance": "0x4d87094125a369d9bd5",
Expand All @@ -75,13 +74,11 @@
},
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
"balance": "0x1780d77678137ac1b775",
"nonce": 29072,
"code": "0x"
"nonce": 29072
},
"0x1585936b53834b021f68cc13eeefdec2efc8e724": {
"balance": "0x0",
"nonce": 0,
"code": "0x"
"nonce": 0
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@
"pre": {
"0x2a65aca4d5fc5b5c859090a6c34d164135398226": {
"balance": "0x9fb6b81e112638b886",
"nonce": 217865,
"code": "0x"
"nonce": 217865
},
"0xf0c5cef39b17c213cfe090a46b8c7760ffb7928a": {
"balance": "0x15b6828e22bb12188",
"nonce": 747,
"code": "0x"
"nonce": 747
}
},
"post": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,21 @@
"pre": {
"0x082d4cdf07f386ffa9258f52a5c49db4ac321ec6": {
"balance": "0xc820f93200f4000",
"nonce": 94,
"code": "0x"
"nonce": 94
},
"0x332b656504f4eabb44c8617a42af37461a34e9dc": {
"balance": "0x11faea4f35e5af80000",
"code": "0x",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5": {
"balance": "0xbf681825be002ac452",
"nonce": 28922,
"code": "0x"
"nonce": 28922
},
"0x82effbaaaf28614e55b2ba440fb198e0e5789b0f": {
"balance": "0xb3d0ac5cb94df6f6b0",
"nonce": 1,
"code": "0x"
"nonce": 1
}
},
"post": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@
"pre": {
"0x2a65aca4d5fc5b5c859090a6c34d164135398226": {
"balance": "0x98e1c608601c2496b2",
"nonce": 218916,
"code": "0x"
"nonce": 218916
},
"0x6c8f2a135f6ed072de4503bd7c4999a1a17f824b": {
"balance": "0x0",
Expand Down Expand Up @@ -303,13 +302,11 @@
},
"0xb834e3edfc1a927bdcecb67a9d0eccbd752a5bb3": {
"balance": "0xffe9b09a5c474dca",
"nonce": 975,
"code": "0x"
"nonce": 975
},
"0xd3cda913deb6f67967b99d67acdfa1712c293601": {
"balance": "0x4f5807198e238f13e",
"nonce": 283,
"code": "0x"
"nonce": 283
}
},
"post": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@
"pre": {
"0x0024f658a46fbb89d8ac105e98d7ac7cbbaf27c5": {
"balance": "0x0",
"nonce": 22,
"code": "0x"
"nonce": 22
},
"0x1585936b53834b021f68cc13eeefdec2efc8e724": {
"balance": "0x0",
"code": "0x"
"balance": "0x0"
},
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
"balance": "0x4d87094125a369d9bd5",
Expand All @@ -83,8 +81,7 @@
},
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
"balance": "0x1780d77678137ac1b775",
"nonce": 29072,
"code": "0x"
"nonce": 29072
}
},
"post": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@
},
"0x2a65aca4d5fc5b5c859090a6c34d164135398226": {
"balance": "0x326601cc6cf364f6b9",
"nonce": 12122,
"code": "0x"
"nonce": 12122
},
"0xd3cda913deb6f67967b99d67acdfa1712c293601": {
"balance": "0x1ff0509d9d6821e26",
"nonce": 138,
"code": "0x"
"nonce": 138
}
},
"post": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious about this 'suicide.json' test -- did any account here do a selfdestruct? If so, it doesn't really show on the post-state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, the contract 0x2861bf89b6c640c79040d357c1e9513693ef5d3f is selfdestructed, and only in the pre stage . actually it's this transaction 0x0de8b6a364b7ab3425069cd5f03acaa3a6fc1e560c61ae7cadab0627f87178d0

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens with contracts that are not modified during the execution (but still read / accessed )? Are they present in the post-state too, but empty?

Copy link
Contributor Author

@jsvisa jsvisa Sep 28, 2022

Choose a reason for hiding this comment

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

In the current implementation, If his balance/storage were modified, then exists in post-state; if only read/accessed, then this account will be in pre or post-state.

But, I think we can add another option to keep them all in pre-post.

Copy link
Contributor

Choose a reason for hiding this comment

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

selfdestructed, and only in the pre stage .

if only read/accessed, then this account will be in pre or post-state.

Not sure I follow. How does one distinguish between "not in post-state because nothing changed" versus "not in post-state, because it was destructed" ?

Copy link
Contributor

@s1na s1na Sep 29, 2022

Choose a reason for hiding this comment

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

I think that's a typo a should read "if only read/accessed, then this account will NOT be in pre or post-state."

I.e. accounts that are only read should be completely left out of the result.

Expand Down