Rigor Protocol contest - apostle0x01's results

Community lending and instant payments for new home construction.

General Information

Platform: Code4rena

Start Date: 01/08/2022

Pot Size: $50,000 USDC

Total HM: 26

Participants: 133

Period: 5 days

Judge: Jack the Pug

Total Solo HM: 6

Id: 151

League: ETH

Rigor Protocol

Findings Distribution

Researcher Performance

Rank: 125/133

Findings: 1

Award: $21.72

🌟 Selected for report: 0

🚀 Solo Findings: 0

Issues found

[G-01] Don't Initialize Variables with Default Value

Explicitly initializing a variable with it's default value costs unnecesary gas.

Findings:
contracts/Community.sol::624 => for (uint256 i = 0; i < _communities[_communityID].memberCount; i++) { contracts/HomeFiProxy.sol::87 => for (uint256 i = 0; i < _length; i++) { contracts/HomeFiProxy.sol::136 => for (uint256 i = 0; i < _length; i++) { contracts/Project.sol::248 => for (uint256 i = 0; i < _length; i++) { contracts/Project.sol::311 => for (uint256 i = 0; i < _length; i++) { contracts/Project.sol::322 => for (uint256 i = 0; i < _length; i++) { contracts/libraries/Tasks.sol::181 => for (uint256 i = 0; i < _length; i++) _alerts[i] = _self.alerts[i];

[G-02] Cache Array Length Outside of Loop

Caching the array length outside a loop saves reading it on each iteration, as long as the array's length is not changed during the loop.

Findings:
./contracts/Project.sol:603: for (; i < _changeOrderedTask.length; i++) {

[G-03] Use != 0 instead of > 0 for Unsigned Integer Comparison

When dealing with unsigned integer types, comparisons with != 0 are cheaper then with > 0.

Findings:
contracts/Community.sol::764 => require(_repayAmount > 0, "Community::!repay"); contracts/Project.sol::195 => require(_cost > 0, "Project::!value>0");

[G-04] Increments can be unchecked

Impact

In Solidity 0.8+, there's a default overflow check on unsigned integers. It's possible to uncheck this in for-loops and save some gas at each iteration, but at the cost of some code readability, as this uncheck cannot be made inline.

Instances include:

./contracts/HomeFiProxy.sol:87: for (uint256 i = 0; i < _length; i++) { ./contracts/HomeFiProxy.sol:136: for (uint256 i = 0; i < _length; i++) { ./contracts/Project.sol:248: for (uint256 i = 0; i < _length; i++) { ./contracts/Project.sol:311: for (uint256 i = 0; i < _length; i++) { ./contracts/Project.sol:322: for (uint256 i = 0; i < _length; i++) { ./contracts/Project.sol:603: for (; i < _changeOrderedTask.length; i++) { ./contracts/Community.sol:624: for (uint256 i = 0; i < _communities[_communityID].memberCount; i++) { ./contracts/libraries/Tasks.sol:181: for (uint256 i = 0; i < _length; i++)

The code would go from:

for (uint256 i = 0; i < _length; i++) { // ... }

to:

for (uint256 i = 0; i < _length;) { // ... unchecked { ++i; } }

The risk of overflow is inexistant for a uint256 here.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter