From ed3652610a07d3c84f97d850607a20de2b754f0a Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 15 Mar 2024 11:01:03 -0400 Subject: [PATCH 01/21] Modify changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15eaf9f494..f1c395d766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Updated documentation for each module to work with docusaurus [PR 1763](https://github.com/provenance-io/provenance/pull/1763). * Create a default market in `make run`, `localnet`, `devnet` and the `provenanced testnet` command [#1757](https://github.com/provenance-io/provenance/issues/1757). * 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). ### Dependencies From bc1315844ed97916d5f683d0e831e94f81dbcd6b Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 15 Mar 2024 11:12:41 -0400 Subject: [PATCH 02/21] Add skeleton for ibc upgrade. --- app/upgrades.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/upgrades.go b/app/upgrades.go index 85fef1e7f6..5177fae718 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -211,6 +211,7 @@ var upgrades = map[string]appUpgrade{ } removeInactiveValidatorDelegations(ctx, app) + upgradeIBC(ctx, app) return vm, nil }, @@ -225,6 +226,7 @@ var upgrades = map[string]appUpgrade{ } removeInactiveValidatorDelegations(ctx, app) + upgradeIBC(ctx, app) return vm, nil }, @@ -533,3 +535,22 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) { }) ctx.Logger().Info("Done updating ibc marker denom metadata") } + +// upgradeIBC upgrades IBC to the latest version +// TODO: Remove with the umbra handlers. +func upgradeIBC(ctx sdk.Context, app *App) { + upgradeToIBCv7(ctx, app) + upgradeToIBCv8(ctx, app) +} + +// upgradeToIBCv7 upgrades IBC from v6 to v7. +// TODO: Remove with the umbra handlers. +func upgradeToIBCv7(ctx sdk.Context, app *App) { + +} + +// upgradeToIBCv8 upgrades IBC from v7 to v8. +// TODO: Remove with the umbra handlers. +func upgradeToIBCv8(ctx sdk.Context, app *App) { + +} From 9cced761b3533760833d38740b77f3a81339b8ef Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 15 Mar 2024 11:21:28 -0400 Subject: [PATCH 03/21] Add logic for v7 upgrade. --- app/upgrades.go | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 5177fae718..18b89c1dc2 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -20,6 +20,7 @@ import ( govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibctmmigrations "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint/migrations" attributekeeper "github.com/provenance-io/provenance/x/attribute/keeper" attributetypes "github.com/provenance-io/provenance/x/attribute/types" "github.com/provenance-io/provenance/x/exchange" @@ -205,13 +206,18 @@ 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 + + err = upgradeIBC(ctx, app) + if err != nil { + return nil, err + } + vm, err = runModuleMigrations(ctx, app, vm) if err != nil { return nil, err } removeInactiveValidatorDelegations(ctx, app) - upgradeIBC(ctx, app) return vm, nil }, @@ -220,13 +226,18 @@ 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 + + err = upgradeIBC(ctx, app) + if err != nil { + return nil, err + } + vm, err = runModuleMigrations(ctx, app, vm) if err != nil { return nil, err } removeInactiveValidatorDelegations(ctx, app) - upgradeIBC(ctx, app) return vm, nil }, @@ -538,19 +549,29 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) { // upgradeIBC upgrades IBC to the latest version // TODO: Remove with the umbra handlers. -func upgradeIBC(ctx sdk.Context, app *App) { - upgradeToIBCv7(ctx, app) - upgradeToIBCv8(ctx, app) +func upgradeIBC(ctx sdk.Context, app *App) error { + if err := upgradeToIBCv7(ctx, app); err != nil { + return err + } + if err := upgradeToIBCv8(ctx, app); err != nil { + return err + } + return nil } // upgradeToIBCv7 upgrades IBC from v6 to v7. // TODO: Remove with the umbra handlers. -func upgradeToIBCv7(ctx sdk.Context, app *App) { - +func upgradeToIBCv7(ctx sdk.Context, app *App) error { + _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.appCodec, app.IBCKeeper.ClientKeeper) + if err != nil { + // TODO Logging + return err + } + return nil } // upgradeToIBCv8 upgrades IBC from v7 to v8. // TODO: Remove with the umbra handlers. -func upgradeToIBCv8(ctx sdk.Context, app *App) { - +func upgradeToIBCv8(ctx sdk.Context, app *App) error { + return nil } From cfb72acaec7623cefc70938010d2371b0e000bd7 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 15 Mar 2024 14:12:41 -0400 Subject: [PATCH 04/21] Add param migration. --- app/app.go | 15 +++++++++------ app/upgrades.go | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index 534a24b8fc..a058dda127 100644 --- a/app/app.go +++ b/app/app.go @@ -127,6 +127,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" appparams "github.com/provenance-io/provenance/app/params" @@ -225,6 +226,7 @@ var ( icq.AppModuleBasic{}, ibchooks.AppModuleBasic{}, ibcratelimitmodule.AppModuleBasic{}, + ibctm.AppModuleBasic{}, marker.AppModuleBasic{}, attribute.AppModuleBasic{}, @@ -443,7 +445,6 @@ 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]), @@ -1390,11 +1391,13 @@ 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(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable()) // TODO[1760]: Not needed since ICA Controller is not enabled + + 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/upgrades.go b/app/upgrades.go index 18b89c1dc2..b9ec462fc9 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -18,6 +18,7 @@ import ( crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibctmmigrations "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint/migrations" @@ -207,6 +208,11 @@ var upgrades = map[string]appUpgrade{ Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error + err = migrateParams(ctx, app) + if err != nil { + return nil, err + } + err = upgradeIBC(ctx, app) if err != nil { return nil, err @@ -575,3 +581,14 @@ func upgradeToIBCv7(ctx sdk.Context, app *App) error { func upgradeToIBCv8(ctx sdk.Context, app *App) error { return nil } + +// Migrate to new ConsensusParamsKeeper +// TODO: Remove with the umbra handlers. +func migrateParams(ctx sdk.Context, app *App) error { + legacyBaseAppSubspace := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) + err := baseapp.MigrateParams(ctx, legacyBaseAppSubspace, app.ConsensusParamsKeeper.ParamsStore) + if err != nil { + return err + } + return nil +} From 33a789766d11a3c606003b2e059c402b696cd6c0 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Fri, 15 Mar 2024 14:39:08 -0400 Subject: [PATCH 05/21] Add upgrades for ibcv8 and add logging. Updated umber tests as well --- app/app.go | 2 ++ app/upgrades.go | 39 +++++++++++++++++++++++++-------------- app/upgrades_test.go | 17 ++++++++++++++++- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/app/app.go b/app/app.go index a058dda127..3bf47db112 100644 --- a/app/app.go +++ b/app/app.go @@ -127,6 +127,7 @@ import ( porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine" ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" @@ -227,6 +228,7 @@ var ( ibchooks.AppModuleBasic{}, ibcratelimitmodule.AppModuleBasic{}, ibctm.AppModuleBasic{}, + solomachine.AppModuleBasic{}, marker.AppModuleBasic{}, attribute.AppModuleBasic{}, diff --git a/app/upgrades.go b/app/upgrades.go index b9ec462fc9..83a8515f56 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -20,6 +20,7 @@ import ( govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" paramstypes "github.com/cosmos/cosmos-sdk/x/params/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" attributekeeper "github.com/provenance-io/provenance/x/attribute/keeper" @@ -233,6 +234,11 @@ var upgrades = map[string]appUpgrade{ Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error + err = migrateParams(ctx, app) + if err != nil { + return nil, err + } + err = upgradeIBC(ctx, app) if err != nil { return nil, err @@ -553,42 +559,47 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) { ctx.Logger().Info("Done updating ibc marker denom metadata") } -// upgradeIBC upgrades IBC to the latest version -// TODO: Remove with the umbra handlers. +// upgradeIBC handles all IBC upgrade logic for each upgrade. func upgradeIBC(ctx sdk.Context, app *App) error { - if err := upgradeToIBCv7(ctx, app); err != nil { - return err - } - if err := upgradeToIBCv8(ctx, app); err != nil { + if err := pruneIBCExpiredConsensusStates(ctx, app); err != nil { return err } - return nil + return upgradeToIBCv8(ctx, app) } -// upgradeToIBCv7 upgrades IBC from v6 to v7. -// TODO: Remove with the umbra handlers. -func upgradeToIBCv7(ctx sdk.Context, app *App) error { +// pruneIBCExpiredConsensusStates upgrades IBC from v6 to v8. +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 { - // TODO Logging + 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 } -// upgradeToIBCv8 upgrades IBC from v7 to v8. -// TODO: Remove with the umbra handlers. +// upgradeToIBCv8 upgrades IBC from v6 to v8. +// TODO: Remove with the umber handlers. func upgradeToIBCv8(ctx sdk.Context, app *App) error { + ctx.Logger().Info("Upgrading to IBCv8") + params := app.IBCKeeper.ClientKeeper.GetParams(ctx) + params.AllowedClients = append(params.AllowedClients, exported.Localhost) + app.IBCKeeper.ClientKeeper.SetParams(ctx, params) + ctx.Logger().Info("Done upgrading to IBCv8") return nil } // Migrate to new ConsensusParamsKeeper -// TODO: Remove with the umbra handlers. +// TODO: Remove with the umber handlers. func migrateParams(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 } diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 2e8d2e51b3..25c6740e65 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -498,6 +498,12 @@ func (s *UpgradeTestSuite) TestTourmaline() { func (s *UpgradeTestSuite) TestUmberRC1() { expInLog := []string{ + "INF Migrating legacy params", + "INF Done migrating legacy params", + "INF Pruning expired consensus states for IBC", + "INF Done pruning expired consensus states for IBC", + "INF Upgrading to IBCv8", + "INF Done Upgrading to IBCv8", "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", } @@ -506,7 +512,16 @@ func (s *UpgradeTestSuite) TestUmberRC1() { } func (s *UpgradeTestSuite) TestUmber() { - expInLog := []string{} + expInLog := []string{ + "INF Migrating legacy params", + "INF Done migrating legacy params", + "INF Pruning expired consensus states for IBC", + "INF Done pruning expired consensus states for IBC", + "INF Upgrading to IBCv8", + "INF Done Upgrading to IBCv8", + "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) } From 48f6190e20373d9650dbea4af1f2ed2502363284 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 20 Mar 2024 14:46:52 -0400 Subject: [PATCH 06/21] Remove ModuleBasics, and migrate ibc params. --- app/app.go | 88 ++++---------------- app/app_test.go | 2 +- app/encoding.go | 4 - app/genesis.go | 7 -- app/test_helpers.go | 8 +- cmd/provenanced/cmd/root.go | 43 +++++++--- cmd/provenanced/cmd/testnet_test.go | 13 ++- go.mod | 1 - go.sum | 4 - testutil/ibc/testchain.go | 2 +- testutil/network.go | 4 +- x/ibchooks/ibc_middleware_test.go | 2 +- x/ibcratelimit/module/ibc_middleware_test.go | 2 +- 13 files changed, 71 insertions(+), 109 deletions(-) diff --git a/app/app.go b/app/app.go index 3bf47db112..7b43f8b162 100644 --- a/app/app.go +++ b/app/app.go @@ -127,8 +127,6 @@ import ( porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" - solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine" - ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" appparams "github.com/provenance-io/provenance/app/params" @@ -191,58 +189,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{}, - ibctm.AppModuleBasic{}, - solomachine.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, @@ -447,6 +393,7 @@ func New( 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]), @@ -819,20 +766,20 @@ func New( // 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, // TODO[1760]: Do we still need the nameclient? ), - }) - 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( @@ -1242,9 +1189,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. @@ -1295,7 +1241,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 { diff --git a/app/app_test.go b/app/app_test.go index 3e8de81cc8..406c636711 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -47,7 +47,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { // 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{}) + map[int64]bool{}, opts.HomePath, 0, MakeEncodingConfig(), simtestutil.EmptyAppOptions{}) var err error require.NotPanics(t, func() { _, err = app2.ExportAppStateAndValidators(false, nil, nil) 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 ce9508c446..78d5c77dc2 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -85,7 +85,7 @@ func setup(t *testing.T, withGenesis bool, invCheckPeriod uint) (*App, GenesisSt app := New(loggerMaker(), db, nil, true, map[int64]bool{}, t.TempDir(), invCheckPeriod, encCdc, simtestutil.EmptyAppOptions{}) if withGenesis { - return app, NewDefaultGenesisState(encCdc.Marshaler) + return app, app.DefaultGenesis() } return app, GenesisState{} } @@ -151,7 +151,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 { @@ -213,7 +213,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) @@ -342,7 +342,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/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index 988ec14075..f7ec81bf8e 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -36,12 +36,15 @@ 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" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + // rosettacmd "github.com/cosmos/rosetta/cmd" // TODO[1760]: rosetta "github.com/provenance-io/provenance/app" @@ -60,7 +63,25 @@ 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. + var tempDir = func() string { + dir, err := os.MkdirTemp("", "provenanced") + if err != nil { + panic("failed to create temp dir: " + err.Error()) + } + defer os.RemoveAll(dir) + + return dir + } + 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). @@ -105,7 +126,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", @@ -140,12 +161,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), @@ -154,7 +175,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(), @@ -170,8 +191,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(), ) @@ -225,7 +246,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"}, @@ -243,13 +264,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", @@ -271,7 +292,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 55a1321393..d0ae22c778 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,6 @@ require ( github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.2 - github.com/otiai10/copy v1.14.0 github.com/rakyll/statik v0.1.7 github.com/rs/zerolog v1.32.0 github.com/spf13/cast v1.6.0 diff --git a/go.sum b/go.sum index 0845e08d13..45e9b77fb5 100644 --- a/go.sum +++ b/go.sum @@ -848,10 +848,6 @@ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= -github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= -github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= -github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= -github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= 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/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/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 } From dd6b2637ad5018ab2556f959d0c41320feb6ddf2 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 20 Mar 2024 15:54:17 -0400 Subject: [PATCH 07/21] Update changelog to account for ModuleBasics. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1c395d766..743804d625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Create a default market in `make run`, `localnet`, `devnet` and the `provenanced testnet` command [#1757](https://github.com/provenance-io/provenance/issues/1757). * 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 ModuleBasicManager [#1760](https://github.com/provenance-io/provenance/issues/1760). ### Dependencies From fd7c82dce0ad7c6a69246aa9fcf4a4f010ad040e Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Wed, 20 Mar 2024 15:54:56 -0400 Subject: [PATCH 08/21] Fix typo in changelog. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 743804d625..fd6e928c2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,7 +54,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Create a default market in `make run`, `localnet`, `devnet` and the `provenanced testnet` command [#1757](https://github.com/provenance-io/provenance/issues/1757). * 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 ModuleBasicManager [#1760](https://github.com/provenance-io/provenance/issues/1760). +* Replace ModuleBasics with BasicModuleManager [#1760](https://github.com/provenance-io/provenance/issues/1760). ### Dependencies From 5884af30c00c9c958f08ac7d1bfc4b9eb26d6c3f Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 21 Mar 2024 10:35:39 -0400 Subject: [PATCH 09/21] Add signing options. --- app/params/proto.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/params/proto.go b/app/params/proto.go index af70d9429c..8107f1b3bf 100644 --- a/app/params/proto.go +++ b/app/params/proto.go @@ -4,9 +4,14 @@ package params import ( + "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/codec" + amino "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/tx" + "github.com/cosmos/gogoproto/proto" ) // MakeTestEncodingConfig creates an EncodingConfig for a non-amino based test configuration. @@ -14,8 +19,19 @@ import ( // App user shouldn't create new codecs - use the app.AppCodec instead. // [DEPRECATED] func MakeTestEncodingConfig() EncodingConfig { - cdc := codec.NewLegacyAmino() - interfaceRegistry := types.NewInterfaceRegistry() + cdc := amino.NewLegacyAmino() + signingOptions := signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + } + interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signingOptions, + }) marshaler := codec.NewProtoCodec(interfaceRegistry) return EncodingConfig{ From 5ae8427b505adb61307a97b6a10266948c1f22f9 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 21 Mar 2024 10:36:17 -0400 Subject: [PATCH 10/21] Add finalize block to make test pass and help ensure encoder/decoders are working. --- app/app_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/app_test.go b/app/app_test.go index 406c636711..e8126f4e00 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -6,6 +6,7 @@ import ( "sort" "testing" + abci "github.com/cometbft/cometbft/abci/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -43,12 +44,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, MakeEncodingConfig(), simtestutil.EmptyAppOptions{}) - var err error require.NotPanics(t, func() { _, err = app2.ExportAppStateAndValidators(false, nil, nil) }, "exporting app state at current height") From 853bd3161b4ec177ccc62022d411f3d9e07c75f2 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 21 Mar 2024 10:57:38 -0400 Subject: [PATCH 11/21] Fix remaining test in app_test.go --- app/app_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/app_test.go b/app/app_test.go index e8126f4e00..42658a37b4 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -146,6 +146,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 From 215a8ca6b8ecb0c7158d25cb4bf0099b0bb4749d Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 21 Mar 2024 14:17:39 -0400 Subject: [PATCH 12/21] Remove replace comment for ibc-go dependency. --- go.mod | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.mod b/go.mod index d0ae22c778..4d976c2bbc 100644 --- a/go.mod +++ b/go.mod @@ -218,8 +218,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 From b7646e0db622c8ae93d33c53bdb2cc71d117a61d Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 21 Mar 2024 14:19:32 -0400 Subject: [PATCH 13/21] Remove commented out code. --- app/app.go | 1 - 1 file changed, 1 deletion(-) diff --git a/app/app.go b/app/app.go index 7b43f8b162..8c1ba19bf9 100644 --- a/app/app.go +++ b/app/app.go @@ -1342,7 +1342,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable) paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable()) paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable()) - // paramsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable()) // TODO[1760]: Not needed since ICA Controller is not enabled paramsKeeper.Subspace(icqtypes.ModuleName) // TODO[1760]: params: Migrate icq params. paramsKeeper.Subspace(ibchookstypes.ModuleName) // TODO[1760]: params: Migrate ibc-hooks params. From 76be962c8dc60257515da21fa25913fe6888d6fa Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 21 Mar 2024 15:17:38 -0400 Subject: [PATCH 14/21] Update interfaces for modules. --- app/app.go | 1 - go.mod | 5 ++--- x/attribute/module.go | 10 ++++++---- x/exchange/module/module.go | 9 +++++---- x/hold/module/module.go | 9 +++++---- x/ibchooks/module.go | 8 +++++--- x/ibcratelimit/module/module.go | 9 +++++---- x/marker/module.go | 9 ++++++--- x/metadata/module.go | 8 +++++--- x/msgfees/module/module.go | 9 +++++---- x/name/module.go | 9 +++++---- x/oracle/module/module.go | 9 +++++---- x/reward/module/module.go | 10 +++++++--- x/trigger/module/module.go | 11 +++++++---- 14 files changed, 68 insertions(+), 48 deletions(-) diff --git a/app/app.go b/app/app.go index 8c1ba19bf9..a5e5632607 100644 --- a/app/app.go +++ b/app/app.go @@ -761,7 +761,6 @@ 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. diff --git a/go.mod b/go.mod index 4d976c2bbc..622f91d400 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.2.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.110.10 // indirect cloud.google.com/go/compute v1.23.3 // 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 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/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/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. From 552236dabf9574fbaf1a00ef8f7c7634f6d36457 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 1 Apr 2024 09:40:37 -0400 Subject: [PATCH 15/21] Fix some migration documentation and fix order of pruning. --- app/upgrades.go | 28 ++++++++++++++-------------- app/upgrades_test.go | 8 ++++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 83a8515f56..2cc9fb89e0 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -209,12 +209,16 @@ var upgrades = map[string]appUpgrade{ Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error - err = migrateParams(ctx, app) + if err := pruneIBCExpiredConsensusStates(ctx, app); err != nil { + return nil, err + } + + err = migrateBaseappParams(ctx, app) if err != nil { return nil, err } - err = upgradeIBC(ctx, app) + err = upgradeToIBCv8(ctx, app) if err != nil { return nil, err } @@ -234,12 +238,16 @@ var upgrades = map[string]appUpgrade{ Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error - err = migrateParams(ctx, app) + if err := pruneIBCExpiredConsensusStates(ctx, app); err != nil { + return nil, err + } + + err = migrateBaseappParams(ctx, app) if err != nil { return nil, err } - err = upgradeIBC(ctx, app) + err = upgradeToIBCv8(ctx, app) if err != nil { return nil, err } @@ -559,14 +567,6 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) { ctx.Logger().Info("Done updating ibc marker denom metadata") } -// upgradeIBC handles all IBC upgrade logic for each upgrade. -func upgradeIBC(ctx sdk.Context, app *App) error { - if err := pruneIBCExpiredConsensusStates(ctx, app); err != nil { - return err - } - return upgradeToIBCv8(ctx, app) -} - // pruneIBCExpiredConsensusStates upgrades IBC from v6 to v8. func pruneIBCExpiredConsensusStates(ctx sdk.Context, app *App) error { ctx.Logger().Info("Pruning expired consensus states for IBC") @@ -590,9 +590,9 @@ func upgradeToIBCv8(ctx sdk.Context, app *App) error { return nil } -// Migrate to new ConsensusParamsKeeper +// migrateBaseappParams migrates to new ConsensusParamsKeeper // TODO: Remove with the umber handlers. -func migrateParams(ctx sdk.Context, app *App) error { +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) diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 25c6740e65..ceadb77e01 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -498,10 +498,10 @@ func (s *UpgradeTestSuite) TestTourmaline() { func (s *UpgradeTestSuite) TestUmberRC1() { expInLog := []string{ - "INF Migrating legacy params", - "INF Done migrating legacy params", "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 Upgrading to IBCv8", "INF Done Upgrading to IBCv8", "INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.", @@ -513,10 +513,10 @@ func (s *UpgradeTestSuite) TestUmberRC1() { func (s *UpgradeTestSuite) TestUmber() { expInLog := []string{ - "INF Migrating legacy params", - "INF Done migrating legacy params", "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 Upgrading to IBCv8", "INF Done Upgrading to IBCv8", "INF Starting module migrations. This may take a significant amount of time to complete. Do not restart node.", From 93f0d9215b83d4aaee2d19d556ce7d5ac9f749b1 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 1 Apr 2024 10:01:18 -0400 Subject: [PATCH 16/21] Remove TODO. --- app/app.go | 2 +- app/upgrades.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/app.go b/app/app.go index a5e5632607..0b38b7d53c 100644 --- a/app/app.go +++ b/app/app.go @@ -773,7 +773,7 @@ func New( append( []govclient.ProposalHandler{}, paramsclient.ProposalHandler, - nameclient.RootNameProposalHandler, // TODO[1760]: Do we still need the nameclient? + nameclient.RootNameProposalHandler, ), ), }) diff --git a/app/upgrades.go b/app/upgrades.go index 2cc9fb89e0..2bded026e0 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -218,12 +218,12 @@ var upgrades = map[string]appUpgrade{ return nil, err } - err = upgradeToIBCv8(ctx, app) + vm, err = runModuleMigrations(ctx, app, vm) if err != nil { return nil, err } - vm, err = runModuleMigrations(ctx, app, vm) + err = upgradeToIBCv8(ctx, app) if err != nil { return nil, err } @@ -247,12 +247,12 @@ var upgrades = map[string]appUpgrade{ return nil, err } - err = upgradeToIBCv8(ctx, app) + vm, err = runModuleMigrations(ctx, app, vm) if err != nil { return nil, err } - vm, err = runModuleMigrations(ctx, app, vm) + err = upgradeToIBCv8(ctx, app) if err != nil { return nil, err } From 2a89460341b6d28fd3ac6e705c9df44b328af7f6 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 1 Apr 2024 11:59:51 -0400 Subject: [PATCH 17/21] Update function comment. --- app/upgrades.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades.go b/app/upgrades.go index 2bded026e0..d0c204be2b 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -567,7 +567,7 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) { ctx.Logger().Info("Done updating ibc marker denom metadata") } -// pruneIBCExpiredConsensusStates upgrades IBC from v6 to v8. +// 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) From bf496e17c0a96e140c6be59d771a4ec6ee02e714 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 1 Apr 2024 13:12:42 -0400 Subject: [PATCH 18/21] Rename upgradeIBCv8 to updateIBCClients. --- app/upgrades.go | 12 ++++++------ app/upgrades_test.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index d0c204be2b..cfb0361e76 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -223,7 +223,7 @@ var upgrades = map[string]appUpgrade{ return nil, err } - err = upgradeToIBCv8(ctx, app) + err = updateIBCClients(ctx, app) if err != nil { return nil, err } @@ -252,7 +252,7 @@ var upgrades = map[string]appUpgrade{ return nil, err } - err = upgradeToIBCv8(ctx, app) + err = updateIBCClients(ctx, app) if err != nil { return nil, err } @@ -579,14 +579,14 @@ func pruneIBCExpiredConsensusStates(ctx sdk.Context, app *App) error { return nil } -// upgradeToIBCv8 upgrades IBC from v6 to v8. +// updateIBCClients updates the allowed clients for IBC. // TODO: Remove with the umber handlers. -func upgradeToIBCv8(ctx sdk.Context, app *App) error { - ctx.Logger().Info("Upgrading to IBCv8") +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 upgrading to IBCv8") + ctx.Logger().Info("Done updating IBC AllowedClients") return nil } diff --git a/app/upgrades_test.go b/app/upgrades_test.go index ceadb77e01..1c5abf06ea 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -502,8 +502,8 @@ func (s *UpgradeTestSuite) TestUmberRC1() { "INF Done pruning expired consensus states for IBC", "INF Migrating legacy params", "INF Done migrating legacy params", - "INF Upgrading to IBCv8", - "INF Done Upgrading to IBCv8", + "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", } @@ -517,8 +517,8 @@ func (s *UpgradeTestSuite) TestUmber() { "INF Done pruning expired consensus states for IBC", "INF Migrating legacy params", "INF Done migrating legacy params", - "INF Upgrading to IBCv8", - "INF Done Upgrading to IBCv8", + "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", } From fffa6bec8913c0cc009374c1bf03b4ebe8ef226c Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Mon, 1 Apr 2024 13:30:18 -0400 Subject: [PATCH 19/21] Add periods to logs. --- app/upgrades.go | 16 ++++++++-------- app/upgrades_test.go | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index cfb0361e76..6cea317f5e 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -569,37 +569,37 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) { // pruneIBCExpiredConsensusStates prunes expired consensus states for IBC. func pruneIBCExpiredConsensusStates(ctx sdk.Context, app *App) error { - ctx.Logger().Info("Pruning expired consensus states for IBC") + 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)) + 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") + 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") + 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") + 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") + 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)) + ctx.Logger().Error(fmt.Sprintf("unable to migrate legacy params to ConsensusParamsKeeper, error: %s.", err)) return err } - ctx.Logger().Info("Done migrating legacy params") + ctx.Logger().Info("Done migrating legacy params.") return nil } diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 1c5abf06ea..b9bc0fdd5f 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -498,12 +498,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 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", } @@ -513,12 +513,12 @@ func (s *UpgradeTestSuite) TestUmberRC1() { func (s *UpgradeTestSuite) TestUmber() { 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 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", } From 6fc5bd79c7d99b1c7603bdc0cc3c51eb51abd571 Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 4 Apr 2024 10:14:03 -0400 Subject: [PATCH 20/21] Change how tempdir is made. --- cmd/provenanced/cmd/root.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index f7ec81bf8e..95ac719580 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -64,19 +64,15 @@ const ( // 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. - var tempDir = func() string { - dir, err := os.MkdirTemp("", "provenanced") - if err != nil { - panic("failed to create temp dir: " + err.Error()) - } - defer os.RemoveAll(dir) - - return dir + 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(), + tempDir, 0, encodingConfig, simtestutil.EmptyAppOptions{}, From 4f2063ecd4c6820c8214624742caec6514965fad Mon Sep 17 00:00:00 2001 From: Matthew Witkowski Date: Thu, 4 Apr 2024 15:04:50 -0400 Subject: [PATCH 21/21] Fix redeclared dependency. --- app/app_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/app/app_test.go b/app/app_test.go index 8602e63e5b..3a28e476a5 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -6,7 +6,6 @@ import ( "sort" "testing" - abci "github.com/cometbft/cometbft/abci/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require"