Platform: Code4rena
Start Date: 27/10/2022
Pot Size: $33,500 USDC
Total HM: 8
Participants: 96
Period: 3 days
Judge: kirk-baird
Total Solo HM: 1
Id: 176
League: ETH
Rank: 41/96
Findings: 2
Award: $31.16
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: robee
Also found by: 0x007, 0x1f8b, 0x52, 0xDjango, 0xNazgul, 0xSmartContract, 8olidity, Awesome, B2, Bnke0x0, Chom, Diana, Dravee, JTJabba, Jeiwan, Josiah, Lambda, Mathieu, Picodes, RaoulSchaffranek, RaymondFam, RedOneN, ReyAdmirado, Rolezn, Ruhum, Sm4rty, Tricko, Trust, Waze, __141345__, a12jmx, adriro, ajtra, brgltd, c3phas, carlitox477, cccz, ch0bu, chaduke, chrisdior4, corerouter, cryptonue, csanuragjain, ctf_sec, cylzxje, delfin454000, dic0de, djxploit, horsefacts, imare, jayphbee, jwood, ktg, ladboy233, leosathya, lukris02, minhtrng, neko_nyaa, oyc_109, pashov, peritoflores, rbserver, rvierdiiev, shark, tnevler, yixxas
19.6449 USDC - $19.64
During the audit, 1 low and 5 non-critical issues were found.
â„– | Title | Risk Rating | Instance Count |
---|---|---|---|
L-1 | Missing check for zero address | Low | 3 |
NC-1 | Misleading function name | Non-Critical | 1 |
NC-2 | Order of Functions | Non-Critical | 2 |
NC-3 | Spaces between the control structures | Non-Critical | 65 |
NC-4 | Maximum line length exceeded | Non-Critical | 3 |
NC-5 | Typos | Non-Critical | 14 |
If address(0x0) is set it may cause the contract to revert or work wrong.
Add checks.
/** * @notice Amount of Pledges listed in this contract * @dev Amount of Pledges listed in this contract * @return uint256: Amount of Pledges listed in this contract */ function pledgesIndex() public view returns(uint256){ return pledges.length; }
Consider changing the name to pledgesLength()
or pledgesAmount()
.
According to Style Guide, ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier.
Functions should be grouped according to their visibility and ordered:
Internal function should be after external:
Public function should be after external:
Reorder functions where possible.
According to Style Guide, there should be a single space between the control structures if
, while
, and for
and the parenthetic block representing the conditional.
if(
for(
Change:
if(...)
to:
if (...)
Some lines of code are too long.
According to Style Guide, maximum suggested line length is 120 characters.
Make the lines shorter.
* @param targetVotes Maximum taget of votes to have (own balacne + delegation) for the receiver
=> target
* @param targetVotes Maximum taget of votes to have (own balacne + delegation) for the receiver
=> balance
* @param maxTotalRewardAmount Maximum total reward amount allowed ot be pulled by this contract
=> to
* @param maxFeeAmount Maximum feeamount allowed ot be pulled by this contract
=> fee amount
* @param maxFeeAmount Maximum feeamount allowed ot be pulled by this contract
=> to
// Add the total reards as available for the Pledge & write Pledge parameters in storage
=> rewards
* @param maxTotalRewardAmount Maximum added total reward amount allowed ot be pulled by this contract
=> to
* @param maxFeeAmount Maximum fee amount allowed ot be pulled by this contract
=> to
* @param pledgeId ID fo the Pledge
=> for
* @param pledgeId ID fo the Pledge to close
=> for
* @param minRewardPerSecond Minmum amount of reward per vote per second for the token
=> Minimum
* @param minRewardsPerSecond Minmum amount of reward per vote per second for each token in the list
=> Minimum
* @param minRewardPerSecond Minmum amount of reward per vote per second for the token
=> Minimum
* @param minRewardPerSecond Minmum amount of reward per vote per second for the token
=> Minimum
#0 - c4-judge
2022-11-12T01:01:13Z
kirk-baird marked the issue as grade-b
🌟 Selected for report: c3phas
Also found by: 0x1f8b, 0xNazgul, 0xRoxas, 0xSmartContract, 0xbepresent, Amithuddar, Awesome, B2, Bnke0x0, Dravee, KoKo, Mathieu, Picodes, RaymondFam, RedOneN, ReyAdmirado, RockingMiles, Ruhum, SadBase, SooYa, Waze, __141345__, adriro, ajtra, ballx, carlitox477, ch0bu, cylzxje, djxploit, durianSausage, emrekocak, erictee, gogo, halden, horsefacts, imare, indijanc, karanctf, leosathya, lukris02, neko_nyaa, oyc_109, peiw, sakman, shark, skyle, tnevler
11.5153 USDC - $11.52
During the audit, 3 gas issues were found.
Total savings ~200.
In Solidity 0.8+, there’s a default overflow and underflow check on unsigned integers. When an overflow or underflow isn’t possible (after require or if-statement), some gas can be saved by using unchecked blocks.
This saves ~35.
So, ~35*4 = 140
It saves gas due to not having to perform the same key’s keccak256 hash and/or offset recalculation.
This saves ~40.
So, ~40*1 = 40
When array or mapping accessed only once, there is no need to use local variable.
This saves ~3.
So, ~3*2 = 6
#0 - c4-judge
2022-11-12T01:06:45Z
kirk-baird marked the issue as grade-b