-
Notifications
You must be signed in to change notification settings - Fork 323
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
fix: do not store code hash for EOAs #1644
fix: do not store code hash for EOAs #1644
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix empty pointer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TLDR;
- All accounts have a codehash. If that account is an eoa it's simply keccak256("");
- You never want to have a disrepancy between the account's code and it's hash, thus it makes sense to write the code_hash in the same function as the account.
I think there's a small misconception between the code_hash
of an account and the extcodehash
in the way we handled this finding:
- All accounts have a code hash that is
keccak256(bytecode)
. If bytecode is empty, that code hash iskeccak256("")
= EMPTY_CODE_HASH - The finding is valid when saying that account deployed with
deploy_externally_owned_account
would have the wrong codehash
However I don't really agree with the way we handled this; I would rather have:
- Modified
Starknet.deploy
toset_code_hash(EMPTY_CODE_HASH)
(you're deploying a contract that doesn't have any code) - Replaced the
write_bytecode
of the account contract to write the code hash as well.
Overwrite fix to codehash done in #1644 Motivation: I prefer a solution that avoids having invalid states altogether. - All accounts have a code_hash set to keccak256("") when deployed - Any modification to the account's code will also modify it's code_hash - extcodehash simply check the account_exists = has_code_or_nonce or has_balance condition to know whether to return 0 or code_hash which is more inline with the spec. The `codehash` of an account is _never_ zero, the `extcodehash` is.
Time spent on this PR:
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Resolves #
What is the new behavior?
Code hash for eoa cannot be stored as they can change. Put the logic of 0 or empty code hash in function.