Make use of a bitmap for claims to save gas in Converter.sol #6
Labels
bug
Something isn't working
Converter
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
TomFrench
Vulnerability details
Impact
Gas consumption
Proof of Concept
https://github.com/code-423n4/2021-11-vader/blob/3a43059e33d549f03b021d6b417b7eeba66cf62e/contracts/tokens/converter/Converter.sol#L52
Each claim performs a SSTORE to a fresh slot in order to mark a leaf as claimed. This results in each user paying 20k gas in order to invalidate a leaf whereas if many users shared the same slot they would pay 5k gas instead.
See Uniswaps implementation for inspiration:
https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol
Recommended Mitigation Steps
Use bitmap for leaf invalidation
The text was updated successfully, but these errors were encountered: