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

Fix infinite vp #299

Merged
merged 2 commits into from
Aug 25, 2022
Merged

Fix infinite vp #299

merged 2 commits into from
Aug 25, 2022

Conversation

pscott
Copy link
Contributor

@pscott pscott commented Aug 24, 2022

Adds a assert_no_duplicates function that will throw if duplicates are found in an array. This function is doing this the "dumb way" (i.e. for each element, loop through the array and make sure there a no duplicates, resulting in O(n^2) complexity). The good thing about this is that no builtins are used whatsoever: so it's step intensive but builtin lightweight.
Another way we could do this is by using the bitwise builtin. Since most spaces will probably not support a gazilion voting strategies, I think we're fine with that, but we could indeed other ways of doing this in the future (sorting by increasing order for example to make lookup faster...)

Call this function in get_cumulative_voting_power to make sure voting strategies are unique.

Closes #298

@pscott pscott requested a review from Orland0x August 24, 2022 15:10
Copy link
Contributor

@Orland0x Orland0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Orland0x Orland0x merged commit d3a05d1 into develop Aug 25, 2022
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 this pull request may close these issues.

Add check to ensure each voting can only be used once.
2 participants