Platform: Code4rena
Start Date: 07/08/2023
Pot Size: $36,500 USDC
Total HM: 11
Participants: 125
Period: 3 days
Judge: alcueca
Total Solo HM: 4
Id: 274
League: ETH
Rank: 119/125
Findings: 1
Award: $4.23
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: RED-LOTUS-REACH
Also found by: 0x3b, 0x4non, 0xCiphky, 0xDING99YA, 0xDetermination, 0xE1, 0xG0P1, 0xStalin, 0xWaitress, 0xbrett8571, 0xhacksmithh, 0xkazim, 0xmuxyz, 0xweb3boy, 14si2o_Flint, AlexCzm, Alhakista, Bube, Bughunter101, Deekshith99, Eeyore, Giorgio, HChang26, InAllHonesty, JP_Courses, KmanOfficial, MatricksDeCoder, Mike_Bello90, MrPotatoMagic, Naubit, QiuhaoLi, RHaO-sec, Raihan, Rolezn, SUPERMAN_I4G, Shubham, Silverskrrrt, Strausses, T1MOH, Topmark, Tripathi, Watermelon, _eperezok, aakansha, auditsea, audityourcontracts, ayden, carlos__alegre, castle_chain, cducrest, ch0bu, d23e, deadrxsezzz, deth, devival, erebus, fatherOfBlocks, halden, hassan-truscova, hpsb, hunter_w3b, imkapadia, immeas, jat, kaden, kaveyjoe, klau5, koxuan, kutugu, ladboy233, lanrebayode77, leasowillow, lsaudit, markus_ether, matrix_0wl, merlin, nemveer, ni8mare, nonseodion, oakcobalt, owadez, p_crypt0, pipidu83, piyushshukla, popular00, ppetrov, rjs, sandy, sl1, supervrijdag, tay054, thekmj, wahedtalash77, windhustler, zhaojie
4.2289 USDC - $4.23
https://github.com/code-423n4/2023-08-verwa/blob/a693b4db05b9e202816346a6f9cada94f28a2698/src/VotingEscrow.sol#L185-L218 https://github.com/code-423n4/2023-08-verwa/blob/a693b4db05b9e202816346a6f9cada94f28a2698/src/GaugeController.sol#L69-L83 https://github.com/code-423n4/2023-08-verwa/blob/a693b4db05b9e202816346a6f9cada94f28a2698/src/GaugeController.sol#L95-L109 https://github.com/code-423n4/2023-08-verwa/blob/a693b4db05b9e202816346a6f9cada94f28a2698/src/GaugeController.sol#L247-L249
VotingEscrow.sol
and GaugeController.sol
rely on several loops that can loop for hundred of times while being costly in terms of gas consumption.
for (uint256 i = 0; i < 255; i++) {
for (uint256 i; i < 500; ++i) {
These loops are executed on every interaction with each of the smart contracts.
Moreover in GaugeController.sol
there are two calls to two different loops in the same function vote_for_gauge_weights
.
uint256 old_weight_bias = _get_weight(_gauge_addr); uint256 old_weight_slope = points_weight[_gauge_addr][next_time].slope; uint256 old_sum_bias = _get_sum();
In one single function call the smart contract is expected to iterate both of these loops with each loop having upper bound of 500 iterations. This approach is error-prone and if the number of periods is large, the contract is essentially deemed useless as his core-functionality will be broken. I consider this to be a Medium severity as assets are not at direct-risk but the core function of the protocol and it's availability could be impacted.
VS-Code/Manual Review
The good approach could be allowing iteration over periods in mutliple transactions.
Loop
#0 - c4-pre-sort
2023-08-12T09:38:49Z
141345 marked the issue as duplicate of #160
#1 - c4-judge
2023-08-24T05:48:26Z
alcueca marked the issue as unsatisfactory: Insufficient proof
#2 - c4-judge
2023-08-28T14:32:01Z
alcueca changed the severity to QA (Quality Assurance)
#3 - c4-judge
2023-08-28T14:32:58Z
alcueca marked the issue as grade-b