diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c24d2a249..aaa6c6fa51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * Remove unsupported database types [#1760](https://github.com/provenance-io/provenance/issues/1760). +* Update ibc and migrate params [#1760](https://github.com/provenance-io/provenance/issues/1760). +* Replace ModuleBasics with BasicModuleManager [#1760](https://github.com/provenance-io/provenance/issues/1760). * Remove handlers from provenance modules [#1760](https://github.com/provenance-io/provenance/issues/1760). * Updated app.go to use RegisterStreamingServices on BaseApp [#1760](https://github.com/provenance-io/provenance/issues/1760). * Bump the SDK to `v0.50.5-pio-1` (from an earlier ephemeral version) [#1897](https://github.com/provenance-io/provenance/pull/1897). diff --git a/app/app.go b/app/app.go index 6e3e868ffa..39e1226c41 100644 --- a/app/app.go +++ b/app/app.go @@ -191,56 +191,6 @@ var ( // DefaultPowerReduction pio specific value for power reduction for TokensFromConsensusPower DefaultPowerReduction = sdkmath.NewIntFromUint64(1_000_000_000) - // ModuleBasics defines the module BasicManager is in charge of setting up basic, - // non-dependant module elements, such as codec registration - // and genesis verification. - ModuleBasics = module.NewBasicManager( - auth.AppModuleBasic{}, - genutil.AppModuleBasic{}, - bank.AppModuleBasic{}, - capability.AppModuleBasic{}, - staking.AppModuleBasic{}, - mint.AppModuleBasic{}, - distr.AppModuleBasic{}, - gov.NewAppModuleBasic(append( - []govclient.ProposalHandler{}, - paramsclient.ProposalHandler, - nameclient.RootNameProposalHandler, - ), - ), - params.AppModuleBasic{}, - crisis.AppModuleBasic{}, - slashing.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - authzmodule.AppModuleBasic{}, - groupmodule.AppModuleBasic{}, - vesting.AppModuleBasic{}, - // quarantinemodule.AppModuleBasic{}, // TODO[1760]: quarantine - // sanctionmodule.AppModuleBasic{}, // TODO[1760]: sanction - consensus.AppModuleBasic{}, - - ibc.AppModuleBasic{}, - ibctransfer.AppModuleBasic{}, - ica.AppModuleBasic{}, - icq.AppModuleBasic{}, - ibchooks.AppModuleBasic{}, - ibcratelimitmodule.AppModuleBasic{}, - - marker.AppModuleBasic{}, - attribute.AppModuleBasic{}, - name.AppModuleBasic{}, - metadata.AppModuleBasic{}, - wasm.AppModuleBasic{}, - msgfeesmodule.AppModuleBasic{}, - rewardmodule.AppModuleBasic{}, - triggermodule.AppModuleBasic{}, - oraclemodule.AppModuleBasic{}, - holdmodule.AppModuleBasic{}, - exchangemodule.AppModuleBasic{}, - ) - // module account permissions maccPerms = map[string][]string{ authtypes.FeeCollectorName: nil, @@ -449,7 +399,7 @@ func New( app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) // set the BaseApp's parameter store - // TODO[1760]: Update upgrade handler + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), @@ -838,25 +788,24 @@ func New( icaModule, ) - // TODO[1760]: app-module: BasicModuleManager: Make sure that this setup has everything we need (it was just copied from the SDK). // BasicModuleManager defines the module BasicManager is in charge of setting up basic, // non-dependant module elements, such as codec registration and genesis verification. // By default it is composed of all the module from the module manager. // Additionally, app module basics can be overwritten by passing them as argument. - /* - app.BasicModuleManager = module.NewBasicManagerFromManager( - app.mm, - map[string]module.AppModuleBasic{ - genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - govtypes.ModuleName: gov.NewAppModuleBasic( - []govclient.ProposalHandler{ - paramsclient.ProposalHandler, - }, + app.BasicModuleManager = module.NewBasicManagerFromManager( + app.mm, + map[string]module.AppModuleBasic{ + genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + govtypes.ModuleName: gov.NewAppModuleBasic( + append( + []govclient.ProposalHandler{}, + paramsclient.ProposalHandler, + nameclient.RootNameProposalHandler, ), - }) - app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino) - app.BasicModuleManager.RegisterInterfaces(interfaceRegistry) - */ + ), + }) + app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino) + app.BasicModuleManager.RegisterInterfaces(interfaceRegistry) // NOTE: upgrade module is required to be prioritized app.mm.SetOrderPreBlockers( @@ -1299,9 +1248,8 @@ func (app *App) InterfaceRegistry() types.InterfaceRegistry { } // DefaultGenesis returns a default genesis from the registered AppModuleBasic's. -func (a *App) DefaultGenesis() map[string]json.RawMessage { - // TODO[1760] This was changed to ModuleBasics, but it will be removed - return ModuleBasics.DefaultGenesis(a.appCodec) +func (app *App) DefaultGenesis() map[string]json.RawMessage { + return app.BasicModuleManager.DefaultGenesis(app.appCodec) } // GetKey returns the KVStoreKey for the provided store key. @@ -1352,7 +1300,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig serverconfig.API nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register grpc-gateway routes for all modules. - ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // register swagger API from root so that other applications can override easily if apiConfig.Swagger { @@ -1420,11 +1368,12 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino // register the key tables for legacy param subspaces keyTable := ibcclienttypes.ParamKeyTable() keyTable.RegisterParamSet(&ibcconnectiontypes.Params{}) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) // TODO[1760]: params: Migrate ibc-transfer params. - paramsKeeper.Subspace(ibcexported.ModuleName) // TODO[1760]: params: Migrate ibc-host params. - paramsKeeper.Subspace(icahosttypes.SubModuleName) // TODO[1760]: params: Migrate ica-host params. - paramsKeeper.Subspace(icqtypes.ModuleName) // TODO[1760]: params: Migrate icq params. - paramsKeeper.Subspace(ibchookstypes.ModuleName) // TODO[1760]: params: Migrate ibc-hooks params. + paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable) + paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable()) + paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable()) + + paramsKeeper.Subspace(icqtypes.ModuleName) // TODO[1760]: params: Migrate icq params. + paramsKeeper.Subspace(ibchookstypes.ModuleName) // TODO[1760]: params: Migrate ibc-hooks params. return paramsKeeper } diff --git a/app/app_test.go b/app/app_test.go index 6a06b08419..3a28e476a5 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -47,12 +47,17 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { ) } + // finalize block so we have CheckTx state set + _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: 1, + }) + require.NoError(t, err) + app.Commit() // Making a new app object with the db, so that initchain hasn't been called app2 := New(log.NewTestLogger(t), opts.DB, nil, true, - map[int64]bool{}, opts.HomePath, 0, opts.EncConfig, simtestutil.EmptyAppOptions{}) - var err error + map[int64]bool{}, opts.HomePath, 0, MakeEncodingConfig(), simtestutil.EmptyAppOptions{}) require.NotPanics(t, func() { _, err = app2.ExportAppStateAndValidators(false, nil, nil) }, "exporting app state at current height") @@ -144,6 +149,12 @@ func TestExportAppStateAndValidators(t *testing.T) { allAccounts := app.AccountKeeper.GetAllAccounts(ctx) logAccounts(t, allAccounts, "allAccounts") + // finalize block so we have CheckTx state set + _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: 1, + }) + require.NoError(t, err) + app.Commit() // Get an export diff --git a/app/encoding.go b/app/encoding.go index 7eaf6c0f5a..68187444f4 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -2,7 +2,6 @@ package app import ( "github.com/cosmos/cosmos-sdk/std" - "github.com/provenance-io/provenance/app/params" ) @@ -14,8 +13,5 @@ func MakeEncodingConfig() params.EncodingConfig { encodingConfig := params.MakeTestEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - - ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) - ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) return encodingConfig } diff --git a/app/genesis.go b/app/genesis.go index 5bf0c1da80..69e3fb3666 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -2,8 +2,6 @@ package app import ( "encoding/json" - - "github.com/cosmos/cosmos-sdk/codec" ) // The genesis state of the blockchain is represented here as a map of raw json @@ -14,8 +12,3 @@ import ( // the ModuleBasicManager which populates json from each BasicModule // object provided to it during init. type GenesisState map[string]json.RawMessage - -// NewDefaultGenesisState generates the default state for the application. -func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState { - return ModuleBasics.DefaultGenesis(cdc) -} diff --git a/app/test_helpers.go b/app/test_helpers.go index 84b40f8d12..e46685e493 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -87,7 +87,7 @@ func setup(t *testing.T, withGenesis bool, invCheckPeriod uint, chainID string) app := New(loggerMaker(), db, nil, true, map[int64]bool{}, t.TempDir(), invCheckPeriod, encCdc, simtestutil.EmptyAppOptions{}, baseapp.SetChainID(chainID)) if withGenesis { - return app, NewDefaultGenesisState(encCdc.Marshaler) + return app, app.DefaultGenesis() } return app, GenesisState{} } @@ -162,7 +162,7 @@ func NewAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptions) } app := New(options.Logger, options.DB, nil, true, options.SkipUpgradeHeights, options.HomePath, options.InvCheckPeriod, options.EncConfig, options.AppOpts) - genesisState := NewDefaultGenesisState(app.appCodec) + genesisState := app.DefaultGenesis() genesisState = genesisStateWithValSet(t, app, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) if !isCheckTx { @@ -224,7 +224,7 @@ func genesisStateWithValSet(t *testing.T, bondAmt := sdk.DefaultPowerReduction for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) + pk, err := cryptocodec.FromCmtPubKeyInterface(val.PubKey) require.NoError(t, err) pkAny, err := codectypes.NewAnyWithValue(pk) require.NoError(t, err) @@ -353,7 +353,7 @@ func GenesisStateWithSingleValidator(t *testing.T, app *App) GenesisState { }, } - genesisState := NewDefaultGenesisState(app.appCodec) + genesisState := app.DefaultGenesis() genesisState = genesisStateWithValSet(t, app, genesisState, valSet, []authtypes.GenesisAccount{acc}, balances...) return genesisState diff --git a/app/upgrades.go b/app/upgrades.go index 0295093106..be81e0c7b0 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -9,15 +9,17 @@ import ( storetypes "cosmossdk.io/store/types" upgradetypes "cosmossdk.io/x/upgrade/types" - icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctmmigrations "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint/migrations" "github.com/provenance-io/provenance/x/exchange" "github.com/provenance-io/provenance/x/hold" ibchookstypes "github.com/provenance-io/provenance/x/ibchooks/types" @@ -168,11 +170,26 @@ var upgrades = map[string]appUpgrade{ Added: []string{crisistypes.ModuleName}, Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error + + if err := pruneIBCExpiredConsensusStates(ctx, app); err != nil { + return nil, err + } + + err = migrateBaseappParams(ctx, app) + if err != nil { + return nil, err + } + vm, err = runModuleMigrations(ctx, app, vm) if err != nil { return nil, err } + err = updateIBCClients(ctx, app) + if err != nil { + return nil, err + } + removeInactiveValidatorDelegations(ctx, app) return vm, nil @@ -182,11 +199,26 @@ var upgrades = map[string]appUpgrade{ Added: []string{crisistypes.ModuleName}, Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error + + if err := pruneIBCExpiredConsensusStates(ctx, app); err != nil { + return nil, err + } + + err = migrateBaseappParams(ctx, app) + if err != nil { + return nil, err + } + vm, err = runModuleMigrations(ctx, app, vm) if err != nil { return nil, err } + err = updateIBCClients(ctx, app) + if err != nil { + return nil, err + } + removeInactiveValidatorDelegations(ctx, app) return vm, nil @@ -447,6 +479,43 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) { ctx.Logger().Info("Done updating ibc marker denom metadata") } +// pruneIBCExpiredConsensusStates prunes expired consensus states for IBC. +func pruneIBCExpiredConsensusStates(ctx sdk.Context, app *App) error { + ctx.Logger().Info("Pruning expired consensus states for IBC.") + _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.appCodec, app.IBCKeeper.ClientKeeper) + if err != nil { + ctx.Logger().Error(fmt.Sprintf("unable to prune expired consensus states, error: %s.", err)) + return err + } + ctx.Logger().Info("Done pruning expired consensus states for IBC.") + return nil +} + +// updateIBCClients updates the allowed clients for IBC. +// TODO: Remove with the umber handlers. +func updateIBCClients(ctx sdk.Context, app *App) error { + ctx.Logger().Info("Updating IBC AllowedClients.") + params := app.IBCKeeper.ClientKeeper.GetParams(ctx) + params.AllowedClients = append(params.AllowedClients, exported.Localhost) + app.IBCKeeper.ClientKeeper.SetParams(ctx, params) + ctx.Logger().Info("Done updating IBC AllowedClients.") + return nil +} + +// migrateBaseappParams migrates to new ConsensusParamsKeeper +// TODO: Remove with the umber handlers. +func migrateBaseappParams(ctx sdk.Context, app *App) error { + ctx.Logger().Info("Migrating legacy params.") + legacyBaseAppSubspace := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) + err := baseapp.MigrateParams(ctx, legacyBaseAppSubspace, app.ConsensusParamsKeeper.ParamsStore) + if err != nil { + ctx.Logger().Error(fmt.Sprintf("unable to migrate legacy params to ConsensusParamsKeeper, error: %s.", err)) + return err + } + ctx.Logger().Info("Done migrating legacy params.") + return nil +} + // convertNavUnits iterates all the net asset values and updates their units if they are using usd. // TODO: Remove with the tourmaline handlers. func convertNavUnits(ctx sdk.Context, app *App) { diff --git a/app/upgrades_test.go b/app/upgrades_test.go index f9a0e46bc2..b33292fed3 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -479,6 +479,12 @@ func (s *UpgradeTestSuite) TestTourmaline() { func (s *UpgradeTestSuite) TestUmberRC1() { expInLog := []string{ + "INF Pruning expired consensus states for IBC.", + "INF Done pruning expired consensus states for IBC.", + "INF Migrating legacy params.", + "INF Done migrating legacy params.", + "INF Updating IBC AllowedClients.", + "INF Done updating IBC AllowedClients.", "INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.", "INF removing all delegations from validators that have been inactive (unbonded) for 21 days", } @@ -487,7 +493,16 @@ func (s *UpgradeTestSuite) TestUmberRC1() { } func (s *UpgradeTestSuite) TestUmber() { - expInLog := []string{} + expInLog := []string{ + "INF Pruning expired consensus states for IBC.", + "INF Done pruning expired consensus states for IBC.", + "INF Migrating legacy params.", + "INF Done migrating legacy params.", + "INF Updating IBC AllowedClients.", + "INF Done updating IBC AllowedClients.", + "INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.", + "INF removing all delegations from validators that have been inactive (unbonded) for 21 days", + } s.AssertUpgradeHandlerLogs("umber", expInLog, nil) } diff --git a/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index 43a2388a6b..09b7c52b22 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -37,7 +37,9 @@ import ( "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/tx/signing" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/tx" @@ -65,7 +67,21 @@ const ( // NewRootCmd creates a new root command for provenanced. It is called once in the main function. // Providing sealConfig = false is only for unit tests that want to run multiple commands. func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) { + // tempDir creates a temporary home directory. + tempDir, err := os.MkdirTemp("", "provenanced") + if err != nil { + panic(fmt.Errorf("failed to create temp dir: %w", err)) + } + os.RemoveAll(tempDir) + encodingConfig := app.MakeEncodingConfig() + tempApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil, + tempDir, + 0, + encodingConfig, + simtestutil.EmptyAppOptions{}, + ) + initClientCtx := client.Context{}. WithCodec(encodingConfig.Marshaler). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). @@ -137,7 +153,7 @@ func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) { }, } genAutoCompleteCmd(rootCmd) - initRootCmd(rootCmd, encodingConfig) + initRootCmd(rootCmd, encodingConfig, tempApp.BasicModuleManager) overwriteFlagDefaults(rootCmd, map[string]string{ flags.FlagChainID: "", flags.FlagKeyringBackend: "test", @@ -172,12 +188,12 @@ func Execute(rootCmd *cobra.Command) error { return executor.ExecuteContext(ctx) } -func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { +func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, basicManager module.BasicManager) { rootCmd.AddCommand( - InitCmd(app.ModuleBasics), + InitCmd(basicManager), // genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), // TODO[1760]: genutil // genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), // TODO[1760]: genutil - genutilcli.ValidateGenesisCmd(app.ModuleBasics), + genutilcli.ValidateGenesisCmd(basicManager), AddGenesisAccountCmd(app.DefaultNodeHome), AddRootDomainAccountCmd(app.DefaultNodeHome), AddGenesisMarkerCmd(app.DefaultNodeHome), @@ -186,7 +202,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { AddGenesisDefaultMarketCmd(app.DefaultNodeHome), AddGenesisCustomMarketCmd(app.DefaultNodeHome), cmtcli.NewCompletionCmd(rootCmd, true), - testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), + testnetCmd(basicManager, banktypes.GenesisBalancesIterator{}), debug.Cmd(), ConfigCmd(), AddMetaAddressCmd(), @@ -202,8 +218,8 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { // add keybase, auxiliary RPC, query, and tx child commands rootCmd.AddCommand( server.StatusCommand(), - queryCommand(), - txCommand(), + queryCommand(basicManager), + txCommand(basicManager), keys.Commands(), ) @@ -257,7 +273,7 @@ func addModuleInitFlags(startCmd *cobra.Command) { crisis.AddModuleInitFlags(startCmd) } -func queryCommand() *cobra.Command { +func queryCommand(basicManager module.BasicManager) *cobra.Command { cmd := &cobra.Command{ Use: "query", Aliases: []string{"q"}, @@ -275,13 +291,13 @@ func queryCommand() *cobra.Command { authcmd.QueryTxCmd(), ) - app.ModuleBasics.AddQueryCommands(cmd) + basicManager.AddQueryCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd } -func txCommand() *cobra.Command { +func txCommand(basicManager module.BasicManager) *cobra.Command { cmd := &cobra.Command{ Use: "tx", Short: "Transactions subcommands", @@ -303,7 +319,7 @@ func txCommand() *cobra.Command { flags.LineBreak, ) - app.ModuleBasics.AddTxCommands(cmd) + basicManager.AddTxCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd diff --git a/cmd/provenanced/cmd/testnet_test.go b/cmd/provenanced/cmd/testnet_test.go index 1c7f43368a..bf12ce5e44 100644 --- a/cmd/provenanced/cmd/testnet_test.go +++ b/cmd/provenanced/cmd/testnet_test.go @@ -11,9 +11,11 @@ import ( "cosmossdk.io/log" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" @@ -29,9 +31,16 @@ func Test_TestnetCmd(t *testing.T) { pioconfig.SetProvenanceConfig("", 0) logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultCometConfig(home) + tempApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil, + home, + 0, + encodingConfig, + simtestutil.EmptyAppOptions{}, + ) + require.NoError(t, err) - err = genutiltest.ExecInitCmd(app.ModuleBasics, home, encodingConfig.Marshaler) + err = genutiltest.ExecInitCmd(tempApp.BasicModuleManager, home, encodingConfig.Marshaler) require.NoError(t, err) serverCtx := server.NewContext(viper.New(), cfg, logger) @@ -43,7 +52,7 @@ func Test_TestnetCmd(t *testing.T) { ctx := context.Background() ctx = context.WithValue(ctx, server.ServerContextKey, serverCtx) ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) - cmd := testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}) + cmd := testnetCmd(tempApp.BasicModuleManager, banktypes.GenesisBalancesIterator{}) cmd.SetArgs([]string{fmt.Sprintf("--%s=test", flags.FlagKeyringBackend), fmt.Sprintf("--output-dir=%s", home)}) err = cmd.ExecuteContext(ctx) require.NoError(t, err) diff --git a/go.mod b/go.mod index 5a4e33b609..b16fd9b0ac 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/provenance-io/provenance go 1.21 require ( + cosmossdk.io/core v0.11.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -32,6 +33,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.2 github.com/rakyll/statik v0.1.7 + github.com/regen-network/cosmos-proto v0.3.1 // TODO[1760]: Verify that this is still needed github.com/rs/zerolog v1.32.0 github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.0 @@ -46,8 +48,6 @@ require ( gopkg.in/yaml.v2 v2.4.0 ) -require github.com/regen-network/cosmos-proto v0.3.1 - require ( cloud.google.com/go v0.112.0 // indirect cloud.google.com/go/compute v1.24.0 // indirect @@ -57,7 +57,6 @@ require ( cosmossdk.io/api v0.7.3 // indirect cosmossdk.io/client/v2 v2.0.0-beta.1 // indirect cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/core v0.11.0 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect cosmossdk.io/x/circuit v0.1.0 // indirect cosmossdk.io/x/nft v0.1.0 // indirect @@ -224,8 +223,6 @@ replace ( // TODO[1760]: Update once async-icq creates tag with our changes https://github.com/cosmos/ibc-apps/pull/168 github.com/cosmos/ibc-apps/modules/async-icq/v8 => github.com/provenance-io/ibc-apps/modules/async-icq/v8 v8.0.0-prov-1 - // TODO[1760]: ibc: Put this ibc-go replace back with an updated version (or delete it). - // github.com/cosmos/ibc-go/v6 => github.com/provenance-io/ibc-go/v6 v6.2.0-pio-1 // dgrijalva/jwt-go is deprecated and doesn't receive security updates. // TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 diff --git a/testutil/ibc/testchain.go b/testutil/ibc/testchain.go index 2352ecaba3..85016678ce 100644 --- a/testutil/ibc/testchain.go +++ b/testutil/ibc/testchain.go @@ -28,7 +28,7 @@ type TestChain struct { func SetupTestingApp(t *testing.T) (ibctesting.TestingApp, map[string]json.RawMessage) { provenanceApp := provenanceapp.Setup(t) - return provenanceApp, provenanceapp.NewDefaultGenesisState(provenanceApp.AppCodec()) + return provenanceApp, provenanceApp.DefaultGenesis() } func (chain *TestChain) StoreContractCounterDirect(suite *suite.Suite) uint64 { diff --git a/testutil/network.go b/testutil/network.go index 7d977e5547..64eb72e3c8 100644 --- a/testutil/network.go +++ b/testutil/network.go @@ -41,6 +41,8 @@ func NewAppConstructor(encodingCfg params.EncodingConfig) testnet.AppConstructor // DefaultTestNetworkConfig creates a network configuration for inproc testing func DefaultTestNetworkConfig() testnet.Config { encCfg := provenanceapp.MakeEncodingConfig() + tempApp := NewAppConstructor(encCfg)(nil).(*provenanceapp.App) + return testnet.Config{ Codec: encCfg.Marshaler, TxConfig: encCfg.TxConfig, @@ -48,7 +50,7 @@ func DefaultTestNetworkConfig() testnet.Config { InterfaceRegistry: encCfg.InterfaceRegistry, AccountRetriever: authtypes.AccountRetriever{}, AppConstructor: NewAppConstructor(encCfg), - GenesisState: provenanceapp.ModuleBasics.DefaultGenesis(encCfg.Marshaler), + GenesisState: tempApp.DefaultGenesis(), TimeoutCommit: 2 * time.Second, ChainID: "chain-" + cmtrand.NewRand().Str(6), NumValidators: 4, diff --git a/x/attribute/module.go b/x/attribute/module.go index f1d4bcfdda..d2a5534476 100644 --- a/x/attribute/module.go +++ b/x/attribute/module.go @@ -11,6 +11,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -28,10 +29,11 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModuleSimulation = AppModule{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) ) // AppModuleBasic contains non-dependent elements for the attribute module. diff --git a/x/exchange/module/module.go b/x/exchange/module/module.go index a1f399d199..99f4d7d5f8 100644 --- a/x/exchange/module/module.go +++ b/x/exchange/module/module.go @@ -6,6 +6,7 @@ import ( "fmt" "math/rand" + "cosmossdk.io/core/appmodule" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -25,10 +26,10 @@ import ( ) var ( - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModule = AppModule{} - _ module.AppModuleSimulation = AppModule{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) ) type AppModuleBasic struct { diff --git a/x/hold/module/module.go b/x/hold/module/module.go index 404e7dcc47..40f1d8ba69 100644 --- a/x/hold/module/module.go +++ b/x/hold/module/module.go @@ -6,6 +6,7 @@ import ( "fmt" "math/rand" + "cosmossdk.io/core/appmodule" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -25,10 +26,10 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModuleSimulation = AppModule{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) ) type AppModule struct { diff --git a/x/ibchooks/ibc_middleware_test.go b/x/ibchooks/ibc_middleware_test.go index 55269db451..119fb8c589 100644 --- a/x/ibchooks/ibc_middleware_test.go +++ b/x/ibchooks/ibc_middleware_test.go @@ -82,7 +82,7 @@ func SetupSimApp() (ibctesting.TestingApp, map[string]json.RawMessage) { db := dbm.NewMemDB() encCdc := app.MakeEncodingConfig() provenanceApp := app.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, app.DefaultNodeHome, 5, encCdc, simtestutil.EmptyAppOptions{}) - genesis := app.NewDefaultGenesisState(encCdc.Marshaler) + genesis := provenanceApp.DefaultGenesis() return provenanceApp, genesis } diff --git a/x/ibchooks/module.go b/x/ibchooks/module.go index 936bd5650a..a7f40b527b 100644 --- a/x/ibchooks/module.go +++ b/x/ibchooks/module.go @@ -5,6 +5,7 @@ import ( "fmt" "math/rand" + "cosmossdk.io/core/appmodule" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -26,9 +27,10 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) ) // AppModuleBasic defines the basic application module used by the ibchooks module. diff --git a/x/ibcratelimit/module/ibc_middleware_test.go b/x/ibcratelimit/module/ibc_middleware_test.go index ff4dcb44eb..61a0c12385 100644 --- a/x/ibcratelimit/module/ibc_middleware_test.go +++ b/x/ibcratelimit/module/ibc_middleware_test.go @@ -54,7 +54,7 @@ func SetupSimApp() (ibctesting.TestingApp, map[string]json.RawMessage) { db := dbm.NewMemDB() encCdc := app.MakeEncodingConfig() provenanceApp := app.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, app.DefaultNodeHome, 5, encCdc, simtestutil.EmptyAppOptions{}) - genesis := app.NewDefaultGenesisState(encCdc.Marshaler) + genesis := provenanceApp.DefaultGenesis() return provenanceApp, genesis } diff --git a/x/ibcratelimit/module/module.go b/x/ibcratelimit/module/module.go index ecdad2a450..01e51d9f42 100644 --- a/x/ibcratelimit/module/module.go +++ b/x/ibcratelimit/module/module.go @@ -6,6 +6,7 @@ import ( "fmt" "math/rand" + "cosmossdk.io/core/appmodule" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -28,10 +29,10 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModuleSimulation = AppModule{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) ) // AppModuleBasic defines the basic application module used by the ibcratelimit module. diff --git a/x/marker/module.go b/x/marker/module.go index 730b3f1328..e36cd4be88 100644 --- a/x/marker/module.go +++ b/x/marker/module.go @@ -11,6 +11,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" feegrantkeeper "cosmossdk.io/x/feegrant/keeper" "github.com/cosmos/cosmos-sdk/client" @@ -31,9 +32,11 @@ import ( // type check to ensure the interface is properly implemented var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) ) // AppModuleBasic contains non-dependent elements for the marker module. diff --git a/x/metadata/module.go b/x/metadata/module.go index f83e94887d..a67d1b40eb 100644 --- a/x/metadata/module.go +++ b/x/metadata/module.go @@ -6,6 +6,7 @@ import ( "fmt" "math/rand" + "cosmossdk.io/core/appmodule" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -36,9 +37,10 @@ const StoreKey = types.StoreKey // type check to ensure the interface is properly implemented var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) ) // AppModuleBasic contains non-dependent elements for the metadata module. diff --git a/x/msgfees/module/module.go b/x/msgfees/module/module.go index de827fdf2b..8b680268eb 100644 --- a/x/msgfees/module/module.go +++ b/x/msgfees/module/module.go @@ -10,6 +10,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" cerrs "cosmossdk.io/errors" sdkclient "github.com/cosmos/cosmos-sdk/client" @@ -26,10 +27,10 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModuleSimulation = AppModule{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) ) // AppModuleBasic defines the basic application module used by the msgfee module. diff --git a/x/name/module.go b/x/name/module.go index dec09cd7a8..ea37c1656b 100644 --- a/x/name/module.go +++ b/x/name/module.go @@ -6,6 +6,7 @@ import ( "fmt" "math/rand" + "cosmossdk.io/core/appmodule" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -28,10 +29,10 @@ import ( // type check to ensure the interface is properly implemented var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModuleSimulation = AppModule{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) ) // AppModuleBasic contains non-dependent elements for the name module. diff --git a/x/oracle/module/module.go b/x/oracle/module/module.go index 2a823db534..5b7b3e9543 100644 --- a/x/oracle/module/module.go +++ b/x/oracle/module/module.go @@ -11,6 +11,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" cerrs "cosmossdk.io/errors" sdkclient "github.com/cosmos/cosmos-sdk/client" @@ -30,10 +31,10 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModuleSimulation = AppModule{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) ) // AppModuleBasic defines the basic application module used by the oracle module. diff --git a/x/reward/module/module.go b/x/reward/module/module.go index a427f916f6..1fb2730042 100644 --- a/x/reward/module/module.go +++ b/x/reward/module/module.go @@ -11,6 +11,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" cerrs "cosmossdk.io/errors" sdkclient "github.com/cosmos/cosmos-sdk/client" @@ -30,9 +31,12 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) + _ appmodule.HasEndBlocker = (*AppModule)(nil) ) // AppModuleBasic defines the basic application module used by the reward module. diff --git a/x/trigger/module/module.go b/x/trigger/module/module.go index 977a574237..fdd8401471 100644 --- a/x/trigger/module/module.go +++ b/x/trigger/module/module.go @@ -11,6 +11,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" cerrs "cosmossdk.io/errors" sdkclient "github.com/cosmos/cosmos-sdk/client" @@ -30,10 +31,12 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ module.AppModuleSimulation = AppModule{} - // TODO[1760]: app-module: Add more assertions for the new types and clean up stuff no longer needed. + _ module.AppModuleBasic = (*AppModule)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) + _ appmodule.HasEndBlocker = (*AppModule)(nil) ) // AppModuleBasic defines the basic application module used by the trigger module.