eth/tracers: native prestate tracer (#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 <martin@swende.se>

* 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 <martin@swende.se>
This commit is contained in:
Sina Mahmoodi
2022-01-31 09:51:17 +01:00
committed by GitHub
parent 0c1bd22ec0
commit cac09a3823
4 changed files with 198 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -47,6 +47,13 @@
// result is invoked when all the opcodes have been iterated over and returns
// the final result of the tracing.
result: function(ctx, db) {
if (this.prestate === null) {
this.prestate = {};
// If tx is transfer-only, the recipient account
// hasn't been populated.
this.lookupAccount(ctx.to, db);
}
// At this point, we need to deduct the 'value' from the
// outer transaction, and move it back to the origin
this.lookupAccount(ctx.from, db);
@ -79,7 +86,7 @@
}
// Whenever new state is accessed, add it to the prestate
switch (log.op.toString()) {
case "EXTCODECOPY": case "EXTCODESIZE": case "BALANCE":
case "EXTCODECOPY": case "EXTCODESIZE": case "EXTCODEHASH": case "BALANCE":
this.lookupAccount(toAddress(log.stack.peek(0).toString(16)), db);
break;
case "CREATE":