Skip to content

Commit

Permalink
EIP-7756 Trace updates
Browse files Browse the repository at this point in the history
Update tracing for EIP-7756 changes, mostly swapping hex format and
numbers for opcode and gas members.

Signed-off-by: Danno Ferrin <[email protected]>
  • Loading branch information
shemnon committed Dec 9, 2024
1 parent 8148f0d commit 69846a6
Show file tree
Hide file tree
Showing 23 changed files with 402 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ public List<String> traceTransactionToFile(
stackedUpdater,
transaction,
transactionProcessor,
new StandardJsonTracer(out, showMemory, true, true, false),
// FIXME // REVIEWME do we want to change the JSON
// debug calls to use EIP-7756 values for gas and opcode?
new StandardJsonTracer(out, showMemory, true, true, false, true),
blobGasPrice);
out.println(
summaryTrace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ void setBytes(final String optionValue) {
scope = INHERIT)
final Boolean showJsonAlloc = false;

@Option(
names = {"--eip-3155", "--trace.eip-3155"},
description = "Produce a trace with types strictly compatible with EIP-3155.",
scope = INHERIT,
negatable = true)
final Boolean eip3155strict = false;

@Option(
names = {"--memory", "--trace.memory"},
description =
Expand Down Expand Up @@ -441,7 +448,8 @@ public void run() {

final OperationTracer tracer = // You should have picked Mercy.
lastLoop && showJsonResults
? new StandardJsonTracer(out, showMemory, !hideStack, showReturnData, showStorage)
? new StandardJsonTracer(
out, showMemory, !hideStack, showReturnData, showStorage, eip3155strict)
: OperationTracer.NO_TRACING;

WorldUpdater updater = component.getWorldUpdater();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ private void traceTestSpecs(final String test, final List<GeneralStateTestCaseEi
parentCommand.showMemory,
!parentCommand.hideStack,
parentCommand.showReturnData,
parentCommand.showStorage)
parentCommand.showStorage,
parentCommand.eip3155strict)
: OperationTracer.NO_TRACING;

final ObjectMapper objectMapper = JsonUtils.createObjectMapper();
Expand Down Expand Up @@ -295,7 +296,11 @@ private void traceTestSpecs(final String test, final List<GeneralStateTestCaseEi
final long timeNs = timer.elapsed(TimeUnit.NANOSECONDS);
final float mGps = gasUsed * 1000.0f / timeNs;

summaryLine.put("gasUsed", StandardJsonTracer.shortNumber(gasUsed));
if (parentCommand.eip3155strict) {
summaryLine.put("gasUsed", StandardJsonTracer.shortNumber(gasUsed));
} else {
summaryLine.put("gasUsed", gasUsed);
}

if (!parentCommand.noTime) {
summaryLine.put("time", timeNs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ public OperationTracer getManagedTracer(final int txIndex, final Hash txHash)
parentCommand.showMemory,
!parentCommand.hideStack,
parentCommand.showReturnData,
parentCommand.showStorage);
parentCommand.showStorage,
parentCommand.eip3155strict);
outputStreams.put(jsonTracer, traceDest);
return jsonTracer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ public OperationTracer getManagedTracer(final int txIndex, final Hash txHash)
parentCommand.showMemory,
!parentCommand.hideStack,
parentCommand.showReturnData,
parentCommand.showStorage);
parentCommand.showStorage,
parentCommand.eip3155strict);
outputStreams.put(jsonTracer, traceDest);
return jsonTracer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,30 @@
}
},
"stdout": [
{"pc":0,"op":96,"gas":"0x9ffffadf8","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":2,"op":96,"gas":"0x9ffffadf5","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":4,"op":96,"gas":"0x9ffffadf2","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":6,"op":96,"gas":"0x9ffffadef","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":8,"op":96,"gas":"0x9ffffadec","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":10,"op":115,"gas":"0x9ffffade9","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH20"},
{"pc":31,"op":100,"gas":"0x9ffffade6","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH5"},
{"pc":37,"op":241,"gas":"0x9ffffade3","gasCost":"0x900000a28","memSize":0,"depth":1,"refund":0,"opName":"CALL"},
{"pc":0,"op":125,"gas":"0x900000000","gasCost":"0x3","memSize":0,"depth":2,"refund":0,"opName":"PUSH30"},
{"pc":31,"op":96,"gas":"0x8fffffffd","gasCost":"0x3","memSize":0,"depth":2,"refund":0,"opName":"PUSH1"},
{"pc":33,"op":82,"gas":"0x8fffffffa","gasCost":"0x6","memSize":0,"depth":2,"refund":0,"opName":"MSTORE"},
{"pc":34,"op":96,"gas":"0x8fffffff4","gasCost":"0x3","memSize":32,"depth":2,"refund":0,"opName":"PUSH1"},
{"pc":36,"op":96,"gas":"0x8fffffff1","gasCost":"0x3","memSize":32,"depth":2,"refund":0,"opName":"PUSH1"},
{"pc":38,"op":243,"gas":"0x8ffffffee","gasCost":"0x0","memSize":32,"depth":2,"refund":0,"opName":"RETURN"},
{"pc":38,"op":80,"gas":"0x9ffffa3a9","gasCost":"0x2","memSize":0,"depth":1,"refund":0,"opName":"POP"},
{"pc":39,"op":96,"gas":"0x9ffffa3a7","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":41,"op":96,"gas":"0x9ffffa3a4","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":43,"op":96,"gas":"0x9ffffa3a1","gasCost":"0x3","memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":45,"op":62,"gas":"0x9ffffa39e","gasCost":"0x9","memSize":0,"depth":1,"refund":0,"opName":"RETURNDATACOPY"},
{"pc":46,"op":96,"gas":"0x9ffffa395","gasCost":"0x3","memSize":32,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":48,"op":81,"gas":"0x9ffffa392","gasCost":"0x3","memSize":32,"depth":1,"refund":0,"opName":"MLOAD"},
{"pc":49,"op":96,"gas":"0x9ffffa38f","gasCost":"0x3","memSize":32,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":51,"op":85,"gas":"0x9ffffa38c","gasCost":"0x1388","memSize":32,"depth":1,"refund":0,"opName":"SSTORE"},
{"pc":52,"op":0,"gas":"0x9ffff9004","gasCost":"0x0","memSize":32,"depth":1,"refund":0,"opName":"STOP"},
{"output":"","gasUsed":"0x6ffc","test":"returndatacopy_following_call","fork":"London","d":0,"g":0,"v":0,"postHash":"0x1c6dda42e80135b6d5ff1a664e6f85e8552d5c56888bb35e2e694f3829a500c7","postLogsHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","pass":true}
{"pc":0,"op":"0x60","gas":42949651960,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":2,"op":"0x60","gas":42949651957,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":4,"op":"0x60","gas":42949651954,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":6,"op":"0x60","gas":42949651951,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":8,"op":"0x60","gas":42949651948,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":10,"op":"0x73","gas":42949651945,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH20"},
{"pc":31,"op":"0x64","gas":42949651942,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH5"},
{"pc":37,"op":"0xf1","gas":42949651939,"gasCost":38654708264,"memSize":0,"depth":1,"refund":0,"opName":"CALL"},
{"pc":0,"op":"0x7d","gas":38654705664,"gasCost":3,"memSize":0,"depth":2,"refund":0,"opName":"PUSH30"},
{"pc":31,"op":"0x60","gas":38654705661,"gasCost":3,"memSize":0,"depth":2,"refund":0,"opName":"PUSH1"},
{"pc":33,"op":"0x52","gas":38654705658,"gasCost":6,"memSize":0,"depth":2,"refund":0,"opName":"MSTORE"},
{"pc":34,"op":"0x60","gas":38654705652,"gasCost":3,"memSize":32,"depth":2,"refund":0,"opName":"PUSH1"},
{"pc":36,"op":"0x60","gas":38654705649,"gasCost":3,"memSize":32,"depth":2,"refund":0,"opName":"PUSH1"},
{"pc":38,"op":"0xf3","gas":38654705646,"gasCost":0,"memSize":32,"depth":2,"refund":0,"opName":"RETURN"},
{"pc":38,"op":"0x50","gas":42949649321,"gasCost":2,"memSize":0,"depth":1,"refund":0,"opName":"POP"},
{"pc":39,"op":"0x60","gas":42949649319,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":41,"op":"0x60","gas":42949649316,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":43,"op":"0x60","gas":42949649313,"gasCost":3,"memSize":0,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":45,"op":"0x3e","gas":42949649310,"gasCost":9,"memSize":0,"depth":1,"refund":0,"opName":"RETURNDATACOPY"},
{"pc":46,"op":"0x60","gas":42949649301,"gasCost":3,"memSize":32,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":48,"op":"0x51","gas":42949649298,"gasCost":3,"memSize":32,"depth":1,"refund":0,"opName":"MLOAD"},
{"pc":49,"op":"0x60","gas":42949649295,"gasCost":3,"memSize":32,"depth":1,"refund":0,"opName":"PUSH1"},
{"pc":51,"op":"0x55","gas":42949649292,"gasCost":5000,"memSize":32,"depth":1,"refund":0,"opName":"SSTORE"},
{"pc":52,"op":"0x00","gas":42949644292,"gasCost":0,"memSize":32,"depth":1,"refund":0,"opName":"STOP"},
{"output":"","gasUsed":28668,"test":"returndatacopy_following_call","fork":"London","d":0,"g":0,"v":0,"postHash":"0x1c6dda42e80135b6d5ff1a664e6f85e8552d5c56888bb35e2e694f3829a500c7","postLogsHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","pass":true}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"--trace.memory",
"--trace.stack",
"--trace.returndata",
"--trace.eip-3155",
"--notime"
],
"stdin": {
Expand Down
Loading

0 comments on commit 69846a6

Please sign in to comment.