State variables in the `Snow.sol` contract are not designated as immutable, costing more gas for functions that use the variable
`Snow.sol` contains state variables that are intialized in the constructor, but never change value through setter functions or other function interactions.
In `Snow.sol`:
Likelihood:
The likelihood is high because every time the variables are loaded the use more gas than they would have if they had been declared immutable
Impact:
Failing to assign these variables as immutable results in more gas use for users. Immutable variables are stored directly in the contract runtime bytecode as opposed to having to be loaded using an `SLOAD` operation.
Add the following contracts to `TestSnow.t.sol`:
Add the contracts as veriables to the `TestSnow` contract:
Initialize the contracts with the same WETH address value in the constructor:
Add the following test to the test suite:
Run the test in the terminal:
If the test passes, then the storage variable uses more gas to load.
Declare the variables as immutable to save gas costs:
In Snow.sol:
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.