How Cosmos’s IBC Works to Achieve Interoperability Between Blockchains

IBC Overview

IBC is a protocol for interoperability between different ledgers. It is being designed and implemented as a core component of the Cosmos network, where multiple tendermint based or non-tendermint based ledgers connect to each other. Theoretically, any blockchains can connect to and communicate with each other via IBC. IBC is standardized as the Inter-chain standard (ICS) at https://github.com/cosmos/ibc.

IBC Architecture

IBC is a layered protocol that consists of the following two layers:

  • the upper application layers built on top of TAO (IBC/APP)

IBC/TAO

IBC/TAO is a layer for relaying packets between two blockchains in a reliable, ordered and authenticated manner.

  • Connection abstraction
  • Channel abstraction

On-Chain Light Client

Syntax and semantics of on-chain light clients in IBC/TAO are standardized in ICS-2. The following is an overview of this component.
Whenever a new block header is appended to an opposite blockchain, a relayer queries for the header and submits it to the IBC/TAO module on a local blockchain. Then the IBC/TAO module executes the light client protocol according to the opposite blockchain to check whether the block header is valid or not and updates its *ClientState* mirroring the opposite blockchain only if the block header is valid.

Connection abstraction

Syntax and semantics of connections in IBC/TAO are specified in ICS-3. Basically, a “connection” in the context of IBC represents a connected pair of two *ClientState*’s on different blockchains. Before starting to relay packets using “channel” abstraction described later, the IBC/TAO modules on both blockchains need to determine and authenticate *ClientState* to communicate with. The connection abstraction is used for this purpose. A connection between blockchains is established through a mechanism like the 3-way handshake of TCP.

Connection Handshake

Connection states transition as follows. All the operations are kicked by transactions sent by relayers.

  1. (connOpenTry) A new connection in TRYOPEN status is created and stored on an opposite blockchain if it is verified that the connection in INIT status was created on the initiating chain.
  2. (connOpenAck) The state of the connection is updated from INIT to OPEN on the initiating chain if it is verified that the connection in TRYOPEN status was created on the opposite chain.
  3. (connOpenConfirm) The state of the connection is updated from TRYOPEN to OPEN on the opposite chain if it is verified that the state of the connection transitioned from INIT to OPEN on the initiating chain.

Channel abstraction

Syntax and semantics of channels in IBC/TAO are specified in ICS-4. Channel abstraction in IBC is used to represent a connected pair of two smart contracts on different blockchains. A channel is established through the handshake mechanism that is almost the same as connection abstraction. Once established, the channel can relay packets repeatedly between the blockchains. The packet relay itself is also done by a 3-way handshake mechanism similar to that of TCP.

Channel handshake

Channel states transition as follows. All the operations are kicked by transactions sent by elayers.

  1. (chanOpenTry) A new channel in TRYOPEN status is created and stored on an opposite blockchain if it is verified that the channel in INIT status was created on the initiating chain.
  2. (chanOpenAck) The state of the channel is updated from INIT to OPEN on the initiating chain if it is verified that the channel in TRYOPEN status was created on the opposite chain.
  3. (chanOpenConfirm) The state of the channel is updated from TRYOPEN to OPEN on the opposite chain if it is verified that the state of the channel transitioned from INIT to OPEN on the initiating chain.

Relaying Packets

With an established channel, two smart contracts can transmit and receive packets (=arbitrary bytes sequences) as follows.

  1. (recvPacket) A new packet with sequence number N is created and stored in a destination chain if it is verified that the source chain exactly sent (created) the packet.
  2. (acknowledgePacket) The packet with sequence number N is deleted.

IBC/APP

The single and simple mechanism for relaying packets (IBC/TAO) enables arbitrary cross-chain protocols. Application protocols built on top of IBC/TAO are called IBC/APP collectively.

Example: Cross-chain token transfer

ICS-20 is a good example of IBC/APP protocols, which enables cross-chain token transfer. There is no need for IBC/APP implementers to design or implement entire blockchain interoperability mechanisms. They only need to implement plugins called along with *sendPacket*, *recvPacket* and *acknowledgePacket*.

  1. ChainB executes the following operations atomically:
    ▹ Executing *recvPacket* operation for the packet
    Then minting voucher tokens that is equivalent to the locked tokens in the ICS-20 module
  2. ChainA executes *acknowledgePacket* as normal.
  1. ChainA executes the following operation atomically:
    ▹ Executing *recvPacket* operation for the packet
    Then unlocking tokens that is equivalent to the burned vouchers in the ICS-20 module
  2. ChainB executes *acknowledgePacket* as normal.
  • Minting and burning vouchers

Final Thoughts

Since Bitcoin was invented, many different paradigms of blockchains have been proposed and various blockchain platforms are being operated today. Especially in the context of enterprise blockchains, as different companies and industries have different needs and relationships among them, it is unthinkable that they all run their blockchain applications on the same unified blockchain platform. Interoperability is already and will be more and more important technology in this industry.

Useful Links

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Datachain

Datachain

Core Contributor of LCP and Hyperledger Lab YUI, cross-chain interoperability solutions using the IBC protocol. https://twitter.com/datachain_en