Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use of a bitmap for claims to save gas in Converter.sol #6

Closed
code423n4 opened this issue Nov 9, 2021 · 0 comments
Closed

Make use of a bitmap for claims to save gas in Converter.sol #6

code423n4 opened this issue Nov 9, 2021 · 0 comments
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")

Comments

@code423n4
Copy link
Contributor

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

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Nov 9, 2021
code423n4 added a commit that referenced this issue Nov 9, 2021
@SamSteinGG SamSteinGG added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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")
Projects
None yet
Development

No branches or pull requests

3 participants