Skip to content

Reputation Voting - #644

Merged
kronosapiens merged 61 commits into
developfrom
feat/voting
Sep 4, 2020
Merged

kronosapiens merged 61 commits into
developfrom
feat/voting

Conversation

@kronosapiens

@kronosapiens kronosapiens commented Jun 13, 2019

Copy link
Copy Markdown
Contributor

Closes #80
Closes #81
Closes #82
Closes #83
Closes #84
Closes #85
Closes #86
Closes #87
Closes #88
Closes #89

Depends on #757, #760, #771, #845

Implementation references:

https://blog.colony.io/towards-better-ethereum-voting-protocols-7e54cb5a0119/
https://blog.colony.io/token-weighted-voting-implementation-part-1-72f836b5423b/
https://blog.colony.io/token-weighted-voting-implementation-part-2-13e490fe1b8a/

Initially I started working on both reputation and token weighted voting, but token voting ended up requiring some more problem-solving w.r.t. managing vote secrets and communicating with the token locking contract, so in the spirit of hitting OKRs it's going to wait until QX.

Features

  • Creating new binary polls
  • Reputation voting rate & reveal
  • Defining the actions votes will determine 💪
  • Poll lifecycle management
  • Tests w/ 100% code coverage for new contracts 🎉
  • Vote power thresholds
  • Staking / spam prevention
  • Stake redistribution
  • Events
  • Handle voter compensation (& any unpaid surplus)
  • Escalation flow
  • Arbitrary targets

Design choices:

  • Actions are defined as bytes arrays and invoked using the call opcode pointed at the colony. An optional target allows for transactions to be executed against any contract, not just the colony.

  • Two classes of poll -- rootPoll and domainPoll. Root polls accept arbitrary bytes32 which can be executed by the extensions -- the simpler and more powerful implementation, with the limitation what all polls go to the entirety of the colony. Domain polls, on the other hand, can be held at, you guessed it, any domain in the colony, and can execute authDomain-ed functions only. Domain polls infer the "domain of action" by parsing the bytes32 action directly -- leveraging our convenient convention that the first two arguments of any domain-level permissioned function is (permissionDomainId, childSkillIndex), which means we can uniquely infer the domain from the action. With the domain of action, we can check that the domain of vote is in the inheritance hierarchy.

  • Escalation is implemented very simply as the requirement that new votes over the same variable have more "vote power" (total reputation) voting on it. Since (domain) reputation always aggregates up the tree, this has the nice property of allowing "escalation" to be either a re-vote in the original domain with higher turnout, or a vote in a parent domain, which by definition has more reputation in total. This requirement is restricted to votes on the setExpenditureState function, which is the general-purpose arbitration state change function (see Arbitration State Changes #760).

  • Staking occurs using the new stake-management system (see Add support for stake management #757).

  • One thing I am quite happy about is how the rate/reveal flow eliminates the need for a hasVoted mapping. A user can update their secret as many times as they want during the voting period, but since the secret can only be revealed once, there's no way to double-vote.

  • Stakers can stake on both sides if they choose. It is unlikely they will, of course, but the point is that it is not explicitly restricted.

  • Winning stakers get their entire stake back, plus a proportion of the loser's stake. Losing stakers pay the voter fees, and then get a proportion of their stake back. The proportion is a function of how close the vote was (e.g. winning with 60% of the vote gets you 20% of the losing side's stake, 120 - 100 = 20).

  • Any unspent voter compensation is returned back to stakers proportional to their contribution.

@kronosapiens kronosapiens self-assigned this Jun 13, 2019
@kronosapiens kronosapiens added this to the Sprint 28 milestone Jun 13, 2019
@kronosapiens
kronosapiens force-pushed the feat/voting branch 4 times, most recently from 0f57fca to 7871a3a Compare June 13, 2019 12:25
@elenadimitrova elenadimitrova removed this from the Sprint 28 milestone Jun 14, 2019
@kronosapiens
kronosapiens force-pushed the feat/voting branch 13 times, most recently from c254d5b to 5dad7af Compare June 21, 2019 08:42
@kronosapiens kronosapiens changed the title Token and Reputation Voting Reputation Voting Jun 21, 2019
@kronosapiens
kronosapiens force-pushed the feat/voting branch 3 times, most recently from a223bbf to eedc7ad Compare June 21, 2019 08:56
kronosapiens and others added 30 commits September 1, 2020 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants