Platform: Code4rena
Start Date: 22/08/2022
Pot Size: $50,000 USDC
Total HM: 4
Participants: 160
Period: 5 days
Judge: gzeon
Total Solo HM: 2
Id: 155
League: ETH
Rank: 149/160
Findings: 1
Award: $16.66
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x040, 0x1f8b, 0xDjango, 0xNazgul, 0xNineDec, 0xSmartContract, 0xbepresent, 0xc0ffEE, 0xkatana, 2997ms, ACai, Amithuddar, Aymen0909, Ben, BipinSah, Bjorn_bug, Bnke0x0, CertoraInc, Ch_301, Chom, CodingNameKiki, Deivitto, DevABDee, DimitarDimitrov, Diraco, Dravee, ElKu, EthLedger, Fitraldys, Funen, GalloDaSballo, GimelSec, Guardian, IgnacioB, JC, JohnSmith, Junnon, KIntern_NA, Lambda, LeoS, Noah3o6, Olivierdem, Polandia94, R2, Randyyy, RaymondFam, Respx, ReyAdmirado, Rohan16, RoiEvenHaim, Rolezn, Ruhum, SaharAP, Saintcode_, SerMyVillage, Shishigami, Sm4rty, SooYa, TomJ, Tomio, Tomo, Waze, Yiko, _Adam, __141345__, a12jmx, ajtra, ak1, bobirichman, brgltd, bulej93, c3phas, cRat1st0s, carlitox477, catchup, ch0bu, d3e4, delfin454000, djxploit, durianSausage, erictee, exolorkistis, fatherOfBlocks, francoHacker, gogo, hyh, ignacio, jag, joestakey, karanctf, ladboy233, lucacez, lukris02, m_Rassska, martin, medikko, mics, mrpathfindr, natzuu, newfork01, oyc_109, pauliax, peritoflores, pfapostol, prasantgupta52, rbserver, ret2basic, rfa, robee, rokinot, rotcivegaf, rvierdiiev, sach1r0, saian, samruna, seyni, shark, shr1ftyy, sikorico, simon135, sryysryy, tay054, tnevler, wagmi, zishansami
16.6573 USDC - $16.66
Uint variable's default value is zero. So, you can save gas by just defining uint variables.
You can just define uint32 lower
without initializing it to zero. Also, there are many for
loops in NounsDAOLogicV2
and NounsDAOLogicV1
contracts that you can just define uint256 i
without initializing it.
Use unchecked blocks for arithmetic operations that can't underflow/overflow.
You can put ++i
or i++
in for loops in an unchecked block.
!= 0 is a cheaper operation compared to > 0, when dealing with uint. > 0 can be replaced with != 0 for gas optimization.
castRefundableVoteInternal()
_writeQuorumParamsCheckpoint()
getCurrentVotes()
_moveDelegates()
_moveDelegates()
_moveDelegates()
_writeCheckpoint()
Replace > 0 with != 0 when comparing unsigned integer variables to save gas.
require()
statements with revert strings.Using custom errors can save gas instead of using string errors.
initialize()
propose()
tokenOfOwnerByIndex
tokenByIndex
Internal functions used once can be written inline to save gas.
safe32()
safe96()
add96()
sub96()
getChainId()
getChainIdInternal()
queueOrRevertInternal()
_refundGas()
Write safe32()
, safe96()
, add96()
, sub96
and getChainId()
functions inside their calling functions.
targets.length
is read multiple times, especially in loops, you should cache it in a memory variable to save gas.
propose()
queue()
execute()
cancel()
veto()
Store targets.length
in a memory variable to save gas.
Public functions that are never called from within the contracts should be declared external to save gas.
Change delegate()
function visiblity from public to external.