Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas Optimizations #38

Open
code423n4 opened this issue Aug 3, 2022 · 1 comment
Open

Gas Optimizations #38

code423n4 opened this issue Aug 3, 2022 · 1 comment
Labels

Comments

@code423n4
Copy link
Contributor

Community

  • L67/69/73/75/79/81/88/90/131/159/191/235/241/248/251/312/347/353/384/400/491/536/539/557/568 - The modifier function can generate much less cost if a private view function is used. In addition, the require can be modified by an if and custom errors, this would generate much less gas costs.

  • L140/198/624- It is less expensive to do ++i, than i++ or i + 1, without modifying the understanding of the code.

  • L261/427/764/840 - It is less expensive to make "variable != 0" than "variable > 0", without generating modifications in the understanding.

  • L624 - It is not necessary to set a variable with its default value, since it has that value defined by default.

  • L624 - When we use the length in a for loop it is better to use a variable in memory instead of constantly querying the length, for example in this line we have this query: _communities[_communityID].memberCount.

  • L768/781 - The variable is created in Storage _communityProject where it is created but then it is used much further down, this means that if it reverts in the middle, gas is spent on bringing a storage value that was never used, generating an expense extra gas.

  • L794 - The operation _lentAndInterest - _repayAmount can be unchecked since lines before it was validated that _lentAndInterest >= _repayAmount.

  • L836/837/843 - The variable is created in Storage _communityProject and _lender where it is created but then it is used much further down inside the if(), this means that if the validation does not pass, gas is spent on creating those variables that they were never used, generating an extra gas expense.

HomeFi

  • L72/73/77/78/82/84/142/191 - The modifier function can generate much less cost if a private view function is used. In addition, the require can be modified by an if and custom errors, this would generate much less gas costs.

  • L245 - It is less expensive to make "variable != 0" than "variable > 0", without generating modifications in the understanding.

Disputes

  • L37/39/43/46/50/52/60/61/183 - La funcion modifier puede generar mucho menor costo si se utilizara una funcion private view. Ademas el require puede ser modificado por un if y errores custom, esto generaria mucho menos costos de gas.

  • L107 - Es menos costoso hacer "variable != 0" que "variable > 0", sin generar modificaciones en el entendimiento.

  • L121 - Es menos costoso hacer ++i, que i++, sin modificar el entendimiento del codigo.

HomeFiProxy

  • L40/41/105 - The modifier function can generate much less cost if a private view function is used. In addition, the require can be modified by an if and custom errors, this would generate much less gas costs.

  • L87/136 - It is not necessary to set a variable with its default value, since it has that value defined by default.

  • L87/136 - It is less expensive to do ++i, than i++, without modifying the understanding of the code.

Project

  • L68/78 - In storage there are two bools (contractorConfirmed and contractorDelegated) that are individually surrounded by many uint256, they could be together and the space in storage would be optimized.

  • L123/132/135/150/153/176/189/195/199/238/241/245/277/301/308/341/406/515/521/530/886/906 - Also the require can be Modified by an if and custom errors, this would result in much lower gas costs.

  • L195/380/601/691/710 - It is less expensive to make "variable != 0" than "variable > 0", without generating modifications in the understanding.

  • L248/311/322/412 - It is not necessary to set a variable with its default value, since it has that value defined by default.

  • L253/256/601/603 - When a variable is used several times, gas can be saved by creating a variable in memory, an example of this is: _taskCosts[i].

  • L248/311/322/368/603/625/672 - It is less expensive to do ++i, than i++, without modifying the understanding of the code.

DebtToken

  • L29/31/50 - The modifier function can generate much less cost if a private view function is used. In addition, the require can be modified by an if and custom errors, this would generate much less gas costs.

ProjectFactory

  • L34/36/64/84 - The modifier function can generate much less cost if a private view function is used. In addition, the require can be modified by an if and custom errors, this would generate much less gas costs.
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Aug 3, 2022
code423n4 added a commit that referenced this issue Aug 3, 2022
@zgorizzo69
Copy link
Collaborator

muchas gracias por su trabajo 🇪🇸 ! 👍 for storage order in project.sol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants