Introducing a new way to review your PRs.

Read the announcement

lfdt-ibc / ibc-go

Inter-Blockchain Communication Protocol (IBC) implementation in Golang.

View on GitHub

20 documents · Updated Nov 13, 2026

docs / connection-handshake

Connection handshake

An IBC connection is a verifiable link between two client records on two chains. The handshake creates one connection end on each chain, proves the remote state at each step, and agrees on the version and delay rules that channel and packet flows use later. See IBC core protocol, client lifecycle and verification, channel and packet lifecycle, and core state and keeper for related systems.

Connection model

The connection module binds two existing IBC clients. Each chain stores one local connection end. The two ends identify each other through client IDs, connection IDs, and the counterparty store prefix.

Connection ends

A connection end is the local record for a cross-chain link. It stores the local client, supported or selected versions, current state, counterparty details, and the delay period used later for packet proof checks. Exactly two connection ends establish one connection between two chains.

The counterparty is the other chain in the link. Its record names the remote client and connection end. Its Merkle prefix tells the local client where that remote chain stores the record. This lets the local chain check remote state without trusting a relayer's claim.

The normal states have these meanings:

StateMeaning
UNINITIALIZEDNo local connection end exists.
INITThe local chain started the handshake.
TRYOPENThe local chain proved the first step from the other chain.
OPENThe local chain proved the completed state on the other chain.

The module also creates a special localhost connection as an already-open local sentinel during genesis. A normal handshake cannot use the localhost client.

References: proto/…/connection.proto• L15-33 proto/…/connection.proto• L55-82 modules/…/msgs.go• L49-72 modules/…/genesis.go• L12-26

Identifiers and paths

Each chain assigns its own connection identifier from a local sequence. In this SDK, normal identifiers use the form connection-{N}. The counterparty connection identifier is empty when Chain A starts the handshake. It becomes known after Chain B creates its connection end.

The module also records the connection paths for each client. This association lets later queries and verification find the client that owns a connection. The connection record itself is stored at the host connection path built from its identifier.

References: modules/…/keys.go• L27-69 modules/…/keeper.go• L54-61 modules/…/keeper.go• L102-127 modules/…/verify.go• L19-32

Handshake sequence

The handshake is a four-step exchange between Chain A and Chain B. A relayer carries messages and proofs between the chains, but each receiving chain checks the claimed remote state through its local client.

The diagram shows how each local record moves toward OPEN and how a proof connects each step to state stored on the other chain.

sequenceDiagram
    participant A as Chain A
    participant R as Relayer
    participant B as Chain B

    A->>A: ConnectionOpenInit
    Note right of A: A end: INIT
    A-->>R: Proof of A connection end
    R->>B: ConnectionOpenTry + proof_init
    B->>B: Verify A end and choose version
    Note right of B: B end: TRYOPEN
    B-->>R: Proof of B connection end
    R->>A: ConnectionOpenAck + proof_try
    A->>A: Verify B end
    Note right of A: A end: OPEN
    A-->>R: Proof of A OPEN end
    R->>B: ConnectionOpenConfirm + proof_ack
    B->>B: Verify A OPEN end
    Note right of B: B end: OPEN

Four-step exchange

The four messages are ordered by the state they prove and update:

  1. Open init on Chain A: An active client starts the attempt. Chain A creates a local connection ID and stores an INIT end. The counterparty connection ID must be empty.
  2. Open try on Chain B: Chain B creates its own connection ID. It proves that Chain A stored the expected INIT end. It selects a compatible version and stores its end as TRYOPEN.
  3. Open acknowledgment on Chain A: Chain A proves that Chain B stored the expected TRYOPEN end. It checks the selected version, records Chain B's connection ID, and changes its end to OPEN.
  4. Open confirmation on Chain B: Chain B proves that Chain A changed its end to OPEN. It then changes its end from TRYOPEN to OPEN.

The connection state model has no separate close state. Channel negotiation can use the relationship only after both ends are OPEN.

References: modules/…/handshake.go• L17-57 modules/…/handshake.go• L60-116 modules/…/handshake.go• L119-177 modules/…/handshake.go• L180-225 proto/…/tx.proto• L37-134

Message checks

Each message checks its input shape before the keeper changes state. The checks cover client and connection IDs, versions, signer addresses, counterparty data, and proof presence where the step needs remote state.

The init message carries no proof because it creates the first local record. Try, acknowledgment, and confirmation carry proof_init, proof_try, and proof_ack with a proof height. The proof height identifies the remote chain history against which the receiving client checks the claim.

References: modules/…/msgs.go• L31-72 modules/…/msgs.go• L75-126 modules/…/msgs.go• L128-190 proto/…/tx.proto• L55-130

Proof model

Proofs make the handshake a state exchange rather than a message exchange. The relayer supplies a proof and the height at which it was built. The receiving chain uses the client named by its local connection end to verify that the expected remote connection value exists at the counterparty path.

Connection state proofs

A membership proof is evidence that a value exists at a store path at a given height. For a connection check, the module builds the remote connection path from the counterparty connection ID, applies the counterparty Merkle prefix, serializes the expected connection end, and asks the client module to verify membership.

The expected value includes the state, IDs, versions, prefix, and delay period that the handshake step requires. A proof is therefore valid only when it matches the expected remote record and the local client's view of the other chain.

Connection-state checks pass zero delay values to client verification. The connection delay period applies to later packet proofs, not to the handshake proofs that establish the link.

References: modules/…/verify.go• L19-49 modules/…/expected_keepers.go• L11-19 modules/…/handshake.go• L78-100

Proof claims

Each proof belongs to one handshake step and proves one remote state:

MessageProof claimReceiving check
ConnectionOpenTryChain A stored its INIT connection end.Chain B verifies the connection state at proof_height.
ConnectionOpenAckChain B stored its TRYOPEN connection end.Chain A verifies the selected counterparty state.
ConnectionOpenConfirmChain A changed its end to OPEN.Chain B verifies the open counterparty state.

The message layer rejects an empty proof before the keeper performs the state check. A stale client or a proof from a height beyond the client's view also stops the handshake.

References: proto/…/tx.proto• L55-83 proto/…/tx.proto• L88-130 modules/…/msgs.go• L94-190 modules/…/verify.go• L41-49

Negotiated connection rules

The handshake establishes rules for later users of the connection. Both chains must agree on an IBC version and use the same delay period.

Version agreement

Chain A offers one or more supported versions at init. Chain B chooses the first compatible version in the intersection of both sets. The chosen version keeps only features supported by both chains. Chain A checks that choice during acknowledgment before it marks its end OPEN.

The current default version has identifier 1 and supports ordered and unordered channels. The connection layer records this capability. Channel setup later chooses how a specific channel uses it.

References: modules/…/version.go• L12-36 modules/…/version.go• L78-107 modules/…/version.go• L115-180 modules/…/handshake.go• L85-95 modules/…/handshake.go• L145-151

Delay agreement

The delay period is stored on both connection ends. It sets how long remote consensus state must age before the client can use it for packet proof verification. The connection parameters include a maximum expected time per block so the module can express the time delay as a block delay when a client needs height checks.

The handshake requires the two ends to use the same delay period. Normal parameter updates reject a zero maximum expected time per block. If unset state reaches the block-delay helper, it uses a zero block delay as a safe fallback.

References: proto/…/connection.proto• L23-33 proto/…/connection.proto• L110-116 modules/…/params.go• L10-29 modules/…/handshake.go• L78-84 modules/…/verify.go• L216-229

Connection readiness

An OPEN end means that the local chain has verified the other end and stored the negotiated relationship. The relationship is usable only when both chains have completed the exchange because channel and packet operations need a connection that can verify remote state.

The connection module does not create or update light-client trust data. It requires an active client at init and delegates remote membership checks to the client module. See client lifecycle and verification for client state and client proof rules.

References: modules/…/handshake.go• L38-49 modules/…/verify.go• L41-49 modules/…/expected_keepers.go• L11-19

Connection visibility

Connection state is exposed for relayers, operators, and other modules. Queries return connection ends, client-to-connection paths, the client or consensus state linked to a connection, and connection parameters.

State queries

The query interface can return one connection or a paged list of all connections. It can also return the paths linked to a client and the client or consensus state used by a connection. Query responses include a height, and proof-capable client utilities can obtain a store proof when a caller needs verifiable query data.

The command interface exposes these views as connections, end, path, and params queries. The end and path queries support proof output through the proof-capable query path.

References: proto/…/query.proto• L16-50 proto/…/query.proto• L53-154 modules/…/grpc_query.go• L38-205 modules/…/utils.go• L25-103 modules/…/query.go• L19-150

Handshake events

Each successful handshake step emits an event with the local connection ID, local client ID, and counterparty identifiers. These events let relayers and operators track progress without reading every connection record.

The event names match the four steps: connection_open_init, connection_open_try, connection_open_ack, and connection_open_confirm.

References: modules/…/events.go• L11-27 modules/…/events.go• L11-76 modules/…/handshake.go• L51-55

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the four proof claims aligned with the state transitions in the connection keeper. A field change can make a relayer prove the wrong remote state.
  • Keep connection identifiers, host paths, and counterparty prefixes aligned. A mismatch can make a valid remote connection look absent.
  • Keep version negotiation aligned with channel feature support. The selected feature set is the contract used by later channel setup.
  • Keep the delay period and maximum expected time per block aligned with packet proof checks. These values affect when remote state becomes usable.
  • Keep client-to-connection paths aligned with connection creation. Later queries and verification use this association to find the client.
  • Keep query proof output and proof heights aligned with the store paths used by relayers. A response without the expected proof cannot support a remote state check.
  • Keep event names and identifier attributes stable for relayers and operators that track handshake progress.

Important failure modes

TriggerConsequenceGuard
The client is not active at open initChain A cannot create an INIT end.Require an active client before starting the handshake.
A normal handshake uses the localhost clientMessage validation rejects the attempt.Use a client that tracks the counterparty chain.
A proof is empty, stale, or built for the wrong pathThe receiving step rejects and the connection does not advance.Submit the proof and height for the exact expected remote state.
Chains have no compatible version or the selected features are unsupportedOpen acknowledgment fails.Intersect supported versions and validate the selected version.
A message arrives in the wrong connection stateThe state transition fails.Accept only INIT for acknowledgment and TRYOPEN for confirmation.
The two ends use different delay periodsRemote state does not match the expected connection end.Use the same delay period on both ends.
A client has not reached the proof heightClient verification fails even when the remote record exists.Update the client before relaying the next handshake proof.

Key files

FileWhy to read it
proto/…/connection.protoDefines connection ends, states, counterparties, versions, and delay parameters.
proto/…/tx.protoDefines the four handshake messages and their proof claims.
modules/…/handshake.goShows the state changes and proof order across the handshake.
modules/…/verify.goShows how a connection proof binds a remote value to a client and path.
modules/…/connection.goDefines validity rules for connection ends and counterparties.
modules/…/version.goExplains version compatibility and feature intersection.
modules/…/keeper.goShows identifier creation and client-to-connection associations.
proto/…/query.protoDefines the operator and relayer views of connection state.
modules/…/events.goShows the events emitted for each successful handshake step.