diff --git a/.github/workflows/proto-registry.yml b/.github/workflows/proto-registry.yml index f259306089..2cfb2443a9 100644 --- a/.github/workflows/proto-registry.yml +++ b/.github/workflows/proto-registry.yml @@ -30,7 +30,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Buf setup action - uses: bufbuild/buf-setup-action@v1.32.2 + uses: bufbuild/buf-setup-action@v1.33.0 - name: Buf push 'third_party/proto' uses: bufbuild/buf-push-action@v1 with: diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 08ec3d38bc..020f9904dc 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -40,7 +40,7 @@ jobs: fi echo "Setting output: base-branch=$branch" echo "base-branch=$branch" >> "$GITHUB_OUTPUT" - - uses: bufbuild/buf-setup-action@v1.32.2 + - uses: bufbuild/buf-setup-action@v1.33.0 - uses: bufbuild/buf-lint-action@v1.1.1 if: always() with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f1e33b699e..9f9118cd59 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -119,7 +119,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Buf setup action - uses: bufbuild/buf-setup-action@v1.32.2 + uses: bufbuild/buf-setup-action@v1.33.0 - name: Buf push 'proto/' uses: bufbuild/buf-push-action@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 930428e2ac..4763412129 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 @@ -131,7 +132,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ - Bump `google.golang.org/grpc` from 1.62.1 to 1.64.0 ([#1903](https://github.com/provenance-io/provenance/pull/1903), [#1918](https://github.com/provenance-io/provenance/pull/1918), [#1972](https://github.com/provenance-io/provenance/pull/1972)) - Bump `bufbuild/buf-breaking-action` from 1.1.3 to 1.1.4 ([#1894](https://github.com/provenance-io/provenance/pull/1894)) - Bump `bufbuild/buf-lint-action` from 1.1.0 to 1.1.1 ([#1895](https://github.com/provenance-io/provenance/pull/1895)) -- Bump `bufbuild/buf-setup-action` from 1.30.0 to 1.32.2 ([#1904](https://github.com/provenance-io/provenance/pull/1904), [#1949](https://github.com/provenance-io/provenance/pull/1949), [#1979](https://github.com/provenance-io/provenance/pull/1979), [#1990](https://github.com/provenance-io/provenance/pull/1990), [#2011](https://github.com/provenance-io/provenance/pull/2011)) +- Bump `bufbuild/buf-setup-action` from 1.30.0 to 1.33.0 ([#1904](https://github.com/provenance-io/provenance/pull/1904), [#1949](https://github.com/provenance-io/provenance/pull/1949), [#1979](https://github.com/provenance-io/provenance/pull/1979), [#1990](https://github.com/provenance-io/provenance/pull/1990), [#2011](https://github.com/provenance-io/provenance/pull/2011), [#2036](https://github.com/provenance-io/provenance/pull/2036)) - Bump `github.com/cometbft/cometbft` from 0.38.5 to 0.38.7 ([#1912](https://github.com/provenance-io/provenance/pull/1912), [#1959](https://github.com/provenance-io/provenance/pull/1959)) - Bump `cosmossdk.io/x/upgrade` from 0.1.0 to 0.1.3 ([#1913](https://github.com/provenance-io/provenance/pull/1913), [#2026](https://github.com/provenance-io/provenance/pull/2026)) - Bump `github.com/hashicorp/go-metrics` from 0.5.2 to 0.5.3 ([#1914](https://github.com/provenance-io/provenance/pull/1914)) @@ -152,6 +153,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ - Bump `cosmossdk.io/store` from 1.0.2 to 1.1.0 [#2026](https://github.com/provenance-io/provenance/pull/2026) - Bump `cosmossdk.io/x/feegrant` from 0.1.0 to 0.1.1 [#2026](https://github.com/provenance-io/provenance/pull/2026) - Bump `cosmossdk.io/x/evidence` from 0.1.0 to 0.1.1 [#2026](https://github.com/provenance-io/provenance/pull/2026) +- Bump `cosmossdk.io/x/circuit` from 0.1.0 to 0.1.1 ([#2035](https://github.com/provenance-io/provenance/pull/2035)) +- Bump `github.com/spf13/cobra` from 1.8.0 to 1.8.1 ([#2038](https://github.com/provenance-io/provenance/pull/2038)) --- diff --git a/app/app.go b/app/app.go index f59c24a469..250f3940d7 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..2ffb392264 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.0 - cosmossdk.io/x/circuit v0.1.0 + cosmossdk.io/x/circuit v0.1.1 cosmossdk.io/x/evidence v0.1.1 cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/tx v0.13.3 @@ -37,7 +37,7 @@ require ( github.com/rakyll/statik v0.1.7 github.com/rs/zerolog v1.33.0 github.com/spf13/cast v1.6.0 - github.com/spf13/cobra v1.8.0 + github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 @@ -82,7 +82,7 @@ require ( github.com/cosmos/iavl v1.1.2 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/danieljoos/wincred v1.2.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect @@ -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. diff --git a/go.sum b/go.sum index e47ebb829e..0d321ce5e5 100644 --- a/go.sum +++ b/go.sum @@ -202,8 +202,8 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk= cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng= -cosmossdk.io/x/circuit v0.1.0 h1:IAej8aRYeuOMritczqTlljbUVHq1E85CpBqaCTwYgXs= -cosmossdk.io/x/circuit v0.1.0/go.mod h1:YDzblVE8+E+urPYQq5kq5foRY/IzhXovSYXb4nwd39w= +cosmossdk.io/x/circuit v0.1.1 h1:KPJCnLChWrxD4jLwUiuQaf5mFD/1m7Omyo7oooefBVQ= +cosmossdk.io/x/circuit v0.1.1/go.mod h1:B6f/urRuQH8gjt4eLIXfZJucrbreuYrKh5CSjaOxr+Q= cosmossdk.io/x/evidence v0.1.1 h1:Ks+BLTa3uftFpElLTDp9L76t2b58htjVbSZ86aoK/E4= cosmossdk.io/x/evidence v0.1.1/go.mod h1:OoDsWlbtuyqS70LY51aX8FBTvguQqvFrt78qL7UzeNc= cosmossdk.io/x/feegrant v0.1.1 h1:EKFWOeo/pup0yF0svDisWWKAA9Zags6Zd0P3nRvVvw8= @@ -374,8 +374,8 @@ github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5n github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE= @@ -968,8 +968,8 @@ github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=