Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gov/weighted-vote #368

Merged
merged 2 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features
* (feat) [\#352] (https://github.com/line/lbm-sdk/pull/352) iavl, db & disk stats logging
* (x/gov) [\#368](https://github.com/line/lbm-sdk/pull/368) Governance Split Votes, use `MsgWeightedVote` to send a split vote. Sending a regular `MsgVote` will convert the underlying vote option into a weighted vote with weight 1.

### Improvements
* (slashing) [\#347](https://github.com/line/lbm-sdk/pull/347) Introduce VoterSetCounter
Expand Down
167 changes: 161 additions & 6 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13467,6 +13467,29 @@ paths:
voter:
type: string
option:
description: >-
Deprecated: Prefer to use `options` instead. This field
is set in queries

if and only if `len(options) == 1` and that option has
weight 1. In all

other cases, this field will default to
VOTE_OPTION_UNSPECIFIED.
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
- VOTE_OPTION_YES
- VOTE_OPTION_ABSTAIN
- VOTE_OPTION_NO
- VOTE_OPTION_NO_WITH_VETO
default: VOTE_OPTION_UNSPECIFIED
options:
type: array
items:
type: object
properties:
option:
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
Expand All @@ -13476,14 +13499,19 @@ paths:
- VOTE_OPTION_NO_WITH_VETO
default: VOTE_OPTION_UNSPECIFIED
description: >-
VoteOption enumerates the valid vote options for a given
governance proposal.
VoteOption enumerates the valid vote options for a
given governance proposal.

- VOTE_OPTION_UNSPECIFIED: VOTE_OPTION_UNSPECIFIED defines a no-op vote option.
- VOTE_OPTION_YES: VOTE_OPTION_YES defines a yes vote option.
- VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option.
- VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option.
- VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option.
weight:
type: string
description: >-
WeightedVoteOption defines a unit of vote for vote
split.
description: >-
Vote defines a vote on a governance proposal.

Expand Down Expand Up @@ -13775,6 +13803,29 @@ paths:
voter:
type: string
option:
description: >-
Deprecated: Prefer to use `options` instead. This field is
set in queries

if and only if `len(options) == 1` and that option has
weight 1. In all

other cases, this field will default to
VOTE_OPTION_UNSPECIFIED.
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
- VOTE_OPTION_YES
- VOTE_OPTION_ABSTAIN
- VOTE_OPTION_NO
- VOTE_OPTION_NO_WITH_VETO
default: VOTE_OPTION_UNSPECIFIED
options:
type: array
items:
type: object
properties:
option:
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
Expand All @@ -13784,14 +13835,19 @@ paths:
- VOTE_OPTION_NO_WITH_VETO
default: VOTE_OPTION_UNSPECIFIED
description: >-
VoteOption enumerates the valid vote options for a given
governance proposal.
VoteOption enumerates the valid vote options for a
given governance proposal.

- VOTE_OPTION_UNSPECIFIED: VOTE_OPTION_UNSPECIFIED defines a no-op vote option.
- VOTE_OPTION_YES: VOTE_OPTION_YES defines a yes vote option.
- VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option.
- VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option.
- VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option.
weight:
type: string
description: >-
WeightedVoteOption defines a unit of vote for vote
split.
description: >-
Vote defines a vote on a governance proposal.

Expand Down Expand Up @@ -42262,6 +42318,28 @@ definitions:
voter:
type: string
option:
description: >-
Deprecated: Prefer to use `options` instead. This field is set in
queries

if and only if `len(options) == 1` and that option has weight 1.
In all

other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
- VOTE_OPTION_YES
- VOTE_OPTION_ABSTAIN
- VOTE_OPTION_NO
- VOTE_OPTION_NO_WITH_VETO
default: VOTE_OPTION_UNSPECIFIED
options:
type: array
items:
type: object
properties:
option:
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
Expand All @@ -42279,6 +42357,9 @@ definitions:
- VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option.
- VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option.
- VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option.
weight:
type: string
description: WeightedVoteOption defines a unit of vote for vote split.
description: |-
Vote defines a vote on a governance proposal.
A Vote consists of a proposal ID, the voter, and the vote option.
Expand All @@ -42297,6 +42378,28 @@ definitions:
voter:
type: string
option:
description: >-
Deprecated: Prefer to use `options` instead. This field is set
in queries

if and only if `len(options) == 1` and that option has weight 1.
In all

other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
- VOTE_OPTION_YES
- VOTE_OPTION_ABSTAIN
- VOTE_OPTION_NO
- VOTE_OPTION_NO_WITH_VETO
default: VOTE_OPTION_UNSPECIFIED
options:
type: array
items:
type: object
properties:
option:
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
Expand All @@ -42314,6 +42417,9 @@ definitions:
- VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option.
- VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option.
- VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option.
weight:
type: string
description: WeightedVoteOption defines a unit of vote for vote split.
description: |-
Vote defines a vote on a governance proposal.
A Vote consists of a proposal ID, the voter, and the vote option.
Expand Down Expand Up @@ -42380,6 +42486,28 @@ definitions:
voter:
type: string
option:
description: >-
Deprecated: Prefer to use `options` instead. This field is set in
queries

if and only if `len(options) == 1` and that option has weight 1. In
all

other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
- VOTE_OPTION_YES
- VOTE_OPTION_ABSTAIN
- VOTE_OPTION_NO
- VOTE_OPTION_NO_WITH_VETO
default: VOTE_OPTION_UNSPECIFIED
options:
type: array
items:
type: object
properties:
option:
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
Expand All @@ -42389,14 +42517,17 @@ definitions:
- VOTE_OPTION_NO_WITH_VETO
default: VOTE_OPTION_UNSPECIFIED
description: >-
VoteOption enumerates the valid vote options for a given governance
proposal.
VoteOption enumerates the valid vote options for a given
governance proposal.

- VOTE_OPTION_UNSPECIFIED: VOTE_OPTION_UNSPECIFIED defines a no-op vote option.
- VOTE_OPTION_YES: VOTE_OPTION_YES defines a yes vote option.
- VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option.
- VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option.
- VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option.
weight:
type: string
description: WeightedVoteOption defines a unit of vote for vote split.
description: |-
Vote defines a vote on a governance proposal.
A Vote consists of a proposal ID, the voter, and the vote option.
Expand Down Expand Up @@ -42425,6 +42556,30 @@ definitions:
type: string
description: Length of the voting period.
description: VotingParams defines the params for voting on governance proposals.
lbm.gov.v1.WeightedVoteOption:
type: object
properties:
option:
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
- VOTE_OPTION_YES
- VOTE_OPTION_ABSTAIN
- VOTE_OPTION_NO
- VOTE_OPTION_NO_WITH_VETO
default: VOTE_OPTION_UNSPECIFIED
description: >-
VoteOption enumerates the valid vote options for a given governance
proposal.

- VOTE_OPTION_UNSPECIFIED: VOTE_OPTION_UNSPECIFIED defines a no-op vote option.
- VOTE_OPTION_YES: VOTE_OPTION_YES defines a yes vote option.
- VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option.
- VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option.
- VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option.
weight:
type: string
description: WeightedVoteOption defines a unit of vote for vote split.
lbm.mint.v1.Params:
type: object
properties:
Expand Down
50 changes: 49 additions & 1 deletion docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@
- [TextProposal](#lbm.gov.v1.TextProposal)
- [Vote](#lbm.gov.v1.Vote)
- [VotingParams](#lbm.gov.v1.VotingParams)
- [WeightedVoteOption](#lbm.gov.v1.WeightedVoteOption)

- [ProposalStatus](#lbm.gov.v1.ProposalStatus)
- [VoteOption](#lbm.gov.v1.VoteOption)
Expand Down Expand Up @@ -503,6 +504,8 @@
- [MsgSubmitProposalResponse](#lbm.gov.v1.MsgSubmitProposalResponse)
- [MsgVote](#lbm.gov.v1.MsgVote)
- [MsgVoteResponse](#lbm.gov.v1.MsgVoteResponse)
- [MsgVoteWeighted](#lbm.gov.v1.MsgVoteWeighted)
- [MsgVoteWeightedResponse](#lbm.gov.v1.MsgVoteWeightedResponse)

- [Msg](#lbm.gov.v1.Msg)

Expand Down Expand Up @@ -7107,7 +7110,8 @@ A Vote consists of a proposal ID, the voter, and the vote option.
| ----- | ---- | ----- | ----------- |
| `proposal_id` | [uint64](#uint64) | | |
| `voter` | [string](#string) | | |
| `option` | [VoteOption](#lbm.gov.v1.VoteOption) | | |
| `option` | [VoteOption](#lbm.gov.v1.VoteOption) | | **Deprecated.** Deprecated: Prefer to use `options` instead. This field is set in queries if and only if `len(options) == 1` and that option has weight 1. In all other cases, this field will default to VOTE_OPTION_UNSPECIFIED. |
| `options` | [WeightedVoteOption](#lbm.gov.v1.WeightedVoteOption) | repeated | |



Expand All @@ -7128,6 +7132,22 @@ VotingParams defines the params for voting on governance proposals.




<a name="lbm.gov.v1.WeightedVoteOption"></a>

### WeightedVoteOption
WeightedVoteOption defines a unit of vote for vote split.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `option` | [VoteOption](#lbm.gov.v1.VoteOption) | | |
| `weight` | [string](#string) | | |





<!-- end messages -->


Expand Down Expand Up @@ -7585,6 +7605,33 @@ MsgVoteResponse defines the Msg/Vote response type.




<a name="lbm.gov.v1.MsgVoteWeighted"></a>

### MsgVoteWeighted
MsgVoteWeighted defines a message to cast a vote.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `proposal_id` | [uint64](#uint64) | | |
| `voter` | [string](#string) | | |
| `options` | [WeightedVoteOption](#lbm.gov.v1.WeightedVoteOption) | repeated | |






<a name="lbm.gov.v1.MsgVoteWeightedResponse"></a>

### MsgVoteWeightedResponse
MsgVoteWeightedResponse defines the Msg/VoteWeighted response type.





<!-- end messages -->

<!-- end enums -->
Expand All @@ -7601,6 +7648,7 @@ Msg defines the bank Msg service.
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `SubmitProposal` | [MsgSubmitProposal](#lbm.gov.v1.MsgSubmitProposal) | [MsgSubmitProposalResponse](#lbm.gov.v1.MsgSubmitProposalResponse) | SubmitProposal defines a method to create new proposal given a content. | |
| `Vote` | [MsgVote](#lbm.gov.v1.MsgVote) | [MsgVoteResponse](#lbm.gov.v1.MsgVoteResponse) | Vote defines a method to add a vote on a specific proposal. | |
| `VoteWeighted` | [MsgVoteWeighted](#lbm.gov.v1.MsgVoteWeighted) | [MsgVoteWeightedResponse](#lbm.gov.v1.MsgVoteWeightedResponse) | VoteWeighted defines a method to add a weighted vote on a specific proposal. | |
| `Deposit` | [MsgDeposit](#lbm.gov.v1.MsgDeposit) | [MsgDepositResponse](#lbm.gov.v1.MsgDepositResponse) | Deposit defines a method to add deposit on a specific proposal. | |

<!-- end services -->
Expand Down
20 changes: 17 additions & 3 deletions proto/lbm/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ enum VoteOption {
VOTE_OPTION_NO_WITH_VETO = 4 [(gogoproto.enumvalue_customname) = "OptionNoWithVeto"];
}

// WeightedVoteOption defines a unit of vote for vote split.
message WeightedVoteOption {
VoteOption option = 1;
string weight = 2 [
(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"weight\""
];
}

// TextProposal defines a standard text proposal whose changes need to be
// manually updated in case of approval.
message TextProposal {
Expand Down Expand Up @@ -119,9 +129,13 @@ message Vote {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = false;

uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""];
string voter = 2;
VoteOption option = 3;
uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""];
string voter = 2;
// Deprecated: Prefer to use `options` instead. This field is set in queries
// if and only if `len(options) == 1` and that option has weight 1. In all
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
VoteOption option = 3 [deprecated = true];
repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false];
}

// DepositParams defines the params for deposits on governance proposals.
Expand Down
Loading