-
Notifications
You must be signed in to change notification settings - Fork 154
feat(tests): extra stack operation test for CLZ opcode #1821
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
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 good! Just a couple of comments, thanks!
|
||
for i in range(bit, 32): | ||
op = getattr(Op, f"PUSH{i}") | ||
code += Op.SSTORE(op[i], Op.CLZ(1 << bit)) |
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.
I feel we should use Op.CLZ(op[1 << bit])
to guarantee that the PUSHn opcode is the one that pushes to the stack right before CLZ.
state_test(pre=pre, post=post, tx=tx) | ||
|
||
|
||
@pytest.mark.parametrize("bit", list(range(1, 33))) |
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.
Could we cram all these into a single test? I feel this generates way too many tests.
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.
Yes, I put all the test cases into a single test, and remove the parametrization
3801962
to
4f2b68d
Compare
🗒️ Description
Hardening Fusaka for EIP-7939
Add two additional test cases for stack manipulation related to the CLZ (Count Leading Zeros) opcode:
The CLZ operation must never cause a stack overflow, as it does not increase the number of items on the stack.
Test: Push 1022 items onto the stack, then execute CLZ 256 times while storing the result after each call. Ensure that no stack overflow occurs during this process.
For the same numeric value pushed onto the stack, the CLZ opcode should yield the same result, regardless of which PUSH variant (PUSH1 to PUSH32) was used.
Examples:
🔗 Related Issues or PRs
Issue #1795
✅ 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.@ported_from
marker.