Gas in LimboDAO.seed()
: Avoiding a 2N for-loop for a N one
#309
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
Dravee
Vulnerability details
Impact
Looping twice is expensive. It's possible to iterate only once from 0 to maxLength.
Proof of Concept
Original code iterating between N and 2N times here: https://github.com/code-423n4/2022-01-behodler/blob/71d8e0cfd9388f975d6a90dffba9b502b222bdfe/contracts/DAO/LimboDAO.sol#L195-L222
It's possible to iterate only N times on
sushiLPs
anduniLPs
.Here's the refacto I suggest, it starts from the comment
//@audit refacto starts here
and ends with//@audit refacto ends here
:Tools Used
VS Code
Recommended Mitigation Steps
Apply the suggested refacto
The text was updated successfully, but these errors were encountered: