diff --git a/app/gov_handlers.go b/app/gov_handlers.go index 6fcdbb82..251af629 100644 --- a/app/gov_handlers.go +++ b/app/gov_handlers.go @@ -1,10 +1,8 @@ package atomone import ( - "fmt" "os" "path/filepath" - "strings" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -12,9 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/version" - paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" - paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/x/upgrade/plan" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" @@ -24,7 +19,6 @@ import ( ) var ( - paramsChangeProposalHandler = govclient.NewProposalHandler(newSubmitParamChangeProposalTxCmd) upgradeProposalHandler = govclient.NewProposalHandler(newCmdSubmitLegacyUpgradeProposal) cancelUpgradeProposalHandler = govclient.NewProposalHandler(newCmdSubmitLegacyCancelUpgradeProposal) ) @@ -33,86 +27,10 @@ func init() { // Proposal types are registered within their specific module in the SDK, but // using the legacy gov module. To register them in the atomone gov module, // we need to do it here. - govv1beta1.RegisterProposalType(paramproposal.ProposalTypeChange) govv1beta1.RegisterProposalType(upgradetypes.ProposalTypeSoftwareUpgrade) govv1beta1.RegisterProposalType(upgradetypes.ProposalTypeCancelSoftwareUpgrade) } -// NewSubmitParamChangeProposalTxCmd returns a CLI command handler for creating -// a parameter change proposal governance transaction. -// -// NOTE: copy of x/params/client.newSubmitParamChangeProposalTxCmd() except -// that it creates a atomone.gov.MsgSubmitProposal instead of a -// cosmos.gov.MsgSubmitProposal. -func newSubmitParamChangeProposalTxCmd() *cobra.Command { - return &cobra.Command{ - Use: "param-change [proposal-file]", - Args: cobra.ExactArgs(1), - Short: "Submit a parameter change proposal", - Long: strings.TrimSpace( - fmt.Sprintf(`Submit a parameter proposal along with an initial deposit. -The proposal details must be supplied via a JSON file. For values that contains -objects, only non-empty fields will be updated. - -IMPORTANT: Currently parameter changes are evaluated but not validated, so it is -very important that any "value" change is valid (ie. correct type and within bounds) -for its respective parameter, eg. "MaxValidators" should be an integer and not a decimal. - -Proper vetting of a parameter change proposal should prevent this from happening -(no deposits should occur during the governance process), but it should be noted -regardless. - -Example: -$ %s tx gov submit-proposal param-change --from= - -Where proposal.json contains: - -{ - "title": "Staking Param Change", - "description": "Update max validators", - "changes": [ - { - "subspace": "staking", - "key": "MaxValidators", - "value": 105 - } - ], - "deposit": "1000stake" -} -`, - version.AppName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - proposal, err := paramscutils.ParseParamChangeProposalJSON(clientCtx.LegacyAmino, args[0]) - if err != nil { - return err - } - - from := clientCtx.GetFromAddress() - content := paramproposal.NewParameterChangeProposal( - proposal.Title, proposal.Description, proposal.Changes.ToParamChanges(), - ) - - deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit) - if err != nil { - return err - } - - msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } -} - const ( // Deprecated: only used for v1beta1 legacy proposals. FlagUpgradeHeight = "upgrade-height" diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 09e5efc4..a1b1d214 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -33,10 +33,6 @@ import ( feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" 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" - 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" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" @@ -47,7 +43,6 @@ import ( govkeeper "github.com/atomone-hub/atomone/x/gov/keeper" govtypes "github.com/atomone-hub/atomone/x/gov/types" - govv1 "github.com/atomone-hub/atomone/x/gov/types/v1" govv1beta1 "github.com/atomone-hub/atomone/x/gov/types/v1beta1" ) @@ -68,7 +63,6 @@ type AppKeepers struct { GovKeeper *govkeeper.Keeper CrisisKeeper *crisiskeeper.Keeper UpgradeKeeper *upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper EvidenceKeeper evidencekeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper AuthzKeeper authzkeeper.Keeper @@ -104,13 +98,6 @@ func NewAppKeeper( os.Exit(1) } - appKeepers.ParamsKeeper = initParamsKeeper( - appCodec, - legacyAmino, - appKeepers.keys[paramstypes.StoreKey], - appKeepers.tkeys[paramstypes.TStoreKey], - ) - // set the BaseApp's parameter store appKeepers.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( appCodec, @@ -245,13 +232,9 @@ func NewAppKeeper( // Deprecated: Avoid adding new handlers, instead use the new proposal flow // by granting the governance module the right to execute the message. // See: https://docs.cosmos.network/main/modules/gov#proposal-messages - // - // TODO(tb): remove completely govRouter and rely only on proposals that - // embed sdk.Msg ? govRouter := govv1beta1.NewRouter() govRouter. AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, govv1beta1.WrapSDKHandler(params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper))). AddRoute(upgradetypes.RouterKey, govv1beta1.WrapSDKHandler(upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper))) // Set legacy router for backwards compatibility with gov v1beta1 @@ -268,29 +251,3 @@ func NewAppKeeper( return appKeepers } - -// GetSubspace returns a param subspace for a given module name. -func (appKeepers *AppKeepers) GetSubspace(moduleName string) paramstypes.Subspace { - subspace, ok := appKeepers.ParamsKeeper.GetSubspace(moduleName) - if !ok { - panic("couldn't load subspace for module: " + moduleName) - } - return subspace -} - -// 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) - - //nolint: staticcheck // SA1019: moduletypes.ParamKeyTable is deprecated - paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable()) - paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable()) - paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable()) //nolint:staticcheck // SA1019 - paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) //nolint:staticcheck // SA1019 - paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable()) //nolint:staticcheck // SA1019 - paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()) //nolint:staticcheck // SA1019 - paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint:staticcheck // SA1019 - paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable()) //nolint:staticcheck // SA1019 - - return paramsKeeper -} diff --git a/app/keepers/keys.go b/app/keepers/keys.go index f4351c3e..f47822a0 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -13,7 +13,6 @@ import ( evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/cosmos/cosmos-sdk/x/feegrant" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" @@ -33,7 +32,6 @@ func (appKeepers *AppKeepers) GenerateKeys() { distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, - paramstypes.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, capabilitytypes.StoreKey, @@ -42,9 +40,6 @@ func (appKeepers *AppKeepers) GenerateKeys() { consensusparamtypes.StoreKey, ) - // Define transient store keys - appKeepers.tkeys = sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - // MemKeys are for information that is stored only in RAM. appKeepers.memKeys = sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) } diff --git a/app/modules.go b/app/modules.go index e9c66e3c..75174ca8 100644 --- a/app/modules.go +++ b/app/modules.go @@ -27,8 +27,6 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/mint" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - sdkparams "github.com/cosmos/cosmos-sdk/x/params" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cosmos/cosmos-sdk/x/slashing" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" @@ -64,14 +62,11 @@ var ModuleBasics = module.NewBasicManager( mint.AppModuleBasic{}, distr.AppModuleBasic{}, gov.NewAppModuleBasic( - // TODO remove since no compat needed with old gov handler system? []govclient.ProposalHandler{ - paramsChangeProposalHandler, upgradeProposalHandler, cancelUpgradeProposalHandler, }, ), - sdkparams.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, feegrantmodule.AppModuleBasic{}, @@ -96,21 +91,20 @@ func appModules( app.BaseApp.DeliverTx, encodingConfig.TxConfig, ), - auth.NewAppModule(appCodec, app.AccountKeeper, nil, app.GetSubspace(authtypes.ModuleName)), + auth.NewAppModule(appCodec, app.AccountKeeper, nil, nil), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, nil), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), - crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), + crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, nil), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, nil), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, nil), upgrade.NewAppModule(app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - sdkparams.NewAppModule(app.ParamsKeeper), consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), } } @@ -125,16 +119,15 @@ func simulationModules( appCodec := encodingConfig.Marshaler return []module.AppModuleSimulation{ - auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), + auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, nil), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, nil), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), - sdkparams.NewAppModule(app.ParamsKeeper), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, nil), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, nil), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil), evidence.NewAppModule(app.EvidenceKeeper), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), } @@ -169,7 +162,6 @@ func orderBeginBlockers() []string { genutiltypes.ModuleName, authz.ModuleName, feegrant.ModuleName, - paramstypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, } @@ -198,7 +190,6 @@ func orderEndBlockers() []string { evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, - paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, @@ -228,7 +219,6 @@ func orderInitBlockers() []string { evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, - paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, diff --git a/tests/e2e/chain.go b/tests/e2e/chain.go index 3d6abb77..de9a7f61 100644 --- a/tests/e2e/chain.go +++ b/tests/e2e/chain.go @@ -17,7 +17,6 @@ import ( distribtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/cosmos/cosmos-sdk/x/feegrant" - paramsproptypes "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" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" @@ -52,8 +51,6 @@ func init() { feegrant.RegisterInterfaces(encodingConfig.InterfaceRegistry) govv1types.RegisterInterfaces(encodingConfig.InterfaceRegistry) govv1beta1types.RegisterInterfaces(encodingConfig.InterfaceRegistry) - paramsproptypes.RegisterInterfaces(encodingConfig.InterfaceRegistry) - paramsproptypes.RegisterLegacyAminoCodec(encodingConfig.Amino) feegrant.RegisterLegacyAminoCodec(encodingConfig.Amino) slashingtypes.RegisterInterfaces(encodingConfig.InterfaceRegistry) diff --git a/x/gov/common_test.go b/x/gov/common_test.go index dfa5b83b..e8b3fe56 100644 --- a/x/gov/common_test.go +++ b/x/gov/common_test.go @@ -28,22 +28,22 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/atomone-hub/atomone/x/gov/keeper" - "github.com/atomone-hub/atomone/x/gov/types" - v1 "github.com/atomone-hub/atomone/x/gov/types/v1" - "github.com/atomone-hub/atomone/x/gov/types/v1beta1" + govkeeper "github.com/atomone-hub/atomone/x/gov/keeper" + govtypes "github.com/atomone-hub/atomone/x/gov/types" + govv1 "github.com/atomone-hub/atomone/x/gov/types/v1" + govv1beta1 "github.com/atomone-hub/atomone/x/gov/types/v1beta1" ) var ( valTokens = sdk.TokensFromConsensusPower(42, sdk.DefaultPowerReduction) - TestProposal = v1beta1.NewTextProposal("Test", "description") + TestProposal = govv1beta1.NewTextProposal("Test", "description") TestDescription = stakingtypes.NewDescription("T", "E", "S", "T", "Z") TestCommissionRates = stakingtypes.NewCommissionRates(math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec()) ) // mkTestLegacyContent creates a MsgExecLegacyContent for testing purposes. -func mkTestLegacyContent(t *testing.T) *v1.MsgExecLegacyContent { - msgContent, err := v1.NewLegacyContent(TestProposal, authtypes.NewModuleAddress(types.ModuleName).String()) +func mkTestLegacyContent(t *testing.T) *govv1.MsgExecLegacyContent { + msgContent, err := govv1.NewLegacyContent(TestProposal, authtypes.NewModuleAddress(govtypes.ModuleName).String()) require.NoError(t, err) return msgContent @@ -104,7 +104,7 @@ var pubkeys = []cryptotypes.PubKey{ type suite struct { AccountKeeper authkeeper.AccountKeeper BankKeeper bankkeeper.Keeper - GovKeeper *keeper.Keeper + GovKeeper *govkeeper.Keeper StakingKeeper *stakingkeeper.Keeper App *runtime.App } diff --git a/x/gov/exported/exported.go b/x/gov/exported/exported.go deleted file mode 100644 index 08a5d259..00000000 --- a/x/gov/exported/exported.go +++ /dev/null @@ -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. - ParamSubspace interface { - Get(ctx sdk.Context, key []byte, ptr interface{}) - } -) diff --git a/x/gov/keeper/migrations.go b/x/gov/keeper/migrations.go index d59ce554..d59a01df 100644 --- a/x/gov/keeper/migrations.go +++ b/x/gov/keeper/migrations.go @@ -1,19 +1,13 @@ package keeper -import ( - "github.com/atomone-hub/atomone/x/gov/exported" -) - // Migrator is a struct for handling in-place store migrations. type Migrator struct { - keeper *Keeper - legacySubspace exported.ParamSubspace + keeper *Keeper } // NewMigrator returns a new Migrator. -func NewMigrator(keeper *Keeper, legacySubspace exported.ParamSubspace) Migrator { +func NewMigrator(keeper *Keeper) Migrator { return Migrator{ - keeper: keeper, - legacySubspace: legacySubspace, + keeper: keeper, } } diff --git a/x/gov/module.go b/x/gov/module.go index 73455e40..1a6f653c 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -28,7 +28,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" govclient "github.com/atomone-hub/atomone/x/gov/client" "github.com/atomone-hub/atomone/x/gov/client/cli" @@ -130,22 +129,18 @@ type AppModule struct { keeper *keeper.Keeper accountKeeper govtypes.AccountKeeper bankKeeper govtypes.BankKeeper - - // legacySubspace is used solely for migration of x/params managed parameters - legacySubspace govtypes.ParamSubspace } // NewAppModule creates a new AppModule object func NewAppModule( cdc codec.Codec, keeper *keeper.Keeper, - ak govtypes.AccountKeeper, bk govtypes.BankKeeper, ss govtypes.ParamSubspace, + ak govtypes.AccountKeeper, bk govtypes.BankKeeper, ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, accountKeeper: ak, bankKeeper: bk, - legacySubspace: ss, } } @@ -160,7 +155,7 @@ func (am AppModule) IsAppModule() {} func init() { appmodule.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule, ProvideKeyTable), + appmodule.Provide(ProvideModule), appmodule.Invoke(InvokeAddRoutes, InvokeSetHooks)) } @@ -176,9 +171,6 @@ type GovInputs struct { AccountKeeper govtypes.AccountKeeper BankKeeper govtypes.BankKeeper StakingKeeper govtypes.StakingKeeper - - // LegacySubspace is used solely for migration of x/params managed parameters - LegacySubspace govtypes.ParamSubspace `optional:"true"` } type GovOutputs struct { @@ -211,16 +203,12 @@ func ProvideModule(in GovInputs) GovOutputs { kConfig, authority.String(), ) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.LegacySubspace) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper) hr := v1beta1.HandlerRoute{Handler: v1beta1.ProposalHandler, RouteKey: govtypes.RouterKey} return GovOutputs{Module: m, Keeper: k, HandlerRoute: hr} } -func ProvideKeyTable() paramtypes.KeyTable { - return v1.ParamKeyTable() //nolint:staticcheck -} - func InvokeAddRoutes(keeper *keeper.Keeper, routes []v1beta1.HandlerRoute) { if keeper == nil || routes == nil { return @@ -283,7 +271,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { v1beta1.RegisterQueryServer(cfg.QueryServer(), legacyQueryServer) v1.RegisterQueryServer(cfg.QueryServer(), am.keeper) - m := keeper.NewMigrator(am.keeper, am.legacySubspace) + m := keeper.NewMigrator(am.keeper) _ = m } diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index b486e5da..78215332 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -8,12 +8,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) -// ParamSubspace defines the expected Subspace interface for parameters (noalias) -type ParamSubspace interface { - Get(ctx sdk.Context, key []byte, ptr interface{}) - Set(ctx sdk.Context, key []byte, param interface{}) -} - // StakingKeeper expected staking keeper (Validator and Delegator sets) (noalias) type StakingKeeper interface { // iterate through bonded validators by operator address, execute func for each validator diff --git a/x/gov/types/v1/params_legacy.go b/x/gov/types/v1/params_legacy.go deleted file mode 100644 index ded90375..00000000 --- a/x/gov/types/v1/params_legacy.go +++ /dev/null @@ -1,91 +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 := sdk.NewDecFromStr(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 := sdk.NewDecFromStr(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) - } - - 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() < MinVotingPeriod.Seconds() { - return fmt.Errorf("voting period must be at least %s: %s", MinVotingPeriod.String(), v.VotingPeriod.String()) - } - - return nil -} diff --git a/x/gov/types/v1beta1/codec.go b/x/gov/types/v1beta1/codec.go index 3bd86657..8b96290d 100644 --- a/x/gov/types/v1beta1/codec.go +++ b/x/gov/types/v1beta1/codec.go @@ -8,7 +8,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/msgservice" authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" groupcodec "github.com/cosmos/cosmos-sdk/x/group/codec" - paramsproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" govcodec "github.com/atomone-hub/atomone/x/gov/codec" @@ -41,10 +40,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { // Register proposal types (this is actually done in related modules, but // since we are using an other gov module, we need to do it manually). - registry.RegisterImplementations( - (*Content)(nil), - ¶msproposal.ParameterChangeProposal{}, - ) registry.RegisterImplementations( (*Content)(nil), &upgradetypes.SoftwareUpgradeProposal{}, //nolint:staticcheck