Open drewstone opened 5 years ago
Okay, so would love to get feedback from anyone. This approach may be unnecessarily complex but I can think of certain runarounds to the problem below.
Lets say there are 3 voters: A
, B
, and C
. Each voter has 10 votes. For clarity, I'm using the notation where a tuple (X, Y, w) indicates voter X
delegates percentage w
of votes to voter Y
. There is a problem in converting leftover delegated votes since they don't evenly split.
For example:
(A, B, 20)
(A, C, 30)
(B, C, 40)
This results in:
A
has 5 votesB
has 7.2 votesC
has 17.8 votesThe question is, weighting doesn't really act nicely. What are alternatives?
Do votes need to be atomic, in the sense that someone can't cast, say, 0.2 votes to A and 0.8 votes to B?
So something that I haven't verified but think is true (as it is with Ethereum) is that there are no decimal types on these blockchain virtual machines. Therefore, we need to stick to integer units.
Now, decimals of ether are understood because 1 ether = 1e18 wei
. I'm not exactly sure what our lowest denomination will be but I will assume that it translates to a vote so that fractional votes don't actually make sense. If the amount of votes is sufficiently large then we can use fractions because they'll resolve to integers but that would be a special case.
When we initialize the runtime, we can set the units when setting balance. So @drewstone previous comment is right. We'd have "fractional" EDG votes, but not fractional votes as defined.
Now that I think about it, this is an issue that should be ironed out at the UI level first -- what experience/interface do we want users to have, and then how do we represent that?
So, we should probably rope in @raykyri.
Overview
With delegation in place, we want modules to consume it. Notably, we want modules that be able to get the respective voting power that each user has with respect to the individuals they are delegating against.
Design
Given a set of accounts, we want to return a tuple
(A, Vec<Ai>, Vec<Wi>)
that contains:Computing the amount of votes to give just involves taking some
vote_count
and running over the set of delegators, multiplying the respectiveWi * vote_count
to yield the number of votes forAi
.