Wasm light client
The Wasm light client is a programmable IBC client proxy. It keeps the shared client record and lifecycle in IBC core while a published Wasm contract supplies the trust rules for a target chain. This lets a chain add or change light-client logic without putting every algorithm in the validator binary.
System purpose
Programmable client boundary
The 08-wasm module presents one IBC client type to core IBC and selects the contract that serves each client instance. Core IBC owns client identity, storage, and call order. The contract owns the meaning of its opaque data and the rules for messages, proofs, updates, and misbehaviour.
| Responsibility | Owning system |
|---|---|
| Client identity, storage, packet checks, and lifecycle order | IBC core |
| Published code and its checksum | The Wasm client module and Wasm VM |
| Chain-specific trust and proof rules | The selected Wasm contract |
| Contract state changes for one client | The contract through the proxy |
References: modules/…/light_client_module.go• L24-43 modules/…/keeper.go• L24-40 modules/…/README.md• L7-15
Opaque client records
The Wasm client state contains contract data, the checksum for its code, and the latest trusted height. The consensus state and client message contain opaque bytes. IBC checks the shared record shape, while the contract defines the bytes inside it.
This stable record lets different client algorithms use the same IBC client type. A contract can define its own header, update, and misbehaviour format without a new Go client type for each chain.
References: proto/…/wasm.proto• L11-34 modules/…/client_state.go• L12-35 modules/…/client_message.go• L11-24
Code management
Contract publication
Contract publication makes Wasm light-client code available for later client creation. An authority submits bytecode through MsgStoreCode; the module validates it, stores it in the VM, and records its SHA-256 checksum as the code identity. Raw and gzip-compressed code are accepted within the module size limit.
Client creation accepts only a checksum that the module has recorded. The usual command path submits code as a governance proposal, so a chain can approve new client code without a coordinated validator binary release. The module also exposes queries for stored checksums and for code selected by checksum.
References: modules/…/msg_server.go• L18-35 modules/…/keeper.go• L85-139 modules/…/tx.go• L27-74 modules/…/grpc_query.go• L23-65
Contract migration
Contract migration changes the code used by one existing client. The target checksum must already be published and must differ from the current checksum. The new contract receives a migration message and may convert the client data before the module records the new checksum.
An authority can also remove a recorded checksum. The module removes the record and unpins the VM code. A client that still points to that checksum remains in storage but cannot use the code and reports an unauthorized status.
References: modules/…/msg_server.go• L37-79 modules/…/keeper.go• L142-185 modules/…/light_client_module.go• L318-344 modules/…/tx.go• L89-129
Code persistence
Code publication is part of chain state, but the VM's code cache is a node-local runtime resource. Genesis export and import carry the published contract bytes. State snapshots carry the code needed to rebuild the VM cache, and node start-up pins the recorded checksums again.
The persistence path keeps a new node or a restored node able to execute clients that already exist. All validators must therefore have compatible Wasm VM support and the same published code state.
References: modules/…/genesis.go• L13-50 modules/…/snapshotter.go• L23-149 modules/…/app.go• L718-775
Publication lifecycle
The publication path connects authority-controlled code to later IBC verification calls.
flowchart LR
A[Authority submits code] --> B[Module validates and hashes code]
B --> C[VM stores and pins code]
C --> D[Module records checksum]
D --> E[Relayer creates 08-wasm client]
E --> F[Contract initializes client data]
F --> G[IBC sends client calls]
G --> H[Proxy selects code by checksum]
H --> I[Contract reads or changes client state]
One published contract can serve many client instances. The checksum is the shared reference that ties each instance to approved code.
References: modules/…/keeper.go• L85-139 modules/…/light_client_module.go• L40-75 modules/…/genesis.go• L30-50
Client message execution
Contract entry points
The proxy maps IBC operations to a small contract API. Read-only queries inspect a client without changing its state. Privileged calls can update the client store. Instantiation creates the initial client and consensus state.
| IBC action | Contract entry point | Result or effect |
|---|---|---|
| Create client | Instantiate | Creates the initial contract state |
| Verify a client message | Query | Accepts or rejects the message |
| Check misbehaviour | Query | Reports whether misbehaviour exists |
| Update state | Sudo | Writes client and consensus state and returns heights |
| Verify membership or non-membership | Sudo | Accepts or rejects the proof |
| Report status or timestamp | Query | Returns status or time data |
| Verify an upgrade or recover a client | Sudo | Verifies and applies the requested state change |
The proxy gives the contract the chain ID, block height, block time, and client ID. Only the contract data result crosses back as a client result. Contract messages, events, and attributes are not allowed through this boundary.
References: modules/…/contract_api.go• L10-127 modules/…/contract_keeper.go• L38-83 modules/…/contract_keeper.go• L101-211
Verification and update sequence
Core IBC treats message verification as the trust gate. It verifies the opaque client message first. Only after that check succeeds does it ask the contract to inspect misbehaviour or update its state.
sequenceDiagram
participant Core as IBC core
participant Proxy as Wasm proxy
participant Contract as Wasm contract
participant Store as Client store
Core->>Proxy: Verify client message
Proxy->>Contract: Query verify_client_message
Contract-->>Proxy: Accept or reject
alt Message accepted
Core->>Proxy: Check misbehaviour or update state
Proxy->>Contract: Query or sudo
Contract->>Store: Read or write client data
Contract-->>Proxy: Result and updated heights
Proxy-->>Core: Result or heights
end
The update is a state transition after verification. The contract owns the chain-specific transition and returns the heights that core IBC uses for its client records.
References: modules/…/light_client_module.go• L78-200 modules/…/contract_api.go• L17-67
Query and sudo contracts
The contract API uses JSON-shaped messages with one operation set at a time. Query operations cover status, timestamps, client-message checks, and misbehaviour checks. Sudo operations cover state updates, proof checks, upgrades, and recovery.
The VM charges gas for setup and execution. The proxy checks the client state after every state-changing call. The client state must still exist and decode as a Wasm client state, and its checksum cannot change except during migration.
References: modules/…/contract_api.go• L17-127 modules/…/contract_keeper.go• L134-170 modules/…/contract_keeper.go• L214-241
State verification
Membership proofs
The Wasm client supports membership and non-membership checks through the common IBC proof interface. The proxy checks the client, proof height, and path types. It rejects a proof above the latest trusted height before the contract applies the target chain's proof rules.
The contract receives the proof, path, expected value when present, and delay values. It can also read approved IBC data through the VM querier. The default route permits the core IBC membership query. Custom and other Stargate queries stay blocked unless the host adds an explicit plugin.
References: modules/…/light_client_module.go• L202-305 modules/…/querier.go• L36-50 modules/…/querier.go• L113-170 modules/…/options_test.go• L30-136
Client upgrades
An upgrade supplies new opaque client and consensus data with proofs. The proxy requires the new client height to be greater than the current height before it asks the contract to verify the change. The contract checks the proof and writes the upgraded state.
This split keeps the shared height rule in the proxy. It leaves the proof format and upgrade trust rule in the contract.
References: modules/…/light_client_module.go• L439-484 modules/…/contract_api.go• L88-94
Client recovery
Recovery uses a substitute Wasm client to repair a subject client. Both clients must use the same checksum, so recovery cannot change contract code while it repairs state. The contract can read both client stores, but writes apply only to the subject client.
References: modules/…/light_client_module.go• L395-436 modules/…/store_test.go• L63-109 modules/…/store_test.go• L203-247
IBC core extension boundary
Light-client module interface
IBC core interacts with the Wasm proxy through the standard light-client module interface. Core owns the common lifecycle and call order. The proxy converts those calls into contract messages and manages contract state access and results.
The host chain must register 08-wasm as a client route and allow the client type in its client parameters. Client identifiers use the 08-wasm-{N} form. Without registration and allow-list support, normal client creation and use are not authorized.
References: modules/…/light_client_module.go• L24-43 modules/…/doc.go• L3-19 modules/…/app.go• L547-560
Host integration surface
The host supplies the client keeper, client store provider, query router, and Wasm VM. These services connect the proxy to IBC storage and control which host data contracts can read. A chain can share its VM with the general Wasm module or create a separate VM from its own configuration.
This is the main extension boundary. New client algorithms belong in contracts. Host-specific data access belongs behind an explicit query route or plugin. For example, a host may add a custom verifier or allow an extra Stargate query while the default querier remains restrictive.
References: modules/…/expected_keepers.go• L12-17 modules/…/keeper_vm.go• L22-98 modules/…/querier.go• L84-163 modules/…/app.go• L393-441
Runtime requirements
Contracts run inside the CosmWasm VM with bounded memory and host-charged gas. A normal keeper needs cgo and the linked Wasm VM. A no-VM build can provide types, but it cannot construct the keeper or execute clients.
Validator binaries must use compatible VM support, capabilities, and module dependencies. The current module targets Go 1.26.10 and Wasm VM v3.0.7. The host must also check that the loaded native Wasm library matches the module dependency before it starts the application.
References: modules/…/doc.go• L10-15 modules/…/keeper_no_vm.go• L15-44 modules/…/go.mod• L1-35 modules/…/root.go• L224-228 modules/…/root.go• L353-399
Related pages
- IBC light clients gives the parent view of light-client types.
- Tendermint light client contrasts a built-in client with the programmable proxy.
- Local and solo-machine clients covers other client trust models.
- Attestation light clients covers another chain-specific verification model.
- Client lifecycle explains the common lifecycle that the Wasm proxy implements.
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to the contract JSON messages must stay aligned with the contract API and the Rust enum shape expected by the Wasm contract.
- Changes to the Wasm client state or message wire fields must preserve interface registration and the
08-wasmclient-store type. - Changes to checksum publication or removal must be checked against client authorization, migration, genesis restore, snapshots, and VM pinning.
- Changes to allowed VM queries must be reviewed with the host query router because they expand the data that a contract can use for verification.
- Changes to the client update result must preserve the consensus heights returned to core IBC after the contract writes state.
- Changes to recovery store access must preserve read access to both clients and write access only to the subject client.
- Changes to the host VM build, native library, architecture targets, or capability set must be applied consistently to all validating nodes.
- Changes to the module, Go toolchain, or Wasm VM dependency versions must be checked for compatible build and runtime support across the chain.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A client uses a checksum that was not published through the module | Initialization fails or status becomes Unauthorized | Require a recorded checksum before initialization and status use |
| An authority removes code still referenced by a client | The client state remains, but execution becomes unauthorized | Check code references before removal or restore the code before use |
| The contract returns messages, events, or attributes from a state-changing call | The call fails and its state result is not accepted | Allow only the contract data result across the proxy boundary |
| A client update runs without successful message verification | Untrusted data can enter the update path | Core verifies the message before misbehaviour checks or state updates |
| A proof height is above the client's latest height | Membership or non-membership verification fails | Compare the proof height with the stored latest height before the contract call |
| A migration targets an unknown or current checksum | The client cannot migrate | Publish the new code first and require a different checksum |
| A recovery pair uses different checksums | Recovery is rejected instead of changing code through recovery | Use the migration message for code changes and recovery for state repair only |
| A contract requests a query outside the accepted routes | The contract cannot obtain the requested host data | Use the default accept list or add an explicit query plugin |
| A node is built without linked Wasm VM support | The keeper cannot be constructed and the client is unavailable | Build validator binaries with the required VM support |
| Validators run incompatible native Wasm libraries or module dependencies | Nodes can fail to run the client or disagree on execution | Keep VM versions, capabilities, and dependencies consistent across validators |
Key files
| File | Why to read it |
|---|---|
| modules/…/README.md | States the product goal and the reason to use a Wasm contract for a light client. |
| modules/…/light_client_module.go | Shows how the standard IBC client interface maps to contract calls and shared checks. |
| modules/…/contract_api.go | Defines the contract-facing operations and result shapes. |
| proto/…/wasm.proto | Defines the opaque client state, consensus state, and client message record. |
| modules/…/keeper.go | Shows publication, checksum tracking, migration, and VM code lifetime. |
| modules/…/contract_keeper.go | Shows the execution boundary, gas use, state checks, and response limits. |
| modules/…/querier.go | Shows how contracts access approved IBC host queries and host plugins. |
| modules/…/genesis.go | Shows how published code enters and leaves chain genesis state. |
| modules/…/snapshotter.go | Shows how VM code is included in state snapshots and restored. |
| modules/…/app.go | Shows host wiring for the keeper, query plugins, client route, and VM startup. |
| proto/…/tx.proto | Defines the public messages for code publication, removal, and migration. |
| proto/…/query.proto | Defines the public queries for checksums and stored code. |