Skip to content
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

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
Collaborator

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:

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

Ctx::HostClientState::try_from(msg.client_state_of_b_on_a.clone()).map_err(Into::into)?;

@rnbguy
Copy link
Collaborator Author

rnbguy commented May 23, 2024

Maybe we can add another generic associated type to ValidationContext:

/// The client state type for the host chain.
type HostClientState: ClientStateValidation<Self::V>;
/// The consensus state type for the host chain.
type HostConsensusState: ConsensusState;

    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
Collaborator Author

rnbguy commented Jun 7, 2024

Looks like, the similar is required for host consensus state. In the following, we need to wrap the consensus state in wasm consensus state and then check for proofs.

let expected_consensus_state_of_a_on_b =
ctx_a.host_consensus_state(&msg.consensus_height_of_a_on_b)?;

let expected_consensus_state_of_b_on_a =
ctx_b.host_consensus_state(&msg.consensus_height_of_b_on_a)?;

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