Platform: Code4rena
Start Date: 08/12/2021
Pot Size: $30,000 ETH
Total HM: 12
Participants: 26
Period: 3 days
Judge: leastwood
Total Solo HM: 9
Id: 65
League: ETH
Rank: 12/26
Findings: 2
Award: $65.95
🌟 Selected for report: 1
🚀 Solo Findings: 0
🌟 Selected for report: 0x0x0x
Also found by: Jujic, pmerkleplant, ye0lde
Jujic
!= 0 is a cheaper operation compared to > 0, when dealing with uint.
#0 - 0xleastwood
2022-03-27T10:26:38Z
Duplicate of #139
🌟 Selected for report: 0x0x0x
Also found by: Jujic, Meta0xNull, WatchPug, pmerkleplant, rishabh
Jujic
Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack. Caching the array length in the stack saves around 3 gas per iteration.
Caching len = weights.length
and using the len
instead will save gas.
#0 - 0xleastwood
2022-03-27T10:28:37Z
Duplicate of #140
11.0559 USDC - $11.06
Jujic
Here you could use unchecked{++i} to save gas since it is more efficient then i++.
#0 - 0xleastwood
2022-03-27T10:29:46Z
Duplicate of #120
🌟 Selected for report: GiveMeTestEther
Also found by: Jujic, TomFrenchBlockchain, WatchPug, gzeon, kenzo, sirhashalot, ye0lde
Jujic
A variable is being assigned its default value which is unnecessary. Removing the assignment will save gas when deploying.
ownerSplit = 0;
Remix
Remove the assignment.
#0 - 0xleastwood
2022-03-27T10:48:52Z
Duplicate of #45
🌟 Selected for report: Jujic
Jujic
contract Basket does not need to import:
import "hardhat/console.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
REmix
Consider reviewing all the unused imports and removing them to reduce the size of the contract and thus save some deployment gas.