Raisebox Faucet

First Flight #50
Beginner FriendlySolidity
100 EXP
Submission Details
Impact: low
Likelihood: low
Invalid

State Variable Not Declared Immutable

Author Revealed upon completion

Root + Impact

Description

The contract sets the variables faucetDrip, sepEthAmountToDrip, and dailySepEthCap in the constructor, and their values never change after deployment. Declaring these as immutable would save gas and make it clear to anyone reading the code that these values are fixed for the lifetime of the contract.

uint256 public faucetDrip; // @> Should be declared immutable
uint256 public sepEthAmountToDrip; // @> Should be declared immutable
uint256 public dailySepEthCap; // @> Should be declared immutable

Risk

Likelihood:

  • This issue is present in every deployment of the contract until the variable are made immutable.

Impact:

  • The contract uses more gas than necessary for these variables.

Proof of Concept

// These variables are only set in the constructor and never changed afterwards.
RaiseBoxFaucet.sol:
uint256 public faucetDrip;
uint256 public sepEthAmountToDrip;
uint256 public dailySepEthCap;
// After deployment, their values never change.

Recommended Mitigation

- uint256 public faucetDrip;
+ uint256 public immutable faucetDrip;
- uint256 public sepEthAmountToDrip;
+ uint256 public immutable sepEthAmountToDrip;
- uint256 public dailySepEthCap;
+ uint256 public immutable dailySepEthCap;
Updates

Lead Judging Commences

inallhonesty Lead Judge 2 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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