Rigor Protocol contest - ak1'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: 81/133

Findings: 2

Award: $62.35

🌟 Selected for report: 0

🚀 Solo Findings: 0

  1. Update natspec comments in follwing lines of codes to understand the codes easily.

https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Disputes.sol#L245-L252 https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Disputes.sol#L265-L267 https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Disputes.sol#L229-L235

  1. use memory instead of storage while reading the data from structs.

  2. Currency type casting missing in following line of code. https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Community.sol#L605

  3. Proper error message can be added in the line, https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Disputes.sol#L106

  4. Update the document, in document it was mentioned that, as, Note that you cannot submit a project with no total budget. Therefore it requires at least one task with a budget > 0. but the zero budjet check is done while lending. Discussed with sponsor and clarified.

  1. ##HomeFiProxy.sol

https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/HomeFiProxy.sol#L87 https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/HomeFiProxy.sol#L137

In above line of codes, Use Pre increment operators in for loops to reduce the gas. for (uint256 i = 0; i < _length; i++) { use ++i

  1. ##HomeFi.sol

https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/HomeFi.sol#L284-L296

Return statement is not used anywhere and its not needed since the projectCount is state variabel and visible inside the contract.

  1. ##Disputes.sol

a) https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Disputes.sol#L180-L183

in above line, the code can be further simplified and the bool variabel can be avoided.

bool _result = _projectInstance.builder() == _address || _projectInstance.contractor() == _address || _sc == _address; require(_result, "Disputes::!Member");

Remove the bool _result and bring the check inside the require as shown below.

require(_projectInstance.builder() == _address || _projectInstance.contractor() == _address || _sc == _address, "Disputes::!Member"

b) https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Disputes.sol#L168-L172 function assertMember( can be internal. It is not used anywhere outside.

  1. ##Project.sol

a) https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Project.sol#L200

In above line of codes, type casting can be avoided.

projectCost() >= uint256(_newTotalLent),

b) Following lines can be swapped in the order of way they called. There is no need to check two times for invalid case.

https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Project.sol#L132 https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Project.sol#L135

c) Use pre-increment operator in following for loop. https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Project.sol#L368 https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Project.sol#L710

d) Inside for loop, during iteration, state variable can be avoided.

https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Project.sol#L603

Instead of using the state variable, declare a local varibale and assign. Use this local varibale in loop iteration.

for (; i < _changeOrderedTask.length; i++) { _changeOrderedTask.length is state variable

  1. ##Community.sol

a) In function lendToProject, after getting the _sender (address _sender = _msgSender();), the _sender can be used in following lines of codes instead of calling _msgSender() https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Community.sol#L443 https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Community.sol#L446

b) Inside for loop, during iteration, state variable can be avoided. https://github.com/code-423n4/2022-08-rigor/blob/b17b2a11d04289f9e927c71703b42771dd7b86a4/contracts/Community.sol#L624

for (uint256 i = 0; i < _communities[_communityID].memberCount; i++) { _communities[_communityID].memberCount is state variable.

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