Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm based light clients #208

Closed
wants to merge 11 commits into from
296 changes: 296 additions & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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 |



Expand Down Expand Up @@ -2889,6 +2913,187 @@ GenesisState defines the ibc module's genesis state.



<a name="ibc/core/wasm/v1/wasm.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/core/wasm/v1/wasm.proto



<a name="ibc.core.wasm.v1.WasmCodeEntry"></a>

### 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) | | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="ibc/core/wasm/v1/query.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/core/wasm/v1/query.proto



<a name="ibc.core.wasm.v1.LatestWASMCodeEntryQuery"></a>

### LatestWASMCodeEntryQuery
Latest wasm code entry query


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_type` | [string](#string) | | |






<a name="ibc.core.wasm.v1.LatestWASMCodeEntryResponse"></a>

### LatestWASMCodeEntryResponse
Latest wasm code entry response


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `code_id` | [string](#string) | | |
| `entry` | [WasmCodeEntry](#ibc.core.wasm.v1.WasmCodeEntry) | | |






<a name="ibc.core.wasm.v1.LatestWASMCodeQuery"></a>

### LatestWASMCodeQuery
Latest wasm code query


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `client_type` | [string](#string) | | |






<a name="ibc.core.wasm.v1.LatestWASMCodeResponse"></a>

### LatestWASMCodeResponse
Latest wasm code response


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `code` | [bytes](#bytes) | | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="ibc.core.wasm.v1.Query"></a>

### 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}|

<!-- end services -->



<a name="ibc/core/wasm/v1/tx.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/core/wasm/v1/tx.proto



<a name="ibc.core.wasm.v1.MsgPushNewWASMCode"></a>

### MsgPushNewWASMCode
Message type to push new wasm code


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `signer` | [string](#string) | | |
| `client_type` | [string](#string) | | |
| `code` | [bytes](#bytes) | | |






<a name="ibc.core.wasm.v1.MsgPushNewWASMCodeResponse"></a>

### MsgPushNewWASMCodeResponse
Response in case of successful handling


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `code_id` | [bytes](#bytes) | | |
| `code_hash` | [string](#string) | | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="ibc.core.wasm.v1.Msg"></a>

### 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. | |

<!-- end services -->



<a name="ibc/lightclients/localhost/v1/localhost.proto"></a>
<p align="right"><a href="#top">Top</a></p>

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



<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="ibc/lightclients/wasm/v1/wasm.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/lightclients/wasm/v1/wasm.proto



<a name="ibc.lightclients.wasm.v1.ClientState"></a>

### 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 | |






<a name="ibc.lightclients.wasm.v1.ConsensusState"></a>

### 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) | | |






<a name="ibc.lightclients.wasm.v1.Header"></a>

### 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) | | |






<a name="ibc.lightclients.wasm.v1.Misbehaviour"></a>

### 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) | | |





<!-- end messages -->

<!-- end enums -->
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions modules/core/02-client/keeper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading