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(x/gov): remove No With Veto, and set default pass threshold to 2/3 and quorum to 25% #9

Merged
merged 5 commits into from
Sep 17, 2024
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
21 changes: 3 additions & 18 deletions proto/atomone/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ enum VoteOption {
VOTE_OPTION_ABSTAIN = 2;
// VOTE_OPTION_NO defines a no vote option.
VOTE_OPTION_NO = 3;
// VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option.
VOTE_OPTION_NO_WITH_VETO = 4;
}

// WeightedVoteOption defines a unit of vote for vote split.
Expand Down Expand Up @@ -127,8 +125,6 @@ message TallyResult {
string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"];
// no_count is the number of no votes on a proposal.
string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"];
// no_with_veto_count is the number of no with veto votes on a proposal.
string no_with_veto_count = 4 [(cosmos_proto.scalar) = "cosmos.Int"];
}

// Vote defines a vote on a governance proposal.
Expand Down Expand Up @@ -173,12 +169,8 @@ message TallyParams {
// considered valid.
string quorum = 1 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
// Minimum proportion of Yes votes for proposal to pass. Default value: 2/3.
string threshold = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
string veto_threshold = 3 [(cosmos_proto.scalar) = "cosmos.Dec"];
}

// Params defines the parameters for the x/gov module.
Expand All @@ -196,16 +188,12 @@ message Params {
google.protobuf.Duration voting_period = 3 [(gogoproto.stdduration) = true];

// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
// considered valid. Default value: 0.25.
string quorum = 4 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
// Minimum proportion of Yes votes for proposal to pass. Default value: 2/3.
string threshold = 5 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
string veto_threshold = 6 [(cosmos_proto.scalar) = "cosmos.Dec"];

// The ratio representing the proportion of the deposit value that must be paid at proposal submission.
string min_initial_deposit_ratio = 7 [(cosmos_proto.scalar) = "cosmos.Dec"];

Expand All @@ -214,7 +202,4 @@ message Params {

// burn deposits if the proposal does not enter voting period
bool burn_proposal_deposit_prevote = 14;

// burn deposits if quorum with vote type no_veto is met
bool burn_vote_veto = 15;
}
4 changes: 2 additions & 2 deletions proto/atomone/gov/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ message TallyParams {
(gogoproto.jsontag) = "quorum,omitempty"
];

// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
// Minimum proportion of Yes votes for proposal to pass. Default value: 2/3.
bytes threshold = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "threshold,omitempty"
];

// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
// vetoed. Default value: 0 (disabled).
bytes veto_threshold = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *IntegrationTestSuite) GovSoftwareUpgrade() {
}

depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()}
voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes=0.8,no=0.1,abstain=0.05,no_with_veto=0.05"}
voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes=0.8,no=0.1,abstain=0.1"}
s.submitLegacyGovProposal(chainAAPIEndpoint, sender, proposalCounter, upgradetypes.ProposalTypeSoftwareUpgrade, submitGovFlags, depositGovFlags, voteGovFlags, "weighted-vote", true)

s.verifyChainHaltedAtUpgradeHeight(s.chainA, 0, proposalHeight)
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ func modifyGenesis(path, moniker, amountStr string, addrAll []sdk.AccAddress, de
govv1.NewParams(
sdk.NewCoins(sdk.NewCoin(denom, amnt)), maxDepositPeriod,
votingPeriod,
quorum.String(), threshold.String(), govv1.DefaultVetoThreshold.String(),
quorum.String(), threshold.String(),
sdk.ZeroDec().String(),
false, false, true,
false, false,
),
)
govGenStateBz, err := cdc.MarshalJSON(govGenState)
Expand Down
2 changes: 1 addition & 1 deletion x/gov/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ $ %s query gov params
vp := v1.NewVotingParams(res.Params.VotingPeriod)
res.VotingParams = &vp

tp := v1.NewTallyParams(res.Params.Quorum, res.Params.Threshold, res.Params.VetoThreshold)
tp := v1.NewTallyParams(res.Params.Quorum, res.Params.Threshold)
res.TallyParams = &tp

