Migrating from v8 to v9
This guide provides instructions for migrating to a new version of ibc-go.
There are four sections based on the four potential user groups of this document:
Note: ibc-go supports golang semantic versioning and therefore all imports must be updated on major version releases.
Chains
Chains will need to remove the route for the legacy proposal handler for 02-client from their app/app.go:
// app.go
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
- AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
- AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
+ AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper))
IBC core
- Because the self client and consensus state validation has been removed from the connection handshake (see section Removal of self client and consensus state from connection handshake for more details), the IBC core keeper does not need the staking keeper anymore to introspect the (self) past historical info at a given height and construct the expected consensus state at that height. Thus, the signature of IBC core keeper constructor function
NewKeeperhas been updated:
func NewKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace types.ParamSubspace,
- stakingKeeper clienttypes.StakingKeeper,
upgradeKeeper clienttypes.UpgradeKeeper,
scopedKeeper capabilitykeeper.ScopedKeeper, authority string,
) *Keeper
API removals
- The
exported.ChannelIandexported.CounterpartyChannelIinterfaces have been removed. Please use the concrete types. - The
exported.ConnectionIandexported.CounterpartyConnectionIinterfaces have been removed. Please use the concrete types. - The
Routerreference has been removed from the IBC core keeper in #6138. Please usePortKeeper.Routerinstead. - The composite interface
QueryServerhas been removed from packagecore/types. Please use the granularQueryServerinterfaces for IBC submodules directly. - The
TypeClientMisbehaviourconstant has been removed. - The function
SetConsensusHosthas been removed because the self client and consensus state validation has been removed from the connection handshake. See section Removal of self client and consensus state from connection handshake for more details.
02-client
- The
QueryVerifyMembershipRequestprotobuf message has been modified to includecommitment.v2.MerklePath. The deprecatedcommitment.v1.MerklePathfield has beenreserved. See 23-commitment. - The function
CreateLocalhostClienthas been removed. The localhost client is now stateless. - The function
NewClientProposalHandlerhas been removed in #6777. - The deprecated
ClientUpdateProposalandUpgradeProposalmessages have been removed in #6782. Please useMsgRecoverClientandMsgIBCSoftwareUpgraderespectively instead. - Because the self client and consensus state validation has been removed from the connection handshake (see section Removal of self client and consensus state from connection handshake for more details):
- The ConsensusHost interface has been removed.
- The function
SetConsensusHosthas been removed. - The functions
GetSelfConsensusStateandValidateSelfClienthave been removed.
03-connection
- The functions
GetState(),GetClientID(),GetCounterparty(),GetVersions(), andGetDelayPeriod()of theConnectiontype have been removed. Please access the fields directly. - The functions
GetClientID(),GetConnectionID(), andGetPrefix()of theCounterpartytype have been removed. Please access the fields directly.
Removal of self client and consensus state from connection handshake
The ConnectionOpenTry and ConnectionOpenAck handlers no longer validate that the light client on counterparty chain has a valid representation of the executing chain's consensus protocol (please see #1128 in cosmos/ibc repository for an exhaustive explanation of the reasoning).
- The fields
client_state,proof_client,proof_consensus,consensus_heightandhost_consensus_state_proofofMsgConnectionOpenTryandMsgConnectionOpenAckhave been deprecated, and the signature of the constructor functionsNewMsgConnectionOpenTryandNewMsgConnectionOpenTryhas been accordingly updated:
func NewMsgConnectionOpenTry(
clientID, counterpartyConnectionID, counterpartyClientID string,
- counterpartyClient exported.ClientState,
counterpartyPrefix commitmenttypes.MerklePrefix,
counterpartyVersions []*Version, delayPeriod uint64,
initProof []byte,
- clientProof []byte,
- consensusProof []byte,
proofHeight lienttypes.Height,
- consensusHeight clienttypes.Height,
signer string,
) *MsgConnectionOpenTry
func NewMsgConnectionOpenAck(
connectionID, counterpartyConnectionID string,
- counterpartyClient exported.ClientState,
tryProof []byte,
- clientProof []byte,
- consensusProof []byte,
proofHeight clienttypes.Height,
- consensusHeight clienttypes.Height,
version *Version,
signer string,
) *MsgConnectionOpenAck
- The functions
VerifyClientStateandVerifyClientConsensusStatehave been removed. - The function
UnpackInterfaceshas been removed.
04-channel
- The utility function
QueryLatestConsensusStateof the CLI has been removed. - The functions
GetState(),GetOrdering(),GetCounterparty(),GetConnectionHops(),GetVersion()of theChanneltype have been removed. Please access the fields directly. - The functions
IsOpen()andIsClosed()of theChanneltype have been removed. - The functions
GetPortID(),GetChannelID()of theCounterpartyChanneltype have been removed. - Functions
ChanCloseConfirmWithCounterpartyUpgradeSequenceandTimeoutOnCloseWithCounterpartyUpgradeSequencehave been removed. Please useChanCloseConfirmandTimeoutOnClosewith the updated signature that takes the counterparty upgrade sequence as extra argument:
func (k *Keeper) ChanCloseConfirm(
ctx sdk.Context,
portID,
channelID string,
chanCap *capabilitytypes.Capability,
initProof []byte,
proofHeight exported.Height,
+ counterpartyUpgradeSequence uint64,
)
func (k *Keeper) TimeoutOnClose(
ctx sdk.Context,
chanCap *capabilitytypes.Capability,
packet types.Packet,
proof,
closedProof []byte,
proofHeight exported.Height,
nextSequenceRecv uint64,
+ counterpartyUpgradeSequence uint64,
)
- The keeper handlers
RecvPacket,AcknowledgePacket,TimeoutPacketandTimeoutOnClosenow return the channel version, which the message server passes to the packet lifecycle application callbacks (OnRecvPacket,OnAcknowledgementPacketandOnTimeoutPacket). The channel version is useful when adding backwards compatible features to an existing application implementation (for example: in the context of ICS20 v2, middleware and the transfer application may use the channel version to unmarshal the packet differently depending on the channel version).
func (k *Keeper) RecvPacket(
ctx sdk.Context,
chanCap *capabilitytypes.Capability,
packet types.Packet,
proof []byte,
proofHeight exported.Height,
- ) error {
+ ) (string, error) {
func (k *Keeper) AcknowledgePacket(
ctx sdk.Context,
chanCap *capabilitytypes.Capability,
packet types.Packet,
acknowledgement []byte,
proof []byte,
proofHeight exported.Height,
- ) error {
+ ) (string, error) {
func (k *Keeper) TimeoutPacket(
ctx sdk.Context,
packet types.Packet,
proof []byte,
proofHeight exported.Height,
nextSequenceRecv uint64,
- ) error {
+ ) (string, error) {
func (k *Keeper) TimeoutOnClose(
ctx sdk.Context,
chanCap *capabilitytypes.Capability,
packet types.Packet,
proof,
closedProof []byte,
proofHeight exported.Height,
nextSequenceRecv uint64,
counterpartyUpgradeSequence uint64,
- ) error {
+ ) (string, error) {
OnRecvPacket func(
ctx sdk.Context,
+ channelVersion string,
packet channeltypes.Packet,
relayer sdk.AccAddress,
) exported.Acknowledgement
OnAcknowledgementPacket func(
ctx sdk.Context,
+ channelVersion string,
packet channeltypes.Packet,
acknowledgement []byte,
relayer sdk.AccAddress,
) error
OnTimeoutPacket func(
ctx sdk.Context,
+ channelVersion string,
packet channeltypes.Packet,
relayer sdk.AccAddress,
) error
05-port
- The signature of the
UnmarshalPacketDatafunction of thePacketDataUnmarshalerinterface takes now extra arguments for the context and the port and channel identifiers. These parameters have been added so that implementations of the interface function can retrieve the channel version, which allows the provided packet data to be unmarshaled based on the channel version. In addition to these,UnmarshalPacketDatanow also returns the underlying application's version:
type PacketDataUnmarshaler interface {
UnmarshalPacketData(
+ ctx sdk.Context,
+ portID,
+ channelID string,
bz []byte,
+ ) (interface{}, string, error)
}
23-commitment
- The
exported.Proofinterface has been removed. Please use theMerkleProofconcrete type. - The
MerklePathtype has been deprecated and a newcommitment.v2.MerklePathtype has been introduced in #6644. The newcommitment.v2.MerklePathcontainsrepeated bytesin favour ofrepeated string. This allows users to prove values stored under keys which contain non-utf8 encoded symbols. As a result, changes have been made to the 02-clientQueryservice and 08-wasm contract API messages for JSON blobs. See 02-client and 08-wasm, respectively. - The
commitment.v1.MerklePathtype has been removed and a newcommitment.v2.MerklePathtype has been introduced in #6644. The newcommitment.v2.MerklePathcontainsrepeated bytesin favour ofrepeated string. This allows users to prove values stored under keys which contain non-utf8 encoded symbols. As a result, changes have been made to the 02-clientQueryservice and 08-wasm contract API messages for JSON blobs. See 02-client and 08-wasm, respectively.
24-host
All functions ending with Path naming have been removed in favour of their sibling function which ends in Key.
IBC Apps
ICS20 - Transfer
ICS20 v2
- With support for multidenom transfer packets and path forwarding, the
NewMsgTransferconstructor function to create a newMsgTransferinstance now accepts multiple coins instead of just one, and an argument with forwarding information:
func NewMsgTransfer(
sourcePort, sourceChannel string,
- token sdk.Coin,
+ tokens sdk.Coins,
sender, receiver string,
timeoutHeight clienttypes.Height, timeoutTimestamp uint64,
memo string,
+ forwarding *Forwarding,
)
- The
ibc_transferandfungible_token_packetevents do not include the attributesdenomandamountanymore; instead they include the attributetokenswith the list of coins transferred in the packet. - A new type for the packet payload has been introduced:
FungibleTokenPacketDataV2. Transfer channels with versionics20-2will use this new type for the payload and it will be encoded using Protobuf (instead of JSON). Middleware that wraps the transfer application and unmarshals the packet data MUST take this into account when upgrading: depending on the channel version, packet data should unmarshal either as JSON (v1) or Protobuf (v2). The helper functionUnmarshalPacketDataencapsulates this logic and can be used by middleware or other applications to correctly unmarshal the packet data:
packetData, err := transfertypes.UnmarshalPacketData(packet.Data, version)
if err != nil {
return err
}
DenomTrace type refactoring
- The
DenomTracetype has been made private and will be completely removed in a later release. Please use theDenomtype instead. - The
DenomTraceandDenomTracesgRPCs have been removed as well (together with the andQueryDenomTraceResponseandQueryDenomTracesResponsetypes). Please use theDenomandDenomsgRPCs instead. - An automatic migration handler is also configured to migrate the storage from using
DenomTracetoDenom. - The
denomination_traceevent emitted in theOnRecvPacketcallback has been replaced with thedenomevent. - The functions
SenderChainIsSourceandReceiverChainIsSourcehave been replaced with the functionHasPrefixof the newly addedDenomtype. - The helper function
GetTransferCoinhas been removed. - The helper function
GetDenomPrefixhas been removed. - The helper function
GetPrefixedDenomhas been removed. Please construct the denom using the newDenomtype.
ICS27 - Interchain Accounts
- In #5785 the list of arguments of the
NewKeeperconstructor function of the host submodule was extended with an extra argument for the gRPC query router that the submodule uses when executing aMsgModuleQuerySafeto perform queries that are module safe:
func NewKeeper(
cdc codec.Codec, key storetypes.StoreKey, legacySubspace icatypes.ParamSubspace,
ics4Wrapper porttypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper,
portKeeper icatypes.PortKeeper, accountKeeper icatypes.AccountKeeper,
scopedKeeper exported.ScopedKeeper, msgRouter icatypes.MessageRouter,
+ queryRouter icatypes.QueryRouter,
authority string,
) Keeper
- The function
RegisterInterchainAccountWithOrderinghas been removed. The legacy functionRegisterInterchainAccountnow takes an extra parameter to specify the ordering of new ICA channels:
func (k Keeper) RegisterInterchainAccount(
ctx sdk.Context,
connectionID, owner,
version string,
+ ordering channeltypes.Order
) error {
- The
requestsrepeated field ofMsgModuleQuerySafehas been marked non-nullable, and therefore the signature of the constructor functionNewMsgModuleQuerySafehas been updated:
func NewMsgModuleQuerySafe(
signer string,
- requests []*QueryRequest,
+ requests []QueryRequest,
) *MsgModuleQuerySafe {
- The signature of the
NewIBCMiddlewareconstructor function in the controller submodule now only takes the controller keeper as an argument. The base application is then set by default to nil and thus authentication is assumed to be done by a Cosmos SDK module, such as thex/gov,x/grouporx/auth, that sends messages to the controller submodule's message server. An authentication module can be set using the newly addedNewIBCMiddlewareWithAuthconstructor function.
func NewIBCMiddleware(
- app porttypes.IBCModule,
k keeper.Keeper,
) IBCMiddleware {
- The
InitModulefunction has been removed. When adding the interchain accounts module to the chain, please set the desired params for controller and host submodules directly after callingRunMigrationsin the upgrade handler. - The
GetBytes()function of theCosmosTxtype has been removed.
Callbacks
The ContractKeeper interface has been extended with the base application version. The base application version will be required by contracts to unmarshal the packet data. An example of this is unmarshaling ICS20 v2 packets which requires knowing the base version of a transfer stack (either v1 or v2).
type ContractKeeper interface {
IBCSendPacketCallback(
cachedCtx sdk.Context,
sourcePort string,
sourceChannel string,
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
packetData []byte,
contractAddress,
packetSenderAddress string,
+ version string,
) error
IBCOnAcknowledgementPacketCallback(
cachedCtx sdk.Context,
packet channeltypes.Packet,
acknowledgement []byte,
relayer sdk.AccAddress,
contractAddress,
packetSenderAddress string,
+ version string,
) error
IBCOnTimeoutPacketCallback(
cachedCtx sdk.Context,
packet channeltypes.Packet,
relayer sdk.AccAddress,
contractAddress,
packetSenderAddress string,
+ version string,
) error
IBCReceivePacketCallback(
cachedCtx sdk.Context,
packet ibcexported.PacketI,
ack ibcexported.Acknowledgement,
contractAddress string,
+ version string,
) error
}
IBC testing package
- In the
TestChainstruct the fieldLastHeaderhas been renamed toLatestCommittedHeader, the fieldCurrentHeaderhas been renamed toProposedHeaderand theQueryServerinterface has been removed.
type TestChain struct {
testing.TB
Coordinator *Coordinator
App TestingApp
ChainID string
- LastHeader *ibctm.Header // header for last block height committed
+ LatestCommittedHeader *ibctm.Header // header for last block height committed
- CurrentHeader cmtproto.Header // header for current block height
+ ProposedHeader cmtproto.Header // proposed (uncommitted) header for current block height
- QueryServer types.QueryServer
TxConfig client.TxConfig
Codec codec.Codec
Vals *cmttypes.ValidatorSet
NextVals *cmttypes.ValidatorSet
// Signers is a map from validator address to the PrivValidator
// The map is converted into an array that is the same order as the validators right before signing commit
// This ensures that signers will always be in correct order even as validator powers change.
// If a test adds a new validator after chain creation, then the signer map must be updated to include
// the new PrivValidator entry.
Signers map[string]cmttypes.PrivValidator
// autogenerated sender private key
SenderPrivKey cryptotypes.PrivKey
SenderAccount sdk.AccountI
SenderAccounts []SenderAccount
// Short-term solution to override the logic of the standard SendMsgs function.
// See issue https://github.com/cosmos/ibc-go/issues/3123 for more information.
SendMsgsOverride func(msgs ...sdk.Msg) (*abci.ExecTxResult, error)
}
Submodule query servers can be constructed directly by passing their associated keeper to the appropriate constructor function. For example:
clientQueryServer := clientkeeper.NewQueryServer(app.IBCKeeper.ClientKeeper)
- The
mock.PVtype has been removed in favour ofcmttypes.MockPVin #5709. - Functions
ConstructUpdateTMClientHeaderandConstructUpdateTMClientHeaderWithTrustedHeightofTestChaintype have been replaced withIBCClientHeaderfunction. This function will construct a 07-tendermint header to update the light client on the counterparty chain. The trusted height must be passed in as a non-zero height. GetValsAtHeighthas been renamed toGetTrustedValidators.AssertEventsLegacyfunction ofibctestingpackage (alias for"github.com/cosmos/ibc-go/v10/testing") has been removed in #6070, andAssertEventsfunction should be used instead.
// testing/events.go
- func AssertEventsLegacy(
- suite *testifysuite.Suite,
- expected EventsMap,
- actual []abci.Event,
- )
func AssertEvents(
suite *testifysuite.Suite,
expected []abci.Event,
actual []abci.Event,
)
- The signature of the function
QueryConnectionHandshakeProofhas changed, since the validation of self client and consensus state has been remove from the connection handshake:
func (endpoint *Endpoint) QueryConnectionHandshakeProof() (
- clientState exported.ClientState, clientProof,
- consensusProof []byte, consensusHeight clienttypes.Height,
connectionProof []byte, proofHeight clienttypes.Height,
)
- The functions
GenerateClientStateProofandGenerateConsensusStateProofhave been removed.
API deprecation notice
- The functions
Setup,SetupClients,SetupConnections,CreateConnections, andCreateChannelsof theCoordinatortype have been deprecated and will be removed in v11. Please use the new functionsSetup,SetupClients,SetupConnections,CreateConnections,CreateChannelsof thePathtype. - The function
SetChannelStateof thePathtype has been deprecated and will be removed in v11. Please use the new functionUpdateChannelof thePathtype.
Relayers
Events
02-client
- The function
CreateClientof the keeper expects now a string for the client type (e.g.07-tendermint) and two[]bytefor the Protobuf-serialized client and consensus states:
func (k *Keeper) CreateClient(
ctx sdk.Context,
+ clientType string,
- clientState exported.ClientState,
- consensusState exported.ConsensusState,
+ clientState []byte,
+ consensusState []byte,
) (string, error)
- The
headerattribute has been removed from theupdate_clientevent in #5110.
04-channel
- The constant
AttributeVersionhas been renamed toAttributeKeyVersion. - The
packet_dataand thepacket_ackattributes of thesend_packet,recv_packetandwrite_acknowledgementevents have been removed in #6023. The attributespacket_data_hexandpacket_ack_hexshould be used instead. The constantsAttributeKeyDataandAttributeKeyAckhave also been removed.
Channel upgrades
- The attributes
version,orderingandconnection_hopsfrom thechannel_upgrade_init,channel_upgrade_try,channel_upgrade_ack,channel_upgrade_open,channel_upgrade_timeoutandchannel_upgrade_cancelledevents have been removed in #6063.
IBC Light Clients
API removals
- The
ExportMetadatainterface function has been removed from theClientStateinterface. Core IBC will export all key/value's within the 02-client store. - The
ZeroCustomFieldsinterface function has been removed from theClientStateinterface. - The following functions have also been removed from the
ClientStateinterface:Initialize,Status,GetLatestHeight,GetTimestampAtHeight,VerifyClientMessage,VerifyMembership,VerifyNonMembership,CheckForMisbehaviour,UpdateState,UpdateStateOnMisbehaviour,CheckSubstituteAndUpdateStateandVerifyUpgradeAndUpdateState. ibc-go v9 decouples routing at the 02-client layer from the light clients' encoding structure (i.e. every light client implementation of theClientStateinterface is not used anymore to route the requests to the right light client at the02-clientlayer, instead a light client module is registered for every light client type and 02-client routes the requests to the right light client module based on the client ID). Light client developers must implement the newly introducedLightClientModuleinterface and are encouraged to move the logic implemented in the functions of their light client's implementation of theClientStateinterface to the equivalent function in theLightClientModuleinterface. The table below shows the equivalence between theClientStateinterface functions that have been removed and the functions in theLightClientModuleinterface:
ClientState interface | LightClientModule interface |
|---|---|
Initialize | Initialize |
Status | Status |
GetLatestHeight | LatestHeight |
GetTimestampAtHeight | TimestampAtHeight |
VerifyClientMessage | VerifyClientMessage |
VerifyMembership | VerifyMembership |
VerifyNonMembership | VerifyNonMembership |
CheckForMisbehaviour | CheckForMisbehaviour |
UpdateState | UpdateState |
UpdateStateOnMisbehaviour | UpdateStateOnMisbehaviour |
CheckSubstituteAndUpdateState | RecoverClient |
VerifyUpgradeAndUpdateState | VerifyUpgradeAndUpdateState |
ExportMetadata | |
ZeroCustomFields |
Please check also the Light client developer guide for more information. The light client module implementation for 07-tendermint may also be useful as reference.
06-solomachine
- The
Initialize,Status,GetTimestampAtHeightandUpdateStateOnMisbehaviourfunctions inClientStatehave been removed and all their logic has been moved to functions of theLightClientModule. TheVerifyMembershipandVerifyNonMembershipfunctions have been made private. - The
Typemethod onMisbehaviourhas been removed.
07-tendermint
- The
IterateConsensusMetadatafunction has been removed. TheInitialize,Status,GetTimestampAtHeight,VerifyMembership,VerifyNonMembershipfunctions have been made private.
08-wasm
Refer to the 08-wasm migration documentation for more information.
09-localhost
The 09-localhost light client has been made stateless and will no longer update the client on every block. The ClientState is constructed on demand when required. The ClientState itself is therefore no longer provable directly with VerifyMembership or VerifyNonMembership.
An automatic migration handler is configured to prune all previously stored client state data on IBC module store migration from ConsensusVersion 6 to 7.