DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Potentially unused private / internal state variables found.

Summary

The contract in KeeperProxy.sol contains a state variable threshold declared on Line 32 that is potentially unused. If this variable is not being referenced anywhere in the code, it is advisable to remove it to save gas costs and reduce code complexity. Unused state variables may also lead to confusion or maintenance challenges for other developers working on the project.

Vulnerability Details

The threshold variable is declared as a uint256 but is not used in the contract's functions or logic. While it's possible that it may be referenced in inline assembly or in the future, if it is genuinely unused, it introduces unnecessary overhead in terms of storage and can negatively affect the gas cost of transactions.

Found Instance:

  1. KeeperProxy.sol - Line 32:

    `uint256 threshold; ` 

Impact

  • Gas Inefficiency: Storing unused variables consumes storage on the blockchain, which costs gas. If the variable is not needed, removing it would save unnecessary gas costs.

  • Increased Code Complexity: Unused variables clutter the code and may cause confusion for other developers. It can also make future development and maintenance more difficult.

  • Potential for Errors: Unused state variables could be mistakenly thought to be part of some logic, leading to confusion and possible errors in the codebase.

Tools Used

  • Static Analysis: This issue was detected using static analysis tools like Slither, MythX, or CodeQL, which can flag potentially unused state variables.

Recommendations

  1. Remove Unused State Variables:

    • If after checking, the threshold variable is confirmed to be unused, it should be removed from the contract to save gas and reduce the code size.

    Example:

    `// Remove the following unused variable: // uint256 threshold; ` 
  2. Check for Future Use or Inline Assembly References:

    • Ensure that the variable isn’t used in any inline assembly code or expected to be used in future contract upgrades. If it is planned for future use, document the intent and leave a comment explaining its purpose to avoid confusion.

  3. Regular Code Reviews:

    • Perform regular code reviews to identify unused variables or other inefficient constructs. Unused code should be cleaned up during development to ensure optimal contract performance and maintainability.

  4. Automate Unused Code Detection:

    • Use automated tools during the development cycle to detect unused state variables and other inefficiencies. Tools like Slither and MythX can be incorporated into CI/CD pipelines to catch such issues early.

By removing unused state variables, you will improve the overall gas efficiency and clarity of the code, making it easier to maintain and audit.

Updates

Lead Judging Commences

n0kto Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

n0kto Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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