Platform: Code4rena
Start Date: 15/10/2021
Pot Size: $35,000 USDC
Total HM: 4
Participants: 10
Period: 4 days
Judge: GalloDaSballo
Total Solo HM: 2
Id: 38
League: ETH
Rank: 6/10
Findings: 1
Award: $139.65
🌟 Selected for report: 2
🚀 Solo Findings: 0
🌟 Selected for report: ye0lde
61.5157 USDC - $61.52
ye0lde
A variable is being assigned its default value which is unnecessary. Removing the assignment will save gas when deploying.
Visual Studio Code, Remix
Remove the assignment.
#0 - Ivshti
2021-10-19T16:00:51Z
#1 - GalloDaSballo
2021-10-24T23:06:40Z
Removing the assignment will indeed reduce deployment gas cost
The sponsor has applied the improvement
16.6093 USDC - $16.61
ye0lde
Redundant arithmetic underflow/overflow checks can be avoided when an underflow/overflow cannot happen.
The "unchecked" keyword can be applied here since there is a "require" statement before to ensure the arithmetic operations would not cause an integer underflow or overflow. https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/libs/SignatureValidatorV2.sol#L54-L58
Change the code at 57,58 to: <code> IERC1271Wallet wallet; unchecked { wallet = IERC1271Wallet(address(uint160(uint256(sig.readBytes32(sig.length - 33))))); sig.trimToSize(sig.length - 33); } </code>
A similar change can be made here: https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/libs/SignatureValidatorV2.sol#L31-L32
Visual Studio Code, Remix
Add the "unchecked" keyword as shown above.
#0 - Ivshti
2021-10-21T16:42:07Z
#1 - GalloDaSballo
2021-10-24T22:34:40Z
Duplicate of #46
🌟 Selected for report: ye0lde
61.5157 USDC - $61.52
ye0lde
Shortening revert strings to fit in 32 bytes will decrease deploy time gas and will decrease runtime gas when the revert condition has been met.
Revert strings that are longer than 32 bytes require at least one additional mstore, along with additional overhead for computing memory offset, etc.
Revert strings > 32 bytes are here: https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/libs/SignatureValidatorV2.sol#L33 https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/libs/SignatureValidatorV2.sol#L55 https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/libs/SignatureValidatorV2.sol#L59 https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/libs/SignatureValidatorV2.sol#L64 https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/libs/SignatureValidatorV2.sol#L65
Visual Studio Code, Remix
Shorten the revert strings to fit in 32 bytes.
#0 - Ivshti
2021-10-20T18:48:14Z
#1 - GalloDaSballo
2021-10-24T23:05:22Z
Agree with the finding, brownie handles this via // dev
comments, not sure if hardhat provides a similar alternative (that costs 0)
#2 - GalloDaSballo
2021-10-24T23:05:36Z
The sponsor has applied the improvement by using shorter strings