Platform: Code4rena
Start Date: 27/05/2022
Pot Size: $75,000 USDC
Total HM: 20
Participants: 58
Period: 7 days
Judge: GalloDaSballo
Total Solo HM: 15
Id: 131
League: ETH
Rank: 30/58
Findings: 2
Award: $171.81
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x29A, 0xNazgul, 0xf15ers, BowTiedWardens, Chom, Funen, Kaiziron, Kumpa, MiloTruck, Picodes, Ruhum, SecureZeroX, Sm4rty, SmartSek, StyxRave, WatchPug, Waze, asutorufos, bardamu, berndartmueller, c3phas, catchup, cccz, codexploder, cryptphi, defsec, delfin454000, dipp, fatherOfBlocks, gzeon, hake, hansfriese, hyh, masterchief, oyc_109, sach1r0, sashik_eth, shenwilly, simon135, unforgiven
113.8755 USDC - $113.88
Severity: Low
Context: VestedEscrow.sol#L64-L72
, VestedEscrow.sol#L74-L78
Description: Setter functions are missing checks to validate if the new value being set is the same as the current value already set in the contract. Such checks will showcase mismatches between on-chain and off-chain states.
Recommendation: Add in the additional checks to validate if the new value being set is the same as the current value already set in the contract.
Severity: Low
Context: Controller.sol#L62-L76
Description: None of the onlyOwner functions that change critical protocol addresses/parameters appear to have a time lock for a time-delayed change to alert: (1) users and give them a chance to engage/exit protocol if they are not agreeable to the changes (2) team in case of compromised owner(s) and given them a chance to perform incident response.
Recommendation: Add a time lock to these functions for a time-delayed change to alert users and protect against possiable malicious changes by compromised owners(s).
Severity: Low
Context: Controller.sol#L33-L37
, StakerVault.sol#L98-L102
, StakerVault.sol#L197-L210
, StakerVault.sol#L218-L235
, AmmGauge.sol#L49-L54
, InflationManager.sol#L58-L63
, InflationManager.sol#L435-L438
, InflationManager.sol#L446-L467
, InflationManager.sol#L482-L489
, KeeperGauge.sol#L57-L62
, Minter.sol#L99-L102
, Minter.sol#L104-L108
, VestedEscrow.sol#L64-L72
, VestedEscrow.sol#L74-L78
Description: Several functions update critical parameters that are missing event emission. These should be performed to ensure tracking of changes of such critical parameters.
Recommendation: Add events to functions that change critical parameters.
Severity: Low
Context: RewardHandler.sol#L62-L65
Description: Giving max/infinite approvals to contracts are dangerous. Giving max/infinite approvals to contracts are dangerous because if those contracts are exploited then they can remove all the funds from the approving addresses.
Recommendation Check allowance and approve as much as required.
Severity: Informational
Context: InflationManager.sol#L532
Description: There should never be any TODOs in the code when deploying.
Recommendation: Finish the TODOs before deploying.
Severity: Informational
Context: BkdLocker.sol#L173 (invlude => include)
, FeeBurner.sol#L29 (successfull => successful)
, FeeBurner.sol#L29 (Emmited => Emitted)
, FeeBurner.sol#L35 (Recieve => Receive)
, FeeBurner.sol#L84 (Transfering => Transferring)
Description: Spelling errors in comments can cause confusion to both users and developers.
Recommendation: Check all misspellings to ensure they are corrected.
Severity: Informational
Context: All Contracts
Description: Some functions are missing @notice/@dev NatSpec comments for the function, @param for all/some of their parameters and @return for return values. Given that NatSpec is an important part of code documentation, this affects code comprehension, auditability and usability.
Recommendation: Add in full NatSpec comments for all functions to have complete code documentation for future use.
#0 - GalloDaSballo
2022-06-19T22:54:37Z
Not sure if this should be gas as it would increase cost of operations, personally am ambivalent on implementing and would consider non-critical
Disagree as you cannot prove the presence or absence of timelock, if anything you could recommend using it, and yet no proof would be in the code, making the finding unactionable
Disagree with the alarmism, agree with the informational finding
Valid but not actionable in lack of an alternative
Valid non-critical finding
I'm very confident you're not supposed to always mark every variable as sometimes the best comment is the one you don't write.
Personally the report feels really cookie cutter, perhaps automated
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x29A, 0xKitsune, 0xNazgul, 0xf15ers, 0xkatana, Chom, Dravee, Fitraldys, Funen, Kaiziron, MiloTruck, Picodes, Randyyy, RoiEvenHaim, SecureZeroX, Sm4rty, SmartSek, StyxRave, Tadashi, Tomio, Waze, asutorufos, berndartmueller, c3phas, catchup, csanuragjain, defsec, delfin454000, djxploit, fatherOfBlocks, gzeon, hake, hansfriese, oyc_109, robee, sach1r0, sashik_eth, scaraven, simon135
57.93 USDC - $57.93
Context: RoleManager.sol#L75-L88
, RewardHandler.sol#L35-L55
, StakerVault.sol#L256-L263
, FeeBurner.sol#L43-L88
, InflationManager.sol#L110-L125 (For L116)
, VestedEscrow.sol#L89-L111
, PoolMigrationZap.sol#L20-L29
, PoolMigrationZap.sol#L38-L45
Description: One can save gas by caching the array length (in stack) and using that set variable in the loop. Replace state variable reads and writes within loops with local variable reads and writes. This is done by assigning state variable values to new local variables, reading and/or writing the local variables in a loop, then after the loop assigning any changed local variables to their equivalent state variables.
Recommendation:
Simply do something like so before the for loop: uint length = variable.length
. Then add length
in place of variable.length
in the for loop.
require()
, Use != 0
Instead of > 0
With Uint ValuesContext: BkdLocker.sol#L90-L100 (For both)
, BkdLocker.sol#L133-L155 (For L137)
, AmmGauge.sol#L103-L116 (For L104)
, AmmGauge.sol#L124-L138 (For L125)
, KeeperGauge.sol#L125-L144 (For L140)
, VestedEscrow.sol#L80-L87 (For L84)
Description:
In a require, when checking a uint, using != 0
instead of > 0
saves 6 gas. This will jump over or avoid an extra ISZERO
opcode.
Recommendation:
Use != 0
instead of > 0
with uint values but only in require()
statements.
Context: All Contracts
Description:
You can cut out 10 opcodes in the creation-time EVM bytecode if you declare a constructor payable. Making the constructor payable eliminates the need for an initial check of msg.value == 0
and saves 21 gas on deployment with no security risks.
Recommendation: Set the constructor to payable.
Context: All Contracts
Description:
Contracts most called functions could simply save gas by function ordering via Method ID. Calling a function at runtime will be cheaper if the function is positioned earlier in the order (has a relatively lower Method ID) because 22 gas are added to the cost of a function for every position that came before it. The caller can save on gas if you prioritize most called functions. One could use This tool
to help find alternative function names with lower Method IDs while keeping the original name intact.
Recommendation:
Find a lower method ID name for the most called functions for example mostCalled()
vs. mostCalled_41q()
is cheaper by 44 gas.
#0 - GalloDaSballo
2022-06-16T20:57:09Z
Would save 3 gas (offset check)
3 * 8 = 24
Valid for solidity below 0.8.13, saves 3 gas
3 * 7 = 21
Appreciate the finding but because it's a one-off gas saving will not include in scoring
I really like this finding, had the warden spent the extra time to submit each optimized function they would have made a killing
Total Gas Saved: 45