President Elector

First Flight #24
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

Potential Gas Limit Issues with Large Voter or Candidate Lists

Description: The contract processes all voters and candidates in loops within functions like selectPresident and _selectPresidentRecursive. If the number of voters or candidates is large, these loops could exceed the block gas limit, causing transactions to fail.

Impact:

  • Transaction Failure: Large voter or candidate lists could lead to transactions running out of gas, resulting in failed attempts to execute critical functions like selecting a president.

  • Operational Disruption: This could disrupt the election process, preventing the selection of a new president and potentially halting the governance process.

Proof of Concept: If the number of voters or candidates is sufficiently large, attempting to execute the selectPresident function could result in an out-of-gas error:

// Assuming a large number of voters and candidates
rankedChoice.selectPresident();

Recommended Mitigation:

  • Batch Processing: Process voters and candidates in smaller batches over multiple transactions to avoid hitting gas limits.

  • Gas Limit Checks: Implement checks to ensure that loops do not exceed a safe number of iterations based on current gas limits.

  • Optimized Data Structures: Use more gas-efficient data structures and algorithms to handle large lists.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

A high number of candidates could cause an OOG

Support

FAQs

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