概述

了解 08-wasm 轻客户端代理模块。

背景

传统上,ibc-go 使用的轻客户端仅以 Go 实现;自 ibc-go v7 起(随着 02-client 重构发布),它们成为一等的 Cosmos SDK 模块。这意味着,更新现有轻客户端实现或新增对轻客户端的支持,是一个包含链上治理在内的多步骤、耗时过程:需要修改 ibc-go 的代码库(如果该轻客户端属于其代码库的一部分)、重新构建各链的二进制文件、通过治理提案,并由验证者升级其节点。

动机

为了打破轻客户端实现只能使用 Go 编写的限制,08-wasm 增加了对使用可编译为 Wasm 的语言编写轻客户端并运行它们的支持。轻客户端字节码实现了 CosmWasm 智能合约的入口点,并在 Wasm VM 内运行。08-wasm 模块公开了一个代理轻客户端接口,将传入消息路由到 Wasm VM 内相应的处理函数执行。 向链中添加新的轻客户端,就像提交一个包含存储轻客户端合约字节码消息的治理提案一样简单。无需协调升级。当治理提案通过且该消息被执行后,合约即可在接收到中继器提交的 MsgCreateClient 时完成实例化。创建 Wasm 轻客户端的过程,与创建常规的 Go 实现轻客户端相同。

用例

  • 为非 Cosmos 生态链开发轻客户端:其他生态中的状态机在很多情况下是用 Rust 实现的,因此其轻客户端实现中很可能会使用一些在 Go 中没有等价实现的库。这会使得用 Go 开发轻客户端非常困难,而用 Rust 实现则相对简单。因此,使用 Rust 编写实现轻客户端算法的 CosmWasm 智能合约,会是一个成本更低的方案。

Overview

Learn about the 08-wasm light client proxy module.

Context

Traditionally, light clients used by ibc-go have been implemented only in Go, and since ibc-go v7 (with the release of the 02-client refactor), they are first-class Cosmos SDK modules. This means that updating existing light client implementations or adding support for new light clients is a multi-step, time-consuming process involving on-chain governance: it is necessary to modify the codebase of ibc-go (if the light client is part of its codebase), re-build chains’ binaries, pass a governance proposal and have validators upgrade their nodes.

Motivation

To break the limitation of being able to write light client implementations only in Go, the 08-wasm adds support to run light clients written in a Wasm-compilable language. The light client byte code implements the entry points of a CosmWasm smart contract, and runs inside a Wasm VM. The 08-wasm module exposes a proxy light client interface that routes incoming messages to the appropriate handler function, inside the Wasm VM, for execution. Adding a new light client to a chain is just as simple as submitting a governance proposal with the message that stores the byte code of the light client contract. No coordinated upgrade is needed. When the governance proposal passes and the message is executed, the contract is ready to be instantiated upon receiving a relayer-submitted MsgCreateClient. The process of creating a Wasm light client is the same as with a regular light client implemented in Go.

Use cases

  • Development of light clients for non-Cosmos ecosystem chains: state machines in other ecosystems are, in many cases, implemented in Rust, and thus there are probably libraries used in their light client implementations for which there is no equivalent in Go. This makes the development of a light client in Go very difficult, but relatively simple to do it in Rust. Therefore, writing a CosmWasm smart contract in Rust that implements the light client algorithm becomes a lower effort.