President Elector

First Flight #24
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Inefficient Use of Storage in Candidate Lists

Description: The RankedChoice contract uses dynamic arrays for storing candidate lists and rankings, which can lead to inefficient use of storage. Dynamic arrays in Solidity can be costly in terms of gas when resizing or iterating over them, especially if the arrays grow large.

Impact:

  • Increased Gas Costs: Operations involving dynamic arrays, such as adding or removing elements, can become expensive, leading to higher transaction costs.

  • Potential Performance Bottlenecks: As the number of candidates or voters increases, operations on these arrays may become slower, affecting the contract's performance.

Proof of Concept: The contract uses dynamic arrays for storing candidates and rankings:

address[] private VOTERS;
address[] private s_candidateList;

Recommended Mitigation:

  • Use Fixed-Size Arrays or Mappings: If the maximum number of candidates or voters is known, consider using fixed-size arrays or mappings to reduce gas costs associated with dynamic resizing.

  • Optimize Data Structures: Consider alternative data structures that are more gas-efficient for the specific operations required by the contract.

  • Batch Processing: For operations that involve large arrays, consider processing in batches to manage gas costs and performance.

Updates

Lead Judging Commences

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

Support

FAQs

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