-
Notifications
You must be signed in to change notification settings - Fork 624
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
Changes from 2 commits
1169822
44c11cf
d2d5ee9
271ad1e
4f7866d
c5fb774
1468c65
8ad270b
b650122
ff490ed
e24d68c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,3 +1,65 @@ | ||||||
<!-- | ||||||
order: 2 | ||||||
--> | ||||||
--> | ||||||
|
||||||
# Implementing the ClientState interface | ||||||
|
||||||
Learn how to implement the [Client State](https://github.com/cosmos/ibc-go/blob/main/modules/core/exported/client.go#L36) interface. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
### ClientType | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
`ClientType` should return a unique string identifier of the light client. | ||||||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
### GetLatestHeight | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
`GetLatestHeight` should return the latest block height. | ||||||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
### Validate | ||||||
|
||||||
`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/main/modules/light-clients/07-tendermint/client_state.go#L111) | ||||||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
as a reference. | ||||||
|
||||||
### Status | ||||||
|
||||||
`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/main/modules/core/exported/client.go). | ||||||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be useful to explain what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bulleted list could be nice, giving a short description of each of the statuses. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked around at our usages of the statues, the only one the connection keeper cares about is Please let me know if my understanding is incorrect! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Frozen, Expired were previously required in the I think it is still useful to explain these concepts even if core IBC only cares if the status is Active as it'll be useful for UX purposes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
|
||||||
### ZeroCustomFields | ||||||
|
||||||
`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 to [verify upgrades](https://github.com/cosmos/ibc-go/blob/main/modules/core/02-client/types/proposal.go#L120) and when [scheduling upgrades](https://github.com/cosmos/ibc-go/blob/main/modules/core/02-client/keeper/proposal.go#L82). | ||||||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
### GetTimestampAtHeight | ||||||
|
||||||
`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
|
||||||
|
||||||
### Initialize | ||||||
|
||||||
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 | ||||||
|
||||||
`VerifyMembership` must verify the existence of a value at a given CommitmentPath at the specified height. | ||||||
The caller of this function is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized | ||||||
path (as defined in ICS 24). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this looks like wording from the spec (I guess it is the godoc string). Maybe we could explain what some of the arguments to this function mean or how they are obtained constructed? We can state that the path provided must be casted to a merkle path (maybe link to example code). We can also explain when this is used (to verify channel ends, packet commits, acknowledgements, etc) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, but I think we've added a page for Membership/Non-Membership proofs here: https://github.com/cosmos/ibc-go/blob/main/docs/.vuepress/config.js#L316 Maybe the specific information could go under that such as CommitmentPath and CommitmentPrefix, explaining what they mean wrt ics24..etc. And then we link to it from here and underneath in We could then be concise here and just briefly mention that these methods are used for verification of existence and absence proofs of counterparty state using the This is just a suggestion, interested to hear what others think regarding how this should be laid out, but as @colin-axner mentioned it will likely grow organically as we progress! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah good point @damiannolan, I think it makes sense to link to the proofs page and give the short version here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good to me! |
||||||
|
||||||
### VerifyNonMembership | ||||||
|
||||||
`VerifyNonMembership` must verify the absence of a given CommitmentPath at a specified height. | ||||||
The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24). | ||||||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
### VerifyClientMessage | ||||||
|
||||||
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 | ||||||
|
||||||
Checks for evidence of a misbehaviour in Header or Misbehaviour type. It assumes the ClientMessage | ||||||
has already been verified. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these be kept under the "Handling Updates" page? I'm wondering if this section should group cc. @colin-axner There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea I agree! The handling updates code also show the code usage which I think would help make each function more clear |
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.