-
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
Adding docs for client state interface #2886
Merged
chatton
merged 11 commits into
main
from
cian/issue#1851-light-client-guide-client-state-functions-
Dec 8, 2022
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1169822
docs: adding docs for client state
chatton 44c11cf
docs: updating client-state docs
chatton d2d5ee9
docs: updating based on PR feedback
chatton 271ad1e
docs: addressing PR feedback
chatton 4f7866d
Merge branch 'main' into cian/issue#1851-light-client-guide-client-st…
chatton c5fb774
docs: adding backtick to ClientState
chatton 1468c65
docs: addressing PR feedback
chatton 8ad270b
docs: fixing grammar in docs
chatton b650122
Merge branch 'main' into cian/issue#1851-light-client-guide-client-st…
chatton ff490ed
docs: addressing PR feedback
chatton e24d68c
Merge branch 'main' into cian/issue#1851-light-client-guide-client-st…
chatton 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,67 @@ | ||
<!-- | ||
order: 2 | ||
--> | ||
--> | ||
|
||
# Implementing the `ClientState` interface | ||
|
||
Learn how to implement the [`Client State`](https://github.com/cosmos/ibc-go/blob/v6.0.0-rc1/modules/core/exported/client.go#L40) interface. | ||
|
||
## `ClientType` method | ||
|
||
`ClientType` should return a unique string identifier of the light client. This will be used when generating a client identifier. | ||
The format is created as follows: `ClientTypes-{N}` where `{N}` is the unique global nonce associated with a specific client. | ||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## `GetLatestHeight` method | ||
|
||
`GetLatestHeight` should return the latest block height that the client state represents. . | ||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## `Validate` method | ||
|
||
`Validate` should validate every client state field and should return an error if any value is invalid. The light client | ||
implementor is in charge of determining which checks are required. See the [tendermint light client implementation](https://github.com/cosmos/ibc-go/blob/v6.0.0-rc1/modules/light-clients/07-tendermint/types/client_state.go#L101) | ||
as a reference. | ||
|
||
## `Status` method | ||
|
||
`Status` must return the status of the client. Only `Active` clients are allowed to process packets. All | ||
possible Status types can be found [here](https://github.com/cosmos/ibc-go/blob/v6.0.0-rc1/modules/core/exported/client.go#L26-L36). | ||
|
||
## `ZeroCustomFields` method | ||
|
||
`ZeroCustomFields` should return a copy of the light client with all client customizable fields with their zero value. It should not mutate the fields of the light client. | ||
This method is used when [scheduling upgrades](https://github.com/cosmos/ibc-go/blob/v6.0.0-rc1/modules/core/02-client/keeper/proposal.go#L89). Upgrades are used to upgrade chain specific fields such as chainID and the unbonding period. | ||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
For more information about client upgrades see [the developer guide](../upgrades/developer-guide.md). | ||
|
||
## `GetTimestampAtHeight` method | ||
|
||
`GetTimestampAtHeight` must return the timestamp for the consensus state associated with the provided height. | ||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This value is used to facilitate timeouts by checking that a timeout on a packet has passed or not. | ||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## `Initialize` method | ||
|
||
Clients must validate the initial consensus state, and may store any client-specific metadata necessary | ||
for correct light client operations in the `Initialize` function. | ||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`Initialize` gets called when a [client is created](https://github.com/cosmos/ibc-go/blob/main/modules/core/02-client/keeper/client.go#L32). | ||
|
||
## `VerifyMembership` method | ||
|
||
`VerifyMembership` must verify the existence of a value at a given CommitmentPath at the specified height. For more information about membership proofs | ||
see [the proof docs](./proofs.md). | ||
|
||
## `VerifyNonMembership` method | ||
|
||
`VerifyNonMembership` must verify the absence of a value at a given CommitmentPath at a specified height. For more information about non membership proofs | ||
see [the proof docs](./proofs.md). | ||
|
||
## `VerifyClientMessage` method | ||
|
||
VerifyClientMessage must verify a ClientMessage. A ClientMessage could be a Header, Misbehaviour, or batch update. | ||
It must handle each type of ClientMessage appropriately. Calls to CheckForMisbehaviour, UpdateState, and UpdateStateOnMisbehaviour | ||
will assume that the content of the ClientMessage has been verified and can be trusted. An error should be returned | ||
if the ClientMessage fails to verify. | ||
|
||
## `CheckForMisbehaviour` method | ||
|
||
Checks for evidence of a misbehaviour in Header or Misbehaviour type. It assumes the ClientMessage | ||
has already been verified. |
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.
I know we usually want to link to a specific tag but linking to v6 seems weird to me because its the old interface. I guess we can update all links when there is a v7 tag available.
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.
Yeah I think we can update this in the next release.