Skip to content

feat(tests): eip-7883 & eip-7823 modexp cases #1579

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

spencer-tb
Copy link
Contributor

@spencer-tb spencer-tb commented May 9, 2025

πŸ—’οΈ Description

Adds tests cases for the 2 modexp EIPs CFI'd in Fusaka: 7883/7823.

Still a WIP.

πŸ”— Related Issues

N/A

βœ… Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.

@spencer-tb spencer-tb added scope:tests Scope: Changes EL client test cases in `./tests` fork:osaka Osaka hardfork feature:eof type:feat type: Feature and removed feature:eof labels May 9, 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.

Just a couple of comments, I didn't fully review yet.

Test cases for [EIP-7883: ModExp Gas Cost Increase](https://eips.ethereum.org/EIPS/eip-7883).
"""

MODEXP_GAS_INCREASE_FORK_NAME = "Osaka"
Copy link
Member

Choose a reason for hiding this comment

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

I think we must also test Prague to validate the gas consumption change.

Comment on lines 44 to 45
ret_offset=0,
ret_size=0x80,
Copy link
Member

Choose a reason for hiding this comment

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

This could be left as zero and we can use the RETURNDATA* opcodes instead, because sometimes the call fails and we still compare our expected output against the arguments that were used as inputs.

@pytest.fixture
def gas_measure_contract(pre: Alloc):
"""Deploys a simple contract to call ModExp and store its success."""
# TODO: fix the gas accounting
Copy link
Member

Choose a reason for hiding this comment

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

The tricky part is where to insert the Op.GAS since you also want to store the call return, so you could do Op.GAS + call + Op.GAS and then use swaps to move the stack, subtract the gas measurements, and save into storage.
You can use the traces to see exactly where each value is in the stack when the code runs.

@spencer-tb spencer-tb force-pushed the spencer-tb/tests/eip-7883 branch from 64a691b to f3996c0 Compare May 20, 2025 12:34
@spencer-tb spencer-tb changed the title feat(tests): eip-7883 modexp gas increase cases feat(tests): eip-7883 & eip-7823 modexp cases May 27, 2025
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