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

audit: Unnecessary Binary Search #190

Closed
Orland0x opened this issue Jun 13, 2023 · 0 comments · Fixed by #200
Closed

audit: Unnecessary Binary Search #190

Orland0x opened this issue Jun 13, 2023 · 0 comments · Fixed by #200
Assignees

Comments

@Orland0x
Copy link
Contributor

The WhitelistVotingStrategy allows the Space contract to provide an ordered list of whitelisted users, so that the strategy can check that a given user is allowed to vote. It searches through this list using a binary search. However, this leads to two main problems:

  1. When the admin / owner of a space updates the whitelist, this may involve writing an arbitrarily large number of storage slots, as they must reorder the entire list.
  2. The gas cost of voting is higher than necessary, as every voter must run the binary search on-chain.
    An alternative to this would be to provide the WhitelistVotingStrategy with an unordered list of members. When a user votes, they must provide the index of their own whitelist entry, so that the contract only needs to confirm that their address is at that index in the list, without going over any other entries. They could provide this index using the userParams field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants