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 / general-message-passing

Generalized message passing

Generalized message passing (GMP) carries a signed set of Cosmos SDK messages from one chain to another over IBC. The destination chain recreates a predictable interchain account for the remote sender, checks that every message names that account as its signer, executes the messages as one unit, and returns the result in an IBC acknowledgement.

System boundary

GMP is an IBC application that turns a cross-chain packet into a local transaction on the destination chain. It uses the IBC v2 channel system for transport and the destination chain's message router for execution. See IBC application modules for the wider application-module model.

Cross-chain contract

The source chain submits MsgSendCall through the GMP port. The message names the source client, sender, destination receiver, salt, call payload, timeout, memo, and optional encoding. GMP packages the call as GMPPacketData and returns the packet sequence to the source transaction.

The packet payload has a stable meaning across supported encodings:

FieldPurpose
senderSource-chain address that authorizes the send
receiverDestination address supplied for the call
saltValue that separates accounts for the same sender and client
payloadSerialized list of destination-chain SDK messages
memoOptional application data, including callback data when middleware uses it

GMP accepts JSON, protobuf, and Solidity ABI forms for packet data and acknowledgements. The encoding changes the wire form. It does not change the message or authorization contract.

References: proto/…/tx.proto• L12-49 proto/…/packet.proto• L9-25 modules/…/packet.go• L26-43

Transport relationship

The GMP module owns the application meaning of the packet. IBC core owns channel ordering, packet commitments, proofs, relaying, timeouts, and acknowledgement delivery. GMP therefore validates its own port, client, version, and data rules while relying on IBC core for cross-chain delivery.

The default GMP port is gmpport. A chain must register the GMP module at that port in its IBC v2 router. Middleware can wrap that module before registration, so the packet still reaches GMP while other components observe or extend the IBC callbacks.

References: modules/…/ibc_module.go• L36-51 modules/…/ibc_module.go• L75-109 modules/…/keys.go• L7-20 modules/…/app.go• L453-463

Packet lifecycle

GMP follows the normal IBC packet path, then adds destination-side transaction execution between packet receipt and acknowledgement creation. The source sender signs the outgoing request. A relayer moves the packet and later moves the acknowledgement, but the relayer does not become the signer of the destination messages.

Send and relay flow

This flow shows how a source transaction becomes a destination transaction and how its result returns to the source chain.

sequenceDiagram
    participant S as Source chain
    participant R as Relayer
    participant D as Destination chain

    S->>S: Validate sender and GMP packet data
    S->>S: Create IBC packet commitment
    S-->>R: Packet and proof
    R->>D: RecvPacket with proof
    D->>D: Decode and validate GMP data
    D->>D: Resolve or create interchain account
    D->>D: Authenticate and execute inner messages
    D-->>R: Success or failure acknowledgement
    R->>S: Acknowledge packet with proof

The send side checks that both packet ports use GMP, that both client identifiers have valid form, and that the packet sender equals the transaction signer. The receive side rejects an invalid port, version, encoding, or packet body. A successful execution returns an acknowledgement whose result contains the serialized SDK message responses.

References: modules/…/ibc_module.go• L36-72 modules/…/ibc_module.go• L75-161 modules/…/msg_server.go• L21-42

Destination execution

The destination creates or finds an ICS27 account from the destination client identifier, packet sender, and salt. An ICS27 account is a local account that acts for the remote sender during message execution. It is not the relayer account and it is not selected by the packet's receiver field.

GMP decodes the packet payload as a CosmosTx, which is a list of SDK messages packed as protobuf Any values. It checks the full list before delivery. Each message must have exactly one declared signer, and that signer must equal the resolved ICS27 account. The destination then sends each message through the chain's normal message router.

References: modules/…/relay.go• L19-49 modules/…/account.go• L72-109 proto/…/account.proto• L12-30

Result and acknowledgement

The destination returns the response from each executed message as the GMP acknowledgement result. GMP applies cache-based execution, so it commits the destination state only after all messages pass basic validation and execute successfully. A single failure prevents the whole inner transaction from changing state.

The GMP application itself does not add work in its acknowledgement or timeout callbacks. IBC core still completes those packet paths, and registered middleware can use the packet data and lifecycle callbacks for related behavior. The callbacks integration exposes GMP packet data through PacketDataProvider, including automatic source-callback data based on the packet sender.

References: modules/…/relay.go• L51-98 modules/…/ibc_module.go• L163-178 modules/…/packet.go• L129-159 modules/…/gmp_test.go• L26-55

Authorization boundaries

GMP separates three roles: the source signer authorizes the packet send, IBC proofs authorize packet delivery, and the destination ICS27 account authorizes the inner SDK messages. This separation keeps a relayer from gaining authority over the destination transaction.

Source authorization

The sender in GMPPacketData is treated as the source account for the send request. On the source chain, GMP parses that address and compares it with the signer supplied to OnSendPacket. A mismatch stops the packet before it enters the IBC channel flow.

The sender address is an application value chosen by the module that requests the packet. GMP's packet-data contract warns that modules on the sending chain may rely on it for sender checks, while destination logic must not treat it as a local authenticated signer by itself.

References: modules/…/ibc_module.go• L44-60 modules/…/packet.go• L129-137 proto/…/tx.proto• L20-31

Destination authorization

The destination derives the account identity from the destination client, source sender, and salt. For every inner message, GMP reads the signer declared by the message type and compares it with that account address. The check applies to single-message and multi-message payloads.

The predictable account address lets the source prepare funds or refer to the destination account before the packet arrives. The destination still resolves the account through its own account keeper and fails if the expected local account is not available for execution.

References: modules/…/relay.go• L26-45 modules/…/relay.go• L100-127 modules/…/account.go• L40-65

Message routing boundary

After authorization, GMP does not define the business meaning of each inner message. It passes each message to the destination chain's message router. The router decides whether a handler exists and the handler applies the chain module's own rules.

This boundary allows GMP to carry different SDK message types without adding a separate cross-chain route for each type. It also means the destination chain must register the message services needed by the payload. An unknown message type or a handler that returns an error fails the GMP execution.

References: modules/…/relay.go• L130-155 modules/…/router.go• L10-14 modules/…/keeper.go• L21-31

Account model

GMP uses an account identity that is stable for a client, sender, and salt pair. The account lets a remote sender fund and control a local address without giving the relayer control of that address.

Account identity

An AccountIdentifier contains the destination-side client identifier, the source sender string, and the salt. GMP maps this tuple to a predictable local address. A new packet can create the local account on demand, while a query can compute the same address without changing state.

The module keeps both directions of the association: identifier to account and account to identifier. This supports packet execution and later inspection of which remote identity owns a local GMP account.

References: proto/…/account.proto• L12-26 modules/…/account.go• L23-38 modules/…/account.go• L16-56

Account queries

The query service exposes both sides of the account mapping. Engineers can ask for the account address from a client, sender, and hexadecimal salt, or ask for the identifier linked to an existing account address. The address query computes an unregistered address without creating the account.

References: proto/…/query.proto• L12-49 modules/…/query_server.go• L19-51

Module integration

An application integrates GMP by providing the account keeper, message router, and module authority to the GMP keeper, then registering GMP services and its IBC route. The IBC route is the runtime connection between IBC core and GMP packet semantics.

Application registration

The application module registers the GMP message and query services and includes GMP in genesis handling. The application must also connect the keeper to the chain account system and message router. The router registration determines whether GMP runs directly or through middleware.

The callbacks test application demonstrates a wrapped route: callback middleware surrounds the GMP IBC module, then the resulting stack is registered under gmpport. A plain application can register gmp.NewIBCModule directly when it does not need that middleware.

References: modules/…/module.go• L37-48 modules/…/module.go• L65-89 modules/…/app.go• L453-463

Integration contracts

The integration points have distinct responsibilities:

  • The IBC router sends GMP packets to the GMP IBC module by port.
  • The account keeper creates and loads the local ICS27 account.
  • The message router dispatches authorized inner messages to destination modules.
  • The codec packs and unpacks the packet transaction and message responses.
  • Middleware can observe or extend packet callbacks without changing the GMP packet contract.

References: modules/…/keeper.go• L21-68 modules/…/expected_keepers.go• L11-19 modules/…/account.go• L72-137 modules/…/ibc_module.go• L171-178

Change checklist

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

  • If the GMP packet or acknowledgement schema changes, update every supported encoding and the callback packet-data view together.
  • If account identity inputs change, keep address derivation, account lookup, reverse lookup, query paths, and genesis records aligned.
  • If inner message signing rules change, review both protobuf signer annotations and destination signer checks.
  • If the IBC port, version, or encoding contract changes, update route registration and all send and receive validation paths.
  • If message routing or response shape changes, preserve one response per inner message and the outer TxMsgData acknowledgement contract.
  • If middleware is added around GMP, verify the route order for send, receive, acknowledgement, and timeout callbacks.

Important failure modes

TriggerConsequenceGuard
Packet sender differs from the source transaction signerThe source packet is rejected before sendOnSendPacket compares the decoded sender with the signer
Packet uses the wrong port or versionDestination returns a failed packet result and no GMP acknowledgementReceive validation checks both ports and the GMP version
Inner message has no handlerThe destination transaction failsThe message router must return a handler for every message type
Any inner message names a signer other than the resolved ICS27 accountThe full destination transaction is rejectedGMP authenticates every message before execution
One inner message fails after earlier messages runNo inner state change is committedGMP executes in a cached context and writes only after all messages succeed
Packet payload cannot be decoded or re-encoded identicallyPacket processing fails as invalid dataGMP validates the selected encoding and checks canonical reserialization
Expected ICS27 account is missing from the destination account storePacket execution failsGMP resolves or creates the predictable account before execution

Key files

FileWhy to read it
modules/…/ibc_module.goDefines the GMP-facing IBC send, receive, timeout, acknowledgement, and packet-data interfaces
modules/…/msg_server.goShows how a source MsgSendCall becomes an IBC v2 packet
modules/…/relay.goShows destination account resolution, signer checks, atomic execution, and result creation
modules/…/account.goExplains account creation, lookup, and predictable-address use
modules/…/packet.goDefines packet validation, supported encodings, and middleware-visible packet data
proto/…/packet.protoDefines the cross-chain packet and acknowledgement contract
proto/…/account.protoDefines account identity and the inner message list carried by a packet
proto/…/tx.protoDefines the source send message and its packet-sequence response
modules/…/app.goIllustrates registration of GMP behind IBC v2 callback middleware