chore: remove params module entirely (#17838)

This commit is contained in:
Marko
2023-09-22 13:51:37 +00:00
committed by GitHub
parent d325b74a9f
commit 65a1ec64f7
51 changed files with 29 additions and 717 deletions
+2
View File
@@ -261,6 +261,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (signing) [#14087](https://github.com/cosmos/cosmos-sdk/pull/14087) Add SignModeHandlerWithContext interface with a new `GetSignBytesWithContext` to get the sign bytes using `context.Context` as an argument to access state.
* (server) [#14062](https://github.com/cosmos/cosmos-sdk/pull/14062) Remove rosetta from server start.
* (crypto) [#3129](https://github.com/cosmos/cosmos-sdk/pull/3129) New armor and keyring key derivation uses aead and encryption uses chacha20poly.
* (app) [#17838](https://github.com/cosmos/cosmos-sdk/pull/17838) Params module was removed from simapp and all imports of the params module removed throughout the repo.
* The Cosmos SDK has migrated aay from using params, if you're app still uses it, then you can leave it plugged into your app
### State Machine Breaking
+4
View File
@@ -5,6 +5,10 @@ Note, always read the **SimApp** section for more information on application wir
## [Unreleased]
### Params
Params Migrations were removed. It is required to migrate to 0.50 prior to upgrading to .51.
### SimApp
In this section we describe the changes made in Cosmos SDK' SimApp.
-1
View File
@@ -86,7 +86,6 @@ func TestBaseApp_BlockGas(t *testing.T) {
configurator.NewAppConfig(
configurator.AuthModule(),
configurator.TxModule(),
configurator.ParamsModule(),
configurator.ConsensusModule(),
configurator.BankModule(),
configurator.StakingModule(),
-1
View File
@@ -13,7 +13,6 @@ $mockgen_cmd -source=orm/model/ormtable/hooks.go -package ormmocks -destination
$mockgen_cmd -source=x/nft/expected_keepers.go -package testutil -destination x/nft/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/feegrant/expected_keepers.go -package testutil -destination x/feegrant/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/mint/types/expected_keepers.go -package testutil -destination x/mint/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/params/proposal_handler_test.go -package testutil -destination x/params/testutil/staking_keeper_mock.go
$mockgen_cmd -source=x/crisis/types/expected_keepers.go -package testutil -destination x/crisis/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/auth/tx/config/expected_keepers.go -package testutil -destination x/auth/tx/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/auth/types/expected_keepers.go -package testutil -destination x/auth/testutil/expected_keepers_mocks.go
-1
View File
@@ -27,7 +27,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
)
+3 -43
View File
@@ -95,11 +95,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
@@ -155,7 +150,6 @@ type SimApp struct {
GovKeeper govkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
UpgradeKeeper *upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
@@ -253,7 +247,7 @@ func NewSimApp(
keys := storetypes.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
govtypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, circuittypes.StoreKey,
authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
)
@@ -263,7 +257,6 @@ func NewSimApp(
panic(err)
}
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
app := &SimApp{
BaseApp: bApp,
legacyAmino: legacyAmino,
@@ -271,11 +264,8 @@ func NewSimApp(
txConfig: txConfig,
interfaceRegistry: interfaceRegistry,
keys: keys,
tkeys: tkeys,
}
app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
// set the BaseApp's parameter store
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), runtime.EventService{})
bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore)
@@ -340,8 +330,6 @@ func NewSimApp(
// by granting the governance module the right to execute the message.
// See: https://docs.cosmos.network/main/modules/gov#proposal-messages
govRouter := govv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper))
govConfig := govtypes.DefaultConfig()
/*
Example of setting gov params:
@@ -395,7 +383,6 @@ func NewSimApp(
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()),
evidence.NewAppModule(app.EvidenceKeeper),
params.NewAppModule(app.ParamsKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
@@ -412,9 +399,7 @@ func NewSimApp(
map[string]module.AppModuleBasic{
genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
govtypes.ModuleName: gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
},
[]govclient.ProposalHandler{},
),
})
app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino)
@@ -453,7 +438,7 @@ func NewSimApp(
authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
feegrant.ModuleName, nft.ModuleName, group.ModuleName, upgradetypes.ModuleName,
vestingtypes.ModuleName, consensusparamtypes.ModuleName, circuittypes.ModuleName,
}
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
@@ -497,7 +482,6 @@ func NewSimApp(
// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tkeys)
// initialize BaseApp
app.SetInitChainer(app.InitChainer)
@@ -678,14 +662,6 @@ func (app *SimApp) GetStoreKeys() []storetypes.StoreKey {
return keys
}
// GetSubspace returns a param subspace for a given module name.
//
// NOTE: This is solely to be used for testing purposes.
func (app *SimApp) GetSubspace(moduleName string) paramstypes.Subspace {
subspace, _ := app.ParamsKeeper.GetSubspace(moduleName)
return subspace
}
// SimulationManager implements the SimulationApp interface
func (app *SimApp) SimulationManager() *module.SimulationManager {
return app.sm
@@ -757,19 +733,3 @@ func BlockedAddresses() map[string]bool {
return modAccAddrs
}
// initParamsKeeper init params keeper and its subspaces
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)
paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
paramsKeeper.Subspace(stakingtypes.ModuleName)
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName)
paramsKeeper.Subspace(crisistypes.ModuleName)
return paramsKeeper
}
+1 -12
View File
@@ -21,7 +21,6 @@ import (
groupmodulev1 "cosmossdk.io/api/cosmos/group/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
nftmodulev1 "cosmossdk.io/api/cosmos/nft/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
slashingmodulev1 "cosmossdk.io/api/cosmos/slashing/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1"
@@ -65,9 +64,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/group/module" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
_ "github.com/cosmos/cosmos-sdk/x/params" // import for side-effects
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
@@ -152,7 +148,6 @@ var (
feegrant.ModuleName,
nft.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
circuittypes.ModuleName,
@@ -197,10 +192,6 @@ var (
Name: slashingtypes.ModuleName,
Config: appconfig.WrapAny(&slashingmodulev1.Module{}),
},
{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
},
{
Name: "tx",
Config: appconfig.WrapAny(&txconfigv1.Config{}),
@@ -267,9 +258,7 @@ var (
map[string]module.AppModuleBasic{
genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
govtypes.ModuleName: gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
},
[]govclient.ProposalHandler{},
),
},
))
-3
View File
@@ -39,7 +39,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
group "github.com/cosmos/cosmos-sdk/x/group/module"
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
)
@@ -206,7 +205,6 @@ func TestRunMigrations(t *testing.T) {
"slashing": slashing.AppModule{}.ConsensusVersion(),
"gov": gov.AppModule{}.ConsensusVersion(),
"group": group.AppModule{}.ConsensusVersion(),
"params": params.AppModule{}.ConsensusVersion(),
"upgrade": upgrade.AppModule{}.ConsensusVersion(),
"vesting": vesting.AppModule{}.ConsensusVersion(),
"feegrant": feegrantmodule.AppModule{}.ConsensusVersion(),
@@ -255,7 +253,6 @@ func TestInitGenesisOnMigration(t *testing.T) {
"distribution": distribution.AppModule{}.ConsensusVersion(),
"slashing": slashing.AppModule{}.ConsensusVersion(),
"gov": gov.AppModule{}.ConsensusVersion(),
"params": params.AppModule{}.ConsensusVersion(),
"upgrade": upgrade.AppModule{}.ConsensusVersion(),
"vesting": vesting.AppModule{}.ConsensusVersion(),
"feegrant": feegrantmodule.AppModule{}.ConsensusVersion(),
-12
View File
@@ -41,8 +41,6 @@ import (
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
)
@@ -75,7 +73,6 @@ type SimApp struct {
GovKeeper *govkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
UpgradeKeeper *upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
@@ -177,7 +174,6 @@ func NewSimApp(
&app.GovKeeper,
&app.CrisisKeeper,
&app.UpgradeKeeper,
&app.ParamsKeeper,
&app.AuthzKeeper,
&app.EvidenceKeeper,
&app.FeeGrantKeeper,
@@ -317,14 +313,6 @@ func (app *SimApp) kvStoreKeys() map[string]*storetypes.KVStoreKey {
return keys
}
// GetSubspace returns a param subspace for a given module name.
//
// NOTE: This is solely to be used for testing purposes.
func (app *SimApp) GetSubspace(moduleName string) paramstypes.Subspace {
subspace, _ := app.ParamsKeeper.GetSubspace(moduleName)
return subspace
}
// SimulationManager implements the SimulationApp interface
func (app *SimApp) SimulationManager() *module.SimulationManager {
return app.sm
-2
View File
@@ -24,7 +24,6 @@ import (
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/staking"
)
@@ -36,7 +35,6 @@ func Test_TestnetCmd(t *testing.T) {
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distribution.AppModuleBasic{},
params.AppModuleBasic{},
consensus.AppModuleBasic{},
)
-2
View File
@@ -31,7 +31,6 @@ import (
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
_ "github.com/cosmos/cosmos-sdk/x/gov"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
)
@@ -117,7 +116,6 @@ func createTestSuite(t *testing.T, genesisAccounts []authtypes.GenesisAccount) s
app, err := simtestutil.SetupWithConfiguration(
depinject.Configs(
configurator.NewAppConfig(
configurator.ParamsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.TxModule(),
@@ -28,7 +28,6 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
)
-2
View File
@@ -31,7 +31,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
@@ -49,7 +48,6 @@ type suite struct {
}
var appConfig = configurator.NewAppConfig(
configurator.ParamsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.BankModule(),
-1
View File
@@ -22,7 +22,6 @@ func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
app, err := simtestutil.SetupAtGenesis(
depinject.Configs(
configurator.NewAppConfig(
configurator.ParamsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.BankModule(),
-5
View File
@@ -25,7 +25,6 @@ import (
gov_v1beta1_api "cosmossdk.io/api/cosmos/gov/v1beta1"
groupapi "cosmossdk.io/api/cosmos/group/v1"
mintapi "cosmossdk.io/api/cosmos/mint/v1beta1"
paramsapi "cosmossdk.io/api/cosmos/params/v1beta1"
slashingapi "cosmossdk.io/api/cosmos/slashing/v1beta1"
stakingapi "cosmossdk.io/api/cosmos/staking/v1beta1"
upgradeapi "cosmossdk.io/api/cosmos/upgrade/v1beta1"
@@ -45,7 +44,6 @@ import (
gov_v1beta1_types "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
grouptypes "github.com/cosmos/cosmos-sdk/x/group"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@@ -267,9 +265,6 @@ var (
GenType(&minttypes.Params{}, &mintapi.Params{}, GenOpts),
// params
GenType(&proposal.ParameterChangeProposal{}, &paramsapi.ParameterChangeProposal{}, GenOpts),
GenType(&slashingtypes.Params{}, &slashingapi.Params{}, GenOpts.WithDisallowNil()),
GenType(&stakingtypes.StakeAuthorization{}, &stakingapi.StakeAuthorization{}, GenOpts),
+1 -3
View File
@@ -24,7 +24,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
_ "github.com/cosmos/cosmos-sdk/x/bank"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
)
@@ -45,7 +44,6 @@ func initFixture(t assert.TestingT) *fixture {
configurator.NewAppConfig(
configurator.AuthModule(),
configurator.TxModule(),
configurator.ParamsModule(),
configurator.ConsensusModule(),
configurator.BankModule(),
configurator.StakingModule(),
@@ -83,7 +81,7 @@ func TestQueryAppConfig(t *testing.T) {
}
// has all expected modules
for _, modName := range []string{"auth", "bank", "tx", "consensus", "runtime", "params", "staking"} {
for _, modName := range []string{"auth", "bank", "tx", "consensus", "runtime", "staking"} {
modConfig := moduleConfigs[modName]
if modConfig == nil {
t.Fatalf("missing %s", modName)
-2
View File
@@ -33,7 +33,6 @@ func TestDefineCustomGetSigners(t *testing.T) {
_, err := simtestutil.SetupAtGenesis(
depinject.Configs(
configurator.NewAppConfig(
configurator.ParamsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.BankModule(),
@@ -61,7 +60,6 @@ func TestDefineCustomGetSigners(t *testing.T) {
_, err = simtestutil.SetupAtGenesis(
depinject.Configs(
configurator.NewAppConfig(
configurator.ParamsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.BankModule(),
+1 -2
View File
@@ -35,7 +35,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
)
@@ -45,7 +44,7 @@ func TestDecode(t *testing.T) {
encCfg := testutil.MakeTestEncodingConfig(
auth.AppModuleBasic{}, authzmodule.AppModuleBasic{}, bank.AppModuleBasic{}, consensus.AppModuleBasic{},
distribution.AppModuleBasic{}, evidence.AppModuleBasic{}, feegrantmodule.AppModuleBasic{},
gov.AppModuleBasic{}, groupmodule.AppModuleBasic{}, mint.AppModuleBasic{}, params.AppModuleBasic{},
gov.AppModuleBasic{}, groupmodule.AppModuleBasic{}, mint.AppModuleBasic{},
slashing.AppModuleBasic{}, staking.AppModuleBasic{}, upgrade.AppModuleBasic{}, vesting.AppModuleBasic{})
legacytx.RegressionTestingAminoCodec = encCfg.Amino
+1 -3
View File
@@ -56,8 +56,8 @@ func defaultConfig() *Config {
"feegrant",
"nft",
"group",
"params",
"consensus",
"params",
"vesting",
"circuit",
},
@@ -76,7 +76,6 @@ func defaultConfig() *Config {
"feegrant",
"nft",
"group",
"params",
"consensus",
"upgrade",
"vesting",
@@ -97,7 +96,6 @@ func defaultConfig() *Config {
"feegrant",
"nft",
"group",
"params",
"consensus",
"upgrade",
"vesting",
-2
View File
@@ -59,7 +59,6 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import consensus as a blank
"github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/params" // import params as a blank
_ "github.com/cosmos/cosmos-sdk/x/staking" // import staking as a blank
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@@ -175,7 +174,6 @@ func DefaultConfig(factory TestFixtureFactory) Config {
func MinimumAppConfig() depinject.Config {
return configurator.NewAppConfig(
configurator.AuthModule(),
configurator.ParamsModule(),
configurator.BankModule(),
configurator.GenutilModule(),
configurator.StakingModule(),
-2
View File
@@ -30,7 +30,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/params"
)
const (
@@ -71,7 +70,6 @@ func (s *paginationTestSuite) SetupTest() {
configurator.NewAppConfig(
configurator.AuthModule(),
configurator.BankModule(),
configurator.ParamsModule(),
configurator.ConsensusModule(),
configurator.OmitInitGenesis(),
),
-2
View File
@@ -8,7 +8,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
)
@@ -19,6 +18,5 @@ var AppConfig = configurator.NewAppConfig(
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.GenutilModule(),
)
-38
View File
@@ -1,38 +0,0 @@
/*
NOTE: Usage of x/params to manage parameters is deprecated in favor of x/gov
controlled execution of MsgUpdateParams messages. These types remains solely
for migration purposes and will be removed in a future release.
*/
package types
import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// Parameter keys
var (
KeyMaxMemoCharacters = []byte("MaxMemoCharacters")
KeyTxSigLimit = []byte("TxSigLimit")
KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte")
KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519")
KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1")
)
var _ paramtypes.ParamSet = &Params{}
// Deprecated: ParamKeyTable for auth module
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// ParamSetPairs implements the ParamSet interface and returns all the key/value pairs
// pairs of auth module's parameters.
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyMaxMemoCharacters, &p.MaxMemoCharacters, validateMaxMemoCharacters),
paramtypes.NewParamSetPair(KeyTxSigLimit, &p.TxSigLimit, validateTxSigLimit),
paramtypes.NewParamSetPair(KeyTxSizeCostPerByte, &p.TxSizeCostPerByte, validateTxSizeCostPerByte),
paramtypes.NewParamSetPair(KeySigVerifyCostED25519, &p.SigVerifyCostED25519, validateSigVerifyCostED25519),
paramtypes.NewParamSetPair(KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1, validateSigVerifyCostSecp256k1),
}
}
-2
View File
@@ -10,7 +10,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/gov" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/mint" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
)
@@ -20,7 +19,6 @@ var AppConfig = configurator.NewAppConfig(
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.GenutilModule(),
configurator.AuthzModule(),
configurator.MintModule(),
+4 -1
View File
@@ -12,6 +12,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank/types"
)
// KeyDefaultSendEnabled is store's key for the DefaultSendEnabled option
var KeyDefaultSendEnabled = []byte("DefaultSendEnabled")
// RandomGenesisDefaultSendEnabledParam computes randomized allow all send transfers param for the bank module
func RandomGenesisDefaultSendEnabledParam(r *rand.Rand) bool {
// 90% chance of transfers being enabled or P(a) = 0.9 for success
@@ -72,7 +75,7 @@ func RandomGenesisBalances(simState *module.SimulationState) []types.Balance {
// RandomizedGenState generates a random GenesisState for bank
func RandomizedGenState(simState *module.SimulationState) {
var defaultSendEnabledParam bool
simState.AppParams.GetOrGenerate(string(types.KeyDefaultSendEnabled), &defaultSendEnabledParam, simState.Rand, func(r *rand.Rand) { defaultSendEnabledParam = RandomGenesisDefaultSendEnabledParam(r) })
simState.AppParams.GetOrGenerate(string(KeyDefaultSendEnabled), &defaultSendEnabledParam, simState.Rand, func(r *rand.Rand) { defaultSendEnabledParam = RandomGenesisDefaultSendEnabledParam(r) })
sendEnabled := RandomGenesisSendEnabled(simState.Rand, simState.BondDenom)
-2
View File
@@ -26,7 +26,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
)
@@ -50,7 +49,6 @@ func (suite *SimTestSuite) SetupTest() {
depinject.Configs(
configurator.NewAppConfig(
configurator.AuthModule(),
configurator.ParamsModule(),
configurator.BankModule(),
configurator.StakingModule(),
configurator.ConsensusModule(),
-23
View File
@@ -1,23 +0,0 @@
package types
import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
var (
// KeySendEnabled is store's key for SendEnabled Params
// Deprecated: Use the SendEnabled functionality in the keeper.
KeySendEnabled = []byte("SendEnabled")
// KeyDefaultSendEnabled is store's key for the DefaultSendEnabled option
KeyDefaultSendEnabled = []byte("DefaultSendEnabled")
)
// Deprecated: ParamKeyTable for bank module.
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// Deprecated: ParamSetPairs implements params.ParamSet
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyDefaultSendEnabled, &p.DefaultSendEnabled, validateIsBool),
}
}
-9
View File
@@ -4,18 +4,9 @@ import (
"context"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type (
// ParamStore defines an interface that implements the legacy x/params Subspace
// type.
//
// NOTE: This is used solely for migration of x/params managed parameters.
ParamStore interface {
Get(ctx sdk.Context, key []byte, ptr interface{})
}
// ConsensusParamSetter defines the interface fulfilled by BaseApp's
// ParamStore which allows setting its appVersion field.
-31
View File
@@ -1,31 +0,0 @@
package types
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// ParamStoreKeyConstantFee is the constant fee parameter
var ParamStoreKeyConstantFee = []byte("ConstantFee")
// Deprecated: Type declaration for parameters
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable(
paramtypes.NewParamSetPair(ParamStoreKeyConstantFee, sdk.Coin{}, validateConstantFee),
)
}
func validateConstantFee(i interface{}) error {
v, ok := i.(sdk.Coin)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if !v.IsValid() {
return fmt.Errorf("invalid constant fee: %s", v)
}
return nil
}
-18
View File
@@ -1,18 +0,0 @@
package exported
import (
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
type (
ParamSet = paramtypes.ParamSet
// Subspace defines an interface that implements the legacy x/params Subspace
// type.
//
// NOTE: This is used solely for migration of x/params managed parameters.
Subspace interface {
GetParamSet(ctx sdk.Context, ps ParamSet)
}
)
-2
View File
@@ -9,7 +9,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/mint" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
)
@@ -19,7 +18,6 @@ var AppConfig = configurator.NewAppConfig(
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.GenutilModule(),
configurator.DistributionModule(),
configurator.MintModule(),
-9
View File
@@ -39,12 +39,3 @@ func validateCommunityTax(i interface{}) error {
return nil
}
func validateWithdrawAddrEnabled(i interface{}) error {
_, ok := i.(bool)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
return nil
}
-22
View File
@@ -1,22 +0,0 @@
package types
import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
// Parameter keys
var (
ParamStoreKeyCommunityTax = []byte("communitytax")
ParamStoreKeyWithdrawAddrEnabled = []byte("withdrawaddrenabled")
)
// Deprecated: ParamKeyTable returns the parameter key table.
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// Deprecated: ParamSetPairs returns the parameter set pairs.
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(ParamStoreKeyCommunityTax, &p.CommunityTax, validateCommunityTax),
paramtypes.NewParamSetPair(ParamStoreKeyWithdrawAddrEnabled, &p.WithdrawAddrEnabled, validateWithdrawAddrEnabled),
}
}
-2
View File
@@ -9,7 +9,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/bank" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
)
@@ -21,7 +20,6 @@ var AppConfig = configurator.NewAppConfig(
configurator.SlashingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.EvidenceModule(),
configurator.GenutilModule(),
)
-2
View File
@@ -36,7 +36,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/consensus"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
_ "github.com/cosmos/cosmos-sdk/x/mint"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
)
@@ -64,7 +63,6 @@ func (suite *SimTestSuite) SetupTest() {
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.GenutilModule(),
configurator.FeegrantModule(),
),
-2
View File
@@ -30,7 +30,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
@@ -120,7 +119,6 @@ func createTestSuite(t *testing.T) suite {
app, err := simtestutil.SetupWithConfiguration(
depinject.Configs(
configurator.NewAppConfig(
configurator.ParamsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.BankModule(),
+2 -7
View File
@@ -33,7 +33,6 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
const ConsensusVersion = 5
@@ -158,12 +157,8 @@ func (am AppModule) IsAppModule() {}
func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(ProvideModule, ProvideKeyTable),
appmodule.Invoke(InvokeAddRoutes, InvokeSetHooks))
}
func ProvideKeyTable() paramtypes.KeyTable {
return v1.ParamKeyTable() //nolint:staticcheck // we still need this for upgrades
appmodule.Invoke(InvokeAddRoutes, InvokeSetHooks),
appmodule.Provide(ProvideModule))
}
type ModuleInputs struct {
-2
View File
@@ -35,7 +35,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
)
@@ -424,7 +423,6 @@ func createTestSuite(t *testing.T, isCheckTx bool) (suite, sdk.Context) {
configurator.NewAppConfig(
configurator.AuthModule(),
configurator.TxModule(),
configurator.ParamsModule(),
configurator.BankModule(),
configurator.StakingModule(),
configurator.ConsensusModule(),
-102
View File
@@ -1,102 +0,0 @@
package v1
import (
"errors"
"fmt"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// Parameter store key
var (
ParamStoreKeyDepositParams = []byte("depositparams")
ParamStoreKeyVotingParams = []byte("votingparams")
ParamStoreKeyTallyParams = []byte("tallyparams")
)
// Deprecated: ParamKeyTable - Key declaration for parameters
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable(
paramtypes.NewParamSetPair(ParamStoreKeyDepositParams, DepositParams{}, validateDepositParams),
paramtypes.NewParamSetPair(ParamStoreKeyVotingParams, VotingParams{}, validateVotingParams),
paramtypes.NewParamSetPair(ParamStoreKeyTallyParams, TallyParams{}, validateTallyParams),
)
}
func validateDepositParams(i interface{}) error {
v, ok := i.(DepositParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if !sdk.Coins(v.MinDeposit).IsValid() {
return fmt.Errorf("invalid minimum deposit: %s", v.MinDeposit)
}
if v.MaxDepositPeriod == nil || v.MaxDepositPeriod.Seconds() <= 0 {
return fmt.Errorf("maximum deposit period must be positive: %d", v.MaxDepositPeriod)
}
return nil
}
func validateTallyParams(i interface{}) error {
v, ok := i.(TallyParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
quorum, err := math.LegacyNewDecFromStr(v.Quorum)
if err != nil {
return fmt.Errorf("invalid quorum string: %w", err)
}
if quorum.IsNegative() {
return fmt.Errorf("quorom cannot be negative: %s", quorum)
}
if quorum.GT(math.LegacyOneDec()) {
return fmt.Errorf("quorom too large: %s", v)
}
threshold, err := math.LegacyNewDecFromStr(v.Threshold)
if err != nil {
return fmt.Errorf("invalid threshold string: %w", err)
}
if !threshold.IsPositive() {
return fmt.Errorf("vote threshold must be positive: %s", threshold)
}
if threshold.GT(math.LegacyOneDec()) {
return fmt.Errorf("vote threshold too large: %s", v)
}
vetoThreshold, err := math.LegacyNewDecFromStr(v.VetoThreshold)
if err != nil {
return fmt.Errorf("invalid vetoThreshold string: %w", err)
}
if !vetoThreshold.IsPositive() {
return fmt.Errorf("veto threshold must be positive: %s", vetoThreshold)
}
if vetoThreshold.GT(math.LegacyOneDec()) {
return fmt.Errorf("veto threshold too large: %s", v)
}
return nil
}
func validateVotingParams(i interface{}) error {
v, ok := i.(VotingParams)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.VotingPeriod == nil {
return errors.New("voting period must not be nil")
}
if v.VotingPeriod.Seconds() <= 0 {
return fmt.Errorf("voting period must be positive: %s", v.VotingPeriod)
}
return nil
}
-2
View File
@@ -10,7 +10,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/group/module" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/mint" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
)
@@ -20,7 +19,6 @@ var AppConfig = configurator.NewAppConfig(
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.GenutilModule(),
configurator.GroupModule(),
)
-2
View File
@@ -8,7 +8,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/mint" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
)
@@ -18,7 +17,6 @@ var AppConfig = configurator.NewAppConfig(
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.GenutilModule(),
configurator.MintModule(),
)
-39
View File
@@ -1,39 +0,0 @@
/*
NOTE: Usage of x/params to manage parameters is deprecated in favor of x/gov
controlled execution of MsgUpdateParams messages. These types remains solely
for migration purposes and will be removed in a future release.
*/
package types
import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// Parameter store keys
var (
KeyMintDenom = []byte("MintDenom")
KeyInflationRateChange = []byte("InflationRateChange")
KeyInflationMax = []byte("InflationMax")
KeyInflationMin = []byte("InflationMin")
KeyGoalBonded = []byte("GoalBonded")
KeyBlocksPerYear = []byte("BlocksPerYear")
)
// Deprecated: ParamTable for minting module.
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// Implements params.ParamSet
//
// Deprecated.
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyMintDenom, &p.MintDenom, validateMintDenom),
paramtypes.NewParamSetPair(KeyInflationRateChange, &p.InflationRateChange, validateInflationRateChange),
paramtypes.NewParamSetPair(KeyInflationMax, &p.InflationMax, validateInflationMax),
paramtypes.NewParamSetPair(KeyInflationMin, &p.InflationMin, validateInflationMin),
paramtypes.NewParamSetPair(KeyGoalBonded, &p.GoalBonded, validateGoalBonded),
paramtypes.NewParamSetPair(KeyBlocksPerYear, &p.BlocksPerYear, validateBlocksPerYear),
}
}
-2
View File
@@ -10,7 +10,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/mint" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
)
@@ -20,7 +19,6 @@ var AppConfig = configurator.NewAppConfig(
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.GenutilModule(),
configurator.MintModule(),
configurator.NFTModule(),
-116
View File
@@ -1,116 +0,0 @@
package params_test
import (
"context"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstestutil "github.com/cosmos/cosmos-sdk/x/params/testutil"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
// StakingKeeper defines the expected staking keeper
type StakingKeeper interface {
MaxValidators(ctx context.Context) (res uint32, err error)
}
type HandlerTestSuite struct {
suite.Suite
ctx sdk.Context
govHandler govv1beta1.Handler
stakingKeeper StakingKeeper
}
func (suite *HandlerTestSuite) SetupTest() {
encodingCfg := moduletestutil.MakeTestEncodingConfig(params.AppModuleBasic{})
key := storetypes.NewKVStoreKey(paramtypes.StoreKey)
tkey := storetypes.NewTransientStoreKey("params_transient_test")
ctx := testutil.DefaultContext(key, tkey)
paramsKeeper := keeper.NewKeeper(encodingCfg.Codec, encodingCfg.Amino, key, tkey)
paramsKeeper.Subspace("staking").WithKeyTable(stakingtypes.ParamKeyTable()) //nolint:staticcheck // TODO: depreacte this test case
ctrl := gomock.NewController(suite.T())
stakingKeeper := paramstestutil.NewMockStakingKeeper(ctrl)
stakingKeeper.EXPECT().MaxValidators(ctx).Return(uint32(1), nil)
suite.govHandler = params.NewParamChangeProposalHandler(paramsKeeper)
suite.stakingKeeper = stakingKeeper
suite.ctx = ctx
}
func TestHandlerTestSuite(t *testing.T) {
suite.Run(t, new(HandlerTestSuite))
}
func testProposal(changes ...proposal.ParamChange) *proposal.ParameterChangeProposal {
return proposal.NewParameterChangeProposal("title", "description", changes)
}
func (suite *HandlerTestSuite) TestProposalHandler() {
testCases := []struct {
name string
proposal *proposal.ParameterChangeProposal
onHandle func()
expErr bool
}{
{
"all fields",
testProposal(proposal.NewParamChange(stakingtypes.ModuleName, string(stakingtypes.KeyMaxValidators), "1")),
func() {
maxVals, err := suite.stakingKeeper.MaxValidators(suite.ctx)
suite.Require().NoError(err)
suite.Require().Equal(uint32(1), maxVals)
},
false,
},
{
"invalid type",
testProposal(proposal.NewParamChange(stakingtypes.ModuleName, string(stakingtypes.KeyMaxValidators), "-")),
func() {},
true,
},
//{
// "omit empty fields",
// testProposal(proposal.ParamChange{
// Subspace: govtypes.ModuleName,
// Key: string(govv1.ParamStoreKeyDepositParams),
// Value: `{"min_deposit": [{"denom": "uatom","amount": "64000000"}], "max_deposit_period": "172800000000000"}`,
// }),
// func() {
// depositParams := suite.app.GovKeeper.GetDepositParams(suite.ctx)
// defaultPeriod := govv1.DefaultPeriod
// suite.Require().Equal(govv1.DepositParams{
// MinDeposit: sdk.NewCoins(sdk.NewCoin("uatom", sdkmath.NewInt(64000000))),
// MaxDepositPeriod: &defaultPeriod,
// }, depositParams)
// },
// false,
// },
}
for _, tc := range testCases {
tc := tc
suite.Run(tc.name, func() {
err := suite.govHandler(suite.ctx, tc.proposal)
if tc.expErr {
suite.Require().Error(err)
} else {
suite.Require().NoError(err)
tc.onHandle()
}
})
}
}
-1
View File
@@ -57,7 +57,6 @@ func TestSlashingMsgs(t *testing.T) {
app, err := sims.SetupWithConfiguration(
depinject.Configs(
configurator.NewAppConfig(
configurator.ParamsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.SlashingModule(),
-2
View File
@@ -9,7 +9,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/mint" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
)
@@ -21,7 +20,6 @@ var AppConfig = configurator.NewAppConfig(
configurator.SlashingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.GenutilModule(),
configurator.MintModule(),
configurator.DistributionModule(),
+10 -98
View File
@@ -12,8 +12,7 @@ import (
address "cosmossdk.io/core/address"
math "cosmossdk.io/math"
types "github.com/cosmos/cosmos-sdk/types"
types0 "github.com/cosmos/cosmos-sdk/x/params/types"
types1 "github.com/cosmos/cosmos-sdk/x/staking/types"
types0 "github.com/cosmos/cosmos-sdk/x/staking/types"
gomock "github.com/golang/mock/gomock"
)
@@ -145,93 +144,6 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr)
}
// MockParamSubspace is a mock of ParamSubspace interface.
type MockParamSubspace struct {
ctrl *gomock.Controller
recorder *MockParamSubspaceMockRecorder
}
// MockParamSubspaceMockRecorder is the mock recorder for MockParamSubspace.
type MockParamSubspaceMockRecorder struct {
mock *MockParamSubspace
}
// NewMockParamSubspace creates a new mock instance.
func NewMockParamSubspace(ctrl *gomock.Controller) *MockParamSubspace {
mock := &MockParamSubspace{ctrl: ctrl}
mock.recorder = &MockParamSubspaceMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockParamSubspace) EXPECT() *MockParamSubspaceMockRecorder {
return m.recorder
}
// Get mocks base method.
func (m *MockParamSubspace) Get(ctx types.Context, key []byte, ptr interface{}) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Get", ctx, key, ptr)
}
// Get indicates an expected call of Get.
func (mr *MockParamSubspaceMockRecorder) Get(ctx, key, ptr interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockParamSubspace)(nil).Get), ctx, key, ptr)
}
// GetParamSet mocks base method.
func (m *MockParamSubspace) GetParamSet(ctx types.Context, ps types0.ParamSet) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "GetParamSet", ctx, ps)
}
// GetParamSet indicates an expected call of GetParamSet.
func (mr *MockParamSubspaceMockRecorder) GetParamSet(ctx, ps interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParamSet", reflect.TypeOf((*MockParamSubspace)(nil).GetParamSet), ctx, ps)
}
// HasKeyTable mocks base method.
func (m *MockParamSubspace) HasKeyTable() bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HasKeyTable")
ret0, _ := ret[0].(bool)
return ret0
}
// HasKeyTable indicates an expected call of HasKeyTable.
func (mr *MockParamSubspaceMockRecorder) HasKeyTable() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasKeyTable", reflect.TypeOf((*MockParamSubspace)(nil).HasKeyTable))
}
// SetParamSet mocks base method.
func (m *MockParamSubspace) SetParamSet(ctx types.Context, ps types0.ParamSet) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetParamSet", ctx, ps)
}
// SetParamSet indicates an expected call of SetParamSet.
func (mr *MockParamSubspaceMockRecorder) SetParamSet(ctx, ps interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetParamSet", reflect.TypeOf((*MockParamSubspace)(nil).SetParamSet), ctx, ps)
}
// WithKeyTable mocks base method.
func (m *MockParamSubspace) WithKeyTable(table types0.KeyTable) types0.Subspace {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "WithKeyTable", table)
ret0, _ := ret[0].(types0.Subspace)
return ret0
}
// WithKeyTable indicates an expected call of WithKeyTable.
func (mr *MockParamSubspaceMockRecorder) WithKeyTable(table interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithKeyTable", reflect.TypeOf((*MockParamSubspace)(nil).WithKeyTable), table)
}
// MockStakingKeeper is a mock of StakingKeeper interface.
type MockStakingKeeper struct {
ctrl *gomock.Controller
@@ -270,10 +182,10 @@ func (mr *MockStakingKeeperMockRecorder) ConsensusAddressCodec() *gomock.Call {
}
// Delegation mocks base method.
func (m *MockStakingKeeper) Delegation(arg0 context.Context, arg1 types.AccAddress, arg2 types.ValAddress) (types1.DelegationI, error) {
func (m *MockStakingKeeper) Delegation(arg0 context.Context, arg1 types.AccAddress, arg2 types.ValAddress) (types0.DelegationI, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Delegation", arg0, arg1, arg2)
ret0, _ := ret[0].(types1.DelegationI)
ret0, _ := ret[0].(types0.DelegationI)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -285,10 +197,10 @@ func (mr *MockStakingKeeperMockRecorder) Delegation(arg0, arg1, arg2 interface{}
}
// GetAllValidators mocks base method.
func (m *MockStakingKeeper) GetAllValidators(ctx context.Context) ([]types1.Validator, error) {
func (m *MockStakingKeeper) GetAllValidators(ctx context.Context) ([]types0.Validator, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetAllValidators", ctx)
ret0, _ := ret[0].([]types1.Validator)
ret0, _ := ret[0].([]types0.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -315,7 +227,7 @@ func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{}
}
// IterateValidators mocks base method.
func (m *MockStakingKeeper) IterateValidators(arg0 context.Context, arg1 func(int64, types1.ValidatorI) bool) error {
func (m *MockStakingKeeper) IterateValidators(arg0 context.Context, arg1 func(int64, types0.ValidatorI) bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IterateValidators", arg0, arg1)
ret0, _ := ret[0].(error)
@@ -402,10 +314,10 @@ func (mr *MockStakingKeeperMockRecorder) Unjail(arg0, arg1 interface{}) *gomock.
}
// Validator mocks base method.
func (m *MockStakingKeeper) Validator(arg0 context.Context, arg1 types.ValAddress) (types1.ValidatorI, error) {
func (m *MockStakingKeeper) Validator(arg0 context.Context, arg1 types.ValAddress) (types0.ValidatorI, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Validator", arg0, arg1)
ret0, _ := ret[0].(types1.ValidatorI)
ret0, _ := ret[0].(types0.ValidatorI)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -431,10 +343,10 @@ func (mr *MockStakingKeeperMockRecorder) ValidatorAddressCodec() *gomock.Call {
}
// ValidatorByConsAddr mocks base method.
func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 context.Context, arg1 types.ConsAddress) (types1.ValidatorI, error) {
func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 context.Context, arg1 types.ConsAddress) (types0.ValidatorI, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1)
ret0, _ := ret[0].(types1.ValidatorI)
ret0, _ := ret[0].(types0.ValidatorI)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-10
View File
@@ -8,7 +8,6 @@ import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
@@ -26,15 +25,6 @@ type BankKeeper interface {
SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins
}
// ParamSubspace defines the expected Subspace interfacace
type ParamSubspace interface {
HasKeyTable() bool
WithKeyTable(table paramtypes.KeyTable) paramtypes.Subspace
Get(ctx sdk.Context, key []byte, ptr interface{})
GetParamSet(ctx sdk.Context, ps paramtypes.ParamSet)
SetParamSet(ctx sdk.Context, ps paramtypes.ParamSet)
}
// StakingKeeper expected staking keeper
type StakingKeeper interface {
ValidatorAddressCodec() address.Codec
-35
View File
@@ -1,35 +0,0 @@
/*
NOTE: Usage of x/params to manage parameters is deprecated in favor of x/gov
controlled execution of MsgUpdateParams messages. These types remains solely
for migration purposes and will be removed in a future release.
*/
package types
import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// Parameter store keys
var (
KeySignedBlocksWindow = []byte("SignedBlocksWindow")
KeyMinSignedPerWindow = []byte("MinSignedPerWindow")
KeyDowntimeJailDuration = []byte("DowntimeJailDuration")
KeySlashFractionDoubleSign = []byte("SlashFractionDoubleSign")
KeySlashFractionDowntime = []byte("SlashFractionDowntime")
)
// Deprecated: ParamKeyTable for slashing module
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// Deprecated: ParamSetPairs implements params.ParamSet
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeySignedBlocksWindow, &p.SignedBlocksWindow, validateSignedBlocksWindow),
paramtypes.NewParamSetPair(KeyMinSignedPerWindow, &p.MinSignedPerWindow, validateMinSignedPerWindow),
paramtypes.NewParamSetPair(KeyDowntimeJailDuration, &p.DowntimeJailDuration, validateDowntimeJailDuration),
paramtypes.NewParamSetPair(KeySlashFractionDoubleSign, &p.SlashFractionDoubleSign, validateSlashFractionDoubleSign),
paramtypes.NewParamSetPair(KeySlashFractionDowntime, &p.SlashFractionDowntime, validateSlashFractionDowntime),
}
}
-2
View File
@@ -9,7 +9,6 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/genutil" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/mint" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/params" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import as blank for app wiring
_ "github.com/cosmos/cosmos-sdk/x/staking" // import as blank for app wiring
)
@@ -20,7 +19,6 @@ var AppConfig = configurator.NewAppConfig(
configurator.StakingModule(),
configurator.TxModule(),
configurator.ConsensusModule(),
configurator.ParamsModule(),
configurator.GenutilModule(),
configurator.MintModule(),
configurator.DistributionModule(),
-32
View File
@@ -1,32 +0,0 @@
package types
import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
var (
KeyUnbondingTime = []byte("UnbondingTime")
KeyMaxValidators = []byte("MaxValidators")
KeyMaxEntries = []byte("MaxEntries")
KeyBondDenom = []byte("BondDenom")
KeyHistoricalEntries = []byte("HistoricalEntries")
KeyMinCommissionRate = []byte("MinCommissionRate")
)
var _ paramtypes.ParamSet = (*Params)(nil)
// Deprecated: now params can be accessed on key `0x51` on the staking store.
// ParamTable for staking module
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// Deprecated: Implements params.ParamSet
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyUnbondingTime, &p.UnbondingTime, validateUnbondingTime),
paramtypes.NewParamSetPair(KeyMaxValidators, &p.MaxValidators, validateMaxValidators),
paramtypes.NewParamSetPair(KeyMaxEntries, &p.MaxEntries, validateMaxEntries),
paramtypes.NewParamSetPair(KeyHistoricalEntries, &p.HistoricalEntries, validateHistoricalEntries),
paramtypes.NewParamSetPair(KeyBondDenom, &p.BondDenom, validateBondDenom),
paramtypes.NewParamSetPair(KeyMinCommissionRate, &p.MinCommissionRate, validateMinCommissionRate),
}
}