Skip to content

Commit

Permalink
fix(simapp,systemtests): fix chain upgrade (#22669)
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe authored Nov 27, 2024
1 parent b5b2f49 commit a267da6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
20 changes: 2 additions & 18 deletions simapp/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import (

"cosmossdk.io/core/appmodule"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/x/accounts"
bankv2types "cosmossdk.io/x/bank/v2/types"
epochstypes "cosmossdk.io/x/epochs/types"
protocolpooltypes "cosmossdk.io/x/protocolpool/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
)

// UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade
Expand All @@ -26,12 +21,6 @@ func (app SimApp) RegisterUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
func(ctx context.Context, _ upgradetypes.Plan, fromVM appmodule.VersionMap) (appmodule.VersionMap, error) {
// sync accounts and auth module account number
err := authkeeper.MigrateAccountNumberUnsafe(ctx, &app.AuthKeeper)
if err != nil {
return nil, err
}

return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
},
)
Expand All @@ -43,13 +32,8 @@ func (app SimApp) RegisterUpgradeHandlers() {

if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := corestore.StoreUpgrades{
Added: []string{
accounts.StoreKey,
protocolpooltypes.StoreKey,
epochstypes.StoreKey,
bankv2types.ModuleName,
},
Deleted: []string{"crisis"}, // The SDK discontinued the crisis module in v0.52.0
Added: []string{bankv2types.StoreKey},
Deleted: []string{},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
Expand Down
2 changes: 1 addition & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error {

store, err := rs.loadCommitStoreFromParams(key, commitID, storeParams)
if err != nil {
return errorsmod.Wrap(err, "failed to load store")
return errorsmod.Wrapf(err, "failed to load store for %s", key.Name())
}

newStores[key] = store
Expand Down
5 changes: 1 addition & 4 deletions tests/systemtests/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ import (
)

func TestChainUpgrade(t *testing.T) {
// err> panic: failed to load latest version: failed to load store: initial version set to 22, but found earlier version 1 [cosmossdk.io/[email protected]/rootmulti/store.go:256]
t.Skip("Skipped until any v052 artifact is available AND main branch handles the store upgrade proper")

// Scenario:
// start a legacy chain with some state
// when a chain upgrade proposal is executed
// then the chain upgrades successfully
systest.Sut.StopChain()

legacyBinary := FetchExecutable(t, "v0.52")
legacyBinary := FetchExecutable(t, "0.52.0-beta.3")
t.Logf("+++ legacy binary: %s\n", legacyBinary)
currentBranchBinary := systest.Sut.ExecBinary()
currentInitializer := systest.Sut.TestnetInitializer()
Expand Down

0 comments on commit a267da6

Please sign in to comment.