Skip to content

Commit cac09a3

Browse files
s1naholiman
andauthored
eth/tracers: native prestate tracer (ethereum#24268)
* eth/tracers: add initial native prestate tracer * fix balance hex * handle prestate for tx from and to * drop created contract from prestate * fix sender balance * use switch instead Co-authored-by: Martin Holst Swende <[email protected]> * minor fix * lookup create2 account * mv code around a bit * check stackLen for create2 * fix transfer tx for js prestate tracer * fix create2 addr * track extcodehash in js prestate tracer Co-authored-by: Martin Holst Swende <[email protected]>
1 parent 0c1bd22 commit cac09a3

File tree

4 files changed

+198
-6
lines changed

4 files changed

+198
-6
lines changed

eth/tracers/js/internal/tracers/assets.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eth/tracers/js/internal/tracers/prestate_tracer.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@
4747
// result is invoked when all the opcodes have been iterated over and returns
4848
// the final result of the tracing.
4949
result: function(ctx, db) {
50+
if (this.prestate === null) {
51+
this.prestate = {};
52+
// If tx is transfer-only, the recipient account
53+
// hasn't been populated.
54+
this.lookupAccount(ctx.to, db);
55+
}
56+
5057
// At this point, we need to deduct the 'value' from the
5158
// outer transaction, and move it back to the origin
5259
this.lookupAccount(ctx.from, db);
@@ -79,7 +86,7 @@
7986
}
8087
// Whenever new state is accessed, add it to the prestate
8188
switch (log.op.toString()) {
82-
case "EXTCODECOPY": case "EXTCODESIZE": case "BALANCE":
89+
case "EXTCODECOPY": case "EXTCODESIZE": case "EXTCODEHASH": case "BALANCE":
8390
this.lookupAccount(toAddress(log.stack.peek(0).toString(16)), db);
8491
break;
8592
case "CREATE":

eth/tracers/native/call.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ type callTracer struct {
5959
func newCallTracer() tracers.Tracer {
6060
// First callframe contains tx context info
6161
// and is populated on start and end.
62-
t := &callTracer{callstack: make([]callFrame, 1)}
63-
return t
62+
return &callTracer{callstack: make([]callFrame, 1)}
6463
}
6564

6665
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.

0 commit comments

Comments
 (0)