From 2cc5b1a573e67602bd33fff066c6cb54d5277ec2 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 28 Jul 2022 07:10:05 -0700 Subject: [PATCH 1/4] fix(x/gov): migrations from 2 to 3 (min proposer deposit) (#298) (#302) * git checkout -b roman/fix-gov-migrations * register migrations --- x/gov/keeper/migrations.go | 6 ++++++ x/gov/legacy/v3/store.go | 28 ++++++++++++++++++++++++++++ x/gov/module.go | 4 ++++ 3 files changed, 38 insertions(+) create mode 100644 x/gov/legacy/v3/store.go diff --git a/x/gov/keeper/migrations.go b/x/gov/keeper/migrations.go index cad01432bb7d..b6b4721b27d9 100644 --- a/x/gov/keeper/migrations.go +++ b/x/gov/keeper/migrations.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" v043 "github.com/cosmos/cosmos-sdk/x/gov/legacy/v043" + v3 "github.com/cosmos/cosmos-sdk/x/gov/legacy/v3" ) // Migrator is a struct for handling in-place store migrations. @@ -19,3 +20,8 @@ func NewMigrator(keeper Keeper) Migrator { func (m Migrator) Migrate1to2(ctx sdk.Context) error { return v043.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) } + +// Migrate2to3 migrates from version 2 to 3. +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + return v3.MigrateStore(ctx, m.keeper.paramSpace) +} diff --git a/x/gov/legacy/v3/store.go b/x/gov/legacy/v3/store.go new file mode 100644 index 000000000000..7caa06db1bbe --- /dev/null +++ b/x/gov/legacy/v3/store.go @@ -0,0 +1,28 @@ +package v3 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100)) + +// MigrateStore performs in-place store migrations for consensus version 3 +// in the gov module. +// Please note that this is the first version that switches from using +// SDK versioning (v043 etc) for package names to consensus versioning +// of the gov module. +// The migration includes: +// +// - Setting the minimum deposit param in the paramstore. +func MigrateStore(ctx sdk.Context, paramstore types.ParamSubspace) error { + migrateParamsStore(ctx, paramstore) + return nil +} + +func migrateParamsStore(ctx sdk.Context, paramstore types.ParamSubspace) { + var depositParams types.DepositParams + paramstore.Get(ctx, types.ParamStoreKeyDepositParams, &depositParams) + depositParams.MinInitialDepositRatio = minInitialDepositRatio + paramstore.Set(ctx, types.ParamStoreKeyDepositParams, depositParams) +} diff --git a/x/gov/module.go b/x/gov/module.go index a090b2c90da2..4da9328ef595 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -161,6 +161,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err != nil { panic(err) } + cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3) + if err != nil { + panic(err) + } } // InitGenesis performs genesis initialization for the gov module. It returns From 643737b32d16f4cad9c73c3cd85f0451ec1eb769 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 27 Jul 2022 16:21:53 -0700 Subject: [PATCH 2/4] feat!: initial deposit requirement for proposals (backport #296) (#297) * feat!: initial deposit requirement for proposals (backport #296) * Update x/gov/legacy/v3/store_test.go Co-authored-by: Adam Tucker * Update x/gov/simulation/genesis.go Co-authored-by: Adam Tucker Co-authored-by: Adam Tucker --- docs/core/proto-docs.md | 1 + proto/cosmos/gov/v1beta1/gov.proto | 6 + x/gov/client/testutil/suite.go | 5 +- x/gov/keeper/deposit.go | 18 +++ x/gov/keeper/deposit_test.go | 105 +++++++++++++ x/gov/keeper/export_test.go | 7 + x/gov/keeper/grpc_query_test.go | 8 +- x/gov/keeper/msg_server.go | 6 + x/gov/keeper/msg_server_test.go | 88 +++++++++++ x/gov/legacy/v040/migrate_test.go | 3 +- x/gov/legacy/v043/json_test.go | 3 +- x/gov/legacy/v3/export_test.go | 3 + x/gov/legacy/v3/store.go | 29 ++++ x/gov/legacy/v3/store_test.go | 38 +++++ x/gov/module.go | 2 +- x/gov/simulation/genesis.go | 14 +- x/gov/simulation/genesis_test.go | 12 +- x/gov/simulation/operations.go | 38 +++-- x/gov/types/errors.go | 1 + x/gov/types/gov.pb.go | 235 ++++++++++++++++++----------- x/gov/types/params.go | 13 +- x/params/proposal_handler_test.go | 5 +- 22 files changed, 518 insertions(+), 122 deletions(-) create mode 100644 x/gov/keeper/export_test.go create mode 100644 x/gov/keeper/msg_server_test.go create mode 100644 x/gov/legacy/v3/export_test.go create mode 100644 x/gov/legacy/v3/store.go create mode 100644 x/gov/legacy/v3/store_test.go diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 41a3b66c2406..09bb2242c428 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -5049,6 +5049,7 @@ DepositParams defines the params for deposits on governance proposals. | ----- | ---- | ----- | ----------- | | `min_deposit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | Minimum deposit for a proposal to enter voting period. | | `max_deposit_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months. | +| `min_initial_deposit_ratio` | [string](#string) | | The ratio representing the proportion of the deposit value that must be paid at proposal submission. | diff --git a/proto/cosmos/gov/v1beta1/gov.proto b/proto/cosmos/gov/v1beta1/gov.proto index 344b5ada19a5..65ed9aea83d9 100644 --- a/proto/cosmos/gov/v1beta1/gov.proto +++ b/proto/cosmos/gov/v1beta1/gov.proto @@ -159,6 +159,12 @@ message DepositParams { (gogoproto.jsontag) = "max_deposit_period,omitempty", (gogoproto.moretags) = "yaml:\"max_deposit_period\"" ]; + // The ratio representing the proportion of the deposit value that must be paid at proposal submission. + string min_initial_deposit_ratio = 3 [ + (gogoproto.nullable) = false, + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.jsontag) = "min_initial_deposit_ratio,omitempty" + ]; } // VotingParams defines the params for voting on governance proposals. diff --git a/x/gov/client/testutil/suite.go b/x/gov/client/testutil/suite.go index ee2634e3d188..db795e72fb32 100644 --- a/x/gov/client/testutil/suite.go +++ b/x/gov/client/testutil/suite.go @@ -88,7 +88,7 @@ func (s *IntegrationTestSuite) TestCmdParams() { { "json output", []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, - `{"voting_params":{"voting_period":"172800000000000"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800000000000"}}`, + `{"voting_params":{"voting_period":"172800000000000"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800000000000","min_initial_deposit_ratio":"0.000000000000000000"}}`, }, { "text output", @@ -99,6 +99,7 @@ deposit_params: min_deposit: - amount: "10000000" denom: stake + min_initial_deposit_ratio: "0.000000000000000000" tally_params: quorum: "0.334000000000000000" threshold: "0.500000000000000000" @@ -153,7 +154,7 @@ func (s *IntegrationTestSuite) TestCmdParam() { "deposit", fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, - `{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800000000000"}`, + `{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800000000000","min_initial_deposit_ratio":"0.000000000000000000"}`, }, } diff --git a/x/gov/keeper/deposit.go b/x/gov/keeper/deposit.go index 9275fbff40dc..d84a0a6e18fc 100644 --- a/x/gov/keeper/deposit.go +++ b/x/gov/keeper/deposit.go @@ -185,3 +185,21 @@ func (keeper Keeper) RefundDeposits(ctx sdk.Context, proposalID uint64) { return false }) } + +// validateInitialDeposit validates if initial deposit is greater than or equal to the minimum +// required at the time of proposal submission. This threshold amount is determined by +// the deposit parameters. Returns nil on success, error otherwise. +func (keeper Keeper) validateInitialDeposit(ctx sdk.Context, initialDeposit sdk.Coins) error { + depositParams := keeper.GetDepositParams(ctx) + if depositParams.MinInitialDepositRatio.IsNil() || depositParams.MinInitialDepositRatio.IsZero() { + return nil + } + minDepositCoins := depositParams.MinDeposit + for i := range minDepositCoins { + minDepositCoins[i].Amount = minDepositCoins[i].Amount.ToDec().Mul(depositParams.MinInitialDepositRatio).RoundInt() + } + if !initialDeposit.IsAllGTE(minDepositCoins) { + return sdkerrors.Wrapf(types.ErrMinDepositTooSmall, "was (%s), need (%s)", initialDeposit, minDepositCoins) + } + return nil +} diff --git a/x/gov/keeper/deposit_test.go b/x/gov/keeper/deposit_test.go index 0c8e370681aa..248a005ff380 100644 --- a/x/gov/keeper/deposit_test.go +++ b/x/gov/keeper/deposit_test.go @@ -9,6 +9,12 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +const ( + baseDepositTestAmount = 100 + baseDepositTestPercent = 25 ) func TestDeposits(t *testing.T) { @@ -108,3 +114,102 @@ func TestDeposits(t *testing.T) { deposits = app.GovKeeper.GetDeposits(ctx, proposalID) require.Len(t, deposits, 0) } + +func TestValidateInitialDeposit(t *testing.T) { + testcases := map[string]struct { + minDeposit sdk.Coins + minInitialDepositPercent int64 + initialDeposit sdk.Coins + + expectError bool + }{ + "min deposit * initial percent == initial deposit: success": { + minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositPercent: baseDepositTestPercent, + initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100))), + }, + "min deposit * initial percent < initial deposit: success": { + minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositPercent: baseDepositTestPercent, + initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100+1))), + }, + "min deposit * initial percent > initial deposit: error": { + minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositPercent: baseDepositTestPercent, + initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100-1))), + + expectError: true, + }, + "min deposit * initial percent == initial deposit (non-base values and denom): success": { + minDeposit: sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(56912))), + minInitialDepositPercent: 50, + initialDeposit: sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(56912/2+10))), + }, + "min deposit * initial percent == initial deposit but different denoms: error": { + minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositPercent: baseDepositTestPercent, + initialDeposit: sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100))), + + expectError: true, + }, + "min deposit * initial percent == initial deposit (multiple coins): success": { + minDeposit: sdk.NewCoins( + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount)), + sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*2))), + minInitialDepositPercent: baseDepositTestPercent, + initialDeposit: sdk.NewCoins( + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100)), + sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*2*baseDepositTestPercent/100)), + ), + }, + "min deposit * initial percent > initial deposit (multiple coins): error": { + minDeposit: sdk.NewCoins( + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount)), + sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*2))), + minInitialDepositPercent: baseDepositTestPercent, + initialDeposit: sdk.NewCoins( + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100)), + sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*2*baseDepositTestPercent/100-1)), + ), + + expectError: true, + }, + "min deposit * initial percent < initial deposit (multiple coins - coin not required by min deposit): success": { + minDeposit: sdk.NewCoins( + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositPercent: baseDepositTestPercent, + initialDeposit: sdk.NewCoins( + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100)), + sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100-1)), + ), + }, + "0 initial percent: success": { + minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositPercent: 0, + initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100))), + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + govKeeper := app.GovKeeper + + params := types.DefaultDepositParams() + params.MinDeposit = tc.minDeposit + params.MinInitialDepositRatio = sdk.NewDec(tc.minInitialDepositPercent).Quo(sdk.NewDec(100)) + + govKeeper.SetDepositParams(ctx, params) + + err := govKeeper.ValidateInitialDeposit(ctx, tc.initialDeposit) + + if tc.expectError { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/gov/keeper/export_test.go b/x/gov/keeper/export_test.go new file mode 100644 index 000000000000..8f95664932d6 --- /dev/null +++ b/x/gov/keeper/export_test.go @@ -0,0 +1,7 @@ +package keeper + +import sdk "github.com/cosmos/cosmos-sdk/types" + +func (k Keeper) ValidateInitialDeposit(ctx sdk.Context, initialDeposit sdk.Coins) error { + return k.validateInitialDeposit(ctx, initialDeposit) +} diff --git a/x/gov/keeper/grpc_query_test.go b/x/gov/keeper/grpc_query_test.go index 0e7d6f251091..f0ccce987580 100644 --- a/x/gov/keeper/grpc_query_test.go +++ b/x/gov/keeper/grpc_query_test.go @@ -470,8 +470,9 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() { func() { req = &types.QueryParamsRequest{ParamsType: types.ParamVoting} expRes = &types.QueryParamsResponse{ - VotingParams: types.DefaultVotingParams(), - TallyParams: types.NewTallyParams(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0)), + VotingParams: types.DefaultVotingParams(), + DepositParams: types.DepositParams{MinInitialDepositRatio: sdk.ZeroDec()}, + TallyParams: types.NewTallyParams(sdk.NewDec(0), sdk.NewDec(0), sdk.NewDec(0)), } }, true, @@ -481,7 +482,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryParams() { func() { req = &types.QueryParamsRequest{ParamsType: types.ParamTallying} expRes = &types.QueryParamsResponse{ - TallyParams: types.DefaultTallyParams(), + DepositParams: types.DepositParams{MinInitialDepositRatio: sdk.ZeroDec()}, + TallyParams: types.DefaultTallyParams(), } }, true, diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index 86e6e9326704..4d5b1736aa27 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -26,6 +26,12 @@ var _ types.MsgServer = msgServer{} func (k msgServer) SubmitProposal(goCtx context.Context, msg *types.MsgSubmitProposal) (*types.MsgSubmitProposalResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + initialDeposit := msg.GetInitialDeposit() + + if err := k.validateInitialDeposit(ctx, initialDeposit); err != nil { + return nil, err + } + proposal, err := k.Keeper.SubmitProposal(ctx, msg.GetContent()) if err != nil { return nil, err diff --git a/x/gov/keeper/msg_server_test.go b/x/gov/keeper/msg_server_test.go new file mode 100644 index 000000000000..2b347c5e19fd --- /dev/null +++ b/x/gov/keeper/msg_server_test.go @@ -0,0 +1,88 @@ +package keeper_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/gov/keeper" + "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestSubmitProposal_InitialDeposit(t *testing.T) { + const meetsDepositValue = baseDepositTestAmount * baseDepositTestPercent / 100 + var baseDepositRatioDec = sdk.NewDec(baseDepositTestPercent).Quo(sdk.NewDec(100)) + + testcases := map[string]struct { + minDeposit sdk.Coins + minInitialDepositRatio sdk.Dec + initialDeposit sdk.Coins + accountBalance sdk.Coins + + expectError bool + }{ + "meets initial deposit, enough balance - success": { + minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositRatio: baseDepositRatioDec, + initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue))), + accountBalance: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue))), + }, + "does not meet initial deposit, enough balance - error": { + minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositRatio: baseDepositRatioDec, + initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue-1))), + accountBalance: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue))), + + expectError: true, + }, + "meets initial deposit, not enough balance - error": { + minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositRatio: baseDepositRatioDec, + initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue))), + accountBalance: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue-1))), + + expectError: true, + }, + "does not meet initial deposit and not enough balance - error": { + minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))), + minInitialDepositRatio: baseDepositRatioDec, + initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue-1))), + accountBalance: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue-1))), + + expectError: true, + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + // Setup + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + govKeeper := app.GovKeeper + msgServer := keeper.NewMsgServerImpl(govKeeper) + + params := types.DefaultDepositParams() + params.MinDeposit = tc.minDeposit + params.MinInitialDepositRatio = tc.minInitialDepositRatio + govKeeper.SetDepositParams(ctx, params) + + address := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(0))[0] + simapp.FundAccount(app.BankKeeper, ctx, address, tc.accountBalance) + + msg, err := types.NewMsgSubmitProposal(TestProposal, tc.initialDeposit, address) + require.NoError(t, err) + + // System under test + _, err = msgServer.SubmitProposal(sdk.WrapSDKContext(ctx), msg) + + // Assertions + if tc.expectError { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/gov/legacy/v040/migrate_test.go b/x/gov/legacy/v040/migrate_test.go index 664696bf296e..5dc83d979bcb 100644 --- a/x/gov/legacy/v040/migrate_test.go +++ b/x/gov/legacy/v040/migrate_test.go @@ -97,7 +97,8 @@ func TestMigrate(t *testing.T) { expected := `{ "deposit_params": { "max_deposit_period": "0s", - "min_deposit": [] + "min_deposit": [], + "min_initial_deposit_ratio": "0" }, "deposits": [], "proposals": [ diff --git a/x/gov/legacy/v043/json_test.go b/x/gov/legacy/v043/json_test.go index d9f045774661..72574188194a 100644 --- a/x/gov/legacy/v043/json_test.go +++ b/x/gov/legacy/v043/json_test.go @@ -50,7 +50,8 @@ func TestMigrateJSON(t *testing.T) { expected := `{ "deposit_params": { "max_deposit_period": "0s", - "min_deposit": [] + "min_deposit": [], + "min_initial_deposit_ratio": "0" }, "deposits": [], "proposals": [], diff --git a/x/gov/legacy/v3/export_test.go b/x/gov/legacy/v3/export_test.go new file mode 100644 index 000000000000..c18fb234cf15 --- /dev/null +++ b/x/gov/legacy/v3/export_test.go @@ -0,0 +1,3 @@ +package v3 + +var MinInitialDepositRatio = minInitialDepositRatio diff --git a/x/gov/legacy/v3/store.go b/x/gov/legacy/v3/store.go new file mode 100644 index 000000000000..dd25e9338b2b --- /dev/null +++ b/x/gov/legacy/v3/store.go @@ -0,0 +1,29 @@ +package v3 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/gov/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100)) + +// MigrateStore performs in-place store migrations for consensus version 3 +// in the gov module. +// Please note that this is the first version that switches from using +// SDK versioning (v043 etc) for package names to consensus versioning +// of the gov module. +// The migration includes: +// +// - Setting the minimum deposit param in the paramstore. +func MigrateStore(ctx sdk.Context, paramstore paramtypes.Subspace) error { + migrateParamsStore(ctx, paramstore) + return nil +} + +func migrateParamsStore(ctx sdk.Context, paramstore paramtypes.Subspace) { + var depositParams types.DepositParams + paramstore.Get(ctx, types.ParamStoreKeyDepositParams, &depositParams) + depositParams.MinInitialDepositRatio = minInitialDepositRatio + paramstore.Set(ctx, types.ParamStoreKeyDepositParams, depositParams) +} diff --git a/x/gov/legacy/v3/store_test.go b/x/gov/legacy/v3/store_test.go new file mode 100644 index 000000000000..9f276d4060aa --- /dev/null +++ b/x/gov/legacy/v3/store_test.go @@ -0,0 +1,38 @@ +package v3_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + v3 "github.com/cosmos/cosmos-sdk/x/gov/legacy/v3" + "github.com/cosmos/cosmos-sdk/x/gov/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +func TestGovStoreMigrationToV3ConsensusVersion(t *testing.T) { + encCfg := simapp.MakeTestEncodingConfig() + govKey := sdk.NewKVStoreKey("gov") + transientTestKey := sdk.NewTransientStoreKey("transient_test") + ctx := testutil.DefaultContext(govKey, transientTestKey) + paramstore := paramtypes.NewSubspace(encCfg.Marshaler, encCfg.Amino, govKey, transientTestKey, "gov") + + paramstore = paramstore.WithKeyTable(types.ParamKeyTable()) + + // We assume that all deposit params are set besides the MinInitialDepositRatio + originalDepositParams := types.DefaultDepositParams() + originalDepositParams.MinInitialDepositRatio = sdk.ZeroDec() + paramstore.Set(ctx, types.ParamStoreKeyDepositParams, originalDepositParams) + + // Run migrations. + err := v3.MigrateStore(ctx, paramstore) + require.NoError(t, err) + + // Make sure the new param is set. + var depositParams types.DepositParams + paramstore.Get(ctx, types.ParamStoreKeyDepositParams, &depositParams) + require.Equal(t, v3.MinInitialDepositRatio, depositParams.MinInitialDepositRatio) +} diff --git a/x/gov/module.go b/x/gov/module.go index a090b2c90da2..69f6d5572839 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -180,7 +180,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock performs a no-op. func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/gov/simulation/genesis.go b/x/gov/simulation/genesis.go index 3f9ed2d086a7..e9d0b66d5621 100644 --- a/x/gov/simulation/genesis.go +++ b/x/gov/simulation/genesis.go @@ -18,6 +18,7 @@ import ( const ( DepositParamsMinDeposit = "deposit_params_min_deposit" DepositParamsDepositPeriod = "deposit_params_deposit_period" + DepositMinInitialPercent = "deposit_params_min_initial_percent" VotingParamsVotingPeriod = "voting_params_voting_period" TallyParamsQuorum = "tally_params_quorum" TallyParamsThreshold = "tally_params_threshold" @@ -34,6 +35,11 @@ func GenDepositParamsMinDeposit(r *rand.Rand) sdk.Coins { return sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, int64(simulation.RandIntBetween(r, 1, 1e3)))) } +// GenDepositMinInitialPercent randomized DepositMinInitialPercent +func GenDepositMinInitialDepositRatio(r *rand.Rand) sdk.Dec { + return sdk.NewDec(int64(simulation.RandIntBetween(r, 0, 99))).Quo(sdk.NewDec(100)) +} + // GenVotingParamsVotingPeriod randomized VotingParamsVotingPeriod func GenVotingParamsVotingPeriod(r *rand.Rand) time.Duration { return time.Duration(simulation.RandIntBetween(r, 1, 2*60*60*24*2)) * time.Second @@ -70,6 +76,12 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { depositPeriod = GenDepositParamsDepositPeriod(r) }, ) + var minInitialDepositRatio sdk.Dec + simState.AppParams.GetOrGenerate( + simState.Cdc, DepositMinInitialPercent, &minInitialDepositRatio, simState.Rand, + func(r *rand.Rand) { minInitialDepositRatio = GenDepositMinInitialDepositRatio(r) }, + ) + var votingPeriod time.Duration simState.AppParams.GetOrGenerate( simState.Cdc, VotingParamsVotingPeriod, &votingPeriod, simState.Rand, @@ -96,7 +108,7 @@ func RandomizedGenState(simState *module.SimulationState) { govGenesis := types.NewGenesisState( startingProposalID, - types.NewDepositParams(minDeposit, depositPeriod), + types.NewDepositParams(minDeposit, depositPeriod).WithMinInitialDepositRatio(minInitialDepositRatio), types.NewVotingParams(votingPeriod), types.NewTallyParams(quorum, threshold, veto), ) diff --git a/x/gov/simulation/genesis_test.go b/x/gov/simulation/genesis_test.go index db8b98bff103..59b92af8ef94 100644 --- a/x/gov/simulation/genesis_test.go +++ b/x/gov/simulation/genesis_test.go @@ -40,13 +40,17 @@ func TestRandomizedGenState(t *testing.T) { var govGenesis types.GenesisState simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &govGenesis) - dec1, _ := sdk.NewDecFromStr("0.361000000000000000") - dec2, _ := sdk.NewDecFromStr("0.512000000000000000") - dec3, _ := sdk.NewDecFromStr("0.267000000000000000") + dec1, _ := sdk.NewDecFromStr("0.400000000000000000") + dec2, _ := sdk.NewDecFromStr("0.539000000000000000") + dec3, _ := sdk.NewDecFromStr("0.314000000000000000") + + minInitialDepositDec, err := sdk.NewDecFromStr("0.590000000000000000") + require.NoError(t, err) require.Equal(t, "905stake", govGenesis.DepositParams.MinDeposit.String()) require.Equal(t, "77h26m10s", govGenesis.DepositParams.MaxDepositPeriod.String()) - require.Equal(t, float64(148296), govGenesis.VotingParams.VotingPeriod.Seconds()) + require.Equal(t, minInitialDepositDec, govGenesis.DepositParams.MinInitialDepositRatio) + require.Equal(t, float64(275567), govGenesis.VotingParams.VotingPeriod.Seconds()) require.Equal(t, dec1, govGenesis.TallyParams.Quorum) require.Equal(t, dec2, govGenesis.TallyParams.Threshold) require.Equal(t, dec3, govGenesis.TallyParams.VetoThreshold) diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 214fb9465676..038db76bc717 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -129,7 +129,7 @@ func SimulateMsgSubmitProposal( } simAccount, _ := simtypes.RandomAcc(r, accs) - deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address) + deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address, true) switch { case skip: return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSubmitProposal, "skip deposit"), nil, nil @@ -219,7 +219,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Ke return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDeposit, "unable to generate proposalID"), nil, nil } - deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address) + deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address, false) switch { case skip: return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDeposit, "skip deposit"), nil, nil @@ -367,8 +367,14 @@ func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeepe // deposit amount between (0, min(balance, minDepositAmount)) // This is to simulate multiple users depositing to get the // proposal above the minimum deposit amount -func randomDeposit(r *rand.Rand, ctx sdk.Context, - ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, addr sdk.AccAddress, +func randomDeposit( + r *rand.Rand, + ctx sdk.Context, + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, + addr sdk.AccAddress, + useMinAmount bool, ) (deposit sdk.Coins, skip bool, err error) { account := ak.GetAccount(ctx, addr) spendable := bk.SpendableCoins(ctx, account.GetAddress()) @@ -377,24 +383,34 @@ func randomDeposit(r *rand.Rand, ctx sdk.Context, return nil, true, nil // skip } - minDeposit := k.GetDepositParams(ctx).MinDeposit + depositParams := k.GetDepositParams(ctx) + + minDeposit := depositParams.MinDeposit denomIndex := r.Intn(len(minDeposit)) denom := minDeposit[denomIndex].Denom - depositCoins := spendable.AmountOf(denom) - if depositCoins.IsZero() { + spendableBalance := spendable.AmountOf(denom) + if spendableBalance.IsZero() { return nil, true, nil } - maxAmt := depositCoins - if maxAmt.GT(minDeposit[denomIndex].Amount) { - maxAmt = minDeposit[denomIndex].Amount + minDepositAmount := minDeposit[denomIndex].Amount + + minAmount := sdk.ZeroInt() + if useMinAmount { + minDepositPercent := depositParams.MinInitialDepositRatio + minAmount = minDepositAmount.ToDec().Mul(minDepositPercent).RoundInt() } - amount, err := simtypes.RandPositiveInt(r, maxAmt) + amount, err := simtypes.RandPositiveInt(r, minDepositAmount.Sub(minAmount)) if err != nil { return nil, false, err } + amount = amount.Add(minAmount) + + if amount.GT(spendableBalance) { + return nil, true, nil + } return sdk.Coins{sdk.NewCoin(denom, amount)}, false, nil } diff --git a/x/gov/types/errors.go b/x/gov/types/errors.go index 96973f1751a2..c04ee3832fdf 100644 --- a/x/gov/types/errors.go +++ b/x/gov/types/errors.go @@ -14,4 +14,5 @@ var ( ErrInvalidVote = sdkerrors.Register(ModuleName, 7, "invalid vote option") ErrInvalidGenesis = sdkerrors.Register(ModuleName, 8, "invalid genesis state") ErrNoProposalHandlerExists = sdkerrors.Register(ModuleName, 9, "no handler exists for proposal type") + ErrMinDepositTooSmall = sdkerrors.Register(ModuleName, 10, "minimum deposit is too small") ) diff --git a/x/gov/types/gov.pb.go b/x/gov/types/gov.pb.go index cc46f20a9c54..9ee09bf0e56c 100644 --- a/x/gov/types/gov.pb.go +++ b/x/gov/types/gov.pb.go @@ -377,6 +377,8 @@ type DepositParams struct { // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 // months. MaxDepositPeriod time.Duration `protobuf:"bytes,2,opt,name=max_deposit_period,json=maxDepositPeriod,proto3,stdduration" json:"max_deposit_period,omitempty" yaml:"max_deposit_period"` + // The ratio representing the proportion of the deposit value that must be paid at proposal submission. + MinInitialDepositRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=min_initial_deposit_ratio,json=minInitialDepositRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_initial_deposit_ratio,omitempty"` } func (m *DepositParams) Reset() { *m = DepositParams{} } @@ -510,98 +512,101 @@ func init() { func init() { proto.RegisterFile("cosmos/gov/v1beta1/gov.proto", fileDescriptor_6e82113c1a9a4b7c) } var fileDescriptor_6e82113c1a9a4b7c = []byte{ - // 1454 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x51, 0x68, 0xdb, 0x56, - 0x17, 0xb6, 0x6c, 0xc7, 0x89, 0xaf, 0x9d, 0x44, 0xbd, 0x49, 0x13, 0xc7, 0x7f, 0x7f, 0xc9, 0xbf, - 0xfe, 0x9f, 0x12, 0x4a, 0xeb, 0xb4, 0xf9, 0xc7, 0xc6, 0x52, 0xd8, 0x66, 0xc5, 0xca, 0xea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9d, 0x1d, 0xcb, 0x24, 0xba, 0x3b, 0x71, 0xa9, 0x29, 0x2f, 0x54, 0x7a, 0x4c, 0x0a, 0xcd, 0x1f, - 0x47, 0x59, 0x60, 0x51, 0x58, 0xbf, 0x04, 0xc0, 0xd2, 0x93, 0x97, 0x22, 0xa7, 0x02, 0x6a, 0x71, - 0x01, 0xd0, 0x04, 0x3c, 0x6b, 0x11, 0x1d, 0xd9, 0x75, 0x1a, 0x21, 0x76, 0x61, 0x84, 0xff, 0xb2, - 0x08, 0xcb, 0x34, 0xc2, 0x28, 0x03, 0x0d, 0x33, 0xc7, 0xcc, 0x8a, 0x5d, 0xf7, 0x42, 0x3d, 0xe6, - 0xc0, 0x2c, 0xc1, 0xc4, 0x68, 0xea, 0xec, 0x20, 0x35, 0x7d, 0x51, 0x23, 0xde, 0x61, 0x71, 0x16, - 0x69, 0x9c, 0x21, 0xb4, 0x34, 0x51, 0x83, 0x26, 0x3d, 0xac, 0x3f, 0x62, 0x4d, 0x70, 0x69, 0x0f, - 0x13, 0xd3, 0x6e, 0xb8, 0x3f, 0x6f, 0x9b, 0x09, 0x3b, 0x73, 0x61, 0xd9, 0xff, 0x63, 0xe9, 0xa4, - 0x68, 0x3a, 0x63, 0x14, 0xb4, 0xee, 0x79, 0x6a, 0xaf, 0xb8, 0x66, 0xaf, 0xf0, 0x87, 0x80, 0x99, - 0x06, 0x12, 0xc7, 0x2f, 0x8c, 0x25, 0xb1, 0x58, 0x4b, 0x43, 0xb1, 0x86, 0x15, 0x9e, 0xa5, 0x56, - 0x26, 0xf0, 0x46, 0xd4, 0xdd, 0x2a, 0xd2, 0x61, 0x18, 0x24, 0x82, 0xed, 0xf3, 0x01, 0x88, 0x1c, - 0x20, 0x87, 0x6e, 0x28, 0x39, 0x3b, 0xc1, 0x26, 0x2c, 0xd8, 0x44, 0x75, 0xa1, 0xf0, 0x0e, 0x98, - 0x36, 0x76, 0x1c, 0x62, 0x98, 0x6c, 0x97, 0x4d, 0xcc, 0x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x1a, 0xb4, 0x4d, 0x4e, 0xfa, 0xe2, 0x95, 0x71, 0xf0, 0x50, 0xae, 0x6c, 0x39, 0x8f, 0x7b, 0x49, - 0x4f, 0xdd, 0xa1, 0xe3, 0x2d, 0x63, 0xdf, 0x97, 0x8b, 0x9a, 0xbf, 0xe4, 0x40, 0xb2, 0xea, 0x4d, - 0x22, 0xd3, 0xef, 0x73, 0xc0, 0x26, 0xd3, 0xcf, 0x8d, 0xbb, 0x28, 0xb7, 0xdb, 0x2c, 0xb7, 0xe5, - 0x21, 0xdc, 0x50, 0x5a, 0x8b, 0x43, 0x8b, 0x20, 0x98, 0x51, 0x92, 0xda, 0x58, 0x36, 0xbf, 0xf9, - 0xf3, 0xcf, 0x92, 0x79, 0x00, 0x62, 0x9f, 0x75, 0x70, 0xbb, 0x63, 0x79, 0x59, 0x24, 0x65, 0x79, - 0xb2, 0x8f, 0xa1, 0x93, 0xbe, 0xc8, 0x53, 0xfc, 0x20, 0x1b, 0x95, 0x31, 0xc2, 0x1a, 0x88, 0x93, - 0xdd, 0x36, 0x72, 0x76, 0x71, 0x93, 0xfe, 0x00, 0xc9, 0x89, 0x86, 0x91, 0xd2, 0x2f, 0x9c, 0x51, - 0x04, 0x22, 0x0c, 0x78, 0x61, 0x97, 0x03, 0x73, 0xee, 0x84, 0xea, 0x83, 0x50, 0x11, 0x2f, 0x54, - 0x6d, 0xe2, 0x50, 0xa9, 0x61, 0x9e, 0x21, 0x7d, 0x2f, 0x33, 0x7d, 0x87, 0x3c, 0x24, 0x75, 0xd6, - 0x35, 0x68, 0xfe, 0xfb, 0xb5, 0x3f, 0x38, 0x00, 0x02, 0x5f, 0xa8, 0xd7, 0xc1, 0x72, 0xb5, 0xa4, - 0x29, 0x7a, 0xa9, 0xac, 0x15, 0x4a, 0x45, 0xfd, 0x5e, 0xb1, 0x52, 0x56, 0x36, 0x0b, 0x5b, 0x05, - 0x25, 0xcf, 0x87, 0xd2, 0xf3, 0xdd, 0x5e, 0x26, 0x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x9c, - 0xab, 0x54, 0x94, 0x3c, 0x1f, 0x49, 0xf3, 0xdd, 0x5e, 0x26, 0x49, 0x31, 0x65, 0xc3, 0x71, 0x50, - 0x1d, 0xde, 0x04, 0xa9, 0x51, 0x6f, 0x55, 0xf9, 0x48, 0xd9, 0xd4, 0x94, 0x3c, 0x1f, 0x4d, 0xc3, - 0x6e, 0x2f, 0x33, 0x47, 0xfd, 0x55, 0xf4, 0x09, 0xaa, 0x11, 0x74, 0x2e, 0xff, 0x56, 0xae, 0x70, - 0x57, 0xc9, 0xf3, 0x53, 0x41, 0xfe, 0x2d, 0xc3, 0x6c, 0xa2, 0x3a, 0x95, 0x53, 0x2e, 0x1e, 0xbe, - 0x12, 0x42, 0x2f, 0x5e, 0x09, 0xa1, 0x2f, 0x8e, 0x84, 0xd0, 0xe1, 0x91, 0xc0, 0x3d, 0x3f, 0x12, - 0xb8, 0xdf, 0x8f, 0x04, 0xee, 0xc9, 0xb1, 0x10, 0x7a, 0x7e, 0x2c, 0x84, 0x5e, 0x1c, 0x0b, 0xa1, - 0x07, 0x7f, 0xbf, 0x10, 0xf7, 0xbd, 0x7f, 0xff, 0xbc, 0x7e, 0xde, 0x89, 0x79, 0x3b, 0xe4, 0xff, - 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x14, 0xb4, 0xf2, 0xfe, 0x19, 0x0e, 0x00, 0x00, + // 1491 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0xd1, 0x6f, 0xdb, 0xd4, + 0x17, 0x8e, 0x93, 0x34, 0x6d, 0x6e, 0xd2, 0xd6, 0xbb, 0xed, 0xda, 0x34, 0xbf, 0xfd, 0xec, 0xe0, + 0xa1, 0xa9, 0x9a, 0xb6, 0x74, 0x2b, 0x08, 0x44, 0x27, 0x01, 0x71, 0xe3, 0xb2, 0xa0, 0x29, 0x89, + 0x9c, 0x2c, 0xd5, 0x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, 0xe4, 0x98, 0x14, 0x65, 0x6f, 0x1c, 0x65, + 0x81, 0x45, 0x61, 0xfd, 0xe2, 0x03, 0x4b, 0x8f, 0x5f, 0x88, 0x9c, 0x0a, 0xa8, 0xc5, 0x05, 0x40, + 0x13, 0xf0, 0xac, 0x45, 0x34, 0xc3, 0xae, 0xd1, 0x08, 0x91, 0x73, 0x23, 0x5c, 0x66, 0x11, 0x96, + 0x69, 0x84, 0x51, 0x06, 0x1a, 0x66, 0x8e, 0x99, 0x15, 0xbb, 0x46, 0x42, 0x3d, 0xe2, 0xc0, 0x2c, + 0x46, 0x58, 0x6f, 0x68, 0xec, 0x20, 0x31, 0x7d, 0x5e, 0x23, 0xde, 0x66, 0x71, 0x16, 0x69, 0x9c, + 0x21, 0xb4, 0x34, 0x51, 0x83, 0xc6, 0x09, 0xd6, 0x1b, 0xb1, 0x06, 0xb8, 0xb0, 0x87, 0xb0, 0x69, + 0xd7, 0xdd, 0x9f, 0xb7, 0xc5, 0x84, 0x9d, 0x39, 0xb7, 0xec, 0x37, 0x59, 0x3a, 0x09, 0x9a, 0xce, + 0x18, 0x05, 0xad, 0x7b, 0x9e, 0xda, 0x4b, 0xae, 0x99, 0x14, 0xfe, 0x00, 0x30, 0xd3, 0x40, 0xe2, + 0xe8, 0xb9, 0xb1, 0x24, 0x16, 0x6b, 0x69, 0x28, 0xd6, 0xb0, 0xc2, 0xb3, 0xd4, 0xca, 0x04, 0xde, + 0x08, 0xbb, 0x5b, 0x45, 0x3a, 0x0c, 0x82, 0x98, 0xbf, 0x7d, 0x3e, 0x04, 0xa1, 0x03, 0xc3, 0xa1, + 0x1b, 0x4a, 0x4e, 0x4f, 0xb0, 0x09, 0x73, 0x36, 0x56, 0x5d, 0x28, 0xbc, 0x0d, 0xa6, 0xf5, 0x1d, + 0x07, 0xeb, 0x26, 0xdb, 0x65, 0x13, 0xb3, 0x78, 0x70, 0xf8, 0x3e, 0x08, 0xda, 0x88, 0x0c, 0xe4, + 0xe4, 0x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x19, 0x9e, 0xf3, 0xf7, 0xc0, 0xff, 0x47, 0xc1, 0x95, 0x42, 0x39, 0x97, + 0xff, 0xc8, 0xc3, 0x06, 0x93, 0x4b, 0x9d, 0x6e, 0x0a, 0x52, 0x6c, 0xc5, 0x37, 0x01, 0xf0, 0x1a, + 0x58, 0x1a, 0x85, 0x16, 0x33, 0xa5, 0x92, 0x92, 0xe5, 0x43, 0x49, 0xbe, 0xd3, 0x4d, 0xc5, 0x29, + 0xa6, 0xa8, 0x3b, 0x8e, 0x51, 0x83, 0x37, 0x40, 0x62, 0xd4, 0x5b, 0x55, 0x3e, 0x56, 0x36, 0xcb, + 0x4a, 0x96, 0x0f, 0x27, 0x61, 0xa7, 0x9b, 0x9a, 0xa3, 0xfe, 0xaa, 0xf1, 0xa9, 0x51, 0xc5, 0xc6, + 0x99, 0xfc, 0x5b, 0x99, 0xdc, 0x1d, 0x25, 0xcb, 0x4f, 0xf9, 0xf9, 0xb7, 0x74, 0xb3, 0x61, 0xd4, + 0xa8, 0x9c, 0x72, 0xfe, 0xf0, 0xa5, 0x10, 0x78, 0xfe, 0x52, 0x08, 0x7c, 0x79, 0x24, 0x04, 0x0e, + 0x8f, 0x04, 0xee, 0xd9, 0x91, 0xc0, 0xfd, 0x71, 0x24, 0x70, 0x8f, 0x8f, 0x85, 0xc0, 0xb3, 0x63, + 0x21, 0xf0, 0xfc, 0x58, 0x08, 0xdc, 0xff, 0xf7, 0x1d, 0xbd, 0x4f, 0xfe, 0x23, 0x25, 0xfd, 0xbc, + 0x13, 0x21, 0x3b, 0xe4, 0xad, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x51, 0x14, 0x32, 0x5c, 0xac, + 0x0e, 0x00, 0x00, } func (this *TextProposal) Equal(that interface{}) bool { @@ -1079,6 +1084,16 @@ func (m *DepositParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.MinInitialDepositRatio.Size() + i -= size + if _, err := m.MinInitialDepositRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a n7, err7 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxDepositPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxDepositPeriod):]) if err7 != nil { return 0, err7 @@ -1343,6 +1358,8 @@ func (m *DepositParams) Size() (n int) { } l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxDepositPeriod) n += 1 + l + sovGov(uint64(l)) + l = m.MinInitialDepositRatio.Size() + n += 1 + l + sovGov(uint64(l)) return n } @@ -2489,6 +2506,40 @@ func (m *DepositParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinInitialDepositRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinInitialDepositRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGov(dAtA[iNdEx:]) diff --git a/x/gov/types/params.go b/x/gov/types/params.go index 95621e100f8e..f001cd97b34e 100644 --- a/x/gov/types/params.go +++ b/x/gov/types/params.go @@ -42,8 +42,9 @@ func ParamKeyTable() paramtypes.KeyTable { // NewDepositParams creates a new DepositParams object func NewDepositParams(minDeposit sdk.Coins, maxDepositPeriod time.Duration) DepositParams { return DepositParams{ - MinDeposit: minDeposit, - MaxDepositPeriod: maxDepositPeriod, + MinDeposit: minDeposit, + MaxDepositPeriod: maxDepositPeriod, + MinInitialDepositRatio: sdk.ZeroDec(), } } @@ -51,8 +52,12 @@ func NewDepositParams(minDeposit sdk.Coins, maxDepositPeriod time.Duration) Depo func DefaultDepositParams() DepositParams { return NewDepositParams( sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, DefaultMinDepositTokens)), - DefaultPeriod, - ) + DefaultPeriod) +} + +func (dp DepositParams) WithMinInitialDepositRatio(ratio sdk.Dec) DepositParams { + dp.MinInitialDepositRatio = ratio + return dp } // String implements stringer insterface diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index b5c79669a66d..e4254a4bcc9a 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -69,8 +69,9 @@ func (suite *HandlerTestSuite) TestProposalHandler() { func() { depositParams := suite.app.GovKeeper.GetDepositParams(suite.ctx) suite.Require().Equal(govtypes.DepositParams{ - MinDeposit: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(64000000))), - MaxDepositPeriod: govtypes.DefaultPeriod, + MinDeposit: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(64000000))), + MaxDepositPeriod: govtypes.DefaultPeriod, + MinInitialDepositRatio: sdk.ZeroDec(), }, depositParams) }, false, From 5bcba4fbf190fdc3829e71c4047e1f488698dc4c Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 28 Jul 2022 07:10:05 -0700 Subject: [PATCH 3/4] fix(x/gov): migrations from 2 to 3 (min proposer deposit) (#298) (#302) * git checkout -b roman/fix-gov-migrations * register migrations --- x/gov/keeper/migrations.go | 6 ++++++ x/gov/legacy/v3/store.go | 5 ++--- x/gov/module.go | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/x/gov/keeper/migrations.go b/x/gov/keeper/migrations.go index cad01432bb7d..b6b4721b27d9 100644 --- a/x/gov/keeper/migrations.go +++ b/x/gov/keeper/migrations.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" v043 "github.com/cosmos/cosmos-sdk/x/gov/legacy/v043" + v3 "github.com/cosmos/cosmos-sdk/x/gov/legacy/v3" ) // Migrator is a struct for handling in-place store migrations. @@ -19,3 +20,8 @@ func NewMigrator(keeper Keeper) Migrator { func (m Migrator) Migrate1to2(ctx sdk.Context) error { return v043.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) } + +// Migrate2to3 migrates from version 2 to 3. +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + return v3.MigrateStore(ctx, m.keeper.paramSpace) +} diff --git a/x/gov/legacy/v3/store.go b/x/gov/legacy/v3/store.go index dd25e9338b2b..7caa06db1bbe 100644 --- a/x/gov/legacy/v3/store.go +++ b/x/gov/legacy/v3/store.go @@ -3,7 +3,6 @@ package v3 import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100)) @@ -16,12 +15,12 @@ var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100)) // The migration includes: // // - Setting the minimum deposit param in the paramstore. -func MigrateStore(ctx sdk.Context, paramstore paramtypes.Subspace) error { +func MigrateStore(ctx sdk.Context, paramstore types.ParamSubspace) error { migrateParamsStore(ctx, paramstore) return nil } -func migrateParamsStore(ctx sdk.Context, paramstore paramtypes.Subspace) { +func migrateParamsStore(ctx sdk.Context, paramstore types.ParamSubspace) { var depositParams types.DepositParams paramstore.Get(ctx, types.ParamStoreKeyDepositParams, &depositParams) depositParams.MinInitialDepositRatio = minInitialDepositRatio diff --git a/x/gov/module.go b/x/gov/module.go index 69f6d5572839..65ddb730ed4f 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -161,6 +161,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err != nil { panic(err) } + cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3) + if err != nil { + panic(err) + } } // InitGenesis performs genesis initialization for the gov module. It returns From 28445cdc69bef22e7d429fcfe3c83645528f40aa Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 27 Jul 2022 16:21:53 -0700 Subject: [PATCH 4/4] go mod tidy --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index d9f848223cd2..d855f7eaf011 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/gogo/protobuf v1.3.3 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.2 - github.com/google/go-cmp v0.5.6 // indirect github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0