-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Post-constantinople, we should use extcodehash instead of extcodesize #4834
Comments
@chriseth , is it as simple as replacing |
Yes, it is very simple, but I think we should wait until constantinople is finalized. |
In theory it can be implemented under the |
Bump! This may reduce all calls to external contracts by ~300 GAS, because currently after each call the address is checked using extcodesize, which uses 700 GAS, and extcodehash uses only 400 GAS.
It should also be checked that the result of extcodehash is not |
@Agusx1211 thanks for bringing this up again! Note that the constant |
If we want to avoid providing the constant literally, we could use |
This was an obvious pricing mistake and it is rectified by EIP-1884 in the upcoming Istanbul update. |
Oh wow, I thought |
Good point though that size is not stored, size should cost more :) But the issue was balance and codehash should cost equal because both are stored in the account. |
So does that mean we can now close this? |
Unless |
Does solidity provide a global for determining if a contract exists or is this assembly technique still best approach? uint256 codeSize;
assembly { codeSize := extcodesize(0x123...) }
bool exists = codeSize > 0; |
It is the best approach. |
Once constantinople is finalized, we should use extcodehash instead of extcodesize to check if the called account exists, because it is cheaper.
The text was updated successfully, but these errors were encountered: