ignite/cli

v0.47 -> v0.50 upgrades doesn't works using the last scaffold (v28.2.0)

RaulBernal opened this issue · 4 comments

Describe the bug
When I try to make an upgrade driven by governance from SDK v0.47 (v0.27.1) to SDK v0.50.3 (v0.28.2) Store key upgrade fails.

To reproduce
Steps to reproduce the behavior:

  1. Scaffold a new chain with Ignite v0.27.1: ignite27 scaffold chain github.com/BitCannaGlobal/test --address-prefix test
  2. Run the chain: ignite27 chain serve (I have modified the voting_time for convenience to 5 mins)
  3. Send an Upgrade Software proposal: testd tx gov submit-legacy-proposal software-upgrade StickyFingers --upgrade-height 1000 --from alice --title "v50 upgrade" --description "v50 upgrade" --deposit 10000000stake --no-validate --gas 300000
  4. In the meantime scaffold a new chain development with Ignite v0.28.2: mkdir v50 && cd v50 && ignite282 scaffold chain github.com/BitCannaGlobal/test --address-prefix test
  5. Add a simple Upgrade Handler to the new development:
package app

import (
	"context"
	"fmt"

	"github.com/cosmos/cosmos-sdk/types/module"

	storetypes "cosmossdk.io/store/types"
	circuittypes "cosmossdk.io/x/circuit/types"
	ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"

	nft "cosmossdk.io/x/nft"
	upgradetypes "cosmossdk.io/x/upgrade/types"
)

// RegisterUpgradeHandlers registers upgrade handlers.

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

	app.StickyFingers(upgradeInfo)
}
func (app *App) StickyFingers(_ upgradetypes.Plan) {
	planName := "StickyFingers"
	app.UpgradeKeeper.SetUpgradeHandler(
		planName,
		func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
			app.Logger().Info("Cosmos-SDK v0.50.x is here...")
			// Print the modules with their respective ver.
			for moduleName, version := range fromVM {
				app.Logger().Info(fmt.Sprintf("Module: %s, Version: %d", moduleName, version))

			}
			versionMap, err := app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
			if err != nil {
				return nil, err
			}
			app.Logger().Info(fmt.Sprintf("post migrate version map: %v", versionMap))
			// return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
			return versionMap, err
		},
	)
	upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
	if err != nil {
		panic(err)
	}

	if upgradeInfo.Name == planName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
		storeUpgrades := storetypes.StoreUpgrades{
			Added: []string{
				circuittypes.ModuleName,
				ibcfeetypes.ModuleName,
				// ibctm.ModuleName,
				// solomachine.ModuleName,
				// runtime.ModuleName,
				// "ibc-interchainaccounts",
				nft.ModuleName,
			},
		}

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

}
  1. Execute the new upgrade when the chain is stopped waiting for the new binary:
11:10AM INF Timed out dur=973.265 height=1000 module=consensus round=0 step=1
11:10AM INF received proposal module=consensus proposal={"Type":32,"block_id":{"hash":"64CFC5795AB69594932FD52F3F73CC8163FE59CE20A04F56D5387DA180641116","parts":{"hash":"10CEC8174C0FE3136C61C2F40DE9238602CCEC338C69D3189BF7734546E762D9","total":1}},"height":1000,"pol_round":-1,"round":0,"signature":"n3O7+fImaYisJj9IfTKBZvGqRfEOwapWVI96gpJ2gCmhPzjc+jrzan+wbad7cDNhfJngJzOoCbL6y6/lKyxxBg==","timestamp":"2024-02-15T10:10:35.875316Z"}
11:10AM INF received complete proposal block hash=64CFC5795AB69594932FD52F3F73CC8163FE59CE20A04F56D5387DA180641116 height=1000 module=consensus
11:10AM INF finalizing commit of block hash={} height=1000 module=consensus num_txs=0 root=DCAC650C417C18546167F966217ACF06FDDE39BE7BA01AA9BB94C2C78D100881
11:10AM ERR UPGRADE "StickyFingers" NEEDED at height: 1000: https://github.com/BitCannaGlobal/bcna/releases/download/v2.0.3/bcna_darwin_arm64.tar.gz?checksum=sha256:253f1503b0d9d8c7f8512c7fb9988cacd7695e82eda2e85bec097eebee76f0eb module=server
11:10AM ERR CONSENSUS FAILURE!!! err="UPGRADE \"StickyFingers\" NEEDED at height: 1000: https://github.com/BitCannaGlobal/bcna/releases/download/v2.0.3/bcna_darwin_arm64.tar.gz?checksum=sha256:253f1503b0d9d8c7f8512c7fb9988cacd7695e82eda2e85bec097eebee76f0eb" module=consensus stack="goroutine 88 [running]:\nruntime/debug.Stack()\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x64\ngithub.com/cometbft/cometbft/consensus.(*State).receiveRoutine.func2()\n\t/Users/raul/go/pkg/mod/github.com/cometbft/cometbft@v0.37.1/consensus/state.go:732 +0x4c\npanic({0x107bb9b40?, 0x14
...
...
...
ignite282 chain build   
Cosmos SDK's version is: v0.50.3

🗃  Installed. Use with: testd
raul@iMac-de-Raul test % testd start          
panic: failed to load latest version: version of store circuit mismatch root store's version; expected 999 got 0; new stores should be added using StoreUpgrades

goroutine 1 [running]:
github.com/BitCannaGlobal/test/cmd/testd/cmd.newApp({0x105f13008, 0x14000225f80}, {0x105f26a70, 0x14001224058}, {0x0, 0x0}, {0x105ed63c0, 0x140014a56c0})
        /Users/raul/SDK/IgniteTEST/v50/test/cmd/testd/cmd/commands.go:137 +0xa8
github.com/cosmos/cosmos-sdk/server.startApp(0x14000697280, 0x105ec45f8, {0x105ec4d48?, 0x0?, 0x0?})
        /Users/raul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.3/server/start.go:642 +0x110
github.com/cosmos/cosmos-sdk/server.start(_, {{0x0, 0x0, 0x0}, {0x105f2c4d0, 0x140014de630}, 0x0, {0x14000db7428, 0x4}, {0x105f4a040, ...}, ...}, ...)
        /Users/raul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.3/server/start.go:250 +0xd8
github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2.1()
        /Users/raul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.3/server/start.go:175 +0x58
github.com/cosmos/cosmos-sdk/server.wrapCPUProfile(0x14000697280, 0x140011457f8)
        /Users/raul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.3/server/start.go:600 +0x16c
github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2(0x14000b61000?, {0x107a32d40?, 0x0?, 0x0?})
        /Users/raul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.3/server/start.go:174 +0x194
github.com/spf13/cobra.(*Command).execute(0x1400134ef00, {0x107a32d40, 0x0, 0x0})
        /Users/raul/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x14001239200)
        /Users/raul/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/raul/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        /Users/raul/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1032
github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x140000aa6e8?, {0x0, 0x0}, {0x14001218000, 0x11})
        /Users/raul/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.3/server/cmd/execute.go:34 +0x154
main.main()
        /Users/raul/SDK/IgniteTEST/v50/test/cmd/testd/main.go:15 +0x3c

What version are you using?

Ignite CLI version:		v28.2.0
Ignite CLI build date:		2024-02-06T11:21:56Z
Ignite CLI source hash:		af25183a2d312aa4d679e65e3d627025b17a7120
Ignite CLI config version:	v1
Cosmos SDK version:		v0.50.3
Your OS:			darwin
Your arch:			arm64
Your Node.js version:		v20.11.0
Your go version:		go version go1.21.6 darwin/arm64
Your uname -a:			Darwin iMac-de-Raul.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:19 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8103 x86_64

To put more context in this issue, I made a successful upgrade with the scaffolded of Ignite v0.28.0
Output of that test is here:

