President Elector

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

Expensive Array Membership Checks

Summary

The function _isInArray() plays a crucial role in the system, but its implementation takes too much gas when the array gets too long.

Vulnerability Details

The function _isInArray() has O(n) complexity, which means the resources needed to finish the computation increases linearly with the array length. When the array has too many members, the function becomes too expensive to execute. When calling selectPresident(), it is highly likely that the function _isInArray() is called multiple times. If each call takes too much gas, the call will become too expensive to execute.

Impact

The operation becomes too expensive.

Tools Used

Manual review.

Recommendations

Consider using OpenZeppelin's EnumerableSet that has O(1) complexity which will reduce the gas consumption significantly.

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.