Remove DefaultParamspace and simplify simapp creation. (#6564)
* Remove DefaultParamspace and simplify simapp creation. * Update changelog. * Create function that inits ParamsKeeper. * Update CHANGELOG.md Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
b671bff594
commit
6a52c5a569
|
@ -63,6 +63,7 @@ older clients.
|
|||
|
||||
### API Breaking Changes
|
||||
|
||||
* (modules) [\#6564](https://github.com/cosmos/cosmos-sdk/pull/6564) Constant `DefaultParamspace` is removed from all modules, use ModuleName instead.
|
||||
* (client) [\#6525](https://github.com/cosmos/cosmos-sdk/pull/6525) Removed support for `indent` in JSON responses. Clients should consider piping to an external tool such as `jq`.
|
||||
* (x/staking) [\#6451](https://github.com/cosmos/cosmos-sdk/pull/6451) `DefaultParamspace` and `ParamKeyTable` in staking module are moved from keeper to types to enforce consistency.
|
||||
* [\#6409](https://github.com/cosmos/cosmos-sdk/pull/6409) Rename all IsEmpty methods to Empty across the codebase and enforce consistency.
|
||||
|
|
|
@ -139,9 +139,6 @@ type SimApp struct {
|
|||
tkeys map[string]*sdk.TransientStoreKey
|
||||
memKeys map[string]*sdk.MemoryStoreKey
|
||||
|
||||
// subspaces
|
||||
subspaces map[string]paramstypes.Subspace
|
||||
|
||||
// keepers
|
||||
AccountKeeper authkeeper.AccountKeeper
|
||||
BankKeeper bankkeeper.Keeper
|
||||
|
@ -199,19 +196,9 @@ func NewSimApp(
|
|||
keys: keys,
|
||||
tkeys: tkeys,
|
||||
memKeys: memKeys,
|
||||
subspaces: make(map[string]paramstypes.Subspace),
|
||||
}
|
||||
|
||||
// init params keeper and subspaces
|
||||
app.ParamsKeeper = paramskeeper.NewKeeper(appCodec, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
|
||||
app.subspaces[authtypes.ModuleName] = app.ParamsKeeper.Subspace(authtypes.DefaultParamspace)
|
||||
app.subspaces[banktypes.ModuleName] = app.ParamsKeeper.Subspace(banktypes.DefaultParamspace)
|
||||
app.subspaces[stakingtypes.ModuleName] = app.ParamsKeeper.Subspace(stakingtypes.DefaultParamspace)
|
||||
app.subspaces[minttypes.ModuleName] = app.ParamsKeeper.Subspace(minttypes.DefaultParamspace)
|
||||
app.subspaces[distrtypes.ModuleName] = app.ParamsKeeper.Subspace(distrtypes.DefaultParamspace)
|
||||
app.subspaces[slashingtypes.ModuleName] = app.ParamsKeeper.Subspace(slashingtypes.DefaultParamspace)
|
||||
app.subspaces[govtypes.ModuleName] = app.ParamsKeeper.Subspace(govtypes.DefaultParamspace).WithKeyTable(govtypes.ParamKeyTable())
|
||||
app.subspaces[crisistypes.ModuleName] = app.ParamsKeeper.Subspace(crisistypes.DefaultParamspace)
|
||||
app.ParamsKeeper = initParamsKeeper(appCodec, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
|
||||
|
||||
// set the BaseApp's parameter store
|
||||
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(std.ConsensusParamsKeyTable()))
|
||||
|
@ -223,27 +210,27 @@ func NewSimApp(
|
|||
|
||||
// add keepers
|
||||
app.AccountKeeper = authkeeper.NewAccountKeeper(
|
||||
appCodec, keys[authtypes.StoreKey], app.subspaces[authtypes.ModuleName], authtypes.ProtoBaseAccount, maccPerms,
|
||||
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms,
|
||||
)
|
||||
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
||||
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.subspaces[banktypes.ModuleName], app.BlockedAddrs(),
|
||||
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlockedAddrs(),
|
||||
)
|
||||
stakingKeeper := stakingkeeper.NewKeeper(
|
||||
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.subspaces[stakingtypes.ModuleName],
|
||||
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName),
|
||||
)
|
||||
app.MintKeeper = mintkeeper.NewKeeper(
|
||||
appCodec, keys[minttypes.StoreKey], app.subspaces[minttypes.ModuleName], &stakingKeeper,
|
||||
appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper,
|
||||
app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName,
|
||||
)
|
||||
app.DistrKeeper = distrkeeper.NewKeeper(
|
||||
appCodec, keys[distrtypes.StoreKey], app.subspaces[distrtypes.ModuleName], app.AccountKeeper, app.BankKeeper,
|
||||
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
||||
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
|
||||
)
|
||||
app.SlashingKeeper = slashingkeeper.NewKeeper(
|
||||
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.subspaces[slashingtypes.ModuleName],
|
||||
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
|
||||
)
|
||||
app.CrisisKeeper = crisiskeeper.NewKeeper(
|
||||
app.subspaces[crisistypes.ModuleName], invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
|
||||
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
|
||||
)
|
||||
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath)
|
||||
|
||||
|
@ -254,7 +241,7 @@ func NewSimApp(
|
|||
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
|
||||
app.GovKeeper = govkeeper.NewKeeper(
|
||||
appCodec, keys[govtypes.StoreKey], app.subspaces[govtypes.ModuleName], app.AccountKeeper, app.BankKeeper,
|
||||
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
||||
&stakingKeeper, govRouter,
|
||||
)
|
||||
|
||||
|
@ -494,7 +481,8 @@ func (app *SimApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey {
|
|||
//
|
||||
// NOTE: This is solely to be used for testing purposes.
|
||||
func (app *SimApp) GetSubspace(moduleName string) paramstypes.Subspace {
|
||||
return app.subspaces[moduleName]
|
||||
subspace, _ := app.ParamsKeeper.GetSubspace(moduleName)
|
||||
return subspace
|
||||
}
|
||||
|
||||
// SimulationManager implements the SimulationApp interface
|
||||
|
@ -518,3 +506,19 @@ func GetMaccPerms() map[string][]string {
|
|||
}
|
||||
return dupMaccPerms
|
||||
}
|
||||
|
||||
// initParamsKeeper init params keeper and its subspaces
|
||||
func initParamsKeeper(appCodec codec.Marshaler, key, tkey sdk.StoreKey) paramskeeper.Keeper {
|
||||
paramsKeeper := paramskeeper.NewKeeper(appCodec, 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).WithKeyTable(govtypes.ParamKeyTable())
|
||||
paramsKeeper.Subspace(crisistypes.ModuleName)
|
||||
|
||||
return paramsKeeper
|
||||
}
|
||||
|
|
|
@ -8,9 +8,6 @@ import (
|
|||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// DefaultParamspace defines the default auth module parameter subspace
|
||||
const DefaultParamspace = ModuleName
|
||||
|
||||
// Default parameter values
|
||||
const (
|
||||
DefaultMaxMemoCharacters uint64 = 256
|
||||
|
|
|
@ -7,8 +7,6 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// DefaultParamspace for params keeper
|
||||
DefaultParamspace = ModuleName
|
||||
// DefaultSendEnabled enabled
|
||||
DefaultSendEnabled = true
|
||||
)
|
||||
|
|
|
@ -7,11 +7,6 @@ import (
|
|||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Default parameter namespace
|
||||
const (
|
||||
DefaultParamspace = ModuleName
|
||||
)
|
||||
|
||||
var (
|
||||
// key for constant fee parameter
|
||||
ParamStoreKeyConstantFee = []byte("ConstantFee")
|
||||
|
|
|
@ -9,11 +9,6 @@ import (
|
|||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
const (
|
||||
// default paramspace for params keeper
|
||||
DefaultParamspace = ModuleName
|
||||
)
|
||||
|
||||
// Parameter keys
|
||||
var (
|
||||
ParamStoreKeyCommunityTax = []byte("communitytax")
|
||||
|
|
|
@ -21,7 +21,7 @@ A full setup of the evidence module may look something as follows:
|
|||
)
|
||||
|
||||
// First, create the keeper's subspace for parameters and the keeper itself.
|
||||
evidenceParamspace := app.ParamsKeeper.Subspace(evidence.DefaultParamspace)
|
||||
evidenceParamspace := app.ParamsKeeper.Subspace(evidence.ModuleName)
|
||||
evidenceKeeper := evidence.NewKeeper(
|
||||
app.cdc, keys[evidence.StoreKey], evidenceParamspace, evidence.DefaultCodespace,
|
||||
)
|
||||
|
|
|
@ -20,9 +20,6 @@ const (
|
|||
|
||||
// QuerierRoute is the querier route for gov
|
||||
QuerierRoute = ModuleName
|
||||
|
||||
// DefaultParamspace default name for parameter store
|
||||
DefaultParamspace = ModuleName
|
||||
)
|
||||
|
||||
// Keys for governance store
|
||||
|
|
|
@ -7,9 +7,6 @@ const (
|
|||
// module name
|
||||
ModuleName = "mint"
|
||||
|
||||
// default paramspace for params keeper
|
||||
DefaultParamspace = ModuleName
|
||||
|
||||
// StoreKey is the default store key for mint
|
||||
StoreKey = ModuleName
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
|
||||
// Default parameter namespace
|
||||
const (
|
||||
DefaultParamspace = ModuleName
|
||||
DefaultSignedBlocksWindow = int64(100)
|
||||
DefaultDowntimeJailDuration = 60 * 10 * time.Second
|
||||
)
|
||||
|
|
|
@ -15,9 +15,6 @@ import (
|
|||
|
||||
// Staking params default values
|
||||
const (
|
||||
// Default parameter namespace
|
||||
DefaultParamspace = ModuleName
|
||||
|
||||
// DefaultUnbondingTime reflects three weeks in seconds as the default
|
||||
// unbonding time.
|
||||
// TODO: Justify our choice of default here.
|
||||
|
|
Loading…
Reference in New Issue