Skip to content

[Documentation]: Upgrade directly from cosmos sdk 0.46.5 to cosmos sdk 0.50.4 #20160

@QuocThi

Description

@QuocThi

Summary

Hi,

I am upgrading from cosmos sdk 0.46.5 to cosmos sdk version 0.50.4. Currently my upgrade handler is merged from this (version 0.47.5) and this to upgrade directly from version 0.46.5 to version 0.50.4, here is the code:

const UpgradeName = "v046-to-v050"

func (app App) RegisterUpgradeHandlers() {
         baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
	app.UpgradeKeeper.SetUpgradeHandler(
		UpgradeName,
		func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
			baseapp.MigrateParams(ctx.(sdk.Context), baseAppLegacySS, app.ConsensusParamsKeeper.ParamsStore)
			consensusParams := baseapp.GetConsensusParams(ctx.(sdk.Context), baseAppLegacySS)
			// make sure the consensus params are set
			if consensusParams.Block == nil || consensusParams.Evidence == nil || consensusParams.Validator == nil {
				defaultParams := tmtypes.DefaultConsensusParams().ToProto()
				app.ConsensusParamsKeeper.ParamsStore.Set(ctx.(sdk.Context), defaultParams)
			}

			storesvc := runtime.NewKVStoreService(app.GetKey("upgrade"))
			consensuskeeper := consensuskeeper.NewKeeper(
				app.appCodec,
				storesvc,
				app.AccountKeeper.GetAuthority(),
				runtime.EventService{},
			)

			params, err := consensuskeeper.ParamsStore.Get(ctx)
			if err != nil {
				return nil, err
			}

			err = app.ConsensusParamsKeeper.ParamsStore.Set(ctx, params)
			if err != nil {
				return nil, err
			}

			return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
		},
	)

	upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
	if err != nil {
		panic(err)
	}

	if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
		storeUpgrades := storetypes.StoreUpgrades{
			Added: []string{
				consensustypes.ModuleName,
				crisistypes.ModuleName,
				circuittypes.ModuleName,
				ibcfee.ModuleName,
			},
		}

		// configure store loader that checks if version == upgradeHeight and applies store upgrades
		app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
	}
}

But I got this error when start the new binary (use cosmos sdk 0.50.4) after gov upgrade proposal pass and reach the upgrade height:

10:15PM INF Replay last block using real app module=consensus
10:15PM ERR failed to get consensus params err="collections: not found: key 'no_key' of type github.com/cosmos/gogoproto/tendermint.types.ConsensusParams" module=server
10:15PM ERR failed to get consensus params err="collections: not found: key 'no_key' of type github.com/cosmos/gogoproto/tendermint.types.ConsensusParams" module=server
10:15PM ERR error in proxyAppConn.FinalizeBlock err="collections: not found: key 'no_key' of type github.com/cosmos/gogoproto/cosmos.distribution.v1beta1.Params" module=consensus
10:15PM INF Closing application.db module=server
10:15PM INF Closing snapshots/metadata.db module=server
Error: error during handshake: error on replay: collections: not found: key 'no_key' of type github.com/cosmos/gogoproto/cosmos.distribution.v1beta1.Params

In my code above I already apply the code follow this command from a related issue: #18733 (comment)

Can I upgrade the binary using cosmos sdk 0.46.5 to use cosmos sdk 0.50.4 directly (skip upgrade to version 0.47 before upgrade to 0.50.4)? Or any mistake in my code?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions