Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Missed Gas Optimization via immutable Variables.

Root + Impact

Description

  • The Game contract sets multiple parameters in the constructor (e.g., _initialClaimFee, _initialGracePeriod, etc.) and never updates them after deployment.

  • These values are currently stored in storage, which is more expensive both at deployment and runtime. Since they are immutable after construction, using the immutable keyword would reduce gas costs and improve efficiency.

contract Game is Ownable {
uint256 public initialClaimFee;
@> uint256 public initialGracePeriod;
@> uint256 public feeIncreasePercentage;
@> uint256 public platformFeePercentage;
constructor(
uint256 _initialClaimFee,
uint256 _gracePeriod,
uint256 _feeIncreasePercentage,
uint256 _platformFeePercentage
) {
initialClaimFee = _initialClaimFee;
initialGracePeriod = _gracePeriod;
feeIncreasePercentage = _feeIncreasePercentage;
platformFeePercentage = _platformFeePercentage;
}
}

Risk

Likelihood:

  • This occurs any time constructor-set variables are used without being updated later.

  • Developers often overlook immutable because the contract works as expected, but this results in silent gas inefficiency.

Impact:

  • Higher deployment gas cost since each variable uses a storage slot.

  • More expensive reads during runtime as storage access is more costly than reading from bytecode (which is where immutable values are stored).

Proof of Concept

Use forge build --sizes or any size analyzer to compare gas costs for:

uint256 public initialClaimFee = 0.1 ether; // stored in storage

vs

uint256 public immutable initialClaimFee; // compiled into bytecode

You will see measurable differences in both bytecode size and gas cost for constructor and read ops.

Recommended Mitigation

- uint256 public _initialClaimFee;
- uint256 public _initialGracePeriod;
- uint256 public _feeIncreasePercentage;
- uint256 public _platformFeePercentage;
+ uint256 public immutable _initialClaimFee;
+ uint256 public immutable _initialGracePeriod;
+ uint256 public immutable _feeIncreasePercentage;
+ uint256 public immutable _platformFeePercentage;
Updates

Appeal created

inallhonesty Lead Judge 17 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.