Skip to content

Commit c999ee8

Browse files
mergify[bot]amaury1093
authored andcommitted
fix: Fix v0.45->v0.46 migration (backport cosmos#12028) (cosmos#12082)
* fix: Fix v0.45->v0.46 migration (cosmos#12028) ## Description closes cosmos#12027 - Add `tendermint key-migrate` subcommand - Fix in-place store migrations Test: - on v0.45 node, make a proposal to update software, make it pass - wait for node to halt - on v0.46 binary, run `simd tendermint key-migrate` - on v0.46 binary, run `simd start --mode validator` - make sure the v0.46 node runs correctly --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) (cherry picked from commit ca0b8f9) # Conflicts: # simapp/upgrades.go * fix conflicts * Update changelog Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
1 parent f1e7cb8 commit c999ee8

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ It is strongly recommended to upgrade to these releases as well.
5656

5757
## [v0.45.14](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.14) - 2023-02-16
5858

59+
### Features
60+
61+
* (cli) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Add the `tendermint key-migrate` to perform Tendermint v0.35 DB key migration.
62+
63+
### Bug Fixes
64+
65+
* (migrations) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Fix v0.45->v0.46 in-place store migrations.
66+
5967
## [v0.46.0-rc1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0-rc1) - 2022-05-23
6068

6169
### Features

server/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ func AddCommands[T types.Application](rootCmd *cobra.Command, appCreator types.A
349349
VersionCmd(),
350350
tmcmd.ResetAllCmd,
351351
tmcmd.ResetStateCmd,
352+
tmcmd.InspectCmd,
353+
makeKeyMigrateCmd(),
352354
)
353355

354356
startCmd := StartCmd(appCreator, defaultNodeHome)

simapp/app.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func NewSimApp(
383383
),
384384
)
385385

386-
app.NFTKeeper = nftkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[nftkeeper.StoreKey]), logger.With(log.ModuleKey, "x/nft")), appCodec, app.AuthKeeper, app.BankKeeper)
386+
app.NFTKeeper = nftkeeper.NewKeeper(keys[nftkeeper.StoreKey], appCodec, app.AccountKeeper, app.BankKeeper)
387387

388388
// create evidence keeper with router
389389
evidenceKeeper := evidencekeeper.NewKeeper(
@@ -513,6 +513,10 @@ func NewSimApp(
513513
}
514514
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)
515515

516+
// RegisterUpgradeHandlers is used for registering any on-chain upgrades.
517+
// Make sure it's called after `app.mm` and `app.configurator` are set.
518+
app.RegisterUpgradeHandlers()
519+
516520
// add test gRPC service for testing gRPC queries in isolation
517521
testdata_pulsar.RegisterQueryServer(app.GRPCQueryRouter(), testdata_pulsar.QueryImpl{})
518522

simapp/upgrades.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,10 @@ import (
2323
const UpgradeName = "v050-to-v051"
2424

2525
func (app SimApp) RegisterUpgradeHandlers() {
26-
app.UpgradeKeeper.SetUpgradeHandler(
27-
UpgradeName,
28-
func(ctx context.Context, _ upgradetypes.Plan, fromVM appmodule.VersionMap) (appmodule.VersionMap, error) {
29-
// sync accounts and auth module account number
30-
err := authkeeper.MigrateAccountNumberUnsafe(ctx, &app.AuthKeeper)
31-
if err != nil {
32-
return nil, err
33-
}
34-
35-
return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
36-
},
37-
)
26+
app.UpgradeKeeper.SetUpgradeHandler(UpgradeName,
27+
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
28+
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
29+
})
3830

3931
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
4032
if err != nil {

0 commit comments

Comments
 (0)