Platform: Code4rena
Start Date: 09/11/2021
Pot Size: $30,000 ETH
Total HM: 6
Participants: 17
Period: 3 days
Judge: pauliax
Total Solo HM: 3
Id: 50
League: ETH
Rank: 14/17
Findings: 2
Award: $52.98
🌟 Selected for report: 2
🚀 Solo Findings: 0
0.007 ETH - $33.11
Reigada
In all the loops, the variable i is incremented using i++. It is known that using ++i costs less gas per iteration than i++.
token/FSD.sol:555: for (uint256 i = 0; i < userLength; i++) { dao/FairSideDAO.sol:344: for (uint256 i = 0; i < votes.length; i++) { dao/FairSideDAO.sol:479: for (uint256 i = 0; i < targetCount; i++) { dao/FairSideDAO.sol:508: for (uint256 i = 0; i < targetCount; i++) { dao/FairSideDAO.sol:552: for (uint256 i = 0; i < targetCount; i++) { network/FSDNetwork.sol:630: for (uint256 i = 0; i < assessorsLength; i++) { dependencies/TributeAccrual.sol:83: for (uint256 i = offset; i < totalTributes; i++) dependencies/TributeAccrual.sol:86: for (uint256 i = offset; i < totalGovernanceTributes; i++)
Manual testing
Use ++i instead of i++ to increment the value of an uint variable.
#0 - YunChe404
2021-11-14T11:30:05Z
#23
#1 - pauliax
2021-11-16T22:38:36Z
Making this a primary issue as it contains more examples where this suggestion can be applied. In my opinion, this is a bit more efficient in terms of gas but decreases the readability of the codebase. It is up to the project team to decide if it's worth making the changes.
0.0042 ETH - $19.87
Reigada
There are functions marked as public but they are never directly called within the same contract or in any of its descendants, hence they can be declared as external to save some gas:
Slither
Declare those functions as external to save some gas.
#0 - YunChe404
2021-11-14T11:29:46Z
#8
#1 - pauliax
2021-11-17T10:28:31Z
Valid suggestion, it is also a good practice to make your functions external if they are not intended to be called internally. But please note that 'external' is not always cheaper than 'public', see: https://ethereum.stackexchange.com/a/107939/17387
Making this a primary issue as it contains the most examples where this suggestion can be applied.