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

EIP-7756 Trace updates #8006

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
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),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to extend this to JSON-RPC calls? Currently this only impacts CLI tools (and those have a CLI override flag).

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 All @@ -308,7 +313,7 @@ private void traceTestSpecs(final String test, final List<GeneralStateTestCaseEi
summaryLine.put("d", spec.getDataIndex());
summaryLine.put("g", spec.getGasIndex());
summaryLine.put("v", spec.getValueIndex());
summaryLine.put("postHash", worldState.rootHash().toHexString());
summaryLine.put("stateRoot", worldState.rootHash().toHexString());
final List<Log> logs = result.getLogs();
final Hash actualLogsHash = Hash.hash(RLP.encode(out -> out.writeList(logs, Log::writeTo)));
summaryLine.put("postLogsHash", actualLogsHash.toHexString());
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,"stateRoot":"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 Expand Up @@ -101,6 +102,6 @@
{"pc":49,"op":96,"gas":"0x9ffffa38f","gasCost":"0x3","memory":"0x0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff","memSize":32,"stack":["0x111122223333444455556666777788889999aaaabbbbccccddddeeeeffff"],"returnData":"0x0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff","depth":1,"refund":0,"opName":"PUSH1"},
{"pc":51,"op":85,"gas":"0x9ffffa38c","gasCost":"0x1388","memory":"0x0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff","memSize":32,"stack":["0x111122223333444455556666777788889999aaaabbbbccccddddeeeeffff","0x0"],"returnData":"0x0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff","depth":1,"refund":0,"opName":"SSTORE"},
{"pc":52,"op":0,"gas":"0x9ffff9004","gasCost":"0x0","memory":"0x0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff","memSize":32,"stack":[],"returnData":"0x0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff","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}
{"output":"","gasUsed":"0x6ffc","test":"returndatacopy_following_call","fork":"London","d":0,"g":0,"v":0,"stateRoot":"0x1c6dda42e80135b6d5ff1a664e6f85e8552d5c56888bb35e2e694f3829a500c7","postLogsHash":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","pass":true}
]
}
Loading
Loading