DittoETH

Ditto
DeFiFoundryOracle
55,000 USDC
View results
Submission Details
Severity: low
Invalid

Using unchecked blocks to save gas - Increments in for loop can be unchecked (save 30-40 gas per loop iteration)

##summary
The majority of Solidity for loops increment a uint256 variable that starts at 0.

Vulnerability Details

These increment operations never need to be checked for over/underflow because the variable will never reach the max number of uint256 (will run out of gas long before that happens). The default over/underflow check wastes gas in every iteration of virtually every for loop.

Impact

Using unchecked blocks to save gas

Tools Used

vscode

Recommendations

Increments in for loop can be unchecked (save 30-40 gas per loop iteration)

instead of this

for (uint256 i = 0; i < size; i++)

make it

for (uint256 i = 0; i < size;)

unchecked {
++i;
}

Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Gas optimizations

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.