Closed code423n4 closed 3 years ago
defsec
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.
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.
Code Review
Consider applying 'unchecked' keyword where overflows/underflows are not possible.
Duplicate of #43
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
Block.timestamp never will overflow.
Tools Used
Code Review
Recommended Mitigation Steps
Consider applying 'unchecked' keyword where overflows/underflows are not possible.