Looping through the entire array to find if an element exists is gas inefficient as traversing an array in O(n) time complexity.
RankedChoice::_isInArray()
function is used inside all external functions and even recursively in RankedChoice::selectPresident()
function. This can easily lead to Denial-of-Service attacks for large array inputs in its parent functions.
Add below snippet to RankedChoiceTest.t.sol
and run the test case.
Merkle proofs provide an efficient way to verify if an element exists in some collection of data, which in our case is a large array input. For example, below snippet can be implemented where MerkleProof
is a library that exposes verify
function that takes array of merkle proofs, the merkle root and the leaf data which can be hash of voter address.
Foundry
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.