From f40ef8f067cac00c87a6ed9bc474fd10b45a139f Mon Sep 17 00:00:00 2001 From: Daniel Wedul Date: Fri, 14 Jun 2024 07:03:20 -0600 Subject: [PATCH] Fix the umber upgrades. (#2033) * Move the call to registerUpgradeHandlers back down to where that stuff was originally so that we can have it inject an upgrade which now overwrites the pre-blocker (instead of begin-blocker). * Add the consensus params to the list of added modules for umber. * inject the umber upgrade (and add a TODO to remove it). * Use the correct type for the marker module's max supply param entry. * Fix the os locator params migration. Make it just set it to the default. Those params never got defined in testnet, and mainnet has an empty entry for it. So both were just using the default value there anyway. * Fix the name params migration to properly identify the keytable. * Fix the ibchooks params migration. * Small cleanup in app.New to reuse stuff from the sdk config. * Refactor app.SetConfig(bool, bool) to be able to switch back to mainnet after initially being changed to testnet. * Move the EnvTypeFlag and CoinTypeFlag variables into the interceptor with some other flags so that we can use them in there as needed. * Add key tables to all the params subspaces. Needed now because the migrations all failed because the needed keys weren't registered. * Tweak the log messages in migrateBaseappParams to better reflect what's being done (all of the params stuff is 'legacy' now, so it didn't really describe what was happening. * Delete the call to injectUpgrade. * Add nolint:staticcheck to all the newly added calls to the deprecated ParamKeyTable functions. * Fix double import. * Fix the umber tests to have the expected log messages for the consensus params migration (that I updated a few commits ago). * Add changelog entry. --- CHANGELOG.md | 1 + app/app.go | 68 ++++++------ app/prefix.go | 14 +-- app/prefix_test/prefix_test.go | 147 ++++++++++++++++++++------ app/upgrades.go | 26 ++--- app/upgrades_test.go | 8 +- cmd/provenanced/cmd/init.go | 2 +- cmd/provenanced/cmd/root.go | 15 +-- cmd/provenanced/config/interceptor.go | 6 +- go.mod | 4 +- 10 files changed, 182 insertions(+), 109 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 930428e2ac..5d57a2c145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,6 +120,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * The `add-net-asset-values` command now correctly uses the from `flag`'s `AccAddress` [#1995](https://github.com/provenance-io/provenance/issues/1995). * Fix the sim tests [#2015](https://github.com/provenance-io/provenance/pull/2015). +* Fix the `umber` and `umber-rc1` upgrades [#2033](https://github.com/provenance-io/provenance/pull/2033). ### Deprecated diff --git a/app/app.go b/app/app.go index 47c89f8706..e47401ce57 100644 --- a/app/app.go +++ b/app/app.go @@ -10,6 +10,7 @@ import ( "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmv2 "github.com/CosmWasm/wasmd/x/wasm/migrations/v2" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" @@ -92,6 +93,7 @@ import ( govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/group" groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper" @@ -332,13 +334,14 @@ func New( logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *App { + sdkConfig := sdk.GetConfig() + addrPrefix := sdkConfig.GetBech32AccountAddrPrefix() + valAddrPrefix := sdkConfig.GetBech32ValidatorAddrPrefix() + consAddrPrefix := sdkConfig.GetBech32ConsensusAddrPrefix() + signingOptions := signing.Options{ - AddressCodec: address.Bech32Codec{ - Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), - }, - ValidatorAddressCodec: address.Bech32Codec{ - Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), - }, + AddressCodec: address.Bech32Codec{Bech32Prefix: addrPrefix}, + ValidatorAddressCodec: address.Bech32Codec{Bech32Prefix: valAddrPrefix}, } exchange.DefineCustomGetSigners(&signingOptions) interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ @@ -359,7 +362,6 @@ func New( bApp.SetInterfaceRegistry(interfaceRegistry) sdk.SetCoinDenomRegex(SdkCoinDenomRegex) - // TODO[1760]: Add the circuit breaker module to the app. keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, @@ -434,13 +436,8 @@ func New( // capability keeper must be sealed after scope to module registrations are completed. app.CapabilityKeeper.Seal() - // Obtain prefixes so running tests can use "cosmos" while we use "pb" - addrPrefix := sdk.GetConfig().GetBech32AccountAddrPrefix() - valAddrPrefix := sdk.GetConfig().GetBech32ValidatorAddrPrefix() - consAddrPrefix := sdk.GetConfig().GetBech32ConsensusAddrPrefix() - // add keepers - app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec(addrPrefix), addrPrefix, govAuthority) + app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, signingOptions.AddressCodec, addrPrefix, govAuthority) app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, @@ -957,11 +954,6 @@ func New( panic(err) } - // Register upgrade handlers and set the store loader. - // This must be done after the module manager and configurator are set, - // but before the baseapp is sealed via LoadLatestVersion() down below. - app.registerUpgradeHandlers(appOpts) - autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules)) reflectionSvc, err := runtimeservices.NewReflectionService() @@ -993,6 +985,11 @@ func New( app.setFeeHandler() app.SetAggregateEventsFunc(piohandlers.AggregateEvents) + // Register upgrade handlers and set the store loader. + // This must be done after the module manager, configurator, and pre-blocker are set, + // but before the baseapp is sealed via LoadLatestVersion() below. + app.registerUpgradeHandlers(appOpts) + if loadLatest { if err := app.LoadLatestVersion(); err != nil { cmtos.Exit(err.Error()) @@ -1346,16 +1343,17 @@ func GetMaccPerms() map[string][]string { func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) - paramsKeeper.Subspace(authtypes.ModuleName) + //nolint:staticcheck // The ParamKeyTable functions are deprecated, but needed here for the migrations. + paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable()) paramsKeeper.Subspace(banktypes.ModuleName) - paramsKeeper.Subspace(stakingtypes.ModuleName) - paramsKeeper.Subspace(minttypes.ModuleName) - paramsKeeper.Subspace(distrtypes.ModuleName) - paramsKeeper.Subspace(slashingtypes.ModuleName) - paramsKeeper.Subspace(govtypes.ModuleName) - paramsKeeper.Subspace(crisistypes.ModuleName) + paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypesv1.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable()) //nolint:staticcheck - paramsKeeper.Subspace(wasmtypes.ModuleName) + paramsKeeper.Subspace(wasmtypes.ModuleName).WithKeyTable(wasmv2.ParamKeyTable()) //nolint:staticcheck // register the key tables for legacy param subspaces keyTable := ibcclienttypes.ParamKeyTable() @@ -1363,14 +1361,15 @@ 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(icqtypes.ModuleName).WithKeyTable(icqtypes.ParamKeyTable()) return paramsKeeper } // injectUpgrade causes the named upgrade to be run as the chain starts. // -// To use this, add a call to it in New after the call to InstallCustomUpgradeHandlers -// but before the line that looks for an upgrade file. +// To use this, add a call to it in registerUpgradeHandlers immediately after the +// call to InstallCustomUpgradeHandlers, but before the line that looks for an upgrade file. // // This function is for testing an upgrade against an existing chain's data (e.g. mainnet). // Here's how: @@ -1401,15 +1400,16 @@ func (app *App) injectUpgrade(name string) { //nolint:unused // This is designed if err := app.UpgradeKeeper.DumpUpgradeInfoToDisk(plan.Height, plan); err != nil { panic(err) } - // Define a new BeginBlocker that will inject the upgrade. + + // Define a new PreBlocker that will inject the upgrade. injected := false - app.SetBeginBlocker(func(ctx sdk.Context) (sdk.BeginBlock, error) { + app.SetPreBlocker(func(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { if !injected { app.Logger().Info("Injecting upgrade plan", "plan", plan) // Ideally, we'd just call ScheduleUpgrade(ctx, plan) here (and panic on error). - // But the upgrade keeper often its own migration stuff that change some store key stuff. - // ScheduleUpgrade tries to read some of that changed store stuff and fails if the migration hasn't - // been applied yet. So we're doing things the hard way here. + // But the upgrade keeper often has its own migration stuff that change some store stuff. + // ScheduleUpgrade would try to read some of that old state using the update pattern, + // causing a failure. So we're doing things the hard way here. if err := app.UpgradeKeeper.ClearUpgradePlan(ctx); err != nil { panic(err) } @@ -1418,6 +1418,6 @@ func (app *App) injectUpgrade(name string) { //nolint:unused // This is designed store.Set(upgradetypes.PlanKey(), bz) injected = true } - return app.BeginBlocker(ctx) + return app.PreBlocker(ctx, req) }) } diff --git a/app/prefix.go b/app/prefix.go index 2e97fc9519..8afac2aad8 100644 --- a/app/prefix.go +++ b/app/prefix.go @@ -26,16 +26,17 @@ var ( // SetConfig sets the configuration for the network using mainnet or testnet func SetConfig(testnet bool, seal bool) { - // not the default (mainnet) so reset with testnet config + AccountAddressPrefix = AccountAddressPrefixMainNet + CoinType = CoinTypeMainNet if testnet { AccountAddressPrefix = AccountAddressPrefixTestNet - AccountPubKeyPrefix = AccountAddressPrefixTestNet + "pub" - ValidatorAddressPrefix = AccountAddressPrefixTestNet + "valoper" - ValidatorPubKeyPrefix = AccountAddressPrefixTestNet + "valoperpub" - ConsNodeAddressPrefix = AccountAddressPrefixTestNet + "valcons" - ConsNodePubKeyPrefix = AccountAddressPrefixTestNet + "valconspub" CoinType = CoinTypeTestNet } + AccountPubKeyPrefix = AccountAddressPrefix + "pub" + ValidatorAddressPrefix = AccountAddressPrefix + "valoper" + ValidatorPubKeyPrefix = AccountAddressPrefix + "valoperpub" + ConsNodeAddressPrefix = AccountAddressPrefix + "valcons" + ConsNodePubKeyPrefix = AccountAddressPrefix + "valconspub" config := sdk.GetConfig() config.SetCoinType(uint32(CoinType)) @@ -43,6 +44,7 @@ func SetConfig(testnet bool, seal bool) { config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix) config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix) config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix) + if seal { config.Seal() } diff --git a/app/prefix_test/prefix_test.go b/app/prefix_test/prefix_test.go index f1b6b093db..07349b5102 100644 --- a/app/prefix_test/prefix_test.go +++ b/app/prefix_test/prefix_test.go @@ -22,6 +22,7 @@ package prefix_test import ( "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,55 +30,131 @@ import ( "github.com/provenance-io/provenance/app" ) -func TestFullBIP44Path(t *testing.T) { +func TestSetConfig(t *testing.T) { cases := []struct { - name string - expected string - isTestnet bool - seal bool - panicMessage string + name string + isTestnet bool + seal bool + expPath string + expHRP string + expCoinType int + expPanic string }{ { - // Note: The way our SetConfig function works, calling it with isTestnet = true makes some changes that aren't undone - // when later calling it with isTestnet = false. So to test the mainnet BIP44, we need to do it first. - name: "has correct bip44th path for mainnet", - expected: "m/44'/505'/0'/0/0", - isTestnet: false, - seal: false, - panicMessage: "", + name: "mainnet", + isTestnet: false, + seal: false, + expPath: "m/44'/505'/0'/0/0", + expHRP: app.AccountAddressPrefixMainNet, + expCoinType: app.CoinTypeMainNet, }, { - // Note: This is the 2nd to last test, so we're doing seal = true. - name: "has correct bip44th path for testnet", - expected: "m/44'/1'/0'/0/0", - isTestnet: true, - seal: true, - panicMessage: "", + name: "testnet", + isTestnet: true, + seal: false, + expPath: "m/44'/1'/0'/0/0", + expHRP: app.AccountAddressPrefixTestNet, + expCoinType: app.CoinTypeTestNet, }, { - // Note: The previous test should have had seal = true, making this an + name: "back to mainnet", + isTestnet: false, + seal: false, + expPath: "m/44'/505'/0'/0/0", + expHRP: app.AccountAddressPrefixMainNet, + expCoinType: app.CoinTypeMainNet, + }, + { + // This is the last valid test, so we're doing seal = true. + name: "back to testnet with seal", + isTestnet: true, + seal: true, + expPath: "m/44'/1'/0'/0/0", + expHRP: app.AccountAddressPrefixTestNet, + expCoinType: app.CoinTypeTestNet, + }, + { + // Note: A previous test should have had seal = true, making this an + // attempt to change the config after sealing it. + name: "already sealed: mainnet, no reseal", + isTestnet: false, + seal: false, + expPanic: "Config is sealed", + }, + { + // Note: A previous test should have had seal = true, making this an + // attempt to change the config after sealing it. + name: "already sealed: testnet, no reseal", + isTestnet: true, + seal: false, + expPanic: "Config is sealed", + }, + { + // Note: A previous test should have had seal = true, making this an // attempt to change the config after sealing it. - name: "cannot double seal", - expected: "", - isTestnet: false, - seal: true, - panicMessage: "Config is sealed", + name: "already sealed: mainnet, with reseal", + isTestnet: false, + seal: true, + expPanic: "Config is sealed", + }, + { + // Note: A previous test should have had seal = true, making this an + // attempt to change the config after sealing it. + name: "already sealed: testnet, with reseal", + isTestnet: true, + seal: true, + expPanic: "Config is sealed", }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { - if len(tc.panicMessage) > 0 { - require.PanicsWithValue(t, tc.panicMessage, func() { - app.SetConfig(tc.isTestnet, tc.seal) - }, "SetConfig") + testFunc := func() { + app.SetConfig(tc.isTestnet, tc.seal) + } + if len(tc.expPanic) > 0 { + require.PanicsWithValue(t, tc.expPanic, testFunc, "SetConfig") } else { - require.NotPanics(t, func() { - app.SetConfig(tc.isTestnet, tc.seal) - }, "SetConfig") - config := sdk.GetConfig() - fullBIP44Path := config.GetFullBIP44Path() - require.Equal(t, tc.expected, fullBIP44Path, "GetFullBIP44Path") + require.NotPanics(t, testFunc, "SetConfig") + + expAddrPre := tc.expHRP + expValPre := tc.expHRP + "valoper" + expValPubPre := tc.expHRP + "valoperpub" + expAddrPrePub := tc.expHRP + "pub" + expConsPre := tc.expHRP + "valcons" + expConsPubPre := tc.expHRP + "valconspub" + + sdkConfig := sdk.GetConfig() + fullBIP44Path := sdkConfig.GetFullBIP44Path() + addrPre := sdkConfig.GetBech32AccountAddrPrefix() + addrPubPre := sdkConfig.GetBech32AccountPubPrefix() + valPre := sdkConfig.GetBech32ValidatorAddrPrefix() + valPubPre := sdkConfig.GetBech32ValidatorPubPrefix() + consPre := sdkConfig.GetBech32ConsensusAddrPrefix() + consPubPre := sdkConfig.GetBech32ConsensusPubPrefix() + coinType := sdkConfig.GetCoinType() + purpose := sdkConfig.GetPurpose() + + // Using require to check the main HRPs because if they're wrong, the rest will almost certainly also be wrong. + require.Equal(t, expAddrPre, app.AccountAddressPrefix, "AccountAddressPrefix") + require.Equal(t, expAddrPre, addrPre, "sdkConfig.GetBech32AccountAddrPrefix()") + // Asserts from here on out so we get a larger picture upon failure. + assert.Equal(t, expAddrPrePub, app.AccountPubKeyPrefix, "AccountPubKeyPrefix") + assert.Equal(t, expAddrPrePub, addrPubPre, "sdkConfig.GetBech32AccountPubPrefix()") + assert.Equal(t, expValPre, app.ValidatorAddressPrefix, "ValidatorAddressPrefix") + assert.Equal(t, expValPre, valPre, "sdkConfig.GetBech32ValidatorAddrPrefix()") + assert.Equal(t, expValPubPre, app.ValidatorPubKeyPrefix, "ValidatorPubKeyPrefix") + assert.Equal(t, expValPubPre, valPubPre, "sdkConfig.GetBech32ValidatorPubPrefix()") + assert.Equal(t, expConsPre, app.ConsNodeAddressPrefix, "ConsNodeAddressPrefix") + assert.Equal(t, expConsPre, consPre, "sdkConfig.GetBech32ConsensusAddrPrefix()") + assert.Equal(t, expConsPubPre, app.ConsNodePubKeyPrefix, "ConsNodePubKeyPrefix") + assert.Equal(t, expConsPubPre, consPubPre, "sdkConfig.GetBech32ConsensusPubPrefix()") + + assert.Equal(t, tc.expPath, fullBIP44Path, "sdkConfig.GetFullBIP44Path()") + assert.Equal(t, tc.expCoinType, app.CoinType, "CoinType") + assert.Equal(t, tc.expCoinType, int(coinType), "sdkConfig.GetCoinType()") + assert.Equal(t, 44, app.Purpose, "Purpose") + assert.Equal(t, 44, int(purpose), "sdkConfig.GetPurpose()") } }) } diff --git a/app/upgrades.go b/app/upgrades.go index 418c40490f..1ad48441ab 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -14,6 +14,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -54,7 +55,7 @@ type appUpgrade struct { // or vice versa, please add comments explaining why in both entries. var upgrades = map[string]appUpgrade{ "umber-rc1": { // upgrade for v1.19.0-rc1 - Added: []string{crisistypes.ModuleName, circuittypes.ModuleName}, + Added: []string{crisistypes.ModuleName, circuittypes.ModuleName, consensusparamtypes.ModuleName}, Deleted: []string{"reward"}, Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error @@ -98,7 +99,7 @@ var upgrades = map[string]appUpgrade{ }, }, "umber": { // upgrade for v1.19.0 - Added: []string{crisistypes.ModuleName, circuittypes.ModuleName}, + Added: []string{crisistypes.ModuleName, circuittypes.ModuleName, consensusparamtypes.ModuleName}, Deleted: []string{"reward"}, Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) { var err error @@ -312,14 +313,14 @@ func updateIBCClients(ctx sdk.Context, app *App) { // 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 consensus 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.") + ctx.Logger().Info("Done migrating consensus params.") return nil } @@ -387,9 +388,9 @@ func migrateMarkerParams(ctx sdk.Context, app *App) { // TODO: remove markertypes.ParamStoreKeyMaxSupply with the umber handlers. if markerParamSpace.Has(ctx, markertypes.ParamStoreKeyMaxSupply) { - var maxSupply string + var maxSupply sdkmath.Int markerParamSpace.Get(ctx, markertypes.ParamStoreKeyMaxSupply, &maxSupply) - params.MaxSupply = markertypes.StringToBigInt(maxSupply) + params.MaxSupply = maxSupply } app.MarkerKeeper.SetParams(ctx, params) @@ -401,13 +402,8 @@ func migrateMarkerParams(ctx sdk.Context, app *App) { // TODO: Remove with the umber handlers. func migrateMetadataOSLocatorParams(ctx sdk.Context, app *App) { ctx.Logger().Info("Migrating metadata os locator params.") - metadataParamSpace := app.ParamsKeeper.Subspace(metadatatypes.ModuleName).WithKeyTable(metadatatypes.ParamKeyTable()) - maxValueLength := uint32(metadatatypes.DefaultMaxURILength) - // TODO: remove metadatatypes.ParamStoreKeyMaxValueLength with the umber handlers. - if metadataParamSpace.Has(ctx, metadatatypes.ParamStoreKeyMaxValueLength) { - metadataParamSpace.Get(ctx, metadatatypes.ParamStoreKeyMaxValueLength, &maxValueLength) - } - app.MetadataKeeper.SetOSLocatorParams(ctx, metadatatypes.OSLocatorParams{MaxUriLength: maxValueLength}) + params := metadatatypes.DefaultOSLocatorParams() + app.MetadataKeeper.SetOSLocatorParams(ctx, params) ctx.Logger().Info("Done migrating metadata os locator params.") } @@ -415,7 +411,7 @@ func migrateMetadataOSLocatorParams(ctx sdk.Context, app *App) { // TODO: Remove with the umber handlers. func migrateNameParams(ctx sdk.Context, app *App) { ctx.Logger().Info("Migrating name params.") - nameParamSpace := app.ParamsKeeper.Subspace(nametypes.ModuleName) + nameParamSpace := app.ParamsKeeper.Subspace(nametypes.ModuleName).WithKeyTable(nametypes.ParamKeyTable()) params := nametypes.DefaultParams() @@ -476,7 +472,7 @@ func migrateMsgFeesParams(ctx sdk.Context, app *App) { // TODO: Remove with the umber handlers. func migrateIbcHooksParams(ctx sdk.Context, app *App) { ctx.Logger().Info("Migrating ibchooks params.") - ibcHooksParamSpace := app.ParamsKeeper.Subspace(ibchookstypes.ModuleName) + ibcHooksParamSpace := app.ParamsKeeper.Subspace(ibchookstypes.ModuleName).WithKeyTable(ibchookstypes.ParamKeyTable()) params := ibchookstypes.DefaultParams() diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 0a7901a3f7..ceab1e2350 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -367,8 +367,8 @@ 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 Migrating consensus params.", + "INF Done migrating consensus params.", "INF Migrating bank params.", "INF Done migrating bank params.", "INF Migrating attribute params.", @@ -400,8 +400,8 @@ 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 Migrating consensus params.", + "INF Done migrating consensus params.", "INF Migrating bank params.", "INF Done migrating bank params.", "INF Migrating attribute params.", diff --git a/cmd/provenanced/cmd/init.go b/cmd/provenanced/cmd/init.go index 38c1dbbff3..3e39f8bace 100644 --- a/cmd/provenanced/cmd/init.go +++ b/cmd/provenanced/cmd/init.go @@ -78,7 +78,7 @@ func Init( moniker string, ) error { chainID, _ := cmd.Flags().GetString(flags.FlagChainID) - isTestnet, _ := cmd.Flags().GetBool(EnvTypeFlag) + isTestnet, _ := cmd.Flags().GetBool(provconfig.EnvTypeFlag) doRecover, _ := cmd.Flags().GetBool(FlagRecover) doOverwrite, _ := cmd.Flags().GetBool(FlagOverwrite) timeoutCommit, err := cmd.Flags().GetDuration(FlagTimeoutCommit) diff --git a/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index 72f2c74609..037464c496 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -51,13 +51,6 @@ import ( "github.com/provenance-io/provenance/internal/pioconfig" ) -const ( - // EnvTypeFlag is a flag for indicating a testnet - EnvTypeFlag = "testnet" - // CoinTypeFlag is a flag for indicating coin type. - CoinTypeFlag = "coin-type" -) - // 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) { @@ -111,12 +104,12 @@ func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) { // set app context based on initialized EnvTypeFlag vpr := server.GetServerContextFromCmd(cmd).Viper - testnet := vpr.GetBool(EnvTypeFlag) + testnet := vpr.GetBool(config.EnvTypeFlag) app.SetConfig(testnet, sealConfig) overwriteFlagDefaults(cmd, map[string]string{ // Override default value for coin-type to match our mainnet or testnet value. - CoinTypeFlag: fmt.Sprint(app.CoinType), + config.CoinTypeFlag: fmt.Sprint(app.CoinType), // Override min gas price(server level config) here since the provenance config would have been set based on flags. server.FlagMinGasPrices: pioconfig.GetProvenanceConfig().ProvenanceMinGasPrices, }) @@ -128,7 +121,7 @@ func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) { overwriteFlagDefaults(rootCmd, map[string]string{ flags.FlagChainID: "", flags.FlagKeyringBackend: "test", - CoinTypeFlag: fmt.Sprint(app.CoinTypeMainNet), + config.CoinTypeFlag: fmt.Sprint(app.CoinTypeMainNet), }) // add keyring to autocli opts @@ -158,7 +151,7 @@ func Execute(rootCmd *cobra.Command) error { ctx = context.WithValue(ctx, client.ClientContextKey, &client.Context{}) ctx = context.WithValue(ctx, server.ServerContextKey, server.NewDefaultContext()) - rootCmd.PersistentFlags().BoolP(EnvTypeFlag, "t", false, "Indicates this command should use the testnet configuration (default: false [mainnet])") + rootCmd.PersistentFlags().BoolP(config.EnvTypeFlag, "t", false, "Indicates this command should use the testnet configuration (default: false [mainnet])") rootCmd.PersistentFlags().String(flags.FlagLogLevel, zerolog.InfoLevel.String(), "The logging level (trace|debug|info|warn|error|fatal|panic)") rootCmd.PersistentFlags().String(flags.FlagLogFormat, cmtconfig.LogFormatPlain, "The logging format (json|plain)") diff --git a/cmd/provenanced/config/interceptor.go b/cmd/provenanced/config/interceptor.go index 97ad5ce8c6..e854bdc62a 100644 --- a/cmd/provenanced/config/interceptor.go +++ b/cmd/provenanced/config/interceptor.go @@ -19,6 +19,10 @@ const ( CustomDenomFlag = "custom-denom" // CustomMsgFeeFloorPriceFlag flag to take in custom msg floor fees, defaults to 1905nhash if not passed in. CustomMsgFeeFloorPriceFlag = "msgfee-floor-price" + // EnvTypeFlag is a flag for indicating a testnet + EnvTypeFlag = "testnet" + // CoinTypeFlag is a flag for indicating coin type. + CoinTypeFlag = "coin-type" ) // InterceptConfigsPreRunHandler performs a pre-run function for all commands. @@ -52,7 +56,7 @@ func InterceptConfigsPreRunHandler(cmd *cobra.Command) error { // This needs to be done before we load the config files for the cases when: // 1. The files don't exist yet, and we're loading the defaults. // 2. The config is packed and we're filling in the missing with defaults. - if vpr.GetBool("testnet") { + if vpr.GetBool(EnvTypeFlag) { DefaultKeyringBackend = "test" } // Read the configs into viper and the contexts. diff --git a/go.mod b/go.mod index 839a354723..b224c6f369 100644 --- a/go.mod +++ b/go.mod @@ -214,9 +214,9 @@ replace ( github.com/CosmWasm/wasmd => github.com/provenance-io/wasmd v0.50.0-pio-2 github.com/cosmos/cosmos-sdk => github.com/provenance-io/cosmos-sdk v0.50.7-pio-1 - // TODO[1760]: Update once async-icq creates tag with our changes https://github.com/cosmos/ibc-apps/pull/168 + // TODO: 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]: Update or change once a tag is made containing a fix for https://github.com/cosmos/ibc-go/issues/6375 + // TODO: Update or change once a tag is made containing a fix for https://github.com/cosmos/ibc-go/issues/6375 github.com/cosmos/ibc-go/v8 => github.com/provenance-io/ibc-go/v8 v8.2.1-pio-1 // dgrijalva/jwt-go is deprecated and doesn't receive security updates.