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

Open
code423n4 opened this issue Feb 10, 2022 · 3 comments
Open

Gas Optimizations #16

code423n4 opened this issue Feb 10, 2022 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

GAS issues

  1. Change the incremental logic from i++ to ++i in order to save some opcodes:
  1. The following structs could be optimized moving the position of certains values in order to save slot storages:
  1. Use delete instead of set to default value (false or address(0))
  1. Change the logic in order to save one variable
    function _setOwner(address newOwner) private {
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Feb 10, 2022
code423n4 added a commit that referenced this issue Feb 10, 2022
@adrien-supizet
Copy link
Collaborator

adrien-supizet commented Feb 15, 2022

  1. already surfaced in first audit
  2. duplicated Gas Optimizations #28
  3. Invalid, this makes no difference
  4. acknowledged

@adrien-supizet adrien-supizet added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Feb 15, 2022
@maximebrugel maximebrugel added duplicate This issue or pull request already exists and removed sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Feb 18, 2022
@harleythedogC4
Copy link
Collaborator

My personal judgements:

  1. "Change the incremental logic from i++ to ++i". Agree with sponsor. Invalid.
  2. "The following structs could be optimized". I am going to disagree with the sponsor here, in theory there is an optimzation here, and obviously I can't reproduce the sponsor's claim of the gas costs actually increasing. I will mark as Valid and small-optimization.
  3. "Use delete instead of set to default value". Agree with sponsor, according to here, it seems that there is no difference in this case. Invalid.
  4. "Change the logic in order to save one variable". 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 2 points.
Thus the final score of this gas report is (2/10)*100 = 20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

4 participants