-
Notifications
You must be signed in to change notification settings - Fork 83
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
new(cli): Introduce eofwrap tool #896
Conversation
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.
Looks good! I think we could apply this in a post-fill script.
I think @danceratopz might have some comments, and I see one regarding how this could be a pytest plugin, and I agree 😄
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.
Nice idea! I agree with Mario that we could make a pytest plugin out of this 🙂 However, I think we can merge this as-is and then consider whether we do this later.
To explain a little how that could be helpful, you can try out consume direct
, which is a small wrapper framework to help execute fixtures against client statetest
and blocktest
commands. Currently, only geth
is supported, but we're currently refactoring this code and plan to add other clients soon. Here's an example:
uv run consume direct --input=../../ethereum/tests/BlockchainTests/GeneralStateTests/Cancun/ --evm-bin=~/bin/evm
All the usual pytest flags are available. For example, tests can be filtered as for fill
with -k
. The consume
command also generates an index file of all the discovered test fixtures - this can be used for subsequent runs, speeding up test discovery.
Of course, if this is more a "single shot" kinda tool, then this CLI could already be sufficient! If we do decide to refactor this to be a pytest plugin, we'd be very happy to take the implementation over or help out. More than likely, we would try to generalize it a bit further in this case.
Anyway, one small comment about this PR below.
32f616d
to
bf73941
Compare
@marioevz @danceratopz Thank you for your comments, I think I've addressed all except the plugin - would be better to leave for a separate PR indeed. I see the benefits, but not sure if I know where to start, and also it is indeed more of a one-off tool (hopefully temporary, until migration, but I have some level of fear that it will be "permanently-temporary", the migration is a lot to take on). Do we want to tackle including of these tests in the |
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.
Thanks for the changes, it's looking very good. A couple of comments.
Co-authored-by: danceratopz <[email protected]>
bf73941
to
f7084a2
Compare
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.
Looks great! Many thanks for the refactor in evm_bytes.py
.
🗒️ Description
There are many general EVM tests in
ethereum/tests
which provide coverage for opcodes and patterns which should behave independently from whether they run as legacy or as EOF code. ThinkADDMOD
,SSTORE
,SHL
etc... These likely will eventually be migrated manually to EEST, and then the existing tools will be there to wrap them in EOF containers. However, this is a long term task, and we would like to have the coverage early, in preparation for the EOF fork.It turns out many of
ethereum/tests
state tests (here using their blockchain_test format, read on to see why) can be opportunistically (that is if they "wrap" easily - good, if not - skip) wrapped into EOF containers and executed and the same expectations on post state will apply.This PR introduces a new CLI tool
eofwrap
accomplishes this. I've used it on v14.1 releaseethereum/tests
(subdirBlockchainTests/GeneralStateTests/
). Themetrics.json
contents is:If one collects the traces with
evmone
, but modifying it to only trace EOF code execution, then after some sorting/counting (cat trace.log | grep -o '\"opName\"\:\".*\"' | sort | uniq -c
), one can get the following summary of the opcodes executed in EOF:Open questions
eofwrap
takes an opportunistic approach - if the test wraps something and passes, it's worthwhile to wrap and run it. For example, there are tests where it is not the most important code under test being EOF-wrapped, but some auxiliary contract which merely interacts with the important one. Opportunistic here means we still keep this test, to potentially test some edge cases of interactions between legacy and EOF contexts. Other aspect is that there are test categories where many of the fixtures are unwrappable, but several remain. Opportunistic means then that we nevertheless keep the ones which wrapped.The opposite side of the spectrum is to be more "systematic", i.e. filter out more test categories where the test is "weaker" and include tests more coarsely, only where we're certain EOF opcodes are executed.
For now we err on the side of opportunistic, since this is intended to be a low-cost, stop-gap solution, and postpone the systematic effort until proper migration to EEST.
eofwrap
in theeip7692
prerelease builds, and just include the JSON files in the resulting directory structure. This maximizes the chance that the EVM implementations will actually run these tests, but might come off as messy.🔗 Related Issues
NA
✅ Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.