-
Notifications
You must be signed in to change notification settings - Fork 106
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
feat(tests): EIP-152 precompiled contracts with Blake2 #1067
Conversation
I wasn't familiar with the opcodes needed to successfully write the pre state contract, so I ended up copying over the yul from the original test. I may not have it all correct since the output state indicates there is no data returned in each case. I have the test cases written out so it'd be great if I could get some eyes on the potential issues with my implementation. 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.
rewrite the yul contract using Op
Also since you start blake test, here are the existing blake tests that need to be converted
https://github.com/search?q=repo%3Aethereum%2Ftests%20blake&type=code
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! Looking good so far, leaving the pre-state contract as Yul is a good first approach to getting the tests working up front.
After all the tests fill successfully with this Yul contract, we could consider splitting it up and deploying test case-specific contracts matching the pytest parameterization.
Below are some cosmetic suggestions. Happy to help debug the fails, just let me know. But a starting point could be to fill using geth and enable traces (these are currently unavailable with EELS, but coming soon). Something like:
uv run pytest ./tests/istanbul/eip152_blake2/test_blake2.py -k "not case8" --evm-bin=~/bin/evm --traces -x
Should I keep all of these tests together in the same file but as separate tests? I could also keep them as separate files entirely, but maybe it's better to keep them all in one spot? |
dda4711
to
36d4d17
Compare
@danceratopz @winsvega Just pushed up the latest revisions. As you can see there are test failures but I am not seeing anything from the trace output that would indicate an issue. It seems the inputs are not producing the same outputs as in the original ethereum/tests cases. From what I can tell, the For example, in case 9, the inputs have a It's possible the output values should be changed based on this logic. I'm not sure what that means for the original test cases or the clients which rely on those. Let me know if my logic is sound, or if there's still a problem with the test cases I've created here. |
36d4d17
to
1e38633
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.
A few comments but it looks pretty good overall, thanks for implementing this!
10647f6
to
3185e35
Compare
3185e35
to
4a8e728
Compare
@marioevz @winsvega I've updated the code based on your feedback, let me know if there's anything else. All cases are consistent with the cases that are in the original precompiled tests. It's hard to tell if any edge cases may be missing. A code search shows other json files but I think most of those cases are already covered by the new tests. I believe the json fixture https://github.com/ethereum/tests/blob/c30599fb23d0470301f68bc69188ef444dcbc861/src/GeneralStateTestsFiller/stPreCompiledContracts2/CALLBlake2fFiller.json#L2 is already covered in this PR. There are several files such as https://github.com/ethereum/tests/blob/c30599fb23d0470301f68bc69188ef444dcbc861/GeneralStateTests/stPreCompiledContracts2/CALLCODEBlake2f.json#L2 which are checking Thanks for checking these and helping me understand if I missed anything! |
hash logs and txbytes generated by the framework, you don't need to worry about it. |
6be2988
to
c38e2bc
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, just the comments about the storage initial state that Dimitry suggested.
c38e2bc
to
1eaf4f2
Compare
Use opcodes and set test parameters to the expected inputs and outputs. Update CHANGELOG Document removal of json in converted-ethereum-tests.txt
1eaf4f2
to
2419435
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.
LGTM, thanks for the changes!
I went over the coverage report and it seems related to the different approach we use in the python tests where we generate a different contract per test case instead of one big contract and handle the cases via jumps, and the lost coverage comes from the jump instructions not being covered anymore, which is completely reasonable to me since we are not looking to test this area with these cases.
Use opcodes and set test parameters to the expected inputs and outputs. Update CHANGELOG Document removal of json in converted-ethereum-tests.txt
🗒️ Description
Add tests for EIP-152: BLAKE2 compression function
F
precompile.Test cases pulled from https://github.com/ethereum/tests/blob/develop/src/GeneralStateTestsFiller/stPreCompiledContracts/blake2BFiller.yml
🔗 Related Issues
ethereum/tests#1431
✅ Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.