diff --git a/.github/workflows/upload-cw-clients.yaml b/.github/workflows/upload-cw-clients.yaml index 224d54bec..6ee12e7e4 100644 --- a/.github/workflows/upload-cw-clients.yaml +++ b/.github/workflows/upload-cw-clients.yaml @@ -1,4 +1,4 @@ -name: Upload CosmWasm clients as Github workflow artifact +name: Upload precompiled CosmWasm clients on: pull_request: paths: @@ -36,7 +36,7 @@ concurrency: jobs: upload-tendermint-cw-client: - name: Compile and upload Tendermint CosmWasm client + name: Upload precompiled Tendermint CosmWasm client runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/ibc-clients/cw-context/src/api.rs b/ibc-clients/cw-context/src/api.rs index dfcbe7ce9..0788520cc 100644 --- a/ibc-clients/cw-context/src/api.rs +++ b/ibc-clients/cw-context/src/api.rs @@ -13,6 +13,6 @@ where >::Error: Into, >::Error: Into, { - type ClientState: ClientStateExecution> + Clone; + type ClientState: ClientStateExecution>; type ConsensusState: ConsensusStateTrait; } diff --git a/ibc-clients/cw-context/src/context/mod.rs b/ibc-clients/cw-context/src/context/mod.rs index ea8518297..4c483e946 100644 --- a/ibc-clients/cw-context/src/context/mod.rs +++ b/ibc-clients/cw-context/src/context/mod.rs @@ -298,9 +298,9 @@ where client_state: C::ClientState, ) -> Result, ClientError> { let wasm_client_state = WasmClientState { - data: C::ClientState::encode_to_any_vec(client_state.clone()), checksum: self.obtain_checksum()?, latest_height: client_state.latest_height(), + data: C::ClientState::encode_to_any_vec(client_state), }; Ok(Any::from(wasm_client_state).encode_to_vec()) diff --git a/ibc-clients/cw-context/src/handlers.rs b/ibc-clients/cw-context/src/handlers.rs index fdf9c3ed2..4b4798d1e 100644 --- a/ibc-clients/cw-context/src/handlers.rs +++ b/ibc-clients/cw-context/src/handlers.rs @@ -138,13 +138,15 @@ where substitute_client_state.latest_height().revision_height(), ))?; + let substitute_client_state_any = substitute_client_state.into(); + self.set_subject_prefix(); - client_state.check_substitute(self, substitute_client_state.clone().into())?; + client_state.check_substitute(self, substitute_client_state_any.clone())?; client_state.update_on_recovery( self, &self.client_id(), - substitute_client_state.into(), + substitute_client_state_any, substitute_consensus_state.into(), )?; diff --git a/ibc-clients/ics07-tendermint/cw-contract/src/client_type.rs b/ibc-clients/ics07-tendermint/cw-contract/src/client_type.rs index dde85427b..001657220 100644 --- a/ibc-clients/ics07-tendermint/cw-contract/src/client_type.rs +++ b/ibc-clients/ics07-tendermint/cw-contract/src/client_type.rs @@ -1,12 +1,6 @@ use ibc_client_cw::api::ClientType; use ibc_client_tendermint::client_state::ClientState; use ibc_client_tendermint::consensus_state::ConsensusState; -use ibc_client_tendermint::types::{ - ConsensusState as ConsensusStateType, TENDERMINT_CONSENSUS_STATE_TYPE_URL, -}; -use ibc_core::client::types::error::ClientError; -use ibc_core::derive::ConsensusState as ConsensusStateDerive; -use ibc_core::primitives::proto::Any; /// A unit struct that represents the Tendermint client type. #[derive(Clone, Debug)] @@ -14,50 +8,5 @@ pub struct TendermintClient; impl<'a> ClientType<'a> for TendermintClient { type ClientState = ClientState; - type ConsensusState = AnyConsensusState; -} - -#[derive(Clone, Debug, ConsensusStateDerive)] -pub enum AnyConsensusState { - Tendermint(ConsensusState), -} - -impl From for AnyConsensusState { - fn from(value: ConsensusStateType) -> Self { - AnyConsensusState::Tendermint(value.into()) - } -} - -impl TryFrom for ConsensusStateType { - type Error = ClientError; - - fn try_from(value: AnyConsensusState) -> Result { - match value { - AnyConsensusState::Tendermint(state) => Ok(state.into_inner()), - } - } -} - -impl From for Any { - fn from(value: AnyConsensusState) -> Self { - match value { - AnyConsensusState::Tendermint(cs) => cs.into(), - } - } -} - -impl TryFrom for AnyConsensusState { - type Error = ClientError; - - fn try_from(raw: Any) -> Result { - match raw.type_url.as_str() { - TENDERMINT_CONSENSUS_STATE_TYPE_URL => { - let cs = ConsensusState::try_from(raw)?; - Ok(AnyConsensusState::Tendermint(cs)) - } - _ => Err(ClientError::UnknownConsensusStateType { - consensus_state_type: raw.type_url, - }), - } - } + type ConsensusState = ConsensusState; } diff --git a/ibc-clients/ics07-tendermint/cw-contract/src/entrypoint.rs b/ibc-clients/ics07-tendermint/cw-contract/src/entrypoint.rs index b496c97c1..e01e796b9 100644 --- a/ibc-clients/ics07-tendermint/cw-contract/src/entrypoint.rs +++ b/ibc-clients/ics07-tendermint/cw-contract/src/entrypoint.rs @@ -1,6 +1,4 @@ -use cosmwasm_std::{ - entry_point, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, -}; +use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Env, MessageInfo, Response}; use ibc_client_cw::context::Context; use ibc_client_cw::types::{ContractError, InstantiateMsg, QueryMsg, SudoMsg}; @@ -16,25 +14,19 @@ pub fn instantiate( msg: InstantiateMsg, ) -> Result { let mut ctx = TendermintContext::new_mut(deps, env)?; - let data = ctx.instantiate(msg)?; - Ok(Response::default().set_data(data)) } #[entry_point] pub fn sudo(deps: DepsMut<'_>, env: Env, msg: SudoMsg) -> Result { let mut ctx = TendermintContext::new_mut(deps, env)?; - let data = ctx.sudo(msg)?; - Ok(Response::default().set_data(data)) } #[entry_point] -pub fn query(deps: Deps<'_>, env: Env, msg: QueryMsg) -> StdResult { +pub fn query(deps: Deps<'_>, env: Env, msg: QueryMsg) -> Result { let ctx = TendermintContext::new_ref(deps, env)?; - ctx.query(msg) - .map_err(|e| StdError::generic_err(e.to_string())) } diff --git a/ibc-clients/ics07-tendermint/src/consensus_state.rs b/ibc-clients/ics07-tendermint/src/consensus_state.rs index d923ebb73..e87778f37 100644 --- a/ibc-clients/ics07-tendermint/src/consensus_state.rs +++ b/ibc-clients/ics07-tendermint/src/consensus_state.rs @@ -43,6 +43,12 @@ impl ConsensusState { } } +impl From for ConsensusStateType { + fn from(value: ConsensusState) -> Self { + value.0 + } +} + impl Protobuf for ConsensusState {} impl TryFrom for ConsensusState { diff --git a/ibc-core/ics02-client/types/src/error.rs b/ibc-core/ics02-client/types/src/error.rs index 0783c906b..9eb5c51da 100644 --- a/ibc-core/ics02-client/types/src/error.rs +++ b/ibc-core/ics02-client/types/src/error.rs @@ -1,5 +1,7 @@ //! Defines the client error type +use core::convert::Infallible; + use displaydoc::Display; use ibc_core_commitment_types::error::CommitmentError; use ibc_core_host_types::error::IdentifierError; @@ -113,6 +115,12 @@ impl From<&'static str> for ClientError { } } +impl From for ClientError { + fn from(value: Infallible) -> Self { + match value {} + } +} + #[cfg(feature = "std")] impl std::error::Error for ClientError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {