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
Implement Evm Trace #828
Implement Evm Trace #828
Conversation
Currently implemented the trace only for |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #828 +/- ##
==========================================
+ Coverage 74.06% 74.09% +0.03%
==========================================
Files 571 572 +1
Lines 31735 32018 +283
==========================================
+ Hits 23503 23725 +222
- Misses 8232 8293 +61
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
037e6a0
to
f588b28
Compare
Since the evm tests fail for the forks before Shanghai, I have added a temporary if condition. This is just so we see all the tests passing in the CI. Once the Shanghai changes have been reviewed and are ported over to the other forks, this if condition goes away before merging all the changes with master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably still here because you've only done Shanghai so far, but just in case, you'll want to remove this as well:
execution-specs/src/ethereum/__init__.py
Lines 31 to 37 in fade6e9
def evm_trace(evm: Any, op: Any) -> None: | |
""" | |
autoapi_noshow | |
Placeholder for an evm trace function. The spec does not trace evm by | |
default. EVM tracing will be injected if the user requests it. | |
""" | |
pass |
Yes. This will also go after porting the changes to the other forks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one further niggle. I think Sam has covered the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really looking forward to using this!
I quickly tested the --trace
flag (combined with the changes required from #823) against ethereum/execution-spec-tests#289; also slightly modified due to differences in filename (more on that below):
diff --git a/src/evm_transition_tool/transition_tool.py b/src/evm_transition_tool/transition_tool.py
index ae24b319..14c1ee2b 100644
--- a/src/evm_transition_tool/transition_tool.py
+++ b/src/evm_transition_tool/transition_tool.py
@@ -242,6 +242,7 @@ class TransitionTool:
traces: List[List[Dict]] = []
for i, r in enumerate(receipts):
trace_file_name = f"trace-{i}-{r['transactionHash']}.jsonl"
+ # trace_file_name = f"spec-trace-{r['transactionHash']}.json"
if debug_output_path:
shutil.copy(
os.path.join(temp_dir.name, trace_file_name),
Here's the execution-spec-tests command:
fill --evm-bin=/path/to/ethereum/execution-specs/venv/bin/ethereum-spec-evm --t8n-dump-dir=/tmp/ethereum-spec-evm/ --fork=Shanghai -v --traces
Some background: The interface used in execution-spec-tests to execute the ethereum-spec-evm t8n
tool is shared with geth's evm t8n
and evmone-t8n
, so any differences are quickly highlighted. Would it be possible to change the filename as below, to make them consistent across these tools? The main effort will be adding the index of the transaction processed by the t8n tool.
Further help on using execution-spec-tests with execution-spec-evm here.
@SamWilsn @petertdavies Have updated the relevant bits based on your comments. @danceratopz Have updated the tool to reflect specific output file names. Please verify. |
@gurukamath Yes, if I apply #823 to this branch, it now works as expected with ethereum/execution-spec-tests#289 as-is, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, one last niggle/discrepancy, sorry! I just saw that the following flags are also available:
--trace.memory TRACE_MEMORY
--trace.nomemory TRACE_NOMEMORY
--trace.noreturndata TRACE_NORETURNDATA
--trace.nostack TRACE_NOSTACK
--trace.returndata TRACE_RETURNDATA
which require an argument. To make the behavior exactly as geth's evm t8n
command, these would be switches that do not take/require an argument.
Of course, we can abstract this away in our interface, but I hope you appreciate it's nice to keep these tools as consistent as possible.
@SamWilsn @petertdavies Have ported the changes over to the older forks. The main update from the earlier commits in this PR is that the refund calculation for SELFDESTRUCT is moved from the |
f239e23
to
753416e
Compare
Hi @gurukamath, I took a deeper look at the traces generated from the current execution-spec-tests and diff'd the traces generated from geth The traces are almost identical 🥳 and only differ upon an error in execution. They fall into 2 categories.
|
The specs do not currently emit comprehensive error messages. We are working on it and have an active issue ( see #795 )
We are aware that in some cases where the opcode runs out of gas, geth and specs might emit different gas costs. In almost all such cases, I have found that geth emits only the static part of the gas cost. See this geth issue for more details. However, I would also like to take a deeper look at this particular case just to make sure that it is a similar case. Would it be possible for you to provide the input json files for running this? Or alternatively, point me to the fixture in the tests repo that has this case? |
Thanks for info and links.
Github wouldn't let me upload json or tgz - I'll send you the files another way. In general, you could run this test case from ethereum/execution-spec-tests in isolation with:
|
@danceratopz I did look into this case and is similar to the scenario that I pointed out earlier. Geth figures out that the opcode is going to run out of gas due to large init code. For efficiency reasons, it then does not even bother to calculate the dynamic gas because it makes no difference. So it just emits the static part in the trace. The specs on the other hand calculate all the components of the gas (static + dynamic) and emits that in the trace. I am not sure if there is a standard behaviour that is agreed upon in this case. At least, I couldn't find anything in EIP-3155. For greater context on such issues you can follow the issue on the geth repo that linked earlier. See here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
(closes #624 )
What was wrong?
The specs don't currently implement the full evm trace.
Related to Issue #624
How was it fixed?
Implemented full evm trace and integrated it fully with
t8n
.Cute Animal Picture