johnson86tw / quadratic-voting-contracts

Ethereum smart contracts for building QV applications on MACI.
GNU General Public License v3.0
7 stars 1 forks source link

Problems of designing voice credit #4

Open johnson86tw opened 2 years ago

johnson86tw commented 2 years ago

The main problem is that the user’s voice credit balance is reset to the same number for each new poll. Because users get voice credits in the sign up process, the sign up state will not change when MACI deploys a new poll. So there is no room for us to change the voice credit balance in each different poll. If we want to change it, currently we have to deploy another maci contract every time for the next poll.

Case 1: Allow the owner set the initial voice credit balance before each round of poll.

In this case, If the owner wants to change the voice credit balance, the owner should deploy another maci contract for the next poll. Otherwise, voters can get voice credit in poll id 1 as the number in the last poll.

See https://github.com/chnejohnson/quadratic-voting-contracts/blob/main/contracts/voiceCredit/AdjustableVoiceCredit.sol for the implementation intention.

Case 2: Allow a specific ERC20 token to be capable of converting into a number of voice credits.

In this case, If we want to bind an ERC20 token to voice credit, we can only use poll id 0 and should deploy another maci contract for the next poll. Otherwise, voters can get voice credit in poll id 1 as the number in the last poll but without any payment.

See https://github.com/chnejohnson/quadratic-voting-contracts/blob/main/contracts/voiceCredit/TradableVoiceCredit.sol for the implementation intention.

Proposed Solution

Following is my rough solution for the above problem: https://github.com/chnejohnson/maci/commit/92f0ac96c5106141335846d324e868a28fcad499

The idea is to move the getVoiceCredits function from MACI to Poll, and add a mapping to link stateIndex to voiceCreditBalance. So the off-chain computation can get the voice credit balance by state index.

Downsides

daodesigner commented 2 years ago

looks good with the exception of https://github.com/chnejohnson/maci/commit/92f0ac96c5106141335846d324e868a28fcad499 , top ups require some changes to circuits Cory is working on https://github.com/appliedzkp/maci/pull/411