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

Open
code423n4 opened this issue May 30, 2022 · 2 comments
Open

Gas Optimizations #200

code423n4 opened this issue May 30, 2022 · 2 comments
Labels
bug Something isn't working G (Gas Optimization) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

  1. Use Custom Error instead of Revert String to Save Gas

Custom error from solidity 0.8.4 are cheaper than revert strings, custom error are defined using the error statement can use inside and outside the contract.

source https://blog.soliditylang.org/2021/04/21/custom-errors/

i suggest replacing revert error strings with custom error

POC :

https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/factories/PairFactory.sol#L56
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/factories/PairFactory.sol#L61
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/factories/PairFactory.sol#L66
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/factories/PairFactory.sol#L67
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/factories/PairFactory.sol#L69
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/factories/PairFactory.sol#L89
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/factories/PairFactory.sol#L91
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/factories/PairFactory.sol#L92
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L25
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L40
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L42
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L58
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L59
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L87
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L177
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L182
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L249
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L250
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L341
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L356
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L369
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L371
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L382
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L384
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Router.sol#L406
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L163
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L307
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L773
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L774
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L786
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L787
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L820
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L821
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L834
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L835
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L836
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L837
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L846
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L849
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L1085
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L1245
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L1315
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L1378
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L1382
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/VotingEscrow.sol#L1386
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Pair.sol#L303
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Pair.sol#L322
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Pair.sol#L336
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Pair.sol#L338
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Pair.sol#L344
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Pair.sol#L353
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Pair.sol#L361
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Pair.sol#L467
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Pair.sol#L485
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Minter.sol#L65
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Minter.sol#L70
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Minter.sol#L75
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Minter.sol#L76
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Gauge.sol#L615
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Gauge.sol#L627
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Gauge.sol#L635
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Gauge.sol#L642
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Bribe.sol#L31
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Bribe.sol#L44
https://github.com/code-423n4/2022-05-velodrome/blob/main/contracts/contracts/Bribe.sol#L69

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels May 30, 2022
code423n4 added a commit that referenced this issue May 30, 2022
@pooltypes pooltypes added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons duplicate This issue or pull request already exists and removed disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) labels Jun 10, 2022
@pooltypes
Copy link
Collaborator

Duplicate of #69

@pooltypes pooltypes marked this as a duplicate of #69 Jun 10, 2022
@liveactionllama liveactionllama removed the duplicate This issue or pull request already exists label Jun 13, 2022
@GalloDaSballo
Copy link
Collaborator

In lack of gas golfing I can't give the report any points

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 acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

4 participants