Puppy Raffle

AI First Flight #1
Beginner FriendlyFoundrySolidityNFT
EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

[I-01] Naming Convention for immutable Variables (Readability + Standardization)

Description

The contract declares an immutable variable as follows:

uint256 public immutable entranceFee;

In Solidity, immutable variables are assigned once at contract deployment and cannot be modified afterward. This provides gas efficiency and ensures the value cannot be tampered with after deployment.

However, the current variable name entranceFee does not follow recommended naming conventions. Per coding standards, immutable variables should be prefixed with i_. This convention signals immutability to developers, improving code readability, maintainability, and reducing the risk of misinterpreting the variable’s mutability in complex contract logic.

Risk

  • Severity: Low

  • Type: Maintainability / Readability

  • Impact: While there is no direct security vulnerability, inconsistent naming conventions can lead to confusion and mistakes when the contract is extended or maintained, particularly in large codebases. Clear and consistent naming helps prevent misusing variables that are immutable.

Impact

  • Low security impact: The immutability is enforced by the compiler, so the variable cannot be altered post-deployment.

  • Maintainability: Using the i_ prefix makes immutable variables easily identifiable, enhancing readability for developers and auditors.

  • Best Practices: Aligns with widely adopted Solidity style guides and internal coding standards.

Proof of Concept

The current declaration:

uint256 public immutable entranceFee;

The recommended change is:

- uint256 public immutable entranceFee;
+ uint256 public immutable i_entranceFee;

Explanation:

  1. The - line shows the existing variable declaration, which does not indicate immutability clearly.

  2. The + line shows the recommended naming convention using the i_ prefix.

  3. Functions or contract logic referencing entranceFee should be updated to i_entranceFee. For example:

function getEntranceFee() external view returns (uint256) {
- return entranceFee;
+ return i_entranceFee;
}

This demonstrates that all reads from the variable remain correct after renaming, ensuring functional integrity while improving readability.

Recommended Mitigation

  • Rename all immutable variables in the contract to use the i_ prefix.

  • Update all references in the contract accordingly to prevent compilation issues.

  • Document this naming convention in the project’s coding guidelines to enforce consistency across the codebase.

  • Review other constants and immutable variables to ensure consistent naming, improving overall code readability and maintainability.

Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 4 hours ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!