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

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

Gas Optimizations #154

code423n4 opened this issue Feb 9, 2022 · 2 comments
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Removable Variable (miniscule gas cost reduction at deploy time)

  • Variable is only written to in the constructor but never used anywhere
    https://github.com/code-423n4/2022-02-concur/blob/72b5216bfeaa7c52983060ebfc56e72e0aa8e3b0/contracts/USDMPegRecovery.sol#L24

Variables that should be immutable (safe costly sloads)

  • https://github.com/code-423n4/2022-02-concur/blob/72b5216bfeaa7c52983060ebfc56e72e0aa8e3b0/contracts/USDMPegRecovery.sol#L22
  • https://github.com/code-423n4/2022-02-concur/blob/72b5216bfeaa7c52983060ebfc56e72e0aa8e3b0/contracts/StakingRewards.sol#L19
  • https://github.com/code-423n4/2022-02-concur/blob/72b5216bfeaa7c52983060ebfc56e72e0aa8e3b0/contracts/StakingRewards.sol#L20
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Feb 9, 2022
code423n4 added a commit that referenced this issue Feb 9, 2022
@GalloDaSballo
Copy link
Collaborator

  1. Remove variable
    Should save the cost of one SSTORE which is 20k gas

  2. Make variable immutable
    The warden could have made a killing here had they spent the extra time linking all the instances
    Because they just linked the variables, so will give each of the findings one SLOAD value.
    2100 * 3

Total Gas saved: 26300

Due to the simplicity, the report doesn't require formatting

@GalloDaSballo
Copy link
Collaborator

Am changing the way I calculate gas savings to mostly run-time so am removing the 20k gas
New total is 6300

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)
Projects
None yet
Development

No branches or pull requests

2 participants