From 7a5ef3ade294fc84f076f6c6a65c7ab96ac919f7 Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Wed, 12 May 2021 01:29:33 +0200 Subject: [PATCH 01/11] rebase parth changes on ibc-go and fix tests --- docs/ibc/proto-docs.md | 296 ++++ go.mod | 2 + go.sum | 5 + modules/core/02-client/keeper/client.go | 6 +- modules/core/02-client/keeper/params.go | 9 +- modules/core/02-client/types/client.pb.go | 140 +- modules/core/02-client/types/genesis_test.go | 30 +- modules/core/02-client/types/params.go | 30 +- modules/core/02-client/types/params_test.go | 4 +- modules/core/24-host/keys.go | 12 + modules/core/28-wasm/cli/cli.go | 43 + modules/core/28-wasm/cli/query.go | 83 + modules/core/28-wasm/cli/tx.go | 49 + modules/core/28-wasm/handler.go | 19 + modules/core/28-wasm/keeper/grpc_query.go | 70 + modules/core/28-wasm/keeper/keeper.go | 105 ++ modules/core/28-wasm/keeper/validation.go | 45 + modules/core/28-wasm/module.go | 28 + modules/core/28-wasm/types/codec.go | 16 + modules/core/28-wasm/types/errors.go | 8 + modules/core/28-wasm/types/keys.go | 5 + modules/core/28-wasm/types/msgs.go | 45 + modules/core/28-wasm/types/query.pb.go | 1032 +++++++++++ modules/core/28-wasm/types/query.pb.gw.go | 282 +++ modules/core/28-wasm/types/tx.pb.go | 741 ++++++++ modules/core/28-wasm/types/wasm.pb.go | 425 +++++ modules/core/client/cli/cli.go | 5 + modules/core/genesis_test.go | 6 +- modules/core/keeper/grpc_query.go | 11 + modules/core/keeper/keeper.go | 6 + modules/core/keeper/msg_server.go | 9 + modules/core/module.go | 3 + modules/core/types/codec.go | 4 + modules/core/types/query.go | 4 + .../light-clients/10-wasm/client/cli/cli.go | 25 + .../light-clients/10-wasm/client/cli/tx.go | 164 ++ modules/light-clients/10-wasm/doc.go | 1 + modules/light-clients/10-wasm/module.go | 17 + .../10-wasm/types/client_state.go | 627 +++++++ modules/light-clients/10-wasm/types/codec.go | 28 + .../10-wasm/types/consensus_state.go | 41 + modules/light-clients/10-wasm/types/errors.go | 12 + .../10-wasm/types/fail_kv_store.go | 52 + modules/light-clients/10-wasm/types/header.go | 24 + modules/light-clients/10-wasm/types/keys.go | 7 + .../10-wasm/types/misbehaviour.go | 38 + modules/light-clients/10-wasm/types/store.go | 37 + modules/light-clients/10-wasm/types/vm.go | 164 ++ .../light-clients/10-wasm/types/wasm.pb.go | 1576 +++++++++++++++++ proto/ibc/core/client/v1/client.proto | 2 + proto/ibc/core/wasm/v1/query.proto | 41 + proto/ibc/core/wasm/v1/tx.proto | 25 + proto/ibc/core/wasm/v1/wasm.proto | 12 + proto/ibc/lightclients/wasm/v1/wasm.proto | 53 + 54 files changed, 6447 insertions(+), 77 deletions(-) create mode 100644 modules/core/28-wasm/cli/cli.go create mode 100644 modules/core/28-wasm/cli/query.go create mode 100644 modules/core/28-wasm/cli/tx.go create mode 100644 modules/core/28-wasm/handler.go create mode 100644 modules/core/28-wasm/keeper/grpc_query.go create mode 100644 modules/core/28-wasm/keeper/keeper.go create mode 100644 modules/core/28-wasm/keeper/validation.go create mode 100644 modules/core/28-wasm/module.go create mode 100644 modules/core/28-wasm/types/codec.go create mode 100644 modules/core/28-wasm/types/errors.go create mode 100644 modules/core/28-wasm/types/keys.go create mode 100644 modules/core/28-wasm/types/msgs.go create mode 100644 modules/core/28-wasm/types/query.pb.go create mode 100644 modules/core/28-wasm/types/query.pb.gw.go create mode 100644 modules/core/28-wasm/types/tx.pb.go create mode 100644 modules/core/28-wasm/types/wasm.pb.go create mode 100644 modules/light-clients/10-wasm/client/cli/cli.go create mode 100644 modules/light-clients/10-wasm/client/cli/tx.go create mode 100644 modules/light-clients/10-wasm/doc.go create mode 100644 modules/light-clients/10-wasm/module.go create mode 100644 modules/light-clients/10-wasm/types/client_state.go create mode 100644 modules/light-clients/10-wasm/types/codec.go create mode 100644 modules/light-clients/10-wasm/types/consensus_state.go create mode 100644 modules/light-clients/10-wasm/types/errors.go create mode 100644 modules/light-clients/10-wasm/types/fail_kv_store.go create mode 100644 modules/light-clients/10-wasm/types/header.go create mode 100644 modules/light-clients/10-wasm/types/keys.go create mode 100644 modules/light-clients/10-wasm/types/misbehaviour.go create mode 100644 modules/light-clients/10-wasm/types/store.go create mode 100644 modules/light-clients/10-wasm/types/vm.go create mode 100644 modules/light-clients/10-wasm/types/wasm.pb.go create mode 100644 proto/ibc/core/wasm/v1/query.proto create mode 100644 proto/ibc/core/wasm/v1/tx.proto create mode 100644 proto/ibc/core/wasm/v1/wasm.proto create mode 100644 proto/ibc/lightclients/wasm/v1/wasm.proto diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index b098c732179..e809f69ba0a 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -192,6 +192,23 @@ - [ibc/core/types/v1/genesis.proto](#ibc/core/types/v1/genesis.proto) - [GenesisState](#ibc.core.types.v1.GenesisState) +- [ibc/core/wasm/v1/wasm.proto](#ibc/core/wasm/v1/wasm.proto) + - [WasmCodeEntry](#ibc.core.wasm.v1.WasmCodeEntry) + +- [ibc/core/wasm/v1/query.proto](#ibc/core/wasm/v1/query.proto) + - [LatestWASMCodeEntryQuery](#ibc.core.wasm.v1.LatestWASMCodeEntryQuery) + - [LatestWASMCodeEntryResponse](#ibc.core.wasm.v1.LatestWASMCodeEntryResponse) + - [LatestWASMCodeQuery](#ibc.core.wasm.v1.LatestWASMCodeQuery) + - [LatestWASMCodeResponse](#ibc.core.wasm.v1.LatestWASMCodeResponse) + + - [Query](#ibc.core.wasm.v1.Query) + +- [ibc/core/wasm/v1/tx.proto](#ibc/core/wasm/v1/tx.proto) + - [MsgPushNewWASMCode](#ibc.core.wasm.v1.MsgPushNewWASMCode) + - [MsgPushNewWASMCodeResponse](#ibc.core.wasm.v1.MsgPushNewWASMCodeResponse) + + - [Msg](#ibc.core.wasm.v1.Msg) + - [ibc/lightclients/localhost/v1/localhost.proto](#ibc/lightclients/localhost/v1/localhost.proto) - [ClientState](#ibc.lightclients.localhost.v1.ClientState) @@ -222,6 +239,12 @@ - [Header](#ibc.lightclients.tendermint.v1.Header) - [Misbehaviour](#ibc.lightclients.tendermint.v1.Misbehaviour) +- [ibc/lightclients/wasm/v1/wasm.proto](#ibc/lightclients/wasm/v1/wasm.proto) + - [ClientState](#ibc.lightclients.wasm.v1.ClientState) + - [ConsensusState](#ibc.lightclients.wasm.v1.ConsensusState) + - [Header](#ibc.lightclients.wasm.v1.Header) + - [Misbehaviour](#ibc.lightclients.wasm.v1.Misbehaviour) + - [Scalar Value Types](#scalar-value-types) @@ -565,6 +588,7 @@ Params defines the set of IBC light client parameters. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `allowed_clients` | [string](#string) | repeated | allowed_clients defines the list of allowed client state types. | +| `wasm_clients_enabled` | [bool](#bool) | | whether or not wasm clients are enabled | @@ -2889,6 +2913,187 @@ GenesisState defines the ibc module's genesis state. + +

Top

+ +## ibc/core/wasm/v1/wasm.proto + + + + + +### WasmCodeEntry +WASM code entry that allows keeper to traverse +the doubly linked list + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code_id` | [bytes](#bytes) | | | +| `previous_code_hash` | [string](#string) | | | +| `next_code_hash` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ +## ibc/core/wasm/v1/query.proto + + + + + +### LatestWASMCodeEntryQuery +Latest wasm code entry query + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `client_type` | [string](#string) | | | + + + + + + + + +### LatestWASMCodeEntryResponse +Latest wasm code entry response + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code_id` | [string](#string) | | | +| `entry` | [WasmCodeEntry](#ibc.core.wasm.v1.WasmCodeEntry) | | | + + + + + + + + +### LatestWASMCodeQuery +Latest wasm code query + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `client_type` | [string](#string) | | | + + + + + + + + +### LatestWASMCodeResponse +Latest wasm code response + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code` | [bytes](#bytes) | | | + + + + + + + + + + + + + + +### Query +Query service for wasm module + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `LatestWASMCode` | [LatestWASMCodeQuery](#ibc.core.wasm.v1.LatestWASMCodeQuery) | [LatestWASMCodeResponse](#ibc.core.wasm.v1.LatestWASMCodeResponse) | Query to get latest wasm code for particular client type. | GET|/ibc/core/wasm/v1beta1/latest_wasm_code/{client_type}| +| `LatestWASMCodeEntry` | [LatestWASMCodeEntryQuery](#ibc.core.wasm.v1.LatestWASMCodeEntryQuery) | [LatestWASMCodeEntryResponse](#ibc.core.wasm.v1.LatestWASMCodeEntryResponse) | Query for get latest wasm code entry for particular client type | GET|/ibc/core/wasm/v1beta1/latest_wasm_code_entry/{client_type}| + + + + + + +

Top

+ +## ibc/core/wasm/v1/tx.proto + + + + + +### MsgPushNewWASMCode +Message type to push new wasm code + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `signer` | [string](#string) | | | +| `client_type` | [string](#string) | | | +| `code` | [bytes](#bytes) | | | + + + + + + + + +### MsgPushNewWASMCodeResponse +Response in case of successful handling + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code_id` | [bytes](#bytes) | | | +| `code_hash` | [string](#string) | | | + + + + + + + + + + + + + + +### Msg +Msg defines the ibc/wasm Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `PushNewWASMCode` | [MsgPushNewWASMCode](#ibc.core.wasm.v1.MsgPushNewWASMCode) | [MsgPushNewWASMCodeResponse](#ibc.core.wasm.v1.MsgPushNewWASMCodeResponse) | PushNewWASMCode defines a rpc handler method for PushNewWASMCode. | | + + + + +

Top

@@ -3353,6 +3558,97 @@ that implements Misbehaviour interface expected by ICS-02 + + + + + + + + + + + +

Top

+ +## ibc/lightclients/wasm/v1/wasm.proto + + + + + +### ClientState +WASM light client's Client state + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `data` | [bytes](#bytes) | | | +| `code_id` | [bytes](#bytes) | | | +| `frozen` | [bool](#bool) | | | +| `frozen_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `latest_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `type` | [string](#string) | | | +| `proof_specs` | [ics23.ProofSpec](#ics23.ProofSpec) | repeated | | + + + + + + + + +### ConsensusState +WASM light client's ConsensusState + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `data` | [bytes](#bytes) | | | +| `code_id` | [bytes](#bytes) | | | +| `timestamp` | [uint64](#uint64) | | timestamp that corresponds to the block height in which the ConsensusState was stored. | +| `root` | [ibc.core.commitment.v1.MerkleRoot](#ibc.core.commitment.v1.MerkleRoot) | | commitment root (i.e app hash) | +| `type` | [string](#string) | | | + + + + + + + + +### Header +WASM light client Header + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `data` | [bytes](#bytes) | | | +| `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | +| `type` | [string](#string) | | | + + + + + + + + +### Misbehaviour +WASM light client Misbehaviour + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `code_id` | [bytes](#bytes) | | | +| `client_id` | [string](#string) | | | +| `header_1` | [Header](#ibc.lightclients.wasm.v1.Header) | | | +| `header_2` | [Header](#ibc.lightclients.wasm.v1.Header) | | | + + + + + diff --git a/go.mod b/go.mod index 233f26b718e..397f1382915 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ module github.com/cosmos/ibc-go replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 require ( + github.com/CosmWasm/wasmvm v0.13.0 github.com/armon/go-metrics v0.3.8 github.com/confio/ics23/go v0.6.6 github.com/cosmos/cosmos-sdk v0.43.0-beta1 @@ -22,4 +23,5 @@ require ( github.com/tendermint/tm-db v0.6.4 google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f google.golang.org/grpc v1.37.0 + google.golang.org/protobuf v1.26.0 // indirect ) diff --git a/go.sum b/go.sum index 3f9f99e4403..d92fdbf7464 100644 --- a/go.sum +++ b/go.sum @@ -32,6 +32,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/CosmWasm/wasmvm v0.13.0 h1:AP8LVcCxI3KLtHY24qLhzVe+ChOXwcR8MNm8Jxkuhwk= +github.com/CosmWasm/wasmvm v0.13.0/go.mod h1:Id107qllDJyJjVQQsKMOy2YYF98sqPJ2t+jX1QES40A= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= @@ -682,6 +684,7 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= @@ -699,6 +702,7 @@ github.com/tendermint/tendermint v0.34.0-rc6/go.mod h1:ugzyZO5foutZImv0Iyx/gOFCX github.com/tendermint/tendermint v0.34.0/go.mod h1:Aj3PIipBFSNO21r+Lq3TtzQ+uKESxkbA3yo/INM4QwQ= github.com/tendermint/tendermint v0.34.10 h1:wBOc/It8sh/pVH9np2V5fBvRmIyFN/bUrGPx+eAHexs= github.com/tendermint/tendermint v0.34.10/go.mod h1:aeHL7alPh4uTBIJQ8mgFEE8VwJLXI1VD3rVOmH2Mcy0= +github.com/tendermint/tm-db v0.5.1/go.mod h1:g92zWjHpCYlEvQXvy9M168Su8V1IBEeawpXVVBaK4f4= github.com/tendermint/tm-db v0.6.2/go.mod h1:GYtQ67SUvATOcoY8/+x6ylk8Qo02BQyLrAs+yAcLvGI= github.com/tendermint/tm-db v0.6.3/go.mod h1:lfA1dL9/Y/Y8wwyPp2NMLyn5P5Ptr/gvDFNWtrCWSf8= github.com/tendermint/tm-db v0.6.4 h1:3N2jlnYQkXNQclQwd/eKV/NzlqPlfK21cpRRIx80XXQ= @@ -814,6 +818,7 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= diff --git a/modules/core/02-client/keeper/client.go b/modules/core/02-client/keeper/client.go index 1ebcceadc4f..3d7e92416ab 100644 --- a/modules/core/02-client/keeper/client.go +++ b/modules/core/02-client/keeper/client.go @@ -27,15 +27,15 @@ func (k Keeper) CreateClient( clientID := k.GenerateClientIdentifier(ctx, clientState.ClientType()) - k.SetClientState(ctx, clientID, clientState) - k.Logger(ctx).Info("client created at height", "client-id", clientID, "height", clientState.GetLatestHeight().String()) - // verifies initial consensus state against client state and initializes client store with any client-specific metadata // e.g. set ProcessedTime in Tendermint clients if err := clientState.Initialize(ctx, k.cdc, k.ClientStore(ctx, clientID), consensusState); err != nil { return "", err } + k.SetClientState(ctx, clientID, clientState) + k.Logger(ctx).Info("client created at height", "client-id", clientID, "height", clientState.GetLatestHeight().String()) + // check if consensus state is nil in case the created client is Localhost if consensusState != nil { k.SetClientConsensusState(ctx, clientID, clientState.GetLatestHeight(), consensusState) diff --git a/modules/core/02-client/keeper/params.go b/modules/core/02-client/keeper/params.go index 2addf95d0df..477f54f52b2 100644 --- a/modules/core/02-client/keeper/params.go +++ b/modules/core/02-client/keeper/params.go @@ -12,9 +12,16 @@ func (k Keeper) GetAllowedClients(ctx sdk.Context) []string { return res } +// GetParams returns the total set of ibc-client parameters. +func (k Keeper) GetWasmClientsEnabled(ctx sdk.Context) bool { + var res bool + k.paramSpace.Get(ctx, types.KeyWasmClientsEnabled, &res) + return res +} + // GetParams returns the total set of ibc-client parameters. func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams(k.GetAllowedClients(ctx)...) + return types.NewParams(k.GetWasmClientsEnabled(ctx), k.GetAllowedClients(ctx)...) } // SetParams sets the total set of ibc-client parameters. diff --git a/modules/core/02-client/types/client.pb.go b/modules/core/02-client/types/client.pb.go index 99f5fe17fc3..e578b0e02e5 100644 --- a/modules/core/02-client/types/client.pb.go +++ b/modules/core/02-client/types/client.pb.go @@ -347,6 +347,8 @@ var xxx_messageInfo_Height proto.InternalMessageInfo type Params struct { // allowed_clients defines the list of allowed client state types. AllowedClients []string `protobuf:"bytes,1,rep,name=allowed_clients,json=allowedClients,proto3" json:"allowed_clients,omitempty" yaml:"allowed_clients"` + // whether or not wasm clients are enabled + WasmClientsEnabled bool `protobuf:"varint,2,opt,name=wasm_clients_enabled,json=wasmClientsEnabled,proto3" json:"wasm_clients_enabled,omitempty" yaml:"wasm_clients_enabled"` } func (m *Params) Reset() { *m = Params{} } @@ -389,6 +391,13 @@ func (m *Params) GetAllowedClients() []string { return nil } +func (m *Params) GetWasmClientsEnabled() bool { + if m != nil { + return m.WasmClientsEnabled + } + return false +} + func init() { proto.RegisterType((*IdentifiedClientState)(nil), "ibc.core.client.v1.IdentifiedClientState") proto.RegisterType((*ConsensusStateWithHeight)(nil), "ibc.core.client.v1.ConsensusStateWithHeight") @@ -402,54 +411,56 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/client.proto", fileDescriptor_b6bc4c8185546947) } var fileDescriptor_b6bc4c8185546947 = []byte{ - // 744 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x3d, 0x73, 0xd3, 0x4a, - 0x14, 0xb5, 0x1c, 0xc7, 0x13, 0xaf, 0xf3, 0xec, 0x3c, 0xc5, 0x7e, 0x71, 0xfc, 0xf2, 0x2c, 0xcf, - 0xce, 0x2b, 0x5c, 0x10, 0x09, 0x9b, 0x81, 0x61, 0xd2, 0x61, 0x37, 0x49, 0x01, 0x18, 0x31, 0x19, - 0x18, 0x1a, 0xa3, 0x8f, 0x8d, 0xbc, 0x19, 0x59, 0xeb, 0xd1, 0xae, 0x0c, 0xfe, 0x07, 0x94, 0x94, - 0x14, 0x14, 0xf9, 0x05, 0xfc, 0x0a, 0x8a, 0x94, 0x99, 0xa1, 0xa1, 0xd2, 0x30, 0x49, 0x43, 0xad, - 0x96, 0x86, 0x91, 0x76, 0xe5, 0xd8, 0x4e, 0x02, 0x0c, 0x74, 0xab, 0xbb, 0xe7, 0x9e, 0x7b, 0xcf, - 0xd9, 0xbd, 0x2b, 0xa0, 0x60, 0xd3, 0xd2, 0x2c, 0xe2, 0x23, 0xcd, 0x72, 0x31, 0xf2, 0x98, 0x36, - 0x69, 0x8b, 0x95, 0x3a, 0xf6, 0x09, 0x23, 0xb2, 0x8c, 0x4d, 0x4b, 0x8d, 0x01, 0xaa, 0x08, 0x4f, - 0xda, 0xf5, 0x8a, 0x43, 0x1c, 0x92, 0x6c, 0x6b, 0xf1, 0x8a, 0x23, 0xeb, 0xdb, 0x0e, 0x21, 0x8e, - 0x8b, 0xb4, 0xe4, 0xcb, 0x0c, 0x8e, 0x34, 0xc3, 0x9b, 0x8a, 0xad, 0xff, 0x2d, 0x42, 0x47, 0x84, - 0x6a, 0xc1, 0xd8, 0xf1, 0x0d, 0x1b, 0x69, 0x93, 0xb6, 0x89, 0x98, 0xd1, 0x4e, 0xbf, 0x39, 0x0a, - 0xbe, 0x97, 0x40, 0xf5, 0xc0, 0x46, 0x1e, 0xc3, 0x47, 0x18, 0xd9, 0xbd, 0xa4, 0xdc, 0x53, 0x66, - 0x30, 0x24, 0xb7, 0x41, 0x81, 0x57, 0x1f, 0x60, 0xbb, 0x26, 0x35, 0xa5, 0x56, 0xa1, 0x5b, 0x89, - 0x42, 0x65, 0x63, 0x6a, 0x8c, 0xdc, 0x3d, 0x38, 0xdb, 0x82, 0xfa, 0x1a, 0x5f, 0x1f, 0xd8, 0x72, - 0x1f, 0xac, 0x8b, 0x38, 0x8d, 0x29, 0x6a, 0xd9, 0xa6, 0xd4, 0x2a, 0x76, 0x2a, 0x2a, 0x6f, 0x52, - 0x4d, 0x9b, 0x54, 0x1f, 0x78, 0xd3, 0xee, 0x56, 0x14, 0x2a, 0x9b, 0x0b, 0x5c, 0x49, 0x0e, 0xd4, - 0x8b, 0xd6, 0x65, 0x13, 0xf0, 0x83, 0x04, 0x6a, 0x3d, 0xe2, 0x51, 0xe4, 0xd1, 0x80, 0x26, 0xa1, - 0x67, 0x98, 0x0d, 0xf7, 0x11, 0x76, 0x86, 0x4c, 0xbe, 0x0f, 0xf2, 0xc3, 0x64, 0x95, 0xb4, 0x57, - 0xec, 0xd4, 0xd5, 0xab, 0xbe, 0xa9, 0x1c, 0xdb, 0xcd, 0x9d, 0x86, 0x4a, 0x46, 0x17, 0x78, 0xf9, - 0x39, 0x28, 0x5b, 0x29, 0xeb, 0x2f, 0xf4, 0xba, 0x1d, 0x85, 0x4a, 0x35, 0xee, 0x15, 0x2e, 0x65, - 0x41, 0xbd, 0x64, 0x2d, 0x74, 0x07, 0x3f, 0x4a, 0xa0, 0xca, 0x5d, 0x5c, 0x6c, 0x9b, 0xfe, 0x8e, - 0x9f, 0xaf, 0xc1, 0xc6, 0x52, 0x41, 0x5a, 0xcb, 0x36, 0x57, 0x5a, 0xc5, 0xce, 0xad, 0xeb, 0xa4, - 0xde, 0x64, 0x54, 0x57, 0x89, 0xc5, 0x47, 0xa1, 0xb2, 0x25, 0x6a, 0x2d, 0x71, 0x42, 0xbd, 0xbc, - 0xa8, 0x82, 0xc2, 0x4f, 0x59, 0x50, 0xe1, 0x32, 0x0e, 0xc7, 0xb6, 0xc1, 0x50, 0xdf, 0x27, 0x63, - 0x42, 0x0d, 0x57, 0xae, 0x80, 0x55, 0x86, 0x99, 0x8b, 0xb8, 0x02, 0x9d, 0x7f, 0xc8, 0x4d, 0x50, - 0xb4, 0x11, 0xb5, 0x7c, 0x3c, 0x66, 0x98, 0x78, 0x89, 0x97, 0x05, 0x7d, 0x3e, 0x24, 0xef, 0x83, - 0xbf, 0x69, 0x60, 0x1e, 0x23, 0x8b, 0x0d, 0x2e, 0x5d, 0x58, 0x49, 0x5c, 0xd8, 0x89, 0x42, 0xa5, - 0xc6, 0x3b, 0xbb, 0x02, 0x81, 0x7a, 0x59, 0xc4, 0x7a, 0xa9, 0x29, 0x4f, 0x40, 0x85, 0x06, 0x26, - 0x65, 0x98, 0x05, 0x0c, 0xcd, 0x91, 0xe5, 0x12, 0x32, 0x25, 0x0a, 0x95, 0x7f, 0x53, 0x32, 0x6a, - 0x2e, 0xa3, 0xa0, 0x2e, 0x5f, 0x26, 0xcf, 0x28, 0x5f, 0x82, 0x12, 0xf6, 0x30, 0xc3, 0x86, 0x3b, - 0x10, 0x17, 0x6a, 0xf5, 0xa7, 0x17, 0xea, 0x3f, 0xe1, 0x69, 0x95, 0x17, 0x5b, 0xcc, 0x87, 0xfa, - 0x5f, 0x22, 0xc0, 0xd1, 0x7b, 0xb9, 0x37, 0x27, 0x4a, 0x06, 0x7e, 0x93, 0x40, 0xf9, 0x90, 0x8f, - 0xdf, 0x1f, 0x1b, 0x7a, 0x0f, 0xe4, 0xc6, 0xae, 0xe1, 0x25, 0x1e, 0x16, 0x3b, 0x3b, 0x2a, 0x9f, - 0x76, 0x35, 0x9d, 0x6e, 0x31, 0xed, 0x6a, 0xdf, 0x35, 0x3c, 0x71, 0xf9, 0x13, 0xbc, 0x7c, 0x0c, - 0xaa, 0x02, 0x63, 0x0f, 0x16, 0x86, 0x35, 0xf7, 0x83, 0x01, 0x68, 0x46, 0xa1, 0xb2, 0xc3, 0x85, - 0x5e, 0x9b, 0x0c, 0xf5, 0xcd, 0x34, 0x3e, 0xf7, 0x84, 0xec, 0xad, 0xc7, 0xaa, 0xdf, 0x9d, 0x28, - 0x99, 0xaf, 0x27, 0x8a, 0x14, 0x3f, 0x35, 0x79, 0x31, 0xb9, 0x3d, 0x50, 0xf6, 0xd1, 0x04, 0x53, - 0x4c, 0xbc, 0x81, 0x17, 0x8c, 0x4c, 0xe4, 0x27, 0xf2, 0x73, 0xdd, 0x7a, 0x14, 0x2a, 0xff, 0xf0, - 0x42, 0x4b, 0x00, 0xa8, 0x97, 0xd2, 0xc8, 0xa3, 0x24, 0xb0, 0x40, 0x22, 0x8e, 0x2d, 0x7b, 0x23, - 0x49, 0x7a, 0x2e, 0x33, 0x12, 0x71, 0x30, 0x6b, 0x69, 0x8b, 0xf0, 0x21, 0xc8, 0xf7, 0x0d, 0xdf, - 0x18, 0xd1, 0x98, 0xd8, 0x70, 0x5d, 0xf2, 0x6a, 0x26, 0x92, 0xd6, 0xa4, 0xe6, 0x4a, 0xab, 0x30, - 0x4f, 0xbc, 0x04, 0x80, 0x7a, 0x49, 0x44, 0xb8, 0x7e, 0xda, 0x7d, 0x7c, 0x7a, 0xde, 0x90, 0xce, - 0xce, 0x1b, 0xd2, 0x97, 0xf3, 0x86, 0xf4, 0xf6, 0xa2, 0x91, 0x39, 0xbb, 0x68, 0x64, 0x3e, 0x5f, - 0x34, 0x32, 0x2f, 0xee, 0x3a, 0x98, 0x0d, 0x03, 0x53, 0xb5, 0xc8, 0x48, 0x13, 0x6f, 0x34, 0x36, - 0xad, 0x5d, 0x87, 0x68, 0x23, 0x62, 0x07, 0x2e, 0xa2, 0xfc, 0xdf, 0x70, 0xbb, 0xb3, 0x2b, 0x7e, - 0x0f, 0x6c, 0x3a, 0x46, 0xd4, 0xcc, 0x27, 0x27, 0x72, 0xe7, 0x7b, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xca, 0x6e, 0xea, 0xc6, 0x3e, 0x06, 0x00, 0x00, + // 774 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x3f, 0x6f, 0xe3, 0x36, + 0x1c, 0xb5, 0x1c, 0xc7, 0x88, 0xe9, 0xd4, 0x4e, 0x15, 0xbb, 0x71, 0xdc, 0xd4, 0x32, 0x88, 0x0e, + 0x1e, 0x1a, 0xa9, 0x76, 0xd1, 0xa2, 0xc8, 0x56, 0x1b, 0x05, 0x92, 0xa5, 0x75, 0x55, 0x04, 0x2d, + 0xba, 0xb8, 0xfa, 0xc3, 0xc8, 0x0c, 0x64, 0xd1, 0x10, 0x29, 0xa7, 0xfe, 0x06, 0x1d, 0x3b, 0x76, + 0xe8, 0xe0, 0x4f, 0xd0, 0x4f, 0x71, 0x43, 0xc6, 0x00, 0xb7, 0xdc, 0x24, 0x1c, 0x92, 0xe5, 0x66, + 0xad, 0xb7, 0x1c, 0x44, 0x52, 0x8e, 0xed, 0x24, 0x77, 0x87, 0xbb, 0x8d, 0x7a, 0x7a, 0x7c, 0xbf, + 0xf7, 0x7b, 0xe4, 0x4f, 0x02, 0x1a, 0xb6, 0x1d, 0xc3, 0x21, 0x21, 0x32, 0x1c, 0x1f, 0xa3, 0x80, + 0x19, 0xb3, 0xae, 0x5c, 0xe9, 0xd3, 0x90, 0x30, 0xa2, 0xaa, 0xd8, 0x76, 0xf4, 0x94, 0xa0, 0x4b, + 0x78, 0xd6, 0x6d, 0xd6, 0x3c, 0xe2, 0x11, 0xfe, 0xda, 0x48, 0x57, 0x82, 0xd9, 0x3c, 0xf4, 0x08, + 0xf1, 0x7c, 0x64, 0xf0, 0x27, 0x3b, 0xba, 0x30, 0xac, 0x60, 0x2e, 0x5f, 0x7d, 0xe9, 0x10, 0x3a, + 0x21, 0xd4, 0x88, 0xa6, 0x5e, 0x68, 0xb9, 0xc8, 0x98, 0x75, 0x6d, 0xc4, 0xac, 0x6e, 0xf6, 0x2c, + 0x58, 0xf0, 0x3f, 0x05, 0xd4, 0xcf, 0x5c, 0x14, 0x30, 0x7c, 0x81, 0x91, 0x3b, 0xe0, 0xe5, 0x7e, + 0x65, 0x16, 0x43, 0x6a, 0x17, 0x94, 0x44, 0xf5, 0x11, 0x76, 0x1b, 0x4a, 0x5b, 0xe9, 0x94, 0xfa, + 0xb5, 0x24, 0xd6, 0xf6, 0xe6, 0xd6, 0xc4, 0x3f, 0x81, 0xcb, 0x57, 0xd0, 0xdc, 0x11, 0xeb, 0x33, + 0x57, 0x1d, 0x82, 0x5d, 0x89, 0xd3, 0x54, 0xa2, 0x91, 0x6f, 0x2b, 0x9d, 0x72, 0xaf, 0xa6, 0x0b, + 0x93, 0x7a, 0x66, 0x52, 0xff, 0x21, 0x98, 0xf7, 0x0f, 0x92, 0x58, 0xdb, 0x5f, 0xd3, 0xe2, 0x7b, + 0xa0, 0x59, 0x76, 0xee, 0x4d, 0xc0, 0xff, 0x15, 0xd0, 0x18, 0x90, 0x80, 0xa2, 0x80, 0x46, 0x94, + 0x43, 0xbf, 0x61, 0x36, 0x3e, 0x45, 0xd8, 0x1b, 0x33, 0xf5, 0x7b, 0x50, 0x1c, 0xf3, 0x15, 0xb7, + 0x57, 0xee, 0x35, 0xf5, 0x87, 0xb9, 0xe9, 0x82, 0xdb, 0x2f, 0x5c, 0xc7, 0x5a, 0xce, 0x94, 0x7c, + 0xf5, 0x77, 0x50, 0x75, 0x32, 0xd5, 0xf7, 0xf0, 0x7a, 0x98, 0xc4, 0x5a, 0x3d, 0xf5, 0x0a, 0x37, + 0x76, 0x41, 0xb3, 0xe2, 0xac, 0xb9, 0x83, 0xcf, 0x14, 0x50, 0x17, 0x29, 0xae, 0xdb, 0xa6, 0x1f, + 0x92, 0xe7, 0x5f, 0x60, 0x6f, 0xa3, 0x20, 0x6d, 0xe4, 0xdb, 0x5b, 0x9d, 0x72, 0xef, 0xab, 0xc7, + 0x5a, 0x7d, 0x2a, 0xa8, 0xbe, 0x96, 0x36, 0x9f, 0xc4, 0xda, 0x81, 0xac, 0xb5, 0xa1, 0x09, 0xcd, + 0xea, 0x7a, 0x17, 0x14, 0x3e, 0xcf, 0x83, 0x9a, 0x68, 0xe3, 0x7c, 0xea, 0x5a, 0x0c, 0x0d, 0x43, + 0x32, 0x25, 0xd4, 0xf2, 0xd5, 0x1a, 0xd8, 0x66, 0x98, 0xf9, 0x48, 0x74, 0x60, 0x8a, 0x07, 0xb5, + 0x0d, 0xca, 0x2e, 0xa2, 0x4e, 0x88, 0xa7, 0x0c, 0x93, 0x80, 0x67, 0x59, 0x32, 0x57, 0x21, 0xf5, + 0x14, 0x7c, 0x4a, 0x23, 0xfb, 0x12, 0x39, 0x6c, 0x74, 0x9f, 0xc2, 0x16, 0x4f, 0xe1, 0x28, 0x89, + 0xb5, 0x86, 0x70, 0xf6, 0x80, 0x02, 0xcd, 0xaa, 0xc4, 0x06, 0x59, 0x28, 0xbf, 0x80, 0x1a, 0x8d, + 0x6c, 0xca, 0x30, 0x8b, 0x18, 0x5a, 0x11, 0x2b, 0x70, 0x31, 0x2d, 0x89, 0xb5, 0xcf, 0x33, 0x31, + 0x6a, 0x6f, 0xb2, 0xa0, 0xa9, 0xde, 0x6f, 0x5e, 0x4a, 0xfe, 0x09, 0x2a, 0x38, 0xc0, 0x0c, 0x5b, + 0xfe, 0x48, 0x5e, 0xa8, 0xed, 0x77, 0x5e, 0xa8, 0x2f, 0x64, 0xa6, 0x75, 0x51, 0x6c, 0x7d, 0x3f, + 0x34, 0x3f, 0x91, 0x80, 0x60, 0x9f, 0x14, 0xfe, 0x5e, 0x68, 0x39, 0xf8, 0x5a, 0x01, 0xd5, 0x73, + 0x31, 0x7e, 0x1f, 0x1d, 0xe8, 0x77, 0xa0, 0x30, 0xf5, 0xad, 0x80, 0x67, 0x58, 0xee, 0x1d, 0xe9, + 0x62, 0xda, 0xf5, 0x6c, 0xba, 0xe5, 0xb4, 0xeb, 0x43, 0xdf, 0x0a, 0xe4, 0xe5, 0xe7, 0x7c, 0xf5, + 0x12, 0xd4, 0x25, 0xc7, 0x1d, 0xad, 0x0d, 0x6b, 0xe1, 0x2d, 0x03, 0xd0, 0x4e, 0x62, 0xed, 0x48, + 0x34, 0xfa, 0xe8, 0x66, 0x68, 0xee, 0x67, 0xf8, 0xca, 0x27, 0xe4, 0x64, 0x37, 0xed, 0xfa, 0xdf, + 0x85, 0x96, 0x7b, 0xb5, 0xd0, 0x94, 0xf4, 0x53, 0x53, 0x94, 0x93, 0x3b, 0x00, 0xd5, 0x10, 0xcd, + 0x30, 0xc5, 0x24, 0x18, 0x05, 0xd1, 0xc4, 0x46, 0x21, 0x6f, 0xbf, 0xd0, 0x6f, 0x26, 0xb1, 0xf6, + 0x99, 0x28, 0xb4, 0x41, 0x80, 0x66, 0x25, 0x43, 0x7e, 0xe2, 0xc0, 0x9a, 0x88, 0x3c, 0xb6, 0xfc, + 0x93, 0x22, 0xd9, 0xb9, 0x2c, 0x45, 0xe4, 0xc1, 0xec, 0x64, 0x16, 0xe1, 0x42, 0x01, 0xc5, 0xa1, + 0x15, 0x5a, 0x13, 0x9a, 0x2a, 0x5b, 0xbe, 0x4f, 0xae, 0x96, 0x5d, 0xd2, 0x86, 0xd2, 0xde, 0xea, + 0x94, 0x56, 0x95, 0x37, 0x08, 0xd0, 0xac, 0x48, 0x44, 0x04, 0x40, 0xd3, 0x7b, 0x7a, 0x65, 0xd1, + 0x49, 0x46, 0x18, 0xa1, 0xc0, 0xb2, 0x7d, 0xe4, 0x72, 0x8f, 0x3b, 0xab, 0xf7, 0xf4, 0x31, 0x16, + 0x34, 0xd5, 0x14, 0x96, 0x5a, 0x3f, 0x0a, 0xb0, 0xff, 0xf3, 0xf5, 0x6d, 0x4b, 0xb9, 0xb9, 0x6d, + 0x29, 0x2f, 0x6f, 0x5b, 0xca, 0x3f, 0x77, 0xad, 0xdc, 0xcd, 0x5d, 0x2b, 0xf7, 0xe2, 0xae, 0x95, + 0xfb, 0xe3, 0x5b, 0x0f, 0xb3, 0x71, 0x64, 0xeb, 0x0e, 0x99, 0x18, 0xf2, 0xbb, 0x8f, 0x6d, 0xe7, + 0xd8, 0x23, 0xc6, 0x84, 0xb8, 0x91, 0x8f, 0xa8, 0xf8, 0xdf, 0x7c, 0xdd, 0x3b, 0x96, 0xbf, 0x1c, + 0x36, 0x9f, 0x22, 0x6a, 0x17, 0xf9, 0x29, 0x7f, 0xf3, 0x26, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x89, + 0x45, 0x52, 0x92, 0x06, 0x00, 0x00, } func (this *UpgradeProposal) Equal(that interface{}) bool { @@ -789,6 +800,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.WasmClientsEnabled { + i-- + if m.WasmClientsEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } if len(m.AllowedClients) > 0 { for iNdEx := len(m.AllowedClients) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.AllowedClients[iNdEx]) @@ -940,6 +961,9 @@ func (m *Params) Size() (n int) { n += 1 + l + sovClient(uint64(l)) } } + if m.WasmClientsEnabled { + n += 2 + } return n } @@ -1845,6 +1869,26 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.AllowedClients = append(m.AllowedClients, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WasmClientsEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.WasmClientsEnabled = bool(v != 0) default: iNdEx = preIndex skippy, err := skipClient(dAtA[iNdEx:]) diff --git a/modules/core/02-client/types/genesis_test.go b/modules/core/02-client/types/genesis_test.go index ab2c479c6f1..1523f38f99d 100644 --- a/modules/core/02-client/types/genesis_test.go +++ b/modules/core/02-client/types/genesis_test.go @@ -101,7 +101,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, - types.NewParams(exported.Tendermint, exported.Localhost), + types.NewParams(true, exported.Tendermint, exported.Localhost), false, 2, ), @@ -132,7 +132,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(exported.Tendermint), + types.NewParams(true, exported.Tendermint), false, 0, ), @@ -149,7 +149,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, nil, nil, - types.NewParams(exported.Tendermint), + types.NewParams(true, exported.Tendermint), false, 0, ), @@ -180,7 +180,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(exported.Tendermint), + types.NewParams(true, exported.Tendermint), false, 0, ), @@ -211,7 +211,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(exported.Tendermint), + types.NewParams(true, exported.Tendermint), false, 0, ), @@ -242,7 +242,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(exported.Tendermint), + types.NewParams(true, exported.Tendermint), false, 0, ), @@ -273,7 +273,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(exported.Solomachine), + types.NewParams(true, exported.Solomachine), false, 0, ), @@ -312,7 +312,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, - types.NewParams(exported.Tendermint, exported.Localhost), + types.NewParams(true, exported.Tendermint, exported.Localhost), false, 0, ), @@ -348,7 +348,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, - types.NewParams(exported.Tendermint), + types.NewParams(true, exported.Tendermint), false, 0, ), @@ -378,7 +378,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(" "), + types.NewParams(true, " "), false, 0, ), @@ -409,7 +409,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(" "), + types.NewParams(true, " "), true, 0, ), @@ -440,7 +440,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(exported.Tendermint), + types.NewParams(true, exported.Tendermint), true, 2, ), @@ -471,7 +471,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(exported.Tendermint, exported.Localhost), + types.NewParams(true, exported.Tendermint, exported.Localhost), false, 0, ), @@ -502,7 +502,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(exported.Tendermint, exported.Localhost), + types.NewParams(true, exported.Tendermint, exported.Localhost), false, 5, ), @@ -530,7 +530,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(exported.Tendermint, exported.Localhost), + types.NewParams(true, exported.Tendermint, exported.Localhost), false, 5, ), diff --git a/modules/core/02-client/types/params.go b/modules/core/02-client/types/params.go index 6460a3fcde5..c606757cad8 100644 --- a/modules/core/02-client/types/params.go +++ b/modules/core/02-client/types/params.go @@ -10,10 +10,14 @@ import ( var ( // DefaultAllowedClients are "06-solomachine" and "07-tendermint" - DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint} + DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint, "wasm_dummy"} + + DefaultWASMClientEnabled = false // KeyAllowedClients is store's key for AllowedClients Params KeyAllowedClients = []byte("AllowedClients") + + KeyWasmClientsEnabled = []byte("WasmClientsEnabled") ) // ParamKeyTable type declaration for parameters @@ -22,26 +26,33 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new parameter configuration for the ibc client module -func NewParams(allowedClients ...string) Params { +func NewParams(wasmClientAllowed bool, allowedClients ...string) Params { return Params{ - AllowedClients: allowedClients, + WasmClientsEnabled: wasmClientAllowed, + AllowedClients: allowedClients, } } // DefaultParams is the default parameter configuration for the ibc-client module func DefaultParams() Params { - return NewParams(DefaultAllowedClients...) + return NewParams(DefaultWASMClientEnabled, DefaultAllowedClients...) } // Validate all ibc-client module parameters func (p Params) Validate() error { - return validateClients(p.AllowedClients) + err := validateClients(p.AllowedClients) + if err != nil { + return err + } + + return validateWasmClientEnabledFlag(p.WasmClientsEnabled) } // ParamSetPairs implements params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyAllowedClients, p.AllowedClients, validateClients), + paramtypes.NewParamSetPair(KeyWasmClientsEnabled, p.WasmClientsEnabled, validateWasmClientEnabledFlag), } } @@ -55,6 +66,15 @@ func (p Params) IsAllowedClient(clientType string) bool { return false } +func validateWasmClientEnabledFlag(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} + func validateClients(i interface{}) error { clients, ok := i.([]string) if !ok { diff --git a/modules/core/02-client/types/params_test.go b/modules/core/02-client/types/params_test.go index 1f3d0571b36..d826fe8efdb 100644 --- a/modules/core/02-client/types/params_test.go +++ b/modules/core/02-client/types/params_test.go @@ -15,8 +15,8 @@ func TestValidateParams(t *testing.T) { expPass bool }{ {"default params", DefaultParams(), true}, - {"custom params", NewParams(exported.Tendermint), true}, - {"blank client", NewParams(" "), false}, + {"custom params", NewParams(true, exported.Tendermint), true}, + {"blank client", NewParams(false, " "), false}, } for _, tc := range testCases { diff --git a/modules/core/24-host/keys.go b/modules/core/24-host/keys.go index ec07af5452f..483dbcedd2b 100644 --- a/modules/core/24-host/keys.go +++ b/modules/core/24-host/keys.go @@ -233,3 +233,15 @@ func sequencePath(sequence uint64) string { func PortPath(portID string) string { return fmt.Sprintf("%s/%s", KeyPortPrefix, portID) } + +func LatestWASMCode(clientType string) []byte { + return []byte(fmt.Sprintf("%s/latest", clientType)) +} + +func WASMCode(clientType string, hash string) []byte { + return []byte(fmt.Sprintf("%s/%s", clientType, hash)) +} + +func WASMCodeEntry(clientType string, codeID string) []byte { + return []byte(fmt.Sprintf("%s/%s/entry", clientType, codeID)) +} diff --git a/modules/core/28-wasm/cli/cli.go b/modules/core/28-wasm/cli/cli.go new file mode 100644 index 00000000000..ba5ccd34fcc --- /dev/null +++ b/modules/core/28-wasm/cli/cli.go @@ -0,0 +1,43 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/ibc-go/modules/core/28-wasm/types" + "github.com/spf13/cobra" +) + +// GetQueryCmd returns the query commands for IBC channels +func GetQueryCmd() *cobra.Command { + queryCmd := &cobra.Command{ + Use: types.SubModuleName, + Short: "IBC wasm manager module query subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + queryCmd.AddCommand( + GetCmdQueryLatestWASMCode(), + GetCmdQueryLatestWASMCodeEntry(), + ) + + return queryCmd +} + +// NewTxCmd returns a CLI command handler for all x/ibc channel transaction commands. +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.SubModuleName, + Short: "IBC wasm manager module transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + NewPushNewWASMCodeCmd(), + ) + + return txCmd +} + diff --git a/modules/core/28-wasm/cli/query.go b/modules/core/28-wasm/cli/query.go new file mode 100644 index 00000000000..dbf77cdb1ad --- /dev/null +++ b/modules/core/28-wasm/cli/query.go @@ -0,0 +1,83 @@ +package cli + +import ( + "context" + "fmt" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + host "github.com/cosmos/ibc-go/modules/core/24-host" + "github.com/cosmos/ibc-go/modules/core/28-wasm/types" + "github.com/spf13/cobra" +) + + +// GetCmdQueryLatestWASMCode defines the command to query latest wasm code +// uploaded for that client type +func GetCmdQueryLatestWASMCode() *cobra.Command { + cmd := &cobra.Command{ + Use: "wasm_code client_type", + Short: "Query latest wasm code", + Long: "Query latest wasm code for particular client type", + Example: fmt.Sprintf("%s query %s %s wasm_code client_type", version.AppName, host.ModuleName, types.SubModuleName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + clientType := args[0] + req := types.LatestWASMCodeQuery{ + ClientType: clientType, + } + + res, err := queryClient.LatestWASMCode(context.Background(), &req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// GetCmdQueryLatestWASMCodeEntry defines the command to query latest wasm code's entry +// for that client type +func GetCmdQueryLatestWASMCodeEntry() *cobra.Command { + cmd := &cobra.Command{ + Use: "wasm_code_entry client_type", + Short: "Query wasm code entry", + Long: "Query latest wasm code entry", + Example: fmt.Sprintf( + "%s query %s %s wasm_code_entry client_type", version.AppName, host.ModuleName, types.SubModuleName, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + clientType := args[0] + req := types.LatestWASMCodeEntryQuery{ + ClientType: clientType, + } + + res, err := queryClient.LatestWASMCodeEntry(context.Background(), &req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/modules/core/28-wasm/cli/tx.go b/modules/core/28-wasm/cli/tx.go new file mode 100644 index 00000000000..2e15955ceb4 --- /dev/null +++ b/modules/core/28-wasm/cli/tx.go @@ -0,0 +1,49 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/ibc-go/modules/core/28-wasm/types" + "github.com/spf13/cobra" + "io/ioutil" +) + +// NewPushNewWASMCodeCmd returns the command to create a PushNewWASMCode transaction +func NewPushNewWASMCodeCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "push_wasm client_type wasm_file", + Short: "Reads wasm code from the file and creates push transaction", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + clientType := args[0] + fileName := args[1] + + code, err := ioutil.ReadFile(fileName) + if err != nil { + return err + } + + msg := &types.MsgPushNewWASMCode{ + ClientType: clientType, + Code: code, + Signer: clientCtx.GetFromAddress().String(), + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/modules/core/28-wasm/handler.go b/modules/core/28-wasm/handler.go new file mode 100644 index 00000000000..70d4b2d7e21 --- /dev/null +++ b/modules/core/28-wasm/handler.go @@ -0,0 +1,19 @@ +package wasm + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/ibc-go/modules/core/28-wasm/keeper" + "github.com/cosmos/ibc-go/modules/core/28-wasm/types" +) + +func HandleMsgPushNewWASMCode(ctx sdk.Context, k keeper.Keeper, msg *types.MsgPushNewWASMCode) (*types.MsgPushNewWASMCodeResponse, error) { + if codeId, codeHash, err := k.PushNewWASMCode(ctx, msg.ClientType, msg.Code); err != nil { + return nil, sdkerrors.Wrap(err, "pushing new wasm code failed") + } else { + return &types.MsgPushNewWASMCodeResponse{ + CodeId: codeId, + CodeHash: codeHash, + }, nil + } +} diff --git a/modules/core/28-wasm/keeper/grpc_query.go b/modules/core/28-wasm/keeper/grpc_query.go new file mode 100644 index 00000000000..607ac16933c --- /dev/null +++ b/modules/core/28-wasm/keeper/grpc_query.go @@ -0,0 +1,70 @@ +package keeper + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + sdk "github.com/cosmos/cosmos-sdk/types" + host "github.com/cosmos/ibc-go/modules/core/24-host" + "github.com/cosmos/ibc-go/modules/core/28-wasm/types" +) + +var _ types.QueryServer = (*Keeper)(nil) + +func (q Keeper) LatestWASMCode(c context.Context, query *types.LatestWASMCodeQuery) (*types.LatestWASMCodeResponse, error) { + if query == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if query.ClientType == "" { + return nil, status.Error(codes.InvalidArgument, "empty client type string") + } + + clientType := query.ClientType + + ctx := sdk.UnwrapSDKContext(c) + store := ctx.KVStore(q.storeKey) + + latestCodeKey := host.LatestWASMCode(clientType) + latestCodeId := store.Get(latestCodeKey) + if latestCodeId == nil { + return nil, status.Error(codes.NotFound, "no code has been uploaded till now.") + } + + return &types.LatestWASMCodeResponse{ + Code: store.Get(host.WASMCode(clientType, string(latestCodeId))), + }, nil +} + +func (q Keeper) LatestWASMCodeEntry(c context.Context, query *types.LatestWASMCodeEntryQuery) (*types.LatestWASMCodeEntryResponse, error) { + if query == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if query.ClientType == "" { + return nil, status.Error(codes.InvalidArgument, "empty client type string") + } + + clientType := query.ClientType + + ctx := sdk.UnwrapSDKContext(c) + store := ctx.KVStore(q.storeKey) + latestCodeKey := host.LatestWASMCode(clientType) + latestCodeId := store.Get(latestCodeKey) + if latestCodeId == nil { + return nil, status.Error(codes.NotFound, "no code has been uploaded till now.") + } + + bz := store.Get(host.WASMCodeEntry(clientType, string(latestCodeId))) + var entry types.WasmCodeEntry + if err := q.cdc.Unmarshal(bz, &entry); err != nil { + return nil, status.Error(codes.Internal, "internal error") + } + + return &types.LatestWASMCodeEntryResponse{ + CodeId: string(latestCodeId), + Entry: &entry, + }, nil +} diff --git a/modules/core/28-wasm/keeper/keeper.go b/modules/core/28-wasm/keeper/keeper.go new file mode 100644 index 00000000000..f6f98f22df8 --- /dev/null +++ b/modules/core/28-wasm/keeper/keeper.go @@ -0,0 +1,105 @@ +package keeper + +import ( + "fmt" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + host "github.com/cosmos/ibc-go/modules/core/24-host" + + wasm "github.com/CosmWasm/wasmvm" + + "github.com/cosmos/ibc-go/modules/core/28-wasm/types" + + "crypto/sha256" + "encoding/hex" +) + +// WASM VM initialized by wasm keeper +var WasmVM *wasm.VM + +func generateWASMCodeHash(code []byte) string { + hash := sha256.Sum256(code) + return hex.EncodeToString(hash[:]) +} + +// Keeper will have a reference to Wasmer with it's own data directory. +type Keeper struct { + storeKey sdk.StoreKey + cdc codec.BinaryCodec + wasmValidator *WASMValidator +} + +func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, validationConfig *WASMValidationConfig) Keeper { + // TODO: Make this configurable + vm, err := wasm.NewVM("wasm_data", "staking", 8, true, 8) + if err != nil { + panic(err) + } + + wasmValidator, err := NewWASMValidator(validationConfig, func() (*wasm.VM, error) { + return wasm.NewVM("wasm_test_data", "staking", 8, true, 8) + }) + if err != nil { + panic(err) + } + + WasmVM = vm + + return Keeper{ + cdc: cdc, + storeKey: key, + wasmValidator: wasmValidator, + } +} + +func (k Keeper) PushNewWASMCode(ctx sdk.Context, clientType string, code []byte) ([]byte, string, error) { + store := ctx.KVStore(k.storeKey) + codeHash := generateWASMCodeHash(code) + + latestVersionKey := host.LatestWASMCode(clientType) + + if isValidWASMCode, err := k.wasmValidator.validateWASMCode(code); err != nil { + return nil, "", fmt.Errorf("unable to validate wasm code, error: %s", err) + } else { + if !isValidWASMCode { + return nil, "", fmt.Errorf("invalid wasm code") + } + } + + codeId, err := WasmVM.Create(code) + if err != nil { + return nil, "", fmt.Errorf("invalid wasm code") + } + + codekey := host.WASMCode(clientType, codeHash) + entryKey := host.WASMCodeEntry(clientType, codeHash) + + latestVersionCodeHash := store.Get(latestVersionKey) + + // More careful management of doubly linked list can lift this constraint + // But we do not see any significant advantage of it. + if store.Has(entryKey) { + return nil, "", fmt.Errorf("wasm code already exists") + } else { + codeEntry := types.WasmCodeEntry{ + PreviousCodeHash: string(latestVersionCodeHash), + NextCodeHash: "", + CodeId: codeId, + } + + previousVersionEntryKey := host.WASMCodeEntry(clientType, string(latestVersionCodeHash)) + previousVersionEntryBz := store.Get(previousVersionEntryKey) + if len(previousVersionEntryBz) != 0 { + var previousEntry types.WasmCodeEntry + k.cdc.MustUnmarshal(previousVersionEntryBz, &previousEntry) + previousEntry.NextCodeHash = codeHash + store.Set(previousVersionEntryKey, k.cdc.MustMarshal(&previousEntry)) + } + + store.Set(entryKey, k.cdc.MustMarshal(&codeEntry)) + store.Set(latestVersionKey, []byte(codeHash)) + store.Set(codekey, code) + } + + return codeId, codeHash, nil +} diff --git a/modules/core/28-wasm/keeper/validation.go b/modules/core/28-wasm/keeper/validation.go new file mode 100644 index 00000000000..d32e20be068 --- /dev/null +++ b/modules/core/28-wasm/keeper/validation.go @@ -0,0 +1,45 @@ +package keeper + +import cosmwasm "github.com/CosmWasm/wasmvm" + +// Basic validation config can be extended to add other configuration later +type WASMValidationConfig struct { + MaxSizeAllowed int +} + +func NewWASMValidator(config *WASMValidationConfig, vmCreateFn func () (*cosmwasm.VM, error)) (*WASMValidator, error) { + return &WASMValidator{ + config: config, + vmCreateFn: vmCreateFn, + }, nil +} + +type WASMValidator struct { + vmCreateFn func () (*cosmwasm.VM, error) + config *WASMValidationConfig +} + +func (v *WASMValidator) validateWASMCode(code []byte) (bool, error) { + if len(code) > v.config.MaxSizeAllowed { + return false, nil + } + + testVm, err := v.vmCreateFn() + if err != nil { + return false, err + } + + _, err = testVm.Create(code) + if err != nil { + return false, nil + } + + // Validation start + + // Validation ends + + testVm.Cleanup() + return true, nil +} + + diff --git a/modules/core/28-wasm/module.go b/modules/core/28-wasm/module.go new file mode 100644 index 00000000000..1d448d93fe1 --- /dev/null +++ b/modules/core/28-wasm/module.go @@ -0,0 +1,28 @@ +package wasm + +import ( + "github.com/cosmos/ibc-go/modules/core/28-wasm/cli" + "github.com/cosmos/ibc-go/modules/core/28-wasm/types" + "github.com/gogo/protobuf/grpc" + "github.com/spf13/cobra" +) + +// Name returns the IBC channel ICS name. +func Name() string { + return "wasm" +} + +// GetTxCmd returns the root tx command for IBC channels. +func GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +// GetQueryCmd returns the root query command for IBC channels. +func GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// RegisterQueryService registers the gRPC query service for IBC channels. +func RegisterQueryService(server grpc.Server, queryServer types.QueryServer) { + types.RegisterQueryServer(server, queryServer) +} diff --git a/modules/core/28-wasm/types/codec.go b/modules/core/28-wasm/types/codec.go new file mode 100644 index 00000000000..96402eb4ed0 --- /dev/null +++ b/modules/core/28-wasm/types/codec.go @@ -0,0 +1,16 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgPushNewWASMCode{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/modules/core/28-wasm/types/errors.go b/modules/core/28-wasm/types/errors.go new file mode 100644 index 00000000000..a1bc81c9f5d --- /dev/null +++ b/modules/core/28-wasm/types/errors.go @@ -0,0 +1,8 @@ +package types + +import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + +var ( + ErrEmptyClientType = sdkerrors.Register(SubModuleName, 2, "empty client type") + ErrEmptyWASMCode = sdkerrors.Register(SubModuleName, 3, "empty wasm code") +) \ No newline at end of file diff --git a/modules/core/28-wasm/types/keys.go b/modules/core/28-wasm/types/keys.go new file mode 100644 index 00000000000..b90e2860e19 --- /dev/null +++ b/modules/core/28-wasm/types/keys.go @@ -0,0 +1,5 @@ +package types + +const ( + SubModuleName = "wasm-manager" +) diff --git a/modules/core/28-wasm/types/msgs.go b/modules/core/28-wasm/types/msgs.go new file mode 100644 index 00000000000..e231b4f59db --- /dev/null +++ b/modules/core/28-wasm/types/msgs.go @@ -0,0 +1,45 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + host "github.com/cosmos/ibc-go/modules/core/24-host" +) + +var _ sdk.Msg = &MsgPushNewWASMCode{} + +func (m *MsgPushNewWASMCode) Route() string { + return host.RouterKey +} + +func (m *MsgPushNewWASMCode) Type() string { + return "wasm_push_new_code" +} + +func (m *MsgPushNewWASMCode) ValidateBasic() error { + if len(m.ClientType) == 0 { + return sdkerrors.Wrapf(ErrEmptyClientType, + "empty client type", + ) + } + + if len(m.Code) == 0 { + return sdkerrors.Wrapf(ErrEmptyWASMCode, + "empty wasm code", + ) + } + + return nil +} + +func (m *MsgPushNewWASMCode) GetSignBytes() []byte { + panic("IBC messages do not support amino") +} + +func (m *MsgPushNewWASMCode) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(m.Signer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{signer} +} diff --git a/modules/core/28-wasm/types/query.pb.go b/modules/core/28-wasm/types/query.pb.go new file mode 100644 index 00000000000..74ea456f62f --- /dev/null +++ b/modules/core/28-wasm/types/query.pb.go @@ -0,0 +1,1032 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/wasm/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Latest wasm code query +type LatestWASMCodeQuery struct { + ClientType string `protobuf:"bytes,1,opt,name=client_type,json=clientType,proto3" json:"client_type,omitempty"` +} + +func (m *LatestWASMCodeQuery) Reset() { *m = LatestWASMCodeQuery{} } +func (m *LatestWASMCodeQuery) String() string { return proto.CompactTextString(m) } +func (*LatestWASMCodeQuery) ProtoMessage() {} +func (*LatestWASMCodeQuery) Descriptor() ([]byte, []int) { + return fileDescriptor_482bc5ce660a9729, []int{0} +} +func (m *LatestWASMCodeQuery) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LatestWASMCodeQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LatestWASMCodeQuery.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LatestWASMCodeQuery) XXX_Merge(src proto.Message) { + xxx_messageInfo_LatestWASMCodeQuery.Merge(m, src) +} +func (m *LatestWASMCodeQuery) XXX_Size() int { + return m.Size() +} +func (m *LatestWASMCodeQuery) XXX_DiscardUnknown() { + xxx_messageInfo_LatestWASMCodeQuery.DiscardUnknown(m) +} + +var xxx_messageInfo_LatestWASMCodeQuery proto.InternalMessageInfo + +func (m *LatestWASMCodeQuery) GetClientType() string { + if m != nil { + return m.ClientType + } + return "" +} + +// Latest wasm code response +type LatestWASMCodeResponse struct { + Code []byte `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` +} + +func (m *LatestWASMCodeResponse) Reset() { *m = LatestWASMCodeResponse{} } +func (m *LatestWASMCodeResponse) String() string { return proto.CompactTextString(m) } +func (*LatestWASMCodeResponse) ProtoMessage() {} +func (*LatestWASMCodeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_482bc5ce660a9729, []int{1} +} +func (m *LatestWASMCodeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LatestWASMCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LatestWASMCodeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LatestWASMCodeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_LatestWASMCodeResponse.Merge(m, src) +} +func (m *LatestWASMCodeResponse) XXX_Size() int { + return m.Size() +} +func (m *LatestWASMCodeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_LatestWASMCodeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_LatestWASMCodeResponse proto.InternalMessageInfo + +func (m *LatestWASMCodeResponse) GetCode() []byte { + if m != nil { + return m.Code + } + return nil +} + +// Latest wasm code entry query +type LatestWASMCodeEntryQuery struct { + ClientType string `protobuf:"bytes,1,opt,name=client_type,json=clientType,proto3" json:"client_type,omitempty"` +} + +func (m *LatestWASMCodeEntryQuery) Reset() { *m = LatestWASMCodeEntryQuery{} } +func (m *LatestWASMCodeEntryQuery) String() string { return proto.CompactTextString(m) } +func (*LatestWASMCodeEntryQuery) ProtoMessage() {} +func (*LatestWASMCodeEntryQuery) Descriptor() ([]byte, []int) { + return fileDescriptor_482bc5ce660a9729, []int{2} +} +func (m *LatestWASMCodeEntryQuery) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LatestWASMCodeEntryQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LatestWASMCodeEntryQuery.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LatestWASMCodeEntryQuery) XXX_Merge(src proto.Message) { + xxx_messageInfo_LatestWASMCodeEntryQuery.Merge(m, src) +} +func (m *LatestWASMCodeEntryQuery) XXX_Size() int { + return m.Size() +} +func (m *LatestWASMCodeEntryQuery) XXX_DiscardUnknown() { + xxx_messageInfo_LatestWASMCodeEntryQuery.DiscardUnknown(m) +} + +var xxx_messageInfo_LatestWASMCodeEntryQuery proto.InternalMessageInfo + +func (m *LatestWASMCodeEntryQuery) GetClientType() string { + if m != nil { + return m.ClientType + } + return "" +} + +// Latest wasm code entry response +type LatestWASMCodeEntryResponse struct { + CodeId string `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + Entry *WasmCodeEntry `protobuf:"bytes,2,opt,name=entry,proto3" json:"entry,omitempty"` +} + +func (m *LatestWASMCodeEntryResponse) Reset() { *m = LatestWASMCodeEntryResponse{} } +func (m *LatestWASMCodeEntryResponse) String() string { return proto.CompactTextString(m) } +func (*LatestWASMCodeEntryResponse) ProtoMessage() {} +func (*LatestWASMCodeEntryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_482bc5ce660a9729, []int{3} +} +func (m *LatestWASMCodeEntryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LatestWASMCodeEntryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LatestWASMCodeEntryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LatestWASMCodeEntryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_LatestWASMCodeEntryResponse.Merge(m, src) +} +func (m *LatestWASMCodeEntryResponse) XXX_Size() int { + return m.Size() +} +func (m *LatestWASMCodeEntryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_LatestWASMCodeEntryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_LatestWASMCodeEntryResponse proto.InternalMessageInfo + +func (m *LatestWASMCodeEntryResponse) GetCodeId() string { + if m != nil { + return m.CodeId + } + return "" +} + +func (m *LatestWASMCodeEntryResponse) GetEntry() *WasmCodeEntry { + if m != nil { + return m.Entry + } + return nil +} + +func init() { + proto.RegisterType((*LatestWASMCodeQuery)(nil), "ibc.core.wasm.v1.LatestWASMCodeQuery") + proto.RegisterType((*LatestWASMCodeResponse)(nil), "ibc.core.wasm.v1.LatestWASMCodeResponse") + proto.RegisterType((*LatestWASMCodeEntryQuery)(nil), "ibc.core.wasm.v1.LatestWASMCodeEntryQuery") + proto.RegisterType((*LatestWASMCodeEntryResponse)(nil), "ibc.core.wasm.v1.LatestWASMCodeEntryResponse") +} + +func init() { proto.RegisterFile("ibc/core/wasm/v1/query.proto", fileDescriptor_482bc5ce660a9729) } + +var fileDescriptor_482bc5ce660a9729 = []byte{ + // 415 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0x4c, 0x4a, 0xd6, + 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4f, 0x2c, 0xce, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, + 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xc8, 0x4c, 0x4a, 0xd6, 0x03, 0xc9, + 0xea, 0x81, 0x64, 0xf5, 0xca, 0x0c, 0xa5, 0xa4, 0x31, 0xd4, 0x83, 0x65, 0xc0, 0xca, 0xa5, 0x64, + 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, + 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0x21, 0xb2, 0x4a, 0x66, 0x5c, 0xc2, 0x3e, 0x89, 0x25, 0xa9, + 0xc5, 0x25, 0xe1, 0x8e, 0xc1, 0xbe, 0xce, 0xf9, 0x29, 0xa9, 0x81, 0x20, 0x9b, 0x84, 0xe4, 0xb9, + 0xb8, 0x93, 0x73, 0x32, 0x53, 0xf3, 0x4a, 0xe2, 0x4b, 0x2a, 0x0b, 0x52, 0x25, 0x18, 0x15, 0x18, + 0x35, 0x38, 0x83, 0xb8, 0x20, 0x42, 0x21, 0x95, 0x05, 0xa9, 0x4a, 0x3a, 0x5c, 0x62, 0xa8, 0xfa, + 0x82, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0x84, 0xb8, 0x58, 0x92, 0xf3, 0x53, 0x20, + 0x7a, 0x78, 0x82, 0xc0, 0x6c, 0x25, 0x6b, 0x2e, 0x09, 0x54, 0xd5, 0xae, 0x79, 0x25, 0x45, 0x95, + 0x44, 0x5a, 0x95, 0xcb, 0x25, 0x8d, 0x45, 0x33, 0xdc, 0x3e, 0x71, 0x2e, 0x76, 0x90, 0x1d, 0xf1, + 0x99, 0x29, 0x50, 0xbd, 0x6c, 0x20, 0xae, 0x67, 0x8a, 0x90, 0x29, 0x17, 0x6b, 0x2a, 0x48, 0xa5, + 0x04, 0x93, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0xbc, 0x1e, 0x7a, 0xb8, 0xe9, 0x85, 0x27, 0x16, 0xe7, + 0x22, 0x0c, 0x84, 0xa8, 0x36, 0x7a, 0xc4, 0xc4, 0xc5, 0x0a, 0x71, 0xd9, 0x02, 0x46, 0x2e, 0x3e, + 0x54, 0x9b, 0x85, 0x54, 0x31, 0x0d, 0xc1, 0x12, 0x7c, 0x52, 0x1a, 0x84, 0x94, 0xc1, 0x5c, 0xaf, + 0x64, 0xdb, 0x74, 0xf9, 0xc9, 0x64, 0x26, 0x73, 0x21, 0x53, 0x7d, 0xf4, 0x38, 0x4c, 0x4a, 0x2d, + 0x49, 0x34, 0xd4, 0xcf, 0x01, 0x6b, 0x8b, 0x07, 0x89, 0xc5, 0x83, 0xfc, 0xa5, 0x5f, 0x8d, 0x14, + 0x58, 0xb5, 0x42, 0x5b, 0x19, 0xd1, 0xe3, 0x0f, 0xec, 0x17, 0x21, 0x2d, 0x42, 0x0e, 0x40, 0x44, + 0x80, 0x94, 0x2e, 0x51, 0x6a, 0xe1, 0x2e, 0x76, 0x06, 0xbb, 0xd8, 0x56, 0xc8, 0x9a, 0x48, 0x17, + 0xc7, 0x83, 0x83, 0x15, 0xd5, 0xdd, 0x4e, 0xbe, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, + 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, + 0xc7, 0x10, 0x65, 0x9c, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9c, + 0x5f, 0x9c, 0x9b, 0x5f, 0x0c, 0xb2, 0x47, 0x37, 0x3d, 0x5f, 0x3f, 0x37, 0x3f, 0xa5, 0x34, 0x27, + 0xb5, 0x18, 0x62, 0xa5, 0x91, 0x85, 0x2e, 0xd8, 0x56, 0x90, 0x71, 0xc5, 0x49, 0x6c, 0xe0, 0xc4, + 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xbc, 0xe8, 0x2d, 0x39, 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Query to get latest wasm code for particular client type. + LatestWASMCode(ctx context.Context, in *LatestWASMCodeQuery, opts ...grpc.CallOption) (*LatestWASMCodeResponse, error) + // Query for get latest wasm code entry for particular client type + LatestWASMCodeEntry(ctx context.Context, in *LatestWASMCodeEntryQuery, opts ...grpc.CallOption) (*LatestWASMCodeEntryResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) LatestWASMCode(ctx context.Context, in *LatestWASMCodeQuery, opts ...grpc.CallOption) (*LatestWASMCodeResponse, error) { + out := new(LatestWASMCodeResponse) + err := c.cc.Invoke(ctx, "/ibc.core.wasm.v1.Query/LatestWASMCode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) LatestWASMCodeEntry(ctx context.Context, in *LatestWASMCodeEntryQuery, opts ...grpc.CallOption) (*LatestWASMCodeEntryResponse, error) { + out := new(LatestWASMCodeEntryResponse) + err := c.cc.Invoke(ctx, "/ibc.core.wasm.v1.Query/LatestWASMCodeEntry", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Query to get latest wasm code for particular client type. + LatestWASMCode(context.Context, *LatestWASMCodeQuery) (*LatestWASMCodeResponse, error) + // Query for get latest wasm code entry for particular client type + LatestWASMCodeEntry(context.Context, *LatestWASMCodeEntryQuery) (*LatestWASMCodeEntryResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) LatestWASMCode(ctx context.Context, req *LatestWASMCodeQuery) (*LatestWASMCodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LatestWASMCode not implemented") +} +func (*UnimplementedQueryServer) LatestWASMCodeEntry(ctx context.Context, req *LatestWASMCodeEntryQuery) (*LatestWASMCodeEntryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LatestWASMCodeEntry not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_LatestWASMCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LatestWASMCodeQuery) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).LatestWASMCode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.wasm.v1.Query/LatestWASMCode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).LatestWASMCode(ctx, req.(*LatestWASMCodeQuery)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_LatestWASMCodeEntry_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LatestWASMCodeEntryQuery) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).LatestWASMCodeEntry(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.wasm.v1.Query/LatestWASMCodeEntry", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).LatestWASMCodeEntry(ctx, req.(*LatestWASMCodeEntryQuery)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.wasm.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "LatestWASMCode", + Handler: _Query_LatestWASMCode_Handler, + }, + { + MethodName: "LatestWASMCodeEntry", + Handler: _Query_LatestWASMCodeEntry_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/wasm/v1/query.proto", +} + +func (m *LatestWASMCodeQuery) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LatestWASMCodeQuery) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LatestWASMCodeQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ClientType) > 0 { + i -= len(m.ClientType) + copy(dAtA[i:], m.ClientType) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LatestWASMCodeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LatestWASMCodeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LatestWASMCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LatestWASMCodeEntryQuery) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LatestWASMCodeEntryQuery) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LatestWASMCodeEntryQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ClientType) > 0 { + i -= len(m.ClientType) + copy(dAtA[i:], m.ClientType) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LatestWASMCodeEntryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LatestWASMCodeEntryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LatestWASMCodeEntryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Entry != nil { + { + size, err := m.Entry.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.CodeId) > 0 { + i -= len(m.CodeId) + copy(dAtA[i:], m.CodeId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CodeId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *LatestWASMCodeQuery) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientType) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *LatestWASMCodeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Code) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *LatestWASMCodeEntryQuery) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientType) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *LatestWASMCodeEntryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CodeId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Entry != nil { + l = m.Entry.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *LatestWASMCodeQuery) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LatestWASMCodeQuery: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LatestWASMCodeQuery: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LatestWASMCodeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LatestWASMCodeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LatestWASMCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = append(m.Code[:0], dAtA[iNdEx:postIndex]...) + if m.Code == nil { + m.Code = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LatestWASMCodeEntryQuery) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LatestWASMCodeEntryQuery: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LatestWASMCodeEntryQuery: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LatestWASMCodeEntryResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LatestWASMCodeEntryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LatestWASMCodeEntryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entry", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Entry == nil { + m.Entry = &WasmCodeEntry{} + } + if err := m.Entry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/28-wasm/types/query.pb.gw.go b/modules/core/28-wasm/types/query.pb.gw.go new file mode 100644 index 00000000000..d74319801a8 --- /dev/null +++ b/modules/core/28-wasm/types/query.pb.gw.go @@ -0,0 +1,282 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: ibc/core/wasm/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +func request_Query_LatestWASMCode_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LatestWASMCodeQuery + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_type"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_type") + } + + protoReq.ClientType, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_type", err) + } + + msg, err := client.LatestWASMCode(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_LatestWASMCode_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LatestWASMCodeQuery + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_type"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_type") + } + + protoReq.ClientType, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_type", err) + } + + msg, err := server.LatestWASMCode(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_LatestWASMCodeEntry_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LatestWASMCodeEntryQuery + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_type"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_type") + } + + protoReq.ClientType, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_type", err) + } + + msg, err := client.LatestWASMCodeEntry(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_LatestWASMCodeEntry_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LatestWASMCodeEntryQuery + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_type"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_type") + } + + protoReq.ClientType, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_type", err) + } + + msg, err := server.LatestWASMCodeEntry(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_LatestWASMCode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_LatestWASMCode_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_LatestWASMCode_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LatestWASMCodeEntry_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_LatestWASMCodeEntry_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_LatestWASMCodeEntry_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_LatestWASMCode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_LatestWASMCode_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_LatestWASMCode_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LatestWASMCodeEntry_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_LatestWASMCodeEntry_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_LatestWASMCodeEntry_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_LatestWASMCode_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "wasm", "v1beta1", "latest_wasm_code", "client_type"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_LatestWASMCodeEntry_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "wasm", "v1beta1", "latest_wasm_code_entry", "client_type"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_LatestWASMCode_0 = runtime.ForwardResponseMessage + + forward_Query_LatestWASMCodeEntry_0 = runtime.ForwardResponseMessage +) diff --git a/modules/core/28-wasm/types/tx.pb.go b/modules/core/28-wasm/types/tx.pb.go new file mode 100644 index 00000000000..e28c961cc8b --- /dev/null +++ b/modules/core/28-wasm/types/tx.pb.go @@ -0,0 +1,741 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/wasm/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Message type to push new wasm code +type MsgPushNewWASMCode struct { + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + ClientType string `protobuf:"bytes,2,opt,name=client_type,json=clientType,proto3" json:"client_type,omitempty"` + Code []byte `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` +} + +func (m *MsgPushNewWASMCode) Reset() { *m = MsgPushNewWASMCode{} } +func (m *MsgPushNewWASMCode) String() string { return proto.CompactTextString(m) } +func (*MsgPushNewWASMCode) ProtoMessage() {} +func (*MsgPushNewWASMCode) Descriptor() ([]byte, []int) { + return fileDescriptor_e7804a9f49664df6, []int{0} +} +func (m *MsgPushNewWASMCode) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPushNewWASMCode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPushNewWASMCode.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPushNewWASMCode) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPushNewWASMCode.Merge(m, src) +} +func (m *MsgPushNewWASMCode) XXX_Size() int { + return m.Size() +} +func (m *MsgPushNewWASMCode) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPushNewWASMCode.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPushNewWASMCode proto.InternalMessageInfo + +func (m *MsgPushNewWASMCode) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +func (m *MsgPushNewWASMCode) GetClientType() string { + if m != nil { + return m.ClientType + } + return "" +} + +func (m *MsgPushNewWASMCode) GetCode() []byte { + if m != nil { + return m.Code + } + return nil +} + +// Response in case of successful handling +type MsgPushNewWASMCodeResponse struct { + CodeId []byte `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + CodeHash string `protobuf:"bytes,2,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty"` +} + +func (m *MsgPushNewWASMCodeResponse) Reset() { *m = MsgPushNewWASMCodeResponse{} } +func (m *MsgPushNewWASMCodeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPushNewWASMCodeResponse) ProtoMessage() {} +func (*MsgPushNewWASMCodeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e7804a9f49664df6, []int{1} +} +func (m *MsgPushNewWASMCodeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPushNewWASMCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPushNewWASMCodeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPushNewWASMCodeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPushNewWASMCodeResponse.Merge(m, src) +} +func (m *MsgPushNewWASMCodeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPushNewWASMCodeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPushNewWASMCodeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPushNewWASMCodeResponse proto.InternalMessageInfo + +func (m *MsgPushNewWASMCodeResponse) GetCodeId() []byte { + if m != nil { + return m.CodeId + } + return nil +} + +func (m *MsgPushNewWASMCodeResponse) GetCodeHash() string { + if m != nil { + return m.CodeHash + } + return "" +} + +func init() { + proto.RegisterType((*MsgPushNewWASMCode)(nil), "ibc.core.wasm.v1.MsgPushNewWASMCode") + proto.RegisterType((*MsgPushNewWASMCodeResponse)(nil), "ibc.core.wasm.v1.MsgPushNewWASMCodeResponse") +} + +func init() { proto.RegisterFile("ibc/core/wasm/v1/tx.proto", fileDescriptor_e7804a9f49664df6) } + +var fileDescriptor_e7804a9f49664df6 = []byte{ + // 313 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xb1, 0x4e, 0x3a, 0x41, + 0x10, 0xc6, 0xb9, 0x3f, 0xff, 0xa0, 0xac, 0x24, 0x9a, 0x8d, 0x51, 0xc4, 0xe4, 0x24, 0xc4, 0x82, + 0x42, 0x76, 0x03, 0x34, 0xb6, 0x6a, 0xa3, 0xc5, 0x19, 0x73, 0x9a, 0x98, 0xd8, 0x90, 0xbb, 0xbd, + 0xc9, 0xde, 0x26, 0x1c, 0x73, 0x61, 0x0e, 0x90, 0xb7, 0xf0, 0xb1, 0x2c, 0x29, 0x2d, 0x0d, 0xbc, + 0x88, 0xd9, 0x05, 0x1b, 0x68, 0xec, 0x66, 0xe6, 0xf7, 0x25, 0xdf, 0xcc, 0x7c, 0xec, 0xcc, 0xc4, + 0x4a, 0x2a, 0x1c, 0x83, 0x9c, 0x45, 0x94, 0xc9, 0x69, 0x57, 0x16, 0xef, 0x22, 0x1f, 0x63, 0x81, + 0xfc, 0xc8, 0xc4, 0x4a, 0x58, 0x24, 0x2c, 0x12, 0xd3, 0x6e, 0xe3, 0x58, 0xa3, 0x46, 0x07, 0xa5, + 0xad, 0xd6, 0xba, 0x56, 0xc4, 0x78, 0x40, 0xfa, 0x69, 0x42, 0xe9, 0x23, 0xcc, 0x5e, 0x6f, 0x9e, + 0x83, 0x3b, 0x4c, 0x80, 0x9f, 0xb0, 0x0a, 0x19, 0x3d, 0x82, 0x71, 0xdd, 0x6b, 0x7a, 0xed, 0x6a, + 0xb8, 0xe9, 0xf8, 0x05, 0x3b, 0x50, 0x43, 0x03, 0xa3, 0x62, 0x50, 0xcc, 0x73, 0xa8, 0xff, 0x73, + 0x90, 0xad, 0x47, 0x2f, 0xf3, 0x1c, 0x38, 0x67, 0xff, 0x15, 0x26, 0x50, 0x2f, 0x37, 0xbd, 0x76, + 0x2d, 0x74, 0x75, 0x2b, 0x64, 0x8d, 0x5d, 0x8b, 0x10, 0x28, 0xc7, 0x11, 0x01, 0x3f, 0x65, 0x7b, + 0x56, 0x35, 0x30, 0x89, 0xf3, 0xaa, 0x85, 0x15, 0xdb, 0x3e, 0x24, 0xfc, 0x9c, 0x55, 0x1d, 0x48, + 0x23, 0x4a, 0x37, 0x4e, 0xfb, 0x76, 0x70, 0x1f, 0x51, 0xda, 0x1b, 0xb2, 0x72, 0x40, 0x9a, 0x03, + 0x3b, 0xdc, 0x5e, 0xfd, 0x52, 0x6c, 0x5f, 0x2e, 0x76, 0xdd, 0x1b, 0x57, 0x7f, 0x51, 0xfd, 0xee, + 0x78, 0x1b, 0x7c, 0x2e, 0x7d, 0x6f, 0xb1, 0xf4, 0xbd, 0xef, 0xa5, 0xef, 0x7d, 0xac, 0xfc, 0xd2, + 0x62, 0xe5, 0x97, 0xbe, 0x56, 0x7e, 0xe9, 0xad, 0xaf, 0x4d, 0x91, 0x4e, 0x62, 0xa1, 0x30, 0x93, + 0x0a, 0x29, 0x43, 0x92, 0x26, 0x56, 0x1d, 0x8d, 0x32, 0xc3, 0x64, 0x32, 0x04, 0x5a, 0xc7, 0xd3, + 0xbb, 0xee, 0xb8, 0x84, 0xec, 0xd7, 0x28, 0xae, 0xb8, 0xd7, 0xf7, 0x7f, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x63, 0x5f, 0x84, 0xbb, 0xbf, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // PushNewWASMCode defines a rpc handler method for PushNewWASMCode. + PushNewWASMCode(ctx context.Context, in *MsgPushNewWASMCode, opts ...grpc.CallOption) (*MsgPushNewWASMCodeResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) PushNewWASMCode(ctx context.Context, in *MsgPushNewWASMCode, opts ...grpc.CallOption) (*MsgPushNewWASMCodeResponse, error) { + out := new(MsgPushNewWASMCodeResponse) + err := c.cc.Invoke(ctx, "/ibc.core.wasm.v1.Msg/PushNewWASMCode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // PushNewWASMCode defines a rpc handler method for PushNewWASMCode. + PushNewWASMCode(context.Context, *MsgPushNewWASMCode) (*MsgPushNewWASMCodeResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) PushNewWASMCode(ctx context.Context, req *MsgPushNewWASMCode) (*MsgPushNewWASMCodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PushNewWASMCode not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_PushNewWASMCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPushNewWASMCode) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PushNewWASMCode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.wasm.v1.Msg/PushNewWASMCode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PushNewWASMCode(ctx, req.(*MsgPushNewWASMCode)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.wasm.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PushNewWASMCode", + Handler: _Msg_PushNewWASMCode_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/wasm/v1/tx.proto", +} + +func (m *MsgPushNewWASMCode) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPushNewWASMCode) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPushNewWASMCode) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintTx(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0x1a + } + if len(m.ClientType) > 0 { + i -= len(m.ClientType) + copy(dAtA[i:], m.ClientType) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientType))) + i-- + dAtA[i] = 0x12 + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgPushNewWASMCodeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPushNewWASMCodeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPushNewWASMCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CodeHash) > 0 { + i -= len(m.CodeHash) + copy(dAtA[i:], m.CodeHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.CodeHash))) + i-- + dAtA[i] = 0x12 + } + if len(m.CodeId) > 0 { + i -= len(m.CodeId) + copy(dAtA[i:], m.CodeId) + i = encodeVarintTx(dAtA, i, uint64(len(m.CodeId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgPushNewWASMCode) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ClientType) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Code) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgPushNewWASMCodeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CodeId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.CodeHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgPushNewWASMCode) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPushNewWASMCode: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPushNewWASMCode: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = append(m.Code[:0], dAtA[iNdEx:postIndex]...) + if m.Code == nil { + m.Code = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPushNewWASMCodeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPushNewWASMCodeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPushNewWASMCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeId = append(m.CodeId[:0], dAtA[iNdEx:postIndex]...) + if m.CodeId == nil { + m.CodeId = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/28-wasm/types/wasm.pb.go b/modules/core/28-wasm/types/wasm.pb.go new file mode 100644 index 00000000000..b3e84a58647 --- /dev/null +++ b/modules/core/28-wasm/types/wasm.pb.go @@ -0,0 +1,425 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/wasm/v1/wasm.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// WASM code entry that allows keeper to traverse +// the doubly linked list +type WasmCodeEntry struct { + CodeId []byte `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + PreviousCodeHash string `protobuf:"bytes,2,opt,name=previous_code_hash,json=previousCodeHash,proto3" json:"previous_code_hash,omitempty"` + NextCodeHash string `protobuf:"bytes,3,opt,name=next_code_hash,json=nextCodeHash,proto3" json:"next_code_hash,omitempty"` +} + +func (m *WasmCodeEntry) Reset() { *m = WasmCodeEntry{} } +func (m *WasmCodeEntry) String() string { return proto.CompactTextString(m) } +func (*WasmCodeEntry) ProtoMessage() {} +func (*WasmCodeEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_8e445a743f39a2b3, []int{0} +} +func (m *WasmCodeEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WasmCodeEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WasmCodeEntry.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *WasmCodeEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_WasmCodeEntry.Merge(m, src) +} +func (m *WasmCodeEntry) XXX_Size() int { + return m.Size() +} +func (m *WasmCodeEntry) XXX_DiscardUnknown() { + xxx_messageInfo_WasmCodeEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_WasmCodeEntry proto.InternalMessageInfo + +func (m *WasmCodeEntry) GetCodeId() []byte { + if m != nil { + return m.CodeId + } + return nil +} + +func (m *WasmCodeEntry) GetPreviousCodeHash() string { + if m != nil { + return m.PreviousCodeHash + } + return "" +} + +func (m *WasmCodeEntry) GetNextCodeHash() string { + if m != nil { + return m.NextCodeHash + } + return "" +} + +func init() { + proto.RegisterType((*WasmCodeEntry)(nil), "ibc.core.wasm.v1.WasmCodeEntry") +} + +func init() { proto.RegisterFile("ibc/core/wasm/v1/wasm.proto", fileDescriptor_8e445a743f39a2b3) } + +var fileDescriptor_8e445a743f39a2b3 = []byte{ + // 234 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xce, 0x4c, 0x4a, 0xd6, + 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4f, 0x2c, 0xce, 0xd5, 0x2f, 0x33, 0x04, 0xd3, 0x7a, 0x05, + 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x02, 0x99, 0x49, 0xc9, 0x7a, 0x20, 0x49, 0x3d, 0xb0, 0x60, 0x99, + 0xa1, 0x52, 0x0d, 0x17, 0x6f, 0x78, 0x62, 0x71, 0xae, 0x73, 0x7e, 0x4a, 0xaa, 0x6b, 0x5e, 0x49, + 0x51, 0xa5, 0x90, 0x38, 0x17, 0x7b, 0x72, 0x7e, 0x4a, 0x6a, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, + 0xa3, 0x06, 0x4f, 0x10, 0x1b, 0x88, 0xeb, 0x99, 0x22, 0xa4, 0xc3, 0x25, 0x54, 0x50, 0x94, 0x5a, + 0x96, 0x99, 0x5f, 0x5a, 0x1c, 0x0f, 0x56, 0x91, 0x91, 0x58, 0x9c, 0x21, 0xc1, 0xa4, 0xc0, 0xa8, + 0xc1, 0x19, 0x24, 0x00, 0x93, 0x01, 0x99, 0xe3, 0x91, 0x58, 0x9c, 0x21, 0xa4, 0xc2, 0xc5, 0x97, + 0x97, 0x5a, 0x51, 0x82, 0xa4, 0x92, 0x19, 0xac, 0x92, 0x07, 0x24, 0x0a, 0x53, 0xe5, 0xe4, 0x7b, + 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, + 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xc6, 0xe9, 0x99, 0x25, 0x19, 0xa5, + 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x99, 0x49, 0xc9, + 0xba, 0xe9, 0xf9, 0xfa, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, 0xc5, 0x10, 0x3f, 0x1a, 0x59, 0xe8, + 0x82, 0xbd, 0x59, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, 0xa5, 0x31, 0x20, 0x00, 0x00, + 0xff, 0xff, 0x81, 0x4f, 0x94, 0xcd, 0x04, 0x01, 0x00, 0x00, +} + +func (m *WasmCodeEntry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *WasmCodeEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WasmCodeEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NextCodeHash) > 0 { + i -= len(m.NextCodeHash) + copy(dAtA[i:], m.NextCodeHash) + i = encodeVarintWasm(dAtA, i, uint64(len(m.NextCodeHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.PreviousCodeHash) > 0 { + i -= len(m.PreviousCodeHash) + copy(dAtA[i:], m.PreviousCodeHash) + i = encodeVarintWasm(dAtA, i, uint64(len(m.PreviousCodeHash))) + i-- + dAtA[i] = 0x12 + } + if len(m.CodeId) > 0 { + i -= len(m.CodeId) + copy(dAtA[i:], m.CodeId) + i = encodeVarintWasm(dAtA, i, uint64(len(m.CodeId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintWasm(dAtA []byte, offset int, v uint64) int { + offset -= sovWasm(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *WasmCodeEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CodeId) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + l = len(m.PreviousCodeHash) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + l = len(m.NextCodeHash) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + return n +} + +func sovWasm(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozWasm(x uint64) (n int) { + return sovWasm(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *WasmCodeEntry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: WasmCodeEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WasmCodeEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeId = append(m.CodeId[:0], dAtA[iNdEx:postIndex]...) + if m.CodeId == nil { + m.CodeId = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PreviousCodeHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PreviousCodeHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextCodeHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NextCodeHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWasm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWasm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipWasm(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWasm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWasm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWasm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthWasm + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupWasm + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthWasm + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthWasm = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowWasm = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupWasm = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/client/cli/cli.go b/modules/core/client/cli/cli.go index 687806b1c15..a8fc11bc1f5 100644 --- a/modules/core/client/cli/cli.go +++ b/modules/core/client/cli/cli.go @@ -4,6 +4,8 @@ import ( "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" + wasmmanager "github.com/cosmos/ibc-go/modules/core/28-wasm" + wasm "github.com/cosmos/ibc-go/modules/light-clients/10-wasm" ibcclient "github.com/cosmos/ibc-go/modules/core/02-client" connection "github.com/cosmos/ibc-go/modules/core/03-connection" channel "github.com/cosmos/ibc-go/modules/core/04-channel" @@ -23,6 +25,8 @@ func GetTxCmd() *cobra.Command { ibcTxCmd.AddCommand( ibcclient.GetTxCmd(), channel.GetTxCmd(), + wasmmanager.GetTxCmd(), + wasm.GetTxCmd(), ) return ibcTxCmd @@ -43,6 +47,7 @@ func GetQueryCmd() *cobra.Command { ibcclient.GetQueryCmd(), connection.GetQueryCmd(), channel.GetQueryCmd(), + wasmmanager.GetQueryCmd(), ) return ibcQueryCmd diff --git a/modules/core/genesis_test.go b/modules/core/genesis_test.go index 5873440dc4b..34d1e8e443e 100644 --- a/modules/core/genesis_test.go +++ b/modules/core/genesis_test.go @@ -105,7 +105,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { }, ), }, - clienttypes.NewParams(exported.Tendermint, exported.Localhost), + clienttypes.NewParams(true, exported.Tendermint, exported.Localhost), true, 2, ), @@ -173,7 +173,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { }, ), }, - clienttypes.NewParams(exported.Tendermint), + clienttypes.NewParams(true, exported.Tendermint), false, 2, ), @@ -269,7 +269,7 @@ func (suite *IBCTestSuite) TestInitGenesis() { }, ), }, - clienttypes.NewParams(exported.Tendermint, exported.Localhost), + clienttypes.NewParams(true, exported.Tendermint, exported.Localhost), true, 0, ), diff --git a/modules/core/keeper/grpc_query.go b/modules/core/keeper/grpc_query.go index f647ab5aceb..30406f4a0df 100644 --- a/modules/core/keeper/grpc_query.go +++ b/modules/core/keeper/grpc_query.go @@ -3,6 +3,7 @@ package keeper import ( "context" + wasmtypes "github.com/cosmos/ibc-go/modules/core/28-wasm/types" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" @@ -132,3 +133,13 @@ func (q Keeper) UnreceivedAcks(c context.Context, req *channeltypes.QueryUnrecei func (q Keeper) NextSequenceReceive(c context.Context, req *channeltypes.QueryNextSequenceReceiveRequest) (*channeltypes.QueryNextSequenceReceiveResponse, error) { return q.ChannelKeeper.NextSequenceReceive(c, req) } + +// LatestWASMCode implements the IBC QueryServer interface +func (q Keeper) LatestWASMCode(c context.Context, req *wasmtypes.LatestWASMCodeQuery) (*wasmtypes.LatestWASMCodeResponse, error) { + return q.WasmKeeper.LatestWASMCode(c, req) +} + +// LatestWASMCodeEntry implements the IBC QueryServer interface +func (q Keeper) LatestWASMCodeEntry(c context.Context, req *wasmtypes.LatestWASMCodeEntryQuery) (*wasmtypes.LatestWASMCodeEntryResponse, error) { + return q.WasmKeeper.LatestWASMCodeEntry(c, req) +} diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 164fecfcd23..5a80f0507a3 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -12,6 +12,7 @@ import ( channelkeeper "github.com/cosmos/ibc-go/modules/core/04-channel/keeper" portkeeper "github.com/cosmos/ibc-go/modules/core/05-port/keeper" porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types" + wasmkeeper "github.com/cosmos/ibc-go/modules/core/28-wasm/keeper" "github.com/cosmos/ibc-go/modules/core/types" ) @@ -28,6 +29,7 @@ type Keeper struct { ConnectionKeeper connectionkeeper.Keeper ChannelKeeper channelkeeper.Keeper PortKeeper portkeeper.Keeper + WasmKeeper wasmkeeper.Keeper Router *porttypes.Router } @@ -49,6 +51,9 @@ func NewKeeper( connectionKeeper := connectionkeeper.NewKeeper(cdc, key, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper(scopedKeeper) channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) + wasmKeeper := wasmkeeper.NewKeeper(cdc, key, &wasmkeeper.WASMValidationConfig{ + MaxSizeAllowed: 1024 * 1024, + }) return &Keeper{ cdc: cdc, @@ -56,6 +61,7 @@ func NewKeeper( ConnectionKeeper: connectionKeeper, ChannelKeeper: channelKeeper, PortKeeper: portKeeper, + WasmKeeper: wasmKeeper, } } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 2edcdd157c2..c91c635708d 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -8,6 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + wasm "github.com/cosmos/ibc-go/modules/core/28-wasm" + wasmtypes "github.com/cosmos/ibc-go/modules/core/28-wasm/types" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types" channel "github.com/cosmos/ibc-go/modules/core/04-channel" @@ -18,6 +20,13 @@ import ( var _ clienttypes.MsgServer = Keeper{} var _ connectiontypes.MsgServer = Keeper{} var _ channeltypes.MsgServer = Keeper{} +var _ wasmtypes.MsgServer = Keeper{} + +// PushNewWASMCode defines a rpc handler method for MsgPushNewWASMCode +func (k Keeper) PushNewWASMCode(goCtx context.Context, msg *wasmtypes.MsgPushNewWASMCode) (*wasmtypes.MsgPushNewWASMCodeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + return wasm.HandleMsgPushNewWASMCode(ctx, k.WasmKeeper, msg) +} // CreateClient defines a rpc handler method for MsgCreateClient. func (k Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateClient) (*clienttypes.MsgCreateClientResponse, error) { diff --git a/modules/core/module.go b/modules/core/module.go index 1d338dcb69e..3d12190bd21 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -18,6 +18,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + wasmtypes "github.com/cosmos/ibc-go/modules/core/28-wasm/types" ibcclient "github.com/cosmos/ibc-go/modules/core/02-client" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types" @@ -72,6 +73,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r clienttypes.RegisterQueryHandlerClient(context.Background(), mux, clienttypes.NewQueryClient(clientCtx)) connectiontypes.RegisterQueryHandlerClient(context.Background(), mux, connectiontypes.NewQueryClient(clientCtx)) channeltypes.RegisterQueryHandlerClient(context.Background(), mux, channeltypes.NewQueryClient(clientCtx)) + wasmtypes.RegisterQueryHandlerClient(context.Background(), mux, wasmtypes.NewQueryClient(clientCtx)) } // GetTxCmd returns the root tx command for the ibc module. @@ -135,6 +137,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { clienttypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) + wasmtypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) types.RegisterQueryService(cfg.QueryServer(), am.keeper) } diff --git a/modules/core/types/codec.go b/modules/core/types/codec.go index 83aa034d35b..82593e1d1ce 100644 --- a/modules/core/types/codec.go +++ b/modules/core/types/codec.go @@ -2,6 +2,8 @@ package types import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" + wasmmanagertypes "github.com/cosmos/ibc-go/modules/core/28-wasm/types" + wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" @@ -17,7 +19,9 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { connectiontypes.RegisterInterfaces(registry) channeltypes.RegisterInterfaces(registry) solomachinetypes.RegisterInterfaces(registry) + wasmtypes.RegisterInterfaces(registry) ibctmtypes.RegisterInterfaces(registry) localhosttypes.RegisterInterfaces(registry) commitmenttypes.RegisterInterfaces(registry) + wasmmanagertypes.RegisterInterfaces(registry) } diff --git a/modules/core/types/query.go b/modules/core/types/query.go index a4a4bd5448c..838f447a925 100644 --- a/modules/core/types/query.go +++ b/modules/core/types/query.go @@ -3,6 +3,8 @@ package types import ( "github.com/gogo/protobuf/grpc" + wasm "github.com/cosmos/ibc-go/modules/core/28-wasm" + wasmtypes "github.com/cosmos/ibc-go/modules/core/28-wasm/types" client "github.com/cosmos/ibc-go/modules/core/02-client" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" connection "github.com/cosmos/ibc-go/modules/core/03-connection" @@ -16,6 +18,7 @@ type QueryServer interface { clienttypes.QueryServer connectiontypes.QueryServer channeltypes.QueryServer + wasmtypes.QueryServer } // RegisterQueryService registers each individual IBC submodule query service @@ -23,4 +26,5 @@ func RegisterQueryService(server grpc.Server, queryService QueryServer) { client.RegisterQueryService(server, queryService) connection.RegisterQueryService(server, queryService) channel.RegisterQueryService(server, queryService) + wasm.RegisterQueryService(server, queryService) } diff --git a/modules/light-clients/10-wasm/client/cli/cli.go b/modules/light-clients/10-wasm/client/cli/cli.go new file mode 100644 index 00000000000..2773dfb0fb7 --- /dev/null +++ b/modules/light-clients/10-wasm/client/cli/cli.go @@ -0,0 +1,25 @@ +package cli + +import ( + "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types" + "github.com/spf13/cobra" + +) + +// NewTxCmd returns a root CLI command handler for all x/ibc/light-clients/07-tendermint transaction commands. +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.SubModuleName, + Short: "WASM client transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + } + + txCmd.AddCommand( + NewCreateClientCmd(), + NewUpdateClientCmd(), + NewSubmitMisbehaviourCmd(), + ) + + return txCmd +} diff --git a/modules/light-clients/10-wasm/client/cli/tx.go b/modules/light-clients/10-wasm/client/cli/tx.go new file mode 100644 index 00000000000..9f3f16b3737 --- /dev/null +++ b/modules/light-clients/10-wasm/client/cli/tx.go @@ -0,0 +1,164 @@ +package cli + +import ( + "bytes" + "encoding/json" + "fmt" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/version" + clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" + "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "io/ioutil" +) + +func NewCreateClientCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create [CodeID in hex] [path/to/consensus_state.bin] [path/to/client_state.bin]", + Short: "create new wasm client", + Long: "Create a new wasm IBC client", + Example: fmt.Sprintf("%s tx ibc %s create [path/to/consensus_state.json] [path/to/client_state.json]", version.AppName, types.SubModuleName), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + clientStateBytes, err := ioutil.ReadFile(args[1]) + if err != nil { + return errors.Wrap(err, "error reading client state from file") + } + + clientState := types.ClientState{} + if err := json.Unmarshal(clientStateBytes, &clientState); err != nil { + return errors.Wrap(err, "error unmarshalling client state") + } + + consensusStateBytes, err := ioutil.ReadFile(args[2]) + if err != nil { + return errors.Wrap(err, "error reading consensus state from file") + } + + consensusState := types.ConsensusState{} + if err := json.Unmarshal(consensusStateBytes, &consensusState); err != nil { + return errors.Wrap(err, "error unmarshalling consensus state") + } + + if bytes.Compare(clientState.CodeId, consensusState.CodeId) != 0 { + return fmt.Errorf("CodeId mismatch between client state and consensus state") + } + + msg, err := clienttypes.NewMsgCreateClient( + &clientState, &consensusState, clientCtx.GetFromAddress().String(), + ) + if err != nil { + return errors.Wrap(err, "error composing MsgCreateClient") + } + + if err := msg.ValidateBasic(); err != nil { + return errors.Wrap(err, "error validating MsgCreateClient") + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func NewUpdateClientCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update [client-id] [Code Id in hex] [path/to/header.bin]", + Short: "update existing client with a header", + Long: "update existing wasm client with a header", + Example: fmt.Sprintf( + "$ %s tx ibc %s update [client-id] [path/to/header.json] --from node0 --home ../node0/cli --chain-id $CID", + version.AppName, types.SubModuleName, + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + clientID := args[0] + + headerBytes, err := ioutil.ReadFile(args[2]) + if err != nil { + return errors.Wrap(err, "error reading header from file") + } + + header := types.Header{} + if err := json.Unmarshal(headerBytes, &header); err != nil { + return errors.Wrap(err, "error unmarshalling header") + } + + msg, err := clienttypes.NewMsgUpdateClient(clientID, &header, clientCtx.GetFromAddress().String()) + if err != nil { + return errors.Wrap(err, "error composing MsgUpdateClient") + } + + if err := msg.ValidateBasic(); err != nil { + return errors.Wrap(err, "error validating MsgUpdateClient") + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func NewSubmitMisbehaviourCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "misbehaviour [client-Id] [path/to/misbehaviour.json]", + Short: "submit a client misbehaviour", + Long: "submit a client misbehaviour to invalidate to invalidate previous state roots and prevent future updates", + Example: fmt.Sprintf( + "$ %s tx ibc %s misbehaviour [client-Id] [path/to/misbehaviour.json] --from node0 --home ../node0/cli --chain-id $CID", + version.AppName, types.SubModuleName, + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + clientID := args[0] + + misbehaviourBytes, err := ioutil.ReadFile(args[2]) + if err != nil { + return errors.Wrap(err, "error reading header1 from file") + } + + misbehaviour := types.Misbehaviour{} + if err := json.Unmarshal(misbehaviourBytes, &misbehaviour); err != nil { + return errors.Wrap(err, "error unmarshalling misbehaviour") + } + misbehaviour.ClientId = clientID + + msg, err := clienttypes.NewMsgSubmitMisbehaviour(misbehaviour.ClientId, &misbehaviour, clientCtx.GetFromAddress().String()) + if err != nil { + return errors.Wrap(err, "error composing MsgSubmitMisbehaviour") + } + + if err := msg.ValidateBasic(); err != nil { + return errors.Wrap(err, "error validating MsgSubmitMisbehaviour") + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/modules/light-clients/10-wasm/doc.go b/modules/light-clients/10-wasm/doc.go new file mode 100644 index 00000000000..955e5a9a88b --- /dev/null +++ b/modules/light-clients/10-wasm/doc.go @@ -0,0 +1 @@ +package wasm diff --git a/modules/light-clients/10-wasm/module.go b/modules/light-clients/10-wasm/module.go new file mode 100644 index 00000000000..8542ac935f4 --- /dev/null +++ b/modules/light-clients/10-wasm/module.go @@ -0,0 +1,17 @@ +package wasm + +import ( + "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/client/cli" + "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types" + "github.com/spf13/cobra" +) + +// Name returns the IBC client name +func Name() string { + return types.SubModuleName +} + +// GetTxCmd returns the root tx command for the IBC client +func GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} diff --git a/modules/light-clients/10-wasm/types/client_state.go b/modules/light-clients/10-wasm/types/client_state.go new file mode 100644 index 00000000000..953ba068043 --- /dev/null +++ b/modules/light-clients/10-wasm/types/client_state.go @@ -0,0 +1,627 @@ +package types + +import ( + "encoding/json" + "fmt" + "github.com/CosmWasm/wasmvm/api" + ics23 "github.com/confio/ics23/go" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" + "github.com/cosmos/ibc-go/modules/core/exported" +) + +func (c *ClientState) Initialize(context sdk.Context, marshaler codec.BinaryCodec, store sdk.KVStore, state exported.ConsensusState) error { + const InitializeState = "initializestate" + payload := make(map[string]map[string]interface{}) + payload[InitializeState] = make(map[string]interface{}) + inner := payload[InitializeState] + inner["me"] = c + inner["consensus_state"] = state + + encodedData, err := json.Marshal(payload) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + + // Under the hood there are two calls to wasm contract for initialization as by design + // cosmwasm does not allow init call to return any value. + + _, err = initContract(c.CodeId, context, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToInit, fmt.Sprintf("underlying error: %s", err.Error())) + } + + out, err := callContract(c.CodeId, context, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToCall, fmt.Sprintf("underlying error: %s", err.Error())) + } + output := clientStateCallResponse{} + if err := json.Unmarshal(out.Data, &output); err != nil { + return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + if !output.Result.IsValid { + return fmt.Errorf("%s error ocurred while initializing client state", output.Result.ErrorMsg) + } + output.resetImmutables(c) + + *c = *output.Me + return nil +} + +func (c *ClientState) CheckHeaderAndUpdateState(context sdk.Context, marshaler codec.BinaryCodec, store sdk.KVStore, header exported.Header) (exported.ClientState, exported.ConsensusState, error) { + consensusState, err := GetConsensusState(store, marshaler, c.LatestHeight) + if err != nil { + return nil, nil, sdkerrors.Wrapf(err, "could not get trusted consensus state from clientStore for Header at Height: %s", header.GetHeight()) + } + + const CheckHeaderAndUpdateState = "checkheaderandupdatestate" + payload := make(map[string]map[string]interface{}) + payload[CheckHeaderAndUpdateState] = make(map[string]interface{}) + inner := payload[CheckHeaderAndUpdateState] + inner["me"] = c + inner["header"] = header + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return nil, nil, sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + out, err := callContract(c.CodeId, context, store, encodedData) + if err != nil { + return nil, nil, sdkerrors.Wrapf(ErrUnableToCall, fmt.Sprintf("underlying error: %s", err.Error())) + } + output := clientStateCallResponse{} + if err := json.Unmarshal(out.Data, &output); err != nil { + return nil, nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + if !output.Result.IsValid { + return nil, nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) + } + output.resetImmutables(c) + return output.NewClientState, output.NewConsensusState, nil +} + +func (c *ClientState) CheckMisbehaviourAndUpdateState(context sdk.Context, marshaler codec.BinaryCodec, store sdk.KVStore, misbehaviour exported.Misbehaviour) (exported.ClientState, error) { + wasmMisbehaviour, ok := misbehaviour.(*Misbehaviour) + if !ok { + return nil, sdkerrors.Wrapf( + clienttypes.ErrInvalidMisbehaviour, + "invalid misbehaviour type %T, expected %T", wasmMisbehaviour, &Misbehaviour{}, + ) + } + + // Get consensus bytes from clientStore + consensusState1, err := GetConsensusState(store, marshaler, wasmMisbehaviour.Header1.Height) + if err != nil { + return nil, sdkerrors.Wrapf(err, "could not get trusted consensus state from clientStore for Header1 at Height: %s", wasmMisbehaviour.Header1) + } + + // Get consensus bytes from clientStore + consensusState2, err := GetConsensusState(store, marshaler, wasmMisbehaviour.Header2.Height) + if err != nil { + return nil, sdkerrors.Wrapf(err, "could not get trusted consensus state from clientStore for Header2 at Height: %s", wasmMisbehaviour.Header2) + } + + const CheckMisbehaviourAndUpdateState = "checkmisbehaviourandupdatestate" + payload := make(map[string]map[string]interface{}) + payload[CheckMisbehaviourAndUpdateState] = make(map[string]interface{}) + inner := payload[CheckMisbehaviourAndUpdateState] + inner["me"] = c + inner["misbehaviour"] = wasmMisbehaviour + inner["consensus_state1"] = consensusState1 + inner["consensus_state2"] = consensusState2 + + encodedData, err := json.Marshal(payload) + if err != nil { + return nil, sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + out, err := callContract(c.CodeId, context, store, encodedData) + if err != nil { + return nil, sdkerrors.Wrapf(ErrUnableToCall, fmt.Sprintf("underlying error: %s", err.Error())) + } + output := clientStateCallResponse{} + if err := json.Unmarshal(out.Data, &output); err != nil { + return nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + if !output.Result.IsValid { + return nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) + } + output.resetImmutables(c) + return output.NewClientState, nil +} + +func (c *ClientState) CheckProposedHeaderAndUpdateState(context sdk.Context, marshaler codec.BinaryCodec, store sdk.KVStore, header exported.Header) (exported.ClientState, exported.ConsensusState, error) { + // get consensus state corresponding to client state to check if the client is expired + consensusState, err := GetConsensusState(store, marshaler, c.LatestHeight) + if err != nil { + return nil, nil, sdkerrors.Wrapf( + err, "could not get consensus state from clientstore at height: %d", c.LatestHeight, + ) + } + + const CheckProposedHeaderAndUpdateState = "checkproposedheaderandupdatestate" + payload := make(map[string]map[string]interface{}) + payload[CheckProposedHeaderAndUpdateState] = make(map[string]interface{}) + inner := payload[CheckProposedHeaderAndUpdateState] + inner["me"] = c + inner["header"] = header + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return nil, nil, sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + out, err := callContract(c.CodeId, context, store, encodedData) + if err != nil { + return nil, nil, sdkerrors.Wrapf(ErrUnableToCall, fmt.Sprintf("underlying error: %s", err.Error())) + } + output := clientStateCallResponse{} + if err := json.Unmarshal(out.Data, &output); err != nil { + return nil, nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + if !output.Result.IsValid { + return nil, nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) + } + output.resetImmutables(c) + return output.NewClientState, output.NewConsensusState, nil +} + +func (c *ClientState) VerifyUpgradeAndUpdateState(ctx sdk.Context, cdc codec.BinaryCodec, store sdk.KVStore, newClient exported.ClientState, newConsState exported.ConsensusState, proofUpgradeClient, proofUpgradeConsState []byte) (exported.ClientState, exported.ConsensusState, error) { + wasmUpgradeConsState, ok := newConsState.(*ConsensusState) + if !ok { + return nil, nil, sdkerrors.Wrapf(clienttypes.ErrInvalidConsensus, "upgraded consensus state must be Tendermint consensus state. expected %T, got: %T", + &ConsensusState{}, wasmUpgradeConsState) + } + + // last height of current counterparty chain must be client's latest height + lastHeight := c.LatestHeight + lastHeightConsensusState, err := GetConsensusState(store, cdc, lastHeight) + if err != nil { + return nil, nil, sdkerrors.Wrap(err, "could not retrieve consensus state for lastHeight") + } + + const VerifyUpgradeAndUpdateState = "verifyupgradeandupdatestate" + payload := make(map[string]map[string]interface{}) + payload[VerifyUpgradeAndUpdateState] = make(map[string]interface{}) + inner := payload[VerifyUpgradeAndUpdateState] + inner["me"] = c + inner["new_client_state"] = newClient + inner["new_consensus_state"] = newConsState + inner["client_upgrade_proof"] = proofUpgradeClient + inner["consensus_state_upgrade_proof"] = proofUpgradeConsState + inner["last_height_consensus_state"] = lastHeightConsensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return nil, nil, sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + out, err := callContract(c.CodeId, ctx, store, encodedData) + if err != nil { + return nil, nil, sdkerrors.Wrapf(ErrUnableToCall, fmt.Sprintf("underlying error: %s", err.Error())) + } + output := clientStateCallResponse{} + if err := json.Unmarshal(out.Data, &output); err != nil { + return nil, nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + if !output.Result.IsValid { + return nil, nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) + } + output.resetImmutables(c) + return output.NewClientState, output.NewConsensusState, nil +} + +func (c *ClientState) ZeroCustomFields() exported.ClientState { + const ZeroCustomFields = "zerocustomfields" + payload := make(map[string]map[string]interface{}) + payload[ZeroCustomFields] = make(map[string]interface{}) + inner := payload[ZeroCustomFields] + inner["me"] = c + + encodedData, err := json.Marshal(payload) + if err != nil { + // TODO: Handle error + } + + gasMeter := sdk.NewGasMeter(0) + out, err := callContractWithEnvAndMeter(c.CodeId, nil, &FailKVStore{}, api.MockEnv(), gasMeter, encodedData) + if err != nil { + // TODO: Handle error + } + output := clientStateCallResponse{} + if err := json.Unmarshal(out.Data, &output); err != nil { + // TODO: Handle error + } + output.resetImmutables(c) + return output.Me +} + +/** +Following functions only queries the state so should be part of query call +*/ + +func (c *ClientState) ClientType() string { + return c.Type +} + +func (c *ClientState) ExportMetadata(store sdk.KVStore) []exported.GenesisMetadata { + const ExportMetadataQuery = "exportmetadata" + payload := make(map[string]map[string]interface{}) + payload[ExportMetadataQuery] = make(map[string]interface{}) + inner := payload[ExportMetadataQuery] + inner["me"] = c + + encodedData, err := json.Marshal(payload) + if err != nil { + // TODO: Handle error + } + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + // TODO: Handle error + } + + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + // TODO: Handle error + } + + genesisMetadata := make([]exported.GenesisMetadata, len(output.GenesisMetadata)) + for i, metadata := range output.GenesisMetadata { + genesisMetadata[i] = metadata + } + return genesisMetadata +} + +func (c *ClientState) GetLatestHeight() exported.Height { + return c.LatestHeight +} + +func (c *ClientState) IsFrozen() bool { + return c.Frozen +} + +func (c *ClientState) GetFrozenHeight() exported.Height { + return c.FrozenHeight +} + +func (c *ClientState) Validate() error { + if c.Data == nil || len(c.Data) == 0 { + return fmt.Errorf("data cannot be empty") + } + + if c.CodeId == nil || len(c.CodeId) == 0 { + return fmt.Errorf("codeid cannot be empty") + } + + return nil +} + +func (c *ClientState) GetProofSpecs() []*ics23.ProofSpec { + return c.ProofSpecs +} + +func (c *ClientState) VerifyClientState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, prefix exported.Prefix, counterpartyClientIdentifier string, proof []byte, clientState exported.ClientState) error { + consensusState, err := GetConsensusState(store, cdc, height) + if err != nil { + return err + } + const VerifyClientStateQuery = "verifyclientstate" + payload := make(map[string]map[string]interface{}) + payload[VerifyClientStateQuery] = make(map[string]interface{}) + inner := payload[VerifyClientStateQuery] + inner["me"] = c + inner["height"] = height + inner["commitment_prefix"] = prefix + inner["counterparty_client_identifier"] = counterpartyClientIdentifier + inner["proof"] = proof + inner["counterparty_client_state"] = clientState + inner["consensus_state"] = consensusState + encodedData, err := json.Marshal(payload) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToQuery, fmt.Sprintf("underlying error: %s", err.Error())) + } + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + if output.Result.IsValid { + return nil + } else { + return fmt.Errorf("%s error while validating client state", output.Result.ErrorMsg) + } +} + +func (c *ClientState) VerifyClientConsensusState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, counterpartyClientIdentifier string, consensusHeight exported.Height, prefix exported.Prefix, proof []byte, consensusState exported.ConsensusState) error { + consensusState, err := GetConsensusState(store, cdc, height) + if err != nil { + return err + } + + const VerifyClientConsensusStateQuery = "verifyclientconsensusstate" + payload := make(map[string]map[string]interface{}) + payload[VerifyClientConsensusStateQuery] = make(map[string]interface{}) + inner := payload[VerifyClientConsensusStateQuery] + inner["me"] = c + inner["height"] = height + inner["consensus_height"] = consensusHeight + inner["commitment_prefix"] = prefix + inner["counterparty_client_identifier"] = counterpartyClientIdentifier + inner["proof"] = proof + inner["counterparty_consensus_state"] = consensusState + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToQuery, fmt.Sprintf("underlying error: %s", err.Error())) + } + + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + + if output.Result.IsValid { + return nil + } else { + return fmt.Errorf("%s error while verifying consensus state", output.Result.ErrorMsg) + } +} + +func (c *ClientState) VerifyConnectionState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, prefix exported.Prefix, proof []byte, connectionID string, connectionEnd exported.ConnectionI) error { + consensusState, err := GetConsensusState(store, cdc, height) + if err != nil { + return err + } + + const VerifyConnectionStateQuery = "verifyconnectionstate" + payload := make(map[string]map[string]interface{}) + payload[VerifyConnectionStateQuery] = make(map[string]interface{}) + inner := payload[VerifyConnectionStateQuery] + inner["me"] = c + inner["height"] = height + inner["commitment_prefix"] = prefix + inner["proof"] = proof + inner["connection_id"] = connectionID + inner["connection_end"] = connectionEnd + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToQuery, fmt.Sprintf("underlying error: %s", err.Error())) + } + + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + + if output.Result.IsValid { + return nil + } else { + return fmt.Errorf("%s error while verifying connection state", output.Result.ErrorMsg) + } +} + +func (c *ClientState) VerifyChannelState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, prefix exported.Prefix, proof []byte, portID, channelID string, channel exported.ChannelI) error { + consensusState, err := GetConsensusState(store, cdc, height) + if err != nil { + return err + } + + const VerifyChannelStateQuery = "verifychannelstate" + payload := make(map[string]map[string]interface{}) + payload[VerifyChannelStateQuery] = make(map[string]interface{}) + inner := payload[VerifyChannelStateQuery] + inner["me"] = c + inner["height"] = height + inner["commitment_prefix"] = prefix + inner["proof"] = proof + inner["port_id"] = portID + inner["channel_id"] = channelID + inner["channel"] = channel + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToQuery, fmt.Sprintf("underlying error: %s", err.Error())) + } + + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + + if output.Result.IsValid { + return nil + } else { + return fmt.Errorf("%s error while verifying channel state", output.Result.ErrorMsg) + } +} + +func (c *ClientState) VerifyPacketCommitment(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, currentTimestamp uint64, delayPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64, commitmentBytes []byte) error { + consensusState, err := GetConsensusState(store, cdc, height) + if err != nil { + return err + } + + const VerifyPacketCommitmentQuery = "verifypacketcommitment" + payload := make(map[string]map[string]interface{}) + payload[VerifyPacketCommitmentQuery] = make(map[string]interface{}) + inner := payload[VerifyPacketCommitmentQuery] + inner["me"] = c + inner["height"] = height + inner["commitment_prefix"] = prefix + inner["proof"] = proof + inner["port_id"] = portID + inner["channel_id"] = channelID + inner["current_timestamp"] = currentTimestamp + inner["delay_period"] = delayPeriod + inner["sequence"] = sequence + inner["commitment_bytes"] = commitmentBytes + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToQuery, fmt.Sprintf("underlying error: %s", err.Error())) + } + + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + + if output.Result.IsValid { + return nil + } else { + return fmt.Errorf("%s error while verifying packet commitment", output.Result.ErrorMsg) + } + +} + +func (c *ClientState) VerifyPacketAcknowledgement(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, currentTimestamp uint64, delayPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64, acknowledgement []byte) error { + consensusState, err := GetConsensusState(store, cdc, height) + if err != nil { + return err + } + + const VerifyPacketAcknowledgementQuery = "verifypacketacknowledgement" + payload := make(map[string]map[string]interface{}) + payload[VerifyPacketAcknowledgementQuery] = make(map[string]interface{}) + inner := payload[VerifyPacketAcknowledgementQuery] + inner["me"] = c + inner["height"] = height + inner["commitment_prefix"] = prefix + inner["proof"] = proof + inner["port_id"] = portID + inner["channel_id"] = channelID + inner["current_timestamp"] = currentTimestamp + inner["delay_period"] = delayPeriod + inner["sequence"] = sequence + inner["acknowledgement"] = acknowledgement + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToQuery, fmt.Sprintf("underlying error: %s", err.Error())) + } + + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + + if output.Result.IsValid { + return nil + } else { + return fmt.Errorf("%s error while verifying packet acknowledgement", output.Result.ErrorMsg) + } +} + +func (c *ClientState) VerifyPacketReceiptAbsence(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, currentTimestamp uint64, delayPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64) error { + consensusState, err := GetConsensusState(store, cdc, height) + if err != nil { + return err + } + + const VerifyPacketReceiptAbsenceQuery = "verifypacketreceiptabsence" + payload := make(map[string]map[string]interface{}) + payload[VerifyPacketReceiptAbsenceQuery] = make(map[string]interface{}) + inner := payload[VerifyPacketReceiptAbsenceQuery] + inner["me"] = c + inner["height"] = height + inner["commitment_prefix"] = prefix + inner["proof"] = proof + inner["port_id"] = portID + inner["channel_id"] = channelID + inner["current_timestamp"] = currentTimestamp + inner["delay_period"] = delayPeriod + inner["sequence"] = sequence + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToQuery, fmt.Sprintf("underlying error: %s", err.Error())) + } + + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + + if output.Result.IsValid { + return nil + } else { + return fmt.Errorf("%s error while verifying packet receipt absense", output.Result.ErrorMsg) + } +} + +func (c *ClientState) VerifyNextSequenceRecv(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, currentTimestamp uint64, delayPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, nextSequenceRecv uint64) error { + consensusState, err := GetConsensusState(store, cdc, height) + if err != nil { + return err + } + + const VerifyNextSequenceRecvQuery = "verifynextsequencerecv" + payload := make(map[string]map[string]interface{}) + payload[VerifyNextSequenceRecvQuery] = make(map[string]interface{}) + inner := payload[VerifyNextSequenceRecvQuery] + inner["me"] = c + inner["height"] = height + inner["commitment_prefix"] = prefix + inner["proof"] = proof + inner["port_id"] = portID + inner["channel_id"] = channelID + inner["current_timestamp"] = currentTimestamp + inner["delay_period"] = delayPeriod + inner["next_sequence_recv"] = nextSequenceRecv + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + return sdkerrors.Wrapf(ErrUnableToQuery, fmt.Sprintf("underlying error: %s", err.Error())) + } + + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + + if output.Result.IsValid { + return nil + } else { + return fmt.Errorf("%s error while verify next sequence", output.Result.ErrorMsg) + } +} diff --git a/modules/light-clients/10-wasm/types/codec.go b/modules/light-clients/10-wasm/types/codec.go new file mode 100644 index 00000000000..eb6ab39ea10 --- /dev/null +++ b/modules/light-clients/10-wasm/types/codec.go @@ -0,0 +1,28 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/ibc-go/modules/core/exported" +) + +// RegisterInterfaces registers the tendermint concrete client-related +// implementations and interfaces. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*exported.ClientState)(nil), + &ClientState{}, + ) + registry.RegisterImplementations( + (*exported.ConsensusState)(nil), + &ConsensusState{}, + ) + registry.RegisterImplementations( + (*exported.Header)(nil), + &Header{}, + ) + registry.RegisterImplementations( + (*exported.Misbehaviour)(nil), + &Misbehaviour{}, + ) +} + diff --git a/modules/light-clients/10-wasm/types/consensus_state.go b/modules/light-clients/10-wasm/types/consensus_state.go new file mode 100644 index 00000000000..d1675fb213e --- /dev/null +++ b/modules/light-clients/10-wasm/types/consensus_state.go @@ -0,0 +1,41 @@ +package types + +import ( + "fmt" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" + "github.com/cosmos/ibc-go/modules/core/exported" +) + +var _ exported.ConsensusState = (*ConsensusState)(nil) + +func (m *ConsensusState) ClientType() string { + return m.Type +} + +func (m *ConsensusState) GetRoot() exported.Root { + return m.Root +} + +func (m *ConsensusState) GetTimestamp() uint64 { + return m.Timestamp +} + +func (m *ConsensusState) ValidateBasic() error { + if m.Root.Empty() { + return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "root cannot be empty") + } + if m.Timestamp == 0 { + return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "timestamp cannot be zero Unix time") + } + + if m.Data == nil || len(m.Data) == 0 { + return fmt.Errorf("data cannot be empty") + } + + if m.CodeId == nil || len(m.CodeId) == 0 { + return fmt.Errorf("codeid cannot be empty") + } + + return nil +} diff --git a/modules/light-clients/10-wasm/types/errors.go b/modules/light-clients/10-wasm/types/errors.go new file mode 100644 index 00000000000..eb1ed2ea5af --- /dev/null +++ b/modules/light-clients/10-wasm/types/errors.go @@ -0,0 +1,12 @@ +package types + +import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + +var ( + ErrInvalidHeader = sdkerrors.Register(SubModuleName, 1, "invalid header") + ErrUnableToUnmarshalPayload = sdkerrors.Register(SubModuleName, 2, "unable to unmarshal wasm contract return value") + ErrUnableToInit = sdkerrors.Register(SubModuleName, 3, "unable to initialize wasm contract") + ErrUnableToCall = sdkerrors.Register(SubModuleName, 4, "unable to call wasm contract") + ErrUnableToQuery = sdkerrors.Register(SubModuleName, 5, "unable to query wasm contract") + ErrUnableToMarshalPayload = sdkerrors.Register(SubModuleName, 6, "unable to marshal wasm contract payload") +) \ No newline at end of file diff --git a/modules/light-clients/10-wasm/types/fail_kv_store.go b/modules/light-clients/10-wasm/types/fail_kv_store.go new file mode 100644 index 00000000000..6f537c0f20b --- /dev/null +++ b/modules/light-clients/10-wasm/types/fail_kv_store.go @@ -0,0 +1,52 @@ +package types + +import ( + store "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/types" + "io" +) + +var _ types.KVStore = (*FailKVStore)(nil) + +type FailKVStore struct { +} + +func (f *FailKVStore) GetStoreType() store.StoreType { + panic("not available for this method of IBC contract") +} + +func (f *FailKVStore) CacheWrap() store.CacheWrap { + panic("not available for this method of IBC contract") +} + +func (f *FailKVStore) CacheWrapWithTrace(w io.Writer, tc store.TraceContext) store.CacheWrap { + panic("not available for this method of IBC contract") +} + +func (f *FailKVStore) CacheWrapWithListeners(storeKey types.StoreKey, listeners []store.WriteListener) types.CacheWrap { + panic("not available for this method of IBC contract") +} + +func (f *FailKVStore) Get(key []byte) []byte { + panic("not available for this method of IBC contract") +} + +func (f *FailKVStore) Has(key []byte) bool { + panic("not available for this method of IBC contract") +} + +func (f FailKVStore) Set(key, value []byte) { + panic("not available for this method of IBC contract") +} + +func (f FailKVStore) Delete(key []byte) { + panic("not available for this method of IBC contract") +} + +func (f FailKVStore) Iterator(start, end []byte) store.Iterator { + panic("not available for this method of IBC contract") +} + +func (f FailKVStore) ReverseIterator(start, end []byte) store.Iterator { + panic("not available for this method of IBC contract") +} diff --git a/modules/light-clients/10-wasm/types/header.go b/modules/light-clients/10-wasm/types/header.go new file mode 100644 index 00000000000..daf63c47aee --- /dev/null +++ b/modules/light-clients/10-wasm/types/header.go @@ -0,0 +1,24 @@ +package types + +import ( + "fmt" + "github.com/cosmos/ibc-go/modules/core/exported" +) + +var _ exported.Header = (*Header)(nil) + +func (m *Header) ClientType() string { + return m.Type +} + +func (m *Header) GetHeight() exported.Height { + return m.Height +} + +func (m *Header) ValidateBasic() error { + if m.Data == nil || len(m.Data) == 0 { + return fmt.Errorf("data cannot be empty") + } + + return nil +} diff --git a/modules/light-clients/10-wasm/types/keys.go b/modules/light-clients/10-wasm/types/keys.go new file mode 100644 index 00000000000..a6d1a535ac8 --- /dev/null +++ b/modules/light-clients/10-wasm/types/keys.go @@ -0,0 +1,7 @@ +package types + +const ( + // SubModuleName for the wasm client + SubModuleName = "wasm-client" + LastInstanceIDKey = "lastInstanceId" +) diff --git a/modules/light-clients/10-wasm/types/misbehaviour.go b/modules/light-clients/10-wasm/types/misbehaviour.go new file mode 100644 index 00000000000..c3811dcd06f --- /dev/null +++ b/modules/light-clients/10-wasm/types/misbehaviour.go @@ -0,0 +1,38 @@ +package types + +import ( + "fmt" + "github.com/cosmos/ibc-go/modules/core/exported" +) + +var ( + _ exported.Misbehaviour = &Misbehaviour{} +) + +func (m *Misbehaviour) ClientType() string { + return m.Header1.ClientType() +} + +func (m *Misbehaviour) GetClientID() string { + return m.ClientId +} + +func (m *Misbehaviour) ValidateBasic() error { + if err := m.Header1.ValidateBasic(); err != nil { + return err + } + + if err := m.Header2.ValidateBasic(); err != nil { + return err + } + + if m.CodeId == nil || len(m.CodeId) == 0 { + return fmt.Errorf("codeid cannot be empty") + } + + return nil +} + +func (m *Misbehaviour) GetHeight() exported.Height { + return m.Header1.GetHeight() +} \ No newline at end of file diff --git a/modules/light-clients/10-wasm/types/store.go b/modules/light-clients/10-wasm/types/store.go new file mode 100644 index 00000000000..a77ea88bf50 --- /dev/null +++ b/modules/light-clients/10-wasm/types/store.go @@ -0,0 +1,37 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" + host "github.com/cosmos/ibc-go/modules/core/24-host" + "github.com/cosmos/ibc-go/modules/core/exported" +) + +// GetConsensusState retrieves the consensus state from the client prefixed +// store. An error is returned if the consensus state does not exist. +func GetConsensusState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height) (*ConsensusState, error) { + bz := store.Get(host.ConsensusStateKey(height)) + if bz == nil { + return nil, sdkerrors.Wrapf( + clienttypes.ErrConsensusStateNotFound, + "consensus state does not exist for height %s", height, + ) + } + + consensusStateI, err := clienttypes.UnmarshalConsensusState(cdc, bz) + if err != nil { + return nil, sdkerrors.Wrapf(clienttypes.ErrInvalidConsensus, "unmarshal error: %v", err) + } + + consensusState, ok := consensusStateI.(*ConsensusState) + if !ok { + return nil, sdkerrors.Wrapf( + clienttypes.ErrInvalidConsensus, + "invalid consensus type %T, expected %T", consensusState, &ConsensusState{}, + ) + } + + return consensusState, nil +} diff --git a/modules/light-clients/10-wasm/types/vm.go b/modules/light-clients/10-wasm/types/vm.go new file mode 100644 index 00000000000..a993d747ed7 --- /dev/null +++ b/modules/light-clients/10-wasm/types/vm.go @@ -0,0 +1,164 @@ +package types + +import ( + "github.com/CosmWasm/wasmvm/api" + "github.com/CosmWasm/wasmvm/types" + ics23 "github.com/confio/ics23/go" + sdk "github.com/cosmos/cosmos-sdk/types" + types2 "github.com/cosmos/ibc-go/modules/core/02-client/types" + types3 "github.com/cosmos/ibc-go/modules/core/23-commitment/types" + "github.com/cosmos/ibc-go/modules/core/28-wasm/keeper" + "github.com/cosmos/ibc-go/modules/core/exported" +) + +const GasMultiplier uint64 = 100 + +var _ exported.ClientState = (*ClientState)(nil) + +type queryResponse struct { + ProofSpecs []*ics23.ProofSpec `json:"proof_specs,omitempty"` + Height types2.Height `json:"height,omitempty"` + IsFrozen bool `json:"is_frozen,omitempty"` + FrozenHeight types2.Height `json:"frozen_height,omitempty"` + GenesisMetadata []types2.GenesisMetadata `json:"genesis_metadata,omitempty"` + Result contractResult `json:"result,omitempty"` + ClientType string `json:"client_type,omitempty"` + Root types3.MerkleRoot `json:"root,omitempty"` + Timestamp uint64 `json:"timestamp,omitempty"` +} + +type contractResult struct { + IsValid bool `json:"is_valid,omitempty"` + ErrorMsg string `json:"err_msg,omitempty"` +} + +type clientStateCallResponse struct { + Me *ClientState `json:"me,omitempty"` + NewConsensusState *ConsensusState `json:"new_consensus_state,omitempty"` + NewClientState *ClientState `json:"new_client_state,omitempty"` + Result contractResult `json:"result,omitempty"` +} + +func (r *clientStateCallResponse) resetImmutables(c *ClientState) { + if r.Me != nil { + r.Me.CodeId = c.CodeId + r.Me.Type = c.Type + } + + if r.NewConsensusState != nil { + r.NewConsensusState.Type = c.Type + r.NewConsensusState.CodeId = c.CodeId + } + + if r.NewClientState != nil { + r.NewClientState.Type = c.Type + r.NewClientState.CodeId = c.CodeId + } +} + +// Calls vm.Init with appropriate arguments +func initContract(codeId []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) (*types.InitResponse, error) { + gasMeter := ctx.GasMeter() + chainID := ctx.BlockHeader().ChainID + height := ctx.BlockHeader().Height + // safety checks before casting below + if height < 0 { + panic("Block height must never be negative") + } + sec := ctx.BlockTime().Unix() + if sec < 0 { + panic("Block (unix) time must never be negative ") + } + nano := ctx.BlockTime().Nanosecond() + env := types.Env{ + Block: types.BlockInfo{ + Height: uint64(height), + Time: uint64(sec), + TimeNanos: uint64(nano), + ChainID: chainID, + }, + Contract: types.ContractInfo{ + Address: "", + }, + } + + msgInfo := types.MessageInfo{ + Sender: "", + SentFunds: nil, + } + mockFailureAPI := *api.NewMockFailureAPI() + mockQuerier := api.MockQuerier{} + + + response, _, err := keeper.WasmVM.Instantiate(codeId, env, msgInfo, msg, store, mockFailureAPI, mockQuerier, gasMeter, gasMeter.Limit()) + return response, err +} + +// Calls vm.Execute with internally constructed Gas meter and environment +func callContract(codeId []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) (*types.HandleResponse, error) { + gasMeter := ctx.GasMeter() + chainID := ctx.BlockHeader().ChainID + height := ctx.BlockHeader().Height + // safety checks before casting below + if height < 0 { + panic("Block height must never be negative") + } + sec := ctx.BlockTime().Unix() + if sec < 0 { + panic("Block (unix) time must never be negative ") + } + nano := ctx.BlockTime().Nanosecond() + env := types.Env{ + Block: types.BlockInfo{ + Height: uint64(height), + Time: uint64(sec), + TimeNanos: uint64(nano), + ChainID: chainID, + }, + Contract: types.ContractInfo{ + Address: "", + }, + } + + return callContractWithEnvAndMeter(codeId, &ctx, store, env, gasMeter, msg) +} + +// Calls vm.Execute with supplied environment and gas meter +func callContractWithEnvAndMeter(codeId []byte, ctx *sdk.Context, store sdk.KVStore, env types.Env, gasMeter sdk.GasMeter, msg []byte) (*types.HandleResponse, error) { + msgInfo := types.MessageInfo{ + Sender: "", + SentFunds: nil, + } + mockFailureAPI := *api.NewMockFailureAPI() + mockQuerier := api.MockQuerier{} + + resp, gasUsed, err := keeper.WasmVM.Execute(codeId, env, msgInfo, msg, store, mockFailureAPI, mockQuerier, gasMeter, gasMeter.Limit()) + if ctx != nil { + consumeGas(*ctx, gasUsed) + } + return resp, err +} + +func queryContract(codeId []byte, msg []byte) ([]byte, error) { + return queryContractWithStore(codeId, &FailKVStore{}, msg) +} + +func queryContractWithStore(codeId []byte, store sdk.KVStore, msg []byte) ([]byte, error) { + mockEnv := api.MockEnv() + mockGasMeter := api.NewMockGasMeter(1) + mockFailureAPI := *api.NewMockFailureAPI() + mockQuerier := api.MockQuerier{} + + resp, _, err := keeper.WasmVM.Query(codeId, mockEnv, msg, store, mockFailureAPI, mockQuerier, mockGasMeter, 0) + return resp, err +} + +func consumeGas(ctx sdk.Context, gas uint64) { + consumed := gas / GasMultiplier + ctx.GasMeter().ConsumeGas(consumed, "wasm contract") + // throw OutOfGas error if we ran out (got exactly to zero due to better limit enforcing) + if ctx.GasMeter().IsOutOfGas() { + panic(sdk.ErrorOutOfGas{Descriptor: "Wasmer function execution"}) + } +} + diff --git a/modules/light-clients/10-wasm/types/wasm.pb.go b/modules/light-clients/10-wasm/types/wasm.pb.go new file mode 100644 index 00000000000..9841ddbf6b8 --- /dev/null +++ b/modules/light-clients/10-wasm/types/wasm.pb.go @@ -0,0 +1,1576 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/lightclients/wasm/v1/wasm.proto + +package types + +import ( + fmt "fmt" + _go "github.com/confio/ics23/go" + types "github.com/cosmos/ibc-go/modules/core/02-client/types" + types1 "github.com/cosmos/ibc-go/modules/core/23-commitment/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// WASM light client's Client state +type ClientState struct { + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + CodeId []byte `protobuf:"bytes,2,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + Frozen bool `protobuf:"varint,3,opt,name=frozen,proto3" json:"frozen,omitempty"` + FrozenHeight *types.Height `protobuf:"bytes,4,opt,name=frozen_height,json=frozenHeight,proto3" json:"frozen_height,omitempty"` + LatestHeight *types.Height `protobuf:"bytes,5,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height,omitempty"` + Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` + ProofSpecs []*_go.ProofSpec `protobuf:"bytes,7,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty"` +} + +func (m *ClientState) Reset() { *m = ClientState{} } +func (m *ClientState) String() string { return proto.CompactTextString(m) } +func (*ClientState) ProtoMessage() {} +func (*ClientState) Descriptor() ([]byte, []int) { + return fileDescriptor_678928ebbdee1807, []int{0} +} +func (m *ClientState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ClientState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ClientState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ClientState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClientState.Merge(m, src) +} +func (m *ClientState) XXX_Size() int { + return m.Size() +} +func (m *ClientState) XXX_DiscardUnknown() { + xxx_messageInfo_ClientState.DiscardUnknown(m) +} + +var xxx_messageInfo_ClientState proto.InternalMessageInfo + +// WASM light client's ConsensusState +type ConsensusState struct { + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + CodeId []byte `protobuf:"bytes,2,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + // timestamp that corresponds to the block height in which the ConsensusState + // was stored. + Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // commitment root (i.e app hash) + Root *types1.MerkleRoot `protobuf:"bytes,4,opt,name=root,proto3" json:"root,omitempty"` + Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` +} + +func (m *ConsensusState) Reset() { *m = ConsensusState{} } +func (m *ConsensusState) String() string { return proto.CompactTextString(m) } +func (*ConsensusState) ProtoMessage() {} +func (*ConsensusState) Descriptor() ([]byte, []int) { + return fileDescriptor_678928ebbdee1807, []int{1} +} +func (m *ConsensusState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsensusState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsensusState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ConsensusState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsensusState.Merge(m, src) +} +func (m *ConsensusState) XXX_Size() int { + return m.Size() +} +func (m *ConsensusState) XXX_DiscardUnknown() { + xxx_messageInfo_ConsensusState.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsensusState proto.InternalMessageInfo + +// WASM light client Header +type Header struct { + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + Height *types.Height `protobuf:"bytes,2,opt,name=height,proto3" json:"height,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` +} + +func (m *Header) Reset() { *m = Header{} } +func (m *Header) String() string { return proto.CompactTextString(m) } +func (*Header) ProtoMessage() {} +func (*Header) Descriptor() ([]byte, []int) { + return fileDescriptor_678928ebbdee1807, []int{2} +} +func (m *Header) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Header.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Header) XXX_Merge(src proto.Message) { + xxx_messageInfo_Header.Merge(m, src) +} +func (m *Header) XXX_Size() int { + return m.Size() +} +func (m *Header) XXX_DiscardUnknown() { + xxx_messageInfo_Header.DiscardUnknown(m) +} + +var xxx_messageInfo_Header proto.InternalMessageInfo + +// WASM light client Misbehaviour +type Misbehaviour struct { + CodeId []byte `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + Header1 *Header `protobuf:"bytes,3,opt,name=header_1,json=header1,proto3" json:"header_1,omitempty" yaml:"header_1"` + Header2 *Header `protobuf:"bytes,4,opt,name=header_2,json=header2,proto3" json:"header_2,omitempty" yaml:"header_2"` +} + +func (m *Misbehaviour) Reset() { *m = Misbehaviour{} } +func (m *Misbehaviour) String() string { return proto.CompactTextString(m) } +func (*Misbehaviour) ProtoMessage() {} +func (*Misbehaviour) Descriptor() ([]byte, []int) { + return fileDescriptor_678928ebbdee1807, []int{3} +} +func (m *Misbehaviour) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Misbehaviour) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Misbehaviour.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Misbehaviour) XXX_Merge(src proto.Message) { + xxx_messageInfo_Misbehaviour.Merge(m, src) +} +func (m *Misbehaviour) XXX_Size() int { + return m.Size() +} +func (m *Misbehaviour) XXX_DiscardUnknown() { + xxx_messageInfo_Misbehaviour.DiscardUnknown(m) +} + +var xxx_messageInfo_Misbehaviour proto.InternalMessageInfo + +func (m *Misbehaviour) GetCodeId() []byte { + if m != nil { + return m.CodeId + } + return nil +} + +func (m *Misbehaviour) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *Misbehaviour) GetHeader1() *Header { + if m != nil { + return m.Header1 + } + return nil +} + +func (m *Misbehaviour) GetHeader2() *Header { + if m != nil { + return m.Header2 + } + return nil +} + +func init() { + proto.RegisterType((*ClientState)(nil), "ibc.lightclients.wasm.v1.ClientState") + proto.RegisterType((*ConsensusState)(nil), "ibc.lightclients.wasm.v1.ConsensusState") + proto.RegisterType((*Header)(nil), "ibc.lightclients.wasm.v1.Header") + proto.RegisterType((*Misbehaviour)(nil), "ibc.lightclients.wasm.v1.Misbehaviour") +} + +func init() { + proto.RegisterFile("ibc/lightclients/wasm/v1/wasm.proto", fileDescriptor_678928ebbdee1807) +} + +var fileDescriptor_678928ebbdee1807 = []byte{ + // 591 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4d, 0x6e, 0xd3, 0x40, + 0x18, 0x8d, 0x53, 0xd7, 0x69, 0x26, 0x05, 0x2a, 0x53, 0x81, 0x55, 0x21, 0xc7, 0x32, 0x0b, 0xb2, + 0xa9, 0x8d, 0x5d, 0x89, 0x45, 0x85, 0x84, 0x94, 0x6e, 0xda, 0x45, 0x25, 0xe4, 0x4a, 0x2c, 0x60, + 0x11, 0xf9, 0x67, 0xe2, 0x0c, 0xd8, 0xf9, 0x2c, 0xcf, 0x24, 0xa8, 0x9c, 0x80, 0x25, 0x0b, 0x0e, + 0x00, 0x07, 0xe0, 0x1e, 0x2c, 0xbb, 0x64, 0x15, 0xa1, 0xe4, 0x06, 0x3d, 0x01, 0x9a, 0x19, 0xdb, + 0x09, 0x2a, 0xa8, 0x82, 0x95, 0xdf, 0x37, 0xf3, 0xfc, 0xbe, 0x79, 0x6f, 0x34, 0x1f, 0x7a, 0x4c, + 0xa2, 0xd8, 0xcd, 0x48, 0x3a, 0x61, 0x71, 0x46, 0xf0, 0x94, 0x51, 0xf7, 0x7d, 0x48, 0x73, 0x77, + 0xee, 0x89, 0xaf, 0x53, 0x94, 0xc0, 0x40, 0x37, 0x48, 0x14, 0x3b, 0x9b, 0x24, 0x47, 0x6c, 0xce, + 0xbd, 0x83, 0xfd, 0x14, 0x52, 0x10, 0x24, 0x97, 0x23, 0xc9, 0x3f, 0xe8, 0x73, 0xd1, 0x18, 0x4a, + 0xec, 0x4a, 0x3e, 0x97, 0x93, 0xa8, 0x22, 0x3c, 0x59, 0x13, 0x20, 0xcf, 0x09, 0xcb, 0x6b, 0x52, + 0x53, 0xd5, 0x4a, 0x29, 0x40, 0x9a, 0x61, 0x57, 0x54, 0xd1, 0x6c, 0xec, 0x32, 0x92, 0x63, 0xca, + 0xc2, 0xbc, 0xa8, 0x08, 0xf7, 0x63, 0x98, 0x8e, 0x09, 0x70, 0x02, 0x8c, 0xa9, 0x5c, 0xb4, 0xbf, + 0xb6, 0x51, 0xef, 0x44, 0xf4, 0xbb, 0x60, 0x21, 0xc3, 0xba, 0x8e, 0xd4, 0x24, 0x64, 0xa1, 0xa1, + 0x58, 0xca, 0x60, 0x37, 0x10, 0x58, 0x7f, 0x88, 0x3a, 0x31, 0x24, 0x78, 0x44, 0x12, 0xa3, 0x2d, + 0x96, 0x35, 0x5e, 0x9e, 0x25, 0xfa, 0x03, 0xa4, 0x8d, 0x4b, 0xf8, 0x80, 0xa7, 0xc6, 0x96, 0xa5, + 0x0c, 0x76, 0x82, 0xaa, 0xd2, 0x5f, 0xa0, 0x3b, 0x12, 0x8d, 0x26, 0x98, 0x47, 0x61, 0xa8, 0x96, + 0x32, 0xe8, 0xf9, 0x07, 0x0e, 0x0f, 0x87, 0x7b, 0x71, 0x2a, 0x8b, 0x73, 0xcf, 0x39, 0x15, 0x8c, + 0x60, 0x57, 0xfe, 0x20, 0x2b, 0x2e, 0x90, 0x85, 0x0c, 0x53, 0x56, 0x0b, 0x6c, 0xdf, 0x2e, 0x20, + 0x7f, 0xa8, 0x04, 0x74, 0xa4, 0xb2, 0xcb, 0x02, 0x1b, 0x9a, 0xa5, 0x0c, 0xba, 0x81, 0xc0, 0xba, + 0x87, 0x7a, 0xc2, 0xfa, 0x88, 0x16, 0x38, 0xa6, 0x46, 0xc7, 0xda, 0x1a, 0xf4, 0xfc, 0x3d, 0x87, + 0xc4, 0xd4, 0x3f, 0x72, 0x5e, 0xf2, 0x9d, 0x8b, 0x02, 0xc7, 0x01, 0x2a, 0x6a, 0x48, 0x8f, 0xd5, + 0x8f, 0x5f, 0xfa, 0x2d, 0xfb, 0x9b, 0x82, 0xee, 0x9e, 0xc0, 0x94, 0xe2, 0x29, 0x9d, 0xd1, 0xff, + 0x88, 0xe9, 0x11, 0xea, 0x36, 0x77, 0x21, 0x92, 0x52, 0x83, 0xf5, 0x82, 0xfe, 0x0c, 0xa9, 0x25, + 0x40, 0x9d, 0x91, 0xbd, 0x61, 0x71, 0x7d, 0xc3, 0x73, 0xcf, 0x39, 0xc7, 0xe5, 0xbb, 0x0c, 0x07, + 0x00, 0x2c, 0x10, 0xfc, 0xc6, 0xe2, 0xf6, 0xda, 0x62, 0x75, 0xde, 0xb7, 0x48, 0x3b, 0xc5, 0x61, + 0x82, 0xcb, 0x3f, 0x1e, 0xd3, 0x47, 0x5a, 0x15, 0x6a, 0xfb, 0xd6, 0x50, 0x2b, 0x66, 0xd3, 0x6b, + 0xeb, 0x46, 0xaf, 0xcf, 0x6d, 0xb4, 0x7b, 0x4e, 0x68, 0x84, 0x27, 0xe1, 0x9c, 0xc0, 0xac, 0xdc, + 0x4c, 0x41, 0xf9, 0x2d, 0x05, 0x0f, 0x75, 0xa5, 0x7e, 0x1d, 0x50, 0x77, 0xb8, 0x7f, 0xbd, 0xe8, + 0xef, 0x5d, 0x86, 0x79, 0x76, 0x6c, 0x37, 0x5b, 0x76, 0xb0, 0x23, 0xf1, 0x59, 0xa2, 0xbf, 0x41, + 0x3b, 0x13, 0x61, 0x64, 0xe4, 0x89, 0xd6, 0x3d, 0xdf, 0x72, 0xfe, 0xf6, 0xbe, 0x1c, 0x69, 0x79, + 0x68, 0x2e, 0x17, 0xfd, 0x8e, 0xc4, 0xde, 0xf5, 0xa2, 0x7f, 0x4f, 0xca, 0xd7, 0x32, 0x76, 0xd0, + 0x91, 0xd0, 0xdb, 0x10, 0xf7, 0xab, 0xec, 0xff, 0x49, 0xdc, 0xbf, 0x21, 0xee, 0x37, 0xe2, 0xfe, + 0xf0, 0xd5, 0xf7, 0xa5, 0xa9, 0x5c, 0x2d, 0x4d, 0xe5, 0xe7, 0xd2, 0x54, 0x3e, 0xad, 0xcc, 0xd6, + 0xd5, 0xca, 0x6c, 0xfd, 0x58, 0x99, 0xad, 0xd7, 0xcf, 0x53, 0xc2, 0x26, 0xb3, 0x88, 0xdf, 0xae, + 0x1b, 0x03, 0xcd, 0x81, 0xba, 0x24, 0x8a, 0x0f, 0x53, 0x70, 0x73, 0x48, 0x66, 0x19, 0xa6, 0x72, + 0xc4, 0x1c, 0xd6, 0x33, 0xc6, 0x7b, 0x7a, 0x28, 0xc6, 0x0c, 0xcf, 0x9c, 0x46, 0x9a, 0x78, 0xb5, + 0x47, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x0e, 0xcb, 0x4b, 0x8c, 0x04, 0x00, 0x00, +} + +func (m *ClientState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ClientState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ProofSpecs) > 0 { + for iNdEx := len(m.ProofSpecs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ProofSpecs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWasm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintWasm(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x32 + } + if m.LatestHeight != nil { + { + size, err := m.LatestHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWasm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.FrozenHeight != nil { + { + size, err := m.FrozenHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWasm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.Frozen { + i-- + if m.Frozen { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.CodeId) > 0 { + i -= len(m.CodeId) + copy(dAtA[i:], m.CodeId) + i = encodeVarintWasm(dAtA, i, uint64(len(m.CodeId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintWasm(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ConsensusState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ConsensusState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintWasm(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x2a + } + if m.Root != nil { + { + size, err := m.Root.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWasm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.Timestamp != 0 { + i = encodeVarintWasm(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x18 + } + if len(m.CodeId) > 0 { + i -= len(m.CodeId) + copy(dAtA[i:], m.CodeId) + i = encodeVarintWasm(dAtA, i, uint64(len(m.CodeId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintWasm(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Header) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Header) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintWasm(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x1a + } + if m.Height != nil { + { + size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWasm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintWasm(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Misbehaviour) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Misbehaviour) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Misbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Header2 != nil { + { + size, err := m.Header2.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWasm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.Header1 != nil { + { + size, err := m.Header1.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWasm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintWasm(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0x12 + } + if len(m.CodeId) > 0 { + i -= len(m.CodeId) + copy(dAtA[i:], m.CodeId) + i = encodeVarintWasm(dAtA, i, uint64(len(m.CodeId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintWasm(dAtA []byte, offset int, v uint64) int { + offset -= sovWasm(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ClientState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + l = len(m.CodeId) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + if m.Frozen { + n += 2 + } + if m.FrozenHeight != nil { + l = m.FrozenHeight.Size() + n += 1 + l + sovWasm(uint64(l)) + } + if m.LatestHeight != nil { + l = m.LatestHeight.Size() + n += 1 + l + sovWasm(uint64(l)) + } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + if len(m.ProofSpecs) > 0 { + for _, e := range m.ProofSpecs { + l = e.Size() + n += 1 + l + sovWasm(uint64(l)) + } + } + return n +} + +func (m *ConsensusState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + l = len(m.CodeId) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + if m.Timestamp != 0 { + n += 1 + sovWasm(uint64(m.Timestamp)) + } + if m.Root != nil { + l = m.Root.Size() + n += 1 + l + sovWasm(uint64(l)) + } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + return n +} + +func (m *Header) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + if m.Height != nil { + l = m.Height.Size() + n += 1 + l + sovWasm(uint64(l)) + } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + return n +} + +func (m *Misbehaviour) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CodeId) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovWasm(uint64(l)) + } + if m.Header1 != nil { + l = m.Header1.Size() + n += 1 + l + sovWasm(uint64(l)) + } + if m.Header2 != nil { + l = m.Header2.Size() + n += 1 + l + sovWasm(uint64(l)) + } + return n +} + +func sovWasm(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozWasm(x uint64) (n int) { + return sovWasm(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ClientState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ClientState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ClientState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeId = append(m.CodeId[:0], dAtA[iNdEx:postIndex]...) + if m.CodeId == nil { + m.CodeId = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Frozen", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Frozen = bool(v != 0) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FrozenHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FrozenHeight == nil { + m.FrozenHeight = &types.Height{} + } + if err := m.FrozenHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LatestHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.LatestHeight == nil { + m.LatestHeight = &types.Height{} + } + if err := m.LatestHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofSpecs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProofSpecs = append(m.ProofSpecs, &_go.ProofSpec{}) + if err := m.ProofSpecs[len(m.ProofSpecs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWasm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWasm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConsensusState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ConsensusState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsensusState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeId = append(m.CodeId[:0], dAtA[iNdEx:postIndex]...) + if m.CodeId == nil { + m.CodeId = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Root == nil { + m.Root = &types1.MerkleRoot{} + } + if err := m.Root.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWasm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWasm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Header) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Header: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Height == nil { + m.Height = &types.Height{} + } + if err := m.Height.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWasm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWasm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Misbehaviour) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Misbehaviour: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Misbehaviour: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeId = append(m.CodeId[:0], dAtA[iNdEx:postIndex]...) + if m.CodeId == nil { + m.CodeId = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header1", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header1 == nil { + m.Header1 = &Header{} + } + if err := m.Header1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header2", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWasm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWasm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWasm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header2 == nil { + m.Header2 = &Header{} + } + if err := m.Header2.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWasm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWasm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipWasm(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWasm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWasm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWasm + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthWasm + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupWasm + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthWasm + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthWasm = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowWasm = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupWasm = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/ibc/core/client/v1/client.proto b/proto/ibc/core/client/v1/client.proto index a4a2cc85def..8a63a1e1f3e 100644 --- a/proto/ibc/core/client/v1/client.proto +++ b/proto/ibc/core/client/v1/client.proto @@ -102,4 +102,6 @@ message Height { message Params { // allowed_clients defines the list of allowed client state types. repeated string allowed_clients = 1 [(gogoproto.moretags) = "yaml:\"allowed_clients\""]; + // whether or not wasm clients are enabled + bool wasm_clients_enabled = 2 [(gogoproto.moretags) = "yaml:\"wasm_clients_enabled\""]; } diff --git a/proto/ibc/core/wasm/v1/query.proto b/proto/ibc/core/wasm/v1/query.proto new file mode 100644 index 00000000000..5207e637713 --- /dev/null +++ b/proto/ibc/core/wasm/v1/query.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; +package ibc.core.wasm.v1; + +import "ibc/core/wasm/v1/wasm.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/cosmos/ibc-go/modules/core/28-wasm/types"; + +// Latest wasm code query +message LatestWASMCodeQuery { + string client_type = 1; +} + +// Latest wasm code response +message LatestWASMCodeResponse { + bytes code = 1; +} + +// Latest wasm code entry query +message LatestWASMCodeEntryQuery { + string client_type = 1; +} + +// Latest wasm code entry response +message LatestWASMCodeEntryResponse { + string code_id = 1; + ibc.core.wasm.v1.WasmCodeEntry entry = 2; +} + +// Query service for wasm module +service Query { + // Query to get latest wasm code for particular client type. + rpc LatestWASMCode(LatestWASMCodeQuery) returns (LatestWASMCodeResponse) { + option (google.api.http).get = "/ibc/core/wasm/v1beta1/latest_wasm_code/{client_type}"; + } + + // Query for get latest wasm code entry for particular client type + rpc LatestWASMCodeEntry(LatestWASMCodeEntryQuery) returns (LatestWASMCodeEntryResponse) { + option (google.api.http).get = "/ibc/core/wasm/v1beta1/latest_wasm_code_entry/{client_type}"; + } +} \ No newline at end of file diff --git a/proto/ibc/core/wasm/v1/tx.proto b/proto/ibc/core/wasm/v1/tx.proto new file mode 100644 index 00000000000..e394f719b68 --- /dev/null +++ b/proto/ibc/core/wasm/v1/tx.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package ibc.core.wasm.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/ibc-go/modules/core/28-wasm/types"; + +// Msg defines the ibc/wasm Msg service. +service Msg { + // PushNewWASMCode defines a rpc handler method for PushNewWASMCode. + rpc PushNewWASMCode(MsgPushNewWASMCode) returns (MsgPushNewWASMCodeResponse); +} + +// Message type to push new wasm code +message MsgPushNewWASMCode { + string signer = 1; + string client_type = 2; + bytes code = 3; +} + +// Response in case of successful handling +message MsgPushNewWASMCodeResponse { + bytes code_id = 1; + string code_hash = 2; +} \ No newline at end of file diff --git a/proto/ibc/core/wasm/v1/wasm.proto b/proto/ibc/core/wasm/v1/wasm.proto new file mode 100644 index 00000000000..dd85ab39188 --- /dev/null +++ b/proto/ibc/core/wasm/v1/wasm.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package ibc.core.wasm.v1; + +option go_package = "github.com/cosmos/ibc-go/modules/core/28-wasm/types"; + +// WASM code entry that allows keeper to traverse +// the doubly linked list +message WasmCodeEntry { + bytes code_id = 1; + string previous_code_hash = 2; + string next_code_hash = 3; +} diff --git a/proto/ibc/lightclients/wasm/v1/wasm.proto b/proto/ibc/lightclients/wasm/v1/wasm.proto new file mode 100644 index 00000000000..6ab33985259 --- /dev/null +++ b/proto/ibc/lightclients/wasm/v1/wasm.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package ibc.lightclients.wasm.v1; + +import "gogoproto/gogo.proto"; +import "ibc/core/client/v1/client.proto"; +import "ibc/core/commitment/v1/commitment.proto"; +import "google/protobuf/timestamp.proto"; +import "confio/proofs.proto"; + +option go_package = "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types"; + +// WASM light client's Client state +message ClientState { + option (gogoproto.goproto_getters) = false; + bytes data = 1; + bytes code_id = 2; + bool frozen = 3; + ibc.core.client.v1.Height frozen_height = 4; + ibc.core.client.v1.Height latest_height = 5; + string type = 6; + repeated ics23.ProofSpec proof_specs = 7; +} + +// WASM light client's ConsensusState +message ConsensusState { + option (gogoproto.goproto_getters) = false; + bytes data = 1; + bytes code_id = 2; + + // timestamp that corresponds to the block height in which the ConsensusState + // was stored. + uint64 timestamp = 3; + // commitment root (i.e app hash) + ibc.core.commitment.v1.MerkleRoot root = 4; + string type = 5; +} + +// WASM light client Header +message Header { + option (gogoproto.goproto_getters) = false; + + bytes data = 1; + ibc.core.client.v1.Height height = 2; + string type = 3; +} + +// WASM light client Misbehaviour +message Misbehaviour { + bytes code_id = 1; + string client_id = 2 [(gogoproto.moretags) = "yaml:\"client_id\""]; + Header header_1 = 3 [(gogoproto.customname) = "Header1", (gogoproto.moretags) = "yaml:\"header_1\""]; + Header header_2 = 4 [(gogoproto.customname) = "Header2", (gogoproto.moretags) = "yaml:\"header_2\""]; +} From 7201c48294a8a5d235c7c02086ed8bcd16c13014 Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Wed, 12 May 2021 01:30:12 +0200 Subject: [PATCH 02/11] upgrade 10-wasm client methods to match the updated client interface --- .../10-wasm/types/client_state.go | 89 +++++++++++-------- modules/light-clients/10-wasm/types/vm.go | 25 +++--- 2 files changed, 62 insertions(+), 52 deletions(-) diff --git a/modules/light-clients/10-wasm/types/client_state.go b/modules/light-clients/10-wasm/types/client_state.go index 953ba068043..536881059d1 100644 --- a/modules/light-clients/10-wasm/types/client_state.go +++ b/modules/light-clients/10-wasm/types/client_state.go @@ -132,40 +132,28 @@ func (c *ClientState) CheckMisbehaviourAndUpdateState(context sdk.Context, marsh return output.NewClientState, nil } -func (c *ClientState) CheckProposedHeaderAndUpdateState(context sdk.Context, marshaler codec.BinaryCodec, store sdk.KVStore, header exported.Header) (exported.ClientState, exported.ConsensusState, error) { - // get consensus state corresponding to client state to check if the client is expired - consensusState, err := GetConsensusState(store, marshaler, c.LatestHeight) - if err != nil { - return nil, nil, sdkerrors.Wrapf( - err, "could not get consensus state from clientstore at height: %d", c.LatestHeight, - ) - } - - const CheckProposedHeaderAndUpdateState = "checkproposedheaderandupdatestate" - payload := make(map[string]map[string]interface{}) - payload[CheckProposedHeaderAndUpdateState] = make(map[string]interface{}) - inner := payload[CheckProposedHeaderAndUpdateState] - inner["me"] = c - inner["header"] = header - inner["consensus_state"] = consensusState - - encodedData, err := json.Marshal(payload) - if err != nil { - return nil, nil, sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) - } - out, err := callContract(c.CodeId, context, store, encodedData) - if err != nil { - return nil, nil, sdkerrors.Wrapf(ErrUnableToCall, fmt.Sprintf("underlying error: %s", err.Error())) - } - output := clientStateCallResponse{} - if err := json.Unmarshal(out.Data, &output); err != nil { - return nil, nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) - } - if !output.Result.IsValid { - return nil, nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) - } - output.resetImmutables(c) - return output.NewClientState, output.NewConsensusState, nil +func (c *ClientState) CheckSubstituteAndUpdateState( + ctx sdk.Context, cdc codec.BinaryCodec, subjectClientStore, + substituteClientStore sdk.KVStore, substituteClient exported.ClientState, + initialHeight exported.Height, +) (exported.ClientState, error) { + // TODO: How to implement this method to be WASM compatible? + // Using the example of tendermint LC (modules/light-clients/07-tendermint/types/proposal_handle.go): + // * two client stores (subject + substitute) can't be passed to WASM at the same time (only one can go) + // * copying the client states in the loop might be expensive + // * binary marshaling ain't easy on the WASM contract side (at least not implemented afaik) + // + // One option that comes to mind is to split the call to WASM (ie. validation) and non-WASM (copying the client states) + // but it won't be pretty. The flow might look like this: + // 1. (WASM) validate subjectClient Consensus State and substituteClientState + // 2a. (Go) in the loop copy the conesnus state between store + // 2b. (WASM) post update (ie. set processing time) + // 3. (WASM) validate latest consensus state from subjectClientStore + // + // ^^ This flow has approximately: + // * Wasm operations = 2 + n + // * Go operations: n + return nil, sdkerrors.Wrap(clienttypes.ErrUpdateClientFailed, "CheckSubstituteAndUpdateState is not implemented for WASM client") } func (c *ClientState) VerifyUpgradeAndUpdateState(ctx sdk.Context, cdc codec.BinaryCodec, store sdk.KVStore, newClient exported.ClientState, newConsState exported.ConsensusState, proofUpgradeClient, proofUpgradeConsState []byte) (exported.ClientState, exported.ConsensusState, error) { @@ -277,12 +265,35 @@ func (c *ClientState) GetLatestHeight() exported.Height { return c.LatestHeight } -func (c *ClientState) IsFrozen() bool { - return c.Frozen -} +func (c *ClientState) Status(ctx sdk.Context, store sdk.KVStore, cdc codec.BinaryCodec) exported.Status { + consensusState, err := GetConsensusState(store, cdc, c.LatestHeight) + if err != nil { + return exported.Unknown + } + + const Status = "status" + payload := make(map[string]map[string]interface{}) + payload[Status] = make(map[string]interface{}) + inner := payload[Status] + inner["me"] = c + inner["consensus_state"] = consensusState + + encodedData, err := json.Marshal(payload) + if err != nil { + return exported.Unknown + } + + response, err := queryContractWithStore(c.CodeId, store, encodedData) + if err != nil { + return exported.Unknown + } + + output := queryResponse{} + if err := json.Unmarshal(response, &output); err != nil { + return exported.Unknown + } -func (c *ClientState) GetFrozenHeight() exported.Height { - return c.FrozenHeight + return output.Status } func (c *ClientState) Validate() error { diff --git a/modules/light-clients/10-wasm/types/vm.go b/modules/light-clients/10-wasm/types/vm.go index a993d747ed7..93e03224349 100644 --- a/modules/light-clients/10-wasm/types/vm.go +++ b/modules/light-clients/10-wasm/types/vm.go @@ -16,19 +16,20 @@ const GasMultiplier uint64 = 100 var _ exported.ClientState = (*ClientState)(nil) type queryResponse struct { - ProofSpecs []*ics23.ProofSpec `json:"proof_specs,omitempty"` - Height types2.Height `json:"height,omitempty"` - IsFrozen bool `json:"is_frozen,omitempty"` - FrozenHeight types2.Height `json:"frozen_height,omitempty"` + ProofSpecs []*ics23.ProofSpec `json:"proof_specs,omitempty"` + Height types2.Height `json:"height,omitempty"` + IsFrozen bool `json:"is_frozen,omitempty"` + FrozenHeight types2.Height `json:"frozen_height,omitempty"` GenesisMetadata []types2.GenesisMetadata `json:"genesis_metadata,omitempty"` - Result contractResult `json:"result,omitempty"` - ClientType string `json:"client_type,omitempty"` - Root types3.MerkleRoot `json:"root,omitempty"` - Timestamp uint64 `json:"timestamp,omitempty"` + Result contractResult `json:"result,omitempty"` + ClientType string `json:"client_type,omitempty"` + Root types3.MerkleRoot `json:"root,omitempty"` + Timestamp uint64 `json:"timestamp,omitempty"` + Status exported.Status `json:"status,omitempty"` } type contractResult struct { - IsValid bool `json:"is_valid,omitempty"` + IsValid bool `json:"is_valid,omitempty"` ErrorMsg string `json:"err_msg,omitempty"` } @@ -83,13 +84,12 @@ func initContract(codeId []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) } msgInfo := types.MessageInfo{ - Sender: "", + Sender: "", SentFunds: nil, } mockFailureAPI := *api.NewMockFailureAPI() mockQuerier := api.MockQuerier{} - response, _, err := keeper.WasmVM.Instantiate(codeId, env, msgInfo, msg, store, mockFailureAPI, mockQuerier, gasMeter, gasMeter.Limit()) return response, err } @@ -126,7 +126,7 @@ func callContract(codeId []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) // Calls vm.Execute with supplied environment and gas meter func callContractWithEnvAndMeter(codeId []byte, ctx *sdk.Context, store sdk.KVStore, env types.Env, gasMeter sdk.GasMeter, msg []byte) (*types.HandleResponse, error) { msgInfo := types.MessageInfo{ - Sender: "", + Sender: "", SentFunds: nil, } mockFailureAPI := *api.NewMockFailureAPI() @@ -161,4 +161,3 @@ func consumeGas(ctx sdk.Context, gas uint64) { panic(sdk.ErrorOutOfGas{Descriptor: "Wasmer function execution"}) } } - From 49e80a5d4117683ffcd9cebe55ad9c183ae6294d Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Mon, 24 May 2021 03:35:51 +0200 Subject: [PATCH 03/11] add Status and CheckSubstituteAndUpdateState IBC methods --- .../10-wasm/types/client_state.go | 58 +++++++++---- modules/light-clients/10-wasm/types/store.go | 83 +++++++++++++++++++ 2 files changed, 124 insertions(+), 17 deletions(-) diff --git a/modules/light-clients/10-wasm/types/client_state.go b/modules/light-clients/10-wasm/types/client_state.go index 536881059d1..7d6bdf5bc73 100644 --- a/modules/light-clients/10-wasm/types/client_state.go +++ b/modules/light-clients/10-wasm/types/client_state.go @@ -137,23 +137,47 @@ func (c *ClientState) CheckSubstituteAndUpdateState( substituteClientStore sdk.KVStore, substituteClient exported.ClientState, initialHeight exported.Height, ) (exported.ClientState, error) { - // TODO: How to implement this method to be WASM compatible? - // Using the example of tendermint LC (modules/light-clients/07-tendermint/types/proposal_handle.go): - // * two client stores (subject + substitute) can't be passed to WASM at the same time (only one can go) - // * copying the client states in the loop might be expensive - // * binary marshaling ain't easy on the WASM contract side (at least not implemented afaik) - // - // One option that comes to mind is to split the call to WASM (ie. validation) and non-WASM (copying the client states) - // but it won't be pretty. The flow might look like this: - // 1. (WASM) validate subjectClient Consensus State and substituteClientState - // 2a. (Go) in the loop copy the conesnus state between store - // 2b. (WASM) post update (ie. set processing time) - // 3. (WASM) validate latest consensus state from subjectClientStore - // - // ^^ This flow has approximately: - // * Wasm operations = 2 + n - // * Go operations: n - return nil, sdkerrors.Wrap(clienttypes.ErrUpdateClientFailed, "CheckSubstituteAndUpdateState is not implemented for WASM client") + var ( + SubjectPrefix = []byte("subject/") + SubstitutePrefix = []byte("substitute/") + ) + + consensusState, err := GetConsensusState(subjectClientStore, cdc, c.LatestHeight) + if err != nil { + return nil, sdkerrors.Wrapf( + err, "unexpected error: could not get consensus state from clientstore at height: %d", c.GetLatestHeight(), + ) + } + + store := NewWrappedStore(subjectClientStore, subjectClientStore, SubjectPrefix, SubstitutePrefix) + + const CheckSubstituteAndUpdateState = "checksubstituteandupdatestate" + payload := make(map[string]map[string]interface{}) + payload[CheckSubstituteAndUpdateState] = make(map[string]interface{}) + inner := payload[CheckSubstituteAndUpdateState] + inner["me"] = c + inner["subject_consensus_state"] = consensusState + inner["substitute_client_state"] = substituteClient + inner["initial_height"] = initialHeight + + encodedData, err := json.Marshal(payload) + if err != nil { + return nil, sdkerrors.Wrapf(ErrUnableToMarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + out, err := callContract(c.CodeId, ctx, store, encodedData) + if err != nil { + return nil, sdkerrors.Wrapf(ErrUnableToCall, fmt.Sprintf("underlying error: %s", err.Error())) + } + output := clientStateCallResponse{} + if err := json.Unmarshal(out.Data, &output); err != nil { + return nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) + } + if !output.Result.IsValid { + return nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) + } + + output.resetImmutables(c) + return output.NewClientState, nil } func (c *ClientState) VerifyUpgradeAndUpdateState(ctx sdk.Context, cdc codec.BinaryCodec, store sdk.KVStore, newClient exported.ClientState, newConsState exported.ConsensusState, proofUpgradeClient, proofUpgradeConsState []byte) (exported.ClientState, exported.ConsensusState, error) { diff --git a/modules/light-clients/10-wasm/types/store.go b/modules/light-clients/10-wasm/types/store.go index a77ea88bf50..8b7d57d18d3 100644 --- a/modules/light-clients/10-wasm/types/store.go +++ b/modules/light-clients/10-wasm/types/store.go @@ -1,7 +1,14 @@ package types import ( + "bytes" + "io" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/cachekv" + "github.com/cosmos/cosmos-sdk/store/listenkv" + "github.com/cosmos/cosmos-sdk/store/tracekv" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" @@ -9,6 +16,82 @@ import ( "github.com/cosmos/ibc-go/modules/core/exported" ) +// WrappedStore combines two KVStores into one while transparently routing the calls based on key prefix +type WrappedStore struct { + first sdk.KVStore + second sdk.KVStore + + firstPrefix []byte + secondPrefix []byte +} + +func NewWrappedStore(first, second sdk.KVStore, firstPrefix, secondPrefix []byte) WrappedStore { + return WrappedStore{ + first: first, + second: second, + firstPrefix: firstPrefix, + secondPrefix: secondPrefix, + } +} + +func (ws WrappedStore) Get(key []byte) []byte { + return ws.getStore(key).Get(ws.trimPrefix(key)) +} + +func (ws WrappedStore) Has(key []byte) bool { + return ws.getStore(key).Has(ws.trimPrefix(key)) +} + +func (ws WrappedStore) Set(key, value []byte) { + ws.getStore(key).Set(ws.trimPrefix(key), value) +} + +func (ws WrappedStore) Delete(key []byte) { + ws.getStore(key).Delete(ws.trimPrefix(key)) +} + +func (ws WrappedStore) GetStoreType() storetypes.StoreType { + return ws.first.GetStoreType() +} + +func (ws WrappedStore) Iterator(start, end []byte) sdk.Iterator { + return ws.getStore(start).Iterator(ws.trimPrefix(start), ws.trimPrefix(end)) +} + +func (ws WrappedStore) ReverseIterator(start, end []byte) sdk.Iterator { + return ws.getStore(start).ReverseIterator(ws.trimPrefix(start), ws.trimPrefix(end)) +} + +func (ws WrappedStore) CacheWrap() storetypes.CacheWrap { + return cachekv.NewStore(ws) +} + +func (ws WrappedStore) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap { + return cachekv.NewStore(tracekv.NewStore(ws, w, tc)) +} + +func (ws WrappedStore) CacheWrapWithListeners(storeKey storetypes.StoreKey, listeners []storetypes.WriteListener) storetypes.CacheWrap { + return cachekv.NewStore(listenkv.NewStore(ws, storeKey, listeners)) +} + +func (ws WrappedStore) trimPrefix(key []byte) []byte { + if bytes.HasPrefix(key, ws.firstPrefix) { + key = bytes.TrimPrefix(key, ws.firstPrefix) + } else { + key = bytes.TrimPrefix(key, ws.secondPrefix) + } + + return key +} + +func (ws WrappedStore) getStore(key []byte) sdk.KVStore { + if bytes.HasPrefix(key, ws.firstPrefix) { + return ws.first + } + + return ws.second +} + // GetConsensusState retrieves the consensus state from the client prefixed // store. An error is returned if the consensus state does not exist. func GetConsensusState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height) (*ConsensusState, error) { From 59e2c4917d1ff14e8ff05e462008f5093d0e5ffb Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Mon, 24 May 2021 16:06:37 +0200 Subject: [PATCH 04/11] update Verify* methods with new delay periods --- .../10-wasm/types/client_state.go | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/light-clients/10-wasm/types/client_state.go b/modules/light-clients/10-wasm/types/client_state.go index 7d6bdf5bc73..ab2fcc1708d 100644 --- a/modules/light-clients/10-wasm/types/client_state.go +++ b/modules/light-clients/10-wasm/types/client_state.go @@ -490,7 +490,7 @@ func (c *ClientState) VerifyChannelState(store sdk.KVStore, cdc codec.BinaryCode } } -func (c *ClientState) VerifyPacketCommitment(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, currentTimestamp uint64, delayPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64, commitmentBytes []byte) error { +func (c *ClientState) VerifyPacketCommitment(ctx sdk.Context, store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, delayTimePeriod, delayBlockPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64, commitmentBytes []byte) error { consensusState, err := GetConsensusState(store, cdc, height) if err != nil { return err @@ -506,8 +506,8 @@ func (c *ClientState) VerifyPacketCommitment(store sdk.KVStore, cdc codec.Binary inner["proof"] = proof inner["port_id"] = portID inner["channel_id"] = channelID - inner["current_timestamp"] = currentTimestamp - inner["delay_period"] = delayPeriod + inner["delay_time_period"] = delayTimePeriod + inner["delay_block_period"] = delayBlockPeriod inner["sequence"] = sequence inner["commitment_bytes"] = commitmentBytes inner["consensus_state"] = consensusState @@ -534,7 +534,7 @@ func (c *ClientState) VerifyPacketCommitment(store sdk.KVStore, cdc codec.Binary } -func (c *ClientState) VerifyPacketAcknowledgement(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, currentTimestamp uint64, delayPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64, acknowledgement []byte) error { +func (c *ClientState) VerifyPacketAcknowledgement(ctx sdk.Context, store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, delayTimePeriod, delayBlockPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64, acknowledgement []byte) error { consensusState, err := GetConsensusState(store, cdc, height) if err != nil { return err @@ -550,8 +550,8 @@ func (c *ClientState) VerifyPacketAcknowledgement(store sdk.KVStore, cdc codec.B inner["proof"] = proof inner["port_id"] = portID inner["channel_id"] = channelID - inner["current_timestamp"] = currentTimestamp - inner["delay_period"] = delayPeriod + inner["delay_time_period"] = delayTimePeriod + inner["delay_block_period"] = delayBlockPeriod inner["sequence"] = sequence inner["acknowledgement"] = acknowledgement inner["consensus_state"] = consensusState @@ -577,7 +577,7 @@ func (c *ClientState) VerifyPacketAcknowledgement(store sdk.KVStore, cdc codec.B } } -func (c *ClientState) VerifyPacketReceiptAbsence(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, currentTimestamp uint64, delayPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64) error { +func (c *ClientState) VerifyPacketReceiptAbsence(ctx sdk.Context, store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, delayTimePeriod, delayBlockPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64) error { consensusState, err := GetConsensusState(store, cdc, height) if err != nil { return err @@ -593,8 +593,8 @@ func (c *ClientState) VerifyPacketReceiptAbsence(store sdk.KVStore, cdc codec.Bi inner["proof"] = proof inner["port_id"] = portID inner["channel_id"] = channelID - inner["current_timestamp"] = currentTimestamp - inner["delay_period"] = delayPeriod + inner["delay_time_period"] = delayTimePeriod + inner["delay_block_period"] = delayBlockPeriod inner["sequence"] = sequence inner["consensus_state"] = consensusState @@ -619,7 +619,7 @@ func (c *ClientState) VerifyPacketReceiptAbsence(store sdk.KVStore, cdc codec.Bi } } -func (c *ClientState) VerifyNextSequenceRecv(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, currentTimestamp uint64, delayPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, nextSequenceRecv uint64) error { +func (c *ClientState) VerifyNextSequenceRecv(ctx sdk.Context, store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, delayTimePeriod, delayBlockPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, nextSequenceRecv uint64) error { consensusState, err := GetConsensusState(store, cdc, height) if err != nil { return err @@ -635,8 +635,8 @@ func (c *ClientState) VerifyNextSequenceRecv(store sdk.KVStore, cdc codec.Binary inner["proof"] = proof inner["port_id"] = portID inner["channel_id"] = channelID - inner["current_timestamp"] = currentTimestamp - inner["delay_period"] = delayPeriod + inner["delay_time_period"] = delayTimePeriod + inner["delay_block_period"] = delayBlockPeriod inner["next_sequence_recv"] = nextSequenceRecv inner["consensus_state"] = consensusState From 11142d0f89922d9278701639fa129258eec50899 Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Tue, 25 May 2021 14:31:11 +0200 Subject: [PATCH 05/11] run linter on 28-wasm and 10-wasm codebase --- modules/core/28-wasm/cli/cli.go | 1 - modules/core/28-wasm/cli/query.go | 4 +- modules/core/28-wasm/cli/tx.go | 7 ++- modules/core/28-wasm/handler.go | 13 ++-- modules/core/28-wasm/keeper/grpc_query.go | 14 ++--- modules/core/28-wasm/keeper/keeper.go | 60 +++++++++---------- modules/core/28-wasm/keeper/validation.go | 20 +++---- modules/core/28-wasm/types/errors.go | 4 +- .../light-clients/10-wasm/client/cli/cli.go | 1 - .../light-clients/10-wasm/client/cli/tx.go | 5 +- .../10-wasm/types/client_state.go | 42 ++++++------- modules/light-clients/10-wasm/types/codec.go | 1 - .../10-wasm/types/consensus_state.go | 1 + modules/light-clients/10-wasm/types/errors.go | 12 ++-- .../10-wasm/types/fail_kv_store.go | 3 +- modules/light-clients/10-wasm/types/header.go | 1 + modules/light-clients/10-wasm/types/keys.go | 2 +- .../10-wasm/types/misbehaviour.go | 3 +- modules/light-clients/10-wasm/types/vm.go | 20 +++---- 19 files changed, 102 insertions(+), 112 deletions(-) diff --git a/modules/core/28-wasm/cli/cli.go b/modules/core/28-wasm/cli/cli.go index ba5ccd34fcc..2571b1c2ce7 100644 --- a/modules/core/28-wasm/cli/cli.go +++ b/modules/core/28-wasm/cli/cli.go @@ -40,4 +40,3 @@ func NewTxCmd() *cobra.Command { return txCmd } - diff --git a/modules/core/28-wasm/cli/query.go b/modules/core/28-wasm/cli/query.go index dbf77cdb1ad..c7f65df92ef 100644 --- a/modules/core/28-wasm/cli/query.go +++ b/modules/core/28-wasm/cli/query.go @@ -3,6 +3,7 @@ package cli import ( "context" "fmt" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" @@ -11,7 +12,6 @@ import ( "github.com/spf13/cobra" ) - // GetCmdQueryLatestWASMCode defines the command to query latest wasm code // uploaded for that client type func GetCmdQueryLatestWASMCode() *cobra.Command { @@ -20,7 +20,7 @@ func GetCmdQueryLatestWASMCode() *cobra.Command { Short: "Query latest wasm code", Long: "Query latest wasm code for particular client type", Example: fmt.Sprintf("%s query %s %s wasm_code client_type", version.AppName, host.ModuleName, types.SubModuleName), - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { diff --git a/modules/core/28-wasm/cli/tx.go b/modules/core/28-wasm/cli/tx.go index 2e15955ceb4..b3feeb9c8eb 100644 --- a/modules/core/28-wasm/cli/tx.go +++ b/modules/core/28-wasm/cli/tx.go @@ -1,12 +1,13 @@ package cli import ( + "io/ioutil" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/ibc-go/modules/core/28-wasm/types" "github.com/spf13/cobra" - "io/ioutil" ) // NewPushNewWASMCodeCmd returns the command to create a PushNewWASMCode transaction @@ -31,8 +32,8 @@ func NewPushNewWASMCodeCmd() *cobra.Command { msg := &types.MsgPushNewWASMCode{ ClientType: clientType, - Code: code, - Signer: clientCtx.GetFromAddress().String(), + Code: code, + Signer: clientCtx.GetFromAddress().String(), } if err := msg.ValidateBasic(); err != nil { diff --git a/modules/core/28-wasm/handler.go b/modules/core/28-wasm/handler.go index 70d4b2d7e21..c65b3646097 100644 --- a/modules/core/28-wasm/handler.go +++ b/modules/core/28-wasm/handler.go @@ -8,12 +8,13 @@ import ( ) func HandleMsgPushNewWASMCode(ctx sdk.Context, k keeper.Keeper, msg *types.MsgPushNewWASMCode) (*types.MsgPushNewWASMCodeResponse, error) { - if codeId, codeHash, err := k.PushNewWASMCode(ctx, msg.ClientType, msg.Code); err != nil { + codeID, codeHash, err := k.PushNewWASMCode(ctx, msg.ClientType, msg.Code) + if err != nil { return nil, sdkerrors.Wrap(err, "pushing new wasm code failed") - } else { - return &types.MsgPushNewWASMCodeResponse{ - CodeId: codeId, - CodeHash: codeHash, - }, nil } + + return &types.MsgPushNewWASMCodeResponse{ + CodeId: codeID, + CodeHash: codeHash, + }, nil } diff --git a/modules/core/28-wasm/keeper/grpc_query.go b/modules/core/28-wasm/keeper/grpc_query.go index 607ac16933c..3d4f990ed38 100644 --- a/modules/core/28-wasm/keeper/grpc_query.go +++ b/modules/core/28-wasm/keeper/grpc_query.go @@ -28,13 +28,13 @@ func (q Keeper) LatestWASMCode(c context.Context, query *types.LatestWASMCodeQue store := ctx.KVStore(q.storeKey) latestCodeKey := host.LatestWASMCode(clientType) - latestCodeId := store.Get(latestCodeKey) - if latestCodeId == nil { + latestCodeID := store.Get(latestCodeKey) + if latestCodeID == nil { return nil, status.Error(codes.NotFound, "no code has been uploaded till now.") } return &types.LatestWASMCodeResponse{ - Code: store.Get(host.WASMCode(clientType, string(latestCodeId))), + Code: store.Get(host.WASMCode(clientType, string(latestCodeID))), }, nil } @@ -52,19 +52,19 @@ func (q Keeper) LatestWASMCodeEntry(c context.Context, query *types.LatestWASMCo ctx := sdk.UnwrapSDKContext(c) store := ctx.KVStore(q.storeKey) latestCodeKey := host.LatestWASMCode(clientType) - latestCodeId := store.Get(latestCodeKey) - if latestCodeId == nil { + latestCodeID := store.Get(latestCodeKey) + if latestCodeID == nil { return nil, status.Error(codes.NotFound, "no code has been uploaded till now.") } - bz := store.Get(host.WASMCodeEntry(clientType, string(latestCodeId))) + bz := store.Get(host.WASMCodeEntry(clientType, string(latestCodeID))) var entry types.WasmCodeEntry if err := q.cdc.Unmarshal(bz, &entry); err != nil { return nil, status.Error(codes.Internal, "internal error") } return &types.LatestWASMCodeEntryResponse{ - CodeId: string(latestCodeId), + CodeId: string(latestCodeID), Entry: &entry, }, nil } diff --git a/modules/core/28-wasm/keeper/keeper.go b/modules/core/28-wasm/keeper/keeper.go index f6f98f22df8..48e87d1a215 100644 --- a/modules/core/28-wasm/keeper/keeper.go +++ b/modules/core/28-wasm/keeper/keeper.go @@ -1,20 +1,18 @@ package keeper import ( + "crypto/sha256" + "encoding/hex" "fmt" + + wasm "github.com/CosmWasm/wasmvm" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" host "github.com/cosmos/ibc-go/modules/core/24-host" - - wasm "github.com/CosmWasm/wasmvm" - "github.com/cosmos/ibc-go/modules/core/28-wasm/types" - - "crypto/sha256" - "encoding/hex" ) -// WASM VM initialized by wasm keeper +// WasmVM initialized by wasm keeper var WasmVM *wasm.VM func generateWASMCodeHash(code []byte) string { @@ -60,13 +58,11 @@ func (k Keeper) PushNewWASMCode(ctx sdk.Context, clientType string, code []byte) if isValidWASMCode, err := k.wasmValidator.validateWASMCode(code); err != nil { return nil, "", fmt.Errorf("unable to validate wasm code, error: %s", err) - } else { - if !isValidWASMCode { - return nil, "", fmt.Errorf("invalid wasm code") - } + } else if !isValidWASMCode { + return nil, "", fmt.Errorf("invalid wasm code") } - codeId, err := WasmVM.Create(code) + codeID, err := WasmVM.Create(code) if err != nil { return nil, "", fmt.Errorf("invalid wasm code") } @@ -80,26 +76,26 @@ func (k Keeper) PushNewWASMCode(ctx sdk.Context, clientType string, code []byte) // But we do not see any significant advantage of it. if store.Has(entryKey) { return nil, "", fmt.Errorf("wasm code already exists") - } else { - codeEntry := types.WasmCodeEntry{ - PreviousCodeHash: string(latestVersionCodeHash), - NextCodeHash: "", - CodeId: codeId, - } - - previousVersionEntryKey := host.WASMCodeEntry(clientType, string(latestVersionCodeHash)) - previousVersionEntryBz := store.Get(previousVersionEntryKey) - if len(previousVersionEntryBz) != 0 { - var previousEntry types.WasmCodeEntry - k.cdc.MustUnmarshal(previousVersionEntryBz, &previousEntry) - previousEntry.NextCodeHash = codeHash - store.Set(previousVersionEntryKey, k.cdc.MustMarshal(&previousEntry)) - } - - store.Set(entryKey, k.cdc.MustMarshal(&codeEntry)) - store.Set(latestVersionKey, []byte(codeHash)) - store.Set(codekey, code) } - return codeId, codeHash, nil + codeEntry := types.WasmCodeEntry{ + PreviousCodeHash: string(latestVersionCodeHash), + NextCodeHash: "", + CodeId: codeID, + } + + previousVersionEntryKey := host.WASMCodeEntry(clientType, string(latestVersionCodeHash)) + previousVersionEntryBz := store.Get(previousVersionEntryKey) + if len(previousVersionEntryBz) != 0 { + var previousEntry types.WasmCodeEntry + k.cdc.MustUnmarshal(previousVersionEntryBz, &previousEntry) + previousEntry.NextCodeHash = codeHash + store.Set(previousVersionEntryKey, k.cdc.MustMarshal(&previousEntry)) + } + + store.Set(entryKey, k.cdc.MustMarshal(&codeEntry)) + store.Set(latestVersionKey, []byte(codeHash)) + store.Set(codekey, code) + + return codeID, codeHash, nil } diff --git a/modules/core/28-wasm/keeper/validation.go b/modules/core/28-wasm/keeper/validation.go index d32e20be068..1fe739d5818 100644 --- a/modules/core/28-wasm/keeper/validation.go +++ b/modules/core/28-wasm/keeper/validation.go @@ -7,16 +7,16 @@ type WASMValidationConfig struct { MaxSizeAllowed int } -func NewWASMValidator(config *WASMValidationConfig, vmCreateFn func () (*cosmwasm.VM, error)) (*WASMValidator, error) { +func NewWASMValidator(config *WASMValidationConfig, vmCreateFn func() (*cosmwasm.VM, error)) (*WASMValidator, error) { return &WASMValidator{ - config: config, + config: config, vmCreateFn: vmCreateFn, }, nil } type WASMValidator struct { - vmCreateFn func () (*cosmwasm.VM, error) - config *WASMValidationConfig + vmCreateFn func() (*cosmwasm.VM, error) + config *WASMValidationConfig } func (v *WASMValidator) validateWASMCode(code []byte) (bool, error) { @@ -24,22 +24,16 @@ func (v *WASMValidator) validateWASMCode(code []byte) (bool, error) { return false, nil } - testVm, err := v.vmCreateFn() + testVM, err := v.vmCreateFn() if err != nil { return false, err } - _, err = testVm.Create(code) + _, err = testVM.Create(code) if err != nil { return false, nil } - // Validation start - - // Validation ends - - testVm.Cleanup() + testVM.Cleanup() return true, nil } - - diff --git a/modules/core/28-wasm/types/errors.go b/modules/core/28-wasm/types/errors.go index a1bc81c9f5d..ece468db14f 100644 --- a/modules/core/28-wasm/types/errors.go +++ b/modules/core/28-wasm/types/errors.go @@ -4,5 +4,5 @@ import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" var ( ErrEmptyClientType = sdkerrors.Register(SubModuleName, 2, "empty client type") - ErrEmptyWASMCode = sdkerrors.Register(SubModuleName, 3, "empty wasm code") -) \ No newline at end of file + ErrEmptyWASMCode = sdkerrors.Register(SubModuleName, 3, "empty wasm code") +) diff --git a/modules/light-clients/10-wasm/client/cli/cli.go b/modules/light-clients/10-wasm/client/cli/cli.go index 2773dfb0fb7..7884503cf49 100644 --- a/modules/light-clients/10-wasm/client/cli/cli.go +++ b/modules/light-clients/10-wasm/client/cli/cli.go @@ -3,7 +3,6 @@ package cli import ( "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types" "github.com/spf13/cobra" - ) // NewTxCmd returns a root CLI command handler for all x/ibc/light-clients/07-tendermint transaction commands. diff --git a/modules/light-clients/10-wasm/client/cli/tx.go b/modules/light-clients/10-wasm/client/cli/tx.go index 9f3f16b3737..9d44278a969 100644 --- a/modules/light-clients/10-wasm/client/cli/tx.go +++ b/modules/light-clients/10-wasm/client/cli/tx.go @@ -4,6 +4,8 @@ import ( "bytes" "encoding/json" "fmt" + "io/ioutil" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -12,7 +14,6 @@ import ( "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types" "github.com/pkg/errors" "github.com/spf13/cobra" - "io/ioutil" ) func NewCreateClientCmd() *cobra.Command { @@ -48,7 +49,7 @@ func NewCreateClientCmd() *cobra.Command { return errors.Wrap(err, "error unmarshalling consensus state") } - if bytes.Compare(clientState.CodeId, consensusState.CodeId) != 0 { + if !bytes.Equal(clientState.CodeId, consensusState.CodeId) { return fmt.Errorf("CodeId mismatch between client state and consensus state") } diff --git a/modules/light-clients/10-wasm/types/client_state.go b/modules/light-clients/10-wasm/types/client_state.go index ab2fcc1708d..6aa0ac75582 100644 --- a/modules/light-clients/10-wasm/types/client_state.go +++ b/modules/light-clients/10-wasm/types/client_state.go @@ -3,6 +3,7 @@ package types import ( "encoding/json" "fmt" + "github.com/CosmWasm/wasmvm/api" ics23 "github.com/confio/ics23/go" "github.com/cosmos/cosmos-sdk/codec" @@ -42,7 +43,7 @@ func (c *ClientState) Initialize(context sdk.Context, marshaler codec.BinaryCode return sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) } if !output.Result.IsValid { - return fmt.Errorf("%s error ocurred while initializing client state", output.Result.ErrorMsg) + return fmt.Errorf("%s error occurred while initializing client state", output.Result.ErrorMsg) } output.resetImmutables(c) @@ -77,7 +78,7 @@ func (c *ClientState) CheckHeaderAndUpdateState(context sdk.Context, marshaler c return nil, nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) } if !output.Result.IsValid { - return nil, nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) + return nil, nil, fmt.Errorf("%s error occurred while updating client state", output.Result.ErrorMsg) } output.resetImmutables(c) return output.NewClientState, output.NewConsensusState, nil @@ -126,7 +127,7 @@ func (c *ClientState) CheckMisbehaviourAndUpdateState(context sdk.Context, marsh return nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) } if !output.Result.IsValid { - return nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) + return nil, fmt.Errorf("%s error occurred while updating client state", output.Result.ErrorMsg) } output.resetImmutables(c) return output.NewClientState, nil @@ -173,7 +174,7 @@ func (c *ClientState) CheckSubstituteAndUpdateState( return nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) } if !output.Result.IsValid { - return nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) + return nil, fmt.Errorf("%s error occurred while updating client state", output.Result.ErrorMsg) } output.resetImmutables(c) @@ -218,7 +219,7 @@ func (c *ClientState) VerifyUpgradeAndUpdateState(ctx sdk.Context, cdc codec.Bin return nil, nil, sdkerrors.Wrapf(ErrUnableToUnmarshalPayload, fmt.Sprintf("underlying error: %s", err.Error())) } if !output.Result.IsValid { - return nil, nil, fmt.Errorf("%s error ocurred while updating client state", output.Result.ErrorMsg) + return nil, nil, fmt.Errorf("%s error occurred while updating client state", output.Result.ErrorMsg) } output.resetImmutables(c) return output.NewClientState, output.NewConsensusState, nil @@ -366,9 +367,9 @@ func (c *ClientState) VerifyClientState(store sdk.KVStore, cdc codec.BinaryCodec } if output.Result.IsValid { return nil - } else { - return fmt.Errorf("%s error while validating client state", output.Result.ErrorMsg) } + + return fmt.Errorf("%s error while validating client state", output.Result.ErrorMsg) } func (c *ClientState) VerifyClientConsensusState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, counterpartyClientIdentifier string, consensusHeight exported.Height, prefix exported.Prefix, proof []byte, consensusState exported.ConsensusState) error { @@ -406,9 +407,9 @@ func (c *ClientState) VerifyClientConsensusState(store sdk.KVStore, cdc codec.Bi if output.Result.IsValid { return nil - } else { - return fmt.Errorf("%s error while verifying consensus state", output.Result.ErrorMsg) } + + return fmt.Errorf("%s error while verifying consensus state", output.Result.ErrorMsg) } func (c *ClientState) VerifyConnectionState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, prefix exported.Prefix, proof []byte, connectionID string, connectionEnd exported.ConnectionI) error { @@ -445,9 +446,9 @@ func (c *ClientState) VerifyConnectionState(store sdk.KVStore, cdc codec.BinaryC if output.Result.IsValid { return nil - } else { - return fmt.Errorf("%s error while verifying connection state", output.Result.ErrorMsg) } + + return fmt.Errorf("%s error while verifying connection state", output.Result.ErrorMsg) } func (c *ClientState) VerifyChannelState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, prefix exported.Prefix, proof []byte, portID, channelID string, channel exported.ChannelI) error { @@ -485,9 +486,9 @@ func (c *ClientState) VerifyChannelState(store sdk.KVStore, cdc codec.BinaryCode if output.Result.IsValid { return nil - } else { - return fmt.Errorf("%s error while verifying channel state", output.Result.ErrorMsg) } + + return fmt.Errorf("%s error while verifying channel state", output.Result.ErrorMsg) } func (c *ClientState) VerifyPacketCommitment(ctx sdk.Context, store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, delayTimePeriod, delayBlockPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64, commitmentBytes []byte) error { @@ -528,10 +529,9 @@ func (c *ClientState) VerifyPacketCommitment(ctx sdk.Context, store sdk.KVStore, if output.Result.IsValid { return nil - } else { - return fmt.Errorf("%s error while verifying packet commitment", output.Result.ErrorMsg) } + return fmt.Errorf("%s error while verifying packet commitment", output.Result.ErrorMsg) } func (c *ClientState) VerifyPacketAcknowledgement(ctx sdk.Context, store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, delayTimePeriod, delayBlockPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64, acknowledgement []byte) error { @@ -572,9 +572,9 @@ func (c *ClientState) VerifyPacketAcknowledgement(ctx sdk.Context, store sdk.KVS if output.Result.IsValid { return nil - } else { - return fmt.Errorf("%s error while verifying packet acknowledgement", output.Result.ErrorMsg) } + + return fmt.Errorf("%s error while verifying packet acknowledgement", output.Result.ErrorMsg) } func (c *ClientState) VerifyPacketReceiptAbsence(ctx sdk.Context, store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, delayTimePeriod, delayBlockPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, sequence uint64) error { @@ -614,9 +614,9 @@ func (c *ClientState) VerifyPacketReceiptAbsence(ctx sdk.Context, store sdk.KVSt if output.Result.IsValid { return nil - } else { - return fmt.Errorf("%s error while verifying packet receipt absense", output.Result.ErrorMsg) } + + return fmt.Errorf("%s error while verifying packet receipt absence", output.Result.ErrorMsg) } func (c *ClientState) VerifyNextSequenceRecv(ctx sdk.Context, store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, delayTimePeriod, delayBlockPeriod uint64, prefix exported.Prefix, proof []byte, portID, channelID string, nextSequenceRecv uint64) error { @@ -656,7 +656,7 @@ func (c *ClientState) VerifyNextSequenceRecv(ctx sdk.Context, store sdk.KVStore, if output.Result.IsValid { return nil - } else { - return fmt.Errorf("%s error while verify next sequence", output.Result.ErrorMsg) } + + return fmt.Errorf("%s error while verify next sequence", output.Result.ErrorMsg) } diff --git a/modules/light-clients/10-wasm/types/codec.go b/modules/light-clients/10-wasm/types/codec.go index eb6ab39ea10..8b30076c25a 100644 --- a/modules/light-clients/10-wasm/types/codec.go +++ b/modules/light-clients/10-wasm/types/codec.go @@ -25,4 +25,3 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &Misbehaviour{}, ) } - diff --git a/modules/light-clients/10-wasm/types/consensus_state.go b/modules/light-clients/10-wasm/types/consensus_state.go index d1675fb213e..07c39cfc5d2 100644 --- a/modules/light-clients/10-wasm/types/consensus_state.go +++ b/modules/light-clients/10-wasm/types/consensus_state.go @@ -2,6 +2,7 @@ package types import ( "fmt" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" "github.com/cosmos/ibc-go/modules/core/exported" diff --git a/modules/light-clients/10-wasm/types/errors.go b/modules/light-clients/10-wasm/types/errors.go index eb1ed2ea5af..acd754eac5b 100644 --- a/modules/light-clients/10-wasm/types/errors.go +++ b/modules/light-clients/10-wasm/types/errors.go @@ -3,10 +3,10 @@ package types import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" var ( - ErrInvalidHeader = sdkerrors.Register(SubModuleName, 1, "invalid header") + ErrInvalidHeader = sdkerrors.Register(SubModuleName, 1, "invalid header") ErrUnableToUnmarshalPayload = sdkerrors.Register(SubModuleName, 2, "unable to unmarshal wasm contract return value") - ErrUnableToInit = sdkerrors.Register(SubModuleName, 3, "unable to initialize wasm contract") - ErrUnableToCall = sdkerrors.Register(SubModuleName, 4, "unable to call wasm contract") - ErrUnableToQuery = sdkerrors.Register(SubModuleName, 5, "unable to query wasm contract") - ErrUnableToMarshalPayload = sdkerrors.Register(SubModuleName, 6, "unable to marshal wasm contract payload") -) \ No newline at end of file + ErrUnableToInit = sdkerrors.Register(SubModuleName, 3, "unable to initialize wasm contract") + ErrUnableToCall = sdkerrors.Register(SubModuleName, 4, "unable to call wasm contract") + ErrUnableToQuery = sdkerrors.Register(SubModuleName, 5, "unable to query wasm contract") + ErrUnableToMarshalPayload = sdkerrors.Register(SubModuleName, 6, "unable to marshal wasm contract payload") +) diff --git a/modules/light-clients/10-wasm/types/fail_kv_store.go b/modules/light-clients/10-wasm/types/fail_kv_store.go index 6f537c0f20b..9b7d17ed479 100644 --- a/modules/light-clients/10-wasm/types/fail_kv_store.go +++ b/modules/light-clients/10-wasm/types/fail_kv_store.go @@ -1,9 +1,10 @@ package types import ( + "io" + store "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/types" - "io" ) var _ types.KVStore = (*FailKVStore)(nil) diff --git a/modules/light-clients/10-wasm/types/header.go b/modules/light-clients/10-wasm/types/header.go index daf63c47aee..ea14fa588a4 100644 --- a/modules/light-clients/10-wasm/types/header.go +++ b/modules/light-clients/10-wasm/types/header.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "github.com/cosmos/ibc-go/modules/core/exported" ) diff --git a/modules/light-clients/10-wasm/types/keys.go b/modules/light-clients/10-wasm/types/keys.go index a6d1a535ac8..790dc5bd22f 100644 --- a/modules/light-clients/10-wasm/types/keys.go +++ b/modules/light-clients/10-wasm/types/keys.go @@ -2,6 +2,6 @@ package types const ( // SubModuleName for the wasm client - SubModuleName = "wasm-client" + SubModuleName = "wasm-client" LastInstanceIDKey = "lastInstanceId" ) diff --git a/modules/light-clients/10-wasm/types/misbehaviour.go b/modules/light-clients/10-wasm/types/misbehaviour.go index c3811dcd06f..b4215ed3f5d 100644 --- a/modules/light-clients/10-wasm/types/misbehaviour.go +++ b/modules/light-clients/10-wasm/types/misbehaviour.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "github.com/cosmos/ibc-go/modules/core/exported" ) @@ -35,4 +36,4 @@ func (m *Misbehaviour) ValidateBasic() error { func (m *Misbehaviour) GetHeight() exported.Height { return m.Header1.GetHeight() -} \ No newline at end of file +} diff --git a/modules/light-clients/10-wasm/types/vm.go b/modules/light-clients/10-wasm/types/vm.go index 93e03224349..d1ded66dfe6 100644 --- a/modules/light-clients/10-wasm/types/vm.go +++ b/modules/light-clients/10-wasm/types/vm.go @@ -58,7 +58,7 @@ func (r *clientStateCallResponse) resetImmutables(c *ClientState) { } // Calls vm.Init with appropriate arguments -func initContract(codeId []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) (*types.InitResponse, error) { +func initContract(codeID []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) (*types.InitResponse, error) { gasMeter := ctx.GasMeter() chainID := ctx.BlockHeader().ChainID height := ctx.BlockHeader().Height @@ -90,12 +90,12 @@ func initContract(codeId []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) mockFailureAPI := *api.NewMockFailureAPI() mockQuerier := api.MockQuerier{} - response, _, err := keeper.WasmVM.Instantiate(codeId, env, msgInfo, msg, store, mockFailureAPI, mockQuerier, gasMeter, gasMeter.Limit()) + response, _, err := keeper.WasmVM.Instantiate(codeID, env, msgInfo, msg, store, mockFailureAPI, mockQuerier, gasMeter, gasMeter.Limit()) return response, err } // Calls vm.Execute with internally constructed Gas meter and environment -func callContract(codeId []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) (*types.HandleResponse, error) { +func callContract(codeID []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) (*types.HandleResponse, error) { gasMeter := ctx.GasMeter() chainID := ctx.BlockHeader().ChainID height := ctx.BlockHeader().Height @@ -120,11 +120,11 @@ func callContract(codeId []byte, ctx sdk.Context, store sdk.KVStore, msg []byte) }, } - return callContractWithEnvAndMeter(codeId, &ctx, store, env, gasMeter, msg) + return callContractWithEnvAndMeter(codeID, &ctx, store, env, gasMeter, msg) } // Calls vm.Execute with supplied environment and gas meter -func callContractWithEnvAndMeter(codeId []byte, ctx *sdk.Context, store sdk.KVStore, env types.Env, gasMeter sdk.GasMeter, msg []byte) (*types.HandleResponse, error) { +func callContractWithEnvAndMeter(codeID []byte, ctx *sdk.Context, store sdk.KVStore, env types.Env, gasMeter sdk.GasMeter, msg []byte) (*types.HandleResponse, error) { msgInfo := types.MessageInfo{ Sender: "", SentFunds: nil, @@ -132,24 +132,20 @@ func callContractWithEnvAndMeter(codeId []byte, ctx *sdk.Context, store sdk.KVSt mockFailureAPI := *api.NewMockFailureAPI() mockQuerier := api.MockQuerier{} - resp, gasUsed, err := keeper.WasmVM.Execute(codeId, env, msgInfo, msg, store, mockFailureAPI, mockQuerier, gasMeter, gasMeter.Limit()) + resp, gasUsed, err := keeper.WasmVM.Execute(codeID, env, msgInfo, msg, store, mockFailureAPI, mockQuerier, gasMeter, gasMeter.Limit()) if ctx != nil { consumeGas(*ctx, gasUsed) } return resp, err } -func queryContract(codeId []byte, msg []byte) ([]byte, error) { - return queryContractWithStore(codeId, &FailKVStore{}, msg) -} - -func queryContractWithStore(codeId []byte, store sdk.KVStore, msg []byte) ([]byte, error) { +func queryContractWithStore(codeID []byte, store sdk.KVStore, msg []byte) ([]byte, error) { mockEnv := api.MockEnv() mockGasMeter := api.NewMockGasMeter(1) mockFailureAPI := *api.NewMockFailureAPI() mockQuerier := api.MockQuerier{} - resp, _, err := keeper.WasmVM.Query(codeId, mockEnv, msg, store, mockFailureAPI, mockQuerier, mockGasMeter, 0) + resp, _, err := keeper.WasmVM.Query(codeID, mockEnv, msg, store, mockFailureAPI, mockQuerier, mockGasMeter, 0) return resp, err } From 220b6fef247c5c56fadfc5de6def5c13980f17ec Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Tue, 25 May 2021 15:29:00 +0200 Subject: [PATCH 06/11] refactor wasm keeper constructor --- modules/core/28-wasm/keeper/keeper.go | 19 +++++++++++++++---- modules/core/28-wasm/keeper/validation.go | 6 +++--- modules/core/keeper/keeper.go | 10 ++++++++-- .../10-wasm/types/client_state.go | 4 ++-- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/modules/core/28-wasm/keeper/keeper.go b/modules/core/28-wasm/keeper/keeper.go index 48e87d1a215..7f6e1d522af 100644 --- a/modules/core/28-wasm/keeper/keeper.go +++ b/modules/core/28-wasm/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "crypto/sha256" "encoding/hex" "fmt" + "strings" wasm "github.com/CosmWasm/wasmvm" "github.com/cosmos/cosmos-sdk/codec" @@ -15,6 +16,15 @@ import ( // WasmVM initialized by wasm keeper var WasmVM *wasm.VM +// VMConfig represents WASM virtual machine settings +type VMConfig struct { + DataDir string + SupportedFeatures []string + MemoryLimitMb uint32 + PrintDebug bool + CacheSizeMb uint32 +} + func generateWASMCodeHash(code []byte) string { hash := sha256.Sum256(code) return hex.EncodeToString(hash[:]) @@ -27,15 +37,16 @@ type Keeper struct { wasmValidator *WASMValidator } -func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, validationConfig *WASMValidationConfig) Keeper { - // TODO: Make this configurable - vm, err := wasm.NewVM("wasm_data", "staking", 8, true, 8) +func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, vmConfig *VMConfig, validationConfig *ValidationConfig) Keeper { + supportedFeatures := strings.Join(vmConfig.SupportedFeatures, ",") + + vm, err := wasm.NewVM(vmConfig.DataDir, supportedFeatures, vmConfig.MemoryLimitMb, vmConfig.PrintDebug, vmConfig.CacheSizeMb) if err != nil { panic(err) } wasmValidator, err := NewWASMValidator(validationConfig, func() (*wasm.VM, error) { - return wasm.NewVM("wasm_test_data", "staking", 8, true, 8) + return wasm.NewVM(vmConfig.DataDir, supportedFeatures, vmConfig.MemoryLimitMb, vmConfig.PrintDebug, vmConfig.CacheSizeMb) }) if err != nil { panic(err) diff --git a/modules/core/28-wasm/keeper/validation.go b/modules/core/28-wasm/keeper/validation.go index 1fe739d5818..00715d924a8 100644 --- a/modules/core/28-wasm/keeper/validation.go +++ b/modules/core/28-wasm/keeper/validation.go @@ -3,11 +3,11 @@ package keeper import cosmwasm "github.com/CosmWasm/wasmvm" // Basic validation config can be extended to add other configuration later -type WASMValidationConfig struct { +type ValidationConfig struct { MaxSizeAllowed int } -func NewWASMValidator(config *WASMValidationConfig, vmCreateFn func() (*cosmwasm.VM, error)) (*WASMValidator, error) { +func NewWASMValidator(config *ValidationConfig, vmCreateFn func() (*cosmwasm.VM, error)) (*WASMValidator, error) { return &WASMValidator{ config: config, vmCreateFn: vmCreateFn, @@ -16,7 +16,7 @@ func NewWASMValidator(config *WASMValidationConfig, vmCreateFn func() (*cosmwasm type WASMValidator struct { vmCreateFn func() (*cosmwasm.VM, error) - config *WASMValidationConfig + config *ValidationConfig } func (v *WASMValidator) validateWASMCode(code []byte) (bool, error) { diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 5a80f0507a3..05eb27c9555 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -51,8 +51,14 @@ func NewKeeper( connectionKeeper := connectionkeeper.NewKeeper(cdc, key, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper(scopedKeeper) channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) - wasmKeeper := wasmkeeper.NewKeeper(cdc, key, &wasmkeeper.WASMValidationConfig{ - MaxSizeAllowed: 1024 * 1024, + wasmKeeper := wasmkeeper.NewKeeper(cdc, key, &wasmkeeper.VMConfig{ + DataDir: "wasm_data", + SupportedFeatures: []string{"staking"}, + MemoryLimitMb: 8, + PrintDebug: true, + CacheSizeMb: 8, + }, &wasmkeeper.ValidationConfig{ + MaxSizeAllowed: 1024 * 1024, // 1 MB }) return &Keeper{ diff --git a/modules/light-clients/10-wasm/types/client_state.go b/modules/light-clients/10-wasm/types/client_state.go index 6aa0ac75582..29aa387e8e1 100644 --- a/modules/light-clients/10-wasm/types/client_state.go +++ b/modules/light-clients/10-wasm/types/client_state.go @@ -373,7 +373,7 @@ func (c *ClientState) VerifyClientState(store sdk.KVStore, cdc codec.BinaryCodec } func (c *ClientState) VerifyClientConsensusState(store sdk.KVStore, cdc codec.BinaryCodec, height exported.Height, counterpartyClientIdentifier string, consensusHeight exported.Height, prefix exported.Prefix, proof []byte, consensusState exported.ConsensusState) error { - consensusState, err := GetConsensusState(store, cdc, height) + currentConsensusState, err := GetConsensusState(store, cdc, height) if err != nil { return err } @@ -389,7 +389,7 @@ func (c *ClientState) VerifyClientConsensusState(store sdk.KVStore, cdc codec.Bi inner["counterparty_client_identifier"] = counterpartyClientIdentifier inner["proof"] = proof inner["counterparty_consensus_state"] = consensusState - inner["consensus_state"] = consensusState + inner["consensus_state"] = currentConsensusState encodedData, err := json.Marshal(payload) if err != nil { From 75811a4b4ae337750a14155c56a31709fdccf041 Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Fri, 11 Jun 2021 12:39:34 +0200 Subject: [PATCH 07/11] partial feedback: wasm_dummy removal, move from 24-host module, gas meter fix --- modules/core/02-client/types/params.go | 6 +++--- modules/core/24-host/keys.go | 12 ------------ modules/core/28-wasm/keeper/grpc_query.go | 9 ++++----- modules/core/28-wasm/keeper/keeper.go | 9 ++++----- modules/core/28-wasm/types/keys.go | 14 ++++++++++++++ .../light-clients/10-wasm/types/client_state.go | 2 +- modules/light-clients/10-wasm/types/vm.go | 3 ++- 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/modules/core/02-client/types/params.go b/modules/core/02-client/types/params.go index c606757cad8..b196ee1bf4e 100644 --- a/modules/core/02-client/types/params.go +++ b/modules/core/02-client/types/params.go @@ -10,7 +10,7 @@ import ( var ( // DefaultAllowedClients are "06-solomachine" and "07-tendermint" - DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint, "wasm_dummy"} + DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint} DefaultWASMClientEnabled = false @@ -26,9 +26,9 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new parameter configuration for the ibc client module -func NewParams(wasmClientAllowed bool, allowedClients ...string) Params { +func NewParams(wasmClientEnabled bool, allowedClients ...string) Params { return Params{ - WasmClientsEnabled: wasmClientAllowed, + WasmClientsEnabled: wasmClientEnabled, AllowedClients: allowedClients, } } diff --git a/modules/core/24-host/keys.go b/modules/core/24-host/keys.go index 483dbcedd2b..ec07af5452f 100644 --- a/modules/core/24-host/keys.go +++ b/modules/core/24-host/keys.go @@ -233,15 +233,3 @@ func sequencePath(sequence uint64) string { func PortPath(portID string) string { return fmt.Sprintf("%s/%s", KeyPortPrefix, portID) } - -func LatestWASMCode(clientType string) []byte { - return []byte(fmt.Sprintf("%s/latest", clientType)) -} - -func WASMCode(clientType string, hash string) []byte { - return []byte(fmt.Sprintf("%s/%s", clientType, hash)) -} - -func WASMCodeEntry(clientType string, codeID string) []byte { - return []byte(fmt.Sprintf("%s/%s/entry", clientType, codeID)) -} diff --git a/modules/core/28-wasm/keeper/grpc_query.go b/modules/core/28-wasm/keeper/grpc_query.go index 3d4f990ed38..e91b683b0f0 100644 --- a/modules/core/28-wasm/keeper/grpc_query.go +++ b/modules/core/28-wasm/keeper/grpc_query.go @@ -7,7 +7,6 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - host "github.com/cosmos/ibc-go/modules/core/24-host" "github.com/cosmos/ibc-go/modules/core/28-wasm/types" ) @@ -27,14 +26,14 @@ func (q Keeper) LatestWASMCode(c context.Context, query *types.LatestWASMCodeQue ctx := sdk.UnwrapSDKContext(c) store := ctx.KVStore(q.storeKey) - latestCodeKey := host.LatestWASMCode(clientType) + latestCodeKey := types.LatestWASMCode(clientType) latestCodeID := store.Get(latestCodeKey) if latestCodeID == nil { return nil, status.Error(codes.NotFound, "no code has been uploaded till now.") } return &types.LatestWASMCodeResponse{ - Code: store.Get(host.WASMCode(clientType, string(latestCodeID))), + Code: store.Get(types.WASMCode(clientType, string(latestCodeID))), }, nil } @@ -51,13 +50,13 @@ func (q Keeper) LatestWASMCodeEntry(c context.Context, query *types.LatestWASMCo ctx := sdk.UnwrapSDKContext(c) store := ctx.KVStore(q.storeKey) - latestCodeKey := host.LatestWASMCode(clientType) + latestCodeKey := types.LatestWASMCode(clientType) latestCodeID := store.Get(latestCodeKey) if latestCodeID == nil { return nil, status.Error(codes.NotFound, "no code has been uploaded till now.") } - bz := store.Get(host.WASMCodeEntry(clientType, string(latestCodeID))) + bz := store.Get(types.WASMCodeEntry(clientType, string(latestCodeID))) var entry types.WasmCodeEntry if err := q.cdc.Unmarshal(bz, &entry); err != nil { return nil, status.Error(codes.Internal, "internal error") diff --git a/modules/core/28-wasm/keeper/keeper.go b/modules/core/28-wasm/keeper/keeper.go index 7f6e1d522af..c77d225686e 100644 --- a/modules/core/28-wasm/keeper/keeper.go +++ b/modules/core/28-wasm/keeper/keeper.go @@ -9,7 +9,6 @@ import ( wasm "github.com/CosmWasm/wasmvm" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - host "github.com/cosmos/ibc-go/modules/core/24-host" "github.com/cosmos/ibc-go/modules/core/28-wasm/types" ) @@ -65,7 +64,7 @@ func (k Keeper) PushNewWASMCode(ctx sdk.Context, clientType string, code []byte) store := ctx.KVStore(k.storeKey) codeHash := generateWASMCodeHash(code) - latestVersionKey := host.LatestWASMCode(clientType) + latestVersionKey := types.LatestWASMCode(clientType) if isValidWASMCode, err := k.wasmValidator.validateWASMCode(code); err != nil { return nil, "", fmt.Errorf("unable to validate wasm code, error: %s", err) @@ -78,8 +77,8 @@ func (k Keeper) PushNewWASMCode(ctx sdk.Context, clientType string, code []byte) return nil, "", fmt.Errorf("invalid wasm code") } - codekey := host.WASMCode(clientType, codeHash) - entryKey := host.WASMCodeEntry(clientType, codeHash) + codekey := types.WASMCode(clientType, codeHash) + entryKey := types.WASMCodeEntry(clientType, codeHash) latestVersionCodeHash := store.Get(latestVersionKey) @@ -95,7 +94,7 @@ func (k Keeper) PushNewWASMCode(ctx sdk.Context, clientType string, code []byte) CodeId: codeID, } - previousVersionEntryKey := host.WASMCodeEntry(clientType, string(latestVersionCodeHash)) + previousVersionEntryKey := types.WASMCodeEntry(clientType, string(latestVersionCodeHash)) previousVersionEntryBz := store.Get(previousVersionEntryKey) if len(previousVersionEntryBz) != 0 { var previousEntry types.WasmCodeEntry diff --git a/modules/core/28-wasm/types/keys.go b/modules/core/28-wasm/types/keys.go index b90e2860e19..d6b8b9ab3db 100644 --- a/modules/core/28-wasm/types/keys.go +++ b/modules/core/28-wasm/types/keys.go @@ -1,5 +1,19 @@ package types +import "fmt" + const ( SubModuleName = "wasm-manager" ) + +func LatestWASMCode(clientType string) []byte { + return []byte(fmt.Sprintf("%s/latest", clientType)) +} + +func WASMCode(clientType string, hash string) []byte { + return []byte(fmt.Sprintf("%s/%s", clientType, hash)) +} + +func WASMCodeEntry(clientType string, codeID string) []byte { + return []byte(fmt.Sprintf("%s/%s/entry", clientType, codeID)) +} diff --git a/modules/light-clients/10-wasm/types/client_state.go b/modules/light-clients/10-wasm/types/client_state.go index 29aa387e8e1..7293848b0f0 100644 --- a/modules/light-clients/10-wasm/types/client_state.go +++ b/modules/light-clients/10-wasm/types/client_state.go @@ -237,7 +237,7 @@ func (c *ClientState) ZeroCustomFields() exported.ClientState { // TODO: Handle error } - gasMeter := sdk.NewGasMeter(0) + gasMeter := sdk.NewGasMeter(maxGasLimit) out, err := callContractWithEnvAndMeter(c.CodeId, nil, &FailKVStore{}, api.MockEnv(), gasMeter, encodedData) if err != nil { // TODO: Handle error diff --git a/modules/light-clients/10-wasm/types/vm.go b/modules/light-clients/10-wasm/types/vm.go index d1ded66dfe6..b31b7796637 100644 --- a/modules/light-clients/10-wasm/types/vm.go +++ b/modules/light-clients/10-wasm/types/vm.go @@ -12,6 +12,7 @@ import ( ) const GasMultiplier uint64 = 100 +const maxGasLimit = uint64(0x7FFFFFFFFFFFFFFF) var _ exported.ClientState = (*ClientState)(nil) @@ -145,7 +146,7 @@ func queryContractWithStore(codeID []byte, store sdk.KVStore, msg []byte) ([]byt mockFailureAPI := *api.NewMockFailureAPI() mockQuerier := api.MockQuerier{} - resp, _, err := keeper.WasmVM.Query(codeID, mockEnv, msg, store, mockFailureAPI, mockQuerier, mockGasMeter, 0) + resp, _, err := keeper.WasmVM.Query(codeID, mockEnv, msg, store, mockFailureAPI, mockQuerier, mockGasMeter, maxGasLimit) return resp, err } From addc5d25bffbf40d588b5fb56a9f0a508ddba3af Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Mon, 14 Jun 2021 22:56:04 +0200 Subject: [PATCH 08/11] remove 10-wasm cli handlers --- modules/core/client/cli/cli.go | 4 +- .../light-clients/10-wasm/client/cli/cli.go | 24 --- .../light-clients/10-wasm/client/cli/tx.go | 165 ------------------ modules/light-clients/10-wasm/module.go | 7 - 4 files changed, 1 insertion(+), 199 deletions(-) delete mode 100644 modules/light-clients/10-wasm/client/cli/cli.go delete mode 100644 modules/light-clients/10-wasm/client/cli/tx.go diff --git a/modules/core/client/cli/cli.go b/modules/core/client/cli/cli.go index a8fc11bc1f5..db985789d59 100644 --- a/modules/core/client/cli/cli.go +++ b/modules/core/client/cli/cli.go @@ -4,12 +4,11 @@ import ( "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - wasmmanager "github.com/cosmos/ibc-go/modules/core/28-wasm" - wasm "github.com/cosmos/ibc-go/modules/light-clients/10-wasm" ibcclient "github.com/cosmos/ibc-go/modules/core/02-client" connection "github.com/cosmos/ibc-go/modules/core/03-connection" channel "github.com/cosmos/ibc-go/modules/core/04-channel" host "github.com/cosmos/ibc-go/modules/core/24-host" + wasmmanager "github.com/cosmos/ibc-go/modules/core/28-wasm" ) // GetTxCmd returns the transaction commands for this module @@ -26,7 +25,6 @@ func GetTxCmd() *cobra.Command { ibcclient.GetTxCmd(), channel.GetTxCmd(), wasmmanager.GetTxCmd(), - wasm.GetTxCmd(), ) return ibcTxCmd diff --git a/modules/light-clients/10-wasm/client/cli/cli.go b/modules/light-clients/10-wasm/client/cli/cli.go deleted file mode 100644 index 7884503cf49..00000000000 --- a/modules/light-clients/10-wasm/client/cli/cli.go +++ /dev/null @@ -1,24 +0,0 @@ -package cli - -import ( - "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types" - "github.com/spf13/cobra" -) - -// NewTxCmd returns a root CLI command handler for all x/ibc/light-clients/07-tendermint transaction commands. -func NewTxCmd() *cobra.Command { - txCmd := &cobra.Command{ - Use: types.SubModuleName, - Short: "WASM client transaction subcommands", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - } - - txCmd.AddCommand( - NewCreateClientCmd(), - NewUpdateClientCmd(), - NewSubmitMisbehaviourCmd(), - ) - - return txCmd -} diff --git a/modules/light-clients/10-wasm/client/cli/tx.go b/modules/light-clients/10-wasm/client/cli/tx.go deleted file mode 100644 index 9d44278a969..00000000000 --- a/modules/light-clients/10-wasm/client/cli/tx.go +++ /dev/null @@ -1,165 +0,0 @@ -package cli - -import ( - "bytes" - "encoding/json" - "fmt" - "io/ioutil" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/version" - clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" - "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -func NewCreateClientCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "create [CodeID in hex] [path/to/consensus_state.bin] [path/to/client_state.bin]", - Short: "create new wasm client", - Long: "Create a new wasm IBC client", - Example: fmt.Sprintf("%s tx ibc %s create [path/to/consensus_state.json] [path/to/client_state.json]", version.AppName, types.SubModuleName), - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - clientStateBytes, err := ioutil.ReadFile(args[1]) - if err != nil { - return errors.Wrap(err, "error reading client state from file") - } - - clientState := types.ClientState{} - if err := json.Unmarshal(clientStateBytes, &clientState); err != nil { - return errors.Wrap(err, "error unmarshalling client state") - } - - consensusStateBytes, err := ioutil.ReadFile(args[2]) - if err != nil { - return errors.Wrap(err, "error reading consensus state from file") - } - - consensusState := types.ConsensusState{} - if err := json.Unmarshal(consensusStateBytes, &consensusState); err != nil { - return errors.Wrap(err, "error unmarshalling consensus state") - } - - if !bytes.Equal(clientState.CodeId, consensusState.CodeId) { - return fmt.Errorf("CodeId mismatch between client state and consensus state") - } - - msg, err := clienttypes.NewMsgCreateClient( - &clientState, &consensusState, clientCtx.GetFromAddress().String(), - ) - if err != nil { - return errors.Wrap(err, "error composing MsgCreateClient") - } - - if err := msg.ValidateBasic(); err != nil { - return errors.Wrap(err, "error validating MsgCreateClient") - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func NewUpdateClientCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "update [client-id] [Code Id in hex] [path/to/header.bin]", - Short: "update existing client with a header", - Long: "update existing wasm client with a header", - Example: fmt.Sprintf( - "$ %s tx ibc %s update [client-id] [path/to/header.json] --from node0 --home ../node0/cli --chain-id $CID", - version.AppName, types.SubModuleName, - ), - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - clientID := args[0] - - headerBytes, err := ioutil.ReadFile(args[2]) - if err != nil { - return errors.Wrap(err, "error reading header from file") - } - - header := types.Header{} - if err := json.Unmarshal(headerBytes, &header); err != nil { - return errors.Wrap(err, "error unmarshalling header") - } - - msg, err := clienttypes.NewMsgUpdateClient(clientID, &header, clientCtx.GetFromAddress().String()) - if err != nil { - return errors.Wrap(err, "error composing MsgUpdateClient") - } - - if err := msg.ValidateBasic(); err != nil { - return errors.Wrap(err, "error validating MsgUpdateClient") - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func NewSubmitMisbehaviourCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "misbehaviour [client-Id] [path/to/misbehaviour.json]", - Short: "submit a client misbehaviour", - Long: "submit a client misbehaviour to invalidate to invalidate previous state roots and prevent future updates", - Example: fmt.Sprintf( - "$ %s tx ibc %s misbehaviour [client-Id] [path/to/misbehaviour.json] --from node0 --home ../node0/cli --chain-id $CID", - version.AppName, types.SubModuleName, - ), - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - clientID := args[0] - - misbehaviourBytes, err := ioutil.ReadFile(args[2]) - if err != nil { - return errors.Wrap(err, "error reading header1 from file") - } - - misbehaviour := types.Misbehaviour{} - if err := json.Unmarshal(misbehaviourBytes, &misbehaviour); err != nil { - return errors.Wrap(err, "error unmarshalling misbehaviour") - } - misbehaviour.ClientId = clientID - - msg, err := clienttypes.NewMsgSubmitMisbehaviour(misbehaviour.ClientId, &misbehaviour, clientCtx.GetFromAddress().String()) - if err != nil { - return errors.Wrap(err, "error composing MsgSubmitMisbehaviour") - } - - if err := msg.ValidateBasic(); err != nil { - return errors.Wrap(err, "error validating MsgSubmitMisbehaviour") - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/modules/light-clients/10-wasm/module.go b/modules/light-clients/10-wasm/module.go index 8542ac935f4..0eb880705d4 100644 --- a/modules/light-clients/10-wasm/module.go +++ b/modules/light-clients/10-wasm/module.go @@ -1,17 +1,10 @@ package wasm import ( - "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/client/cli" "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types" - "github.com/spf13/cobra" ) // Name returns the IBC client name func Name() string { return types.SubModuleName } - -// GetTxCmd returns the root tx command for the IBC client -func GetTxCmd() *cobra.Command { - return cli.NewTxCmd() -} From 10ea5ced7b9bddc172a31c7e514e5a36272db249 Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Tue, 15 Jun 2021 01:10:41 +0200 Subject: [PATCH 09/11] update client selection --- modules/core/02-client/types/params.go | 14 ++++++++++++-- modules/core/exported/client.go | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/core/02-client/types/params.go b/modules/core/02-client/types/params.go index b196ee1bf4e..2227c185a55 100644 --- a/modules/core/02-client/types/params.go +++ b/modules/core/02-client/types/params.go @@ -12,11 +12,13 @@ var ( // DefaultAllowedClients are "06-solomachine" and "07-tendermint" DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint} - DefaultWASMClientEnabled = false + // DefaultWasmClientsEnabled is false + DefaultWasmClientsEnabled = false // KeyAllowedClients is store's key for AllowedClients Params KeyAllowedClients = []byte("AllowedClients") + // KeyWasmClientsEnabled indicates whether Wasm light clients are allowed KeyWasmClientsEnabled = []byte("WasmClientsEnabled") ) @@ -35,7 +37,7 @@ func NewParams(wasmClientEnabled bool, allowedClients ...string) Params { // DefaultParams is the default parameter configuration for the ibc-client module func DefaultParams() Params { - return NewParams(DefaultWASMClientEnabled, DefaultAllowedClients...) + return NewParams(DefaultWasmClientsEnabled, DefaultAllowedClients...) } // Validate all ibc-client module parameters @@ -58,6 +60,10 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { // IsAllowedClient checks if the given client type is registered on the allowlist. func (p Params) IsAllowedClient(clientType string) bool { + if p.WasmClientsEnabled && isWasmClient(clientType) { + return true + } + for _, allowedClient := range p.AllowedClients { if allowedClient == clientType { return true @@ -89,3 +95,7 @@ func validateClients(i interface{}) error { return nil } + +func isWasmClient(clientType string) bool { + return strings.HasPrefix(clientType, exported.WasmClientPrefix) +} diff --git a/modules/core/exported/client.go b/modules/core/exported/client.go index 8de7976c14c..6863a1c42fa 100644 --- a/modules/core/exported/client.go +++ b/modules/core/exported/client.go @@ -15,6 +15,9 @@ const ( // TypeClientMisbehaviour is the shared evidence misbehaviour type TypeClientMisbehaviour string = "client_misbehaviour" + // WasmClientPrefix is used to indicate that the client is a on-chain Wasm blob. + WasmClientPrefix string = "wasm-" + // Solomachine is used to indicate that the light client is a solo machine. Solomachine string = "06-solomachine" From 364a2ac1012043f82b3eecf6c72af5c6e19504d8 Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Wed, 16 Jun 2021 15:19:51 +0200 Subject: [PATCH 10/11] simplify client status management --- docs/ibc/proto-docs.md | 97 +-- modules/core/02-client/keeper/params.go | 9 +- modules/core/02-client/types/events.go | 2 + modules/core/02-client/types/genesis_test.go | 30 +- modules/core/02-client/types/params.go | 22 +- modules/core/02-client/types/params_test.go | 4 +- modules/core/28-wasm/cli/cli.go | 3 +- modules/core/28-wasm/cli/query.go | 54 +- modules/core/28-wasm/cli/tx.go | 12 +- modules/core/28-wasm/handler.go | 5 +- modules/core/28-wasm/keeper/grpc_query.go | 57 +- modules/core/28-wasm/keeper/keeper.go | 58 +- modules/core/28-wasm/types/errors.go | 8 +- modules/core/28-wasm/types/keys.go | 17 +- modules/core/28-wasm/types/msgs.go | 8 +- modules/core/28-wasm/types/query.pb.go | 623 +++--------------- modules/core/28-wasm/types/query.pb.gw.go | 142 +--- modules/core/28-wasm/types/tx.pb.go | 148 +---- modules/core/28-wasm/types/wasm.pb.go | 425 ------------ modules/core/exported/client.go | 6 +- modules/core/genesis_test.go | 6 +- modules/core/keeper/grpc_query.go | 13 +- modules/core/keeper/msg_server.go | 23 +- .../07-tendermint/types/tendermint.pb.go | 4 +- .../10-wasm/types/client_state.go | 2 +- .../10-wasm/types/consensus_state.go | 2 +- modules/light-clients/10-wasm/types/header.go | 2 +- .../10-wasm/types/misbehaviour.go | 10 - modules/light-clients/10-wasm/types/vm.go | 6 - .../light-clients/10-wasm/types/wasm.pb.go | 390 ++--------- proto/ibc/core/wasm/v1/query.proto | 35 +- proto/ibc/core/wasm/v1/tx.proto | 4 +- proto/ibc/core/wasm/v1/wasm.proto | 12 - proto/ibc/lightclients/wasm/v1/wasm.proto | 18 +- 34 files changed, 328 insertions(+), 1929 deletions(-) delete mode 100644 modules/core/28-wasm/types/wasm.pb.go delete mode 100644 proto/ibc/core/wasm/v1/wasm.proto diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index e809f69ba0a..71b6ccfb820 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -192,14 +192,9 @@ - [ibc/core/types/v1/genesis.proto](#ibc/core/types/v1/genesis.proto) - [GenesisState](#ibc.core.types.v1.GenesisState) -- [ibc/core/wasm/v1/wasm.proto](#ibc/core/wasm/v1/wasm.proto) - - [WasmCodeEntry](#ibc.core.wasm.v1.WasmCodeEntry) - - [ibc/core/wasm/v1/query.proto](#ibc/core/wasm/v1/query.proto) - - [LatestWASMCodeEntryQuery](#ibc.core.wasm.v1.LatestWASMCodeEntryQuery) - - [LatestWASMCodeEntryResponse](#ibc.core.wasm.v1.LatestWASMCodeEntryResponse) - - [LatestWASMCodeQuery](#ibc.core.wasm.v1.LatestWASMCodeQuery) - - [LatestWASMCodeResponse](#ibc.core.wasm.v1.LatestWASMCodeResponse) + - [WasmCodeQuery](#ibc.core.wasm.v1.WasmCodeQuery) + - [WasmCodeResponse](#ibc.core.wasm.v1.WasmCodeResponse) - [Query](#ibc.core.wasm.v1.Query) @@ -2903,40 +2898,6 @@ GenesisState defines the ibc module's genesis state. - - - - - - - - - - - -

Top

- -## ibc/core/wasm/v1/wasm.proto - - - - - -### WasmCodeEntry -WASM code entry that allows keeper to traverse -the doubly linked list - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `code_id` | [bytes](#bytes) | | | -| `previous_code_hash` | [string](#string) | | | -| `next_code_hash` | [string](#string) | | | - - - - - @@ -2954,56 +2915,25 @@ the doubly linked list - - -### LatestWASMCodeEntryQuery -Latest wasm code entry query - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `client_type` | [string](#string) | | | - - - - - - - + -### LatestWASMCodeEntryResponse -Latest wasm code entry response +### WasmCodeQuery +WasmCode query | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `code_id` | [string](#string) | | | -| `entry` | [WasmCodeEntry](#ibc.core.wasm.v1.WasmCodeEntry) | | | - + -### LatestWASMCodeQuery -Latest wasm code query - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `client_type` | [string](#string) | | | - - - - - - - - -### LatestWASMCodeResponse -Latest wasm code response +### WasmCodeResponse +WasmCode response | Field | Type | Label | Description | @@ -3028,8 +2958,7 @@ Query service for wasm module | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `LatestWASMCode` | [LatestWASMCodeQuery](#ibc.core.wasm.v1.LatestWASMCodeQuery) | [LatestWASMCodeResponse](#ibc.core.wasm.v1.LatestWASMCodeResponse) | Query to get latest wasm code for particular client type. | GET|/ibc/core/wasm/v1beta1/latest_wasm_code/{client_type}| -| `LatestWASMCodeEntry` | [LatestWASMCodeEntryQuery](#ibc.core.wasm.v1.LatestWASMCodeEntryQuery) | [LatestWASMCodeEntryResponse](#ibc.core.wasm.v1.LatestWASMCodeEntryResponse) | Query for get latest wasm code entry for particular client type | GET|/ibc/core/wasm/v1beta1/latest_wasm_code_entry/{client_type}| +| `WasmCode` | [WasmCodeQuery](#ibc.core.wasm.v1.WasmCodeQuery) | [WasmCodeResponse](#ibc.core.wasm.v1.WasmCodeResponse) | Get Wasm code for given code id | GET|/ibc/core/wasm/v1beta1/code/{code_id}| @@ -3051,7 +2980,6 @@ Message type to push new wasm code | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `signer` | [string](#string) | | | -| `client_type` | [string](#string) | | | | `code` | [bytes](#bytes) | | | @@ -3068,7 +2996,6 @@ Response in case of successful handling | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `code_id` | [bytes](#bytes) | | | -| `code_hash` | [string](#string) | | | @@ -3585,10 +3512,7 @@ WASM light client's Client state | ----- | ---- | ----- | ----------- | | `data` | [bytes](#bytes) | | | | `code_id` | [bytes](#bytes) | | | -| `frozen` | [bool](#bool) | | | -| `frozen_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | | `latest_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `type` | [string](#string) | | | | `proof_specs` | [ics23.ProofSpec](#ics23.ProofSpec) | repeated | | @@ -3608,7 +3532,6 @@ WASM light client's ConsensusState | `code_id` | [bytes](#bytes) | | | | `timestamp` | [uint64](#uint64) | | timestamp that corresponds to the block height in which the ConsensusState was stored. | | `root` | [ibc.core.commitment.v1.MerkleRoot](#ibc.core.commitment.v1.MerkleRoot) | | commitment root (i.e app hash) | -| `type` | [string](#string) | | | @@ -3625,7 +3548,6 @@ WASM light client Header | ----- | ---- | ----- | ----------- | | `data` | [bytes](#bytes) | | | | `height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | | -| `type` | [string](#string) | | | @@ -3640,7 +3562,6 @@ WASM light client Misbehaviour | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `code_id` | [bytes](#bytes) | | | | `client_id` | [string](#string) | | | | `header_1` | [Header](#ibc.lightclients.wasm.v1.Header) | | | | `header_2` | [Header](#ibc.lightclients.wasm.v1.Header) | | | diff --git a/modules/core/02-client/keeper/params.go b/modules/core/02-client/keeper/params.go index 477f54f52b2..2addf95d0df 100644 --- a/modules/core/02-client/keeper/params.go +++ b/modules/core/02-client/keeper/params.go @@ -12,16 +12,9 @@ func (k Keeper) GetAllowedClients(ctx sdk.Context) []string { return res } -// GetParams returns the total set of ibc-client parameters. -func (k Keeper) GetWasmClientsEnabled(ctx sdk.Context) bool { - var res bool - k.paramSpace.Get(ctx, types.KeyWasmClientsEnabled, &res) - return res -} - // GetParams returns the total set of ibc-client parameters. func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams(k.GetWasmClientsEnabled(ctx), k.GetAllowedClients(ctx)...) + return types.NewParams(k.GetAllowedClients(ctx)...) } // SetParams sets the total set of ibc-client parameters. diff --git a/modules/core/02-client/types/events.go b/modules/core/02-client/types/events.go index 464ad4d426e..5975cb76098 100644 --- a/modules/core/02-client/types/events.go +++ b/modules/core/02-client/types/events.go @@ -13,6 +13,7 @@ const ( AttributeKeyClientType = "client_type" AttributeKeyConsensusHeight = "consensus_height" AttributeKeyHeader = "header" + AttributeKeyWasmCodeID = "wasm_code_id" ) // IBC client events vars @@ -22,6 +23,7 @@ var ( EventTypeUpgradeClient = "upgrade_client" EventTypeSubmitMisbehaviour = "client_misbehaviour" EventTypeUpdateClientProposal = "update_client_proposal" + EventTypePushWasmCode = "push_wasm_code" AttributeValueCategory = fmt.Sprintf("%s_%s", host.ModuleName, SubModuleName) ) diff --git a/modules/core/02-client/types/genesis_test.go b/modules/core/02-client/types/genesis_test.go index 1523f38f99d..ab2c479c6f1 100644 --- a/modules/core/02-client/types/genesis_test.go +++ b/modules/core/02-client/types/genesis_test.go @@ -101,7 +101,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, - types.NewParams(true, exported.Tendermint, exported.Localhost), + types.NewParams(exported.Tendermint, exported.Localhost), false, 2, ), @@ -132,7 +132,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, exported.Tendermint), + types.NewParams(exported.Tendermint), false, 0, ), @@ -149,7 +149,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, nil, nil, - types.NewParams(true, exported.Tendermint), + types.NewParams(exported.Tendermint), false, 0, ), @@ -180,7 +180,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, exported.Tendermint), + types.NewParams(exported.Tendermint), false, 0, ), @@ -211,7 +211,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, exported.Tendermint), + types.NewParams(exported.Tendermint), false, 0, ), @@ -242,7 +242,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, exported.Tendermint), + types.NewParams(exported.Tendermint), false, 0, ), @@ -273,7 +273,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, exported.Solomachine), + types.NewParams(exported.Solomachine), false, 0, ), @@ -312,7 +312,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, - types.NewParams(true, exported.Tendermint, exported.Localhost), + types.NewParams(exported.Tendermint, exported.Localhost), false, 0, ), @@ -348,7 +348,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, - types.NewParams(true, exported.Tendermint), + types.NewParams(exported.Tendermint), false, 0, ), @@ -378,7 +378,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, " "), + types.NewParams(" "), false, 0, ), @@ -409,7 +409,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, " "), + types.NewParams(" "), true, 0, ), @@ -440,7 +440,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, exported.Tendermint), + types.NewParams(exported.Tendermint), true, 2, ), @@ -471,7 +471,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, exported.Tendermint, exported.Localhost), + types.NewParams(exported.Tendermint, exported.Localhost), false, 0, ), @@ -502,7 +502,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, exported.Tendermint, exported.Localhost), + types.NewParams(exported.Tendermint, exported.Localhost), false, 5, ), @@ -530,7 +530,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { ), }, nil, - types.NewParams(true, exported.Tendermint, exported.Localhost), + types.NewParams(exported.Tendermint, exported.Localhost), false, 5, ), diff --git a/modules/core/02-client/types/params.go b/modules/core/02-client/types/params.go index 2227c185a55..8ab9a227b56 100644 --- a/modules/core/02-client/types/params.go +++ b/modules/core/02-client/types/params.go @@ -12,14 +12,8 @@ var ( // DefaultAllowedClients are "06-solomachine" and "07-tendermint" DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint} - // DefaultWasmClientsEnabled is false - DefaultWasmClientsEnabled = false - // KeyAllowedClients is store's key for AllowedClients Params KeyAllowedClients = []byte("AllowedClients") - - // KeyWasmClientsEnabled indicates whether Wasm light clients are allowed - KeyWasmClientsEnabled = []byte("WasmClientsEnabled") ) // ParamKeyTable type declaration for parameters @@ -28,16 +22,15 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new parameter configuration for the ibc client module -func NewParams(wasmClientEnabled bool, allowedClients ...string) Params { +func NewParams(allowedClients ...string) Params { return Params{ - WasmClientsEnabled: wasmClientEnabled, - AllowedClients: allowedClients, + AllowedClients: allowedClients, } } // DefaultParams is the default parameter configuration for the ibc-client module func DefaultParams() Params { - return NewParams(DefaultWasmClientsEnabled, DefaultAllowedClients...) + return NewParams(DefaultAllowedClients...) } // Validate all ibc-client module parameters @@ -54,16 +47,11 @@ func (p Params) Validate() error { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyAllowedClients, p.AllowedClients, validateClients), - paramtypes.NewParamSetPair(KeyWasmClientsEnabled, p.WasmClientsEnabled, validateWasmClientEnabledFlag), } } // IsAllowedClient checks if the given client type is registered on the allowlist. func (p Params) IsAllowedClient(clientType string) bool { - if p.WasmClientsEnabled && isWasmClient(clientType) { - return true - } - for _, allowedClient := range p.AllowedClients { if allowedClient == clientType { return true @@ -95,7 +83,3 @@ func validateClients(i interface{}) error { return nil } - -func isWasmClient(clientType string) bool { - return strings.HasPrefix(clientType, exported.WasmClientPrefix) -} diff --git a/modules/core/02-client/types/params_test.go b/modules/core/02-client/types/params_test.go index d826fe8efdb..1f3d0571b36 100644 --- a/modules/core/02-client/types/params_test.go +++ b/modules/core/02-client/types/params_test.go @@ -15,8 +15,8 @@ func TestValidateParams(t *testing.T) { expPass bool }{ {"default params", DefaultParams(), true}, - {"custom params", NewParams(true, exported.Tendermint), true}, - {"blank client", NewParams(false, " "), false}, + {"custom params", NewParams(exported.Tendermint), true}, + {"blank client", NewParams(" "), false}, } for _, tc := range testCases { diff --git a/modules/core/28-wasm/cli/cli.go b/modules/core/28-wasm/cli/cli.go index 2571b1c2ce7..39e79c52695 100644 --- a/modules/core/28-wasm/cli/cli.go +++ b/modules/core/28-wasm/cli/cli.go @@ -17,8 +17,7 @@ func GetQueryCmd() *cobra.Command { } queryCmd.AddCommand( - GetCmdQueryLatestWASMCode(), - GetCmdQueryLatestWASMCodeEntry(), + GetCmdCode(), ) return queryCmd diff --git a/modules/core/28-wasm/cli/query.go b/modules/core/28-wasm/cli/query.go index c7f65df92ef..8696c874720 100644 --- a/modules/core/28-wasm/cli/query.go +++ b/modules/core/28-wasm/cli/query.go @@ -12,48 +12,14 @@ import ( "github.com/spf13/cobra" ) -// GetCmdQueryLatestWASMCode defines the command to query latest wasm code -// uploaded for that client type -func GetCmdQueryLatestWASMCode() *cobra.Command { +// GetCmdCode defines the command to query wasm code for given code id +func GetCmdCode() *cobra.Command { cmd := &cobra.Command{ - Use: "wasm_code client_type", - Short: "Query latest wasm code", - Long: "Query latest wasm code for particular client type", - Example: fmt.Sprintf("%s query %s %s wasm_code client_type", version.AppName, host.ModuleName, types.SubModuleName), - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - clientType := args[0] - req := types.LatestWASMCodeQuery{ - ClientType: clientType, - } - - res, err := queryClient.LatestWASMCode(context.Background(), &req) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - flags.AddQueryFlagsToCmd(cmd) - return cmd -} - -// GetCmdQueryLatestWASMCodeEntry defines the command to query latest wasm code's entry -// for that client type -func GetCmdQueryLatestWASMCodeEntry() *cobra.Command { - cmd := &cobra.Command{ - Use: "wasm_code_entry client_type", - Short: "Query wasm code entry", - Long: "Query latest wasm code entry", + Use: "code [code-id]", + Short: "Query wasm code", + Long: "Query wasm code", Example: fmt.Sprintf( - "%s query %s %s wasm_code_entry client_type", version.AppName, host.ModuleName, types.SubModuleName, + "%s query %s %s code [code-id]", version.AppName, host.ModuleName, types.SubModuleName, ), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -63,12 +29,12 @@ func GetCmdQueryLatestWASMCodeEntry() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - clientType := args[0] - req := types.LatestWASMCodeEntryQuery{ - ClientType: clientType, + codeID := args[0] + req := types.WasmCodeQuery{ + CodeId: codeID, } - res, err := queryClient.LatestWASMCodeEntry(context.Background(), &req) + res, err := queryClient.WasmCode(context.Background(), &req) if err != nil { return err } diff --git a/modules/core/28-wasm/cli/tx.go b/modules/core/28-wasm/cli/tx.go index b3feeb9c8eb..87afd674ecb 100644 --- a/modules/core/28-wasm/cli/tx.go +++ b/modules/core/28-wasm/cli/tx.go @@ -13,17 +13,16 @@ import ( // NewPushNewWASMCodeCmd returns the command to create a PushNewWASMCode transaction func NewPushNewWASMCodeCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "push_wasm client_type wasm_file", + Use: "push-wasm [wasm-file]", Short: "Reads wasm code from the file and creates push transaction", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - clientType := args[0] - fileName := args[1] + fileName := args[0] code, err := ioutil.ReadFile(fileName) if err != nil { @@ -31,9 +30,8 @@ func NewPushNewWASMCodeCmd() *cobra.Command { } msg := &types.MsgPushNewWASMCode{ - ClientType: clientType, - Code: code, - Signer: clientCtx.GetFromAddress().String(), + Code: code, + Signer: clientCtx.GetFromAddress().String(), } if err := msg.ValidateBasic(); err != nil { diff --git a/modules/core/28-wasm/handler.go b/modules/core/28-wasm/handler.go index c65b3646097..b864410de4c 100644 --- a/modules/core/28-wasm/handler.go +++ b/modules/core/28-wasm/handler.go @@ -8,13 +8,12 @@ import ( ) func HandleMsgPushNewWASMCode(ctx sdk.Context, k keeper.Keeper, msg *types.MsgPushNewWASMCode) (*types.MsgPushNewWASMCodeResponse, error) { - codeID, codeHash, err := k.PushNewWASMCode(ctx, msg.ClientType, msg.Code) + codeID, err := k.PushNewWASMCode(ctx, msg.Code) if err != nil { return nil, sdkerrors.Wrap(err, "pushing new wasm code failed") } return &types.MsgPushNewWASMCodeResponse{ - CodeId: codeID, - CodeHash: codeHash, + CodeId: codeID, }, nil } diff --git a/modules/core/28-wasm/keeper/grpc_query.go b/modules/core/28-wasm/keeper/grpc_query.go index e91b683b0f0..b0c084759f5 100644 --- a/modules/core/28-wasm/keeper/grpc_query.go +++ b/modules/core/28-wasm/keeper/grpc_query.go @@ -2,68 +2,41 @@ package keeper import ( "context" + "encoding/hex" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/ibc-go/modules/core/28-wasm/types" ) var _ types.QueryServer = (*Keeper)(nil) -func (q Keeper) LatestWASMCode(c context.Context, query *types.LatestWASMCodeQuery) (*types.LatestWASMCodeResponse, error) { +func (q Keeper) WasmCode(c context.Context, query *types.WasmCodeQuery) (*types.WasmCodeResponse, error) { if query == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - if query.ClientType == "" { - return nil, status.Error(codes.InvalidArgument, "empty client type string") - } - - clientType := query.ClientType - ctx := sdk.UnwrapSDKContext(c) store := ctx.KVStore(q.storeKey) - latestCodeKey := types.LatestWASMCode(clientType) - latestCodeID := store.Get(latestCodeKey) - if latestCodeID == nil { - return nil, status.Error(codes.NotFound, "no code has been uploaded till now.") - } - - return &types.LatestWASMCodeResponse{ - Code: store.Get(types.WASMCode(clientType, string(latestCodeID))), - }, nil -} - -func (q Keeper) LatestWASMCodeEntry(c context.Context, query *types.LatestWASMCodeEntryQuery) (*types.LatestWASMCodeEntryResponse, error) { - if query == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - if query.ClientType == "" { - return nil, status.Error(codes.InvalidArgument, "empty client type string") - } - - clientType := query.ClientType - - ctx := sdk.UnwrapSDKContext(c) - store := ctx.KVStore(q.storeKey) - latestCodeKey := types.LatestWASMCode(clientType) - latestCodeID := store.Get(latestCodeKey) - if latestCodeID == nil { - return nil, status.Error(codes.NotFound, "no code has been uploaded till now.") + codeID, err := hex.DecodeString(query.CodeId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid code id") } - bz := store.Get(types.WASMCodeEntry(clientType, string(latestCodeID))) - var entry types.WasmCodeEntry - if err := q.cdc.Unmarshal(bz, &entry); err != nil { - return nil, status.Error(codes.Internal, "internal error") + codeKey := types.CodeID(codeID) + code := store.Get(codeKey) + if code == nil { + return nil, status.Error( + codes.NotFound, + sdkerrors.Wrap(types.ErrWasmCodeIDNotFound, query.CodeId).Error(), + ) } - return &types.LatestWASMCodeEntryResponse{ - CodeId: string(latestCodeID), - Entry: &entry, + return &types.WasmCodeResponse{ + Code: code, }, nil } diff --git a/modules/core/28-wasm/keeper/keeper.go b/modules/core/28-wasm/keeper/keeper.go index c77d225686e..875045abdc9 100644 --- a/modules/core/28-wasm/keeper/keeper.go +++ b/modules/core/28-wasm/keeper/keeper.go @@ -1,14 +1,14 @@ package keeper import ( + "bytes" "crypto/sha256" - "encoding/hex" - "fmt" "strings" wasm "github.com/CosmWasm/wasmvm" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/ibc-go/modules/core/28-wasm/types" ) @@ -24,11 +24,6 @@ type VMConfig struct { CacheSizeMb uint32 } -func generateWASMCodeHash(code []byte) string { - hash := sha256.Sum256(code) - return hex.EncodeToString(hash[:]) -} - // Keeper will have a reference to Wasmer with it's own data directory. type Keeper struct { storeKey sdk.StoreKey @@ -60,52 +55,37 @@ func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, vmConfig *VMConfig, vali } } -func (k Keeper) PushNewWASMCode(ctx sdk.Context, clientType string, code []byte) ([]byte, string, error) { +func (k Keeper) PushNewWASMCode(ctx sdk.Context, code []byte) ([]byte, error) { store := ctx.KVStore(k.storeKey) codeHash := generateWASMCodeHash(code) + codeIDKey := types.CodeID(codeHash) - latestVersionKey := types.LatestWASMCode(clientType) + if store.Has(codeIDKey) { + return nil, types.ErrWasmCodeExists + } if isValidWASMCode, err := k.wasmValidator.validateWASMCode(code); err != nil { - return nil, "", fmt.Errorf("unable to validate wasm code, error: %s", err) + return nil, sdkerrors.Wrapf(types.ErrWasmCodeValidation, "unable to validate wasm code: %s", err) } else if !isValidWASMCode { - return nil, "", fmt.Errorf("invalid wasm code") + return nil, types.ErrWasmInvalidCode } codeID, err := WasmVM.Create(code) if err != nil { - return nil, "", fmt.Errorf("invalid wasm code") + return nil, types.ErrWasmInvalidCode } - codekey := types.WASMCode(clientType, codeHash) - entryKey := types.WASMCodeEntry(clientType, codeHash) - - latestVersionCodeHash := store.Get(latestVersionKey) - - // More careful management of doubly linked list can lift this constraint - // But we do not see any significant advantage of it. - if store.Has(entryKey) { - return nil, "", fmt.Errorf("wasm code already exists") + // safety check to assert that code id returned by WasmVM equals to code hash + if !bytes.Equal(codeID, codeHash) { + return nil, types.ErrWasmInvalidCodeID } - codeEntry := types.WasmCodeEntry{ - PreviousCodeHash: string(latestVersionCodeHash), - NextCodeHash: "", - CodeId: codeID, - } - - previousVersionEntryKey := types.WASMCodeEntry(clientType, string(latestVersionCodeHash)) - previousVersionEntryBz := store.Get(previousVersionEntryKey) - if len(previousVersionEntryBz) != 0 { - var previousEntry types.WasmCodeEntry - k.cdc.MustUnmarshal(previousVersionEntryBz, &previousEntry) - previousEntry.NextCodeHash = codeHash - store.Set(previousVersionEntryKey, k.cdc.MustMarshal(&previousEntry)) - } + store.Set(codeIDKey, code) - store.Set(entryKey, k.cdc.MustMarshal(&codeEntry)) - store.Set(latestVersionKey, []byte(codeHash)) - store.Set(codekey, code) + return codeID, nil +} - return codeID, codeHash, nil +func generateWASMCodeHash(code []byte) []byte { + hash := sha256.Sum256(code) + return hash[:] } diff --git a/modules/core/28-wasm/types/errors.go b/modules/core/28-wasm/types/errors.go index ece468db14f..b3ac9538eba 100644 --- a/modules/core/28-wasm/types/errors.go +++ b/modules/core/28-wasm/types/errors.go @@ -3,6 +3,10 @@ package types import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" var ( - ErrEmptyClientType = sdkerrors.Register(SubModuleName, 2, "empty client type") - ErrEmptyWASMCode = sdkerrors.Register(SubModuleName, 3, "empty wasm code") + ErrWasmEmptyCode = sdkerrors.Register(SubModuleName, 2, "empty wasm code") + ErrWasmCodeExists = sdkerrors.Register(SubModuleName, 3, "wasm code already exists") + ErrWasmCodeValidation = sdkerrors.Register(SubModuleName, 4, "unable to validate wasm code") + ErrWasmInvalidCode = sdkerrors.Register(SubModuleName, 5, "invalid wasm code") + ErrWasmInvalidCodeID = sdkerrors.Register(SubModuleName, 6, "invalid wasm code id") + ErrWasmCodeIDNotFound = sdkerrors.Register(SubModuleName, 7, "wasm code id not found") ) diff --git a/modules/core/28-wasm/types/keys.go b/modules/core/28-wasm/types/keys.go index d6b8b9ab3db..df3ddc77535 100644 --- a/modules/core/28-wasm/types/keys.go +++ b/modules/core/28-wasm/types/keys.go @@ -1,19 +1,14 @@ package types -import "fmt" +import ( + "encoding/hex" + "fmt" +) const ( SubModuleName = "wasm-manager" ) -func LatestWASMCode(clientType string) []byte { - return []byte(fmt.Sprintf("%s/latest", clientType)) -} - -func WASMCode(clientType string, hash string) []byte { - return []byte(fmt.Sprintf("%s/%s", clientType, hash)) -} - -func WASMCodeEntry(clientType string, codeID string) []byte { - return []byte(fmt.Sprintf("%s/%s/entry", clientType, codeID)) +func CodeID(codeID []byte) []byte { + return []byte(fmt.Sprintf("code_id/%s", hex.EncodeToString(codeID))) } diff --git a/modules/core/28-wasm/types/msgs.go b/modules/core/28-wasm/types/msgs.go index e231b4f59db..2905f5e90d1 100644 --- a/modules/core/28-wasm/types/msgs.go +++ b/modules/core/28-wasm/types/msgs.go @@ -17,14 +17,8 @@ func (m *MsgPushNewWASMCode) Type() string { } func (m *MsgPushNewWASMCode) ValidateBasic() error { - if len(m.ClientType) == 0 { - return sdkerrors.Wrapf(ErrEmptyClientType, - "empty client type", - ) - } - if len(m.Code) == 0 { - return sdkerrors.Wrapf(ErrEmptyWASMCode, + return sdkerrors.Wrapf(ErrWasmEmptyCode, "empty wasm code", ) } diff --git a/modules/core/28-wasm/types/query.pb.go b/modules/core/28-wasm/types/query.pb.go index 74ea456f62f..f57f745da9e 100644 --- a/modules/core/28-wasm/types/query.pb.go +++ b/modules/core/28-wasm/types/query.pb.go @@ -28,23 +28,23 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Latest wasm code query -type LatestWASMCodeQuery struct { - ClientType string `protobuf:"bytes,1,opt,name=client_type,json=clientType,proto3" json:"client_type,omitempty"` +// WasmCode query +type WasmCodeQuery struct { + CodeId string `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` } -func (m *LatestWASMCodeQuery) Reset() { *m = LatestWASMCodeQuery{} } -func (m *LatestWASMCodeQuery) String() string { return proto.CompactTextString(m) } -func (*LatestWASMCodeQuery) ProtoMessage() {} -func (*LatestWASMCodeQuery) Descriptor() ([]byte, []int) { +func (m *WasmCodeQuery) Reset() { *m = WasmCodeQuery{} } +func (m *WasmCodeQuery) String() string { return proto.CompactTextString(m) } +func (*WasmCodeQuery) ProtoMessage() {} +func (*WasmCodeQuery) Descriptor() ([]byte, []int) { return fileDescriptor_482bc5ce660a9729, []int{0} } -func (m *LatestWASMCodeQuery) XXX_Unmarshal(b []byte) error { +func (m *WasmCodeQuery) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *LatestWASMCodeQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *WasmCodeQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_LatestWASMCodeQuery.Marshal(b, m, deterministic) + return xxx_messageInfo_WasmCodeQuery.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -54,42 +54,42 @@ func (m *LatestWASMCodeQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *LatestWASMCodeQuery) XXX_Merge(src proto.Message) { - xxx_messageInfo_LatestWASMCodeQuery.Merge(m, src) +func (m *WasmCodeQuery) XXX_Merge(src proto.Message) { + xxx_messageInfo_WasmCodeQuery.Merge(m, src) } -func (m *LatestWASMCodeQuery) XXX_Size() int { +func (m *WasmCodeQuery) XXX_Size() int { return m.Size() } -func (m *LatestWASMCodeQuery) XXX_DiscardUnknown() { - xxx_messageInfo_LatestWASMCodeQuery.DiscardUnknown(m) +func (m *WasmCodeQuery) XXX_DiscardUnknown() { + xxx_messageInfo_WasmCodeQuery.DiscardUnknown(m) } -var xxx_messageInfo_LatestWASMCodeQuery proto.InternalMessageInfo +var xxx_messageInfo_WasmCodeQuery proto.InternalMessageInfo -func (m *LatestWASMCodeQuery) GetClientType() string { +func (m *WasmCodeQuery) GetCodeId() string { if m != nil { - return m.ClientType + return m.CodeId } return "" } -// Latest wasm code response -type LatestWASMCodeResponse struct { +// WasmCode response +type WasmCodeResponse struct { Code []byte `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` } -func (m *LatestWASMCodeResponse) Reset() { *m = LatestWASMCodeResponse{} } -func (m *LatestWASMCodeResponse) String() string { return proto.CompactTextString(m) } -func (*LatestWASMCodeResponse) ProtoMessage() {} -func (*LatestWASMCodeResponse) Descriptor() ([]byte, []int) { +func (m *WasmCodeResponse) Reset() { *m = WasmCodeResponse{} } +func (m *WasmCodeResponse) String() string { return proto.CompactTextString(m) } +func (*WasmCodeResponse) ProtoMessage() {} +func (*WasmCodeResponse) Descriptor() ([]byte, []int) { return fileDescriptor_482bc5ce660a9729, []int{1} } -func (m *LatestWASMCodeResponse) XXX_Unmarshal(b []byte) error { +func (m *WasmCodeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *LatestWASMCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *WasmCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_LatestWASMCodeResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_WasmCodeResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -99,160 +99,53 @@ func (m *LatestWASMCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *LatestWASMCodeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_LatestWASMCodeResponse.Merge(m, src) +func (m *WasmCodeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_WasmCodeResponse.Merge(m, src) } -func (m *LatestWASMCodeResponse) XXX_Size() int { +func (m *WasmCodeResponse) XXX_Size() int { return m.Size() } -func (m *LatestWASMCodeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_LatestWASMCodeResponse.DiscardUnknown(m) +func (m *WasmCodeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_WasmCodeResponse.DiscardUnknown(m) } -var xxx_messageInfo_LatestWASMCodeResponse proto.InternalMessageInfo +var xxx_messageInfo_WasmCodeResponse proto.InternalMessageInfo -func (m *LatestWASMCodeResponse) GetCode() []byte { +func (m *WasmCodeResponse) GetCode() []byte { if m != nil { return m.Code } return nil } -// Latest wasm code entry query -type LatestWASMCodeEntryQuery struct { - ClientType string `protobuf:"bytes,1,opt,name=client_type,json=clientType,proto3" json:"client_type,omitempty"` -} - -func (m *LatestWASMCodeEntryQuery) Reset() { *m = LatestWASMCodeEntryQuery{} } -func (m *LatestWASMCodeEntryQuery) String() string { return proto.CompactTextString(m) } -func (*LatestWASMCodeEntryQuery) ProtoMessage() {} -func (*LatestWASMCodeEntryQuery) Descriptor() ([]byte, []int) { - return fileDescriptor_482bc5ce660a9729, []int{2} -} -func (m *LatestWASMCodeEntryQuery) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LatestWASMCodeEntryQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LatestWASMCodeEntryQuery.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *LatestWASMCodeEntryQuery) XXX_Merge(src proto.Message) { - xxx_messageInfo_LatestWASMCodeEntryQuery.Merge(m, src) -} -func (m *LatestWASMCodeEntryQuery) XXX_Size() int { - return m.Size() -} -func (m *LatestWASMCodeEntryQuery) XXX_DiscardUnknown() { - xxx_messageInfo_LatestWASMCodeEntryQuery.DiscardUnknown(m) -} - -var xxx_messageInfo_LatestWASMCodeEntryQuery proto.InternalMessageInfo - -func (m *LatestWASMCodeEntryQuery) GetClientType() string { - if m != nil { - return m.ClientType - } - return "" -} - -// Latest wasm code entry response -type LatestWASMCodeEntryResponse struct { - CodeId string `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` - Entry *WasmCodeEntry `protobuf:"bytes,2,opt,name=entry,proto3" json:"entry,omitempty"` -} - -func (m *LatestWASMCodeEntryResponse) Reset() { *m = LatestWASMCodeEntryResponse{} } -func (m *LatestWASMCodeEntryResponse) String() string { return proto.CompactTextString(m) } -func (*LatestWASMCodeEntryResponse) ProtoMessage() {} -func (*LatestWASMCodeEntryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_482bc5ce660a9729, []int{3} -} -func (m *LatestWASMCodeEntryResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LatestWASMCodeEntryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LatestWASMCodeEntryResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *LatestWASMCodeEntryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_LatestWASMCodeEntryResponse.Merge(m, src) -} -func (m *LatestWASMCodeEntryResponse) XXX_Size() int { - return m.Size() -} -func (m *LatestWASMCodeEntryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_LatestWASMCodeEntryResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_LatestWASMCodeEntryResponse proto.InternalMessageInfo - -func (m *LatestWASMCodeEntryResponse) GetCodeId() string { - if m != nil { - return m.CodeId - } - return "" -} - -func (m *LatestWASMCodeEntryResponse) GetEntry() *WasmCodeEntry { - if m != nil { - return m.Entry - } - return nil -} - func init() { - proto.RegisterType((*LatestWASMCodeQuery)(nil), "ibc.core.wasm.v1.LatestWASMCodeQuery") - proto.RegisterType((*LatestWASMCodeResponse)(nil), "ibc.core.wasm.v1.LatestWASMCodeResponse") - proto.RegisterType((*LatestWASMCodeEntryQuery)(nil), "ibc.core.wasm.v1.LatestWASMCodeEntryQuery") - proto.RegisterType((*LatestWASMCodeEntryResponse)(nil), "ibc.core.wasm.v1.LatestWASMCodeEntryResponse") + proto.RegisterType((*WasmCodeQuery)(nil), "ibc.core.wasm.v1.WasmCodeQuery") + proto.RegisterType((*WasmCodeResponse)(nil), "ibc.core.wasm.v1.WasmCodeResponse") } func init() { proto.RegisterFile("ibc/core/wasm/v1/query.proto", fileDescriptor_482bc5ce660a9729) } var fileDescriptor_482bc5ce660a9729 = []byte{ - // 415 bytes of a gzipped FileDescriptorProto + // 289 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0x4c, 0x4a, 0xd6, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4f, 0x2c, 0xce, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xc8, 0x4c, 0x4a, 0xd6, 0x03, 0xc9, - 0xea, 0x81, 0x64, 0xf5, 0xca, 0x0c, 0xa5, 0xa4, 0x31, 0xd4, 0x83, 0x65, 0xc0, 0xca, 0xa5, 0x64, - 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, - 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0x21, 0xb2, 0x4a, 0x66, 0x5c, 0xc2, 0x3e, 0x89, 0x25, 0xa9, - 0xc5, 0x25, 0xe1, 0x8e, 0xc1, 0xbe, 0xce, 0xf9, 0x29, 0xa9, 0x81, 0x20, 0x9b, 0x84, 0xe4, 0xb9, - 0xb8, 0x93, 0x73, 0x32, 0x53, 0xf3, 0x4a, 0xe2, 0x4b, 0x2a, 0x0b, 0x52, 0x25, 0x18, 0x15, 0x18, - 0x35, 0x38, 0x83, 0xb8, 0x20, 0x42, 0x21, 0x95, 0x05, 0xa9, 0x4a, 0x3a, 0x5c, 0x62, 0xa8, 0xfa, - 0x82, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0x84, 0xb8, 0x58, 0x92, 0xf3, 0x53, 0x20, - 0x7a, 0x78, 0x82, 0xc0, 0x6c, 0x25, 0x6b, 0x2e, 0x09, 0x54, 0xd5, 0xae, 0x79, 0x25, 0x45, 0x95, - 0x44, 0x5a, 0x95, 0xcb, 0x25, 0x8d, 0x45, 0x33, 0xdc, 0x3e, 0x71, 0x2e, 0x76, 0x90, 0x1d, 0xf1, - 0x99, 0x29, 0x50, 0xbd, 0x6c, 0x20, 0xae, 0x67, 0x8a, 0x90, 0x29, 0x17, 0x6b, 0x2a, 0x48, 0xa5, - 0x04, 0x93, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0xbc, 0x1e, 0x7a, 0xb8, 0xe9, 0x85, 0x27, 0x16, 0xe7, - 0x22, 0x0c, 0x84, 0xa8, 0x36, 0x7a, 0xc4, 0xc4, 0xc5, 0x0a, 0x71, 0xd9, 0x02, 0x46, 0x2e, 0x3e, - 0x54, 0x9b, 0x85, 0x54, 0x31, 0x0d, 0xc1, 0x12, 0x7c, 0x52, 0x1a, 0x84, 0x94, 0xc1, 0x5c, 0xaf, - 0x64, 0xdb, 0x74, 0xf9, 0xc9, 0x64, 0x26, 0x73, 0x21, 0x53, 0x7d, 0xf4, 0x38, 0x4c, 0x4a, 0x2d, - 0x49, 0x34, 0xd4, 0xcf, 0x01, 0x6b, 0x8b, 0x07, 0x89, 0xc5, 0x83, 0xfc, 0xa5, 0x5f, 0x8d, 0x14, - 0x58, 0xb5, 0x42, 0x5b, 0x19, 0xd1, 0xe3, 0x0f, 0xec, 0x17, 0x21, 0x2d, 0x42, 0x0e, 0x40, 0x44, - 0x80, 0x94, 0x2e, 0x51, 0x6a, 0xe1, 0x2e, 0x76, 0x06, 0xbb, 0xd8, 0x56, 0xc8, 0x9a, 0x48, 0x17, - 0xc7, 0x83, 0x83, 0x15, 0xd5, 0xdd, 0x4e, 0xbe, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, + 0xea, 0x81, 0x64, 0xf5, 0xca, 0x0c, 0xa5, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, + 0x0b, 0x32, 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0x21, 0xea, + 0x95, 0x34, 0xb8, 0x78, 0xc3, 0x13, 0x8b, 0x73, 0x9d, 0xf3, 0x53, 0x52, 0x03, 0x41, 0xc6, 0x08, + 0x89, 0x73, 0xb1, 0x27, 0xe7, 0xa7, 0xa4, 0xc6, 0x67, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, + 0x06, 0xb1, 0x81, 0xb8, 0x9e, 0x29, 0x4a, 0x6a, 0x5c, 0x02, 0x30, 0x95, 0x41, 0xa9, 0xc5, 0x05, + 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0x42, 0x5c, 0x2c, 0x20, 0x59, 0xb0, 0x4a, 0x9e, 0x20, 0x30, 0xdb, + 0xa8, 0x9d, 0x91, 0x8b, 0x15, 0x62, 0x54, 0x1d, 0x17, 0x07, 0x4c, 0x87, 0x90, 0xbc, 0x1e, 0xba, + 0xc3, 0xf4, 0x50, 0xec, 0x95, 0x52, 0xc2, 0xad, 0x00, 0x66, 0x9d, 0x92, 0x6e, 0xd3, 0xe5, 0x27, + 0x93, 0x99, 0xd4, 0x85, 0x54, 0xf5, 0xd1, 0xc3, 0x20, 0x29, 0xb5, 0x24, 0xd1, 0x50, 0x1f, 0x64, + 0xbf, 0x7e, 0x35, 0xd4, 0xf9, 0xb5, 0x4e, 0xbe, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x9c, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9c, - 0x5f, 0x9c, 0x9b, 0x5f, 0x0c, 0xb2, 0x47, 0x37, 0x3d, 0x5f, 0x3f, 0x37, 0x3f, 0xa5, 0x34, 0x27, - 0xb5, 0x18, 0x62, 0xa5, 0x91, 0x85, 0x2e, 0xd8, 0x56, 0x90, 0x71, 0xc5, 0x49, 0x6c, 0xe0, 0xc4, - 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xbc, 0xe8, 0x2d, 0x39, 0x03, 0x00, 0x00, + 0x5f, 0x9c, 0x9b, 0x5f, 0x0c, 0x32, 0x51, 0x37, 0x3d, 0x5f, 0x3f, 0x37, 0x3f, 0xa5, 0x34, 0x27, + 0xb5, 0x18, 0x62, 0xb8, 0x91, 0x85, 0x2e, 0xd8, 0xfc, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, + 0x70, 0x88, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x6c, 0xdb, 0xe2, 0x92, 0x81, 0x01, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -267,10 +160,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Query to get latest wasm code for particular client type. - LatestWASMCode(ctx context.Context, in *LatestWASMCodeQuery, opts ...grpc.CallOption) (*LatestWASMCodeResponse, error) - // Query for get latest wasm code entry for particular client type - LatestWASMCodeEntry(ctx context.Context, in *LatestWASMCodeEntryQuery, opts ...grpc.CallOption) (*LatestWASMCodeEntryResponse, error) + // Get Wasm code for given code id + WasmCode(ctx context.Context, in *WasmCodeQuery, opts ...grpc.CallOption) (*WasmCodeResponse, error) } type queryClient struct { @@ -281,18 +172,9 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) LatestWASMCode(ctx context.Context, in *LatestWASMCodeQuery, opts ...grpc.CallOption) (*LatestWASMCodeResponse, error) { - out := new(LatestWASMCodeResponse) - err := c.cc.Invoke(ctx, "/ibc.core.wasm.v1.Query/LatestWASMCode", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) LatestWASMCodeEntry(ctx context.Context, in *LatestWASMCodeEntryQuery, opts ...grpc.CallOption) (*LatestWASMCodeEntryResponse, error) { - out := new(LatestWASMCodeEntryResponse) - err := c.cc.Invoke(ctx, "/ibc.core.wasm.v1.Query/LatestWASMCodeEntry", in, out, opts...) +func (c *queryClient) WasmCode(ctx context.Context, in *WasmCodeQuery, opts ...grpc.CallOption) (*WasmCodeResponse, error) { + out := new(WasmCodeResponse) + err := c.cc.Invoke(ctx, "/ibc.core.wasm.v1.Query/WasmCode", in, out, opts...) if err != nil { return nil, err } @@ -301,59 +183,36 @@ func (c *queryClient) LatestWASMCodeEntry(ctx context.Context, in *LatestWASMCod // QueryServer is the server API for Query service. type QueryServer interface { - // Query to get latest wasm code for particular client type. - LatestWASMCode(context.Context, *LatestWASMCodeQuery) (*LatestWASMCodeResponse, error) - // Query for get latest wasm code entry for particular client type - LatestWASMCodeEntry(context.Context, *LatestWASMCodeEntryQuery) (*LatestWASMCodeEntryResponse, error) + // Get Wasm code for given code id + WasmCode(context.Context, *WasmCodeQuery) (*WasmCodeResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) LatestWASMCode(ctx context.Context, req *LatestWASMCodeQuery) (*LatestWASMCodeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LatestWASMCode not implemented") -} -func (*UnimplementedQueryServer) LatestWASMCodeEntry(ctx context.Context, req *LatestWASMCodeEntryQuery) (*LatestWASMCodeEntryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LatestWASMCodeEntry not implemented") +func (*UnimplementedQueryServer) WasmCode(ctx context.Context, req *WasmCodeQuery) (*WasmCodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WasmCode not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_LatestWASMCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LatestWASMCodeQuery) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).LatestWASMCode(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.wasm.v1.Query/LatestWASMCode", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).LatestWASMCode(ctx, req.(*LatestWASMCodeQuery)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_LatestWASMCodeEntry_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LatestWASMCodeEntryQuery) +func _Query_WasmCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WasmCodeQuery) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).LatestWASMCodeEntry(ctx, in) + return srv.(QueryServer).WasmCode(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.wasm.v1.Query/LatestWASMCodeEntry", + FullMethod: "/ibc.core.wasm.v1.Query/WasmCode", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).LatestWASMCodeEntry(ctx, req.(*LatestWASMCodeEntryQuery)) + return srv.(QueryServer).WasmCode(ctx, req.(*WasmCodeQuery)) } return interceptor(ctx, in, info, handler) } @@ -363,19 +222,15 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "LatestWASMCode", - Handler: _Query_LatestWASMCode_Handler, - }, - { - MethodName: "LatestWASMCodeEntry", - Handler: _Query_LatestWASMCodeEntry_Handler, + MethodName: "WasmCode", + Handler: _Query_WasmCode_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/wasm/v1/query.proto", } -func (m *LatestWASMCodeQuery) Marshal() (dAtA []byte, err error) { +func (m *WasmCodeQuery) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -385,27 +240,27 @@ func (m *LatestWASMCodeQuery) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *LatestWASMCodeQuery) MarshalTo(dAtA []byte) (int, error) { +func (m *WasmCodeQuery) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *LatestWASMCodeQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *WasmCodeQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ClientType) > 0 { - i -= len(m.ClientType) - copy(dAtA[i:], m.ClientType) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientType))) + if len(m.CodeId) > 0 { + i -= len(m.CodeId) + copy(dAtA[i:], m.CodeId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CodeId))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *LatestWASMCodeResponse) Marshal() (dAtA []byte, err error) { +func (m *WasmCodeResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -415,12 +270,12 @@ func (m *LatestWASMCodeResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *LatestWASMCodeResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *WasmCodeResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *LatestWASMCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *WasmCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -435,78 +290,6 @@ func (m *LatestWASMCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *LatestWASMCodeEntryQuery) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *LatestWASMCodeEntryQuery) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LatestWASMCodeEntryQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ClientType) > 0 { - i -= len(m.ClientType) - copy(dAtA[i:], m.ClientType) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientType))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *LatestWASMCodeEntryResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *LatestWASMCodeEntryResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LatestWASMCodeEntryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Entry != nil { - { - size, err := m.Entry.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.CodeId) > 0 { - i -= len(m.CodeId) - copy(dAtA[i:], m.CodeId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.CodeId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -518,20 +301,20 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *LatestWASMCodeQuery) Size() (n int) { +func (m *WasmCodeQuery) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ClientType) + l = len(m.CodeId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *LatestWASMCodeResponse) Size() (n int) { +func (m *WasmCodeResponse) Size() (n int) { if m == nil { return 0 } @@ -544,43 +327,13 @@ func (m *LatestWASMCodeResponse) Size() (n int) { return n } -func (m *LatestWASMCodeEntryQuery) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientType) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *LatestWASMCodeEntryResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.CodeId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Entry != nil { - l = m.Entry.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *LatestWASMCodeQuery) Unmarshal(dAtA []byte) error { +func (m *WasmCodeQuery) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -603,15 +356,15 @@ func (m *LatestWASMCodeQuery) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: LatestWASMCodeQuery: wiretype end group for non-group") + return fmt.Errorf("proto: WasmCodeQuery: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: LatestWASMCodeQuery: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: WasmCodeQuery: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientType", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -639,7 +392,7 @@ func (m *LatestWASMCodeQuery) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ClientType = string(dAtA[iNdEx:postIndex]) + m.CodeId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -662,7 +415,7 @@ func (m *LatestWASMCodeQuery) Unmarshal(dAtA []byte) error { } return nil } -func (m *LatestWASMCodeResponse) Unmarshal(dAtA []byte) error { +func (m *WasmCodeResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -685,10 +438,10 @@ func (m *LatestWASMCodeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: LatestWASMCodeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: WasmCodeResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: LatestWASMCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: WasmCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -746,206 +499,6 @@ func (m *LatestWASMCodeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *LatestWASMCodeEntryQuery) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LatestWASMCodeEntryQuery: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LatestWASMCodeEntryQuery: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LatestWASMCodeEntryResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LatestWASMCodeEntryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LatestWASMCodeEntryResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CodeId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Entry", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Entry == nil { - m.Entry = &WasmCodeEntry{} - } - if err := m.Entry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/28-wasm/types/query.pb.gw.go b/modules/core/28-wasm/types/query.pb.gw.go index d74319801a8..b7b882bdb1e 100644 --- a/modules/core/28-wasm/types/query.pb.gw.go +++ b/modules/core/28-wasm/types/query.pb.gw.go @@ -31,8 +31,8 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -func request_Query_LatestWASMCode_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq LatestWASMCodeQuery +func request_Query_WasmCode_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq WasmCodeQuery var metadata runtime.ServerMetadata var ( @@ -42,24 +42,24 @@ func request_Query_LatestWASMCode_0(ctx context.Context, marshaler runtime.Marsh _ = err ) - val, ok = pathParams["client_type"] + val, ok = pathParams["code_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_type") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "code_id") } - protoReq.ClientType, err = runtime.String(val) + protoReq.CodeId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_type", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "code_id", err) } - msg, err := client.LatestWASMCode(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.WasmCode(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_LatestWASMCode_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq LatestWASMCodeQuery +func local_request_Query_WasmCode_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq WasmCodeQuery var metadata runtime.ServerMetadata var ( @@ -69,72 +69,18 @@ func local_request_Query_LatestWASMCode_0(ctx context.Context, marshaler runtime _ = err ) - val, ok = pathParams["client_type"] + val, ok = pathParams["code_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_type") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "code_id") } - protoReq.ClientType, err = runtime.String(val) + protoReq.CodeId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_type", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "code_id", err) } - msg, err := server.LatestWASMCode(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_LatestWASMCodeEntry_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq LatestWASMCodeEntryQuery - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["client_type"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_type") - } - - protoReq.ClientType, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_type", err) - } - - msg, err := client.LatestWASMCodeEntry(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_LatestWASMCodeEntry_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq LatestWASMCodeEntryQuery - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["client_type"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_type") - } - - protoReq.ClientType, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_type", err) - } - - msg, err := server.LatestWASMCodeEntry(ctx, &protoReq) + msg, err := server.WasmCode(ctx, &protoReq) return msg, metadata, err } @@ -145,27 +91,7 @@ func local_request_Query_LatestWASMCodeEntry_0(ctx context.Context, marshaler ru // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_LatestWASMCode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_LatestWASMCode_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_LatestWASMCode_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_LatestWASMCodeEntry_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_WasmCode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -174,14 +100,14 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_LatestWASMCodeEntry_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_WasmCode_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_LatestWASMCodeEntry_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_WasmCode_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -226,7 +152,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_LatestWASMCode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_WasmCode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -235,34 +161,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_LatestWASMCode_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_WasmCode_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_LatestWASMCode_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_LatestWASMCodeEntry_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_LatestWASMCodeEntry_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_LatestWASMCodeEntry_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_WasmCode_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -270,13 +176,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_LatestWASMCode_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "wasm", "v1beta1", "latest_wasm_code", "client_type"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_LatestWASMCodeEntry_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "wasm", "v1beta1", "latest_wasm_code_entry", "client_type"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_WasmCode_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "wasm", "v1beta1", "code", "code_id"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( - forward_Query_LatestWASMCode_0 = runtime.ForwardResponseMessage - - forward_Query_LatestWASMCodeEntry_0 = runtime.ForwardResponseMessage + forward_Query_WasmCode_0 = runtime.ForwardResponseMessage ) diff --git a/modules/core/28-wasm/types/tx.pb.go b/modules/core/28-wasm/types/tx.pb.go index e28c961cc8b..572fcfe38b9 100644 --- a/modules/core/28-wasm/types/tx.pb.go +++ b/modules/core/28-wasm/types/tx.pb.go @@ -30,9 +30,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Message type to push new wasm code type MsgPushNewWASMCode struct { - Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` - ClientType string `protobuf:"bytes,2,opt,name=client_type,json=clientType,proto3" json:"client_type,omitempty"` - Code []byte `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + Code []byte `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` } func (m *MsgPushNewWASMCode) Reset() { *m = MsgPushNewWASMCode{} } @@ -75,13 +74,6 @@ func (m *MsgPushNewWASMCode) GetSigner() string { return "" } -func (m *MsgPushNewWASMCode) GetClientType() string { - if m != nil { - return m.ClientType - } - return "" -} - func (m *MsgPushNewWASMCode) GetCode() []byte { if m != nil { return m.Code @@ -91,8 +83,7 @@ func (m *MsgPushNewWASMCode) GetCode() []byte { // Response in case of successful handling type MsgPushNewWASMCodeResponse struct { - CodeId []byte `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` - CodeHash string `protobuf:"bytes,2,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty"` + CodeId []byte `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` } func (m *MsgPushNewWASMCodeResponse) Reset() { *m = MsgPushNewWASMCodeResponse{} } @@ -135,13 +126,6 @@ func (m *MsgPushNewWASMCodeResponse) GetCodeId() []byte { return nil } -func (m *MsgPushNewWASMCodeResponse) GetCodeHash() string { - if m != nil { - return m.CodeHash - } - return "" -} - func init() { proto.RegisterType((*MsgPushNewWASMCode)(nil), "ibc.core.wasm.v1.MsgPushNewWASMCode") proto.RegisterType((*MsgPushNewWASMCodeResponse)(nil), "ibc.core.wasm.v1.MsgPushNewWASMCodeResponse") @@ -150,27 +134,25 @@ func init() { func init() { proto.RegisterFile("ibc/core/wasm/v1/tx.proto", fileDescriptor_e7804a9f49664df6) } var fileDescriptor_e7804a9f49664df6 = []byte{ - // 313 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xb1, 0x4e, 0x3a, 0x41, - 0x10, 0xc6, 0xb9, 0x3f, 0xff, 0xa0, 0xac, 0x24, 0x9a, 0x8d, 0x51, 0xc4, 0xe4, 0x24, 0xc4, 0x82, - 0x42, 0x76, 0x03, 0x34, 0xb6, 0x6a, 0xa3, 0xc5, 0x19, 0x73, 0x9a, 0x98, 0xd8, 0x90, 0xbb, 0xbd, - 0xc9, 0xde, 0x26, 0x1c, 0x73, 0x61, 0x0e, 0x90, 0xb7, 0xf0, 0xb1, 0x2c, 0x29, 0x2d, 0x0d, 0xbc, - 0x88, 0xd9, 0x05, 0x1b, 0x68, 0xec, 0x66, 0xe6, 0xf7, 0x25, 0xdf, 0xcc, 0x7c, 0xec, 0xcc, 0xc4, - 0x4a, 0x2a, 0x1c, 0x83, 0x9c, 0x45, 0x94, 0xc9, 0x69, 0x57, 0x16, 0xef, 0x22, 0x1f, 0x63, 0x81, - 0xfc, 0xc8, 0xc4, 0x4a, 0x58, 0x24, 0x2c, 0x12, 0xd3, 0x6e, 0xe3, 0x58, 0xa3, 0x46, 0x07, 0xa5, - 0xad, 0xd6, 0xba, 0x56, 0xc4, 0x78, 0x40, 0xfa, 0x69, 0x42, 0xe9, 0x23, 0xcc, 0x5e, 0x6f, 0x9e, - 0x83, 0x3b, 0x4c, 0x80, 0x9f, 0xb0, 0x0a, 0x19, 0x3d, 0x82, 0x71, 0xdd, 0x6b, 0x7a, 0xed, 0x6a, - 0xb8, 0xe9, 0xf8, 0x05, 0x3b, 0x50, 0x43, 0x03, 0xa3, 0x62, 0x50, 0xcc, 0x73, 0xa8, 0xff, 0x73, - 0x90, 0xad, 0x47, 0x2f, 0xf3, 0x1c, 0x38, 0x67, 0xff, 0x15, 0x26, 0x50, 0x2f, 0x37, 0xbd, 0x76, - 0x2d, 0x74, 0x75, 0x2b, 0x64, 0x8d, 0x5d, 0x8b, 0x10, 0x28, 0xc7, 0x11, 0x01, 0x3f, 0x65, 0x7b, - 0x56, 0x35, 0x30, 0x89, 0xf3, 0xaa, 0x85, 0x15, 0xdb, 0x3e, 0x24, 0xfc, 0x9c, 0x55, 0x1d, 0x48, - 0x23, 0x4a, 0x37, 0x4e, 0xfb, 0x76, 0x70, 0x1f, 0x51, 0xda, 0x1b, 0xb2, 0x72, 0x40, 0x9a, 0x03, - 0x3b, 0xdc, 0x5e, 0xfd, 0x52, 0x6c, 0x5f, 0x2e, 0x76, 0xdd, 0x1b, 0x57, 0x7f, 0x51, 0xfd, 0xee, - 0x78, 0x1b, 0x7c, 0x2e, 0x7d, 0x6f, 0xb1, 0xf4, 0xbd, 0xef, 0xa5, 0xef, 0x7d, 0xac, 0xfc, 0xd2, - 0x62, 0xe5, 0x97, 0xbe, 0x56, 0x7e, 0xe9, 0xad, 0xaf, 0x4d, 0x91, 0x4e, 0x62, 0xa1, 0x30, 0x93, - 0x0a, 0x29, 0x43, 0x92, 0x26, 0x56, 0x1d, 0x8d, 0x32, 0xc3, 0x64, 0x32, 0x04, 0x5a, 0xc7, 0xd3, - 0xbb, 0xee, 0xb8, 0x84, 0xec, 0xd7, 0x28, 0xae, 0xb8, 0xd7, 0xf7, 0x7f, 0x02, 0x00, 0x00, 0xff, - 0xff, 0x63, 0x5f, 0x84, 0xbb, 0xbf, 0x01, 0x00, 0x00, + // 274 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x4c, 0x4a, 0xd6, + 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4f, 0x2c, 0xce, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xc8, 0x4c, 0x4a, 0xd6, 0x03, 0x49, 0xe9, 0x81, 0xa4, + 0xf4, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, + 0x92, 0x03, 0x97, 0x90, 0x6f, 0x71, 0x7a, 0x40, 0x69, 0x71, 0x86, 0x5f, 0x6a, 0x79, 0xb8, 0x63, + 0xb0, 0xaf, 0x73, 0x7e, 0x4a, 0xaa, 0x90, 0x18, 0x17, 0x5b, 0x71, 0x66, 0x7a, 0x5e, 0x6a, 0x91, + 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x94, 0x27, 0x24, 0xc4, 0xc5, 0x92, 0x9c, 0x9f, 0x92, + 0x2a, 0xc1, 0xac, 0xc0, 0xa8, 0xc1, 0x13, 0x04, 0x66, 0x2b, 0x99, 0x72, 0x49, 0x61, 0x9a, 0x10, + 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0x24, 0xce, 0xc5, 0x0e, 0x52, 0x15, 0x9f, 0x99, + 0x02, 0x36, 0x8a, 0x27, 0x88, 0x0d, 0xc4, 0xf5, 0x4c, 0x31, 0xca, 0xe1, 0x62, 0xf6, 0x2d, 0x4e, + 0x17, 0x4a, 0xe5, 0xe2, 0x47, 0xb7, 0x5c, 0x45, 0x0f, 0xdd, 0xed, 0x7a, 0x98, 0x16, 0x48, 0xe9, + 0x10, 0xa3, 0x0a, 0xe6, 0x0c, 0x27, 0xdf, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, + 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, + 0x88, 0x32, 0x4e, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, + 0xce, 0xcd, 0x2f, 0xd6, 0xcf, 0x4c, 0x4a, 0xd6, 0x4d, 0xcf, 0xd7, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, + 0x49, 0x2d, 0x86, 0x04, 0xb0, 0x91, 0x85, 0x2e, 0x38, 0x8c, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, + 0xd8, 0xc0, 0x81, 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x30, 0xf5, 0x11, 0xa9, 0x81, 0x01, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -282,13 +264,6 @@ func (m *MsgPushNewWASMCode) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.ClientType) > 0 { - i -= len(m.ClientType) - copy(dAtA[i:], m.ClientType) - i = encodeVarintTx(dAtA, i, uint64(len(m.ClientType))) - i-- - dAtA[i] = 0x12 - } if len(m.Signer) > 0 { i -= len(m.Signer) copy(dAtA[i:], m.Signer) @@ -319,13 +294,6 @@ func (m *MsgPushNewWASMCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - if len(m.CodeHash) > 0 { - i -= len(m.CodeHash) - copy(dAtA[i:], m.CodeHash) - i = encodeVarintTx(dAtA, i, uint64(len(m.CodeHash))) - i-- - dAtA[i] = 0x12 - } if len(m.CodeId) > 0 { i -= len(m.CodeId) copy(dAtA[i:], m.CodeId) @@ -357,10 +325,6 @@ func (m *MsgPushNewWASMCode) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.ClientType) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } l = len(m.Code) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -378,10 +342,6 @@ func (m *MsgPushNewWASMCodeResponse) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.CodeHash) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } return n } @@ -452,38 +412,6 @@ func (m *MsgPushNewWASMCode) Unmarshal(dAtA []byte) error { } m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) @@ -602,38 +530,6 @@ func (m *MsgPushNewWASMCodeResponse) Unmarshal(dAtA []byte) error { m.CodeId = []byte{} } iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CodeHash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CodeHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/modules/core/28-wasm/types/wasm.pb.go b/modules/core/28-wasm/types/wasm.pb.go deleted file mode 100644 index b3e84a58647..00000000000 --- a/modules/core/28-wasm/types/wasm.pb.go +++ /dev/null @@ -1,425 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ibc/core/wasm/v1/wasm.proto - -package types - -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// WASM code entry that allows keeper to traverse -// the doubly linked list -type WasmCodeEntry struct { - CodeId []byte `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` - PreviousCodeHash string `protobuf:"bytes,2,opt,name=previous_code_hash,json=previousCodeHash,proto3" json:"previous_code_hash,omitempty"` - NextCodeHash string `protobuf:"bytes,3,opt,name=next_code_hash,json=nextCodeHash,proto3" json:"next_code_hash,omitempty"` -} - -func (m *WasmCodeEntry) Reset() { *m = WasmCodeEntry{} } -func (m *WasmCodeEntry) String() string { return proto.CompactTextString(m) } -func (*WasmCodeEntry) ProtoMessage() {} -func (*WasmCodeEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_8e445a743f39a2b3, []int{0} -} -func (m *WasmCodeEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *WasmCodeEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_WasmCodeEntry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *WasmCodeEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_WasmCodeEntry.Merge(m, src) -} -func (m *WasmCodeEntry) XXX_Size() int { - return m.Size() -} -func (m *WasmCodeEntry) XXX_DiscardUnknown() { - xxx_messageInfo_WasmCodeEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_WasmCodeEntry proto.InternalMessageInfo - -func (m *WasmCodeEntry) GetCodeId() []byte { - if m != nil { - return m.CodeId - } - return nil -} - -func (m *WasmCodeEntry) GetPreviousCodeHash() string { - if m != nil { - return m.PreviousCodeHash - } - return "" -} - -func (m *WasmCodeEntry) GetNextCodeHash() string { - if m != nil { - return m.NextCodeHash - } - return "" -} - -func init() { - proto.RegisterType((*WasmCodeEntry)(nil), "ibc.core.wasm.v1.WasmCodeEntry") -} - -func init() { proto.RegisterFile("ibc/core/wasm/v1/wasm.proto", fileDescriptor_8e445a743f39a2b3) } - -var fileDescriptor_8e445a743f39a2b3 = []byte{ - // 234 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xce, 0x4c, 0x4a, 0xd6, - 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4f, 0x2c, 0xce, 0xd5, 0x2f, 0x33, 0x04, 0xd3, 0x7a, 0x05, - 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x02, 0x99, 0x49, 0xc9, 0x7a, 0x20, 0x49, 0x3d, 0xb0, 0x60, 0x99, - 0xa1, 0x52, 0x0d, 0x17, 0x6f, 0x78, 0x62, 0x71, 0xae, 0x73, 0x7e, 0x4a, 0xaa, 0x6b, 0x5e, 0x49, - 0x51, 0xa5, 0x90, 0x38, 0x17, 0x7b, 0x72, 0x7e, 0x4a, 0x6a, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, - 0xa3, 0x06, 0x4f, 0x10, 0x1b, 0x88, 0xeb, 0x99, 0x22, 0xa4, 0xc3, 0x25, 0x54, 0x50, 0x94, 0x5a, - 0x96, 0x99, 0x5f, 0x5a, 0x1c, 0x0f, 0x56, 0x91, 0x91, 0x58, 0x9c, 0x21, 0xc1, 0xa4, 0xc0, 0xa8, - 0xc1, 0x19, 0x24, 0x00, 0x93, 0x01, 0x99, 0xe3, 0x91, 0x58, 0x9c, 0x21, 0xa4, 0xc2, 0xc5, 0x97, - 0x97, 0x5a, 0x51, 0x82, 0xa4, 0x92, 0x19, 0xac, 0x92, 0x07, 0x24, 0x0a, 0x53, 0xe5, 0xe4, 0x7b, - 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, - 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xc6, 0xe9, 0x99, 0x25, 0x19, 0xa5, - 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x99, 0x49, 0xc9, - 0xba, 0xe9, 0xf9, 0xfa, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, 0xc5, 0x10, 0x3f, 0x1a, 0x59, 0xe8, - 0x82, 0xbd, 0x59, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, 0xa5, 0x31, 0x20, 0x00, 0x00, - 0xff, 0xff, 0x81, 0x4f, 0x94, 0xcd, 0x04, 0x01, 0x00, 0x00, -} - -func (m *WasmCodeEntry) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *WasmCodeEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *WasmCodeEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.NextCodeHash) > 0 { - i -= len(m.NextCodeHash) - copy(dAtA[i:], m.NextCodeHash) - i = encodeVarintWasm(dAtA, i, uint64(len(m.NextCodeHash))) - i-- - dAtA[i] = 0x1a - } - if len(m.PreviousCodeHash) > 0 { - i -= len(m.PreviousCodeHash) - copy(dAtA[i:], m.PreviousCodeHash) - i = encodeVarintWasm(dAtA, i, uint64(len(m.PreviousCodeHash))) - i-- - dAtA[i] = 0x12 - } - if len(m.CodeId) > 0 { - i -= len(m.CodeId) - copy(dAtA[i:], m.CodeId) - i = encodeVarintWasm(dAtA, i, uint64(len(m.CodeId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintWasm(dAtA []byte, offset int, v uint64) int { - offset -= sovWasm(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *WasmCodeEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.CodeId) - if l > 0 { - n += 1 + l + sovWasm(uint64(l)) - } - l = len(m.PreviousCodeHash) - if l > 0 { - n += 1 + l + sovWasm(uint64(l)) - } - l = len(m.NextCodeHash) - if l > 0 { - n += 1 + l + sovWasm(uint64(l)) - } - return n -} - -func sovWasm(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozWasm(x uint64) (n int) { - return sovWasm(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *WasmCodeEntry) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: WasmCodeEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: WasmCodeEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWasm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWasm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CodeId = append(m.CodeId[:0], dAtA[iNdEx:postIndex]...) - if m.CodeId == nil { - m.CodeId = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PreviousCodeHash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthWasm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthWasm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PreviousCodeHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NextCodeHash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthWasm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthWasm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NextCodeHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipWasm(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthWasm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipWasm(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowWasm - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowWasm - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowWasm - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthWasm - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupWasm - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthWasm - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthWasm = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowWasm = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupWasm = fmt.Errorf("proto: unexpected end of group") -) diff --git a/modules/core/exported/client.go b/modules/core/exported/client.go index 6863a1c42fa..f5a9bcd5bd6 100644 --- a/modules/core/exported/client.go +++ b/modules/core/exported/client.go @@ -15,9 +15,6 @@ const ( // TypeClientMisbehaviour is the shared evidence misbehaviour type TypeClientMisbehaviour string = "client_misbehaviour" - // WasmClientPrefix is used to indicate that the client is a on-chain Wasm blob. - WasmClientPrefix string = "wasm-" - // Solomachine is used to indicate that the light client is a solo machine. Solomachine string = "06-solomachine" @@ -28,6 +25,9 @@ const ( // for the localhost client. Localhost string = "09-localhost" + // Wasm is used to indicate that the light client is a on-chain Wasm program + Wasm string = "10-wasm" + // Active is a status type of a client. An active client is allowed to be used. Active Status = "Active" diff --git a/modules/core/genesis_test.go b/modules/core/genesis_test.go index 34d1e8e443e..5873440dc4b 100644 --- a/modules/core/genesis_test.go +++ b/modules/core/genesis_test.go @@ -105,7 +105,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { }, ), }, - clienttypes.NewParams(true, exported.Tendermint, exported.Localhost), + clienttypes.NewParams(exported.Tendermint, exported.Localhost), true, 2, ), @@ -173,7 +173,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { }, ), }, - clienttypes.NewParams(true, exported.Tendermint), + clienttypes.NewParams(exported.Tendermint), false, 2, ), @@ -269,7 +269,7 @@ func (suite *IBCTestSuite) TestInitGenesis() { }, ), }, - clienttypes.NewParams(true, exported.Tendermint, exported.Localhost), + clienttypes.NewParams(exported.Tendermint, exported.Localhost), true, 0, ), diff --git a/modules/core/keeper/grpc_query.go b/modules/core/keeper/grpc_query.go index 30406f4a0df..d706cafd441 100644 --- a/modules/core/keeper/grpc_query.go +++ b/modules/core/keeper/grpc_query.go @@ -3,10 +3,10 @@ package keeper import ( "context" - wasmtypes "github.com/cosmos/ibc-go/modules/core/28-wasm/types" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + wasmtypes "github.com/cosmos/ibc-go/modules/core/28-wasm/types" ) // ClientState implements the IBC QueryServer interface @@ -134,12 +134,7 @@ func (q Keeper) NextSequenceReceive(c context.Context, req *channeltypes.QueryNe return q.ChannelKeeper.NextSequenceReceive(c, req) } -// LatestWASMCode implements the IBC QueryServer interface -func (q Keeper) LatestWASMCode(c context.Context, req *wasmtypes.LatestWASMCodeQuery) (*wasmtypes.LatestWASMCodeResponse, error) { - return q.WasmKeeper.LatestWASMCode(c, req) -} - -// LatestWASMCodeEntry implements the IBC QueryServer interface -func (q Keeper) LatestWASMCodeEntry(c context.Context, req *wasmtypes.LatestWASMCodeEntryQuery) (*wasmtypes.LatestWASMCodeEntryResponse, error) { - return q.WasmKeeper.LatestWASMCodeEntry(c, req) +// WasmCode implements the IBC QueryServer interface +func (q Keeper) WasmCode(c context.Context, req *wasmtypes.WasmCodeQuery) (*wasmtypes.WasmCodeResponse, error) { + return q.WasmKeeper.WasmCode(c, req) } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index c91c635708d..1e5a828fdab 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -2,19 +2,20 @@ package keeper import ( "context" + "encoding/hex" "github.com/armon/go-metrics" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - wasm "github.com/cosmos/ibc-go/modules/core/28-wasm" - wasmtypes "github.com/cosmos/ibc-go/modules/core/28-wasm/types" clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types" channel "github.com/cosmos/ibc-go/modules/core/04-channel" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types" + wasm "github.com/cosmos/ibc-go/modules/core/28-wasm" + wasmtypes "github.com/cosmos/ibc-go/modules/core/28-wasm/types" ) var _ clienttypes.MsgServer = Keeper{} @@ -25,7 +26,23 @@ var _ wasmtypes.MsgServer = Keeper{} // PushNewWASMCode defines a rpc handler method for MsgPushNewWASMCode func (k Keeper) PushNewWASMCode(goCtx context.Context, msg *wasmtypes.MsgPushNewWASMCode) (*wasmtypes.MsgPushNewWASMCodeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - return wasm.HandleMsgPushNewWASMCode(ctx, k.WasmKeeper, msg) + response, err := wasm.HandleMsgPushNewWASMCode(ctx, k.WasmKeeper, msg) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + clienttypes.EventTypePushWasmCode, + sdk.NewAttribute(clienttypes.AttributeKeyWasmCodeID, hex.EncodeToString(response.CodeId)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, clienttypes.AttributeValueCategory), + ), + }) + + return response, nil } // CreateClient defines a rpc handler method for MsgCreateClient. diff --git a/modules/light-clients/07-tendermint/types/tendermint.pb.go b/modules/light-clients/07-tendermint/types/tendermint.pb.go index 84a79b66668..9a0645a4462 100644 --- a/modules/light-clients/07-tendermint/types/tendermint.pb.go +++ b/modules/light-clients/07-tendermint/types/tendermint.pb.go @@ -11,10 +11,10 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/golang/protobuf/ptypes/duration" - _ "github.com/golang/protobuf/ptypes/timestamp" github_com_tendermint_tendermint_libs_bytes "github.com/tendermint/tendermint/libs/bytes" types2 "github.com/tendermint/tendermint/proto/tendermint/types" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" diff --git a/modules/light-clients/10-wasm/types/client_state.go b/modules/light-clients/10-wasm/types/client_state.go index 7293848b0f0..ec968066e29 100644 --- a/modules/light-clients/10-wasm/types/client_state.go +++ b/modules/light-clients/10-wasm/types/client_state.go @@ -255,7 +255,7 @@ Following functions only queries the state so should be part of query call */ func (c *ClientState) ClientType() string { - return c.Type + return exported.Wasm } func (c *ClientState) ExportMetadata(store sdk.KVStore) []exported.GenesisMetadata { diff --git a/modules/light-clients/10-wasm/types/consensus_state.go b/modules/light-clients/10-wasm/types/consensus_state.go index 07c39cfc5d2..cda001ec6ca 100644 --- a/modules/light-clients/10-wasm/types/consensus_state.go +++ b/modules/light-clients/10-wasm/types/consensus_state.go @@ -11,7 +11,7 @@ import ( var _ exported.ConsensusState = (*ConsensusState)(nil) func (m *ConsensusState) ClientType() string { - return m.Type + return exported.Wasm } func (m *ConsensusState) GetRoot() exported.Root { diff --git a/modules/light-clients/10-wasm/types/header.go b/modules/light-clients/10-wasm/types/header.go index ea14fa588a4..ce44ce646b9 100644 --- a/modules/light-clients/10-wasm/types/header.go +++ b/modules/light-clients/10-wasm/types/header.go @@ -9,7 +9,7 @@ import ( var _ exported.Header = (*Header)(nil) func (m *Header) ClientType() string { - return m.Type + return exported.Wasm } func (m *Header) GetHeight() exported.Height { diff --git a/modules/light-clients/10-wasm/types/misbehaviour.go b/modules/light-clients/10-wasm/types/misbehaviour.go index b4215ed3f5d..e4a19879ce3 100644 --- a/modules/light-clients/10-wasm/types/misbehaviour.go +++ b/modules/light-clients/10-wasm/types/misbehaviour.go @@ -1,8 +1,6 @@ package types import ( - "fmt" - "github.com/cosmos/ibc-go/modules/core/exported" ) @@ -27,13 +25,5 @@ func (m *Misbehaviour) ValidateBasic() error { return err } - if m.CodeId == nil || len(m.CodeId) == 0 { - return fmt.Errorf("codeid cannot be empty") - } - return nil } - -func (m *Misbehaviour) GetHeight() exported.Height { - return m.Header1.GetHeight() -} diff --git a/modules/light-clients/10-wasm/types/vm.go b/modules/light-clients/10-wasm/types/vm.go index b31b7796637..c6c149ebfbc 100644 --- a/modules/light-clients/10-wasm/types/vm.go +++ b/modules/light-clients/10-wasm/types/vm.go @@ -19,11 +19,8 @@ var _ exported.ClientState = (*ClientState)(nil) type queryResponse struct { ProofSpecs []*ics23.ProofSpec `json:"proof_specs,omitempty"` Height types2.Height `json:"height,omitempty"` - IsFrozen bool `json:"is_frozen,omitempty"` - FrozenHeight types2.Height `json:"frozen_height,omitempty"` GenesisMetadata []types2.GenesisMetadata `json:"genesis_metadata,omitempty"` Result contractResult `json:"result,omitempty"` - ClientType string `json:"client_type,omitempty"` Root types3.MerkleRoot `json:"root,omitempty"` Timestamp uint64 `json:"timestamp,omitempty"` Status exported.Status `json:"status,omitempty"` @@ -44,16 +41,13 @@ type clientStateCallResponse struct { func (r *clientStateCallResponse) resetImmutables(c *ClientState) { if r.Me != nil { r.Me.CodeId = c.CodeId - r.Me.Type = c.Type } if r.NewConsensusState != nil { - r.NewConsensusState.Type = c.Type r.NewConsensusState.CodeId = c.CodeId } if r.NewClientState != nil { - r.NewClientState.Type = c.Type r.NewClientState.CodeId = c.CodeId } } diff --git a/modules/light-clients/10-wasm/types/wasm.pb.go b/modules/light-clients/10-wasm/types/wasm.pb.go index 9841ddbf6b8..d4f8c21765a 100644 --- a/modules/light-clients/10-wasm/types/wasm.pb.go +++ b/modules/light-clients/10-wasm/types/wasm.pb.go @@ -31,11 +31,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ClientState struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` CodeId []byte `protobuf:"bytes,2,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` - Frozen bool `protobuf:"varint,3,opt,name=frozen,proto3" json:"frozen,omitempty"` - FrozenHeight *types.Height `protobuf:"bytes,4,opt,name=frozen_height,json=frozenHeight,proto3" json:"frozen_height,omitempty"` - LatestHeight *types.Height `protobuf:"bytes,5,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height,omitempty"` - Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` - ProofSpecs []*_go.ProofSpec `protobuf:"bytes,7,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty"` + LatestHeight *types.Height `protobuf:"bytes,3,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height,omitempty"` + ProofSpecs []*_go.ProofSpec `protobuf:"bytes,4,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty"` } func (m *ClientState) Reset() { *m = ClientState{} } @@ -80,7 +77,6 @@ type ConsensusState struct { Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // commitment root (i.e app hash) Root *types1.MerkleRoot `protobuf:"bytes,4,opt,name=root,proto3" json:"root,omitempty"` - Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` } func (m *ConsensusState) Reset() { *m = ConsensusState{} } @@ -120,7 +116,6 @@ var xxx_messageInfo_ConsensusState proto.InternalMessageInfo type Header struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Height *types.Height `protobuf:"bytes,2,opt,name=height,proto3" json:"height,omitempty"` - Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` } func (m *Header) Reset() { *m = Header{} } @@ -158,10 +153,9 @@ var xxx_messageInfo_Header proto.InternalMessageInfo // WASM light client Misbehaviour type Misbehaviour struct { - CodeId []byte `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` - ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` - Header1 *Header `protobuf:"bytes,3,opt,name=header_1,json=header1,proto3" json:"header_1,omitempty" yaml:"header_1"` - Header2 *Header `protobuf:"bytes,4,opt,name=header_2,json=header2,proto3" json:"header_2,omitempty" yaml:"header_2"` + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + Header1 *Header `protobuf:"bytes,2,opt,name=header_1,json=header1,proto3" json:"header_1,omitempty" yaml:"header_1"` + Header2 *Header `protobuf:"bytes,3,opt,name=header_2,json=header2,proto3" json:"header_2,omitempty" yaml:"header_2"` } func (m *Misbehaviour) Reset() { *m = Misbehaviour{} } @@ -197,34 +191,6 @@ func (m *Misbehaviour) XXX_DiscardUnknown() { var xxx_messageInfo_Misbehaviour proto.InternalMessageInfo -func (m *Misbehaviour) GetCodeId() []byte { - if m != nil { - return m.CodeId - } - return nil -} - -func (m *Misbehaviour) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -func (m *Misbehaviour) GetHeader1() *Header { - if m != nil { - return m.Header1 - } - return nil -} - -func (m *Misbehaviour) GetHeader2() *Header { - if m != nil { - return m.Header2 - } - return nil -} - func init() { proto.RegisterType((*ClientState)(nil), "ibc.lightclients.wasm.v1.ClientState") proto.RegisterType((*ConsensusState)(nil), "ibc.lightclients.wasm.v1.ConsensusState") @@ -237,44 +203,41 @@ func init() { } var fileDescriptor_678928ebbdee1807 = []byte{ - // 591 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4d, 0x6e, 0xd3, 0x40, - 0x18, 0x8d, 0x53, 0xd7, 0x69, 0x26, 0x05, 0x2a, 0x53, 0x81, 0x55, 0x21, 0xc7, 0x32, 0x0b, 0xb2, - 0xa9, 0x8d, 0x5d, 0x89, 0x45, 0x85, 0x84, 0x94, 0x6e, 0xda, 0x45, 0x25, 0xe4, 0x4a, 0x2c, 0x60, - 0x11, 0xf9, 0x67, 0xe2, 0x0c, 0xd8, 0xf9, 0x2c, 0xcf, 0x24, 0xa8, 0x9c, 0x80, 0x25, 0x0b, 0x0e, - 0x00, 0x07, 0xe0, 0x1e, 0x2c, 0xbb, 0x64, 0x15, 0xa1, 0xe4, 0x06, 0x3d, 0x01, 0x9a, 0x19, 0xdb, - 0x09, 0x2a, 0xa8, 0x82, 0x95, 0xdf, 0x37, 0xf3, 0xfc, 0xbe, 0x79, 0x6f, 0x34, 0x1f, 0x7a, 0x4c, - 0xa2, 0xd8, 0xcd, 0x48, 0x3a, 0x61, 0x71, 0x46, 0xf0, 0x94, 0x51, 0xf7, 0x7d, 0x48, 0x73, 0x77, - 0xee, 0x89, 0xaf, 0x53, 0x94, 0xc0, 0x40, 0x37, 0x48, 0x14, 0x3b, 0x9b, 0x24, 0x47, 0x6c, 0xce, - 0xbd, 0x83, 0xfd, 0x14, 0x52, 0x10, 0x24, 0x97, 0x23, 0xc9, 0x3f, 0xe8, 0x73, 0xd1, 0x18, 0x4a, - 0xec, 0x4a, 0x3e, 0x97, 0x93, 0xa8, 0x22, 0x3c, 0x59, 0x13, 0x20, 0xcf, 0x09, 0xcb, 0x6b, 0x52, - 0x53, 0xd5, 0x4a, 0x29, 0x40, 0x9a, 0x61, 0x57, 0x54, 0xd1, 0x6c, 0xec, 0x32, 0x92, 0x63, 0xca, - 0xc2, 0xbc, 0xa8, 0x08, 0xf7, 0x63, 0x98, 0x8e, 0x09, 0x70, 0x02, 0x8c, 0xa9, 0x5c, 0xb4, 0xbf, - 0xb6, 0x51, 0xef, 0x44, 0xf4, 0xbb, 0x60, 0x21, 0xc3, 0xba, 0x8e, 0xd4, 0x24, 0x64, 0xa1, 0xa1, - 0x58, 0xca, 0x60, 0x37, 0x10, 0x58, 0x7f, 0x88, 0x3a, 0x31, 0x24, 0x78, 0x44, 0x12, 0xa3, 0x2d, - 0x96, 0x35, 0x5e, 0x9e, 0x25, 0xfa, 0x03, 0xa4, 0x8d, 0x4b, 0xf8, 0x80, 0xa7, 0xc6, 0x96, 0xa5, - 0x0c, 0x76, 0x82, 0xaa, 0xd2, 0x5f, 0xa0, 0x3b, 0x12, 0x8d, 0x26, 0x98, 0x47, 0x61, 0xa8, 0x96, - 0x32, 0xe8, 0xf9, 0x07, 0x0e, 0x0f, 0x87, 0x7b, 0x71, 0x2a, 0x8b, 0x73, 0xcf, 0x39, 0x15, 0x8c, - 0x60, 0x57, 0xfe, 0x20, 0x2b, 0x2e, 0x90, 0x85, 0x0c, 0x53, 0x56, 0x0b, 0x6c, 0xdf, 0x2e, 0x20, - 0x7f, 0xa8, 0x04, 0x74, 0xa4, 0xb2, 0xcb, 0x02, 0x1b, 0x9a, 0xa5, 0x0c, 0xba, 0x81, 0xc0, 0xba, - 0x87, 0x7a, 0xc2, 0xfa, 0x88, 0x16, 0x38, 0xa6, 0x46, 0xc7, 0xda, 0x1a, 0xf4, 0xfc, 0x3d, 0x87, - 0xc4, 0xd4, 0x3f, 0x72, 0x5e, 0xf2, 0x9d, 0x8b, 0x02, 0xc7, 0x01, 0x2a, 0x6a, 0x48, 0x8f, 0xd5, - 0x8f, 0x5f, 0xfa, 0x2d, 0xfb, 0x9b, 0x82, 0xee, 0x9e, 0xc0, 0x94, 0xe2, 0x29, 0x9d, 0xd1, 0xff, - 0x88, 0xe9, 0x11, 0xea, 0x36, 0x77, 0x21, 0x92, 0x52, 0x83, 0xf5, 0x82, 0xfe, 0x0c, 0xa9, 0x25, - 0x40, 0x9d, 0x91, 0xbd, 0x61, 0x71, 0x7d, 0xc3, 0x73, 0xcf, 0x39, 0xc7, 0xe5, 0xbb, 0x0c, 0x07, - 0x00, 0x2c, 0x10, 0xfc, 0xc6, 0xe2, 0xf6, 0xda, 0x62, 0x75, 0xde, 0xb7, 0x48, 0x3b, 0xc5, 0x61, - 0x82, 0xcb, 0x3f, 0x1e, 0xd3, 0x47, 0x5a, 0x15, 0x6a, 0xfb, 0xd6, 0x50, 0x2b, 0x66, 0xd3, 0x6b, - 0xeb, 0x46, 0xaf, 0xcf, 0x6d, 0xb4, 0x7b, 0x4e, 0x68, 0x84, 0x27, 0xe1, 0x9c, 0xc0, 0xac, 0xdc, - 0x4c, 0x41, 0xf9, 0x2d, 0x05, 0x0f, 0x75, 0xa5, 0x7e, 0x1d, 0x50, 0x77, 0xb8, 0x7f, 0xbd, 0xe8, - 0xef, 0x5d, 0x86, 0x79, 0x76, 0x6c, 0x37, 0x5b, 0x76, 0xb0, 0x23, 0xf1, 0x59, 0xa2, 0xbf, 0x41, - 0x3b, 0x13, 0x61, 0x64, 0xe4, 0x89, 0xd6, 0x3d, 0xdf, 0x72, 0xfe, 0xf6, 0xbe, 0x1c, 0x69, 0x79, - 0x68, 0x2e, 0x17, 0xfd, 0x8e, 0xc4, 0xde, 0xf5, 0xa2, 0x7f, 0x4f, 0xca, 0xd7, 0x32, 0x76, 0xd0, - 0x91, 0xd0, 0xdb, 0x10, 0xf7, 0xab, 0xec, 0xff, 0x49, 0xdc, 0xbf, 0x21, 0xee, 0x37, 0xe2, 0xfe, - 0xf0, 0xd5, 0xf7, 0xa5, 0xa9, 0x5c, 0x2d, 0x4d, 0xe5, 0xe7, 0xd2, 0x54, 0x3e, 0xad, 0xcc, 0xd6, - 0xd5, 0xca, 0x6c, 0xfd, 0x58, 0x99, 0xad, 0xd7, 0xcf, 0x53, 0xc2, 0x26, 0xb3, 0x88, 0xdf, 0xae, - 0x1b, 0x03, 0xcd, 0x81, 0xba, 0x24, 0x8a, 0x0f, 0x53, 0x70, 0x73, 0x48, 0x66, 0x19, 0xa6, 0x72, - 0xc4, 0x1c, 0xd6, 0x33, 0xc6, 0x7b, 0x7a, 0x28, 0xc6, 0x0c, 0xcf, 0x9c, 0x46, 0x9a, 0x78, 0xb5, - 0x47, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x0e, 0xcb, 0x4b, 0x8c, 0x04, 0x00, 0x00, + // 541 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x3f, 0x6f, 0xd3, 0x40, + 0x1c, 0x8d, 0x53, 0x2b, 0x69, 0x2e, 0x01, 0x2a, 0x53, 0x09, 0x2b, 0x42, 0x4e, 0x64, 0x06, 0xb2, + 0xe4, 0x8c, 0x5d, 0x89, 0xa1, 0x42, 0x42, 0x4a, 0x97, 0x76, 0xa8, 0x84, 0x5c, 0xa9, 0x03, 0x0c, + 0x91, 0x7d, 0xbe, 0x38, 0x27, 0xec, 0xfc, 0x2c, 0xdf, 0x25, 0xa8, 0x23, 0x1b, 0x23, 0x2b, 0x1b, + 0x1f, 0x82, 0x0f, 0xc1, 0xd8, 0x91, 0x29, 0x42, 0xc9, 0x37, 0xe8, 0x27, 0x40, 0x77, 0xe7, 0xfc, + 0x91, 0x00, 0x21, 0x3a, 0xf9, 0xfd, 0xee, 0xde, 0xbd, 0x7b, 0xbf, 0xe7, 0xfb, 0xa1, 0x67, 0x2c, + 0x26, 0x5e, 0xc6, 0xd2, 0xa9, 0x20, 0x19, 0xa3, 0x33, 0xc1, 0xbd, 0x0f, 0x11, 0xcf, 0xbd, 0x85, + 0xaf, 0xbe, 0xb8, 0x28, 0x41, 0x80, 0x65, 0xb3, 0x98, 0xe0, 0x7d, 0x12, 0x56, 0x9b, 0x0b, 0xbf, + 0x7b, 0x9c, 0x42, 0x0a, 0x8a, 0xe4, 0x49, 0xa4, 0xf9, 0xdd, 0x9e, 0x14, 0x25, 0x50, 0x52, 0x4f, + 0xf3, 0xa5, 0x9c, 0x46, 0x15, 0xe1, 0xf9, 0x8e, 0x00, 0x79, 0xce, 0x44, 0xbe, 0x21, 0x6d, 0xab, + 0x8d, 0x52, 0x0a, 0x90, 0x66, 0xd4, 0x53, 0x55, 0x3c, 0x9f, 0x78, 0x82, 0xe5, 0x94, 0x8b, 0x28, + 0x2f, 0x2a, 0xc2, 0x63, 0x02, 0xb3, 0x09, 0x03, 0x49, 0x80, 0x09, 0xd7, 0x8b, 0xee, 0x37, 0x03, + 0xb5, 0xcf, 0xd4, 0x7d, 0x57, 0x22, 0x12, 0xd4, 0xb2, 0x90, 0x99, 0x44, 0x22, 0xb2, 0x8d, 0xbe, + 0x31, 0xe8, 0x84, 0x0a, 0x5b, 0x4f, 0x50, 0x93, 0x40, 0x42, 0xc7, 0x2c, 0xb1, 0xeb, 0x6a, 0xb9, + 0x21, 0xcb, 0x8b, 0xc4, 0x7a, 0x8d, 0x1e, 0x64, 0x91, 0xa0, 0x5c, 0x8c, 0xa7, 0x54, 0xb6, 0x6c, + 0x1f, 0xf4, 0x8d, 0x41, 0x3b, 0xe8, 0x62, 0x19, 0x82, 0xf4, 0x8c, 0xab, 0x56, 0x16, 0x3e, 0x3e, + 0x57, 0x8c, 0xb0, 0xa3, 0x0f, 0xe8, 0xca, 0xf2, 0x51, 0x5b, 0xb9, 0x19, 0xf3, 0x82, 0x12, 0x6e, + 0x9b, 0xfd, 0x83, 0x41, 0x3b, 0x38, 0xc2, 0x8c, 0xf0, 0xe0, 0x04, 0xbf, 0x91, 0x3b, 0x57, 0x05, + 0x25, 0x21, 0x2a, 0x36, 0x90, 0x9f, 0x9a, 0x9f, 0xbe, 0xf6, 0x6a, 0xee, 0x17, 0x03, 0x3d, 0x3c, + 0x83, 0x19, 0xa7, 0x33, 0x3e, 0xe7, 0xf7, 0x70, 0xfe, 0x14, 0xb5, 0xb6, 0xf1, 0x28, 0xd7, 0x66, + 0xb8, 0x5b, 0xb0, 0x5e, 0x22, 0xb3, 0x04, 0x10, 0xb6, 0xa9, 0xda, 0x71, 0xf7, 0xda, 0xd9, 0x85, + 0xbe, 0xf0, 0xf1, 0x25, 0x2d, 0xdf, 0x67, 0x34, 0x04, 0x10, 0xa1, 0xe2, 0x57, 0xde, 0xae, 0x51, + 0xe3, 0x9c, 0x46, 0x09, 0x2d, 0xff, 0x68, 0x29, 0x40, 0x8d, 0x2a, 0xac, 0xfa, 0x3f, 0xc3, 0xaa, + 0x98, 0x95, 0xee, 0xc7, 0x3a, 0xea, 0x5c, 0x32, 0x1e, 0xd3, 0x69, 0xb4, 0x60, 0x30, 0x2f, 0x2d, + 0x1f, 0xb5, 0xf4, 0x11, 0xd9, 0x9f, 0xbc, 0xa3, 0x35, 0x3a, 0xbe, 0x5b, 0xf6, 0x8e, 0x6e, 0xa2, + 0x3c, 0x3b, 0x75, 0xb7, 0x5b, 0x6e, 0x78, 0xa8, 0xf1, 0x45, 0x62, 0xbd, 0x43, 0x87, 0x53, 0xe5, + 0x6d, 0xec, 0x57, 0xf7, 0xf7, 0xf1, 0xdf, 0x5e, 0x2c, 0xd6, 0x5d, 0x8c, 0x9c, 0xd5, 0xb2, 0xd7, + 0xd4, 0xd8, 0xbf, 0x5b, 0xf6, 0x1e, 0x69, 0xf9, 0x8d, 0x8c, 0x1b, 0x36, 0x35, 0xf4, 0xf7, 0xc4, + 0x83, 0xea, 0x25, 0xfc, 0x97, 0x78, 0xf0, 0x9b, 0x78, 0xb0, 0x15, 0x0f, 0x74, 0x06, 0xa3, 0xeb, + 0xef, 0x2b, 0xc7, 0xb8, 0x5d, 0x39, 0xc6, 0xcf, 0x95, 0x63, 0x7c, 0x5e, 0x3b, 0xb5, 0xdb, 0xb5, + 0x53, 0xfb, 0xb1, 0x76, 0x6a, 0x6f, 0x5f, 0xa5, 0x4c, 0x4c, 0xe7, 0xb1, 0xfc, 0x45, 0x1e, 0x01, + 0x9e, 0x03, 0xf7, 0x58, 0x4c, 0x86, 0x29, 0x78, 0x39, 0x24, 0xf3, 0x8c, 0x72, 0x3d, 0xba, 0xc3, + 0xcd, 0xec, 0xfa, 0x2f, 0x86, 0x6a, 0x7c, 0xc5, 0x4d, 0x41, 0x79, 0xdc, 0x50, 0xd3, 0x70, 0xf2, + 0x2b, 0x00, 0x00, 0xff, 0xff, 0x72, 0x42, 0xb2, 0x0c, 0xe4, 0x03, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { @@ -308,16 +271,9 @@ func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintWasm(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x22 } } - if len(m.Type) > 0 { - i -= len(m.Type) - copy(dAtA[i:], m.Type) - i = encodeVarintWasm(dAtA, i, uint64(len(m.Type))) - i-- - dAtA[i] = 0x32 - } if m.LatestHeight != nil { { size, err := m.LatestHeight.MarshalToSizedBuffer(dAtA[:i]) @@ -328,29 +284,7 @@ func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintWasm(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a - } - if m.FrozenHeight != nil { - { - size, err := m.FrozenHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintWasm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.Frozen { - i-- - if m.Frozen { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1a } if len(m.CodeId) > 0 { i -= len(m.CodeId) @@ -389,13 +323,6 @@ func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Type) > 0 { - i -= len(m.Type) - copy(dAtA[i:], m.Type) - i = encodeVarintWasm(dAtA, i, uint64(len(m.Type))) - i-- - dAtA[i] = 0x2a - } if m.Root != nil { { size, err := m.Root.MarshalToSizedBuffer(dAtA[:i]) @@ -450,13 +377,6 @@ func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Type) > 0 { - i -= len(m.Type) - copy(dAtA[i:], m.Type) - i = encodeVarintWasm(dAtA, i, uint64(len(m.Type))) - i-- - dAtA[i] = 0x1a - } if m.Height != nil { { size, err := m.Height.MarshalToSizedBuffer(dAtA[:i]) @@ -509,7 +429,7 @@ func (m *Misbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintWasm(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } if m.Header1 != nil { { @@ -521,20 +441,13 @@ func (m *Misbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintWasm(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if len(m.ClientId) > 0 { i -= len(m.ClientId) copy(dAtA[i:], m.ClientId) i = encodeVarintWasm(dAtA, i, uint64(len(m.ClientId))) i-- - dAtA[i] = 0x12 - } - if len(m.CodeId) > 0 { - i -= len(m.CodeId) - copy(dAtA[i:], m.CodeId) - i = encodeVarintWasm(dAtA, i, uint64(len(m.CodeId))) - i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -565,21 +478,10 @@ func (m *ClientState) Size() (n int) { if l > 0 { n += 1 + l + sovWasm(uint64(l)) } - if m.Frozen { - n += 2 - } - if m.FrozenHeight != nil { - l = m.FrozenHeight.Size() - n += 1 + l + sovWasm(uint64(l)) - } if m.LatestHeight != nil { l = m.LatestHeight.Size() n += 1 + l + sovWasm(uint64(l)) } - l = len(m.Type) - if l > 0 { - n += 1 + l + sovWasm(uint64(l)) - } if len(m.ProofSpecs) > 0 { for _, e := range m.ProofSpecs { l = e.Size() @@ -610,10 +512,6 @@ func (m *ConsensusState) Size() (n int) { l = m.Root.Size() n += 1 + l + sovWasm(uint64(l)) } - l = len(m.Type) - if l > 0 { - n += 1 + l + sovWasm(uint64(l)) - } return n } @@ -631,10 +529,6 @@ func (m *Header) Size() (n int) { l = m.Height.Size() n += 1 + l + sovWasm(uint64(l)) } - l = len(m.Type) - if l > 0 { - n += 1 + l + sovWasm(uint64(l)) - } return n } @@ -644,10 +538,6 @@ func (m *Misbehaviour) Size() (n int) { } var l int _ = l - l = len(m.CodeId) - if l > 0 { - n += 1 + l + sovWasm(uint64(l)) - } l = len(m.ClientId) if l > 0 { n += 1 + l + sovWasm(uint64(l)) @@ -767,62 +657,6 @@ func (m *ClientState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Frozen", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Frozen = bool(v != 0) - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FrozenHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthWasm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthWasm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.FrozenHeight == nil { - m.FrozenHeight = &types.Height{} - } - if err := m.FrozenHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LatestHeight", wireType) } @@ -858,39 +692,7 @@ func (m *ClientState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthWasm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthWasm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofSpecs", wireType) } @@ -1097,38 +899,6 @@ func (m *ConsensusState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthWasm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthWasm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipWasm(dAtA[iNdEx:]) @@ -1249,38 +1019,6 @@ func (m *Header) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthWasm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthWasm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipWasm(dAtA[iNdEx:]) @@ -1332,40 +1070,6 @@ func (m *Misbehaviour) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CodeId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWasm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWasm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWasm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CodeId = append(m.CodeId[:0], dAtA[iNdEx:postIndex]...) - if m.CodeId == nil { - m.CodeId = []byte{} - } - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) } @@ -1397,7 +1101,7 @@ func (m *Misbehaviour) Unmarshal(dAtA []byte) error { } m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Header1", wireType) } @@ -1433,7 +1137,7 @@ func (m *Misbehaviour) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Header2", wireType) } diff --git a/proto/ibc/core/wasm/v1/query.proto b/proto/ibc/core/wasm/v1/query.proto index 5207e637713..85a66f986aa 100644 --- a/proto/ibc/core/wasm/v1/query.proto +++ b/proto/ibc/core/wasm/v1/query.proto @@ -1,41 +1,24 @@ syntax = "proto3"; package ibc.core.wasm.v1; -import "ibc/core/wasm/v1/wasm.proto"; import "google/api/annotations.proto"; option go_package = "github.com/cosmos/ibc-go/modules/core/28-wasm/types"; -// Latest wasm code query -message LatestWASMCodeQuery { - string client_type = 1; +// WasmCode query +message WasmCodeQuery { + string code_id = 1; } -// Latest wasm code response -message LatestWASMCodeResponse { +// WasmCode response +message WasmCodeResponse { bytes code = 1; } -// Latest wasm code entry query -message LatestWASMCodeEntryQuery { - string client_type = 1; -} - -// Latest wasm code entry response -message LatestWASMCodeEntryResponse { - string code_id = 1; - ibc.core.wasm.v1.WasmCodeEntry entry = 2; -} - // Query service for wasm module service Query { - // Query to get latest wasm code for particular client type. - rpc LatestWASMCode(LatestWASMCodeQuery) returns (LatestWASMCodeResponse) { - option (google.api.http).get = "/ibc/core/wasm/v1beta1/latest_wasm_code/{client_type}"; + // Get Wasm code for given code id + rpc WasmCode(WasmCodeQuery) returns (WasmCodeResponse) { + option (google.api.http).get = "/ibc/core/wasm/v1beta1/code/{code_id}"; } - - // Query for get latest wasm code entry for particular client type - rpc LatestWASMCodeEntry(LatestWASMCodeEntryQuery) returns (LatestWASMCodeEntryResponse) { - option (google.api.http).get = "/ibc/core/wasm/v1beta1/latest_wasm_code_entry/{client_type}"; - } -} \ No newline at end of file +} diff --git a/proto/ibc/core/wasm/v1/tx.proto b/proto/ibc/core/wasm/v1/tx.proto index e394f719b68..49b2da3d177 100644 --- a/proto/ibc/core/wasm/v1/tx.proto +++ b/proto/ibc/core/wasm/v1/tx.proto @@ -14,12 +14,10 @@ service Msg { // Message type to push new wasm code message MsgPushNewWASMCode { string signer = 1; - string client_type = 2; bytes code = 3; } // Response in case of successful handling message MsgPushNewWASMCodeResponse { bytes code_id = 1; - string code_hash = 2; -} \ No newline at end of file +} diff --git a/proto/ibc/core/wasm/v1/wasm.proto b/proto/ibc/core/wasm/v1/wasm.proto deleted file mode 100644 index dd85ab39188..00000000000 --- a/proto/ibc/core/wasm/v1/wasm.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; -package ibc.core.wasm.v1; - -option go_package = "github.com/cosmos/ibc-go/modules/core/28-wasm/types"; - -// WASM code entry that allows keeper to traverse -// the doubly linked list -message WasmCodeEntry { - bytes code_id = 1; - string previous_code_hash = 2; - string next_code_hash = 3; -} diff --git a/proto/ibc/lightclients/wasm/v1/wasm.proto b/proto/ibc/lightclients/wasm/v1/wasm.proto index 6ab33985259..c7f3676b154 100644 --- a/proto/ibc/lightclients/wasm/v1/wasm.proto +++ b/proto/ibc/lightclients/wasm/v1/wasm.proto @@ -14,11 +14,8 @@ message ClientState { option (gogoproto.goproto_getters) = false; bytes data = 1; bytes code_id = 2; - bool frozen = 3; - ibc.core.client.v1.Height frozen_height = 4; - ibc.core.client.v1.Height latest_height = 5; - string type = 6; - repeated ics23.ProofSpec proof_specs = 7; + ibc.core.client.v1.Height latest_height = 3; + repeated ics23.ProofSpec proof_specs = 4; } // WASM light client's ConsensusState @@ -32,7 +29,6 @@ message ConsensusState { uint64 timestamp = 3; // commitment root (i.e app hash) ibc.core.commitment.v1.MerkleRoot root = 4; - string type = 5; } // WASM light client Header @@ -41,13 +37,13 @@ message Header { bytes data = 1; ibc.core.client.v1.Height height = 2; - string type = 3; } // WASM light client Misbehaviour message Misbehaviour { - bytes code_id = 1; - string client_id = 2 [(gogoproto.moretags) = "yaml:\"client_id\""]; - Header header_1 = 3 [(gogoproto.customname) = "Header1", (gogoproto.moretags) = "yaml:\"header_1\""]; - Header header_2 = 4 [(gogoproto.customname) = "Header2", (gogoproto.moretags) = "yaml:\"header_2\""]; + option (gogoproto.goproto_getters) = false; + + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + Header header_1 = 2 [(gogoproto.customname) = "Header1", (gogoproto.moretags) = "yaml:\"header_1\""]; + Header header_2 = 3 [(gogoproto.customname) = "Header2", (gogoproto.moretags) = "yaml:\"header_2\""]; } From 7ae0507a974c8b7532d4ccf9ee697e8926cb608e Mon Sep 17 00:00:00 2001 From: Kaczanowski Mateusz Date: Fri, 18 Jun 2021 14:20:41 +0200 Subject: [PATCH 11/11] rename WASM to Wasm --- docs/ibc/proto-docs.md | 22 +-- modules/core/28-wasm/cli/cli.go | 2 +- modules/core/28-wasm/cli/tx.go | 6 +- modules/core/28-wasm/handler.go | 6 +- modules/core/28-wasm/keeper/keeper.go | 16 +- modules/core/28-wasm/keeper/validation.go | 8 +- modules/core/28-wasm/types/codec.go | 2 +- modules/core/28-wasm/types/msgs.go | 12 +- modules/core/28-wasm/types/tx.pb.go | 164 +++++++++--------- modules/core/keeper/msg_server.go | 6 +- .../light-clients/10-wasm/types/wasm.pb.go | 8 +- proto/ibc/core/wasm/v1/tx.proto | 8 +- proto/ibc/lightclients/wasm/v1/wasm.proto | 8 +- 13 files changed, 134 insertions(+), 134 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 71b6ccfb820..989a50d1c36 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -199,8 +199,8 @@ - [Query](#ibc.core.wasm.v1.Query) - [ibc/core/wasm/v1/tx.proto](#ibc/core/wasm/v1/tx.proto) - - [MsgPushNewWASMCode](#ibc.core.wasm.v1.MsgPushNewWASMCode) - - [MsgPushNewWASMCodeResponse](#ibc.core.wasm.v1.MsgPushNewWASMCodeResponse) + - [MsgPushNewWasmCode](#ibc.core.wasm.v1.MsgPushNewWasmCode) + - [MsgPushNewWasmCodeResponse](#ibc.core.wasm.v1.MsgPushNewWasmCodeResponse) - [Msg](#ibc.core.wasm.v1.Msg) @@ -2971,9 +2971,9 @@ Query service for wasm module - + -### MsgPushNewWASMCode +### MsgPushNewWasmCode Message type to push new wasm code @@ -2987,9 +2987,9 @@ Message type to push new wasm code - + -### MsgPushNewWASMCodeResponse +### MsgPushNewWasmCodeResponse Response in case of successful handling @@ -3015,7 +3015,7 @@ Msg defines the ibc/wasm Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `PushNewWASMCode` | [MsgPushNewWASMCode](#ibc.core.wasm.v1.MsgPushNewWASMCode) | [MsgPushNewWASMCodeResponse](#ibc.core.wasm.v1.MsgPushNewWASMCodeResponse) | PushNewWASMCode defines a rpc handler method for PushNewWASMCode. | | +| `PushNewWasmCode` | [MsgPushNewWasmCode](#ibc.core.wasm.v1.MsgPushNewWasmCode) | [MsgPushNewWasmCodeResponse](#ibc.core.wasm.v1.MsgPushNewWasmCodeResponse) | PushNewWasmCode defines a rpc handler method for PushNewWasmCode. | | @@ -3505,7 +3505,7 @@ that implements Misbehaviour interface expected by ICS-02 ### ClientState -WASM light client's Client state +Wasm light client's Client state | Field | Type | Label | Description | @@ -3523,7 +3523,7 @@ WASM light client's Client state ### ConsensusState -WASM light client's ConsensusState +Wasm light client's ConsensusState | Field | Type | Label | Description | @@ -3541,7 +3541,7 @@ WASM light client's ConsensusState ### Header -WASM light client Header +Wasm light client Header | Field | Type | Label | Description | @@ -3557,7 +3557,7 @@ WASM light client Header ### Misbehaviour -WASM light client Misbehaviour +Wasm light client Misbehaviour | Field | Type | Label | Description | diff --git a/modules/core/28-wasm/cli/cli.go b/modules/core/28-wasm/cli/cli.go index 39e79c52695..3bf4bc2647a 100644 --- a/modules/core/28-wasm/cli/cli.go +++ b/modules/core/28-wasm/cli/cli.go @@ -34,7 +34,7 @@ func NewTxCmd() *cobra.Command { } txCmd.AddCommand( - NewPushNewWASMCodeCmd(), + NewPushNewWasmCodeCmd(), ) return txCmd diff --git a/modules/core/28-wasm/cli/tx.go b/modules/core/28-wasm/cli/tx.go index 87afd674ecb..868226e3aaa 100644 --- a/modules/core/28-wasm/cli/tx.go +++ b/modules/core/28-wasm/cli/tx.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/cobra" ) -// NewPushNewWASMCodeCmd returns the command to create a PushNewWASMCode transaction -func NewPushNewWASMCodeCmd() *cobra.Command { +// NewPushNewWasmCodeCmd returns the command to create a PushNewWasmCode transaction +func NewPushNewWasmCodeCmd() *cobra.Command { cmd := &cobra.Command{ Use: "push-wasm [wasm-file]", Short: "Reads wasm code from the file and creates push transaction", @@ -29,7 +29,7 @@ func NewPushNewWASMCodeCmd() *cobra.Command { return err } - msg := &types.MsgPushNewWASMCode{ + msg := &types.MsgPushNewWasmCode{ Code: code, Signer: clientCtx.GetFromAddress().String(), } diff --git a/modules/core/28-wasm/handler.go b/modules/core/28-wasm/handler.go index b864410de4c..1882612b3b8 100644 --- a/modules/core/28-wasm/handler.go +++ b/modules/core/28-wasm/handler.go @@ -7,13 +7,13 @@ import ( "github.com/cosmos/ibc-go/modules/core/28-wasm/types" ) -func HandleMsgPushNewWASMCode(ctx sdk.Context, k keeper.Keeper, msg *types.MsgPushNewWASMCode) (*types.MsgPushNewWASMCodeResponse, error) { - codeID, err := k.PushNewWASMCode(ctx, msg.Code) +func HandleMsgPushNewWasmCode(ctx sdk.Context, k keeper.Keeper, msg *types.MsgPushNewWasmCode) (*types.MsgPushNewWasmCodeResponse, error) { + codeID, err := k.PushNewWasmCode(ctx, msg.Code) if err != nil { return nil, sdkerrors.Wrap(err, "pushing new wasm code failed") } - return &types.MsgPushNewWASMCodeResponse{ + return &types.MsgPushNewWasmCodeResponse{ CodeId: codeID, }, nil } diff --git a/modules/core/28-wasm/keeper/keeper.go b/modules/core/28-wasm/keeper/keeper.go index 875045abdc9..70c8a3f216c 100644 --- a/modules/core/28-wasm/keeper/keeper.go +++ b/modules/core/28-wasm/keeper/keeper.go @@ -15,7 +15,7 @@ import ( // WasmVM initialized by wasm keeper var WasmVM *wasm.VM -// VMConfig represents WASM virtual machine settings +// VMConfig represents Wasm virtual machine settings type VMConfig struct { DataDir string SupportedFeatures []string @@ -28,7 +28,7 @@ type VMConfig struct { type Keeper struct { storeKey sdk.StoreKey cdc codec.BinaryCodec - wasmValidator *WASMValidator + wasmValidator *WasmValidator } func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, vmConfig *VMConfig, validationConfig *ValidationConfig) Keeper { @@ -39,7 +39,7 @@ func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, vmConfig *VMConfig, vali panic(err) } - wasmValidator, err := NewWASMValidator(validationConfig, func() (*wasm.VM, error) { + wasmValidator, err := NewWasmValidator(validationConfig, func() (*wasm.VM, error) { return wasm.NewVM(vmConfig.DataDir, supportedFeatures, vmConfig.MemoryLimitMb, vmConfig.PrintDebug, vmConfig.CacheSizeMb) }) if err != nil { @@ -55,18 +55,18 @@ func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, vmConfig *VMConfig, vali } } -func (k Keeper) PushNewWASMCode(ctx sdk.Context, code []byte) ([]byte, error) { +func (k Keeper) PushNewWasmCode(ctx sdk.Context, code []byte) ([]byte, error) { store := ctx.KVStore(k.storeKey) - codeHash := generateWASMCodeHash(code) + codeHash := generateWasmCodeHash(code) codeIDKey := types.CodeID(codeHash) if store.Has(codeIDKey) { return nil, types.ErrWasmCodeExists } - if isValidWASMCode, err := k.wasmValidator.validateWASMCode(code); err != nil { + if isValidWasmCode, err := k.wasmValidator.validateWasmCode(code); err != nil { return nil, sdkerrors.Wrapf(types.ErrWasmCodeValidation, "unable to validate wasm code: %s", err) - } else if !isValidWASMCode { + } else if !isValidWasmCode { return nil, types.ErrWasmInvalidCode } @@ -85,7 +85,7 @@ func (k Keeper) PushNewWASMCode(ctx sdk.Context, code []byte) ([]byte, error) { return codeID, nil } -func generateWASMCodeHash(code []byte) []byte { +func generateWasmCodeHash(code []byte) []byte { hash := sha256.Sum256(code) return hash[:] } diff --git a/modules/core/28-wasm/keeper/validation.go b/modules/core/28-wasm/keeper/validation.go index 00715d924a8..9757ab29f8c 100644 --- a/modules/core/28-wasm/keeper/validation.go +++ b/modules/core/28-wasm/keeper/validation.go @@ -7,19 +7,19 @@ type ValidationConfig struct { MaxSizeAllowed int } -func NewWASMValidator(config *ValidationConfig, vmCreateFn func() (*cosmwasm.VM, error)) (*WASMValidator, error) { - return &WASMValidator{ +func NewWasmValidator(config *ValidationConfig, vmCreateFn func() (*cosmwasm.VM, error)) (*WasmValidator, error) { + return &WasmValidator{ config: config, vmCreateFn: vmCreateFn, }, nil } -type WASMValidator struct { +type WasmValidator struct { vmCreateFn func() (*cosmwasm.VM, error) config *ValidationConfig } -func (v *WASMValidator) validateWASMCode(code []byte) (bool, error) { +func (v *WasmValidator) validateWasmCode(code []byte) (bool, error) { if len(code) > v.config.MaxSizeAllowed { return false, nil } diff --git a/modules/core/28-wasm/types/codec.go b/modules/core/28-wasm/types/codec.go index 96402eb4ed0..96425d1a602 100644 --- a/modules/core/28-wasm/types/codec.go +++ b/modules/core/28-wasm/types/codec.go @@ -9,7 +9,7 @@ import ( func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), - &MsgPushNewWASMCode{}, + &MsgPushNewWasmCode{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/modules/core/28-wasm/types/msgs.go b/modules/core/28-wasm/types/msgs.go index 2905f5e90d1..718de71b483 100644 --- a/modules/core/28-wasm/types/msgs.go +++ b/modules/core/28-wasm/types/msgs.go @@ -6,17 +6,17 @@ import ( host "github.com/cosmos/ibc-go/modules/core/24-host" ) -var _ sdk.Msg = &MsgPushNewWASMCode{} +var _ sdk.Msg = &MsgPushNewWasmCode{} -func (m *MsgPushNewWASMCode) Route() string { +func (m *MsgPushNewWasmCode) Route() string { return host.RouterKey } -func (m *MsgPushNewWASMCode) Type() string { +func (m *MsgPushNewWasmCode) Type() string { return "wasm_push_new_code" } -func (m *MsgPushNewWASMCode) ValidateBasic() error { +func (m *MsgPushNewWasmCode) ValidateBasic() error { if len(m.Code) == 0 { return sdkerrors.Wrapf(ErrWasmEmptyCode, "empty wasm code", @@ -26,11 +26,11 @@ func (m *MsgPushNewWASMCode) ValidateBasic() error { return nil } -func (m *MsgPushNewWASMCode) GetSignBytes() []byte { +func (m *MsgPushNewWasmCode) GetSignBytes() []byte { panic("IBC messages do not support amino") } -func (m *MsgPushNewWASMCode) GetSigners() []sdk.AccAddress { +func (m *MsgPushNewWasmCode) GetSigners() []sdk.AccAddress { signer, err := sdk.AccAddressFromBech32(m.Signer) if err != nil { panic(err) diff --git a/modules/core/28-wasm/types/tx.pb.go b/modules/core/28-wasm/types/tx.pb.go index 572fcfe38b9..27754be921e 100644 --- a/modules/core/28-wasm/types/tx.pb.go +++ b/modules/core/28-wasm/types/tx.pb.go @@ -29,23 +29,23 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Message type to push new wasm code -type MsgPushNewWASMCode struct { +type MsgPushNewWasmCode struct { Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` Code []byte `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` } -func (m *MsgPushNewWASMCode) Reset() { *m = MsgPushNewWASMCode{} } -func (m *MsgPushNewWASMCode) String() string { return proto.CompactTextString(m) } -func (*MsgPushNewWASMCode) ProtoMessage() {} -func (*MsgPushNewWASMCode) Descriptor() ([]byte, []int) { +func (m *MsgPushNewWasmCode) Reset() { *m = MsgPushNewWasmCode{} } +func (m *MsgPushNewWasmCode) String() string { return proto.CompactTextString(m) } +func (*MsgPushNewWasmCode) ProtoMessage() {} +func (*MsgPushNewWasmCode) Descriptor() ([]byte, []int) { return fileDescriptor_e7804a9f49664df6, []int{0} } -func (m *MsgPushNewWASMCode) XXX_Unmarshal(b []byte) error { +func (m *MsgPushNewWasmCode) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgPushNewWASMCode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgPushNewWasmCode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgPushNewWASMCode.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgPushNewWasmCode.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,26 +55,26 @@ func (m *MsgPushNewWASMCode) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgPushNewWASMCode) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgPushNewWASMCode.Merge(m, src) +func (m *MsgPushNewWasmCode) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPushNewWasmCode.Merge(m, src) } -func (m *MsgPushNewWASMCode) XXX_Size() int { +func (m *MsgPushNewWasmCode) XXX_Size() int { return m.Size() } -func (m *MsgPushNewWASMCode) XXX_DiscardUnknown() { - xxx_messageInfo_MsgPushNewWASMCode.DiscardUnknown(m) +func (m *MsgPushNewWasmCode) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPushNewWasmCode.DiscardUnknown(m) } -var xxx_messageInfo_MsgPushNewWASMCode proto.InternalMessageInfo +var xxx_messageInfo_MsgPushNewWasmCode proto.InternalMessageInfo -func (m *MsgPushNewWASMCode) GetSigner() string { +func (m *MsgPushNewWasmCode) GetSigner() string { if m != nil { return m.Signer } return "" } -func (m *MsgPushNewWASMCode) GetCode() []byte { +func (m *MsgPushNewWasmCode) GetCode() []byte { if m != nil { return m.Code } @@ -82,22 +82,22 @@ func (m *MsgPushNewWASMCode) GetCode() []byte { } // Response in case of successful handling -type MsgPushNewWASMCodeResponse struct { +type MsgPushNewWasmCodeResponse struct { CodeId []byte `protobuf:"bytes,1,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` } -func (m *MsgPushNewWASMCodeResponse) Reset() { *m = MsgPushNewWASMCodeResponse{} } -func (m *MsgPushNewWASMCodeResponse) String() string { return proto.CompactTextString(m) } -func (*MsgPushNewWASMCodeResponse) ProtoMessage() {} -func (*MsgPushNewWASMCodeResponse) Descriptor() ([]byte, []int) { +func (m *MsgPushNewWasmCodeResponse) Reset() { *m = MsgPushNewWasmCodeResponse{} } +func (m *MsgPushNewWasmCodeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPushNewWasmCodeResponse) ProtoMessage() {} +func (*MsgPushNewWasmCodeResponse) Descriptor() ([]byte, []int) { return fileDescriptor_e7804a9f49664df6, []int{1} } -func (m *MsgPushNewWASMCodeResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgPushNewWasmCodeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgPushNewWASMCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgPushNewWasmCodeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgPushNewWASMCodeResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgPushNewWasmCodeResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -107,19 +107,19 @@ func (m *MsgPushNewWASMCodeResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgPushNewWASMCodeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgPushNewWASMCodeResponse.Merge(m, src) +func (m *MsgPushNewWasmCodeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPushNewWasmCodeResponse.Merge(m, src) } -func (m *MsgPushNewWASMCodeResponse) XXX_Size() int { +func (m *MsgPushNewWasmCodeResponse) XXX_Size() int { return m.Size() } -func (m *MsgPushNewWASMCodeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgPushNewWASMCodeResponse.DiscardUnknown(m) +func (m *MsgPushNewWasmCodeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPushNewWasmCodeResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgPushNewWASMCodeResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgPushNewWasmCodeResponse proto.InternalMessageInfo -func (m *MsgPushNewWASMCodeResponse) GetCodeId() []byte { +func (m *MsgPushNewWasmCodeResponse) GetCodeId() []byte { if m != nil { return m.CodeId } @@ -127,32 +127,32 @@ func (m *MsgPushNewWASMCodeResponse) GetCodeId() []byte { } func init() { - proto.RegisterType((*MsgPushNewWASMCode)(nil), "ibc.core.wasm.v1.MsgPushNewWASMCode") - proto.RegisterType((*MsgPushNewWASMCodeResponse)(nil), "ibc.core.wasm.v1.MsgPushNewWASMCodeResponse") + proto.RegisterType((*MsgPushNewWasmCode)(nil), "ibc.core.wasm.v1.MsgPushNewWasmCode") + proto.RegisterType((*MsgPushNewWasmCodeResponse)(nil), "ibc.core.wasm.v1.MsgPushNewWasmCodeResponse") } func init() { proto.RegisterFile("ibc/core/wasm/v1/tx.proto", fileDescriptor_e7804a9f49664df6) } var fileDescriptor_e7804a9f49664df6 = []byte{ - // 274 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x4c, 0x4a, 0xd6, - 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x4f, 0x2c, 0xce, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xc8, 0x4c, 0x4a, 0xd6, 0x03, 0x49, 0xe9, 0x81, 0xa4, - 0xf4, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, - 0x92, 0x03, 0x97, 0x90, 0x6f, 0x71, 0x7a, 0x40, 0x69, 0x71, 0x86, 0x5f, 0x6a, 0x79, 0xb8, 0x63, - 0xb0, 0xaf, 0x73, 0x7e, 0x4a, 0xaa, 0x90, 0x18, 0x17, 0x5b, 0x71, 0x66, 0x7a, 0x5e, 0x6a, 0x91, - 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x94, 0x27, 0x24, 0xc4, 0xc5, 0x92, 0x9c, 0x9f, 0x92, - 0x2a, 0xc1, 0xac, 0xc0, 0xa8, 0xc1, 0x13, 0x04, 0x66, 0x2b, 0x99, 0x72, 0x49, 0x61, 0x9a, 0x10, - 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x2a, 0x24, 0xce, 0xc5, 0x0e, 0x52, 0x15, 0x9f, 0x99, - 0x02, 0x36, 0x8a, 0x27, 0x88, 0x0d, 0xc4, 0xf5, 0x4c, 0x31, 0xca, 0xe1, 0x62, 0xf6, 0x2d, 0x4e, - 0x17, 0x4a, 0xe5, 0xe2, 0x47, 0xb7, 0x5c, 0x45, 0x0f, 0xdd, 0xed, 0x7a, 0x98, 0x16, 0x48, 0xe9, - 0x10, 0xa3, 0x0a, 0xe6, 0x0c, 0x27, 0xdf, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, - 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, - 0x88, 0x32, 0x4e, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, - 0xce, 0xcd, 0x2f, 0xd6, 0xcf, 0x4c, 0x4a, 0xd6, 0x4d, 0xcf, 0xd7, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, - 0x49, 0x2d, 0x86, 0x04, 0xb0, 0x91, 0x85, 0x2e, 0x38, 0x8c, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, - 0xd8, 0xc0, 0x81, 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x30, 0xf5, 0x11, 0xa9, 0x81, 0x01, - 0x00, 0x00, + // 273 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x50, 0x31, 0x4b, 0xc3, 0x40, + 0x18, 0xcd, 0x51, 0x89, 0x78, 0x14, 0x94, 0x43, 0xb4, 0x66, 0x38, 0x4a, 0x71, 0xe8, 0x60, 0xef, + 0x68, 0x8b, 0xe0, 0x28, 0x3a, 0x39, 0x44, 0x24, 0x8b, 0xe0, 0x22, 0xcd, 0xe5, 0xe3, 0x7a, 0xd0, + 0xf4, 0x0b, 0xf9, 0x92, 0x56, 0xff, 0x85, 0x3f, 0xcb, 0xb1, 0xa3, 0xa3, 0x24, 0x7f, 0x44, 0x92, + 0xea, 0xd2, 0x2e, 0x6e, 0xef, 0xf1, 0x1e, 0xef, 0x3d, 0x1e, 0xbf, 0x70, 0xb1, 0xd1, 0x06, 0x73, + 0xd0, 0xeb, 0x19, 0xa5, 0x7a, 0x35, 0xd6, 0xc5, 0x9b, 0xca, 0x72, 0x2c, 0x50, 0x9c, 0xb8, 0xd8, + 0xa8, 0x46, 0x52, 0x8d, 0xa4, 0x56, 0xe3, 0xe0, 0xd4, 0xa2, 0xc5, 0x56, 0xd4, 0x0d, 0xda, 0xfa, + 0x06, 0xb7, 0x5c, 0x84, 0x64, 0x9f, 0x4a, 0x9a, 0x3f, 0xc2, 0xfa, 0x79, 0x46, 0xe9, 0x3d, 0x26, + 0x20, 0xce, 0xb8, 0x4f, 0xce, 0x2e, 0x21, 0xef, 0xb1, 0x3e, 0x1b, 0x1e, 0x45, 0xbf, 0x4c, 0x08, + 0x7e, 0x60, 0x30, 0x81, 0x5e, 0xa7, 0xcf, 0x86, 0xdd, 0xa8, 0xc5, 0x83, 0x6b, 0x1e, 0xec, 0x27, + 0x44, 0x40, 0x19, 0x2e, 0x09, 0xc4, 0x39, 0x3f, 0x6c, 0x5c, 0xaf, 0x2e, 0x69, 0xa3, 0xba, 0x91, + 0xdf, 0xd0, 0x87, 0x64, 0xb2, 0xe0, 0x9d, 0x90, 0xac, 0x00, 0x7e, 0xbc, 0x5b, 0x7e, 0xa9, 0x76, + 0xb7, 0xab, 0xfd, 0x82, 0xe0, 0xea, 0x3f, 0xae, 0xbf, 0x19, 0x77, 0xe1, 0x67, 0x25, 0xd9, 0xa6, + 0x92, 0xec, 0xbb, 0x92, 0xec, 0xa3, 0x96, 0xde, 0xa6, 0x96, 0xde, 0x57, 0x2d, 0xbd, 0x97, 0xa9, + 0x75, 0xc5, 0xbc, 0x8c, 0x95, 0xc1, 0x54, 0x1b, 0xa4, 0x14, 0x49, 0xbb, 0xd8, 0x8c, 0x2c, 0xea, + 0x14, 0x93, 0x72, 0x01, 0xb4, 0x3d, 0x78, 0x72, 0x33, 0x6a, 0x3f, 0x2e, 0xde, 0x33, 0xa0, 0xd8, + 0x6f, 0xcf, 0x9b, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x38, 0xbc, 0x3b, 0x40, 0x81, 0x01, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -167,8 +167,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // PushNewWASMCode defines a rpc handler method for PushNewWASMCode. - PushNewWASMCode(ctx context.Context, in *MsgPushNewWASMCode, opts ...grpc.CallOption) (*MsgPushNewWASMCodeResponse, error) + // PushNewWasmCode defines a rpc handler method for PushNewWasmCode. + PushNewWasmCode(ctx context.Context, in *MsgPushNewWasmCode, opts ...grpc.CallOption) (*MsgPushNewWasmCodeResponse, error) } type msgClient struct { @@ -179,9 +179,9 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) PushNewWASMCode(ctx context.Context, in *MsgPushNewWASMCode, opts ...grpc.CallOption) (*MsgPushNewWASMCodeResponse, error) { - out := new(MsgPushNewWASMCodeResponse) - err := c.cc.Invoke(ctx, "/ibc.core.wasm.v1.Msg/PushNewWASMCode", in, out, opts...) +func (c *msgClient) PushNewWasmCode(ctx context.Context, in *MsgPushNewWasmCode, opts ...grpc.CallOption) (*MsgPushNewWasmCodeResponse, error) { + out := new(MsgPushNewWasmCodeResponse) + err := c.cc.Invoke(ctx, "/ibc.core.wasm.v1.Msg/PushNewWasmCode", in, out, opts...) if err != nil { return nil, err } @@ -190,36 +190,36 @@ func (c *msgClient) PushNewWASMCode(ctx context.Context, in *MsgPushNewWASMCode, // MsgServer is the server API for Msg service. type MsgServer interface { - // PushNewWASMCode defines a rpc handler method for PushNewWASMCode. - PushNewWASMCode(context.Context, *MsgPushNewWASMCode) (*MsgPushNewWASMCodeResponse, error) + // PushNewWasmCode defines a rpc handler method for PushNewWasmCode. + PushNewWasmCode(context.Context, *MsgPushNewWasmCode) (*MsgPushNewWasmCodeResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) PushNewWASMCode(ctx context.Context, req *MsgPushNewWASMCode) (*MsgPushNewWASMCodeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PushNewWASMCode not implemented") +func (*UnimplementedMsgServer) PushNewWasmCode(ctx context.Context, req *MsgPushNewWasmCode) (*MsgPushNewWasmCodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PushNewWasmCode not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_PushNewWASMCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgPushNewWASMCode) +func _Msg_PushNewWasmCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPushNewWasmCode) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).PushNewWASMCode(ctx, in) + return srv.(MsgServer).PushNewWasmCode(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.core.wasm.v1.Msg/PushNewWASMCode", + FullMethod: "/ibc.core.wasm.v1.Msg/PushNewWasmCode", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).PushNewWASMCode(ctx, req.(*MsgPushNewWASMCode)) + return srv.(MsgServer).PushNewWasmCode(ctx, req.(*MsgPushNewWasmCode)) } return interceptor(ctx, in, info, handler) } @@ -229,15 +229,15 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "PushNewWASMCode", - Handler: _Msg_PushNewWASMCode_Handler, + MethodName: "PushNewWasmCode", + Handler: _Msg_PushNewWasmCode_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/wasm/v1/tx.proto", } -func (m *MsgPushNewWASMCode) Marshal() (dAtA []byte, err error) { +func (m *MsgPushNewWasmCode) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -247,12 +247,12 @@ func (m *MsgPushNewWASMCode) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgPushNewWASMCode) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgPushNewWasmCode) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgPushNewWASMCode) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgPushNewWasmCode) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -274,7 +274,7 @@ func (m *MsgPushNewWASMCode) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgPushNewWASMCodeResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgPushNewWasmCodeResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -284,12 +284,12 @@ func (m *MsgPushNewWASMCodeResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgPushNewWASMCodeResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgPushNewWasmCodeResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgPushNewWASMCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgPushNewWasmCodeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -315,7 +315,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgPushNewWASMCode) Size() (n int) { +func (m *MsgPushNewWasmCode) Size() (n int) { if m == nil { return 0 } @@ -332,7 +332,7 @@ func (m *MsgPushNewWASMCode) Size() (n int) { return n } -func (m *MsgPushNewWASMCodeResponse) Size() (n int) { +func (m *MsgPushNewWasmCodeResponse) Size() (n int) { if m == nil { return 0 } @@ -351,7 +351,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgPushNewWASMCode) Unmarshal(dAtA []byte) error { +func (m *MsgPushNewWasmCode) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -374,10 +374,10 @@ func (m *MsgPushNewWASMCode) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgPushNewWASMCode: wiretype end group for non-group") + return fmt.Errorf("proto: MsgPushNewWasmCode: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgPushNewWASMCode: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgPushNewWasmCode: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -467,7 +467,7 @@ func (m *MsgPushNewWASMCode) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgPushNewWASMCodeResponse) Unmarshal(dAtA []byte) error { +func (m *MsgPushNewWasmCodeResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -490,10 +490,10 @@ func (m *MsgPushNewWASMCodeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgPushNewWASMCodeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgPushNewWasmCodeResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgPushNewWASMCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgPushNewWasmCodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 1e5a828fdab..f3c3960313c 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -23,10 +23,10 @@ var _ connectiontypes.MsgServer = Keeper{} var _ channeltypes.MsgServer = Keeper{} var _ wasmtypes.MsgServer = Keeper{} -// PushNewWASMCode defines a rpc handler method for MsgPushNewWASMCode -func (k Keeper) PushNewWASMCode(goCtx context.Context, msg *wasmtypes.MsgPushNewWASMCode) (*wasmtypes.MsgPushNewWASMCodeResponse, error) { +// PushNewWasmCode defines a rpc handler method for MsgPushNewWasmCode +func (k Keeper) PushNewWasmCode(goCtx context.Context, msg *wasmtypes.MsgPushNewWasmCode) (*wasmtypes.MsgPushNewWasmCodeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - response, err := wasm.HandleMsgPushNewWASMCode(ctx, k.WasmKeeper, msg) + response, err := wasm.HandleMsgPushNewWasmCode(ctx, k.WasmKeeper, msg) if err != nil { return nil, err } diff --git a/modules/light-clients/10-wasm/types/wasm.pb.go b/modules/light-clients/10-wasm/types/wasm.pb.go index d4f8c21765a..2d5e277035e 100644 --- a/modules/light-clients/10-wasm/types/wasm.pb.go +++ b/modules/light-clients/10-wasm/types/wasm.pb.go @@ -27,7 +27,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// WASM light client's Client state +// Wasm light client's Client state type ClientState struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` CodeId []byte `protobuf:"bytes,2,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` @@ -68,7 +68,7 @@ func (m *ClientState) XXX_DiscardUnknown() { var xxx_messageInfo_ClientState proto.InternalMessageInfo -// WASM light client's ConsensusState +// Wasm light client's ConsensusState type ConsensusState struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` CodeId []byte `protobuf:"bytes,2,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` @@ -112,7 +112,7 @@ func (m *ConsensusState) XXX_DiscardUnknown() { var xxx_messageInfo_ConsensusState proto.InternalMessageInfo -// WASM light client Header +// Wasm light client Header type Header struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Height *types.Height `protobuf:"bytes,2,opt,name=height,proto3" json:"height,omitempty"` @@ -151,7 +151,7 @@ func (m *Header) XXX_DiscardUnknown() { var xxx_messageInfo_Header proto.InternalMessageInfo -// WASM light client Misbehaviour +// Wasm light client Misbehaviour type Misbehaviour struct { ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` Header1 *Header `protobuf:"bytes,2,opt,name=header_1,json=header1,proto3" json:"header_1,omitempty" yaml:"header_1"` diff --git a/proto/ibc/core/wasm/v1/tx.proto b/proto/ibc/core/wasm/v1/tx.proto index 49b2da3d177..ea9d1b023a4 100644 --- a/proto/ibc/core/wasm/v1/tx.proto +++ b/proto/ibc/core/wasm/v1/tx.proto @@ -7,17 +7,17 @@ option go_package = "github.com/cosmos/ibc-go/modules/core/28-wasm/types"; // Msg defines the ibc/wasm Msg service. service Msg { - // PushNewWASMCode defines a rpc handler method for PushNewWASMCode. - rpc PushNewWASMCode(MsgPushNewWASMCode) returns (MsgPushNewWASMCodeResponse); + // PushNewWasmCode defines a rpc handler method for PushNewWasmCode. + rpc PushNewWasmCode(MsgPushNewWasmCode) returns (MsgPushNewWasmCodeResponse); } // Message type to push new wasm code -message MsgPushNewWASMCode { +message MsgPushNewWasmCode { string signer = 1; bytes code = 3; } // Response in case of successful handling -message MsgPushNewWASMCodeResponse { +message MsgPushNewWasmCodeResponse { bytes code_id = 1; } diff --git a/proto/ibc/lightclients/wasm/v1/wasm.proto b/proto/ibc/lightclients/wasm/v1/wasm.proto index c7f3676b154..031b4212205 100644 --- a/proto/ibc/lightclients/wasm/v1/wasm.proto +++ b/proto/ibc/lightclients/wasm/v1/wasm.proto @@ -9,7 +9,7 @@ import "confio/proofs.proto"; option go_package = "github.com/cosmos/ibc-go/modules/light-clients/10-wasm/types"; -// WASM light client's Client state +// Wasm light client's Client state message ClientState { option (gogoproto.goproto_getters) = false; bytes data = 1; @@ -18,7 +18,7 @@ message ClientState { repeated ics23.ProofSpec proof_specs = 4; } -// WASM light client's ConsensusState +// Wasm light client's ConsensusState message ConsensusState { option (gogoproto.goproto_getters) = false; bytes data = 1; @@ -31,7 +31,7 @@ message ConsensusState { ibc.core.commitment.v1.MerkleRoot root = 4; } -// WASM light client Header +// Wasm light client Header message Header { option (gogoproto.goproto_getters) = false; @@ -39,7 +39,7 @@ message Header { ibc.core.client.v1.Height height = 2; } -// WASM light client Misbehaviour +// Wasm light client Misbehaviour message Misbehaviour { option (gogoproto.goproto_getters) = false;