Skip to content

feat(tests): add call operation test case for CLZ #1829

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 2 commits into
base: main
Choose a base branch
from

Conversation

LouisTsai-Csie
Copy link
Collaborator

@LouisTsai-Csie LouisTsai-Csie commented Jul 1, 2025

🗒️ Description

Add CALL/DELEGATECALL/STATICCALL/CODECALL opcode interaction with CLZ

🔗 Related Issues or PRs

Issue #1795

✅ 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.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.
  • Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned @ported_from marker.

@LouisTsai-Csie LouisTsai-Csie self-assigned this Jul 1, 2025
@LouisTsai-Csie LouisTsai-Csie added fork:osaka Osaka hardfork type:test Type: Add/refactor fw unit tests; no fw or el client test case changes labels Jul 1, 2025
@LouisTsai-Csie LouisTsai-Csie changed the title feat(CLZ): add call operation test case for CLZ feat(tests): add call operation test case for CLZ Jul 1, 2025
Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

Fantastic test, just a few minor comments. Thanks!

callee_address = pre.deploy_contract(code=callee_code)

caller_code = opcode(gas=0xFFFF, address=callee_address, ret_offset=0, ret_size=0x20)
caller_code += Op.RETURNDATACOPY(dest=0, offset=0, size=Op.RETURNDATASIZE)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
caller_code += Op.RETURNDATACOPY(dest=0, offset=0, size=Op.RETURNDATASIZE)

Return data is already in memory thanks to ret_size=0x20 ;)

Comment on lines 250 to 255
callee_code = Op.PUSH32(1 << bits) + Op.DUP1

if context != CallingContext.no_context:
callee_code += Op.CLZ + Op.PUSH0 + Op.SSTORE

callee_code += Op.CLZ + Op.PUSH0 + Op.MSTORE + Op.RETURN(0, 32)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
callee_code = Op.PUSH32(1 << bits) + Op.DUP1
if context != CallingContext.no_context:
callee_code += Op.CLZ + Op.PUSH0 + Op.SSTORE
callee_code += Op.CLZ + Op.PUSH0 + Op.MSTORE + Op.RETURN(0, 32)
callee_code = Op.PUSH32(1 << bits) + Op.CLZ
if context != CallingContext.no_context:
callee_code += Op.DUP1 + Op.PUSH0 + Op.SSTORE
callee_code += Op.PUSH0 + Op.MSTORE + Op.RETURN(0, 32)

I feel like this is a tiny bit more readable (do the CLZ operation then duplicate the result, instead of redoing the operation).

@LouisTsai-Csie
Copy link
Collaborator Author

@marioevz Thanks for review! I've updated accordingly

@LouisTsai-Csie LouisTsai-Csie requested a review from marioevz July 7, 2025 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fork:osaka Osaka hardfork type:test Type: Add/refactor fw unit tests; no fw or el client test case changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants