DemocracyEarth / old_dapp

Liquid democracy smart contract implementation
32 stars 13 forks source link

Implement basic delegate() function #13

Closed medied closed 6 years ago

medied commented 6 years ago

This feature can take from PR #7. Implementation must come with its respective tests in the corresponding test file

aecc commented 6 years ago

I'll be writing here some possible requirements for delegation:

A. Glossary:

  1. Delegation: one voter giving its voting power to another voter
  2. Representative: receiving part of a delegation (Representee ---> Representative)
  3. Representee: giving part of a delegation (Representee ---> Representative)

B. Initial assumptions:

  1. Every voter has a single unit of voting power, it can delegate it to another voter, or keep it
  2. Delegations are publicly visible for any voter
  3. No GAS optimizations are done, however it should be stated every time a decision of arguably big GAS consumption is made
  4. Cycles-capability is not possible

C. Functional Requirements:

  1. Only registered voters can delegate
  2. Every registered voter can receive delegations
  3. For simplicity, every voter has a delegation
  4. For simplicity, initially, a voter delegates to itself (a loop is made)
  5. A voter delegates exactly 1 vote of its own.
  6. A voter can receive delegation from [1 to n] voters. n has no upper bound
  7. A voter can transitively delegate x votes from representees.

D. Non-functional requirements:

  1. It's necessary to be able to fetch the status of all the delegations (voting power of every voter) just by reading the blockchain (no transaction should be made to compute the whole delegation)
  2. Every time a delegation is changed, a transaction should be made to the blockchain and all the delegations should be recomputed (this is probably very expensive, and unfair as it will be more costly for delegations made later than others)
aecc commented 6 years ago

@medied let's discuss things here that could be changed/improved from the proposed requirements, and after we agree on each point I'll make changes to the original requirements

medied commented 6 years ago

Looks good @aecc, glad we went over it. I went ahead and created a similar spec the same for #11

aecc commented 6 years ago

@medied I just added B.4 . Something that will not be implemented in this PR. I managed to make cycles work on the previous implementation of Delegation.sol . I'll create it on another issue to encourage the resolution of smaller tasks/issues

virgile-dev commented 6 years ago

Hey guys, @medied @aecc

Just read this from Alessandro's post.

Every time a delegation is changed, a transaction should be made to the blockchain and all the delegations should be recomputed (this is probably very expensive, and unfair as it will be more costly for delegations made later than others)

I was wondering if this wasn't the right time to start thinking of what happens on chain vs off chain. Here is a few thoughts I had written down, (Santi went over it).


The client will interact with a smart contract library that will move around the vote token and settle transaction in the blockchain. We want things to move fast even if operating with a blockchain. For that we should consider what happens off-chain and on-chain.

medied commented 6 years ago

Thanks @virgile-dev. This is relevant to #16 which will be part of our next v0.1.1 milestone. We need to sync and talk about what goes in the next milestone, let's start in the sprint sync today.

aecc commented 6 years ago

@virgile-dev @medied while I agree with separating responsibilities in off-chain / on-chain categories, I think we are still quite far from it. We should aim at the moment for a 100% working product on-chain. Off-chain development adds other levels of complexity, for starters there is no standard SDKs or programming languages for off-chain solutions. We need to strongly familiarize ourselves with the technology before we can start building something off-chain.