bcnad start
9:37AM INF Upgrading IAVL storage for faster queries + execution on live state. This may take a while commit=436F6D6D697449447B5B5D3A307D module=server store_key="KVStoreKey{0x14000df1d10, circuit}" version=100
9:37AM INF Upgrading IAVL storage for faster queries + execution on live state. This may take a while commit=436F6D6D697449447B5B5D3A307D module=server store_key="KVStoreKey{0x140016e02c0, feeibc}" version=100
9:37AM INF starting node with ABCI CometBFT in-process module=server
9:37AM INF service start impl=multiAppConn module=proxy msg="Starting multiAppConn service"
9:37AM INF service start connection=query impl=localClient module=abci-client msg="Starting localClient service"
9:37AM INF service start connection=snapshot impl=localClient module=abci-client msg="Starting localClient service"
9:37AM INF service start connection=mempool impl=localClient module=abci-client msg="Starting localClient service"
9:37AM INF service start connection=consensus impl=localClient module=abci-client msg="Starting localClient service"
9:37AM INF service start impl=EventBus module=events msg="Starting EventBus service"
9:37AM INF service start impl=PubSub module=pubsub msg="Starting PubSub service"
9:37AM INF service start impl=IndexerService module=txindex msg="Starting IndexerService service"
9:37AM INF ABCI Handshake App Info hash=F37E306C930DD54CBFF7495E78941C63CB2F83012A1BE6D83495650697BB64ED height=99 module=consensus protocol-version=0 software-version=3.0.0-rc3-ba0b2da8
9:37AM INF ABCI Replay Blocks appHeight=99 module=consensus stateHeight=99 storeHeight=100
9:37AM INF Replay last block using real app module=consensus
9:37AM INF applying upgrade "StickyFingers" at height: 100 module=x/upgrade
9:37AM INF Cosmos-SDK v0.50.x is here... module=server
9:37AM INF Module: interchainaccounts, Version: 2 module=server
9:37AM INF Module: params, Version: 1 module=server
9:37AM INF Module: slashing, Version: 3 module=server
9:37AM INF Module: transfer, Version: 3 module=server
9:37AM INF Module: feegrant, Version: 2 module=server
9:37AM INF Module: group, Version: 2 module=server
9:37AM INF Module: ibc, Version: 4 module=server
9:37AM INF Module: mint, Version: 2 module=server
9:37AM INF Module: authz, Version: 2 module=server
9:37AM INF Module: evidence, Version: 1 module=server
9:37AM INF Module: gov, Version: 4 module=server
9:37AM INF Module: consensus, Version: 1 module=server
9:37AM INF Module: crisis, Version: 2 module=server
9:37AM INF Module: distribution, Version: 3 module=server
9:37AM INF Module: staking, Version: 4 module=server
9:37AM INF Module: auth, Version: 4 module=server
9:37AM INF Module: bcna, Version: 1 module=server
9:37AM INF Module: capability, Version: 1 module=server
9:37AM INF Module: vesting, Version: 1 module=server
9:37AM INF Module: bank, Version: 4 module=server
9:37AM INF Module: genutil, Version: 1 module=server
9:37AM INF Module: upgrade, Version: 2 module=server
9:37AM INF adding a new module: 06-solomachine module=server
9:37AM INF adding a new module: 07-tendermint module=server
9:37AM INF adding a new module: circuit module=server
9:37AM INF adding a new module: feeibc module=server
9:37AM INF migrating module gov from version 4 to version 5 module=server
9:37AM INF migrating module ibc from version 4 to version 5 module=server
9:37AM INF successfully migrated client to self-manage params module=x/ibc/client
9:37AM INF successfully migrated connection to self-manage params module=x/ibc/connection
9:37AM INF migrating module interchainaccounts from version 2 to version 3 module=server
9:37AM INF successfully migrated ica/host submodule to self-manage params module=x/ibc-interchainaccounts
9:37AM INF successfully migrated ica/controller submodule to self-manage params module=x/ibc-interchainaccounts
9:37AM INF adding a new module: runtime module=server
9:37AM INF migrating module slashing from version 3 to version 4 module=server
9:37AM INF migrating module staking from version 4 to version 5 module=server
9:37AM INF migrating module transfer from version 3 to version 4 module=server
9:37AM INF successfully migrated transfer app self-manage params module=x/ibc-transfer
9:37AM INF migrating module transfer from version 4 to version 5 module=server
9:37AM INF successfully added metadata to IBC voucher denominations module=x/ibc-transfer
9:37AM INF migrating module auth from version 4 to version 5 module=server
9:37AM INF finalized block block_app_hash=6724392F556C369F5A1CF5C3B18782F5D3F0F4A7450FDE456F0B9B36B6D20CA6 height=100 module=consensus num_txs_res=0 num_val_updates=0
9:37AM INF executed block app_hash=6724392F556C369F5A1CF5C3B18782F5D3F0F4A7450FDE456F0B9B36B6D20CA6 height=100 module=consensus
9:37AM INF committed state block_app_hash=F37E306C930DD54CBFF7495E78941C63CB2F83012A1BE6D83495650697BB64ED height=100 module=consensus

NOTE: my own test (previous comment) was made with NFT module deactivated but the Ignite clean test are done with NFT activated in app_conf etc