return clientCtx.PrintProto(res)
Expand Down
6 changes: 3 additions & 3 deletions x/gov/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func NewCmdVote() *cobra.Command {
cmd := &cobra.Command{
Use: "vote [proposal-id] [option]",
Args: cobra.ExactArgs(2),
Short: "Vote for an active proposal, options: yes/no/no_with_veto/abstain",
Short: "Vote for an active proposal, options: yes/no/abstain",
Long: strings.TrimSpace(
fmt.Sprintf(`Submit a vote for an active proposal. You can
find the proposal-id by running "%s query gov proposals".
Expand Down Expand Up @@ -327,13 +327,13 @@ func NewCmdWeightedVote() *cobra.Command {
cmd := &cobra.Command{
Use: "weighted-vote [proposal-id] [weighted-options]",
Args: cobra.ExactArgs(2),
Short: "Vote for an active proposal, options: yes/no/no_with_veto/abstain",
Short: "Vote for an active proposal, options: yes/no/abstain",
Long: strings.TrimSpace(
fmt.Sprintf(`Submit a vote for an active proposal. You can
find the proposal-id by running "%s query gov proposals".

Example:
$ %s tx gov weighted-vote 1 yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05 --from mykey
$ %s tx gov weighted-vote 1 yes=0.6,no=0.3,abstain=0.1 --from mykey
`,
version.AppName, version.AppName,
),
Expand Down
6 changes: 3 additions & 3 deletions x/gov/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *CLITestSuite) SetupSuite() {
s.Require().NoError(err)

// vote for proposal3 as val
_, err = govclitestutil.MsgVote(s.clientCtx, val[0].Address.String(), "3", "yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05")
_, err = govclitestutil.MsgVote(s.clientCtx, val[0].Address.String(), "3", "yes=0.6,no=0.3,abstain=0.1")
s.Require().NoError(err)
}

Expand Down Expand Up @@ -457,7 +457,7 @@ func (s *CLITestSuite) TestNewCmdWeightedVote() {
"invalid valid split vote string",
[]string{
"1",
"yes/0.6,no/0.3,abstain/0.05,no_with_veto/0.05",
"yes/0.6,no/0.3,abstain/0.1",
fmt.Sprintf("--%s=%s", flags.FlagFrom, val[0].Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
Expand All @@ -469,7 +469,7 @@ func (s *CLITestSuite) TestNewCmdWeightedVote() {
"valid split vote",
[]string{
"1",
"yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05",
"yes=0.6,no=0.3,abstain=0.1",
fmt.Sprintf("--%s=%s", flags.FlagFrom, val[0].Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
Expand Down
3 changes: 0 additions & 3 deletions x/gov/client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ func NormalizeVoteOption(option string) string {
case "No", "no":
return v1beta1.OptionNo.String()

case "NoWithVeto", "no_with_veto":
return v1beta1.OptionNoWithVeto.String()

default:
return option
}
Expand Down
12 changes: 6 additions & 6 deletions x/gov/client/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ func TestNormalizeWeightedVoteOptions(t *testing.T) {
normalized: "VOTE_OPTION_YES=0.5,VOTE_OPTION_NO=0.5",
},
"3 options": {
options: "Yes=0.5,No=0.4,NoWithVeto=0.1",
normalized: "VOTE_OPTION_YES=0.5,VOTE_OPTION_NO=0.4,VOTE_OPTION_NO_WITH_VETO=0.1",
options: "Yes=0.5,No=0.4,Abstain=0.1",
normalized: "VOTE_OPTION_YES=0.5,VOTE_OPTION_NO=0.4,VOTE_OPTION_ABSTAIN=0.1",
},
"zero weight option": {
options: "Yes=0.5,No=0.5,NoWithVeto=0",
normalized: "VOTE_OPTION_YES=0.5,VOTE_OPTION_NO=0.5,VOTE_OPTION_NO_WITH_VETO=0",
options: "Yes=0.5,No=0.5,Abstain=0",
normalized: "VOTE_OPTION_YES=0.5,VOTE_OPTION_NO=0.5,VOTE_OPTION_ABSTAIN=0",
},
"minus weight option": {
options: "Yes=0.5,No=0.6,NoWithVeto=-0.1",
normalized: "VOTE_OPTION_YES=0.5,VOTE_OPTION_NO=0.6,VOTE_OPTION_NO_WITH_VETO=-0.1",
options: "Yes=0.5,No=0.6,Abstain=-0.1",
normalized: "VOTE_OPTION_YES=0.5,VOTE_OPTION_NO=0.6,VOTE_OPTION_ABSTAIN=-0.1",
},
"empty options": {
options: "",
Expand Down
8 changes: 2 additions & 6 deletions x/gov/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (q Keeper) Params(c context.Context, req *v1.QueryParamsRequest) (*v1.Query
response.VotingParams = &votingParams

case v1.ParamTallying:
tallyParams := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold)
tallyParams := v1.NewTallyParams(params.Quorum, params.Threshold)
response.TallyParams = &tallyParams

default:
Expand Down Expand Up @@ -403,12 +403,8 @@ func (q legacyQueryServer) Params(c context.Context, req *v1beta1.QueryParamsReq
if err != nil {
return nil, err
}
vetoThreshold, err := sdk.NewDecFromStr(resp.TallyParams.VetoThreshold)
if err != nil {
return nil, err
}

response.TallyParams = v1beta1.NewTallyParams(quorum, threshold, vetoThreshold)
response.TallyParams = v1beta1.NewTallyParams(quorum, threshold, sdk.ZeroDec())
}

return response, nil
Expand Down
86 changes: 37 additions & 49 deletions x/gov/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() {
"tally params request",
func() {
req = &v1.QueryParamsRequest{ParamsType: v1.ParamTallying}
tallyParams := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold)
tallyParams := v1.NewTallyParams(params.Quorum, params.Threshold)
expRes = &v1.QueryParamsResponse{
TallyParams: &tallyParams,
}
Expand Down Expand Up @@ -1406,10 +1406,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
Id: 1,
Status: v1.StatusPassed,
FinalTallyResult: &v1.TallyResult{
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
NoWithVetoCount: "0",
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
},
SubmitTime: &propTime,
VotingStartTime: &propTime,
Expand All @@ -1421,10 +1420,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}

expTally = &v1.TallyResult{
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
NoWithVetoCount: "0",
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
}
},
true,
Expand All @@ -1446,10 +1444,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}

expTally = &v1.TallyResult{
YesCount: "0",
AbstainCount: "0",
NoCount: "0",
NoWithVetoCount: "0",
YesCount: "0",
AbstainCount: "0",
NoCount: "0",
}
},
true,
Expand All @@ -1471,10 +1468,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}

expTally = &v1.TallyResult{
YesCount: "0",
AbstainCount: "0",
NoCount: "0",
NoWithVetoCount: "0",
YesCount: "0",
AbstainCount: "0",
NoCount: "0",
}
},
true,
Expand All @@ -1487,10 +1483,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
Id: 1,
Status: v1.StatusFailed,
FinalTallyResult: &v1.TallyResult{
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
NoWithVetoCount: "0",
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
},
SubmitTime: &propTime,
VotingStartTime: &propTime,
Expand All @@ -1502,10 +1497,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}

expTally = &v1.TallyResult{
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
NoWithVetoCount: "0",
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
}
},
true,
Expand Down Expand Up @@ -1573,10 +1567,9 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
Id: 1,
Status: v1.StatusPassed,
FinalTallyResult: &v1.TallyResult{
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
NoWithVetoCount: "0",
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
},
SubmitTime: &propTime,
VotingStartTime: &propTime,
Expand All @@ -1588,10 +1581,9 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}

expTally = &v1beta1.TallyResult{
Yes: math.NewInt(4),
Abstain: math.NewInt(1),
No: math.NewInt(0),
NoWithVeto: math.NewInt(0),
Yes: math.NewInt(4),
Abstain: math.NewInt(1),
No: math.NewInt(0),
}
},
true,
Expand All @@ -1613,10 +1605,9 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}

expTally = &v1beta1.TallyResult{
Yes: math.NewInt(0),
Abstain: math.NewInt(0),
No: math.NewInt(0),
NoWithVeto: math.NewInt(0),
Yes: math.NewInt(0),
Abstain: math.NewInt(0),
No: math.NewInt(0),
}
},
true,
Expand All @@ -1638,10 +1629,9 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}

expTally = &v1beta1.TallyResult{
Yes: math.NewInt(0),
Abstain: math.NewInt(0),
No: math.NewInt(0),
NoWithVeto: math.NewInt(0),
Yes: math.NewInt(0),
Abstain: math.NewInt(0),
No: math.NewInt(0),
}
},
true,
Expand All @@ -1654,10 +1644,9 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
Id: 1,
Status: v1.StatusFailed,
FinalTallyResult: &v1.TallyResult{
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
NoWithVetoCount: "0",
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
},
SubmitTime: &propTime,
VotingStartTime: &propTime,
Expand All @@ -1669,10 +1658,9 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}

expTally = &v1beta1.TallyResult{
Yes: math.NewInt(4),
Abstain: math.NewInt(1),
No: math.NewInt(0),
NoWithVeto: math.NewInt(0),
Yes: math.NewInt(4),
Abstain: math.NewInt(1),
No: math.NewInt(0),
}
},
true,
Expand Down
Loading
Loading