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

Closed
code423n4 opened this issue Oct 6, 2022 · 1 comment
Closed

Gas Optimizations #14

code423n4 opened this issue Oct 6, 2022 · 1 comment
Labels
bug Something isn't working G (Gas Optimization) invalid This doesn't seem right unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@code423n4
Copy link
Contributor

code423n4 commented Oct 6, 2022

++I/I++ SHOULD BE UNCHECKED{++I}/UNCHECKED{I++} WHEN IT IS NOT POSSIBLE FOR THEM TO OVERFLOW, AS IS THE CASE WHEN USED IN FOR- AND WHILE-LOOPS

The unchecked keyword is new in solidity version 0.8.0, so this only applies to that version or higher, which these instances are. This saves 30-40 gas per loop

for (uint256 i = 0; i < length; /** NOTE: Removed i++ **/ ) {
// Do the thing
// Unchecked pre-increment is cheapest
unchecked { ++i; }
}

instances:

https://github.com/code-423n4/2022-10-blur/blob/main/contracts/PolicyManager.sol#L77

https://github.com/code-423n4/2022-10-blur/blob/main/contracts/lib/EIP712.sol#L77

https://github.com/code-423n4/2022-10-blur/blob/main/contracts/BlurExchange.sol#L199-L476

https://github.com/code-423n4/2022-10-blur/blob/main/contracts/lib/MerkleVerifier.sol#L38

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Oct 6, 2022
code423n4 added a commit that referenced this issue Oct 6, 2022
code423n4 added a commit that referenced this issue Oct 6, 2022
@GalloDaSballo
Copy link
Collaborator

Needs more savings, better findings and explanations

@GalloDaSballo GalloDaSballo added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Oct 20, 2022
@JeeberC4 JeeberC4 added the invalid This doesn't seem right label Nov 8, 2022
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) invalid This doesn't seem right unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants