设置授权方
Wasm 轻客户端字节码的存储以及现有 Wasm 轻客户端合约的迁移都属于受权限控制的操作(即仅允许治理等授权方执行)。指定的授权方会在实例化08-wasm 的 keeper 时设置:NewKeeperWithVM 和 NewKeeperWithConfig 两个构造函数都接收一个 authority 参数,该参数必须是被授权执行者的地址。例如,在 app.go 中实例化 keeper 时,可以传入治理模块的地址:
存储新的 Wasm 轻客户端字节码
如果治理是允许的授权方,那么为了上传新的轻客户端合约而提交的治理 v1 提案中,应包含消息MsgStoreCode,并附带 Wasm 合约字节码的 base64 编码。可参考以下 CLI 命令和 JSON 示例:
proposal.json 内容如下:
submit-proposal CLI 命令,请参阅 Cosmos SDK 文档中的相关章节。
另外,如果使用 CLI 命令 store-code,提交流程可能会更简单。该 CLI 命令接收 Wasm 轻客户端合约文件作为参数,并会负责构造带有 MsgStoreCode 的提案消息并进行广播。
迁移现有的 Wasm 轻客户端合约
如果治理是允许的授权方,那么为了迁移现有 Wasm 轻客户端合约而提交的治理 v1 提案中,应包含消息MsgMigrateContract,并附带要迁移到的新 Wasm 字节码的校验和。可参考以下 CLI 命令和 JSON 示例:
proposal.json 内容如下:
submit-proposal CLI 命令,请参阅 Cosmos SDK 文档中的相关章节。
删除现有校验和
如果治理是允许的授权方,那么为了从允许的校验和列表中移除某个特定校验和而提交的治理 v1 提案中,应包含消息MsgRemoveChecksum,并附带该校验和(对应某个 Wasm 字节码)。可参考以下 CLI 命令和 JSON 示例:
proposal.json 内容如下:
submit-proposal CLI 命令,请参阅 Cosmos SDK 文档中的相关章节。
Learn how to upload Wasm light client byte code on a chain, and how to migrate an existing Wasm light client contract.
Setting an authority
Both the storage of Wasm light client byte code as well as the migration of an existing Wasm light client contract are permissioned (i.e. only allowed to an authority such as governance). The designated authority is specified when instantiating08-wasm’s keeper: both NewKeeperWithVM and NewKeeperWithConfig constructor functions accept an authority argument that must be the address of the authorized actor. For example, in app.go, when instantiating the keeper, you can pass the address of the governance module:
Storing new Wasm light client byte code
If governance is the allowed authority, the governance v1 proposal that needs to be submitted to upload a new light client contract should contain the messageMsgStoreCode with the base64-encoded byte code of the Wasm contract. Use the following CLI command and JSON as an example:
proposal.json contains:
submit-proposal CLI command, please check out the relevant section in Cosmos SDK documentation.
Alternatively, the process of submitting the proposal may be simpler if you use the CLI command store-code. This CLI command accepts as argument the file of the Wasm light client contract and takes care of constructing the proposal message with MsgStoreCode and broadcasting it.
Migrating an existing Wasm light client contract
If governance is the allowed authority, the governance v1 proposal that needs to be submitted to migrate an existing new Wasm light client contract should contain the messageMsgMigrateContract with the checksum of the Wasm byte code to migrate to. Use the following CLI command and JSON as an example:
proposal.json contains:
submit-proposal CLI command, please check out the relevant section in Cosmos SDK documentation.
Removing an existing checksum
If governance is the allowed authority, the governance v1 proposal that needs to be submitted to remove a specific checksum from the list of allowed checksums should contain the messageMsgRemoveChecksum with the checksum (of a corresponding Wasm byte code). Use the following CLI command and JSON as an example:
proposal.json contains:
submit-proposal CLI command, please check out the relevant section in Cosmos SDK documentation.