diff --git a/.changelog/unreleased/improvements/1433-optional-rust-crypto-in-ibc-client-tendermint.md b/.changelog/unreleased/improvements/1433-optional-rust-crypto-in-ibc-client-tendermint.md new file mode 100644 index 0000000000..ce25c35968 --- /dev/null +++ b/.changelog/unreleased/improvements/1433-optional-rust-crypto-in-ibc-client-tendermint.md @@ -0,0 +1,2 @@ +- [ibc-client-tendermint] Make `rust-crypto` an optional default-enabled feature + ([#1433](https://github.com/cosmos/ibc-rs/pull/1433)) diff --git a/ibc-clients/Cargo.toml b/ibc-clients/Cargo.toml index 0ab910b3cf..87e0cd90bb 100644 --- a/ibc-clients/Cargo.toml +++ b/ibc-clients/Cargo.toml @@ -22,7 +22,8 @@ ibc-client-tendermint = { workspace = true } ibc-client-wasm-types = { workspace = true } [features] -default = [ "std" ] +default = [ "std", "rust-crypto" ] +rust-crypto = [ "ibc-client-tendermint/rust-crypto" ] std = [ "ibc-client-tendermint/std", "ibc-client-wasm-types/std", diff --git a/ibc-clients/ics07-tendermint/Cargo.toml b/ibc-clients/ics07-tendermint/Cargo.toml index 93cab56a6a..651195db3b 100644 --- a/ibc-clients/ics07-tendermint/Cargo.toml +++ b/ibc-clients/ics07-tendermint/Cargo.toml @@ -32,10 +32,11 @@ ibc-primitives = { workspace = true } # cosmos dependencies tendermint = { workspace = true } -tendermint-light-client-verifier = { workspace = true, features = [ "rust-crypto" ] } +tendermint-light-client-verifier = { workspace = true } [features] -default = [ "std" ] +default = [ "std", "rust-crypto" ] +rust-crypto = [ "tendermint-light-client-verifier/rust-crypto" ] std = [ "serde/std", "ibc-client-tendermint-types/std", diff --git a/ibc-clients/ics07-tendermint/src/client_state/validation.rs b/ibc-clients/ics07-tendermint/src/client_state/validation.rs index ccb08b5af6..56ff402b0e 100644 --- a/ibc-clients/ics07-tendermint/src/client_state/validation.rs +++ b/ibc-clients/ics07-tendermint/src/client_state/validation.rs @@ -10,10 +10,9 @@ use ibc_core_host::types::identifiers::ClientId; use ibc_core_host::types::path::ClientConsensusStatePath; use ibc_primitives::prelude::*; use ibc_primitives::proto::Any; -use tendermint::crypto::default::Sha256; use tendermint::crypto::Sha256 as Sha256Trait; use tendermint::merkle::MerkleHash; -use tendermint_light_client_verifier::{ProdVerifier, Verifier}; +use tendermint_light_client_verifier::Verifier; use super::{ check_for_misbehaviour_on_misbehavior, check_for_misbehaviour_on_update, @@ -48,17 +47,30 @@ where /// parameter. fn verify_client_message( &self, - ctx: &V, - client_id: &ClientId, - client_message: Any, + _ctx: &V, + _client_id: &ClientId, + _client_message: Any, ) -> Result<(), ClientError> { - verify_client_message::( - self.inner(), - ctx, - client_id, - client_message, - &ProdVerifier::default(), - ) + #[cfg(feature = "rust-crypto")] + { + use tendermint::crypto::default::Sha256; + use tendermint_light_client_verifier::ProdVerifier; + + verify_client_message::( + self.inner(), + _ctx, + _client_id, + _client_message, + &ProdVerifier::default(), + ) + } + #[cfg(not(feature = "rust-crypto"))] + { + unimplemented!( + "verify_client_message requires the `rust-crypto` feature; \ + use a custom verifier via the standalone verify_client_message function instead" + ) + } } fn check_for_misbehaviour( diff --git a/ibc-clients/ics07-tendermint/types/Cargo.toml b/ibc-clients/ics07-tendermint/types/Cargo.toml index 8bb4b70ecf..0baf22f6dd 100644 --- a/ibc-clients/ics07-tendermint/types/Cargo.toml +++ b/ibc-clients/ics07-tendermint/types/Cargo.toml @@ -33,7 +33,7 @@ ibc-proto = { workspace = true } # cosmos dependencies tendermint = { workspace = true } -tendermint-light-client-verifier = { workspace = true, features = [ "rust-crypto" ] } +tendermint-light-client-verifier = { workspace = true } tendermint-proto = { workspace = true } # parity dependencies diff --git a/ibc-testkit/Cargo.toml b/ibc-testkit/Cargo.toml index 8e43636b84..eb28b9bbfa 100644 --- a/ibc-testkit/Cargo.toml +++ b/ibc-testkit/Cargo.toml @@ -44,7 +44,8 @@ hex = { workspace = true } rstest = { workspace = true } [features] -default = [ "std" ] +default = [ "std", "rust-crypto" ] +rust-crypto = [ "ibc/rust-crypto" ] std = [ "hex/std", "serde/std", diff --git a/ibc-testkit/src/relayer/integration.rs b/ibc-testkit/src/relayer/integration.rs index 145ed50044..4a5a6cea6d 100644 --- a/ibc-testkit/src/relayer/integration.rs +++ b/ibc-testkit/src/relayer/integration.rs @@ -163,6 +163,7 @@ where } #[cfg(test)] +#[cfg(feature = "rust-crypto")] mod tests { use super::*; use crate::hosts::{MockHost, TendermintHost}; diff --git a/ibc/Cargo.toml b/ibc/Cargo.toml index 1a1eb6f567..f399e570c3 100644 --- a/ibc/Cargo.toml +++ b/ibc/Cargo.toml @@ -29,7 +29,8 @@ ibc-derive = { workspace = true } ibc-primitives = { workspace = true } [features] -default = [ "std" ] +default = [ "std", "rust-crypto" ] +rust-crypto = [ "ibc-clients/rust-crypto" ] std = [ "ibc-apps/std", "ibc-clients/std", diff --git a/tests-integration/Cargo.toml b/tests-integration/Cargo.toml index 57f2834689..3fe0a82dfb 100644 --- a/tests-integration/Cargo.toml +++ b/tests-integration/Cargo.toml @@ -41,7 +41,8 @@ test-log = { version = "0.2.16", features = [ "trace" ] } tendermint-rpc = { workspace = true } [features] -default = [ "std" ] +default = [ "std", "rust-crypto" ] +rust-crypto = [ "ibc/rust-crypto" ] std = [ "serde/std", "serde-json/std", diff --git a/tests-integration/tests/core/ics02_client/mod.rs b/tests-integration/tests/core/ics02_client/mod.rs index 267b760cc0..0e8e43d20c 100644 --- a/tests-integration/tests/core/ics02_client/mod.rs +++ b/tests-integration/tests/core/ics02_client/mod.rs @@ -1,6 +1,7 @@ #[cfg(feature = "serde")] pub mod create_client; pub mod recover_client; +#[cfg(feature = "rust-crypto")] pub mod update_client; #[cfg(feature = "serde")] pub mod upgrade_client; diff --git a/tests-integration/tests/core/router.rs b/tests-integration/tests/core/router.rs index 9bfdd06fba..4371a7b73d 100644 --- a/tests-integration/tests/core/router.rs +++ b/tests-integration/tests/core/router.rs @@ -42,6 +42,7 @@ use ibc_testkit::testapp::ibc::clients::mock::client_state::MockClientState; use ibc_testkit::testapp::ibc::clients::mock::consensus_state::MockConsensusState; use ibc_testkit::testapp::ibc::clients::mock::header::MockHeader; use ibc_testkit::testapp::ibc::core::router::MockRouter; +use std::panic; use test_log::test; #[test]