IBC CLI APIs and protocol contracts
The IBC CLI v2 API defines protobuf contracts for relay work, proof generation, and signed chain data. The relayer coordinates packet work, a prover supplies light-client updates and proofs, and an attestor supplies signed statements. Generated Go bindings make the same contracts available to local services and remote clients. See Link relayer system and Link attestation and transactions for the wider system flows.
Contract model
Service roles
The API uses three protobuf services in the ibc.v2 package family. The relayer service accepts packet work and exposes packet records. The prover service supplies updates and proofs for one configured light client. The attestor service returns signed statements about chain state or packet commitments.
These roles separate coordination from chain evidence. A relayer can use a prover as a remote service. A prover can use an attestor or another chain-specific source without changing the relayer contract.
The following diagram shows how the three service roles support relay work.
flowchart LR
Caller[CLI or relay caller] --> Relayer[RelayerApiService]
Relayer --> Prover[ProverService]
Prover --> Attestor[AttestationService]
Prover --> Updates[Light-client update payloads]
Prover --> Proofs[Light-client proofs]
Attestor --> Statements[Signed statements]
Updates --> Relayer
Proofs --> Relayer
Relayer --> Packets[Packet records and relay result]
References: proto/…/relayer.proto• L9-16 proto/…/prover.proto• L9-28 proto/…/attestor.proto• L9-22
Relayer API
Relay selection
RelayerApiService.Relay starts work for packets found in one source-chain transaction. The request names the source chain and transaction. One required selection choice defines which packets this relayer instance records for delivery.
| Selection | Contract meaning |
|---|---|
AllPackets | Select every packet that has a configured client and route. Skip packets without one. The request still succeeds if no packet remains to relay. |
SelectedPackets | Select only the listed source-client and sequence pairs. Fail if any listed packet is absent or cannot be routed. Repeating a request for an already selected, active, or terminal packet is a successful no-op. |
The response lists every send packet in the source transaction, including packets that this relayer will not deliver. Each packet reports whether this request selected it, did not select it, or skipped it because no client or route is configured. A selected result records work for later delivery; it does not mean that delivery has completed.
References: proto/…/relayer.proto• L18-66 cli/…/relayer_handler.go• L45-89
Packet queries
RelayerApiService.Packets gives callers a paged view of packets known to the relayer. Filters can narrow the view by chain, client, source transaction, sequence, or packet state. An opaque cursor moves the caller through results that are ordered from newest to oldest.
Each PacketStatus identifies a packet with its source chain, source client ID, and sequence number. It reports the relay state and the transactions that Link has submitted or found on the source and destination chains.
| State | Meaning |
|---|---|
NOT_SELECTED | The packet is known but this relayer instance did not select it. |
PENDING | Relay work is still in progress. |
SUCCEEDED | The source chain has a successful acknowledgement. |
TIMED_OUT | The source chain has a timeout refund. |
REJECTED | The source chain has an error acknowledgement. |
RELAY_FAILED | A permanent error blocks relay work. |
References: proto/…/relayer.proto• L68-134 cli/…/relayer_handler.go• L118-180
Prover API
Client-scoped proof requests
ProverService supplies the material that a relayer passes to one light client. Every request names a Client, which is the pair of chain ID and client ID. This scope lets one prover endpoint serve clients on many chains.
The API separates height selection from update and proof retrieval. A caller first obtains the highest usable counterparty height and its timestamp. It then asks for client update payloads and packet proofs at that shared height.
| RPC | Purpose | Result |
|---|---|---|
LatestProvableHeight | Find a height that later prover calls can share. | Height and counterparty timestamp. |
ClientUpdatePayloads | Bring the light client to the selected counterparty height. | Ordered opaque update payloads. |
PacketProofs | Prove counterparty packet membership or non-membership. | One opaque proof for each requested packet. |
PacketProofs selects one ProofKind for the whole request. The kinds cover packet commitment, acknowledgement, and receipt absence. The last kind supports timeout proof by showing that a packet receipt does not exist. Acknowledgement proofs also carry one acknowledgement per packet in packet order.
References: proto/…/prover.proto• L9-28 proto/…/prover.proto• L30-93 cli/…/prover.go• L26-48
Client update payloads
ClientUpdatePayloads returns encoded light-client update messages for the selected height. The relayer passes each payload unchanged and in order before it submits the packet work. An empty response means that the light client already trusts the selected height. Each returned payload is a non-empty update message.
This RPC completes the height contract with LatestProvableHeight. The height returned by the first call is the height used for both update payloads and packet proofs, so the client update and the packet evidence describe the same counterparty state.
References: proto/…/prover.proto• L16-23 proto/…/prover.proto• L39-63 cli/…/prover.pb.go• L236-335 cli/…/remote.go• L78-93
Packet proof correspondence
The prover receives the packet identity, timeout, and application payloads needed to prove the exact packet being relayed. For acknowledgement proofs, it also receives the encoded application acknowledgements that match the packet order.
The response keeps proof indices aligned with request indices, so the first proof belongs to the first packet and so on. The relayer submits the proofs from one response together and in that order. This lets a prover place material shared by the batch only in the first proof.
Proof bytes are opaque to the relayer. The target light-client protocol interprets them. A proof service must therefore preserve packet meaning and return the same number of proofs as packets in the request.
References: proto/…/prover.proto• L65-124 cli/…/prover.pb.go• L337-548 cli/…/remote.go• L95-180
Attestor API
Attestation queries
AttestationService provides signed data for a configured chain. Info identifies the watched chain and signing address. LatestHeight tells a caller which height the attestor can currently serve. The two attestation RPCs then return state data or packet-related data at a requested height.
| RPC | Main input | Contract result |
|---|---|---|
Info | Attestor name. | Watched chain ID and signing address. |
LatestHeight | Attestor name. | Highest height available for attestation. |
StateAttestation | Attestor name and height. | Signed state attestation. |
PacketAttestation | Attestor name, packet bytes, height, and commitment type. | Signed packet, acknowledgement, or receipt attestation. |
Unlike a prover request, a packet attestation request carries its height directly. The request must contain at least one packet. CommitmentType selects packet commitment, acknowledgement commitment, or receipt commitment. If it is not set, the contract uses packet commitment for backward compatibility.
References: proto/…/attestor.proto• L9-22 proto/…/attestor.proto• L24-76 cli/…/attestor_handler.go• L47-123
Signed attestation payloads
Each attestation contains the height, an optional block timestamp, the attested bytes, and a signature. The API leaves the attested bytes opaque so the downstream IBC protocol can verify and interpret them for the selected commitment.
| Commitment type | Protocol use |
|---|---|
COMMITMENT_TYPE_PACKET | Prove a packet commitment from a send event. |
COMMITMENT_TYPE_ACK | Prove an acknowledgement commitment. |
COMMITMENT_TYPE_RECEIPT | Prove receipt absence for timeout handling. |
The attestor name selects the configured signer and watched chain. The returned statement and signature then become inputs to proof or transaction work.
References: proto/…/attestor.proto• L65-86 cli/…/attestor_handler.go• L140-169
Generated Go bindings
Protobuf message bindings
The generated cli/…/relayer.pb.go, cli/…/prover.pb.go, and cli/…/attestor.pb.go files expose schema messages and enums as Go types. They also carry descriptors that let the transport layer use the same service and field definitions.
The .proto files are the source of the wire contract. proto/buf.gen.yaml selects the Go protobuf and Connect Go generators and writes their output under the CLI module. Generated Go files are derived views for Go callers. Contract changes therefore require regeneration rather than hand edits to generated output.
The prover bindings expose ClientUpdatePayloadsRequest and ClientUpdatePayloadsResponse together with the existing height and packet-proof messages. They also encode the packet-proof acknowledgement list, proof-kind enum, and three-method service descriptor. The generated service descriptor and Go types must agree with the three prover RPCs.
References: proto/buf.gen.yaml• L3-15 proto/…/relayer.proto• L3-134 proto/…/prover.proto• L3-124 proto/…/attestor.proto• L3-86 cli/…/prover.pb.go• L236-347 cli/…/prover.pb.go• L618-732
RPC transport bindings
The generated *.connect.go files expose typed clients and handler interfaces. They bind fully qualified service names and procedure paths to unary HTTP calls. Connect is the default protocol, with gRPC and gRPC-Web supported through client or handler options.
The same generated contract serves both sides of a remote call. A service implements the handler interface. A relayer or other caller constructs the matching client. The remote prover adapter uses this path to turn relayer height, update, and proof requests into ProverService calls.
References: cli/…/relayer.connect.go• L24-133 cli/…/prover.connect.go• L24-167 cli/…/attestor.connect.go• L24-184 cli/…/remote.go• L32-45
Service adapters
The server adapters keep the network contract separate from service logic. They convert protobuf messages into service requests, map domain results back to protobuf messages, and translate known domain errors into Connect status codes.
This boundary also protects the wire contract from local type changes. A relayer, prover, or attestor implementation can change behind its adapter while clients continue to use the stable service name, procedure names, and message schema.
References: cli/…/relayer_handler.go• L17-51 cli/…/relayer_handler.go• L53-180 cli/…/attestor_handler.go• L17-53 cli/…/server.go• L34-60 cli/…/server.go• L132-194
Request lifecycle
Relay and proof sequence
The contract-level relay flow starts with a source transaction and uses a client-scoped prover to obtain client updates and packet evidence for later IBC transaction work. An attestation-backed prover may obtain signed chain data as part of its own service. The relayer only depends on the prover contract.
The diagram shows the relationship between the public relay API and the prover API without the chain-specific transaction steps.
sequenceDiagram
participant C as CLI or caller
participant R as RelayerApiService
participant P as ProverService
participant A as AttestationService
C->>R: Relay(source chain, transaction, selection)
R-->>C: Observed packets
R->>P: LatestProvableHeight(client)
P-->>R: Height and timestamp
R->>P: ClientUpdatePayloads(client, height)
P-->>R: Ordered opaque update payloads
R->>P: PacketProofs(client, height, kind, packets)
P-->>R: Opaque proofs
P->>A: Optional attestation queries
A-->>P: Signed attestation
R-->>C: Packets(filters, cursor)
References: proto/…/relayer.proto• L9-16 proto/…/prover.proto• L15-28 cli/…/remote.go• L59-128 cli/…/server.go• L132-194
Change checklist
When these files or sections are changed, remember to consider these:
- Preserve protobuf field numbers, service names, procedure names, and enum zero values. They are part of the wire and route contract.
- Regenerate both message bindings and Connect transport bindings after a .proto change. Use the generators selected by proto/buf.gen.yaml.
- Keep relayer selection and packet-state mappings aligned between the schema and the server adapter. Include selected, not-selected, and unconfigured packet results.
- Keep proof-kind and commitment-kind mappings aligned between local service types and wire enums.
- Preserve the shared height across
LatestProvableHeight,ClientUpdatePayloads, andPacketProofs. - Preserve client update payload order and pass each payload unchanged to the light-client update path.
- Preserve packet-to-proof order and count. The caller uses both to match each proof to its packet.
- Keep acknowledgement order aligned with packet order for acknowledgement proofs.
- Keep the client-scoped identity aligned across prover configuration, remote client construction, and service lookup.
- Keep service registration paths aligned with the generated client procedure paths.
- Preserve the default packet commitment behavior when a packet attestation request omits
commitment_type.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A relay request has no selection or lists an unavailable packet. | The relayer cannot define valid work and rejects the request. | Set exactly one selection and validate explicit packet selectors. |
| An all-packets request assumes every observed packet will be delivered. | Unconfigured packets are skipped even though the request succeeds. | Read each ObservedPacket.selection result before tracking delivery. |
| A packet query reuses an invalid cursor or an unsupported state value. | The page request fails or cannot continue from the expected position. | Treat cursors as opaque and use only declared packet states. |
| A proof request names an unknown client. | The prover cannot select a light-client implementation. | Use the configured chain ID and client ID pair. |
| Update payloads and packet proofs use different heights. | The client update and packet evidence can describe different counterparty states. | Reuse the height returned by LatestProvableHeight for both calls. |
| A client update payload is reordered, changed, or omitted. | The light client may not reach the state required by the packet proofs. | Pass non-empty payloads unchanged and in response order. |
PacketProofs returns a proof count different from the packet count. | The relayer cannot safely match proofs to packets. | Preserve request order and return one proof per packet. |
| Acknowledgements do not match packet order for acknowledgement proofs. | The prover can build evidence for the wrong packet. | Send one acknowledgement per packet in the same order. |
| A packet attestation has no packets or an unsupported commitment type. | The attestor returns an invalid-argument error. | Send a non-empty packet set and a declared commitment kind. |
| A requested attestation height is not usable. | The attestor returns no valid signed statement. | Query the latest usable height before requesting state data. |
| An omitted packet attestation commitment type is treated as invalid. | Older callers lose the default packet-commitment behavior. | Interpret the zero enum value as COMMITMENT_TYPE_PACKET. |
| Generated bindings do not match the .proto files. | Clients, handlers, message fields, or routes can disagree. | Regenerate *.pb.go and *.connect.go from the current schemas. |
Key files
| File | Why to read it |
|---|---|
| proto/…/relayer.proto | Defines relay selection, packet selection results, packet queries, packet states, and transaction links. |
| proto/…/prover.proto | Defines client-scoped heights, update payloads, packet proofs, acknowledgement inputs, and packet data for custom light clients. |
| proto/…/attestor.proto | Defines signed state and packet-attestation requests, default commitment behavior, and payloads. |
| proto/buf.gen.yaml | Defines the generators and output module used to publish Go message and transport bindings. |
| cli/…/relayer.pb.go | Provides generated Go messages and enums for the relayer contract. |
| cli/…/prover.pb.go | Provides generated Go messages, proof kinds, update payload messages, packet-proof inputs, and descriptors for the prover contract. |
| cli/…/attestor.pb.go | Provides generated Go messages and enums for the attestor contract. |
| cli/…/relayer.connect.go | Provides relayer client and handler interfaces with service routes. |
| cli/…/prover.connect.go | Provides prover client and handler interfaces for height, update, and proof calls. |
| cli/…/attestor.connect.go | Provides attestor client and handler interfaces with service routes. |
| cli/…/relayer_handler.go | Shows how relayer messages cross into relayer service logic. |
| cli/…/attestor_handler.go | Shows how attestation messages and domain errors cross the API boundary. |
| cli/…/remote.go | Shows how a relayer consumes the remote prover contract and checks proof correspondence. |
| cli/…/server.go | Shows how a prover service resolves clients and serves the contract. |