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

0 stars 0 forks source link

Explicit initialization with zero not required #126

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

Dravee

Vulnerability details

Impact

Explicit initialization with zero is not required for variable declaration because uints are 0 by default. Removing this will reduce contract size and save a bit of gas.

Proof of Concept

Instances include:

./staking-rewards/StakingRewards.sol:26:    uint256 public periodFinish = 0;
./staking-rewards/StakingRewards.sol:27:    uint256 public rewardRate = 0;
./tokens/USDV.sol:152:        for (uint256 i = 0; i < userLocks.length; i++) {
./tokens/vesting/LinearVesting.sol:169:        for (uint256 i = 0; i < vesters.length; ++i) {

Tools Used

Manual Analysis

Recommended Mitigation Steps

Remove explicit initialization with zero. It's already done at several places and in most for-loops, which means that this optimization would be consistent with the overall code style.