Beatland Festival

First Flight #44
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Impact: low
Likelihood: high
Invalid

Unnecessary Public State Variables Increase Deployment Gas Costs

Many public state variables can cause large gas costs

Description

  • The contract declares most state variables and mappings as public, which automatically generates external getter functions for each variable. Many of these variables are only used internally by the contract and don't require external access, making the public visibility unnecessary and wasteful.

    Each public state variable generates bytecode for a getter function, increasing the contract's deployment size and gas costs. This is particularly impactful for complex mappings that generate more expensive getter functions.

// @> ISSUE: Most of these don't need external access
mapping(uint256 => uint256) public passSupply;
mapping(uint256 => uint256) public passMaxSupply;
mapping(uint256 => uint256) public passPrice;
mapping(uint256 => Performance) public performances;
mapping(uint256 => mapping(address => bool)) public hasAttended;
mapping(address => uint256) public lastCheckIn;
mapping(uint256 => MemorabiliaCollection) public collections;
mapping(uint256 => uint256) public tokenIdToEdition;
address public beatToken;
address public organizer;
uint256 public nextCollectionId = 100;
uint256 public performanceCount;

Risk

Likelihood:

  • Issue occurs on every contract deployment

  • Gas costs are directly passed to the deployer

  • Affects project economics and deployment feasibility

Impact:

  • Increased deployment gas costs for unnecessary getter functions

  • Larger contract bytecode size affecting deployment limits

  • Wasted blockchain resources for unused functionality

  • Higher barrier to entry due to increased deployment costs

Proof of Concept

// Current: All public (generates 10+ getter functions)
mapping(uint256 => uint256) public passSupply; // Generates: function passSupply(uint256) external view returns(uint256)
// Most of these getters are never called externally
// Users typically interact through specific view functions like hasPass(), getMultiplier()

Recommended Mitigation

Change visibility to internal for variables that don't need external access.
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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