-
Notifications
You must be signed in to change notification settings - Fork 586
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
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 b080ff9
adding godoc and temp comment
damiannolan ccfb9fb
dumping 09-localhost client state boilerplate
damiannolan 3416304
adding codec and app module basic
damiannolan 6b85352
rearrange code in client_state.go
damiannolan 8f13c75
adding conditional checks for localhost client
damiannolan a679368
adding localhost connection id const
damiannolan f5d0abd
updating client state for localhost
damiannolan 2dee015
adding abci call to update localhost client state
damiannolan 6c33d2e
add basic update method, update godocs
damiannolan da61d3a
Merge branch 'main' into 09-localhost
damiannolan 42cb750
Add sentinel localhost connection end to genesis state (#3040)
chatton bf26904
adding getClientStateAndKVStore to 03-connection verify.go to retriev…
damiannolan d1b0825
chore: adding 09-localhost to client InitGenesis (#3092)
damiannolan 72fcd65
adding initial localhost client testing (#3085)
damiannolan 3715153
Remove ProofHeight and Proof Validation in msg.ValidateBasic (#3061)
charleenfei badc331
updating errors returns in 09-localhost (#3105)
damiannolan 0e72157
remove chain id from localhost client (#3103)
damiannolan fdd332e
Merge branch 'main' into 09-localhost
damiannolan 40ca344
return error in 09-localhost VerifyClientMessage (#3115)
damiannolan c7d798b
disallow localhost client creation in 02-client (#3114)
damiannolan 9681f65
Merge branch 'main' into 09-localhost
damiannolan 4557d2d
Merge branch 'main' into 09-localhost
damiannolan 8e11eb1
Merge branch 'main' into 09-localhost
damiannolan 63111de
adding e2e tests for 09-localhost (#3119)
damiannolan 2edfbd2
e2e localhost test create new channel for existing ica account (#3146)
damiannolan d4e24d1
revert: unnecessary code change for localhost (#3170)
colin-axner 7568559
revert: unnecessary changes in connection handshake for localhost (#3…
colin-axner fe24586
adding localhost client ID checks to init and try validate basic (#3169)
damiannolan 69e1a51
Bumping localhost light client proto to v2 (#3168)
chatton 9352d83
fix typo
crodriguezvega 49f7065
Merge branch 'main' into 09-localhost
damiannolan c68f48b
Merge branch 'main' into 09-localhost
damiannolan 34a99fe
adding e2e upgrade test for v7.1 localhost (#3164)
damiannolan d7d43b3
localhost godocs and nits (#3199)
damiannolan 5d9639e
use sentinel proofs for localhost channels (#3195)
damiannolan 3bd6eab
chore: update AllowedClients godoc (#3200)
colin-axner 9fb39d3
chore: use single attribute for connection id in channel events (#3203)
colin-axner 5a955e0
fix: make proto-all (#3211)
colin-axner da5061f
chore: move localhost client and connection IDs to the exported packa…
colin-axner 610d812
chore: rename function (#3202)
colin-axner e50870d
update localhost upgrade handler to explicitly set allowed clients pa…
damiannolan b6cd296
correcting error - use client type, not client id in upgrade handler
damiannolan 53eea55
moving set connection to create localhost sentinel connection (#3209)
damiannolan c6beda3
Allow disabling of client type via allowed_clients param (#3196)
chatton dc9a7a7
Sync localhost branch with main (#3215)
chatton 5a9e184
removing unnecessary defensive checks in 07-tendermint (#3218)
damiannolan 868d0e4
register localhost types in ibc core, remove AppModuleBasic (#3220)
damiannolan 7303ce3
adding site docs for 09-localhost client (#3147)
damiannolan b1c4f4d
sync localhost with main to prep feat branch for PR (#3228)
damiannolan 46e1a42
Merge branch 'main' into 09-localhost
damiannolan 0ec6aad
chore: client state key nit (#3226)
crodriguezvega 5145187
indentation
crodriguezvega 9a41fe1
indentation
crodriguezvega 1e131c7
add 09-locahost to default list
5c0fc8b
update events.md
4bad6d2
Merge branch 'main' into 09-localhost
chatton 78cdc69
adding migration doc for v7.1 localhost client (#3210)
damiannolan 38f7d99
ran go mod tidy
chatton 12bd5b8
changed tendermint to cometbft
chatton b67680f
chore: add in-code comment
colin-axner 3290689
Merge branch 'main' into 09-localhost
colin-axner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
) | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3261