Weather Witness

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

Unused Constructor Parameter Creates Confusion and Potential Future Issues

Description

  • The WeatherNft contract accepts various parameters in its constructor to configure the contract and initialize key variables.

  • The _keeperRegistry parameter is declared and assigned to state variable s_keeperRegistry, but this state variable is never used anywhere in the contract's logic.

constructor(
Weather[] memory weathers,
string[] memory weatherURIs,
address functionsRouter,
FunctionsConfig memory _config,
uint256 _currentMintPrice,
uint256 _stepIncreasePerMint,
address _link,
address _keeperRegistry, // @> _keeperRegistry declared not used.
address _keeperRegistrar,
uint32 _upkeepGaslimit
)
ERC721("Weather NFT", "W-NFT")
FunctionsClient(functionsRouter)
ConfirmedOwner(msg.sender)
{
// ...
s_keeperRegistry = _keeperRegistry;
// ...
}

Risk

Likelihood: Low

  • The issue is present in deployed code and will affect all instances

  • The code compiles and functions correctly despite the unused parameter

Impact: Low

  • Introduces unnecessary gas costs during contract deployment due to storing an unused address

  • Creates confusion for developers maintaining or interacting with the system

  • May indicate incomplete or abandoned functionality that was intended for the contract

Proof of Concept

The state variable s_keeperRegistry is assigned in the constructor but no function in the contract reads or uses this value:

// This parameter is stored but never used
s_keeperRegistry = _keeperRegistry;
// Searching through the entire contract, there are no instances where s_keeperRegistry is used
// The state variable is effectively dead code, but still costs gas to store

Recommended Mitigation

Either remove the unused parameter or implement its intended functionality:

Option 1 - Remove the unused parameter:

constructor(
Weather[] memory weathers,
string[] memory weatherURIs,
address functionsRouter,
FunctionsConfig memory _config,
uint256 _currentMintPrice,
uint256 _stepIncreasePerMint,
address _link,
- address _keeperRegistry,
address _keeperRegistrar,
uint32 _upkeepGaslimit
)
ERC721("Weather NFT", "W-NFT")
FunctionsClient(functionsRouter)
ConfirmedOwner(msg.sender)
{
// ...
- s_keeperRegistry = _keeperRegistry;
// ...
}

Option 2 - Document its purpose if it's intended for future functionality:

+ /// @notice Keeper registry address stored for future direct registry interaction functionality
address private immutable s_keeperRegistry;
Updates

Appeal created

bube 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.