code-423n4 / 2021-12-amun-findings

0 stars 0 forks source link

Use id to manage itarable addresses #268

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

Czar102

Vulnerability details

Impact

Iterating through a storage list consumes large amounts of gas.

Proof of Concept

This is relevant to:

Recommended Mitigation Steps

To remediate the consumption and scale solutions, consider changing LibBasketStorage.basketStorage().inPool and LibCallStorage.callStorage().canCall into a mapping to uint - id, starting with 1 to differentiate from unmapped addresses. This way, deletion and addition of tokens can be achieved in constant time fully on-chain.

bool inPool or bool canCall can be retrieved by checking id != 0.