code-423n4 / 2021-11-vader-findings

0 stars 0 forks source link

Adding unchecked directive can save gas #177

Closed code423n4 closed 3 years ago

code423n4 commented 3 years ago

Handle

defsec

Vulnerability details

Impact

For the arithmetic operations that will never over/underflow, using the unchecked directive (Solidity v0.8 has default overflow/underflow checks) can save some gas from the unnecessary internal over/underflow checks.

Proof of Concept

Example Code Location

https://github.com/code-423n4/2021-11-vader/blob/607d2b9e253d59c782e921bfc2951184d3f65825/contracts/governance/GovernorAlpha.sol#L434

        Proposal storage proposal = proposals[proposalId];
        uint256 eta = block.timestamp + timelock.delay();

Block.timestamp never will overflow.

Tools Used

Code Review

Recommended Mitigation Steps

Consider applying 'unchecked' keyword where overflows/underflows are not possible.

SamSteinGG commented 3 years ago

Duplicate of #43