Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
330 lines
7.5 KiB
Markdown
330 lines
7.5 KiB
Markdown
---
|
|
sidebar_position: 995
|
|
title: v0.24.0
|
|
description: For chains that were scaffolded with IGNITE® CLI versions lower than v0.24, changes are required to use IGNITE® CLI v0.24.0.
|
|
---
|
|
|
|
## Cosmos SDK v0.46 upgrade notes
|
|
|
|
### Update dependencies
|
|
|
|
Cosmos SDK v0.46 is compatible with the latest version of IBC Go v5. If you have a chain that is using an older version,
|
|
update the dependencies in your project.
|
|
|
|
Throughout the code you might see the following dependencies:
|
|
|
|
```go
|
|
package pkg_name
|
|
|
|
import (
|
|
"github.com/cosmos/ibc-go/v3/..."
|
|
)
|
|
```
|
|
|
|
Where `v3` is the version of IBC Go and `...` are different IBC Go packages.
|
|
|
|
To upgrade the version to `v5`, a global find-and-replace should work. Replace `cosmos/ibc-go/v3` (or whicherver version
|
|
you're using) with `cosmos/ibc-go/v5` only in `*.go` files (to exclude unwated changes to files like `go,sum`).
|
|
|
|
### Module keeper
|
|
|
|
Add an import:
|
|
|
|
```go
|
|
// x/{moduleName}/keeper/keeper.go
|
|
|
|
package keeper
|
|
|
|
// ...
|
|
|
|
import (
|
|
//...
|
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
)
|
|
```
|
|
|
|
In the `Keeper` struct replace `sdk.StoreKey` with `storetypes.StoreKey`:
|
|
|
|
```go
|
|
// x/{moduleName}/keeper/keeper.go
|
|
|
|
package keeper
|
|
|
|
// ...
|
|
|
|
type (
|
|
Keeper struct {
|
|
cdc codec.BinaryCodec
|
|
storeKey storetypes.StoreKey
|
|
memKey storetypes.StoreKey
|
|
paramstore paramtypes.Subspace
|
|
}
|
|
)
|
|
```
|
|
|
|
In the argument list of the `NewKeeper` function definition:
|
|
|
|
```go
|
|
package keeper
|
|
|
|
// ...
|
|
|
|
// x/{moduleName}/keeper/keeper.go
|
|
|
|
func NewKeeper(
|
|
//...
|
|
memKey storetypes.StoreKey,
|
|
)
|
|
```
|
|
|
|
Store type aliases have been removed from the Cosmos SDK `types` package and now have to be imported from `store/types`,
|
|
instead.
|
|
|
|
In the `testutil/keeper/{moduleName}.go` replace `types.StoreKey` with `storetypes.StoreKey` and `types.MemStoreKey`
|
|
with `storetypes.MemStoreKey`.
|
|
|
|
```go
|
|
// testutil/keeper/{moduleName}.go
|
|
|
|
package keeper
|
|
|
|
// ...
|
|
|
|
func {moduleName}Keeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
|
storeKey := sdk.NewKVStoreKey(storetypes.StoreKey)
|
|
memStoreKey := storetypes.NewMemoryStoreKey(storetypes.MemStoreKey)
|
|
//...
|
|
}
|
|
```
|
|
|
|
### Testutil network package
|
|
|
|
Add the `require` package for testing and `pruningtypes` and remove `storetypes`:
|
|
|
|
```go
|
|
// testutil/network/network.go
|
|
|
|
package network
|
|
|
|
// ...
|
|
|
|
import (
|
|
pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
|
|
"github.com/stretchr/testify/require"
|
|
// storetypes "github.com/cosmos/cosmos-sdk/store/types" <-- remove this line
|
|
)
|
|
```
|
|
|
|
In the `DefaultConfig` function replace `storetypes.NewPruningOptionsFromString`
|
|
with `pruningtypes.NewPruningOptionsFromString`
|
|
|
|
```go
|
|
// testutil/network/network.go
|
|
|
|
package network
|
|
|
|
// ...
|
|
|
|
func DefaultConfig() network.Config {
|
|
//...
|
|
return network.Config{
|
|
AppConstructor: func(val network.Validator) servertypes.Application {
|
|
return app.New(
|
|
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)),
|
|
//...
|
|
)
|
|
},
|
|
//...
|
|
}
|
|
}
|
|
```
|
|
|
|
The `New` function in the Cosmos SDK `testutil/network` package now
|
|
accepts [three arguments](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/testutil/network/network.go#L206) instead of
|
|
two.
|
|
|
|
In the `New` function add `t.TempDir()` as the second argument to `network.New()` and test that no error is thrown
|
|
with `require.NoError(t, err)`:
|
|
|
|
```go
|
|
// testutil/network/network.go
|
|
|
|
package network
|
|
|
|
// ...
|
|
|
|
func New(t *testing.T, configs ...network.Config) *network.Network {
|
|
//...
|
|
net, err := network.New(t, t.TempDir(), cfg)
|
|
require.NoError(t, err)
|
|
//...
|
|
}
|
|
```
|
|
|
|
### Testutil keeper package
|
|
|
|
In the `{moduleName}Keeper` function make the following replacements:
|
|
|
|
- `storetypes.StoreKey` → `types.StoreKey`
|
|
- `storetypes.MemStoreKey` → `types.MemStoreKey`
|
|
- `sdk.StoreTypeIAVL` → `storetypes.StoreTypeIAVL`
|
|
- `sdk.StoreTypeMemory` → `storetypes.StoreTypeMemory`
|
|
|
|
```go
|
|
// testutil/keeper/{moduleName}.go
|
|
|
|
package keeper
|
|
|
|
// ...
|
|
|
|
func {moduleName}Keeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
|
storeKey := sdk.NewKVStoreKey(types.StoreKey)
|
|
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)
|
|
//...
|
|
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
|
|
stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil)
|
|
//...
|
|
}
|
|
```
|
|
|
|
### IBC modules
|
|
|
|
If you have IBC-enabled modules (for example, added with `ignite scaffold module ... --ibc` or created manually), make
|
|
the following changes to the source code.
|
|
|
|
Cosmos SDK expects IBC modules
|
|
to [implement the `IBCModule` interface](https://ibc.cosmos.network/main/ibc/apps/ibcmodule/). Create a `IBCModule`
|
|
type that embeds the module's keeper and a method that returns a new `IBCModule`. Methods in this file will be defined
|
|
on this type.
|
|
|
|
```go
|
|
// x/{moduleName}/module_ibc.go
|
|
|
|
package module_name
|
|
|
|
// ...
|
|
|
|
type IBCModule struct {
|
|
keeper keeper.Keeper
|
|
}
|
|
|
|
func NewIBCModule(k keeper.Keeper) IBCModule {
|
|
return IBCModule{
|
|
keeper: k,
|
|
}
|
|
}
|
|
```
|
|
|
|
Replace receivers for all methods in this file from `(am AppModule)` to `(im IBCModule)`. Replace all instances of `am.`
|
|
with `im.` to fix the errors.
|
|
|
|
`OnChanOpenInit` now returns to values: a `string` and an `error`:
|
|
|
|
```go
|
|
// x/{moduleName}/module_ibc.go
|
|
|
|
package module_name
|
|
|
|
// ...
|
|
|
|
func (im IBCModule) OnChanOpenInit( /*...*/ ) (string, error)
|
|
```
|
|
|
|
Ensure that all return statements (five, in the default template) in `OnChanOpenInit` return two values. For example:
|
|
|
|
```go
|
|
// x/{moduleName}/module_ibc.go
|
|
|
|
package module_name
|
|
|
|
// ...
|
|
|
|
func (im IBCModule) OnChanOpenInit( /*...*/ ) (string, error) {
|
|
//...
|
|
return "", errorsmod.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort)
|
|
//...
|
|
}
|
|
```
|
|
|
|
Error acknowledgments returned from Transfer `OnRecvPacket` now include a deterministic ABCI code and error message.
|
|
Remove the `.Error()` call:
|
|
|
|
```go
|
|
// x/{moduleName}/module_ibc.go
|
|
|
|
package module_name
|
|
|
|
// ...
|
|
|
|
func (im IBCModule) OnRecvPacket( /*...*/ ) {
|
|
//...
|
|
if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil {
|
|
// return channeltypes.NewErrorAcknowledgement(errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error()).Error())
|
|
return channeltypes.NewErrorAcknowledgement(errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error()))
|
|
}
|
|
|
|
// ...
|
|
|
|
// Dispatch packet
|
|
switch packet := modulePacketData.Packet.(type) {
|
|
// ...
|
|
default:
|
|
// errMsg := fmt.Sprintf("unrecognized %s packet type: %T", types.ModuleName, packet)
|
|
// return channeltypes.NewErrorAcknowledgement(errMsg)
|
|
err := fmt.Errorf("unrecognized %s packet type: %T", types.ModuleName, packet)
|
|
return channeltypes.NewErrorAcknowledgement(err)
|
|
}
|
|
}
|
|
```
|
|
|
|
After switching to using both `AppModule` and `IBCModule`, modifying the following line:
|
|
|
|
```go
|
|
// x/{moduleName}/module.go
|
|
|
|
package module_name
|
|
|
|
// ...
|
|
|
|
var (
|
|
//...
|
|
_ porttypes.IBCModule = IBCModule{} // instead of "= AppModule{}"
|
|
)
|
|
```
|
|
|
|
### Main
|
|
|
|
The `Execute` function in Cosmos SDK `server/cmd` package now
|
|
accepts [three arguments](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/server/cmd/execute.go#L20) instead of two.
|
|
|
|
```go
|
|
// cmd/{{projectName}}d/main.go
|
|
|
|
package projectNamed
|
|
|
|
// ...
|
|
|
|
func main() {
|
|
//...
|
|
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
```
|
|
|
|
### Handler
|
|
|
|
Cosmos SDK v0.46 no longer needs a `NewHandler` function that was used to handle messages and call appropriate keeper
|
|
methods based on message types. Feel free to remove `x/{moduleName}/handler.go` file.
|
|
|
|
Since there is no `NewHandler` now, modify the deprecated `Route` function to return `sdk.Route{}`:
|
|
|
|
```go
|
|
// x/{moduleName}/module.go
|
|
|
|
package module_name
|
|
|
|
// ...
|
|
|
|
func (am AppModule) Route() sdk.Route { return sdk.Route{} }
|
|
```
|