Skip to content

Commit

Permalink
docs: add initial migration steps for v0.27.1
Browse files Browse the repository at this point in the history
There are more `app.go` changes to be added to the migration guide and
after that the document must be copied to nightly docs.
  • Loading branch information
jeronimoalbi committed Jun 22, 2023
1 parent d3dae76 commit 956c505
Showing 1 changed file with 334 additions and 0 deletions.
334 changes: 334 additions & 0 deletions docs/versioned_docs/version-v0.27.1/06-migration/v0.27.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,334 @@
---
sidebar_position: 991
title: v0.27.1
description: For chains that were scaffolded with Ignite CLI versions lower than v0.27.0. changes are required to use Ignite CLI v0.27.1.
---

## Query commands

Query commands context initialization should be changed to:

```go title="x/{moduleName}/client/cli/query_{typeName}.go"
RunE: func(cmd *cobra.Command, args []string) (err error) {
// remove-next-line
clientCtx := client.GetClientContextFromCmd(cmd)
// highlight-start
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
// highlight-end

// ...
}
```

## Cosmos SDK v0.47.3 upgrade notes

### Imports

To use the new cosmos SDK make sure you update `go.mod` dependencies:

```go title="go.mod"
go 1.19

require (
// remove-start
github.com/cosmos/cosmos-sdk v0.46.7
github.com/tendermint/tendermint v0.34.24
github.com/tendermint/tm-db v0.6.7
github.com/gogo/protobuf v1.3.3
// remove-end
// highlight-start
cosmossdk.io/api v0.3.1
github.com/cosmos/cosmos-sdk v0.47.1
github.com/cometbft/cometbft v0.37.0
github.com/cometbft/cometbft-db v0.7.0
github.com/cosmos/gogoproto v1.4.7
// highlight-end

// ...
)

// ...

replace (
// remove-start
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
// remove-end
// highlight-next-line
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
```

The Cosmos SDK has migrated to CometBFT as its default consensus engine which requires
changes in your app imports:

1. Replace `github.com/tendermint/tendermint` by `github.com/cometbft/cometbft`
2. Replace `github.com/tendermint/tm-db` by `github.com/cometbft/cometbft-db`
3. Verify `github.com/tendermint/tendermint` is not an indirect or direct dependency

The SDK has also migrated from `gogo/protobuf` to `cosmos/gogoproto`. This means you must
replace all `github.com/gogo/protobuf` imports with `github.com/cosmos/gogoproto`. This change
might introduce breaking changes to your proto layout. Follow the official
[Cosmos migration guide](https://docs.cosmos.network/main/migrations/upgrading#gogoproto-import-paths)
to make sure you are using the correct layout.

### App changes

Applications scaffolded with older version of Ignite CLI would require the following changes to the app file:

```go title="app/app.go"
import (
//...

// highlight-start
"github.com/cosmos/cosmos-sdk/x/consensus"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
// highlight-end
)

var (
// ...

ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
authzmodule.AppModuleBasic{},
// remove-next-line
genutil.AppModuleBasic{},
// highlight-next-line
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
bank.AppModuleBasic{},
//...
)
)

var (
// highlight-next-line
_ runtime.AppI = (*App)(nil)
_ servertypes.Application = (*App)(nil)
// remove-next-line
_ simapp.App = (*App)(nil)
)

func init() {
}

// ...

type App struct {
*baseapp.BaseApp

cdc *codec.LegacyAmino
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry
// highlight-next-line
txConfig client.TxConfig

invCheckPeriod uint

// ...

FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
// highlight-next-line
ConsensusParamsKeeper consensusparamkeeper.Keeper

// ...
}

// ...

// New returns a reference to an initialized blockchain app
func New(
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig appparams.EncodingConfig,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
appCodec := encodingConfig.Marshaler
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
// highlight-next-line
txConfig := encodingConfig.TxConfig

// ...

bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)
// highlight-next-line
bApp.SetTxEncoder(txConfig.TxEncoder())

keys := sdk.NewKVStoreKeys(
authtypes.StoreKey,
authz.ModuleName,
banktypes.StoreKey,
stakingtypes.StoreKey,
// highlight-next-line
crisistypes.StoreKey,
minttypes.StoreKey,
distrtypes.StoreKey,
slashingtypes.StoreKey,
govtypes.StoreKey,
paramstypes.StoreKey,
ibcexported.StoreKey,
upgradetypes.StoreKey,
feegrant.StoreKey,
evidencetypes.StoreKey,
ibctransfertypes.StoreKey,
icahosttypes.StoreKey,
capabilitytypes.StoreKey,
group.StoreKey,
icacontrollertypes.StoreKey,
// highlight-next-line
consensusparamtypes.StoreKey,
// ...
)

// ...

app := &App{
BaseApp: bApp,
cdc: cdc,
appCodec: appCodec,
interfaceRegistry: interfaceRegistry,
// highlight-next-line
txConfig: txConfig,
invCheckPeriod: invCheckPeriod,
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
}

// ...

// set the BaseApp's parameter store
// remove-next-line
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))
// highlight-start
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
bApp.SetParamStore(&app.ConsensusParamsKeeper)
// highlight-end

// ...

app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec,
keys[authtypes.StoreKey],
// remove-next-line
app.GetSubspace(authtypes.ModuleName),
authtypes.ProtoBaseAccount,
maccPerms,
sdk.Bech32PrefixAccAddr,
// highlight-next-line
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// ...
}

// ...

// highlight-start
// TxConfig returns App's TxConfig.
func (app *App) TxConfig() client.TxConfig {
return app.txConfig
}
// highlight-end
```

### Deprecations

The app module might contains some legacy methods that are deprecated and can be removed:

```go title="x/{{moduleName}}/module.go"
// remove-start
// Deprecated: use RegisterServices
func (am AppModule) Route() sdk.Route { return sdk.Route{} }

// Deprecated: use RegisterServices
func (AppModule) QuerierRoute() string { return types.RouterKey }

// Deprecated: use RegisterServices
func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier {
return nil
}
// remove-end
```

### Other required changes

Update the collect genesis transactions command and add the new message validator argument:

```go title="cmd/{{binaryNamePrefix}}d/cmd/root.go"
import (
// ...

// highlight-next-line
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)

// ...

func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
// ...

// highlight-next-line
gentxModule := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic)
rootCmd.AddCommand(
// ...
// remove-next-line
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultHome),
// highlight-next-line
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, gentxModule.GenTxValidator),
// ...
)

// ...
}
```

Add the new extra argument to `ExportAppStateAndValidators`:

```go title="app/export.go"
func (app *App) ExportAppStateAndValidators(
forZeroHeight bool,
jailAllowedAddrs []string,
// highlight-next-line
modulesToExport []string,
) (servertypes.ExportedApp, error) {
// ...

// highlight-next-line
genState := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
appState, err := json.MarshalIndent(genState, "", " ")
if err != nil {
return servertypes.ExportedApp{}, err
}

// ...
}
```

### Migration

You can also follow other Cosmos SDK migration steps in their [upgrade guide](https://docs.cosmos.network/main/migrations/upgrading#v047x).

## ibc-go v7

Chains that are newly scaffolded with Ignite CLI `v0.27.1` now use `ibc-go/v7` for ibc functionality. It is
recommended to upgrade to the newest version of `ibc-go`. Migrations can be done by following the `ibc-go`
[migration guide v6 to v7](https://github.com/cosmos/ibc-go/blob/v7.0.1/docs/migrations/v6-to-v7.md).

## Doctor command

As the final step it's recommended to run `ignite doctor`.

0 comments on commit 956c505

Please sign in to comment.