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

feat: adding 09-localhost loopback client module #3229

Merged
merged 62 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b996c6c
add EnableLocalhost to 03-connection
damiannolan Jan 18, 2023
b080ff9
adding godoc and temp comment
damiannolan Jan 18, 2023
ccfb9fb
dumping 09-localhost client state boilerplate
damiannolan Jan 18, 2023
3416304
adding codec and app module basic
damiannolan Jan 18, 2023
6b85352
rearrange code in client_state.go
damiannolan Jan 18, 2023
8f13c75
adding conditional checks for localhost client
damiannolan Jan 23, 2023
a679368
adding localhost connection id const
damiannolan Jan 23, 2023
f5d0abd
updating client state for localhost
damiannolan Jan 23, 2023
2dee015
adding abci call to update localhost client state
damiannolan Jan 24, 2023
6c33d2e
add basic update method, update godocs
damiannolan Jan 24, 2023
da61d3a
Merge branch 'main' into 09-localhost
damiannolan Jan 25, 2023
42cb750
Add sentinel localhost connection end to genesis state (#3040)
chatton Jan 30, 2023
bf26904
adding getClientStateAndKVStore to 03-connection verify.go to retriev…
damiannolan Jan 31, 2023
d1b0825
chore: adding 09-localhost to client InitGenesis (#3092)
damiannolan Jan 31, 2023
72fcd65
adding initial localhost client testing (#3085)
damiannolan Feb 2, 2023
3715153
Remove ProofHeight and Proof Validation in msg.ValidateBasic (#3061)
charleenfei Feb 2, 2023
badc331
updating errors returns in 09-localhost (#3105)
damiannolan Feb 6, 2023
0e72157
remove chain id from localhost client (#3103)
damiannolan Feb 6, 2023
fdd332e
Merge branch 'main' into 09-localhost
damiannolan Feb 6, 2023
40ca344
return error in 09-localhost VerifyClientMessage (#3115)
damiannolan Feb 7, 2023
c7d798b
disallow localhost client creation in 02-client (#3114)
damiannolan Feb 8, 2023
9681f65
Merge branch 'main' into 09-localhost
damiannolan Feb 8, 2023
4557d2d
Merge branch 'main' into 09-localhost
damiannolan Feb 8, 2023
8e11eb1
Merge branch 'main' into 09-localhost
damiannolan Feb 14, 2023
63111de
adding e2e tests for 09-localhost (#3119)
damiannolan Feb 15, 2023
2edfbd2
e2e localhost test create new channel for existing ica account (#3146)
damiannolan Feb 16, 2023
d4e24d1
revert: unnecessary code change for localhost (#3170)
colin-axner Feb 20, 2023
7568559
revert: unnecessary changes in connection handshake for localhost (#3…
colin-axner Feb 20, 2023
fe24586
adding localhost client ID checks to init and try validate basic (#3169)
damiannolan Feb 20, 2023
69e1a51
Bumping localhost light client proto to v2 (#3168)
chatton Feb 20, 2023
9352d83
fix typo
crodriguezvega Feb 20, 2023
49f7065
Merge branch 'main' into 09-localhost
damiannolan Feb 20, 2023
c68f48b
Merge branch 'main' into 09-localhost
damiannolan Feb 21, 2023
34a99fe
adding e2e upgrade test for v7.1 localhost (#3164)
damiannolan Feb 21, 2023
d7d43b3
localhost godocs and nits (#3199)
damiannolan Feb 24, 2023
5d9639e
use sentinel proofs for localhost channels (#3195)
damiannolan Feb 24, 2023
3bd6eab
chore: update AllowedClients godoc (#3200)
colin-axner Feb 27, 2023
9fb39d3
chore: use single attribute for connection id in channel events (#3203)
colin-axner Feb 27, 2023
5a955e0
fix: make proto-all (#3211)
colin-axner Feb 27, 2023
da5061f
chore: move localhost client and connection IDs to the exported packa…
colin-axner Feb 27, 2023
610d812
chore: rename function (#3202)
colin-axner Feb 27, 2023
e50870d
update localhost upgrade handler to explicitly set allowed clients pa…
damiannolan Feb 27, 2023
b6cd296
correcting error - use client type, not client id in upgrade handler
damiannolan Feb 27, 2023
53eea55
moving set connection to create localhost sentinel connection (#3209)
damiannolan Feb 27, 2023
c6beda3
Allow disabling of client type via allowed_clients param (#3196)
chatton Feb 28, 2023
dc9a7a7
Sync localhost branch with main (#3215)
chatton Feb 28, 2023
5a9e184
removing unnecessary defensive checks in 07-tendermint (#3218)
damiannolan Mar 1, 2023
868d0e4
register localhost types in ibc core, remove AppModuleBasic (#3220)
damiannolan Mar 1, 2023
7303ce3
adding site docs for 09-localhost client (#3147)
damiannolan Mar 1, 2023
b1c4f4d
sync localhost with main to prep feat branch for PR (#3228)
damiannolan Mar 2, 2023
46e1a42
Merge branch 'main' into 09-localhost
damiannolan Mar 2, 2023
0ec6aad
chore: client state key nit (#3226)
crodriguezvega Mar 2, 2023
5145187
indentation
crodriguezvega Mar 6, 2023
9a41fe1
indentation
crodriguezvega Mar 6, 2023
1e131c7
add 09-locahost to default list
Mar 6, 2023
5c0fc8b
update events.md
Mar 6, 2023
4bad6d2
Merge branch 'main' into 09-localhost
chatton Mar 7, 2023
78cdc69
adding migration doc for v7.1 localhost client (#3210)
damiannolan Mar 7, 2023
38f7d99
ran go mod tidy
chatton Mar 7, 2023
12bd5b8
changed tendermint to cometbft
chatton Mar 7, 2023
b67680f
chore: add in-code comment
colin-axner Mar 8, 2023
3290689
Merge branch 'main' into 09-localhost
colin-axner Mar 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/e2e-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@ jobs:
upgrade-plan-name: "v7"
test-entry-point: "TestUpgradeTestSuite"
test: "TestV6ToV7ChainUpgrade"

upgrade-v7_1:
uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
chain-a-tag: pr-3136 # TODO: needs v7.0.0 (with simapp fixes) when cut
chain-b-tag: pr-3136 # TODO: needs v7.0.0 (with simapp fixes) when cut
Comment on lines +50 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an issue for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chain-upgrade-tag: pr-3164 # TODO: needs v7.1.0 when cut
upgrade-plan-name: "v7.1"
test-entry-point: "TestUpgradeTestSuite"
test: "TestV7ChainUpgradeAddLocalhost"
42 changes: 42 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ module.exports = {
directory: false,
path: "/roadmap/roadmap.html",
},
{
title: "Troubleshooting",
directory: false,
path: "/ibc/troubleshooting.html",
},
],
},
{
Expand Down Expand Up @@ -393,6 +398,38 @@ module.exports = {
},
]
},
{
title: "Localhost",
directory: true,
path: "/ibc/light-clients/localhost",
children: [
{
title: "Overview",
directory: false,
path: "/ibc/light-clients/localhost/overview.html",
},
{
title: "Integration",
directory: false,
path: "/ibc/light-clients/localhost/integration.html",
},
{
title: "ClientState",
directory: false,
path: "/ibc/light-clients/localhost/client-state.html",
},
{
title: "Connection",
directory: false,
path: "/ibc/light-clients/localhost/connection.html",
},
{
title: "State Verification",
directory: false,
path: "/ibc/light-clients/localhost/state-verification.html",
},
],
},
{
title: "Solomachine",
directory: true,
Expand Down Expand Up @@ -508,6 +545,11 @@ module.exports = {
directory: false,
path: "/migrations/v6-to-v7.html",
},
{
title: "IBC-Go v7 to v7.1",
directory: false,
path: "/migrations/v7-to-v7_1.html",
},
],
},
{
Expand Down
129 changes: 78 additions & 51 deletions docs/ibc/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,63 +185,90 @@ callbacks to IBC applications.

### SendPacket (application module call)

| Type | Attribute Key | Attribute Value |
|-------------|--------------------------|----------------------------------|
| send_packet | packet_data | {data} |
| send_packet | packet_timeout_height | {timeoutHeight} |
| send_packet | packet_timeout_timestamp | {timeoutTimestamp} |
| send_packet | packet_sequence | {sequence} |
| send_packet | packet_src_port | {sourcePort} |
| send_packet | packet_src_channel | {sourceChannel} |
| send_packet | packet_dst_port | {destinationPort} |
| send_packet | packet_dst_channel | {destinationChannel} |
| send_packet | packet_channel_ordering | {channel.Ordering} |
| message | action | application-module-defined-field |
| message | module | ibc-channel |
| Type | Attribute Key | Attribute Value | Status |
|-------------|--------------------------|----------------------------------|------------|
| send_packet | packet_data | {data} | Deprecated |
| send_packet | packet_data_hex | {hex.Encode(data)} | |
| send_packet | packet_timeout_height | {timeoutHeight} | |
| send_packet | packet_timeout_timestamp | {timeoutTimestamp} | |
| send_packet | packet_sequence | {sequence} | |
| send_packet | packet_src_port | {sourcePort} | |
| send_packet | packet_src_channel | {sourceChannel} | |
| send_packet | packet_dst_port | {destinationPort} | |
| send_packet | packet_dst_channel | {destinationChannel} | |
| send_packet | packet_channel_ordering | {channel.Ordering} | |
| send_packet | packet_connection | {channel.ConnectionHops[0]} | Deprecated |
| send_packet | connection_id | {channel.ConnectionHops[0]} | |
| message | action | application-module-defined-field | |
| message | module | ibc-channel | |

### MsgRecvPacket

| Type | Attribute Key | Attribute Value |
|-------------|--------------------------|----------------------|
| recv_packet | packet_data | {data} |
| recv_packet | packet_ack | {acknowledgement} |
| recv_packet | packet_timeout_height | {timeoutHeight} |
| recv_packet | packet_timeout_timestamp | {timeoutTimestamp} |
| recv_packet | packet_sequence | {sequence} |
| recv_packet | packet_src_port | {sourcePort} |
| recv_packet | packet_src_channel | {sourceChannel} |
| recv_packet | packet_dst_port | {destinationPort} |
| recv_packet | packet_dst_channel | {destinationChannel} |
| recv_packet | packet_channel_ordering | {channel.Ordering} |
| message | action | recv_packet |
| message | module | ibc-channel |
| Type | Attribute Key | Attribute Value | Status |
|-------------|--------------------------|-------------------------------|------------|
| recv_packet | packet_data | {data} | Deprecated |
| recv_packet | packet_data_hex | {hex.Encode(data)} | |
| recv_packet | packet_timeout_height | {timeoutHeight} | |
| recv_packet | packet_timeout_timestamp | {timeoutTimestamp} | |
| recv_packet | packet_sequence | {sequence} | |
| recv_packet | packet_src_port | {sourcePort} | |
| recv_packet | packet_src_channel | {sourceChannel} | |
| recv_packet | packet_dst_port | {destinationPort} | |
| recv_packet | packet_dst_channel | {destinationChannel} | |
| recv_packet | packet_channel_ordering | {channel.Ordering} | |
| recv_packet | packet_connection | {channel.ConnectionHops[0]} | Deprecated |
| recv_packet | connection_id | {channel.ConnectionHops[0]} | |
| message | action | recv_packet | |
| message | module | ibc-channel | |

| Type | Attribute Key | Attribute Value | Status |
|-----------------------|--------------------------|-------------------------------|------------|
| write_acknowledgement | packet_data | {data} | Deprecated |
| write_acknowledgement | packet_data_hex | {hex.Encode(data)} | |
| write_acknowledgement | packet_timeout_height | {timeoutHeight} | |
| write_acknowledgement | packet_timeout_timestamp | {timeoutTimestamp} | |
| write_acknowledgement | packet_sequence | {sequence} | |
| write_acknowledgement | packet_src_port | {sourcePort} | |
| write_acknowledgement | packet_src_channel | {sourceChannel} | |
| write_acknowledgement | packet_dst_port | {destinationPort} | |
| write_acknowledgement | packet_dst_channel | {destinationChannel} | |
| write_acknowledgement | packet_ack | {ack} | Deprecated |
| write_acknowledgement | packet_ack_hex | {hex.Encode(ack)} | |
| write_acknowledgement | packet_channel_ordering | {channel.Ordering} | |
| write_acknowledgement | packet_connection | {channel.ConnectionHops[0]} | Deprecated |
| write_acknowledgement | connection_id | {channel.ConnectionHops[0]} | |
| message | action | write_acknowledgement | |
| message | module | ibc-channel | |

### MsgAcknowledgePacket

| Type | Attribute Key | Attribute Value |
|--------------------|--------------------------|----------------------|
| acknowledge_packet | packet_timeout_height | {timeoutHeight} |
| acknowledge_packet | packet_timeout_timestamp | {timeoutTimestamp} |
| acknowledge_packet | packet_sequence | {sequence} |
| acknowledge_packet | packet_src_port | {sourcePort} |
| acknowledge_packet | packet_src_channel | {sourceChannel} |
| acknowledge_packet | packet_dst_port | {destinationPort} |
| acknowledge_packet | packet_dst_channel | {destinationChannel} |
| acknowledge_packet | packet_channel_ordering | {channel.Ordering} |
| message | action | acknowledge_packet |
| message | module | ibc-channel |
| Type | Attribute Key | Attribute Value | Status |
|--------------------|--------------------------|-------------------------------|------------|
| acknowledge_packet | packet_timeout_height | {timeoutHeight} | |
| acknowledge_packet | packet_timeout_timestamp | {timeoutTimestamp} | |
| acknowledge_packet | packet_sequence | {sequence} | |
| acknowledge_packet | packet_src_port | {sourcePort} | |
| acknowledge_packet | packet_src_channel | {sourceChannel} | |
| acknowledge_packet | packet_dst_port | {destinationPort} | |
| acknowledge_packet | packet_dst_channel | {destinationChannel} | |
| acknowledge_packet | packet_channel_ordering | {channel.Ordering} | |
| acknowledge_packet | packet_connection | {channel.ConnectionHops[0]} | Deprecated |
| acknowledge_packet | connection_id | {channel.ConnectionHops[0]} | |
| message | action | acknowledge_packet | |
| message | module | ibc-channel | |

### MsgTimeoutPacket & MsgTimeoutOnClose

| Type | Attribute Key | Attribute Value |
|----------------|--------------------------|----------------------|
| timeout_packet | packet_timeout_height | {timeoutHeight} |
| timeout_packet | packet_timeout_timestamp | {timeoutTimestamp} |
| timeout_packet | packet_sequence | {sequence} |
| timeout_packet | packet_src_port | {sourcePort} |
| timeout_packet | packet_src_channel | {sourceChannel} |
| timeout_packet | packet_dst_port | {destinationPort} |
| timeout_packet | packet_dst_channel | {destinationChannel} |
| timeout_packet | packet_channel_ordering | {channel.Ordering} |
| message | action | timeout_packet |
| message | module | ibc-channel |
| Type | Attribute Key | Attribute Value |
|----------------|--------------------------|-------------------------------|
| timeout_packet | packet_timeout_height | {timeoutHeight} |
| timeout_packet | packet_timeout_timestamp | {timeoutTimestamp} |
| timeout_packet | packet_sequence | {sequence} |
| timeout_packet | packet_src_port | {sourcePort} |
| timeout_packet | packet_src_channel | {sourceChannel} |
| timeout_packet | packet_dst_port | {destinationPort} |
| timeout_packet | packet_dst_channel | {destinationChannel} |
| timeout_packet | packet_channel_ordering | {channel.Ordering} |
| timeout_packet | connection_id | {channel.ConnectionHops[0]} |
| message | action | timeout_packet |
| message | module | ibc-channel |
60 changes: 60 additions & 0 deletions docs/ibc/light-clients/localhost/client-state.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!--
order: 3
-->

# `ClientState`

The 09-localhost `ClientState` maintains a single field used to track the latest sequence of the state machine i.e. the height of the blockchain.

```go
type ClientState struct {
// the latest height of the blockchain
LatestHeight clienttypes.Height
}
```

The 09-localhost `ClientState` is instantiated in the `InitGenesis` handler of the 02-client submodule in core IBC.
It calls `CreateLocalhostClient`, declaring a new `ClientState` and initializing it with its own client prefixed store.

```go
func (k Keeper) CreateLocalhostClient(ctx sdk.Context) error {
var clientState localhost.ClientState
return clientState.Initialize(ctx, k.cdc, k.ClientStore(ctx, exported.LocalhostClientID), nil)
}
```

It is possible to disable the localhost client by removing the `09-localhost` entry from the `allowed_clients` list through governance.

## Client updates

The latest height is updated periodically through the ABCI [`BeginBlock`](https://docs.cosmos.network/v0.47/building-modules/beginblock-endblock) interface of the 02-client submodule in core IBC.

[See `BeginBlocker` in abci.go.](https://github.com/cosmos/ibc-go/blob/09-localhost/modules/core/02-client/abci.go#L12)

```go
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
// ...

if clientState, found := k.GetClientState(ctx, exported.Localhost); found {
if k.GetClientStatus(ctx, clientState, exported.Localhost) == exported.Active {
k.UpdateLocalhostClient(ctx, clientState)
}
}
}
```

The above calls into the the 09-localhost `UpdateState` method of the `ClientState` .
It retrieves the current block height from the application context and sets the `LatestHeight` of the 09-localhost client.

```go
func (cs ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, clientMsg exported.ClientMessage) []exported.Height {
height := clienttypes.GetSelfHeight(ctx)
cs.LatestHeight = height

clientStore.Set(host.ClientStateKey(), clienttypes.MustMarshalClientState(cdc, &cs))

return []exported.Height{height}
}
```

Note that the 09-localhost `ClientState` is not updated through the 02-client interface leveraged by conventional IBC light clients.
25 changes: 25 additions & 0 deletions docs/ibc/light-clients/localhost/connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
order: 4
-->

# Localhost connections

The 09-localhost light client module integrates with core IBC through a single sentinel localhost connection.
The sentinel `ConnectionEnd` is stored by default in the core IBC store.

This enables channel handshakes to be initiated out of the box by supplying the localhost connection identifier (`connection-localhost`) in the `connectionHops` parameter of `MsgChannelOpenInit`.

The `ConnectionEnd` is created and set in store via the `InitGenesis` handler of the 03-connection submodule in core IBC.
The `ConnectionEnd` and its `Counterparty` both reference the `09-localhost` client identifier, and share the localhost connection identifier `connection-localhost`.

```go
// CreateSentinelLocalhostConnection creates and sets the sentinel localhost connection end in the IBC store.
func (k Keeper) CreateSentinelLocalhostConnection(ctx sdk.Context) {
counterparty := types.NewCounterparty(exported.LocalhostClientID, exported.LocalhostConnectionID, commitmenttypes.NewMerklePrefix(k.GetCommitmentPrefix().Bytes()))
connectionEnd := types.NewConnectionEnd(types.OPEN, exported.LocalhostClientID, counterparty, types.ExportedVersionsToProto(types.GetCompatibleVersions()), 0)

k.SetConnection(ctx, exported.LocalhostConnectionID, connectionEnd)
}
```

Note that connection handshakes are disallowed when using the `09-localhost` client type.
16 changes: 16 additions & 0 deletions docs/ibc/light-clients/localhost/integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
order: 2
-->

# Integration

The 09-localhost light client module registers codec types within the core IBC module. This differs from other light client module implementations which are expected to register codec types using the `AppModuleBasic` interface.

The localhost client is added to the 02-client submodule param [`allowed_clients`](https://github.com/cosmos/ibc-go/blob/v7.0.0-rc0/proto/ibc/core/client/v1/client.proto#L102) by default in ibc-go.

```go
var (
// DefaultAllowedClients are the default clients for the AllowedClients parameter.
DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint, exported.Localhost}
)
```
Loading