Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Invalid

State Variables Not Declared Immutable Causing Unnecessary Gas Overhead

Details:

Certain state variables in the contracts are only assigned once in the constructor and never modified thereafter. Specifically, in InheritanceManager.sol, the variable NFTFactory nft is set during contract creation, and in NFTFactory.sol, the variable address inheritanceManager is assigned in the constructor. Declaring these variables as immutable would allow the compiler to optimize gas usage by embedding their values directly into the contract’s bytecode.

Root Cause:

The variables that should be constant after initialization are not marked as immutable. This oversight leads to additional gas costs when these variables are accessed during contract execution.

Impact:

  • Gas Inefficiency: Increased gas usage on deployment and on read operations.

  • Clarity: Without the immutable keyword, it is less clear to auditors and developers that these variables are not intended to change after construction.

Recommendation:

Modify the variable declarations to include the immutable keyword. For example:

  • In InheritanceManager.sol, change:

    NFTFactory nft;

    to:

    NFTFactory immutable nft;
  • In NFTFactory.sol, change:

    address inheritanceManager;

    to:

    address immutable inheritanceManager;
Updates

Lead Judging Commences

0xtimefliez Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
0xtimefliez Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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