Platform: Code4rena
Start Date: 03/05/2022
Pot Size: $30,000 USDC
Total HM: 6
Participants: 93
Period: 3 days
Judge: gzeon
Id: 118
League: ETH
Rank: 10/93
Findings: 3
Award: $1,162.64
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: VAD37
Also found by: AuditsAreUS, IllIllI, MaratCerby, rfa, sorrynotsorry
1116.8018 USDC - $1,116.80
ERC20 standard allows transfer function of some contracts to return bool or return nothing. Using safeTransfer of SafeERC20.sol is recommended instead.
#0 - KenzoAgada
2022-06-06T05:30:44Z
Duplicate of #2.
#1 - gzeoneth
2022-06-18T17:03:38Z
Duplicate of #70
🌟 Selected for report: defsec
Also found by: 0v3rf10w, 0x1f8b, 0x4non, 0x52, 0xDjango, 0xf15ers, 0xkatana, 0xliumin, AuditsAreUS, BowTiedWardens, CertoraInc, Cr4ckM3, Funen, GimelSec, Hawkeye, IllIllI, Kulk0, M0ndoHEHE, MaratCerby, Picodes, Ruhum, TerrierLover, TrungOre, VAD37, WatchPug, berndartmueller, broccolirob, catchup, cccz, cryptphi, csanuragjain, delfin454000, dirk_y, eccentricexit, ellahi, fatherOfBlocks, gzeon, hake, hansfriese, hickuphh3, horsefacts, hubble, hyh, ilan, joestakey, kebabsec, kenta, kenzo, leastwood, m9800, marximimus, minhquanym, oyc_109, p4st13r4, pauliax, pedroais, peritoflores, plotchy, rajatbeladiya, reassor, rfa, robee, rotcivegaf, samruna, shenwilly, shung, simon135, sorrynotsorry, sseefried, teddav, throttle, tintin, unforgiven, z3s
30.3871 USDC - $30.39
uint256 is assigned to zero by default, additional reassignment to zero is unnecessary Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsGuild.sol#L24
https://docs.soliditylang.org/en/v0.8.13/control-structures.html#default-value
Recommended code:
uint256 public numMinted;
uint256 is assigned to zero by default, additional reassignment to zero is unnecessary Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L162
https://docs.soliditylang.org/en/v0.8.13/control-structures.html#default-value
Recommended code:
uint256 i;
uint256 is assigned to zero by default, additional reassignment to zero is unnecessary Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L220
https://docs.soliditylang.org/en/v0.8.13/control-structures.html#default-value
Recommended code:
uint256 i;
uint256 is assigned to zero by default, additional reassignment to zero is unnecessary Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L259
https://docs.soliditylang.org/en/v0.8.13/control-structures.html#default-value
Recommended code:
uint256 i;
Msg.sender will never equal to address(0). Require statement can be safely removed. Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsGuild.sol#L174
string is assigned to '' by default, additional reassignment to '' is unnecessary Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsGuild.sol#L36
https://docs.soliditylang.org/en/v0.8.13/control-structures.html#default-value
Recommended code:
string public METADATA_PROVENANCE_HASH;
Constant R is unused and can be safely removed Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsGuild.sol#L32-L33
Possibility of loosing precision. It is recommended to have a single division. Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsMinter.sol#L284-L285
Recommended code:
uint256 dropPerStep = ((startPrice - lowestPrice) * daDropInterval) / daPriceCurveLength;
Possibility of getting out of bounds in array daMinters. Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsMinter.sol#L284-L285
Additional check is recommended:
require(daMinters.length > endIdx); // equal to daMinters.length >= (endIdx + 1) but using less gas
🌟 Selected for report: BowTiedWardens
Also found by: 0v3rf10w, 0x1f8b, 0x4non, 0xDjango, 0xNazgul, 0xProf, 0xc0ffEE, 0xf15ers, 0xkatana, 0xliumin, ACai, AlleyCat, CertoraInc, Cityscape, Cr4ckM3, DavidGialdi, Dinddle, FSchmoede, Funen, GimelSec, Hawkeye, IllIllI, Kulk0, M0ndoHEHE, MaratCerby, MiloTruck, Picodes, RoiEvenHaim, Tadashi, TerrierLover, TrungOre, VAD37, WatchPug, antonttc, catchup, defsec, delfin454000, dirk_y, eccentricexit, ellahi, fatherOfBlocks, gzeon, hake, hansfriese, hickuphh3, horsefacts, ilan, joestakey, kebabsec, kenta, kenzo, marximimus, minhquanym, noobie, oyc_109, p4st13r4, pauliax, rajatbeladiya, reassor, rfa, robee, rotcivegaf, saian, samruna, shenwilly, shung, simon135, slywaters, sorrynotsorry, throttle, unforgiven, z3s
15.4498 USDC - $15.45
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsGuild.sol#L100
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error AllWarriorsHaveBeenSummoned(); .. if(numMinted >= MAX_WARRIORS) { revert AllWarriorsHaveBeenSummoned(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsGuild.sol#L101
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error NotAMinter(); .. if(_msgSender() != minter) { revert NotAMinter(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L136
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error ActionSoldOut(); .. if(numSold >= maxDaSupply) { revert ActionSoldOut(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L137
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error NotEnoughRemaining(); .. if(numSold + numWarriors > maxDaSupply) { revert NotEnoughRemaining(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L138
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error AuctionNotStarted(); .. if(!daStarted()) { revert AuctionNotStarted(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L139
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error AuctionPhaseOver(); .. if(mintlistStarted()) { revert AuctionPhaseOver(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L177
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error SoldOut(); .. if(numSold >= maxForSale) { revert SoldOut(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L178
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error MintlistPhaseNotStarted(); .. if(!mintlistStarted()) { revert MintlistPhaseNotStarted(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L179
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error EtherValueIncorrect(); .. if(msg.value != finalPrice) { revert EtherValueIncorrect(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L182
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error AlreadyMinted(); .. if(mintlistMinted[msg.sender] != false) { revert AlreadyMinted(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L207
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error SoldOut(); .. if(numSold >= maxForSale) { revert SoldOut(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L208
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error NotEnoughRemaining(); .. if(numSold + numWarriors > maxForSale) { revert NotEnoughRemaining(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L209
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error PublicSaleNotStarted(); .. if(!publicStarted()) { revert PublicSaleNotStarted(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L234
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error NoMoreClaims(); .. if(numClaimed >= maxForClaim) { revert NoMoreClaims(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L235
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error ClaimPhaseNotStarted(); .. if(!claimsStarted()) { revert ClaimPhaseNotStarted(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L238
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error AlreadyClaimed(); .. if(claimlistMinted[msg.sender] != false) { revert AlreadyClaimed(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L258
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error AddressRequired(); .. if(address(recipient) == address(0)) { revert AddressRequired(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L372
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error SelfRefundPeriodNotStarted(); .. if(!selfRefundsStarted()) { revert SelfRefundPeriodNotStarted(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L609
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error NoVault(); .. if(address(vault) == address(0)) { revert NoVault(); }
Recommending to upgrade solidity version to 0.8.4 which introduces new custom errors. Custom errors are reducing 38 gas if condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Affected code: https://github.com/code-423n4/2022-05-runes/tree/main/contracts/ForgottenRunesWarriorsMinter.sol#L617
https://blog.soliditylang.org/2021/04/21/custom-errors/
Recommended code:
error NoVault(); .. if(address(vault) == address(0)) { revert NoVault(); }
Instead of having 5 mappings it is better to use a struct type and a single mapping. It will significantly reduce gas usage while updating the storage. At least 5 x 5000 gas for each unique address. Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsMinter.sol#L75-L88
Solidity 0.8.0 introduced SafeMath enabled by default for any math operation. To improve gas usage unchecked keyword is recommended in for cycle. It reduces 49 gas per each iteration in cycle. Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsMinter.sol#L162-L164
https://docs.soliditylang.org/en/v0.8.13/080-breaking-changes.html#:~:text=Arithmetic%20operations
Saves 49 * numWarriors gas. Recommended code:
for (uint256 i = 0; i < numWarriors;) { _mint(msg.sender); unchecked {i++;} }
Solidity 0.8.0 introduced SafeMath enabled by default for any math operation. To improve gas usage unchecked keyword is recommended in for cycle. It reduces 49 gas per each iteration in cycle. Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsMinter.sol#L220-L222
https://docs.soliditylang.org/en/v0.8.13/080-breaking-changes.html#:~:text=Arithmetic%20operations
Saves 49 * numWarriors gas. Recommended code:
for (uint256 i = 0; i < numWarriors;) { _mint(msg.sender); unchecked {i++;} }
Solidity 0.8.0 introduced SafeMath enabled by default for any math operation. To improve gas usage unchecked keyword is recommended in for cycle. It reduces 49 gas per each iteration in cycle. Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsMinter.sol#L259-L261
https://docs.soliditylang.org/en/v0.8.13/080-breaking-changes.html#:~:text=Arithmetic%20operations
Saves 49 * count gas. Recommended code:
for (uint256 i = 0; i < count;) { _mint(recipient); unchecked {i++;} }
Solidity 0.8.0 introduced SafeMath enabled by default for any math operation. To improve gas usage unchecked keyword is recommended in for cycle. It reduces 49 gas per each iteration in cycle. Affected code: https://github.com/code-423n4/2022-05-runes/blob/060b4f82b79c8308fe65674a39a07c44fa586cd3/contracts/ForgottenRunesWarriorsMinter.sol#L355-L357
https://docs.soliditylang.org/en/v0.8.13/080-breaking-changes.html#:~:text=Arithmetic%20operations
Saves 49 * (endIdx + 1 - startIdx) gas. Recommended code:
for (uint256 i = startIdx; i < endIdx + 1;) { _refundAddress(daMinters[i]); unchecked {i++;} }