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

refactor(fw,tests): fix address and hash types #422

Merged
merged 8 commits into from
Feb 1, 2024

Conversation

marioevz
Copy link
Member

@marioevz marioevz commented Jan 31, 2024

🗒️ Description

  • Creates the common/base_types.py file, which includes basic types other complex types use, such as Address, Hash, and other types that do not have any other dependency.
  • Completely removes to_address, to_hash and to_hash_bytes in favor of using the Address and Hash classes directly.
  • Adds Address to the list of types an Op callable can receive, and, instead of treating the Address as bytecode, it automatically detects the type and adds the appropriate Op.PUSH20.
  • FixedSizeBytes types can now be compared to strings and integers
  • Removes Op.PUSH20 across all tests when an Address type is used as a parameter of an Op.

Nice thing about this change is that it produces zero fixture changes, and slightly reduces lines of code.

TODO: Update docs.

🔗 Related Issues

Fixes #387

✅ 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: 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 scope:tests Scope: Test cases type:chore Type: Chore type:refactor Type: Refactor scope:fw Scope: Framework (evm|tools|forks|pytest) labels Jan 31, 2024
Copy link
Collaborator

@spencer-tb spencer-tb left a comment

Choose a reason for hiding this comment

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

LGTM! Had another look locally to see if I could find anything else, got matching fixtures too :D

src/ethereum_test_tools/common/constants.py Show resolved Hide resolved
@spencer-tb spencer-tb changed the title Fix to address refactor(fw,tests): fix address and hash types Feb 1, 2024
@spencer-tb
Copy link
Collaborator

Not sure what docs should be added, the only thing I can think of adding the usage of the Address type when initializing accounts, within pre & post states etc here:
https://github.com/ethereum/execution-spec-tests/blob/main/docs/writing_tests/writing_a_new_test.md?plain=1#L103-L206

This PR got me thinking: I wonder if we should force all addresses to be of the Address type, pre and post to be Alloc types, and storage to be Storage. If we check for this when filling, it might catch some an unintentional additions.

Copy link
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

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

Really welcome tidy-up to our types, makes much more sense. And also nice to move these to base_types.py.

Agree with Spencer, not sure what we could add to the docs here.

@marioevz
Copy link
Member Author

marioevz commented Feb 1, 2024

Really welcome tidy-up to our types, makes much more sense. And also nice to move these to base_types.py.

Agree with Spencer, not sure what we could add to the docs here.

I think we could search for to_address usages and remove them.

Just verified and there aren't any.

@marioevz marioevz merged commit 6239499 into ethereum:main Feb 1, 2024
5 checks passed
@marioevz marioevz deleted the fix-to-address branch February 1, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:fw Scope: Framework (evm|tools|forks|pytest) scope:tests Scope: Test cases type:chore Type: Chore type:refactor Type: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: Automatically handle Address types on Opcode calls (PUSH20)
3 participants