-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Deprecate variable argument mode of keccak256/sha256/ripemd160 #3955
Comments
A deprecation warning could be added which suggest to use |
This should also include |
Result of discussion: Add a warning for hash functions, and do the rest (including call*) with 0.5.0 proper. |
Related: #3789 |
Hi guys! I have noticed that there is a difference between versions 0.4.23 and 0.4.24 in how code for keccak256(abi.encodePacked(...)) is generated. In version 0.4.23, the memory segment which is result of abi.encodePacked is passed directly to keccak256, but in 0.4.24, an extra loop is generated, to create another copy of the same byte string in memory, before passing it to keccak256(). Both behaviours are equivalent, it is just 0.4.24 generates more code and spends more gas. Was it interntional? |
@AlexeyAkhunov are you sure this is really the case or are you comparing |
@chriseth This was specifically the line I was looking at: https://github.com/gnosis/safe-contracts/blob/76b70e83151530fa5d72d45f937abed8294be01a/contracts/GnosisSafePersonalEdition.sol#L152 I tried to do "solc --asm" (without optimiser) with 0.4.23 and 0.4.24, and there was an extra loop generated with 0.4.24. I will double-check again |
@chriseth I am going to make a very small 1-line example and confirm if it occurs there |
@chriseth I made a small example, and the loop is generated in both versions. I must have missed it somehow the first time. Sorry for trouble |
@chriseth I was indeed looking at the version which did not have abi.encodePacked() function earlier. Mystery is solved |
Right now these functions accept a variable number of arguments and produce a tight packed version.
Some warnings are already displayed for tight packing literals. #982 proposes to turn those warnings into errors.
The new
abi.encode*()
methods offer a replacement to perform packing, which then can be passed to all these hashing functions.Proposal is to raise a warning now when these hashing functions receive multiple arguments or the first and only argument isn't of
bytes
type.The text was updated successfully, but these errors were encountered: