Skip to content
Commit cb524013 authored by Luke Schoen's avatar Luke Schoen Committed by Gav Wood
Browse files

Update SRML Council: prevent excess votes/computation (#1162)

* fix: Add assertions to prevent excess votes and computation, and to end council seat election when no empty seats

* Add assertion to prevent a vote from voters that provide a list of votes that exceeds the desired seats length, since otherise an attacker may be able to submit a very long list of `votes` that far exceeds the amount of candidates and waste more computation than a reasonable voting bond would cover. Added additional associated test that may be run with `cargo test -p srml-council`

* Add assertion so expired council seats are not up for election when desired seat count changes during the voting period such that there are no longer any empty seats

* Update comment to refer to `reporter` instead of `who` (target of inactivity), since the origin is the `reporter`

* Update commment to refer more specifically to how many vote indexes, since `InactiveGracePeriod` is measured in vote indexes

* Update comment for `ApprovalsOf` since previously the comment was a duplicate of the comment for `LastActiveOf`'s

* Create variable to refer to `retaining_seats` to improve readability

* Reference Notes: https://hackmd.io/nr6kPD2sR4urmljtvHs0CQ

* WIP - length votes should be less than length candidates. pushing changes for reference so can fix

* fix: Amount of candidate approval votes cannot exceed candidates amount. Candidates amount must be over zero.

* Fix so that amount of candidate approval votes cannot exceed amount of candidates (instead of desired seats)

* Add assertion to `set_approvals` such that amount of candidates to receive approval votes must be greater than zero. Add associated test

* fix: Remove assertion preventing votes when empty seats is 0

* review-fix: Replace with is_zero and add corresponding test

* Update seats.rs

* Update seats.rs
parent eb0ff291
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment