Skip to content

Commit

Permalink
feat!: upstream expedited proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored and MSalopek committed Jun 13, 2024
1 parent 14f041a commit d0b67d8
Show file tree
Hide file tree
Showing 51 changed files with 1,942 additions and 707 deletions.
666 changes: 527 additions & 139 deletions api/cosmos/gov/v1/gov.pulsar.go

Large diffs are not rendered by default.

318 changes: 207 additions & 111 deletions api/cosmos/gov/v1/tx.pulsar.go

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion proto/cosmos/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ message Proposal {
// Since: cosmos-sdk 0.47
string summary = 12;

// Proposer is the address of the proposal sumbitter
// proposer is the address of the proposal sumbitter
//
// Since: cosmos-sdk 0.47
string proposer = 13 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// expedited defines if the proposal is expedited
//
// Since: cosmos-sdk 0.48
bool expedited = 14;
}

// ProposalStatus enumerates the valid statuses of a proposal.
Expand Down Expand Up @@ -151,6 +156,8 @@ message Vote {

// DepositParams defines the params for deposits on governance proposals.
message DepositParams {
option deprecated = true;

// Minimum deposit for a proposal to enter voting period.
repeated cosmos.base.v1beta1.Coin min_deposit = 1
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "min_deposit,omitempty"];
Expand All @@ -163,12 +170,16 @@ message DepositParams {

// VotingParams defines the params for voting on governance proposals.
message VotingParams {
option deprecated = true;

// Duration of the voting period.
google.protobuf.Duration voting_period = 1 [(gogoproto.stdduration) = true];
}

// TallyParams defines the params for tallying votes on governance proposals.
message TallyParams {
option deprecated = true;

// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
string quorum = 1 [(cosmos_proto.scalar) = "cosmos.Dec"];
Expand Down Expand Up @@ -209,6 +220,22 @@ message Params {
// 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"];

// Duration of the voting period of an expedited proposal.
//
// NOTE: backported from v50 (https://github.com/cosmos/cosmos-sdk/pull/14720)
google.protobuf.Duration expedited_voting_period = 10 [(gogoproto.stdduration) = true];

// Minimum proportion of Yes votes for proposal to pass. Default value: 0.67.
//
// NOTE: backported from v50 (https://github.com/cosmos/cosmos-sdk/pull/14720)
string expedited_threshold = 11 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum expedited deposit for a proposal to enter voting period.
//
// NOTE: backported from v50 (https://github.com/cosmos/cosmos-sdk/pull/14720)
repeated cosmos.base.v1beta1.Coin expedited_min_deposit = 12
[(gogoproto.nullable) = false, (amino.dont_omitempty) = true];

// burn deposits if a proposal does not meet quorum
bool burn_vote_quorum = 13;

Expand Down
5 changes: 5 additions & 0 deletions proto/cosmos/gov/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ message MsgSubmitProposal {
//
// Since: cosmos-sdk 0.47
string summary = 6;

// expedided defines if the proposal is expedited or not
//
// Since: cosmos-sdk 0.48
bool expedited = 7;
}

// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type.
Expand Down
7 changes: 6 additions & 1 deletion tests/e2e/gov/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (s *E2ETestSuite) TestCmdParams() {
{
"json output",
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
`{"voting_params":{"voting_period":"172800s"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s","voting_period":"172800s","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","min_initial_deposit_ratio":"0.000000000000000000","burn_vote_quorum":false,"burn_proposal_deposit_prevote":false,"burn_vote_veto":true,"min_deposit_ratio":"0.010000000000000000"}}`,
`{"voting_params":{"voting_period":"172800s"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s","voting_period":"172800s","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","min_initial_deposit_ratio":"0.000000000000000000","expedited_voting_period":"86400s","expedited_threshold":"0.667000000000000000","expedited_min_deposit":[{"denom":"stake","amount":"50000000"}]}}`,
},
{
"text output",
Expand All @@ -38,6 +38,11 @@ params:
burn_proposal_deposit_prevote: false
burn_vote_quorum: false
burn_vote_veto: true
expedited_min_deposit:
- amount: "50000000"
denom: stake
expedited_threshold: "0.667000000000000000"
expedited_voting_period: 86400s
max_deposit_period: 172800s
min_deposit:
- amount: "10000000"
Expand Down
9 changes: 5 additions & 4 deletions tests/integration/gov/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/stretchr/testify/require"
"gotest.tools/assert"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/runtime"
Expand Down Expand Up @@ -74,12 +75,12 @@ func TestImportExportQueues(t *testing.T) {

ctx = s1.app.BaseApp.NewContext(false, tmproto.Header{})
// Create two proposals, put the second into the voting period
proposal1, err := s1.GovKeeper.SubmitProposal(ctx, []sdk.Msg{mkTestLegacyContent(t)}, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal1, err := s1.GovKeeper.SubmitProposal(ctx, []sdk.Msg{mkTestLegacyContent(t)}, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
proposalID1 := proposal1.Id

proposal2, err := s1.GovKeeper.SubmitProposal(ctx, []sdk.Msg{mkTestLegacyContent(t)}, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal2, err := s1.GovKeeper.SubmitProposal(ctx, []sdk.Msg{mkTestLegacyContent(t)}, "", "test", "description", addrs[0], true)
assert.NilError(t, err)
proposalID2 := proposal2.Id

votingStarted, err := s1.GovKeeper.AddDeposit(ctx, proposalID2, addrs[0], s1.GovKeeper.GetParams(ctx).MinDeposit)
Expand Down
13 changes: 7 additions & 6 deletions tests/integration/gov/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"gotest.tools/assert"
)

func (suite *KeeperTestSuite) TestGRPCQueryTally() {
Expand Down Expand Up @@ -50,9 +51,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryTally() {
"create a proposal and get tally",
func() {
var err error
proposal, err = app.GovKeeper.SubmitProposal(ctx, TestProposal, "", "test", "description", addrs[0])
suite.Require().NoError(err)
suite.Require().NotNil(proposal)
proposal, err = app.GovKeeper.SubmitProposal(ctx, TestProposal, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
assert.Assert(t, proposal.String() != "")

req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}

Expand Down Expand Up @@ -161,9 +162,9 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTally() {
"create a proposal and get tally",
func() {
var err error
proposal, err = app.GovKeeper.SubmitProposal(ctx, TestProposal, "", "test", "description", addrs[0])
suite.Require().NoError(err)
suite.Require().NotNil(proposal)
proposal, err = app.GovKeeper.SubmitProposal(ctx, TestProposal, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
assert.Assert(t, proposal.String() != "")

req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}

Expand Down
61 changes: 31 additions & 30 deletions tests/integration/gov/keeper/tally_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/stretchr/testify/require"
"gotest.tools/assert"

"cosmossdk.io/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -20,8 +21,8 @@ func TestTallyNoOneVotes(t *testing.T) {
createValidators(t, ctx, app, []int64{5, 5, 5})

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", sdk.AccAddress("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r"))
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", sdk.AccAddress("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r"), false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand All @@ -44,8 +45,8 @@ func TestTallyNoQuorum(t *testing.T) {
addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000000))

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand All @@ -67,8 +68,8 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) {
addrs, _ := createValidators(t, ctx, app, []int64{5, 5, 5})
tp := TestProposal

proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand All @@ -93,8 +94,8 @@ func TestTallyOnlyValidators51No(t *testing.T) {
valAccAddrs, _ := createValidators(t, ctx, app, []int64{5, 6, 0})

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand All @@ -117,8 +118,8 @@ func TestTallyOnlyValidators51Yes(t *testing.T) {
valAccAddrs, _ := createValidators(t, ctx, app, []int64{5, 6, 0})

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand All @@ -142,8 +143,8 @@ func TestTallyOnlyValidatorsVetoed(t *testing.T) {
valAccAddrs, _ := createValidators(t, ctx, app, []int64{6, 6, 7})

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand All @@ -168,8 +169,8 @@ func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) {
valAccAddrs, _ := createValidators(t, ctx, app, []int64{6, 6, 7})

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand All @@ -194,8 +195,8 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
valAccAddrs, _ := createValidators(t, ctx, app, []int64{6, 6, 7})

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand All @@ -221,8 +222,8 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
valAccAddr1, valAccAddr2 := valAccAddrs[0], valAccAddrs[1]

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", valAccAddrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand Down Expand Up @@ -255,8 +256,8 @@ func TestTallyDelgatorOverride(t *testing.T) {
_ = staking.EndBlocker(ctx, app.StakingKeeper)

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand Down Expand Up @@ -291,8 +292,8 @@ func TestTallyDelgatorInherit(t *testing.T) {
_ = staking.EndBlocker(ctx, app.StakingKeeper)

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand Down Expand Up @@ -330,8 +331,8 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) {
_ = staking.EndBlocker(ctx, app.StakingKeeper)

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand Down Expand Up @@ -372,8 +373,8 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) {
_ = staking.EndBlocker(ctx, app.StakingKeeper)

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand Down Expand Up @@ -415,8 +416,8 @@ func TestTallyJailedValidator(t *testing.T) {
app.StakingKeeper.Jail(ctx, sdk.ConsAddress(consAddr.Bytes()))

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand Down Expand Up @@ -448,8 +449,8 @@ func TestTallyValidatorMultipleDelegations(t *testing.T) {
require.NoError(t, err)

tp := TestProposal
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0])
require.NoError(t, err)
proposal, err := app.GovKeeper.SubmitProposal(ctx, tp, "", "test", "description", addrs[0], false)
assert.NilError(t, err)
proposalID := proposal.Id
proposal.Status = v1.StatusVotingPeriod
app.GovKeeper.SetProposal(ctx, proposal)
Expand Down
2 changes: 2 additions & 0 deletions x/bank/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ func TestMsgSetSendEnabled(t *testing.T) {
"set default send enabled to true",
"Change send enabled",
"Modify send enabled and set to true",
false,
)
require.NoError(t, err, "making goodGovProp")
badGovProp, err := govv1.NewMsgSubmitProposal(
Expand All @@ -373,6 +374,7 @@ func TestMsgSetSendEnabled(t *testing.T) {
"set default send enabled to true",
"Change send enabled",
"Modify send enabled and set to true",
false,
)
require.NoError(t, err, "making badGovProp")

Expand Down
Loading

0 comments on commit d0b67d8

Please sign in to comment.