-
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
fix(fw,tests): Fixes to EOF #513
Conversation
(previously |
logically this field does not belong to container. the container itself should be agnostic about its validity. I generated tests from test_code_validation.py into json and verified it against evmone eof tool. the valid tests however are not generating at all, need to add more unit tests to pyspecs Container class and validate it with evmone. I posted TODO comments around the exceptions that I think need double checking need more unit tests.
because I want to write but that does not work as it must be bytes. |
lots of TODOs
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.
Pydantic and Opcode changes LGTM! Pretty clever to hijack __getitem__
to create the RJUMPV look-up table.
The reason we use bytes here is because you might want to add many zeros at the end for testing purposes and if you make this an integer you cannot specify more than one byte (0x0000 just resolves to 0 in python and the leading zeros are discarded). Maybe the correct name for this field should then be |
then all the reset must be bytes too for consistancy. |
🗒️ Description
EOF classes use pydantic
EOF classes
Section
andContainer
now use pydanticBaseModel
.Opcodes with data portion are now subscriptable
Opcodes that have a data portion are now subscriptable:
Op.PUSH1[1]
Op.RJUMP[1]
Op.RJUMPI[1](Op.ORIGIN)
Where the subscript is used to define the data portion of the opcode, and the call arguments can now be used exclusively for the stack.
Data portion can still be passed as the first argument to the call, so
Op.PUSH1(1) == Op.PUSH1[1] == b"\x60\x01"
butOp.PUSH1[1](1)
will fail (we can begin to look forward to deprecate setting the data portion from the call arguments).This is specially useful for
Op.RJUMPV
, where we can define each jump destination as a parameter of the subscript:Op.RJUMPV[5, 6, 7](Op.ORIGIN)
In this example, the RJUMPV is converted into bytecode with three possible jump destinations,
+5
,+6
, or+7
, and themax_index
operand is automatically set touint8(3)
, andOp.ORIGIN
is executed to set the only required stack element.Fixes to EOF tests
All tests usages of
RJUMP
,RJUMPI
,RJUMPV
andCALLF
have been fixed to properly use subscripts.Section.Code
,Section.Data
,Section.Container
helpersThree helpers have been added as class methods to the
Section
class, and can be used as helpers to create code, data or container sections respectively.can now simply be:
Rest of the section arguments are passed along to the class creator.
Notes
Fixed
Tox is still failing due to filetests/prague/eip3540_eof_v1/test_execution_function.py
🔗 Related Issues
✅ Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.