Platform: Code4rena
Start Date: 12/09/2022
Pot Size: $75,000 USDC
Total HM: 19
Participants: 110
Period: 7 days
Judge: HardlyDifficult
Total Solo HM: 9
Id: 160
League: ETH
Rank: 87/110
Findings: 1
Award: $35.48
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: CertoraInc
Also found by: 0x1f8b, 0x4non, 0x5rings, 0x85102, 0xNazgul, 0xSmartContract, 0xkatana, Amithuddar, Aymen0909, B2, Bnke0x0, CRYP70, Chom, ChristianKuri, CodingNameKiki, Deivitto, Diraco, Fitraldys, Funen, IgnacioB, JAGADESH, JC, Lambda, LeoS, Matin, Metatron, MiloTruck, Noah3o6, Ocean_Sky, Olivierdem, PaludoX0, RaymondFam, ReyAdmirado, Rohan16, Rolezn, Saintcode_, Sm4rty, SnowMan, StevenL, Tomio, Tomo, V_B, Waze, __141345__, ajtra, asutorufos, aysha, brgltd, bulej93, c3phas, ch0bu, d3e4, delfin454000, dharma09, djxploit, erictee, fatherOfBlocks, francoHacker, gianganhnguyen, gogo, got_targ, ignacio, jag, karanctf, ladboy233, leosathya, lukris02, m_Rassska, malinariy, martin, natzuu, pashov, peanuts, peiw, pfapostol, prasantgupta52, robee, simon135, slowmoses, sryysryy, tnevler
35.4847 USDC - $35.48
Caching the array length outside a loop saves reading it on each iteration, as long as the array's length is not changed during the loop. There are 12 instances of this issue
contracts/crowdfund/CollectionBuyCrowdfund.sol::62 => for (uint256 i; i < hosts.length; i++) { contracts/crowdfund/Crowdfund.sol::180 => for (uint256 i = 0; i < contributors.length; ++i) { contracts/crowdfund/Crowdfund.sol::300 => for (uint256 i = 0; i < preciousTokens.length; ++i) { contracts/distribution/TokenDistributor.sol::230 => for (uint256 i = 0; i < infos.length; ++i) { contracts/distribution/TokenDistributor.sol::239 => for (uint256 i = 0; i < infos.length; ++i) { contracts/party/PartyGovernance.sol::306 => for (uint256 i=0; i < opts.hosts.length; ++i) { contracts/proposals/ArbitraryCallsProposal.sol::52 => for (uint256 i = 0; i < hadPreciouses.length; ++i) { contracts/proposals/ArbitraryCallsProposal.sol::61 => for (uint256 i = 0; i < calls.length; ++i) { contracts/proposals/ArbitraryCallsProposal.sol::78 => for (uint256 i = 0; i < hadPreciouses.length; ++i) { contracts/proposals/LibProposal.sol::14 => for (uint256 i = 0; i < preciousTokens.length; ++i) { contracts/proposals/LibProposal.sol::32 => for (uint256 i = 0; i < preciousTokens.length; ++i) { contracts/proposals/ListOnOpenseaProposal.sol::291 => for (uint256 i = 0; i < fees.length; ++i) {
 Â
++I
 COSTS LESS GAS THAN I++
, ESPECIALLY WHEN IT’S USED IN FOR
-LOOPS (--I
/I--
 TOO)There is 1 instance of this issue
contracts/crowdfund/CollectionBuyCrowdfund.sol::62 => Â Â Â Â for (uint256 i; i < hosts.length; i++) {
 Â
<X> -= <Y>
COSTS MORE GAS THANÂ <X> = <X> - <Y>
 FOR STATE VARIABLESThere is 1 instance of this issue
contracts/distribution/TokenDistributor.sol 381:Â Â Â Â _storedBalances[balanceId] -= amount;
 Â
Uninitialized variables are assigned with the types default value. Explicitly initializing a variable with it's default value costs unnecesary gas. There are 14 instances of this issue
contracts/crowdfund/Crowdfund.sol::180 => for (uint256 i = 0; i < contributors.length; ++i) { contracts/crowdfund/Crowdfund.sol::242 => for (uint256 i = 0; i < numContributions; ++i) { contracts/crowdfund/Crowdfund.sol::300 => for (uint256 i = 0; i < preciousTokens.length; ++i) { contracts/crowdfund/Crowdfund.sol::348 => for (uint256 i = 0; i < numContributions; ++i) { contracts/distribution/TokenDistributor.sol::230 => for (uint256 i = 0; i < infos.length; ++i) { contracts/distribution/TokenDistributor.sol::239 => for (uint256 i = 0; i < infos.length; ++i) { contracts/party/PartyGovernance.sol::306 => for (uint256 i=0; i < opts.hosts.length; ++i) { contracts/party/PartyGovernance.sol::432 => uint256 low = 0; contracts/proposals/ArbitraryCallsProposal.sol::52 => for (uint256 i = 0; i < hadPreciouses.length; ++i) { contracts/proposals/ArbitraryCallsProposal.sol::61 => for (uint256 i = 0; i < calls.length; ++i) { contracts/proposals/ArbitraryCallsProposal.sol::78 => for (uint256 i = 0; i < hadPreciouses.length; ++i) { contracts/proposals/LibProposal.sol::14 => for (uint256 i = 0; i < preciousTokens.length; ++i) { contracts/proposals/LibProposal.sol::32 => for (uint256 i = 0; i < preciousTokens.length; ++i) { contracts/proposals/ListOnOpenseaProposal.sol::291 => for (uint256 i = 0; i < fees.length; ++i) {
 Â
When dealing with unsigned integer types, comparisons with != 0 are cheaper then with > 0. This change saves 6 gas per instance There are 2 instances of this issue
contracts/crowdfund/Crowdfund.sol::144 => if (initialBalance > 0) { contracts/crowdfund/Crowdfund.sol::471 => if (votingPower > 0) {
 Â
There are 5 instances of this issue
contracts/crowdfund/Crowdfund.sol 106:Â Â bool private _splitRecipientHasBurned; contracts/distribution/TokenDistributor.sol 28:Â Â Â Â bool wasFeeClaimed; 30:Â Â Â Â mapping(uint256 => bool) hasPartyTokenClaimed; 62:Â Â bool public emergencyActionsDisabled; contracts/globals/Global.sol 12:Â Â mapping(uint256 => mapping(bytes32 => bool)) private _includedWordValues; contracts/party/PartyGovernance.sol 108:Â Â Â Â bool isDelegated; 197:Â Â bool public emergencyExecuteDisabled; 207:Â Â mapping(address => bool) public isHost; contracts/vendor/markets/IZoraAuctionHouse.sol 15:Â Â Â Â bool approved;
 Â
ABI.ENCODE()
 IS LESS EFFICIENT THAN ABI.ENCODEPACKED()
There are 4 instances of this issue
contracts/proposals/ListOnOpenseaProposal.sol 164:Â Â Â Â Â Â Â Â Â Â return abi.encode(ListOnOpenseaStep.ListedOnZora, ZoraProgressData({ 219:Â Â Â Â Â Â return abi.encode(ListOnOpenseaStep.ListedOnOpenSea, orderHash, expiry); contracts/proposals/ListOnZoraProposal.sol 115:Â Â Â Â Â Â return abi.encode(ZoraStep.ListedOnZora, ZoraProgressData({ contracts/utils/ReadOnlyDelegateCall.sol 23:Â Â Â Â abi.encode(s, r).rawRevert();
 Â
There is 1 instance of this issue
contracts/party/PartyGovernance.sol::434 => uint256 mid = (low + high) / 2;
 Â
ADDRESS
 MAPPINGS CAN BE COMBINED INTO A SINGLE MAPPING
 OF AN ADDRESS
 TO A STRUCT
, WHERE APPROPRIATEThere are 6 instances of this issue
contracts/crowdfund/Crowdfund.sol 112:Â Â mapping(address => address) public delegationsByContributor; 115:Â Â mapping (address => Contribution[]) private _contributionsByContributor; contracts/party/PartyGovernance.sol 148:Â Â Â Â mapping (address => bool) hasVoted; 207:Â Â mapping(address => bool) public isHost; 209:Â Â mapping(address => address) public delegationsByVoter; 215:Â Â mapping(address => VotingPowerSnapshot[]) private _votingPowerSnapshotsByVoter;