Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
QuocThi opened this issue Apr 23, 2024 · 6 comments
Closed
Labels
T:Docs Changes and features related to documentation.

Comments

@QuocThi
Copy link

QuocThi commented Apr 23, 2024

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!

@QuocThi QuocThi added the T:Docs Changes and features related to documentation. label Apr 23, 2024
@johnletey
Copy link
Contributor

@QuocThi Are you using app wiring? I was running into this exact issue when upgrading from v0.45.x, and it was because I wasn't registering the x/upgrade Pre Blocker.

@QuocThi
Copy link
Author

QuocThi commented Apr 24, 2024

Hi @johnletey , can you give me some docs about registering the x/upgrade Pre Blocker.

@QuocThi
Copy link
Author

QuocThi commented May 7, 2024

Hi @johnletey, I just finish switch to use app wiring, and also has bellow code in app_config.go,
PreBlockers: []string{ upgradetypes.ModuleName, },
But the issue still happen.

@QuocThi
Copy link
Author

QuocThi commented May 7, 2024

From the code I could see this issue is expected from 0.46 to 0.50:

// This could happen while migrating from v0.45/v0.46 to v0.50, we should

But my binary still crashed after that.

@QuocThi
Copy link
Author

QuocThi commented May 8, 2024

I found that this issue doesn't cause the binary crashed, so the case can be close here.

@QuocThi QuocThi closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T:Docs Changes and features related to documentation.
Projects
Status: 🥳 Done
Development

No branches or pull requests

2 participants