Skip to content
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

new(tests): Add generic precompile-absence test #1036

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

Conversation

marioevz
Copy link
Member

@marioevz marioevz commented Dec 19, 2024

🗒️ Description

Adds a simple test that, starting from Byzantium, calls all addresses less than or equal to 0x101 with:

  • zero calldata
  • 31 bytes of calldata
  • 32 bytes of calldata

and expects success from every call.

Normally if a pre-compile is present in the address, it should return failure if the size is not what it expects, so in this test we use three different sizes to try to ensure that at least one of them is an invalid size to a would-be accidentally-active pre-compile in one of these addresses.

We also check the RETURNDATASIZE to be zero.

🔗 Related Issues

ethereum/EIPs#8945

✅ 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.
  • Tests: All converted JSON/YML tests from ethereum/tests have been added to converted-ethereum-tests.txt.
  • Tests: A PR with removal of converted JSON/YML tests from ethereum/tests have been opened.
  • Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

@marioevz marioevz added the scope:tests Scope: Test cases label Dec 19, 2024
@marioevz marioevz requested a review from winsvega December 19, 2024 16:45
Copy link
Collaborator

@winsvega winsvega left a comment

Choose a reason for hiding this comment

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

But the call return 1 in either case if you call defined or undefined precompile?

@winsvega
Copy link
Collaborator

I sent random bytes data to precompiles with the call. And if it's a precompile it consumes more gas than a call to empty account

@marioevz marioevz force-pushed the no-precompile-addresses-check-test branch from 40c21a6 to c192cd2 Compare December 19, 2024 18:30
@marioevz
Copy link
Member Author

@winsvega I changed the call to have zero gas, so it will undoubtedly fail in case there's a precompile where it should not. It worked great.

I checked by removing the BLS precompiles in the EEST's forks definitions but not in EELS, and this test failed as expected.

@winsvega
Copy link
Collaborator

Ah yes, can restrict the gas, I shall go an correct my test )

@marioevz marioevz requested a review from winsvega December 23, 2024 13:12
@marioevz marioevz force-pushed the no-precompile-addresses-check-test branch from d15b12d to e5d05c8 Compare December 27, 2024 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:tests Scope: Test cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants