IBC core protocol
The IBC core module is the trust and state layer for cross-chain communication in a Cosmos SDK chain. It tracks remote-chain views, authenticates connection paths, controls application channels, and records packet progress so relayers can move data without direct trust between the two chains.
Protocol model
Core IBC links local application state to a remote chain through verified state. A client tracks the remote chain. A connection authenticates the two chain ends. A channel binds applications on those ends. Packet commitments and acknowledgements then prove delivery, completion, or timeout.
The main protocol objects have distinct roles:
| Object | Role in cross-chain trust |
|---|---|
| Client | Maintains a verified view of the remote chain and checks proofs against that view. |
| Connection | Binds two clients and records the delay rules for later proof checks. |
| Channel | Binds application ports across an open connection and defines packet ordering. |
| Packet state | Records sends, receipts, acknowledgements, and timeouts. |
| Host state | Gives protocol objects stable paths that can appear in proofs. |
The core keeper joins the client, connection, channel, port, and IBC v2 keepers. The ibc application module exposes their message and query services as one Cosmos SDK module. See Client lifecycle, Connection handshake, Channel and packet lifecycle, and Core state and keeper for focused views.
References: modules/…/keeper.go• L25-69 modules/…/module.go• L123-153 modules/…/genesis.go• L17-52
Client verification
The client layer is the root of IBC trust. Core IBC routes a client identifier to its light client module. That module creates the initial remote-chain view, checks updates, detects misbehaviour, reports status, and verifies membership or non-membership proofs.
Client use follows these rules:
- A client must use an allowed and registered client type.
- A new client must be active before later protocol objects can use it.
- An update is checked before it changes the stored remote-chain view.
- Detected misbehaviour can freeze the client and stop later proof use.
- Upgrade and recovery operations require proofs or authority checks that preserve the client’s trust boundary.
IBC v2 adds counterparty metadata and optional relayer access rules to the client state. A counterparty is registered by the same signer that created the client. An empty relayer list keeps packet relay permissionless; a non-empty list limits relay messages for that client.
The chain also uses the client begin-block process for scheduled IBC software upgrades. It records the final trusted consensus data before the chain upgrade so the next chain version can continue client verification.
References: modules/…/client.go• L15-164 modules/…/keeper.go• L61-90 modules/…/abci.go• L13-35 modules/…/keeper.go• L29-66 modules/…/config.go• L21-41
Connection authentication
A connection is the authenticated link between two chain ends. Each end names the client for the other chain, stores counterparty details, selects a compatible version, and records a delay period. The handshake moves both ends from INIT or TRYOPEN to OPEN only after each side proves the state of the other.
The proof checks use the client’s remote-chain view. Core IBC builds the expected counterparty connection and verifies it at a supplied height. This makes the connection the trust link used by later channel and packet proofs. See Connection handshake for the full state flow.
References: modules/…/handshake.go• L17-116 modules/…/handshake.go• L119-225 modules/…/verify.go• L19-49
Channel and packet processing
A classic IBC channel is the application path over an open connection. Its port names the local application, its counterparty names the remote application, and its ordering mode controls receive and acknowledgement progress. Core IBC checks the connection and proof state, then calls the application at the points where application policy must approve or handle the event.
The classic packet lifecycle moves through these stages:
- An application sends data through the ICS4 boundary.
- Core IBC assigns a sequence and stores a packet commitment.
- A relayer submits a proof of that commitment to the receiving chain.
- Core IBC checks timeout, counterparty, replay, and ordering rules.
- The receiving application handles the packet and writes an acknowledgement.
- The sending chain proves the acknowledgement or proves that the packet was not received before timeout.
- Core IBC clears the packet commitment after acknowledgement or timeout.
This diagram shows how verified packet state controls application callbacks and cleanup.
flowchart LR
A[Application sends] --> B[Store commitment]
B --> C[Relayer submits proof]
C --> D[Verify packet state]
D --> E[Application receives]
E --> F[Store acknowledgement]
F --> G[Verify acknowledgement]
G --> H[Clear commitment]
D --> I[Verify timeout]
I --> H
IBC v2 uses client identifiers as packet endpoints and supports several payloads in one packet. It keeps the same trust pattern: the sender commits to packet data, the receiver proves that commitment, and the sender later proves an acknowledgement or receipt absence. Its packet path also supports asynchronous acknowledgements and can restrict relay messages through client configuration.
Cached execution separates protocol state from application state when a receive callback returns an unsuccessful acknowledgement. Redundant receive, acknowledgement, and timeout relays return a no-op instead of applying the same packet transition twice.
See Channel and packet lifecycle for channel handshakes, packet states, ordering, timeout, and acknowledgement details.
References: modules/…/msg_server.go• L212-355 modules/…/msg_server.go• L412-622 modules/…/packet.go• L19-107 modules/…/packet.go• L110-263 modules/…/packet.go• L266-462 modules/…/packet.go• L21-103 modules/…/packet.go• L105-397 modules/…/msg_server.go• L22-151
Commitment proofs and host state
The host layer defines the state names that make IBC objects provable. Client state uses client-scoped paths. Connections use connection paths. Channels and packet records use port, channel, and sequence parts. The commitment layer adds the chain’s store prefix and checks the resulting path against the client’s trusted root.
The important packet records are:
| Record | Protocol purpose |
|---|---|
| Next send sequence | Assigns the next packet number on a sending endpoint. |
| Next receive sequence | Enforces order on ordered channels. |
| Next acknowledgement sequence | Enforces acknowledgement order on ordered channels. |
| Packet commitment | Proves that the sender committed to packet data. |
| Packet receipt | Proves receipt on an unordered endpoint. |
| Packet acknowledgement | Proves the receiver’s result. |
| Receive start sequence | Rejects proofs for packets from an older channel lifecycle. |
Classic IBC uses port and channel paths. IBC v2 uses compact client-based packet paths with separate commitment, receipt, acknowledgement, and send-sequence keys. These path formats are protocol contracts because the counterparty constructs proofs from them.
Core IBC uses membership proofs for committed state and non-membership proofs for receipt absence. Packet proofs include the connection delay rules. Handshake proofs do not apply packet delay checks because they authenticate setup state rather than packet state. See Core state and keeper for the state and keeper view.
References: modules/…/client_keys.go• L11-53 modules/…/connection_keys.go• L7-20 modules/…/channel_keys.go• L7-22 modules/…/packet_keys.go• L7-71 modules/…/packet_keys.go• L11-57 modules/…/merkle.go• L68-105 modules/…/merkle.go• L107-142 modules/…/verify.go• L52-213
Application boundary
Core IBC owns proof checks, protocol state, sequence rules, timeout rules, and replay protection. An IBC application owns the meaning of packet data and the business state changes that follow a packet.
The boundary has two directions:
- Core IBC calls application callbacks for channel handshakes, packet receipt, acknowledgements, and timeouts.
- Applications send packets and write acknowledgements through the ICS4 wrapper so middleware can inspect or change those operations.
The classic port router maps a port to one application callback set. The v2 router maps a port or port prefix to its callback set. Both routers reject ambiguous routes. A missing route stops the protocol before an application callback runs.
This separation lets core IBC verify cross-chain facts without knowing the business meaning of a packet. Middleware remains part of the application-facing path rather than bypassing the core protocol.
References: modules/…/module.go• L13-153 modules/…/router.go• L13-80 modules/…/router.go• L13-130 modules/…/msg_server.go• L218-242 modules/…/msg_server.go• L38-45
Cosmos SDK integration
The Cosmos SDK application installs core IBC as the ibc module. The module registers classic and v2 message and query services, validates one combined genesis state, and initializes or exports the client, connection, channel, and v2 state groups together.
The core keeper requires the chain codec, store service, upgrade keeper, and a non-empty authority. It creates the related keepers as one coordination point. The application must set the classic and v2 routers before traffic uses them.
Authority controls protocol parameter changes and protected operations such as client recovery and IBC software upgrades. Client updates can also use the per-client v2 relayer policy. Module migrations preserve state across the current consensus version and register client and channel migrations with the SDK module configurator.
References: modules/…/module.go• L72-106 modules/…/module.go• L141-198 modules/…/keeper.go• L39-95 modules/…/genesis.go• L17-35 modules/…/genesis.go• L17-52
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to client status, height, timestamp, or proof interfaces affect connection, channel, classic packet, v2 packet, acknowledgement, and timeout verification.
- Changes to client counterparty metadata or relayer policy must stay aligned with client creation, registration, v2 packet routing, and all v2 relay messages.
- Changes to host paths must stay aligned with commitment path construction and with the state written on both classic and v2 packet paths.
- Changes to sequence, receipt, acknowledgement, timeout, or receive-start rules must preserve ordered and unordered progress and channel-upgrade replay protection.
- Changes to port routers or ICS4 contracts must preserve both core-to-application callbacks and application-to-core packet and acknowledgement calls.
- Changes to combined genesis or migrations must preserve validation and import or export behavior for classic clients, v2 client data, connections, classic channels, and v2 packet state.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A client is inactive, unauthorized, or has no usable height | Setup, packet send, and proof checks stop | Client status and trusted-height checks gate those actions |
| A client type is not allowed or has no registered light client route | Client creation or proof verification fails | Client parameters and the client router validate the type before use |
| A connection or channel is not open | Packet receive, acknowledgement, or timeout processing stops | Packet paths check the local channel and connection state |
| A proof uses a wrong height, prefix, or host path | The remote state cannot be authenticated | Core IBC builds the path from counterparty data and checks it against the client root |
| A packet is replayed or arrives out of order | Relay work is rejected or treated as a no-op | Receipts, receive and acknowledgement sequences, and receive-start sequences protect progress |
| A packet timeout is already reached or cannot be represented by the client view | The packet is rejected or cannot time out safely | Send and timeout paths compare timeout data with current or trusted client time and height |
| A v2 relay signer is not allowed by client configuration | The v2 relay message is rejected | The client’s empty-or-allowlisted relayer policy is checked before processing |
| An application route is missing or a callback rejects the event | Channel or packet processing stops before the expected application result | The router must contain a valid callback route and the callback must accept the event |
| An acknowledgement is empty, duplicated, or does not match the packet | Packet completion fails and the sender commitment remains | Acknowledgement validation, commitment comparison, and duplicate checks run before cleanup |
Key files
| File | Why to read it |
|---|---|
| modules/…/module.go | Shows how core IBC joins the Cosmos SDK application and exposes classic and v2 services. |
| modules/…/keeper.go | Shows the keeper relationships and the authority and router boundaries. |
| modules/…/msg_server.go | Shows how messages combine protocol checks, application callbacks, and state changes. |
| modules/…/client.go | Shows the client lifecycle and the trust boundary for remote-chain proofs. |
| modules/…/keeper.go | Shows client routing, status checks, proof forwarding, and client-scoped state. |
| modules/…/keeper.go | Shows v2 counterparty and relayer policy data linked to clients. |
| modules/…/handshake.go | Shows the authenticated connection state flow. |
| modules/…/verify.go | Shows how client proofs authenticate connection, channel, and packet state. |
| modules/…/packet.go | Shows classic commitments, replay protection, acknowledgements, and cleanup. |
| modules/…/packet.go | Shows v2 packet commitments, receipts, acknowledgements, timeouts, and client-based paths. |
| modules/…/module.go | Defines the application callback and ICS4 packet boundary. |
| modules/…/packet_keys.go | Defines classic packet state paths used by proofs. |
| modules/…/packet_keys.go | Defines v2 packet state paths used by proofs. |
| modules/…/merkle.go | Shows the membership and non-membership proof model. |
| modules/…/genesis.go | Shows how core state is initialized and exported as one module state. |