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): Identity precompile test #1047

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

Conversation

marioevz
Copy link
Member

🗒️ Description

Adds a test for the identity precompile based on this https://github.com/ethereum/go-ethereum/blob/master/docs/postmortems/2021-08-22-split-postmortem.md

Also adds a new variant that can be filled for EOF EXT*CALL opcodes .

🔗 Related Issues

✅ 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
Copy link
Member Author

@shemnon I was reviewing your memory expansion tests and remembered this case, so decided to add a test that can be filled for the EXT*CALL opcodes in test_identity_return_buffer_modify, let me know what you think.

post = {
contract_address: Account(
storage={
1: keccak256(bytes([1, 2, 3, 4, 4]).ljust(32, b"\0")),
Copy link
Contributor

Choose a reason for hiding this comment

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

can this benefit from leftpadding?

code = (
sum(Op.MSTORE8(offset=i, value=(i + 1)) for i in range(4)) # memory = [1, 2, 3, 4]
+ call_opcode(
address=4,
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we have global space constants for the precompiles?

"""Test the return data of the identity precompile overwriting its input."""
env = Environment()
code = (
sum(Op.MSTORE8(offset=i, value=(i + 1)) for i in range(4)) # memory = [1, 2, 3, 4]
Copy link
Contributor

Choose a reason for hiding this comment

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

if possible I prefer to have concrete looking memory input like
0x000102030405 because when reading the code we will have to stop and calculate or sometimes we don't see what exactly the result of a calculation and when its not obvious we can have a bug and difficulty to find it.

@shemnon
Copy link
Collaborator

shemnon commented Feb 5, 2025

Tests look fine WRT EXTCALL vs CALL. The only twist may be to test for the "corrupted" version in the memory write version when the opcodes are the EOF variants to verify no memory writes occured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants