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

ADR 037 Implementation: Governance Split Votes #7802

Merged
merged 47 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
da0c391
modify vote type on proto
antstalepresh Oct 27, 2020
09a282d
basic migration for SubVote type
antstalepresh Oct 27, 2020
c504784
Fix build errors and tests after struct modification
antstalepresh Oct 28, 2020
0cb2c70
add subvotes parser from string
antstalepresh Oct 29, 2020
7e87b5d
add cli, grpc, keeper test for new split vote
antstalepresh Oct 29, 2020
e7d3549
fix lint issues
antstalepresh Oct 29, 2020
fe0d0a5
add comment for SubVote proto
antstalepresh Oct 29, 2020
b3d86e1
update msg vote validate basic and test
antstalepresh Oct 29, 2020
a59ac3e
fix integration and rest test
antstalepresh Oct 29, 2020
73c757d
refactor SubVote to WeightedVoteOption && add utility for NewNonSplit…
antstalepresh Oct 30, 2020
5a08258
Remove Div operation on tally() considering sum(Weight)=1
antstalepresh Oct 30, 2020
ee1988a
split MsgVote and MsgWeightedVote for backwards compatibility
antstalepresh Nov 3, 2020
350f88c
fix lint issues
antstalepresh Nov 3, 2020
eb992a4
Merge branch 'master' of https://github.com/sikkatech/cosmos-sdk into…
antstalepresh Nov 3, 2020
381d1b0
fix deprecated function use after merging cosmos master
antstalepresh Nov 3, 2020
2671482
Merge pull request #39 from antstalepresh/gov_split_vote
antstalepresh Nov 4, 2020
138ae17
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Nov 6, 2020
e239504
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Nov 16, 2020
9635a99
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Nov 26, 2020
81bc447
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Jan 10, 2021
5b0b323
remove old adr
sunnya97 Jan 10, 2021
a517c6b
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Jan 12, 2021
ba96bbe
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Jan 13, 2021
99c7a2c
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Jan 19, 2021
3edb714
simapp: add testnet instructions (#8342)
tessr Jan 18, 2021
21575b0
fix: wrappedError.Is (#8355)
robert-zaremba Jan 18, 2021
48006b4
x/bank: client denom metadata gRPC (#8317)
fedekunze Jan 18, 2021
0460f98
gRPC-web proxy (#8077)
aleem1314 Jan 18, 2021
116769b
Add missing unpack interfaces functions to IBC (#8359)
colin-axner Jan 18, 2021
72572ba
Update changelog (#8371)
colin-axner Jan 19, 2021
420037c
proto: docker deployment (#8367)
tac0turtle Jan 19, 2021
4279f3c
update to tendermint v0.34.3 (#8388)
Jan 19, 2021
cc15a2d
GetClientContextFromCmd -> GetClientTxContext
sunnya97 Jan 19, 2021
e94018a
fix merge bugs
sunnya97 Jan 19, 2021
be40971
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Jan 19, 2021
56ed27a
use @aaronc's suggested proto upgrade method
sunnya97 Jan 22, 2021
b125fcc
MsgWeightedVote -> MsgVoteWeighted
sunnya97 Jan 25, 2021
b55913d
fix comments and add CHANGELOG
antstalepresh Feb 5, 2021
404dc4f
Merge branch 'master' of github.com:sikkatech/cosmos-sdk into gov_spl…
antstalepresh Feb 5, 2021
46d6fa0
fix simulation test, marshal json process
antstalepresh Feb 5, 2021
157a246
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Feb 9, 2021
065c1b3
Apply suggestions from code review
sunnya97 Feb 10, 2021
ac16c90
remove legacy rest endpoints as per @anilCSE
sunnya97 Feb 12, 2021
47f7502
Merge branch 'master' into gov_split_vote_weighted_vote
sunnya97 Feb 12, 2021
8847157
Update x/gov/client/utils/utils.go
sunnya97 Feb 12, 2021
188a8a2
import hygiene
sunnya97 Feb 12, 2021
a417b51
update CHANGELOG
sunnya97 Feb 12, 2021
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 @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/{bank,distrib,gov,slashing,staking}) [\#8363](https://github.com/cosmos/cosmos-sdk/issues/8363) Store keys have been modified to allow for variable-length addresses.
* (x/ibc) [\#8266](https://github.com/cosmos/cosmos-sdk/issues/8266) Add amino JSON for IBC messages in order to support Ledger text signing.
* (x/evidence) [\#8502](https://github.com/cosmos/cosmos-sdk/pull/8502) `HandleEquivocationEvidence` persists the evidence to state.
* (x/gov) [\#7733](https://github.com/cosmos/cosmos-sdk/pull/7733) ADR 037 Implementation: Governance Split Votes

### Improvements

Expand Down
8 changes: 4 additions & 4 deletions docs/architecture/adr-037-gov-split-vote.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Status

Proposed
Accepted

## Abstract

Expand Down Expand Up @@ -35,22 +35,22 @@ type Vote struct {
}
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
```

And for backwards compatibility, we introduce `MsgWeightedVote` while keeping `MsgVote`.
And for backwards compatibility, we introduce `MsgVoteWeighted` while keeping `MsgVote`.
```
type MsgVote struct {
ProposalID int64
Voter sdk.Address
Option Option
}

type MsgWeightedVote struct {
type MsgVoteWeighted struct {
ProposalID int64
Voter sdk.Address
Options []WeightedVoteOption
}
```

The `ValidateBasic` of a `MsgWeightedVote` struct would require that
The `ValidateBasic` of a `MsgVoteWeighted` struct would require that
1. The sum of all the Rates is equal to 1.0
2. No Option is repeated

Expand Down
49 changes: 48 additions & 1 deletion docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
- [TextProposal](#cosmos.gov.v1beta1.TextProposal)
- [Vote](#cosmos.gov.v1beta1.Vote)
- [VotingParams](#cosmos.gov.v1beta1.VotingParams)
- [WeightedVoteOption](#cosmos.gov.v1beta1.WeightedVoteOption)

- [ProposalStatus](#cosmos.gov.v1beta1.ProposalStatus)
- [VoteOption](#cosmos.gov.v1beta1.VoteOption)
Expand Down Expand Up @@ -336,6 +337,8 @@
- [MsgSubmitProposalResponse](#cosmos.gov.v1beta1.MsgSubmitProposalResponse)
- [MsgVote](#cosmos.gov.v1beta1.MsgVote)
- [MsgVoteResponse](#cosmos.gov.v1beta1.MsgVoteResponse)
- [MsgVoteWeighted](#cosmos.gov.v1beta1.MsgVoteWeighted)
- [MsgVoteWeightedResponse](#cosmos.gov.v1beta1.MsgVoteWeightedResponse)

- [Msg](#cosmos.gov.v1beta1.Msg)

Expand Down Expand Up @@ -4587,7 +4590,7 @@ A Vote consists of a proposal ID, the voter, and the vote option.
| ----- | ---- | ----- | ----------- |
| `proposal_id` | [uint64](#uint64) | | |
| `voter` | [string](#string) | | |
| `option` | [VoteOption](#cosmos.gov.v1beta1.VoteOption) | | |
| `options` | [WeightedVoteOption](#cosmos.gov.v1beta1.WeightedVoteOption) | repeated | |



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




<a name="cosmos.gov.v1beta1.WeightedVoteOption"></a>

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


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





<!-- end messages -->


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




<a name="cosmos.gov.v1beta1.MsgVoteWeighted"></a>

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


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






<a name="cosmos.gov.v1beta1.MsgVoteWeightedResponse"></a>

### MsgVoteWeightedResponse
MsgVoteWeightedResponse defines the MsgVoteWeighted response type.





<!-- end messages -->

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

<!-- end services -->
Expand Down
18 changes: 15 additions & 3 deletions proto/cosmos/gov/v1beta1/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/cosmos/cosmos-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,11 @@ 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;
reserved 3;
reserved "option";
repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false];
}

// DepositParams defines the params for deposits on governance proposals.
Expand Down
18 changes: 18 additions & 0 deletions proto/cosmos/gov/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ service Msg {
// Vote defines a method to add a vote on a specific proposal.
rpc Vote(MsgVote) returns (MsgVoteResponse);

// WeightedVote defines a method to add a weighted vote on a specific proposal.
rpc VoteWeighted(MsgVoteWeighted) returns (MsgVoteWeightedResponse);

// Deposit defines a method to add deposit on a specific proposal.
rpc Deposit(MsgDeposit) returns (MsgDepositResponse);
}
Expand Down Expand Up @@ -55,9 +58,24 @@ message MsgVote {
VoteOption option = 3;
}

// MsgVote defines a message to cast a vote.
message MsgVoteWeighted {
option (gogoproto.equal) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.stringer) = false;
option (gogoproto.goproto_getters) = false;

uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""];
string voter = 2;
repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false];
}

// MsgVoteResponse defines the Msg/Vote response type.
message MsgVoteResponse {}

// MsgVoteWeightedResponse defines the Msg/VoteWeighted response type.
message MsgVoteWeightedResponse {}

// MsgDeposit defines a message to submit a deposit to an existing proposal.
message MsgDeposit {
option (gogoproto.equal) = false;
Expand Down
1 change: 1 addition & 0 deletions simapp/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
DefaultWeightMsgFundCommunityPool int = 50
DefaultWeightMsgDeposit int = 100
DefaultWeightMsgVote int = 67
DefaultWeightMsgVoteWeighted int = 33
DefaultWeightMsgUnjail int = 100
DefaultWeightMsgCreateValidator int = 100
DefaultWeightMsgEditValidator int = 5
Expand Down
4 changes: 2 additions & 2 deletions x/gov/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
deposits := initialModuleAccCoins.Add(proposal.TotalDeposit...).Add(proposalCoins...)
require.True(t, moduleAccCoins.IsEqual(deposits))

err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.OptionYes)
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
require.NoError(t, err)

newHeader := ctx.BlockHeader()
Expand Down Expand Up @@ -348,7 +348,7 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) {

handleAndCheck(t, gov.NewHandler(app.GovKeeper), ctx, newDepositMsg)

err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.OptionYes)
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
require.NoError(t, err)

newHeader := ctx.BlockHeader()
Expand Down
Loading