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
217 changes: 217 additions & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@
- [ibc/core/types/v1/genesis.proto](#ibc/core/types/v1/genesis.proto)
- [GenesisState](#ibc.core.types.v1.GenesisState)

- [ibc/core/wasm/v1/query.proto](#ibc/core/wasm/v1/query.proto)
- [WasmCodeQuery](#ibc.core.wasm.v1.WasmCodeQuery)
- [WasmCodeResponse](#ibc.core.wasm.v1.WasmCodeResponse)

- [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 +234,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 +583,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 +2908,119 @@ GenesisState defines the ibc module's genesis state.



<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.WasmCodeQuery"></a>

### WasmCodeQuery
WasmCode query


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






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

### WasmCodeResponse
WasmCode 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 |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `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}|

<!-- 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) | | |
| `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) | | |





<!-- 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 +3485,91 @@ 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) | | |
| `latest_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | |
| `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) |






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






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

### Misbehaviour
Wasm light client Misbehaviour


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `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