harry
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # IBC Light Clients IBC functions by utilising light clients to determine the state of a counterparty chain. By using the connections, channels and ports built on top of a specific pair of light client the IBC host is able to send packets to a counterparty chain and have the counterparty chain validate the inclusion of these packets in the sending chains state. For **chain A** to be able to communicate with **chain B** both chains must run a light client of the other on their own network. This means the node running an IBC host on **chain A** must have a light client of **chain B** initialised (and vice versa) for cross chain communication to be possible. This is because all IBC related information is stored in the network state. Thus any packets being sent will be included in the state hash of the sending chain. When the relayer sends this packet to its destination chain they can verify its inclusion in the sending chains state by verifying it with the light client. In order for these light clients to work with IBC two different ICS components must be implemented in the Pocket V1 IBC module: ICS-02 (Client Semantics) and ICS-08 (WASM Client). The choice of implementing a WASM client is detailed below, but in summary utilising WASM clients simplifies the challenge of dealing with different consensus types. In essence all one must do is integrate a WASM virtual machine that allows for the interaction with a WASM binary and then send it properly formatted inputs to receive the requested outputs. This allows for easy "plug and play" with light clients and allows for easier upgradability. _Note_: Light clients in IBC are a simplified sparse representation of the chain they represent's state. They are not a "fully featured" light client, but instead are simply state verification algorithms implemented for a specific consensus type (typically per chain). ## ICS-02 - The Interface ICS-02 defines the interface, its functions and types, different light client implementations must follow in order to verify the state of the network they represent. The following functions must be exposed to relayers in order to interact with the light clients and manage them through the IBC hosts: ```go func CreateClient(clientState ClientState, consensusState ConsensusState, ) (string, error) // (clientID, error) func UpdateClient(clientID string, clientMsg ClientMessage) error func UpgradeClient(clientID string, upgradeClient ClientState, upgradeConsensusState ConsensusState, proofUpgradeClient, proofUpgradeConsensus []byte, ) error func SubmitMisbehaviourToClient(clientID string, clientMsg ClientMessage) error ``` These functions then require the following functions to be defined in the client upon their calling: ```go func (c *Client) Initialise(clientState ClientState, consensusState ConsensusState, ) error func (c *Client) VerifyClientMessage(clientMsg ClientMessage) error func (c *Client) Update(clientMsg ClientMessage) error func (c *Client) CheckForMisbehaviour(clientMsg ClientMessage) error func (c *Client) UpdateStateOnMisbehaviour(clientMsg ClientMessage) error ``` The client then must also implement the following functions to verify a serialised `CommitmentProof` as defined in ICS-23 in accordance with the `ConsensusState` the client keeps track of. ```go func (c *Client) VerifyMembership(clientState ClientState, height, delayPeriodTime, delayPeriodBlocks uint64, proof CommitmentProof, path CommitmentPath, value bytes, ) error func (c *Client) VerifyNonMembership(clientState ClientState, height, delayPeriodTime, delayPeriodBlocks uint64, proof CommitmentProof, path CommitmentPath, ) error ``` The chain itself must expose the following functions via an API (`http`, `rpc` or `grpc`) for the relayers so they can pass this information to the light clients periodically ```go func QueryUpdate(height uint64) ClientMessage func QueryChainConsensusState(height uint64) ConsensusState ``` Then the clients must also expose numerous querying functions as follows: ```go func LatestClientHeight(clientState ClientState) uint64 func (c *ClientState) LatestHeight() uint64 func GetTimestampAtHeight(clientState ClientState, height uint64) uint64 func QueryClientState(clientID string) ClientState func QueryConsensusState(clientID string, height uint64) ConsensusState ``` Each client should also expose functions that allow for the querying of certain information and the generation of proofs for the retrieved information in a single call. This allows the relayers to save on calls to the host for proofs after the requested information has been retrieved. ```go func QueryAndProveClientConsensusState(clientID string, height uint64, prefix CommitmentPrefix, consensusStateHeight uint64, ) (ConsensusState, CommitmentProof, error) ``` ## ICS-08 - The Implementation ICS-08 details the WASM specific implementation of the functions defined above. In the case of an IBC WASM client the entry stored under `clients/{clientID}` in the IBC store will be the binary of the WASM client. This is referred to as the `WASM Client Code` and all data passed into the client (`ClientState`, `ConsensusState`, `ClientMessage` and `CommitmentProof` for example) must be serialisable and passed to the `WASM Client Code` in `[]byte` form. In order for WASM binaries to be produced and interacted with in Go the following libraries should be used: - [`cosmwasm/cosmwasm`](https://github.com/CosmWasm/cosmwasm) - For creating WASM Contracts (binaries) that can interface with `cosmwasm/wasmvm` - [`cosmwasm/wasmvm`](https://github.com/CosmWasm/wasmvm) - Go library that allows for the compilation, initialisation and execution of `cosmwasm/cosmwasm` WASM contracts (binaries) The WASM binaries must be produced by using the `cosmwasm/cosmwasm` toolchain (not the Rust `std` library) this means they can be used efficiently and work correctly in the go code that calls them. In order for the ICS-02 interface to be implemented the following helper function must be defined ```go func GetWasmCode(clientID string) CodeHandle ``` It is then the `CodeHandle` that is responsible for interfacing with the WASM client and implementing the different ICS-02 functions. As mentioned above any types passed into the ICS-02 functions must be JSON serialisable and when passed into the `CodeHandle` functions they will be serialised and passed into the `WASM Client Code` as `[]byte` types which will then be deserialised inside the WASM binary's logic and used accordingly. For example: ```go func (c *CodeHandle) IsValidClientState(clientState ClientState, height uint64) error { clientStateBytes := json.Serialise(clientState) packedData := pack(clientStateBytes, height) // Call WASM Client Code using the packed data using wasmvm } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully