Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Governance: vote options #2544

Merged
merged 57 commits into from
Nov 11, 2021
Merged

Governance: vote options #2544

merged 57 commits into from
Nov 11, 2021

Conversation

SebastianBor
Copy link
Contributor

@SebastianBor SebastianBor commented Oct 25, 2021

Summary

This change adds support for multi option voting and survey only proposals. The following voting systems were implemented:

  • Single choice voting - each voter may select only one choice from multiple options
  • Multi choice voting - each voter may select multiple choices from multiple options

Each proposal can either be executable or non executable (survey only). The executable proposals can have instructions associated with different options and always have Deny option which allows to down vote the proposal and prevent execution of the instructions.
When multiple choice executable proposal is voted on each option is considered individually and can either success or fail and hence only a subset of successful options can be executed after vote on the proposal ends.

Implementation details

The voting system was generalised to multi option voting and the legacy Yes/No vote system is now implemented as a specific use case: SingleChoice vote with Yes only option and Deny (No) option.

Legacy V1 accounts are fully supported through in/out serialisation transformations.

Out of the scope

Support for 1) Weighted voting 2) Quadratic voting and 3) Ranked voting was added to the account structures but not implemented in this PR

@SebastianBor SebastianBor marked this pull request as ready for review October 29, 2021 10:24
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great work! No big showstoppers as far as I can see, just one question about backwards compatibility and some nits

governance/program/src/instruction.rs Show resolved Hide resolved
governance/program/src/processor/process_cast_vote.rs Outdated Show resolved Hide resolved
governance/program/src/state/legacy.rs Show resolved Hide resolved
governance/program/src/state/proposal.rs Outdated Show resolved Hide resolved
governance/program/src/state/proposal.rs Outdated Show resolved Hide resolved
governance/program/src/state/proposal_instruction.rs Outdated Show resolved Hide resolved
governance/program/src/state/proposal_instruction.rs Outdated Show resolved Hide resolved
governance/program/src/state/vote_record.rs Outdated Show resolved Hide resolved
@@ -1207,6 +1217,25 @@ impl GovernanceProgramTest {
.await
}

#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not specific to this line, but I'm having a tough time seeing -- are you running any basic tests creating / voting on v1 structs? If you'll have outstanding v1 proposals still being voted on, it'll be good as a sanity check to add these if they aren't there.

I'm mainly bringing this up because I'm worried about the PDA change on the proposal instruction account for existing v1 proposals.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still working on these tests. What is the best approach here? Load the old program, create accounts and then upgrade or we can somehow fake the V1 accounts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking you'd fake the v1 accounts by hand, but that might be extremely annoying in your case... anyway, not a show-stopper by any means

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@SebastianBor SebastianBor merged commit bf7ad18 into solana-labs:master Nov 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants