Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

support ICS008 wrapper type for host client and consensus state #1237

Closed
rnbguy opened this issue May 23, 2024 · 2 comments · Fixed by #1246 or #1252
Closed

support ICS008 wrapper type for host client and consensus state #1237

rnbguy opened this issue May 23, 2024 · 2 comments · Fixed by #1246 or #1252
Assignees

Comments

@rnbguy
Copy link
Member

rnbguy commented May 23, 2024

Feature Summary

Now that ibc-go comes with wasm-08, client state of an ibc-rs chain maybe stored as wasm wrapped format in wasm-08 enabled chain.

So when MsgConnectionOpenTry or MsgConnectionOpenAck is received at ibc-rs, it should expect two cases:

  1. normal client state. e.g., the chain is using vanilla tendermint engine, so the counterparty ibc-go chain uses ibc-go implementation of ics07.
  2. wasm wrapped client state. e.g., the chain is using a custom consensus, so the counterparty ibc-go chain uses wasm client via wasm-08

Proposal

We need to introduce an enum:

pub enum HostClientState<T> {
    Native {
        state: T,
    },
    Wasm {
        state: T,
        checksum: Vec<u8>,
        latest_height: Height,
    },
}

Then, use HosClientState<Ctx::HostClientState> in the following places:

https://github.com/cosmos/ibc-rs/blob/2378cd4ba45094b8ed856ff7dba5f1d0882f59ae/ibc-core/ics03-connection/src/handler/conn_open_ack.rs#L52

https://github.com/cosmos/ibc-rs/blob/2378cd4ba45094b8ed856ff7dba5f1d0882f59ae/ibc-core/ics03-connection/src/handler/conn_open_try.rs#L42

@rnbguy
Copy link
Member Author

rnbguy commented May 23, 2024

Maybe we can add another generic associated type to ValidationContext:

https://github.com/cosmos/ibc-rs/blob/2378cd4ba45094b8ed856ff7dba5f1d0882f59ae/ibc-core/ics24-host/src/context.rs#L28-L31

    type HostClientStateAtCounterparty<V>: Into<V> + TryFrom<Any> where V: TryFrom<Any>;

And, later, we use it as::

Ctx::HostClientStateAtCounterparty<Ctx::HostClientState>::try_from(
    msg.client_state_of_a_on_b.clone()
  )
  .map_err(Into::into)?
  .into(); 

This way, we allow the crate users to build their own custom host client wrapper.

@rnbguy rnbguy changed the title support wrapper type for host client state support ICS008 wrapper type for host client state Jun 3, 2024
@rnbguy rnbguy reopened this Jun 7, 2024
@rnbguy rnbguy changed the title support ICS008 wrapper type for host client state support ICS008 wrapper type for host client and consensus state Jun 7, 2024
@rnbguy
Copy link
Member Author

rnbguy commented Jun 7, 2024

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
1 participant