Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

chore: incorporate updates from ibc-rs ADR-10 #92

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 86 additions & 53 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ tempfile = "3.5"
thiserror = "1.0.38"

# ibc depedenencies
ibc-core = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false, features = ["borsh","schema","serde"] }
ibc-core-client = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-core-host-cosmos = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-client-tendermint = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-client-wasm-types = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-app-transfer = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-primitives = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-query = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-testkit = { git = "https://github.com/cosmos/ibc-rs.git", rev = "552863ec93", default-features = false }
ibc-core = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false, features = ["borsh","schema","serde"] }
ibc-core-client = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-core-host-cosmos = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-client-tendermint = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-client-wasm-types = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-app-transfer = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-primitives = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-query = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-testkit = { git = "https://github.com/cosmos/ibc-rs.git", rev = "4463366e65", default-features = false }
ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", rev = "1b1d7a9", default-features = false }

# cosmos dependencies
Expand Down
45 changes: 39 additions & 6 deletions clients/sov-celestia-cw/src/context/client_ctx.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,56 @@
use ibc_client_wasm_types::client_state::ClientState as WasmClientState;
use ibc_client_wasm_types::consensus_state::ConsensusState as WasmConsensusState;
use ibc_core::client::context::{ClientExecutionContext, ClientValidationContext};
use ibc_core::client::types::error::ClientError;
use ibc_core::client::types::Height;
use ibc_core::handler::types::error::ContextError;
use ibc_core::host::types::identifiers::ClientId;
use ibc_core::host::types::path::{iteration_key, ClientConsensusStatePath, ClientStatePath};
use ibc_core::host::ValidationContext;
use ibc_core::primitives::proto::Any;
use ibc_core::primitives::proto::{Any, Protobuf};
use ibc_core::primitives::Timestamp;
use prost::Message;
use sov_celestia_client::client_state::ClientState;
use sov_celestia_client::types::client_state::SovTmClientState;
use sov_celestia_client::types::consensus_state::SovTmConsensusState;

use super::Context;
use crate::types::AnyConsensusState;

impl ClientValidationContext for Context<'_> {
fn update_meta(
type ClientStateRef = ClientState;
type ConsensusStateRef = AnyConsensusState;

fn client_state(&self, _client_id: &ClientId) -> Result<Self::ClientStateRef, ContextError> {
let client_state_value = self.retrieve(ClientStatePath::leaf())?;

let any_wasm: WasmClientState = Protobuf::<Any>::decode(client_state_value.as_slice())
.map_err(|e| ClientError::Other {
description: e.to_string(),
})?;

let sov_client_state = SovTmClientState::decode_thru_any(any_wasm.data)?;

Ok(sov_client_state.into())
}

fn consensus_state(
&self,
client_cons_state_path: &ClientConsensusStatePath,
) -> Result<Self::ConsensusStateRef, ContextError> {
let consensus_state_value = self.retrieve(client_cons_state_path.leaf())?;
let any_wasm: WasmConsensusState =
Protobuf::<Any>::decode(consensus_state_value.as_slice()).map_err(|e| {
ClientError::Other {
description: e.to_string(),
}
})?;

let consensus_state = SovTmConsensusState::decode_thru_any(any_wasm.data)?;

Ok(AnyConsensusState::Sovereign(consensus_state.into()))
}

fn client_update_meta(
&self,
_client_id: &ClientId,
height: &Height,
Expand Down Expand Up @@ -43,9 +78,7 @@ impl ClientValidationContext for Context<'_> {
}

impl ClientExecutionContext for Context<'_> {
type V = <Self as ValidationContext>::V;
type AnyClientState = <Self as ValidationContext>::AnyClientState;
type AnyConsensusState = <Self as ValidationContext>::AnyConsensusState;
type ClientStateMut = ClientState;

fn store_client_state(
&mut self,
Expand Down
296 changes: 0 additions & 296 deletions clients/sov-celestia-cw/src/context/core_ctx.rs

This file was deleted.

Loading
Loading