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

modify rpcStataManager getAccount #3345

Merged
merged 6 commits into from
Apr 12, 2024
Merged

Conversation

rodrigoherrerai
Copy link
Contributor

When getting an account from the provider that has never been touched, the returned codeHash is not keccak(""), but just empty bytes (0...0). Therefore, the getAccount function will not return "undefined" but an account with empty bytes.

This creates a problem in some edge cases. For example, when forking a network and creating a contract within a contract, the evm will revert with collision error, due to this implementation.

Copy link

codecov bot commented Apr 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.06%. Comparing base (4be68d2) to head (608830d).
Report is 4 commits behind head on master.

❗ Current head 608830d differs from pull request most recent head fab52c9. Consider uploading reports for the commit fab52c9 to get more accurate results

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 82.24% <ø> (ø)
blockchain 90.92% <ø> (ø)
client ?
common 94.02% <ø> (ø)
devp2p 81.36% <ø> (ø)
evm 73.30% <ø> (ø)
genesis 99.98% <ø> (ø)
statemanager 74.72% <100.00%> (+<0.01%) ⬆️
trie 59.62% <ø> (+0.02%) ⬆️
tx 85.70% <ø> (ø)
util 81.32% <ø> (ø)
vm 61.56% <ø> (ø)
wallet 87.25% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@acolytec3
Copy link
Contributor

I have verified that this resolves the issue with non-existent accounts returned by a remote RPC (which do indeed seem to return a string of 0s for the codeHash and storageHash values. Does anyone else on the team have any hesitations about this approach to resolving this?

@scorbajio
Copy link
Contributor

scorbajio commented Apr 11, 2024

Would be useful to capture some data and add a unit test.

@acolytec3
Copy link
Contributor

Would be useful to capture some data and add a unit test.

This should already be covered in the existing tests. I've also updated our mockProvider to return a response that mirrors the Infura API response to getProof for non-existent accounts.

@acolytec3
Copy link
Contributor

Have also updated the check of the codeHash field to compare the underlying bytes instead of .every(... notation per some internal discussion.

Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the PR.

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

Successfully merging this pull request may close these issues.

4 participants