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 #68

Open
code423n4 opened this issue Feb 12, 2022 · 2 comments
Open

Gas Optimizations #68

code423n4 opened this issue Feb 12, 2022 · 2 comments
Assignees
Labels
bug Something isn't working G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Use cached variable value

Impact

The _submitOutOrders() function sets batchLength = _batchedOrders.orders.length, but in the for loop the value "_batchedOrders.orders.length" is used instead of "batchLength". Using the cached variable could save gas.

Proof of Concept

The for loop on line 369 could use the batchLength variable. This approach is used in the similar for loop on line 327.

Recommended Mitigation Steps

Use the cached "batchLength" variable

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Feb 12, 2022
code423n4 added a commit that referenced this issue Feb 12, 2022
@maximebrugel maximebrugel added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Feb 17, 2022
@maximebrugel maximebrugel self-assigned this Feb 18, 2022
@harleythedogC4
Copy link
Collaborator

My personal judgments:

  1. "Use cached variable value". Other reports had their submissions marked as invalid as they recommend using a cached length variable, and this was already acknowledged in the first contest. However, this submission is different, since the length is already cached, and so it definitely makes sense to use the cached length. Valid and small-optimization.

@harleythedogC4
Copy link
Collaborator

Now, here is the methodology I used for calculating a score for each gas report. I first assigned each submission to be either small-optimization (1 point), medium-optimization (5 points) or large-optimization (10 points), depending on how useful the optimization is. The score of a gas report is the sum of these points, divided by the maximum number of points achieved by a gas report. This maximum number was 10 points, achieved by #67.

The number of points achieved by this report is 1 points.
Thus the final score of this gas report is (1/10)*100 = 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants