Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kclowes
Copy link
Collaborator

@kclowes kclowes commented Aug 21, 2025

πŸ—’οΈ 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

  • All: Ran fast 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
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered adding an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

@kclowes kclowes added scope:tests Scope: Changes EL client test cases in `./tests` type:feat type: Feature fork:osaka Osaka hardfork labels Aug 21, 2025
@kclowes kclowes marked this pull request as ready for review August 21, 2025 22:01
Comment on lines 314 to 326
+ 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))
Copy link
Collaborator

@LouisTsai-Csie LouisTsai-Csie Aug 22, 2025

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)
Copy link
Collaborator

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
),

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catches, thanks!

@LouisTsai-Csie
Copy link
Collaborator

Thanks for the PR, leave some comment above. Please let me know if there is anything unclear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fork:osaka Osaka hardfork scope:tests Scope: Changes EL client test cases in `./tests` type:feat type: Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants