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

add unit tests for is_empty method for Account #6265

Merged
merged 2 commits into from
Jan 29, 2024

Conversation

tcoratger
Copy link
Contributor

@tcoratger tcoratger commented Jan 28, 2024

Description

This pull request introduces improvements inspired by the Ethereum execution specification:

  • Introduces a Lazy pub static EMPTY_ACCOUNT, initialized on first access, which is now utilized in the is_empty method for more efficient account emptiness checks.
  • Unit tests have been added to validate the correctness and functionality of the enhanced is_empty method.

These changes enhance the codebase by optimizing account emptiness checks and providing thorough test coverage.

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

I don't think this is correct, because now the bytecode_hash field must be Some for is_empty to return true. this is likely why the is_empty function is not just a comparison with a const value in the first place.

@tcoratger
Copy link
Contributor Author

I don't think this is correct, because now the bytecode_hash field must be Some for is_empty to return true. this is likely why the is_empty function is not just a comparison with a const value in the first place.

@Rjected My bad, I had forgotten this case. I just fixed it, if you agree I think we can merge this because I put the unit tests to cover these two cases of hash None and KECCAK_EMPTY to no longer cause this confusion.

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

I don't think this is correct, because now the bytecode_hash field must be Some for is_empty to return true. this is likely why the is_empty function is not just a comparison with a const value in the first place.

@Rjected My bad, I had forgotten this case. I just fixed it, if you agree I think we can merge this because I put the unit tests to cover these two cases of hash None and KECCAK_EMPTY to no longer cause this confusion.

good idea to add tests, thanks!

@tcoratger tcoratger changed the title add a Lazy EMPTY_ACCOUNT as pub static add unit tests for is_empty method for Account Jan 29, 2024
@Rjected Rjected added this pull request to the merge queue Jan 29, 2024
Merged via the queue into paradigmxyz:main with commit 7ad81d5 Jan 29, 2024
28 checks passed
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.

2 participants