本指南提供了迁移到新版本 ibc-go 的说明。 注意: ibc-go 遵循 golang 语义化版本规范,因此在主版本发布时,所有导入都必须更新。 以下是在整体变更列表之后展示的 diff 示例:
  • 各链需要从所有 Keeper 构造函数调用中移除 ParamSubspace 参数
  app.IBCKeeper = ibckeeper.NewKeeper(
    appCodec,
    runtime.NewKVStoreService(keys[ibcexported.StoreKey]),
-   app.GetSubspace(ibcexported.ModuleName),
    app.UpgradeKeeper,
    authtypes.NewModuleAddress(govtypes.ModuleName).String(),
  )
transfer 模块、packet forward middleware 以及 rate limiting middleware 支持自定义地址编码器。此特性主要是为了支持 Cosmos EVM 的 IBC 转账。在标准的 Cosmos SDK 应用中,其接线方式如下:
  app.TransferKeeper = ibctransferkeeper.NewKeeper(
    appCodec,
+    app.AccountKeeper.AddressCodec(),
    runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]),
    app.IBCKeeper.ChannelKeeper,
    app.MsgServiceRouter(),
    app.AccountKeeper, app.BankKeeper,
    authtypes.NewModuleAddress(govtypes.ModuleName).String(),
  )
  app.RateLimitKeeper = ratelimitkeeper.NewKeeper(
    appCodec,
+    app.AccountKeeper.AddressCodec(),
    runtime.NewKVStoreService(keys[ratelimittypes.StoreKey]),
    app.IBCKeeper.ChannelKeeper,
    app.IBCKeeper.ClientKeeper,
    app.BankKeeper,
    authtypes.NewModuleAddress(govtypes.ModuleName).String()
  )
  app.PFMKeeper = packetforwardkeeper.NewKeeper(
    appCodec,
+    app.AccountKeeper.AddressCodec(),
    runtime.NewKVStoreService(keys[packetforwardtypes.StoreKey]),
    app.TransferKeeper,
    app.IBCKeeper.ChannelKeeper,
    app.BankKeeper,
    authtypes.NewModuleAddress(govtypes.ModuleName).String()
  )

ICS27-GMP

ICS27 General Message Passing(GMP)已作为 ibc-go 支持的 IBC 应用加入。它没有任何参数。

为 ICS27-GMP 模块添加 StoreUpgrades

对于 ICS27-GMP,还需要为新的 GMP 模块手动添加 store upgrades,然后在 app.go 中配置 store loader 以应用这些升级:
if upgradeInfo.Name == "v11" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
  storeUpgrades := store.StoreUpgrades{
    Added: []string{gmptypes.StoreKey},
  }

  app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
这可以确保在迁移开始之前,将新模块的 store 添加到 multistore 中。 如果某条链选择不集成 GMP 模块,则无需在 Added 字段中添加 GMP key。
This guide provides instructions for migrating to a new version of ibc-go. Note: ibc-go supports golang semantic versioning and therefore all imports must be updated on major version releases. Diff examples are shown after the list of overall changes:
  • Chains will need to remove the ParamSubspace arg from all calls to Keeper constructors
  app.IBCKeeper = ibckeeper.NewKeeper(
    appCodec,
    runtime.NewKVStoreService(keys[ibcexported.StoreKey]),
-   app.GetSubspace(ibcexported.ModuleName),
    app.UpgradeKeeper,
    authtypes.NewModuleAddress(govtypes.ModuleName).String(),
  )
The transfer module, the packet forward middleware, and the rate limiting middleware support custom address codecs. This feature is primarily added to support Cosmos EVM for IBC transfers. In a standard Cosmos SDK app, they are wired as follows:
  app.TransferKeeper = ibctransferkeeper.NewKeeper(
    appCodec,
+    app.AccountKeeper.AddressCodec(),
    runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]),
    app.IBCKeeper.ChannelKeeper,
    app.MsgServiceRouter(),
    app.AccountKeeper, app.BankKeeper,
    authtypes.NewModuleAddress(govtypes.ModuleName).String(),
  )
  app.RateLimitKeeper = ratelimitkeeper.NewKeeper(
    appCodec,
+    app.AccountKeeper.AddressCodec(),
    runtime.NewKVStoreService(keys[ratelimittypes.StoreKey]),
    app.IBCKeeper.ChannelKeeper,
    app.IBCKeeper.ClientKeeper,
    app.BankKeeper,
    authtypes.NewModuleAddress(govtypes.ModuleName).String()
  )
  app.PFMKeeper = packetforwardkeeper.NewKeeper(
    appCodec,
+    app.AccountKeeper.AddressCodec(),
    runtime.NewKVStoreService(keys[packetforwardtypes.StoreKey]),
    app.TransferKeeper,
    app.IBCKeeper.ChannelKeeper,
    app.BankKeeper,
    authtypes.NewModuleAddress(govtypes.ModuleName).String()
  )

ICS27-GMP

ICS27 General Message Passing (GMP) has been added as a supported IBC application of ibc-go. It has no parameters.

Add StoreUpgrades for ICS27-GMP module

For ICS27-GMP it is also necessary to manually add store upgrades for the new GMP module and then configure the store loader to apply those upgrades in app.go:
if upgradeInfo.Name == "v11" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
  storeUpgrades := store.StoreUpgrades{
    Added: []string{gmptypes.StoreKey},
  }

  app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
This ensures that the new module’s stores are added to the multistore before the migrations begin. If a chain chooses not to integrate the GMP module, it does not need to add the GMP key to the Added field.