hyperledger-labs / blockchain-carbon-accounting

This project implements blockchain applications for climate action and accounting, including emissions calculations, carbon trading, and validation of climate claims. It is part of the Linux Foundation's Hyperledger Climate Action and Accounting SIG.
https://wiki.hyperledger.org/display/CASIG/Carbon+Accounting+and+Certification+WG
Apache License 2.0
195 stars 104 forks source link

break up proposal into votes on attributes of proposals #117

Closed sichen1234 closed 3 years ago

sichen1234 commented 3 years ago

For example, carbon offset projects have a series of attributes, such as Real, Additional, Realistic Baselines, Permanent, Adequate Leakage Accounting.

So you can vote for the proposal or put all your votes for/against an attribute of the proposal. For example, you can vote 100 dCLM8 tokens on a carbon offset proposal, which will count as 20 votes on each point. Or you can vote all 100 tokens on 1 particular attribute, such as additionality, and it will count as 100 votes on additionality.

(With #114 quadratic voting it voting 20 tokens will count as 4.47 votes, and voting 100 tokens will count as 10 votes.)

sichen1234 commented 3 years ago

See https://wiki.hyperledger.org/display/CASIG/DAO+Project for the latest:

Proposals can be broken up into attributes, so you can either vote on the proposal as a whole, which is the same as splitting your vote equally on all its attributes, or cast all your votes on one attribute of it. When proposals are split into attributes:

Right now to keep things simple, all offsets projects should have the attributes of Real, Additional, Realistic Baselines, Permanent, Adequate Leakage Accounting when they are created, so you can vote on all or some of those attributes on the voting page.

sichen1234 commented 3 years ago

My recommendation here is to keep the way the Proposal works, but make a sub-proposal so that an attribute could be a proposal that is a sub-proposal of another proposal.

In the Governor there should be new attributes for the Proposal which are

  1. parentProposalId - for sub-proposals to identify the parent
  2. subProposals [] - ids of all the sub-proposals of the parent

Then there could be a new function in Governor to makeMultiAttributeProposal which will

  1. take an array [] of proposal attributes
  2. call propose to make the parent proposal first
  3. loop through to call propose to make each attribute of the proposal
  4. store the subProposalId in the parent and the parentProposalid in the sub proposals

In Governor.propose we can remove the threshold checking for sub proposals, ie proposals with a parent proposal id.

Also we can in general remove the restriction of one proposal at a time. We do not have this requirement.

In the castVote function, if there are subProposals and the vote is cast on a parent proposal ID, then it just splits the votes and casts them on all the sub proposals. If there is no sub proposal id (ie a proposal without attributes or a sub proposal) it just casts it on the proposal.

In the Governor.state method you could check what kind of proposal it is:

  1. If it has no sub proposals and no parent proposal, then it should work like now.
  2. If it has a parent proposal, then it's a sub proposal. In that case, it's passed or failed based on the votes cast for it. there is no quorum for sub proposals.
  3. If it has sub proposals, then add up all the votes for and against of all the sub proposals. This is used to calculate the quorum. If it passes quorum, then it passes if all the sub proposals pass based on 2 above. Otherwise if any sub proposal fails it fails.
sichen1234 commented 3 years ago

For UI, setting up attributes of proposal can be done by the create-proposal. It can just automatically call makeMultiAttributeProposal to create an array [] of sub-proposals for the attributes of a carbon offset.

Then when displaying proposals with attributes, it can display each attribute with a vote for/against button, and the vote for/against button at the bottom for proposal as a whole.