-
Notifications
You must be signed in to change notification settings - Fork 169
feat(tests): Add contract creation tests for 7951 #2068
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
base: main
Are you sure you want to change the base?
Conversation
+ Op.SSTORE( | ||
0, | ||
Op.CALL( | ||
gas=Spec.P256VERIFY_GAS, | ||
address=Spec.P256VERIFY, | ||
value=0, | ||
args_offset=0, | ||
args_size=len(input_data), | ||
ret_offset=0, | ||
ret_size=len(input_data) + 32, | ||
), | ||
) | ||
+ Op.SSTORE(1, Op.MLOAD(0)) |
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.
What about using the Storage
object? This could simplify the slot management!
The storage updated logic can be updated as follow, and we do not need to assign slots.
storage = Storage()
storage.store_next(true, Op.CALL(...))
storage.store_next(len(expected_output), Op.RETURNDATASIZE)
storage.store_next(expected_output, Op.MLOAD(0))
For the post storage, it could be updated as:
post = {
contract_address: {
"storage":storage,
},
}
This can be applied to the test case below also!
), | ||
) | ||
+ Op.SSTORE(1, Op.MLOAD(0)) | ||
+ Op.RETURN(0, 32) |
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.
Maybe here we only need 32 bytes as the return data size according to eip-7951?
Some small suggestion (nit) here, we can use STOP
instead of RETURN
maybe, but it works fine for both.
Op.CALL(
gas=Spec.P256VERIFY_GAS,
address=Spec.P256VERIFY,
value=0,
args_offset=0,
args_size=len(input_data),
ret_offset=0,
ret_size=len(input_data) + 32, # return data is 32 bytes
),
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 catches, thanks!
Thanks for the PR, leave some comment above. Please let me know if there is anything unclear! |
ποΈ Description
Add a few more tests for the p256verify precompile, specifically around what happens if a contract calls a precompile on initialization.
π Related Issues or PRs
#1794
β Checklist
tox
checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx --with=tox-uv tox -e lint,typecheck,spellcheck,markdownlint
type(scope):
.mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.