Skip to content

Commit

Permalink
expedited proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Nov 7, 2023
1 parent c3c7ab7 commit b9be75b
Show file tree
Hide file tree
Showing 59 changed files with 2,503 additions and 911 deletions.
661 changes: 532 additions & 129 deletions api/cosmos/gov/v1/gov.pulsar.go

Large diffs are not rendered by default.

317 changes: 192 additions & 125 deletions api/cosmos/gov/v1/tx.pulsar.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions crypto/ledger/ledger_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build ledger
// +build ledger

package ledger

import (
Expand Down
38 changes: 37 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,31 @@ 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"];

// // The cancel ratio which will not be returned back to the depositors when a proposal is cancelled.
// //
// // Since: cosmos-sdk 0.48
// string proposal_cancel_ratio = 8 [(cosmos_proto.scalar) = "cosmos.Dec"];

// // The address which will receive (proposal_cancel_ratio * deposit) proposal deposits.
// // If empty, the (proposal_cancel_ratio * deposit) proposal deposits will be burned.
// //
// // Since: cosmos-sdk 0.48
// string proposal_cancel_dest = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// Duration of the voting period of an expedited proposal.
//
// Since: cosmos-sdk 0.48
google.protobuf.Duration expedited_voting_period = 10 [(gogoproto.stdduration) = true];

// Minimum proportion of Yes votes for proposal to pass. Default value: 0.67.
//
// Since: cosmos-sdk 0.48
string expedited_threshold = 11 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum expedited deposit for a proposal to enter voting period.
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
10 changes: 6 additions & 4 deletions 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}}`,
`{"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","proposal_cancel_ratio":"0.500000000000000000","proposal_cancel_dest":"","expedited_voting_period":"86400s","expedited_threshold":"0.667000000000000000","expedited_min_deposit":[{"denom":"stake","amount":"50000000"}]}}`,
},
{
"text output",
Expand All @@ -35,9 +35,11 @@ deposit_params:
- amount: "10000000"
denom: stake
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/v3/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], false)
assert.NilError(t, err)
proposalID2 := proposal2.Id

votingStarted, err := s1.GovKeeper.AddDeposit(ctx, proposalID2, addrs[0], s1.GovKeeper.GetParams(ctx).MinDeposit)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/gov/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ 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])
proposal, err = app.GovKeeper.SubmitProposal(ctx, TestProposal, "", "test", "description", addrs[0], false)
suite.Require().NoError(err)
suite.Require().NotNil(proposal)

Expand Down Expand Up @@ -161,7 +161,7 @@ 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])
proposal, err = app.GovKeeper.SubmitProposal(ctx, TestProposal, "", "test", "description", addrs[0], false)
suite.Require().NoError(err)
suite.Require().NotNil(proposal)

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/v3/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
1 change: 1 addition & 0 deletions testutil/sims/simulation_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func SimulationOperations(app runtime.AppI, cdc codec.JSONCodec, config simtypes
simState := module.SimulationState{
AppParams: make(simtypes.AppParams),
Cdc: cdc,
BondDenom: sdk.DefaultBondDenom,
}

if config.ParamsFile != "" {
Expand Down
1 change: 1 addition & 0 deletions testutil/sims/state_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func AppStateRandomizedFn(
Accounts: accs,
InitialStake: initialStake,
NumBonded: numInitiallyBonded,
BondDenom: sdk.DefaultBondDenom,
GenTimestamp: genesisTimestamp,
}

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 @@ -361,6 +361,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 @@ -372,6 +373,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
1 change: 1 addition & 0 deletions x/bank/keeper/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func createTestSuite(t *testing.T, genesisAccounts []authtypes.GenesisAccount) t
configurator.ConsensusModule(),
configurator.BankModule(),
configurator.GovModule(),
configurator.ConsensusModule(),
),
startupCfg, &res.BankKeeper, &res.AccountKeeper, &res.StakingKeeper)

Expand Down
Loading

0 comments on commit b9be75b

Please sign in to comment.