From 89cdd1d474e37a48035b86cb37790849cdb9b2eb Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Wed, 27 Sep 2023 10:42:53 +0545 Subject: [PATCH 01/64] feat: add wasm client project --- Cargo.lock | 140 ++++- Cargo.toml | 2 +- .../cw-ibc-core/src/ics02_client/handler.rs | 6 +- .../cw-ibc-core/src/ics02_client/mod.rs | 1 + .../src/ics03_connection/connection.rs | 14 +- .../src/ics03_connection/handler.rs | 8 +- .../cw-ibc-core/tests/test_client.rs | 4 +- .../tests/test_execution_messages.rs | 2 +- .../cw-icon-light-client/Cargo.toml | 1 + .../cw-icon-light-client/src/contract.rs | 2 +- .../cw-icon-light-client/src/lib.rs | 15 +- .../cw-light-client-common/Cargo.toml | 27 + .../src/constants.rs | 0 .../src/error.rs | 0 .../cw-light-client-common/src/lib.rs | 7 + .../src/light_client.rs | 0 .../src/query_handler.rs | 0 .../src/state.rs | 0 .../src/traits.rs | 0 .../src/send_message.rs | 4 +- .../cw-wasm-light-client/.cargo/config | 4 + .../cw-wasm-light-client/Cargo.toml | 69 +++ .../cw-wasm-light-client/README.md | 33 ++ .../cw-wasm-light-client/src/contract.rs | 535 ++++++++++++++++++ .../src/ics08_wasm/client_message.rs | 213 +++++++ .../src/ics08_wasm/client_state.rs | 204 +++++++ .../src/ics08_wasm/consensus_state.rs | 124 ++++ .../src/ics08_wasm/mod.rs | 3 + .../cw-wasm-light-client/src/lib.rs | 11 + .../cw-wasm-light-client/src/msg.rs | 360 ++++++++++++ .../cw-wasm-light-client/tests/setup.rs | 86 +++ .../cw-xcall-ibc-connection/src/admin.rs | 2 +- .../src/send_message.rs | 2 +- .../tests/test_owner.rs | 3 +- .../tests/test_receive_packet.rs | 2 +- .../tests/test_send_message.rs | 8 +- .../src/ibc/core/ics23_commitment/merkle.rs | 252 ++++----- .../src/ibc/core/ics23_commitment/mod.rs | 2 +- .../rust/common/src/ibc/mock/client_state.rs | 2 +- .../common/src/ibc/mock/consensus_state.rs | 2 +- libraries/rust/common/src/ibc/mock/header.rs | 4 +- .../rust/common/src/ibc/mock/misbehaviour.rs | 2 +- scripts/optimize-cosmwasm.sh | 2 +- 43 files changed, 1974 insertions(+), 184 deletions(-) create mode 100644 contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml rename contracts/cosmwasm-vm/{cw-icon-light-client => cw-light-client-common}/src/constants.rs (100%) rename contracts/cosmwasm-vm/{cw-icon-light-client => cw-light-client-common}/src/error.rs (100%) create mode 100644 contracts/cosmwasm-vm/cw-light-client-common/src/lib.rs rename contracts/cosmwasm-vm/{cw-icon-light-client => cw-light-client-common}/src/light_client.rs (100%) rename contracts/cosmwasm-vm/{cw-icon-light-client => cw-light-client-common}/src/query_handler.rs (100%) rename contracts/cosmwasm-vm/{cw-icon-light-client => cw-light-client-common}/src/state.rs (100%) rename contracts/cosmwasm-vm/{cw-icon-light-client => cw-light-client-common}/src/traits.rs (100%) create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/.cargo/config create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/README.md create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs diff --git a/Cargo.lock b/Cargo.lock index 5271cdb09..3a0388bfd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,6 +66,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" + [[package]] name = "base64ct" version = "1.6.0" @@ -204,8 +210,8 @@ dependencies = [ "dyn-clone", "hex", "hex-literal 0.3.4", - "ibc-proto", - "ics23", + "ibc-proto 0.35.0", + "ics23 0.9.0", "pbjson", "pbjson-types", "prost 0.11.9", @@ -241,8 +247,8 @@ dependencies = [ "dyn-clone", "hex", "hex-literal 0.3.4", - "ibc-proto", - "ics23", + "ibc-proto 0.26.0", + "ics23 0.9.0", "pbjson", "pbjson-types", "prost 0.11.9", @@ -433,7 +439,7 @@ dependencies = [ "getrandom", "hex", "hex-buffer-serde", - "ibc-proto", + "ibc-proto 0.35.0", "prost 0.11.9", "schemars 0.8.12", "serde", @@ -481,6 +487,7 @@ dependencies = [ "cosmwasm-std", "cosmwasm-storage", "cw-common", + "cw-light-client-common", "cw-storage-plus 1.1.0", "cw2", "debug_print", @@ -525,6 +532,29 @@ dependencies = [ "test-utils", ] +[[package]] +name = "cw-light-client-common" +version = "0.1.0" +dependencies = [ + "common 0.1.0", + "cosmwasm", + "cosmwasm-schema", + "cosmwasm-std", + "cosmwasm-storage", + "cw-common", + "cw-storage-plus 1.1.0", + "debug_print", + "getrandom", + "hex", + "hex-literal 0.4.1", + "prost 0.11.9", + "schemars 0.8.12", + "serde", + "serde-json-wasm 0.5.1", + "test-utils", + "thiserror", +] + [[package]] name = "cw-mock-dapp" version = "0.1.0" @@ -677,6 +707,35 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-wasm-light-client" +version = "0.1.0" +dependencies = [ + "bytes", + "common 0.1.0", + "cosmwasm", + "cosmwasm-schema", + "cosmwasm-std", + "cosmwasm-storage", + "cw-common", + "cw-light-client-common", + "cw-storage-plus 1.1.0", + "cw2", + "debug_print", + "getrandom", + "hex", + "hex-literal 0.4.1", + "ibc-proto 0.35.0", + "prost 0.11.9", + "schemars 0.8.12", + "serde", + "serde-json-wasm 0.5.1", + "sha2 0.10.6", + "sha3", + "test-utils", + "thiserror", +] + [[package]] name = "cw-xcall" version = "0.1.0" @@ -1153,8 +1212,8 @@ dependencies = [ "displaydoc", "dyn-clone", "erased-serde", - "ibc-proto", - "ics23", + "ibc-proto 0.26.0", + "ics23 0.9.0", "num-traits", "parity-scale-codec", "primitive-types", @@ -1168,7 +1227,7 @@ dependencies = [ "subtle-encoding", "tendermint", "tendermint-light-client-verifier", - "tendermint-proto", + "tendermint-proto 0.29.1", "time", "tracing", "uint", @@ -1189,7 +1248,24 @@ dependencies = [ "scale-info", "serde", "subtle-encoding", - "tendermint-proto", + "tendermint-proto 0.29.1", +] + +[[package]] +name = "ibc-proto" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "459ccbab879b749bf500ae13244593fa16fc64c1b3159f6b0753c169625a1e23" +dependencies = [ + "base64 0.21.4", + "bytes", + "flex-error", + "ics23 0.10.2", + "prost 0.11.9", + "schemars 0.8.12", + "serde", + "subtle-encoding", + "tendermint-proto 0.33.2", ] [[package]] @@ -1207,6 +1283,20 @@ dependencies = [ "sha3", ] +[[package]] +name = "ics23" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442d4bab37956e76f739c864f246c825d87c0bb7f9afa65660c57833c91bf6d4" +dependencies = [ + "anyhow", + "bytes", + "hex", + "informalsystems-pbjson", + "prost 0.11.9", + "serde", +] + [[package]] name = "impl-serde" version = "0.4.0" @@ -1237,6 +1327,16 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "informalsystems-pbjson" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eecd90f87bea412eac91c6ef94f6b1e390128290898cbe14f2b926787ae1fb" +dependencies = [ + "base64 0.13.1", + "serde", +] + [[package]] name = "instant" version = "0.1.12" @@ -2190,7 +2290,7 @@ dependencies = [ "signature", "subtle", "subtle-encoding", - "tendermint-proto", + "tendermint-proto 0.29.1", "time", "zeroize", ] @@ -2226,6 +2326,24 @@ dependencies = [ "time", ] +[[package]] +name = "tendermint-proto" +version = "0.33.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "639e5adffd77220d238a800a72c74c98d7e869290a6e4494c10b6b4e8f702f02" +dependencies = [ + "bytes", + "flex-error", + "num-derive", + "num-traits", + "prost 0.11.9", + "prost-types", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + [[package]] name = "test-log" version = "0.2.11" @@ -2247,7 +2365,7 @@ dependencies = [ "getrandom", "hex", "hex-literal 0.4.1", - "ibc-proto", + "ibc-proto 0.35.0", "prost 0.11.9", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 0acc4348a..27b5bf0e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="main" cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="main" } cw2 = "1.0.1" -ibc-proto = { version = "0.26.0", default-features = false} +ibc-proto = { version = "0.35.0", default-features = false,features = ["std", "schemars","serde"]} prost = { version = "0.11.8", default-features = false,features=["prost-derive"]} serde-json-wasm = {version="0.5.0", default-features = false} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs index b1bbdf5af..425b11c12 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs @@ -131,7 +131,7 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> { message: RawMsgUpdateClient, ) -> Result { let client_id = to_ibc_client_id(&message.client_id)?; - let header = message.header.ok_or(ContractError::IbcClientError { + let header = message.client_message.ok_or(ContractError::IbcClientError { error: ClientError::MissingRawHeader, })?; @@ -468,7 +468,7 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> { let clinet_message = LightClientMessage::Misbehaviour { client_id: client_id.to_string(), - misbehaviour: to_vec(&message.misbehaviour)?, + misbehaviour: message.misbehaviour.unwrap().encode_to_vec(), }; let wasm_exec_message: CosmosMsg = CosmosMsg::Wasm(cosmwasm_std::WasmMsg::Execute { @@ -547,6 +547,8 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> { } } + + #[cfg(test)] mod tests { use cosmwasm_std::{from_binary, to_binary}; diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/mod.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/mod.rs index c9e814968..c942061b6 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/mod.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/mod.rs @@ -23,3 +23,4 @@ use cw_common::raw_types::Any; use events::{create_client_event, update_client_event, upgrade_client_event}; use std::time::Duration; + diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs index 2c29ccef9..6862cac36 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs @@ -28,11 +28,8 @@ impl<'a> CwIbcCoreContext<'a> { conn_end: &ConnectionEnd, ) -> Result<(), ContractError> { let data = conn_end - .encode_vec() - .map_err(|error| ConnectionError::Other { - description: error.to_string(), - }) - .map_err(Into::::into)?; + .encode_vec(); + match self.ibc_store().connections().save(store, conn_id, &data) { Ok(_) => Ok(()), Err(error) => Err(ContractError::Std(error)), @@ -289,12 +286,7 @@ impl<'a> CwIbcCoreContext<'a> { let connection_end_bytes = connection_end - .encode_vec() - .map_err(|error| ContractError::IbcConnectionError { - error: ConnectionError::Other { - description: error.to_string(), - }, - })?; + .encode_vec(); let commitment_bytes = keccak256(&connection_end_bytes).to_vec(); diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs index c9172099a..2a279ad5a 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs @@ -218,7 +218,7 @@ impl<'a> CwIbcCoreContext<'a> { to_vec(&counterparty_prefix)?, msg.proof_try, connection_path, - expected_connection_end.encode_vec().unwrap(), + expected_connection_end.encode_vec(), ); let client_state_path = commitment::client_state_path(counterparty_client_id); @@ -356,7 +356,7 @@ impl<'a> CwIbcCoreContext<'a> { cw_println!( deps, "[ConnOpenTry]: expected counterpart connection_end:{:?}", - HexString::from_bytes(&expected_connection_end.encode_vec().unwrap()) + HexString::from_bytes(&expected_connection_end.encode_vec()) ); let consensus_state = self.consensus_state(deps.as_ref(), &client_id, &proof_height)?; @@ -378,7 +378,7 @@ impl<'a> CwIbcCoreContext<'a> { to_vec(&counterparty_prefix).map_err(ContractError::Std)?, message.proof_init, counterparty_connection_path, - expected_connection_end.encode_vec().unwrap().to_vec(), + expected_connection_end.encode_vec(), ); // this is verifying tendermint client state and shouldn't have icon-client as an argument @@ -530,7 +530,7 @@ impl<'a> CwIbcCoreContext<'a> { to_vec(&counterparty_prefix).map_err(ContractError::Std)?, msg.proof_ack, connection_path, - expected_connection_end.encode_vec().unwrap(), + expected_connection_end.encode_vec(), ); client.verify_connection_open_confirm(deps.as_ref(), verify_connection_state, client_id)?; diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs index 21a8d1fc5..b54a0985d 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs @@ -536,7 +536,7 @@ fn check_for_update_client_message() { let update_client_message = RawMsgUpdateClient { client_id: client_id.to_string(), - header: Some(client_state.to_any()), + client_message: Some(client_state.to_any()), signer: signer.to_string(), }; @@ -598,7 +598,7 @@ fn fails_on_updating_non_existing_client() { let signer = Signer::from_str("new_signer").unwrap(); let update_client_message = RawMsgUpdateClient { client_id: client_id.to_string(), - header: Some(client_state.to_any()), + client_message: Some(client_state.to_any()), signer: signer.to_string(), }; diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_execution_messages.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_execution_messages.rs index d12d5c55c..4817eb50c 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_execution_messages.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_execution_messages.rs @@ -182,7 +182,7 @@ fn test_for_update_client_execution_messages() { let msg_hex = RawMsgUpdateClient { client_id: "iconclient-0".to_string(), - header: Some(signed_header.to_any()), + client_message: Some(signed_header.to_any()), signer: "signeraddress".to_string(), }; diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml index ce374c189..d870f0f75 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml @@ -45,6 +45,7 @@ sha3 = { version = "0.10.6", default-features = false } bytes = { workspace=true } common = { path="../../../libraries/rust/common", default-features = false } cw-common = { path="../cw-common",default-features = false } +cw-light-client-common = { path="../cw-light-client-common",default-features = false } prost = { workspace=true} serde-json-wasm = {workspace=true} debug_print = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs index 92728e03a..ca8f456b0 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs @@ -21,10 +21,10 @@ use cw_common::raw_types::Any; use cw_common::types::VerifyChannelState; use crate::constants::{CLIENT_STATE_HASH, CONSENSUS_STATE_HASH, HEIGHT}; -use crate::error::ContractError; use crate::light_client::IconClient; use crate::state::CwContext; use crate::traits::{Config, IContext, ILightClient}; +use crate::ContractError; use cw_common::client_msg::{ ExecuteMsg, InstantiateMsg, LightClientPacketMessage, QueryMsg, VerifyClientConsensusState, VerifyClientFullState, VerifyConnectionState, diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/lib.rs index ef02fd1dc..9bed4860b 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/lib.rs @@ -1,11 +1,12 @@ -mod constants; +pub use cw_light_client_common::constants; pub mod contract; -mod error; -pub mod light_client; + +pub use cw_light_client_common::light_client; + #[cfg(feature = "mock")] pub mod mock_client; -pub mod query_handler; -pub mod state; -mod traits; +pub use cw_light_client_common::query_handler; +pub use cw_light_client_common::state; +pub use cw_light_client_common::traits; -pub use crate::error::ContractError; +pub use cw_light_client_common::error::ContractError; diff --git a/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml b/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml new file mode 100644 index 000000000..787deb2d3 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "cw-light-client-common" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +cosmwasm-schema = {workspace=true} +cosmwasm-std = {workspace=true} +cosmwasm-storage = {workspace=true} +cw-storage-plus = {workspace=true} +thiserror = { workspace=true} +prost = { workspace=true} +hex ={workspace=true } +schemars = {workspace=true} +serde = { workspace=true} +serde-json-wasm = {workspace=true} +debug_print = {workspace=true} +cw-common = { path="../cw-common",default-features = false } +common = { path="../../../libraries/rust/common", default-features = false } + +[dev-dependencies] +cosmwasm = "0.7.2" +hex-literal="*" +test-utils={path="../../../libraries/rust/test-utils"} +getrandom = {version = "0.2", default-features = false, features = ["custom"]} diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/constants.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/constants.rs similarity index 100% rename from contracts/cosmwasm-vm/cw-icon-light-client/src/constants.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/constants.rs diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/error.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/error.rs similarity index 100% rename from contracts/cosmwasm-vm/cw-icon-light-client/src/error.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/error.rs diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/lib.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/lib.rs new file mode 100644 index 000000000..1ef9e7d57 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/lib.rs @@ -0,0 +1,7 @@ +pub mod constants; +pub mod error; +pub mod light_client; +pub mod query_handler; +pub mod state; +pub mod traits; +pub use crate::error::ContractError; diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs similarity index 100% rename from contracts/cosmwasm-vm/cw-icon-light-client/src/light_client.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs similarity index 100% rename from contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/state.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs similarity index 100% rename from contracts/cosmwasm-vm/cw-icon-light-client/src/state.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/state.rs diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/traits.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs similarity index 100% rename from contracts/cosmwasm-vm/cw-icon-light-client/src/traits.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-connection/src/send_message.rs b/contracts/cosmwasm-vm/cw-mock-ibc-connection/src/send_message.rs index d7d3bffe7..84fff8bac 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-connection/src/send_message.rs +++ b/contracts/cosmwasm-vm/cw-mock-ibc-connection/src/send_message.rs @@ -16,11 +16,11 @@ impl<'a> CwIbcConnection<'a> { self.ensure_xcall_handler(deps.as_ref().storage, info.sender.clone())?; println!("{LOG_PREFIX} Packet Validated"); - let network_fee = self.get_network_fees(deps.as_ref().storage, nid.clone()); + let network_fee = self.get_network_fees(deps.as_ref().storage, nid); let mut total_fee = network_fee.send_packet_fee; if sn > 0 { - total_fee = total_fee + network_fee.ack_fee; + total_fee += network_fee.ack_fee; } let config = self.get_config(deps.storage)?; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/.cargo/config b/contracts/cosmwasm-vm/cw-wasm-light-client/.cargo/config new file mode 100644 index 000000000..af5698e58 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/.cargo/config @@ -0,0 +1,4 @@ +[alias] +wasm = "build --release --lib --target wasm32-unknown-unknown" +unit-test = "test --lib" +schema = "run --bin schema" diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml new file mode 100644 index 000000000..c6177885b --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml @@ -0,0 +1,69 @@ +[package] +name = "cw-wasm-light-client" +version = "0.1.0" +authors.workspace = true +edition = "2021" + +exclude = [ + # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. + "contract.wasm", + "hash.txt", +] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib", "rlib"] + +[features] +default = [] +# for more explicit tests, cargo test --features=backtraces +backtraces = ["cosmwasm-std/backtraces"] +# use library feature to disable all instantiate/execute/query exports +library = [] +mock=[] + +[package.metadata.scripts] +optimize = """docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/rust-optimizer:0.12.10 +""" + +[dependencies] +cosmwasm-schema = {workspace=true} +cosmwasm-std = {workspace=true} +cosmwasm-storage = {workspace=true} +cw-storage-plus = {workspace=true} +cw2 = {workspace=true} +schemars = {workspace=true} +serde = { workspace=true} +thiserror = { workspace=true} +sha2 = { version = "0.10.6", default-features = false } +hex ={workspace=true } +sha3 = { version = "0.10.6", default-features = false } +bytes = { workspace=true } +common = { path="../../../libraries/rust/common", default-features = false } +cw-light-client-common = { path="../cw-light-client-common",default-features = false } +cw-common = { path="../cw-common",default-features = false } +prost = { workspace=true} +serde-json-wasm = {workspace=true} +debug_print = {workspace=true} +ibc-proto = { workspace=true} + + +[dev-dependencies] +cosmwasm = "0.7.2" +hex-literal="*" +test-utils={path="../../../libraries/rust/test-utils"} +getrandom = {version = "0.2", default-features = false, features = ["custom"]} + +[profile.release] +# Do not perform backtrace for panic on release builds. +panic = 'abort' +# Perform optimizations on all codegen units. +codegen-units = 1 +# Optimize for size. +opt-level = 'z' # or 'z' to optimize "aggressively" for size +# Enable link time optimization. +lto = true diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/README.md b/contracts/cosmwasm-vm/cw-wasm-light-client/README.md new file mode 100644 index 000000000..e66c6f741 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/README.md @@ -0,0 +1,33 @@ +# Deviations from IBC Tendermint LightClient + +This LightClient was meant to be used for [ICON-IBC Integration](https://github.com/icon-project/IBC-Integration). So, it is made to accomodate all the changes made on IBC Integration such that IBC can be established between ICON and Cosmos based chains. + +The IBC Tendermint LightClient is originally available as module. One of the major deviations in ICON LightClient was to implement it under smart contract environment. + +All other deviations can be found [here](). + +## Changes +The major changes in Icon LightClient Implementation includes: + +- [createClient](#createclient) +- [updateClient](#updateclient) +- [verifyNonMembership](#verifynonmembership) + +## createClient +The IBC Tendermint LightClient sets the *type, clientState, consensusState, blockTimestamp* and *blockHeight* while creating client. + +Our Implementation sets just the *clientState, consensusState* and *blockHeight*. + +## updateClient +In case of IBC Tendermint LightClient, while updating client, the headers are verfied for adjacent or non-adjacent updates. + +In our ICON LightClient relay can update non-adjacent blocks provided that it is within the trusting period and can provide a previous trusted height.It can also update older blocks upto certain time limit from latest updated height in clientstate. + +Similarly, in our ICON LightClient implementation, we are not using the actual block headers, but the BTP headers where we just verify if the incoming BTP header height is always greater than the previous one. Then we store a mapping of BTP block height and actual block height as well as BTP block height and actual block timestamp. + +In IBC Tendermint LightClient, the update is based on block height but in our ICON LightClient, the update is based on BTP block height and epoch. + +## verifyNonMembership +Both IBC Tendermint Lightclient and ICON LightClient uses MerkelProof for verifying membership and non-membership. + +In IBC Tendermint Lightclient, the verifyNonMembership verifies the absence of key. But in case of ICON LightClient, we need to verify that the value of key is empty. \ No newline at end of file diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs new file mode 100644 index 000000000..06b3a58f3 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -0,0 +1,535 @@ +use common::constants::ICON_CLIENT_TYPE; +use common::icon::icon::lightclient::v1::{ClientState, ConsensusState}; +use common::traits::AnyTypes; +use cosmwasm_schema::cw_serde; +use cw_common::ibc_types::IbcHeight; +use cw_common::to_checked_address; + +#[cfg(feature = "mock")] +use crate::mock_client::MockClient; +use crate::query_handler::QueryHandler; +use common::icon::icon::types::v1::{MerkleProofs, SignedHeader}; + +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; +use cosmwasm_std::{ + to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, +}; +use cw2::set_contract_version; +use cw_common::client_response::{CreateClientResponse, UpdateClientResponse}; +use cw_common::raw_types::Any; +use cw_common::types::VerifyChannelState; + +use crate::constants::{CLIENT_STATE_HASH, CONSENSUS_STATE_HASH, HEIGHT}; +use crate::ContractError; +use crate::light_client::IconClient; +use crate::state::CwContext; +use crate::traits::{Config, IContext, ILightClient}; +use cw_common::client_msg::{ + ExecuteMsg, InstantiateMsg, LightClientPacketMessage, QueryMsg, VerifyClientConsensusState, + VerifyClientFullState, VerifyConnectionState, +}; +use prost::Message; + +// version info for migration info +const CONTRACT_NAME: &str = "crates.io:cw-icon-light-client"; +const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn instantiate( + deps: DepsMut, + _env: Env, + info: MessageInfo, + msg: InstantiateMsg, +) -> Result { + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION) + .map_err(|_e| ContractError::FailedToInitContract)?; + let ibc_host = to_checked_address(deps.as_ref(), msg.ibc_host.as_ref()); + let config = Config::new(info.sender, ibc_host); + let mut context = CwContext::new(deps, _env); + context.insert_config(&config)?; + Ok(Response::default()) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + deps_mut: DepsMut, + _env: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::CreateClient { + client_id, + client_state, + consensus_state, + } => { + let context = CwContext::new(deps_mut, _env); + let mut client = IconClient::new(context); + let client_state_any = + Any::decode(client_state.as_slice()).map_err(ContractError::DecodeError)?; + let consensus_state_any = + Any::decode(consensus_state.as_slice()).map_err(ContractError::DecodeError)?; + let client_state = ClientState::from_any(client_state_any.clone()) + .map_err(ContractError::DecodeError)?; + let consensus_state = ConsensusState::from_any(consensus_state_any.clone()) + .map_err(ContractError::DecodeError)?; + let update = + client.create_client(info.sender, &client_id, client_state, consensus_state)?; + + let mut response = Response::new() + .add_attribute( + CLIENT_STATE_HASH, + hex::encode(update.client_state_commitment), + ) + .add_attribute( + CONSENSUS_STATE_HASH, + hex::encode(update.consensus_state_commitment), + ) + .add_attribute(HEIGHT, update.height.to_string()); + + let client_response = CreateClientResponse::new( + ICON_CLIENT_TYPE.to_string(), + IbcHeight::new(1, update.height).unwrap().to_string(), + update.client_state_commitment.to_vec(), + update.consensus_state_commitment.into(), + client_state_any.encode_to_vec(), + consensus_state_any.encode_to_vec(), + ); + + response.data = to_binary(&client_response).ok(); + + Ok(response) + } + ExecuteMsg::UpdateClient { + client_id, + signed_header, + } => { + let context = CwContext::new(deps_mut, _env); + let mut client = IconClient::new(context); + let header_any = Any::decode(signed_header.as_slice()).unwrap(); + let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; + let update = client.update_client(info.sender, &client_id, header)?; + let response_data = to_binary(&UpdateClientResponse { + height: to_ibc_height(update.height).map(|h| h.to_string())?, + client_id, + client_state_commitment: update.client_state_commitment.to_vec(), + consensus_state_commitment: update.consensus_state_commitment.to_vec(), + client_state_bytes: ClientState::any_from_value(&update.client_state_bytes) + .encode_to_vec(), + consensus_state_bytes: ConsensusState::any_from_value( + &update.consensus_state_bytes, + ) + .encode_to_vec(), + }) + .map_err(ContractError::Std)?; + Ok(Response::new() + .add_attribute( + CLIENT_STATE_HASH, + hex::encode(update.client_state_commitment), + ) + .add_attribute( + CONSENSUS_STATE_HASH, + hex::encode(update.consensus_state_commitment), + ) + .add_attribute(HEIGHT, update.height.to_string()) + .set_data(response_data)) + } + ExecuteMsg::Misbehaviour { + client_id: _, + misbehaviour: _, + } => { + todo!() + } + + ExecuteMsg::UpgradeClient { + upgraded_client_state: _, + upgraded_consensus_state: _, + proof_upgrade_client: _, + proof_upgrade_consensus_state: _, + } => { + todo!() + } + } +} + +pub fn validate_channel_state( + client_id: &str, + deps: Deps, + state: &VerifyChannelState, +) -> Result { + let proofs_decoded = + MerkleProofs::decode(state.proof.as_slice()).map_err(ContractError::DecodeError)?; + let height = to_height_u64(&state.proof_height)?; + let result = QueryHandler::verify_membership( + deps, + client_id, + height, + 0, + 0, + &proofs_decoded.proofs, + &state.expected_counterparty_channel_end, + &state.counterparty_chan_end_path, + )?; + Ok(result) +} + +pub fn validate_connection_state( + client_id: &str, + deps: Deps, + state: &VerifyConnectionState, +) -> Result { + let proofs_decoded = + MerkleProofs::decode(state.proof.as_slice()).map_err(ContractError::DecodeError)?; + let height = to_height_u64(&state.proof_height)?; + + let result = QueryHandler::verify_membership( + deps, + client_id, + height, + 0, + 0, + &proofs_decoded.proofs, + &state.expected_counterparty_connection_end, + &state.counterparty_conn_end_path, + )?; + Ok(result) +} + +pub fn validate_client_state( + client_id: &str, + deps: Deps, + state: &VerifyClientFullState, +) -> Result { + let proofs_decoded = MerkleProofs::decode(state.client_state_proof.as_slice()) + .map_err(ContractError::DecodeError)?; + println!("starting validating client state"); + let height = to_height_u64(&state.proof_height)?; + let result = QueryHandler::verify_membership( + deps, + client_id, + height, + 0, + 0, + &proofs_decoded.proofs, + &state.expected_client_state, + &state.client_state_path, + )?; + Ok(result) +} + +pub fn validate_consensus_state( + client_id: &str, + deps: Deps, + state: &VerifyClientConsensusState, +) -> Result { + let proofs_decoded = MerkleProofs::decode(state.consensus_state_proof.as_slice()) + .map_err(ContractError::DecodeError)?; + let height = to_height_u64(&state.proof_height)?; + let result = QueryHandler::verify_membership( + deps, + client_id, + height, + 0, + 0, + &proofs_decoded.proofs, + &state.expected_conesenus_state, + &state.conesenus_state_path, + )?; + Ok(result) +} + +pub fn validate_next_seq_recv( + deps: Deps, + client_id: &str, + state: &LightClientPacketMessage, +) -> Result { + let result = match state { + LightClientPacketMessage::VerifyNextSequenceRecv { + height, + prefix: _, + proof, + root: _, + seq_recv_path, + sequence, + } => { + let proofs_decoded = + MerkleProofs::decode(proof.as_slice()).map_err(ContractError::DecodeError)?; + let height = to_height_u64(height)?; + + QueryHandler::verify_membership( + deps, + client_id, + height, + 0, + 0, + &proofs_decoded.proofs, + sequence.to_be_bytes().as_ref(), + seq_recv_path, + )? + } + LightClientPacketMessage::VerifyPacketReceiptAbsence { + height, + prefix: _, + proof, + root: _, + receipt_path, + } => { + let proofs_decoded = + MerkleProofs::decode(proof.as_slice()).map_err(ContractError::DecodeError)?; + let height = to_height_u64(height)?; + + QueryHandler::verify_non_membership( + deps, + client_id, + height, + 0, + 0, + &proofs_decoded.proofs, + receipt_path, + )? + } + }; + Ok(result) +} + +fn to_height_u64(height: &str) -> Result { + let heights = height.split('-').collect::>(); + if heights.len() != 2 { + return Err(ContractError::InvalidHeight); + } + heights[1] + .parse::() + .map_err(|_e| ContractError::InvalidHeight) +} + +fn to_ibc_height(height: u64) -> Result { + IbcHeight::new(0, height).map_err(|_e| ContractError::InvalidHeight) +} + +pub fn any_from_byte(bytes: &[u8]) -> Result { + let any = Any::decode(bytes).map_err(ContractError::DecodeError)?; + Ok(any) +} + +// pub fn to_packet_response(packet_data: &[u8]) -> Result { +// let packet_data: PacketData = from_slice(packet_data).map_err(ContractError::Std)?; +// let data = to_binary(&PacketDataResponse::from(packet_data)).map_err(ContractError::Std)?; +// Ok(data) +// } + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::GetClientState { client_id } => { + let res = QueryHandler::get_client_state_any(deps.storage, &client_id).unwrap(); + to_binary(&res) + } + QueryMsg::GetConsensusState { client_id, height } => to_binary( + &QueryHandler::get_consensus_state_any(deps.storage, &client_id, height).unwrap(), + ), + + QueryMsg::GetLatestHeight { client_id } => { + to_binary(&QueryHandler::get_latest_height(deps.storage, &client_id).unwrap()) + } + QueryMsg::VerifyMembership { + client_id, + message_bytes, + proofs, + path, + height, + delay_time_period, + delay_block_period, + } => { + let proofs_decoded = MerkleProofs::decode(proofs.as_slice()) + .map_err(|e| StdError::GenericErr { msg: e.to_string() })?; + let result = QueryHandler::verify_membership( + deps, + &client_id, + height, + delay_time_period, + delay_block_period, + &proofs_decoded.proofs, + &message_bytes, + &path, + ) + .unwrap_or(false); + to_binary(&result) + } + QueryMsg::VerifyNonMembership { + client_id, + + proofs, + path, + height, + delay_time_period, + delay_block_period, + } => { + let proofs_decoded = MerkleProofs::decode(proofs.as_slice()) + .map_err(|e| StdError::GenericErr { msg: e.to_string() })?; + let result = QueryHandler::verify_non_membership( + deps, + &client_id, + height, + delay_time_period, + delay_block_period, + &proofs_decoded.proofs, + &path, + ) + .unwrap_or(false); + to_binary(&result) + } + QueryMsg::VerifyPacketData { + client_id, + verify_packet_data, + // packet_data, + } => { + let proofs_decoded = MerkleProofs::decode(verify_packet_data.proof.as_slice()) + .map_err(|e| StdError::GenericErr { msg: e.to_string() })?; + let height = to_height_u64(&verify_packet_data.height).unwrap(); + let result = QueryHandler::verify_membership( + deps, + &client_id, + height, + 0, + 0, + &proofs_decoded.proofs, + &verify_packet_data.commitment, + &verify_packet_data.commitment_path, + ) + .unwrap_or(false); + + to_binary(&result) + } + QueryMsg::VerifyPacketAcknowledgement { + client_id, + verify_packet_acknowledge, + // packet_data, + } => { + let proofs_decoded = MerkleProofs::decode(verify_packet_acknowledge.proof.as_slice()) + .map_err(|e| StdError::GenericErr { msg: e.to_string() })?; + let height = to_height_u64(&verify_packet_acknowledge.height).unwrap(); + let result = QueryHandler::verify_membership( + deps, + &client_id, + height, + 0, + 0, + &proofs_decoded.proofs, + &verify_packet_acknowledge.ack, + &verify_packet_acknowledge.ack_path, + ) + .unwrap_or(false); + + to_binary(&result) + } + QueryMsg::VerifyOpenConfirm { + client_id, + verify_connection_state, + // expected_response, + } => { + let result = validate_connection_state(&client_id, deps, &verify_connection_state) + .unwrap_or(false); + to_binary(&result) + } + QueryMsg::VerifyConnectionOpenTry(state) => { + println!("checking all the valid state "); + let client_valid = + validate_client_state(&state.client_id, deps, &state.verify_client_full_state) + .unwrap_or(false); + println!(" is valid clientstate {client_valid:?}"); + + let connection_valid = + validate_connection_state(&state.client_id, deps, &state.verify_connection_state) + .unwrap_or(false); + to_binary(&(client_valid && connection_valid)) + } + QueryMsg::VerifyConnectionOpenAck(state) => { + let connection_valid = + validate_connection_state(&state.client_id, deps, &state.verify_connection_state) + .unwrap(); + let client_valid = + validate_client_state(&state.client_id, deps, &state.verify_client_full_state) + .unwrap(); + + to_binary(&(client_valid && connection_valid)) + } + + QueryMsg::VerifyChannel { + verify_channel_state, + // message_info, + // endpoint, + } => { + // fix once we receive client id + let result = validate_channel_state( + &verify_channel_state.client_id, + deps, + &verify_channel_state, + ) + .unwrap(); + + to_binary(&result) + } + QueryMsg::PacketTimeout { + client_id, + next_seq_recv_verification_result, + } => { + let _sequence_valid = + validate_next_seq_recv(deps, &client_id, &next_seq_recv_verification_result) + .unwrap(); + to_binary(&_sequence_valid) + } + QueryMsg::TimeoutOnCLose { + client_id, + verify_channel_state, + next_seq_recv_verification_result, + } => { + let is_channel_valid = + validate_channel_state(&client_id, deps, &verify_channel_state).unwrap(); + let _sequence_valid = + validate_next_seq_recv(deps, &client_id, &next_seq_recv_verification_result) + .unwrap(); + + to_binary(&(is_channel_valid && _sequence_valid)) + } + QueryMsg::GetPreviousConsensusState { client_id, height } => { + let res: Vec = + QueryHandler::get_previous_consensus(deps.storage, height, client_id).unwrap(); + to_binary(&res) + } + QueryMsg::GetTimestampAtHeight { + client_id: _, + height: _, + } => to_binary(&0_u64), + QueryMsg::GetLatestConsensusState { client_id } => { + let res = QueryHandler::get_latest_consensus_state(deps.storage, &client_id).unwrap(); + to_binary(&res) + } + } +} + +#[cw_serde] +pub struct MigrateMsg {} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION) + .map_err(ContractError::Std)?; + Ok(Response::default().add_attribute("migrate", "successful")) +} + +pub fn get_light_client(context: CwContext<'_>) -> impl ILightClient + '_ { + #[cfg(feature = "mock")] + return MockClient::new(context); + #[cfg(not(feature = "mock"))] + return IconClient::new(context); +} + +pub fn ensure_owner(deps: Deps, info: &MessageInfo) -> Result<(), ContractError> { + let config = QueryHandler::get_config(deps.storage)?; + if info.sender != config.owner { + return Err(ContractError::Unauthorized {}); + } + Ok(()) +} + diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs new file mode 100644 index 000000000..d84534b15 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs @@ -0,0 +1,213 @@ +// Copyright (C) 2022 ComposableFi. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[cfg(feature = "cosmwasm")] +use crate::msg::Base64; +use crate::Bytes; +use alloc::{ + boxed::Box, + string::{String, ToString}, + vec::Vec, +}; +use core::fmt::Display; +#[cfg(feature = "cosmwasm")] +use cosmwasm_schema::cw_serde; +use common::ibc::{ + core::ics02_client::{client_message::ClientMessage as IbcClientMessage, error::Error}, + protobuf::Protobuf, + Height, +}; +use ibc_proto::{ + google::protobuf::Any, + ibc::wasm::v1::{Header as RawHeader, Misbehaviour as RawMisbehaviour}, +}; +use prost::Message; + +pub const WASM_HEADER_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.Header"; +pub const WASM_MISBEHAVIOUR_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.Misbehaviour"; +pub const WASM_CLIENT_MESSAGE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.ClientMessage"; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ClientMessage { + Header(Header), + Misbehaviour(Misbehaviour), +} + +impl ClientMessage { + pub fn inner(&self) -> &AnyClientMessage { + match self { + ClientMessage::Header(h) => &h.inner, + ClientMessage::Misbehaviour(m) => &m.inner, + } + } + + pub fn into_inner(self) -> AnyClientMessage { + match self { + ClientMessage::Header(h) => *h.inner, + ClientMessage::Misbehaviour(m) => *m.inner, + } + } +} + +impl IbcClientMessage for ClientMessage +where + AnyClientMessage: IbcClientMessage, + AnyClientMessage: TryFrom, + >::Error: Display, +{ + fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { + self.encode_vec() + } +} + +impl Protobuf for ClientMessage +where + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, +{ +} + +impl TryFrom for ClientMessage +where + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, +{ + type Error = Error; + + fn try_from(any: Any) -> Result { + let msg = match &*any.type_url { + WASM_HEADER_TYPE_URL => + Self::Header(Header::decode(&*any.value).map_err(Error::decode_raw_header)?), + WASM_MISBEHAVIOUR_TYPE_URL => Self::Misbehaviour( + Misbehaviour::decode(&*any.value).map_err(Error::decode_raw_misbehaviour)?, + ), + _ => return Err(Error::malformed_header()), // TODO: choose a better error + }; + + Ok(msg) + } +} + +impl From> for Any +where + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, +{ + fn from(msg: ClientMessage) -> Self { + match msg { + ClientMessage::Header(header) => Any { + value: header.encode_vec().expect("encode header"), + type_url: WASM_HEADER_TYPE_URL.to_string(), + }, + ClientMessage::Misbehaviour(misbheaviour) => Any { + value: misbheaviour.encode_vec().expect("encode misbehaviour"), + type_url: WASM_MISBEHAVIOUR_TYPE_URL.to_string(), + }, + } + } +} + +impl Protobuf for Misbehaviour +where + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, +{ +} + +impl TryFrom for Misbehaviour +where + AnyClientMessage: TryFrom, + >::Error: Display, +{ + type Error = String; + + fn try_from(raw: RawMisbehaviour) -> Result { + let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; + let inner = AnyClientMessage::try_from(any).map_err(|e| e.to_string())?; + Ok(Self { inner: Box::new(inner), data: raw.data }) + } +} + +impl Protobuf for Header +where + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, +{ +} + +impl TryFrom for Header +where + AnyClientMessage: TryFrom, + >::Error: Display, +{ + type Error = String; + + fn try_from(raw: RawHeader) -> Result { + let any = Any::decode(&mut &raw.data[..]) + .map_err(|e| format!("failed to decode raw header into Any: {e}"))?; + let inner = AnyClientMessage::try_from(any) + .map_err(|e| format!("failed to decode raw header into AnyClientMessage: {e}"))?; + + let header = Self { + inner: Box::new(inner), + data: raw.data, + height: raw + .height + .ok_or_else(|| { + "failed to decode raw header into Header: missing height".to_string() + })? + .into(), + }; + Ok(header) + } +} + +#[cfg_attr(feature = "cosmwasm", cw_serde)] +#[cfg_attr(not(feature = "cosmwasm"), derive(Clone, Debug, PartialEq))] +#[derive(Eq)] +pub struct Header { + #[cfg_attr(feature = "cosmwasm", serde(skip))] + #[cfg_attr(feature = "cosmwasm", schemars(skip))] + pub inner: Box, + #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] + #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] + pub data: Bytes, + pub height: Height, +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Misbehaviour { + // #[schemars(with = "String")] + // #[serde(with = "Base64", default)] + pub inner: Box, + pub data: Bytes, +} + +impl From> for RawMisbehaviour { + fn from(value: Misbehaviour) -> Self { + RawMisbehaviour { data: value.data } + } +} + +impl From> for RawHeader { + fn from(value: Header) -> Self { + RawHeader { data: value.data, height: Some(value.height.into()) } + } +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs new file mode 100644 index 000000000..03f6910b4 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs @@ -0,0 +1,204 @@ +// Copyright (C) 2022 ComposableFi. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[cfg(feature = "cosmwasm")] +use crate::msg::Base64; +use crate::{client_def::WasmClient, Bytes}; +use alloc::{ + boxed::Box, + string::{String, ToString}, + vec::Vec, +}; +use core::{ + fmt::{Debug, Display}, + marker::PhantomData, + time::Duration, +}; +#[cfg(feature = "cosmwasm")] +use cosmwasm_schema::cw_serde; +use ibc::{ + core::{ + ics02_client::{ + client_consensus::ConsensusState as IbcConsensusState, client_def::ClientDef, + client_state::ClientState as IbcClientState, + }, + ics24_host::identifier::ChainId, + }, + protobuf::Protobuf, + Height, +}; +use ibc_proto::{ + google::protobuf::Any, ibc::lightclients::wasm::v1::ClientState as RawClientState, +}; +use prost::Message; + +pub const WASM_CLIENT_STATE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.ClientState"; + +#[cfg_attr(feature = "cosmwasm", cw_serde)] +#[cfg_attr(not(feature = "cosmwasm"), derive(Clone, Debug, PartialEq))] +#[derive(Eq)] +pub struct ClientState { + #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] + #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] + pub data: Bytes, + #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] + #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] + pub code_id: Bytes, + pub latest_height: Height, + #[cfg_attr(feature = "cosmwasm", serde(skip))] + #[cfg_attr(feature = "cosmwasm", schemars(skip))] + pub inner: Box, + #[cfg_attr(feature = "cosmwasm", serde(skip))] + #[cfg_attr(feature = "cosmwasm", schemars(skip))] + pub _phantom: PhantomData<(AnyConsensusState, AnyClient)>, +} + +impl IbcClientState + for ClientState +where + AnyClientState: TryFrom, + >::Error: Display, + AnyConsensusState: IbcConsensusState + Eq, + AnyConsensusState: TryFrom, + >::Error: Display, + AnyClient: ClientDef + + Debug + + Send + + Sync + + Eq, + AnyClientState: IbcClientState + Eq, + AnyClient::ClientMessage: TryFrom, + >::Error: Display, +{ + type UpgradeOptions = Box; + type ClientDef = WasmClient; + + fn chain_id(&self) -> ChainId { + // self.inner.chain_id() + self.inner.chain_id() + } + + fn client_def(&self) -> Self::ClientDef { + let inner = self.inner.client_def(); + WasmClient { inner: Box::new(inner), _phantom: Default::default() } + } + + fn client_type(&self) -> String { + "08-wasm".to_string() + } + + fn latest_height(&self) -> Height { + self.latest_height + } + + fn frozen_height(&self) -> Option { + self.inner.frozen_height() + } + + fn upgrade( + self, + upgrade_height: Height, + upgrade_options: Self::UpgradeOptions, + chain_id: ChainId, + ) -> Self { + let inner = self.inner.upgrade(upgrade_height, *upgrade_options, chain_id); + Self { inner: Box::new(inner), ..self } + } + + fn expired(&self, elapsed: Duration) -> bool { + self.inner.expired(elapsed) + } + + fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { + self.encode_vec() + } +} + +impl + ClientState +where + AnyClientState: TryFrom, + >::Error: Display, + AnyConsensusState: IbcConsensusState + Eq, + AnyConsensusState: TryFrom, + >::Error: Display, + AnyClient: ClientDef + + Debug + + Send + + Sync + + Eq, + AnyClientState: IbcClientState + Eq, + AnyClient::ClientMessage: TryFrom, + >::Error: Display, +{ + pub fn to_any(&self) -> Any { + Any { + type_url: WASM_CLIENT_STATE_TYPE_URL.to_string(), + value: self + .encode_to_vec() + .expect("ClientState is always valid and can be encoded to Any"), + } + } +} + +impl TryFrom + for ClientState +where + AnyClientState: TryFrom, + >::Error: Display, +{ + type Error = String; + + fn try_from(raw: RawClientState) -> Result { + let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; + let inner = AnyClientState::try_from(any).map_err(|e| e.to_string())?; + Ok(Self { + data: raw.data, + code_id: raw.code_id, + inner: Box::new(inner), + latest_height: raw + .latest_height + .map(|h| Height::new(h.revision_number, h.revision_height)) + .unwrap_or_default(), + _phantom: Default::default(), + }) + } +} + +impl + From> for RawClientState +where + AnyClientState: TryFrom, + >::Error: Display, +{ + fn from(client_state: ClientState) -> Self { + Self { + data: client_state.data, + code_id: client_state.code_id, + latest_height: Some(client_state.latest_height.into()), + } + } +} + +impl Protobuf + for ClientState +where + AnyClientState: Clone, + AnyClientState: TryFrom, + >::Error: Display, + AnyConsensusState: Clone, + AnyClient: Clone, +{ +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs new file mode 100644 index 000000000..42dd961f9 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs @@ -0,0 +1,124 @@ +// Copyright (C) 2022 ComposableFi. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[cfg(feature = "cosmwasm")] +use crate::msg::Base64; +use crate::Bytes; +use alloc::{ + boxed::Box, + string::{String, ToString}, + vec::Vec, +}; +use core::{ + convert::Infallible, + fmt::{Debug, Display}, +}; +#[cfg(feature = "cosmwasm")] +use cosmwasm_schema::cw_serde; +use ibc::{ + core::{ + ics02_client::client_consensus::ConsensusState as IbcConsensusState, + ics23_commitment::commitment::CommitmentRoot, + }, + protobuf::Protobuf, + timestamp::Timestamp, +}; +use ibc_proto::{ + google::protobuf::Any, ibc::lightclients::wasm::v1::ConsensusState as RawConsensusState, +}; +use prost::Message; + +pub const WASM_CONSENSUS_STATE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.ConsensusState"; + +#[cfg_attr(feature = "cosmwasm", cw_serde)] +#[cfg_attr(not(feature = "cosmwasm"), derive(Clone, Debug, PartialEq))] +#[derive(Eq)] +pub struct ConsensusState { + #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] + #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] + pub data: Bytes, + pub timestamp: u64, + #[cfg_attr(feature = "cosmwasm", serde(skip))] + #[cfg_attr(feature = "cosmwasm", schemars(skip))] + pub inner: Box, +} + +impl IbcConsensusState for ConsensusState +where + AnyConsensusState: Clone + Debug + Send + Sync, + AnyConsensusState: TryFrom, + >::Error: Display, +{ + type Error = Infallible; + + fn root(&self) -> &CommitmentRoot { + unimplemented!() + } + + fn timestamp(&self) -> Timestamp { + Timestamp::from_nanoseconds(self.timestamp).expect("timestamp is valid") + } + + fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { + self.encode_vec() + } +} + +impl ConsensusState +where + AnyConsensusState: Clone + Debug + Send + Sync, + AnyConsensusState: TryFrom + IbcConsensusState, + >::Error: Display, +{ + pub fn to_any(&self) -> Any { + Any { + type_url: WASM_CONSENSUS_STATE_TYPE_URL.to_string(), + value: self.encode_to_vec().expect( + "ConsensusState is always valid and can be encoded to Any", + ), + } + } +} + +impl TryFrom for ConsensusState +where + AnyConsensusState: TryFrom, + >::Error: Display, +{ + type Error = String; + + fn try_from(raw: RawConsensusState) -> Result { + let any = Any::decode(&mut &raw.data[..]) + .map_err(|e| format!("failed to decode ConsensusState::data into Any: {e}"))?; + let inner = AnyConsensusState::try_from(any).map_err(|e| { + format!("failed to decode ConsensusState::data into ConsensusState: {e}") + })?; + Ok(Self { data: raw.data, timestamp: raw.timestamp, inner: Box::new(inner) }) + } +} + +impl From> for RawConsensusState { + fn from(value: ConsensusState) -> Self { + Self { data: value.data, timestamp: value.timestamp } + } +} + +impl Protobuf for ConsensusState +where + AnyConsensusState: Clone, + AnyConsensusState: TryFrom, + >::Error: Display, +{ +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs new file mode 100644 index 000000000..8170c0794 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs @@ -0,0 +1,3 @@ +pub mod client_message; +pub mod client_state; +pub mod consensus_state; \ No newline at end of file diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs new file mode 100644 index 000000000..ff3e5eaee --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs @@ -0,0 +1,11 @@ +pub use cw_light_client_common::constants; +pub mod contract; +// mod msg; +// mod ics08_wasm; + +pub use cw_light_client_common::light_client; +pub use cw_light_client_common::query_handler; +pub use cw_light_client_common::state; +pub use cw_light_client_common::traits; + +pub use cw_light_client_common::error::ContractError; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs new file mode 100644 index 000000000..7229c591b --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -0,0 +1,360 @@ +// Copyright (C) 2022 ComposableFi. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// use crate::{contract::HostFunctions, ics23::FakeInner, Bytes, ContractError}; +use core::{str::FromStr, time::Duration}; +use cosmwasm_schema::cw_serde; +use common::ibc::{ + core::{ + ics02_client::trust_threshold::TrustThreshold, + ics23_commitment::commitment::{CommitmentPrefix, CommitmentProofBytes}, + ics24_host::Path, + }, + protobuf::Protobuf, + Height, +}; +use cw_light_client_common::ContractError; +use ibc_proto::{google::protobuf::Any}; +use ics07_tendermint::{ + client_message::{ClientMessage, Header, Misbehaviour}, + client_state::ClientState, +}; +// use ics08_wasm::{ +// client_message::Header as WasmHeader, client_state::ClientState as WasmClientState, +// consensus_state::ConsensusState as WasmConsensusState, +// }; +use prost::Message; +use serde::{Deserializer, Serializer}; + +#[cw_serde] +pub struct HeightRaw { + pub revision_number: u64, + + pub revision_height: u64, +} + +struct Base64; + +impl Base64 { + pub fn serialize(v: &[u8], serializer: S) -> Result { + ibc_proto::base64::serialize(v, serializer) + } + + pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result, D::Error> { + ibc_proto::base64::deserialize(deserializer) + } +} + +#[cw_serde] +pub struct GenesisMetadata { + pub key: Vec, + pub value: Vec, +} + +#[cw_serde] +pub struct QueryResponse { + pub status: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub genesis_metadata: Option>, +} + +impl QueryResponse { + pub fn status(status: String) -> Self { + Self { status, genesis_metadata: None } + } + + pub fn genesis_metadata(genesis_metadata: Option>) -> Self { + Self { status: "".to_string(), genesis_metadata } + } +} + +#[cw_serde] +pub struct ContractResult { + pub is_valid: bool, + pub error_msg: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub data: Option>, + pub found_misbehaviour: bool, +} + +impl ContractResult { + pub fn success() -> Self { + Self { is_valid: true, error_msg: "".to_string(), data: None, found_misbehaviour: false } + } + + pub fn error(msg: String) -> Self { + Self { is_valid: false, error_msg: msg, data: None, found_misbehaviour: false } + } + + pub fn misbehaviour(mut self, found: bool) -> Self { + self.found_misbehaviour = found; + self + } + + pub fn data(mut self, data: Vec) -> Self { + self.data = Some(data); + self + } +} + +#[cw_serde] +pub struct InstantiateMsg {} + +#[cw_serde] +pub enum ExecuteMsg { + VerifyMembership(VerifyMembershipMsgRaw), + VerifyNonMembership(VerifyNonMembershipMsgRaw), + VerifyClientMessage(VerifyClientMessageRaw), + CheckForMisbehaviour(CheckForMisbehaviourMsgRaw), + UpdateStateOnMisbehaviour(UpdateStateOnMisbehaviourMsgRaw), + UpdateState(UpdateStateMsgRaw), + CheckSubstituteAndUpdateState(CheckSubstituteAndUpdateStateMsg), + VerifyUpgradeAndUpdateState(VerifyUpgradeAndUpdateStateMsgRaw), +} + +#[cw_serde] +pub enum QueryMsg { + ClientTypeMsg(ClientTypeMsg), + GetLatestHeightsMsg(GetLatestHeightsMsg), + ExportMetadata(ExportMetadataMsg), + Status(StatusMsg), +} + +#[cw_serde] +pub struct ClientTypeMsg {} + +#[cw_serde] +pub struct GetLatestHeightsMsg {} + +#[cw_serde] +pub struct StatusMsg {} + +#[cw_serde] +pub struct ExportMetadataMsg {} + +#[cw_serde] +pub struct MerklePath { + pub key_path: Vec, +} + +#[cw_serde] +pub struct VerifyMembershipMsgRaw { + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub proof: Vec, + pub path: MerklePath, + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub value: Vec, + pub height: HeightRaw, + pub delay_block_period: u64, + pub delay_time_period: u64, +} + +// pub struct VerifyMembershipMsg { +// pub prefix: CommitmentPrefix, +// pub proof: CommitmentProofBytes, +// pub path: Path, +// pub value: Vec, +// pub height: Height, +// pub delay_block_period: u64, +// pub delay_time_period: u64, +// } + +// impl TryFrom for VerifyMembershipMsg { +// type Error = ContractError; + +// fn try_from(mut raw: VerifyMembershipMsgRaw) -> Result { +// let proof = CommitmentProofBytes::try_from(raw.proof)?; +// let prefix = raw.path.key_path.remove(0).into_bytes(); +// let path_str = raw.path.key_path.join(""); +// let path = Path::from_str(&path_str)?; +// let height = Height::from(raw.height); +// Ok(Self { +// proof, +// path, +// value: raw.value, +// height, +// prefix: CommitmentPrefix::try_from(prefix)?, +// delay_block_period: raw.delay_block_period, +// delay_time_period: raw.delay_time_period, +// }) +// } +// } + +#[cw_serde] +pub struct VerifyNonMembershipMsgRaw { + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub proof: Vec, + pub path: MerklePath, + pub height: HeightRaw, + pub delay_block_period: u64, + pub delay_time_period: u64, +} + +// pub struct VerifyNonMembershipMsg { +// pub prefix: CommitmentPrefix, +// pub proof: CommitmentProofBytes, +// pub path: Path, +// pub height: Height, +// pub delay_block_period: u64, +// pub delay_time_period: u64, +// } + +// impl TryFrom for VerifyNonMembershipMsg { +// type Error = ContractError; + +// fn try_from(mut raw: VerifyNonMembershipMsgRaw) -> Result { +// let proof = CommitmentProofBytes::try_from(raw.proof)?; +// let prefix = raw.path.key_path.remove(0).into_bytes(); +// let path_str = raw.path.key_path.join(""); +// let path = Path::from_str(&path_str)?; +// let height = Height::from(raw.height); +// Ok(Self { +// proof, +// path, +// height, +// prefix: CommitmentPrefix::try_from(prefix)?, +// delay_block_period: raw.delay_block_period, +// delay_time_period: raw.delay_time_period, +// }) +// } +// } + +#[cw_serde] +pub struct WasmMisbehaviour { + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub data: Vec, +} + +#[cw_serde] +pub enum ClientMessageRaw { + Header(WasmHeader), + Misbehaviour(WasmMisbehaviour), +} + +#[cw_serde] +pub struct VerifyClientMessageRaw { + pub client_message: ClientMessageRaw, +} + +pub struct VerifyClientMessage { + pub client_message: ClientMessage, +} + +impl TryFrom for VerifyClientMessage { + type Error = ContractError; + + fn try_from(raw: VerifyClientMessageRaw) -> Result { + let client_message = Self::decode_client_message(raw.client_message)?; + Ok(Self { client_message }) + } +} + +impl VerifyClientMessage { + fn decode_client_message(raw: ClientMessageRaw) -> Result { + let client_message = match raw { + ClientMessageRaw::Header(header) => { + let any = Any::decode(&mut header.data.as_slice())?; + ClientMessage::Header(Header::decode_vec(&any.value)?) + }, + ClientMessageRaw::Misbehaviour(misbehaviour) => { + let any = Any::decode(&mut misbehaviour.data.as_slice())?; + ClientMessage::Misbehaviour(Misbehaviour::decode_vec(&any.value)?) + }, + }; + Ok(client_message) + } +} + +#[cw_serde] +pub struct CheckForMisbehaviourMsgRaw { + pub client_message: ClientMessageRaw, +} + +pub struct CheckForMisbehaviourMsg { + pub client_message: ClientMessage, +} + +impl TryFrom for CheckForMisbehaviourMsg { + type Error = ContractError; + + fn try_from(raw: CheckForMisbehaviourMsgRaw) -> Result { + let client_message = VerifyClientMessage::decode_client_message(raw.client_message)?; + Ok(Self { client_message }) + } +} + +#[cw_serde] +pub struct UpdateStateOnMisbehaviourMsgRaw { + pub client_message: ClientMessageRaw, +} + +pub struct UpdateStateOnMisbehaviourMsg { + pub client_message: ClientMessage, +} + +impl TryFrom for UpdateStateOnMisbehaviourMsg { + type Error = ContractError; + + fn try_from(raw: UpdateStateOnMisbehaviourMsgRaw) -> Result { + let client_message = VerifyClientMessage::decode_client_message(raw.client_message)?; + Ok(Self { client_message }) + } +} + +#[cw_serde] +pub struct UpdateStateMsgRaw { + pub client_message: ClientMessageRaw, +} + +pub struct UpdateStateMsg { + pub client_message: ClientMessage, +} + +impl TryFrom for UpdateStateMsg { + type Error = ContractError; + + fn try_from(raw: UpdateStateMsgRaw) -> Result { + let client_message = VerifyClientMessage::decode_client_message(raw.client_message)?; + Ok(Self { client_message }) + } +} + +#[cw_serde] +pub struct CheckSubstituteAndUpdateStateMsg {} + +#[cw_serde] +pub struct VerifyUpgradeAndUpdateStateMsgRaw { + pub upgrade_client_state: WasmClientState, + pub upgrade_consensus_state: WasmConsensusState, + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub proof_upgrade_client: Vec, + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub proof_upgrade_consensus_state: Vec, +} + +// pub struct VerifyUpgradeAndUpdateStateMsg { +// pub upgrade_client_state: WasmClientState, +// pub upgrade_consensus_state: WasmConsensusState, +// pub proof_upgrade_client: CommitmentProofBytes, +// pub proof_upgrade_consensus_state: CommitmentProofBytes, +// } + + diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs new file mode 100644 index 000000000..f5975dba3 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs @@ -0,0 +1,86 @@ +#[cfg(test)] +use cosmwasm_std::{ + coins, + testing::{ + mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage, + MOCK_CONTRACT_ADDR, + }, + Addr, BlockInfo, ContractInfo, Empty, Env, MessageInfo, OwnedDeps, Timestamp, TransactionInfo, +}; + +pub struct MockEnvBuilder { + env: Env, +} + +impl MockEnvBuilder { + pub fn new() -> MockEnvBuilder { + MockEnvBuilder { + env: Env { + block: BlockInfo { + height: 0, + time: Timestamp::from_nanos(0), + chain_id: "".to_string(), + }, + transaction: None, + contract: ContractInfo { + address: Addr::unchecked("input"), + }, + }, + } + } + pub fn add_block(mut self, block: BlockInfo) -> MockEnvBuilder { + self.env.block = block; + self + } + + pub fn add_txn_info(mut self, txn_info: Option) -> MockEnvBuilder { + self.env.transaction = txn_info; + self + } + + pub fn add_contract_info(mut self, contract_info: ContractInfo) -> MockEnvBuilder { + self.env.contract = contract_info; + self + } + + pub fn build(self) -> Env { + Env { + block: self.env.block, + transaction: self.env.transaction, + contract: self.env.contract, + } + } +} + +pub fn create_mock_info(creator: &str, denom: &str, amount: u128) -> MessageInfo { + let funds = coins(amount, denom); + mock_info(creator, &funds) +} + +pub fn deps() -> OwnedDeps { + mock_dependencies() +} + +#[test] +fn test() { + let mock = mock_env(); + + let block_info = BlockInfo { + height: 12_345, + time: Timestamp::from_nanos(1_571_797_419_879_305_533), + chain_id: "cosmos-testnet-14002".to_string(), + }; + + let transaction = Some(TransactionInfo { index: 3 }); + let contract = ContractInfo { + address: Addr::unchecked(MOCK_CONTRACT_ADDR), + }; + + let mock_env: Env = MockEnvBuilder::new() + .add_block(block_info) + .add_txn_info(transaction) + .add_contract_info(contract) + .build(); + + assert_eq!(mock, mock_env) +} diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/admin.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/admin.rs index 47ffb136a..57f38b880 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/admin.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/admin.rs @@ -46,7 +46,7 @@ impl<'a> CwIbcConnection<'a> { pub fn add_admin( &self, store: &mut dyn Storage, - info: MessageInfo, + _info: MessageInfo, admin: Addr, ) -> Result { self.admin().save(store, &admin)?; diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/send_message.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/send_message.rs index c6eab1861..868c70b4c 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/send_message.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/send_message.rs @@ -32,7 +32,7 @@ impl<'a> CwIbcConnection<'a> { let mut total_fee = network_fee.send_packet_fee; if sn > 0 { - total_fee = total_fee + network_fee.ack_fee; + total_fee += network_fee.ack_fee; self.add_unclaimed_ack_fees( deps.storage, &nid, diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_owner.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_owner.rs index e1013ceba..2d4bb0257 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_owner.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_owner.rs @@ -2,7 +2,6 @@ mod account; mod setup; use account::*; -use cosmwasm_std::Addr; use cw_xcall_ibc_connection::state::CwIbcConnection; use setup::*; #[test] @@ -40,6 +39,6 @@ fn add_existing_owner() { assert_eq!(result, mock_info.sender.to_string()); contract - .add_owner(mock_deps.as_mut().storage, mock_info.clone().sender) + .add_owner(mock_deps.as_mut().storage, mock_info.sender) .unwrap(); } diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_receive_packet.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_receive_packet.rs index 3e21ff8b4..81afdcb18 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_receive_packet.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_receive_packet.rs @@ -84,7 +84,7 @@ fn test_receive_packet_for_call_message_response() { let contract = CwIbcConnection::default(); contract - .add_owner(mock_deps.as_mut().storage, mock_info.clone().sender) + .add_owner(mock_deps.as_mut().storage, mock_info.sender) .unwrap(); contract diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_send_message.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_send_message.rs index 3dd9931c8..cd838398c 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_send_message.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_send_message.rs @@ -57,8 +57,8 @@ fn send_message_setup() -> ( contract .store_ibc_config( deps.as_mut().storage, - &nid.clone(), - &IbcConfig::new(src.clone(), dst.clone()), + &nid, + &IbcConfig::new(src.clone(), dst), ) .unwrap(); @@ -69,7 +69,7 @@ fn send_message_setup() -> ( let xcall_address = Addr::unchecked("xcalladdress"); contract - .set_xcall_host(deps.as_mut().storage, xcall_address.clone()) + .set_xcall_host(deps.as_mut().storage, xcall_address) .unwrap(); contract @@ -163,7 +163,7 @@ fn send_message_with_negative_sn() { }; let timeout = IbcTimeout::with_block(timeout_block); - let packet = IbcPacket::new(vec![], src.clone(), dst.clone(), 0, timeout); + let packet = IbcPacket::new(vec![], src.clone(), dst, 0, timeout); contract .store_incoming_packet(deps.as_mut().storage, &src.channel_id, 1, packet) diff --git a/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs b/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs index f2500f260..3355dc1e7 100644 --- a/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs +++ b/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs @@ -12,7 +12,7 @@ use ics23::{ use crate::ibc::core::ics23_commitment::commitment::{CommitmentPrefix, CommitmentRoot}; use crate::ibc::core::ics23_commitment::error::CommitmentError; -use crate::ibc::core::ics23_commitment::specs::ProofSpecs; +// use crate::ibc::core::ics23_commitment::specs::ProofSpecs; pub fn apply_prefix(prefix: &CommitmentPrefix, mut path: Vec) -> MerklePath { let mut key_path: Vec = vec![format!("{prefix:?}")]; @@ -67,140 +67,140 @@ impl From for RawMerkleProof { } } -impl MerkleProof { - pub fn verify_membership( - &self, - specs: &ProofSpecs, - root: MerkleRoot, - keys: MerklePath, - value: Vec, - start_index: usize, - ) -> Result<(), CommitmentError> { - // validate arguments - if self.proofs.is_empty() { - return Err(CommitmentError::EmptyMerkleProof); - } - if root.hash.is_empty() { - return Err(CommitmentError::EmptyMerkleRoot); - } - let num = self.proofs.len(); - let ics23_specs = Vec::::from(specs.clone()); - if ics23_specs.len() != num { - return Err(CommitmentError::NumberOfSpecsMismatch); - } - if keys.key_path.len() != num { - return Err(CommitmentError::NumberOfKeysMismatch); - } - if value.is_empty() { - return Err(CommitmentError::EmptyVerifiedValue); - } +// impl MerkleProof { +// pub fn verify_membership( +// &self, +// specs: &ProofSpecs, +// root: MerkleRoot, +// keys: MerklePath, +// value: Vec, +// start_index: usize, +// ) -> Result<(), CommitmentError> { +// // validate arguments +// if self.proofs.is_empty() { +// return Err(CommitmentError::EmptyMerkleProof); +// } +// if root.hash.is_empty() { +// return Err(CommitmentError::EmptyMerkleRoot); +// } +// let num = self.proofs.len(); +// let ics23_specs = Vec::::from(specs.clone()); +// if ics23_specs.len() != num { +// return Err(CommitmentError::NumberOfSpecsMismatch); +// } +// if keys.key_path.len() != num { +// return Err(CommitmentError::NumberOfKeysMismatch); +// } +// if value.is_empty() { +// return Err(CommitmentError::EmptyVerifiedValue); +// } - let mut subroot = value.clone(); - let mut value = value; - // keys are represented from root-to-leaf - for ((proof, spec), key) in self - .proofs - .iter() - .zip(ics23_specs.iter()) - .zip(keys.key_path.iter().rev()) - .skip(start_index) - { - match &proof.proof { - Some(Proof::Exist(existence_proof)) => { - subroot = - calculate_existence_root::(existence_proof) - .map_err(|_| CommitmentError::InvalidMerkleProof)?; +// let mut subroot = value.clone(); +// let mut value = value; +// // keys are represented from root-to-leaf +// for ((proof, spec), key) in self +// .proofs +// .iter() +// .zip(ics23_specs.iter()) +// .zip(keys.key_path.iter().rev()) +// .skip(start_index) +// { +// match &proof.proof { +// Some(Proof::Exist(existence_proof)) => { +// subroot = +// calculate_existence_root::(existence_proof) +// .map_err(|_| CommitmentError::InvalidMerkleProof)?; - if !verify_membership::( - proof, - spec, - &subroot, - key.as_bytes(), - &value, - ) { - return Err(CommitmentError::VerificationFailure); - } - value = subroot.clone(); - } - _ => return Err(CommitmentError::InvalidMerkleProof), - } - } +// if !verify_membership::( +// proof, +// spec, +// &subroot, +// key.as_bytes(), +// &value, +// ) { +// return Err(CommitmentError::VerificationFailure); +// } +// value = subroot.clone(); +// } +// _ => return Err(CommitmentError::InvalidMerkleProof), +// } +// } - if root.hash != subroot { - return Err(CommitmentError::VerificationFailure); - } +// if root.hash != subroot { +// return Err(CommitmentError::VerificationFailure); +// } - Ok(()) - } +// Ok(()) +// } - pub fn verify_non_membership( - &self, - specs: &ProofSpecs, - root: MerkleRoot, - keys: MerklePath, - ) -> Result<(), CommitmentError> { - // validate arguments - if self.proofs.is_empty() { - return Err(CommitmentError::EmptyMerkleProof); - } - if root.hash.is_empty() { - return Err(CommitmentError::EmptyMerkleRoot); - } - let num = self.proofs.len(); - let ics23_specs = Vec::::from(specs.clone()); - if ics23_specs.len() != num { - return Err(CommitmentError::NumberOfSpecsMismatch); - } - if keys.key_path.len() != num { - return Err(CommitmentError::NumberOfKeysMismatch); - } +// pub fn verify_non_membership( +// &self, +// specs: &ProofSpecs, +// root: MerkleRoot, +// keys: MerklePath, +// ) -> Result<(), CommitmentError> { +// // validate arguments +// if self.proofs.is_empty() { +// return Err(CommitmentError::EmptyMerkleProof); +// } +// if root.hash.is_empty() { +// return Err(CommitmentError::EmptyMerkleRoot); +// } +// let num = self.proofs.len(); +// let ics23_specs = Vec::::from(specs.clone()); +// if ics23_specs.len() != num { +// return Err(CommitmentError::NumberOfSpecsMismatch); +// } +// if keys.key_path.len() != num { +// return Err(CommitmentError::NumberOfKeysMismatch); +// } - // verify the absence of key in lowest subtree - let proof = self - .proofs - .get(0) - .ok_or(CommitmentError::InvalidMerkleProof)?; - let spec = ics23_specs - .get(0) - .ok_or(CommitmentError::InvalidMerkleProof)?; - // keys are represented from root-to-leaf - let key = keys - .key_path - .get(num - 1) - .ok_or(CommitmentError::InvalidMerkleProof)?; - match &proof.proof { - Some(Proof::Nonexist(non_existence_proof)) => { - let subroot = calculate_non_existence_root(non_existence_proof)?; +// // verify the absence of key in lowest subtree +// let proof = self +// .proofs +// .get(0) +// .ok_or(CommitmentError::InvalidMerkleProof)?; +// let spec = ics23_specs +// .get(0) +// .ok_or(CommitmentError::InvalidMerkleProof)?; +// // keys are represented from root-to-leaf +// let key = keys +// .key_path +// .get(num - 1) +// .ok_or(CommitmentError::InvalidMerkleProof)?; +// match &proof.proof { +// Some(Proof::Nonexist(non_existence_proof)) => { +// let subroot = calculate_non_existence_root(non_existence_proof)?; - if !verify_non_membership::( - proof, - spec, - &subroot, - key.as_bytes(), - ) { - return Err(CommitmentError::VerificationFailure); - } +// if !verify_non_membership::( +// proof, +// spec, +// &subroot, +// key.as_bytes(), +// ) { +// return Err(CommitmentError::VerificationFailure); +// } - // verify membership proofs starting from index 1 with value = subroot - self.verify_membership(specs, root, keys, subroot, 1) - } - _ => Err(CommitmentError::InvalidMerkleProof), - } - } -} +// // verify membership proofs starting from index 1 with value = subroot +// self.verify_membership(specs, root, keys, subroot, 1) +// } +// _ => Err(CommitmentError::InvalidMerkleProof), +// } +// } +// } -// TODO move to ics23 -fn calculate_non_existence_root(proof: &NonExistenceProof) -> Result, CommitmentError> { - if let Some(left) = &proof.left { - calculate_existence_root::(left) - .map_err(|_| CommitmentError::InvalidMerkleProof) - } else if let Some(right) = &proof.right { - calculate_existence_root::(right) - .map_err(|_| CommitmentError::InvalidMerkleProof) - } else { - Err(CommitmentError::InvalidMerkleProof) - } -} +// // TODO move to ics23 +// fn calculate_non_existence_root(proof: &NonExistenceProof) -> Result, CommitmentError> { +// if let Some(left) = &proof.left { +// calculate_existence_root::(left) +// .map_err(|_| CommitmentError::InvalidMerkleProof) +// } else if let Some(right) = &proof.right { +// calculate_existence_root::(right) +// .map_err(|_| CommitmentError::InvalidMerkleProof) +// } else { +// Err(CommitmentError::InvalidMerkleProof) +// } +// } // Merkle Proof serialization notes: // "Proof" id currently defined in a number of forms and included in a number of places diff --git a/libraries/rust/common/src/ibc/core/ics23_commitment/mod.rs b/libraries/rust/common/src/ibc/core/ics23_commitment/mod.rs index ecffa81d6..fc4c1217e 100644 --- a/libraries/rust/common/src/ibc/core/ics23_commitment/mod.rs +++ b/libraries/rust/common/src/ibc/core/ics23_commitment/mod.rs @@ -4,4 +4,4 @@ pub mod commitment; pub mod error; pub mod merkle; -pub mod specs; +//pub mod specs; diff --git a/libraries/rust/common/src/ibc/mock/client_state.rs b/libraries/rust/common/src/ibc/mock/client_state.rs index caf4dddcb..a517a6ff2 100644 --- a/libraries/rust/common/src/ibc/mock/client_state.rs +++ b/libraries/rust/common/src/ibc/mock/client_state.rs @@ -144,7 +144,7 @@ impl From for Any { Any { type_url: MOCK_CLIENT_STATE_TYPE_URL.to_string(), value: Protobuf::::encode_vec(&client_state) - .expect("encoding to `Any` from `MockClientState`"), + , } } } diff --git a/libraries/rust/common/src/ibc/mock/consensus_state.rs b/libraries/rust/common/src/ibc/mock/consensus_state.rs index ba37195c9..ba3ccc0e6 100644 --- a/libraries/rust/common/src/ibc/mock/consensus_state.rs +++ b/libraries/rust/common/src/ibc/mock/consensus_state.rs @@ -90,7 +90,7 @@ impl From for Any { Any { type_url: MOCK_CONSENSUS_STATE_TYPE_URL.to_string(), value: Protobuf::::encode_vec(&consensus_state) - .expect("encoding to `Any` from `MockConsensusState`"), + } } } diff --git a/libraries/rust/common/src/ibc/mock/header.rs b/libraries/rust/common/src/ibc/mock/header.rs index 6c434fb88..998a92b4b 100644 --- a/libraries/rust/common/src/ibc/mock/header.rs +++ b/libraries/rust/common/src/ibc/mock/header.rs @@ -113,7 +113,7 @@ impl From for Any { Any { type_url: MOCK_HEADER_TYPE_URL.to_string(), value: Protobuf::::encode_vec(&header) - .expect("encoding to `Any` from `TmHeader`"), + } } } @@ -126,7 +126,7 @@ mod tests { #[test] fn encode_any() { let header = MockHeader::new(Height::new(1, 10).unwrap()).with_timestamp(Timestamp::none()); - let bytes = >::encode_vec(&header).unwrap(); + let bytes = >::encode_vec(&header); assert_eq!( &bytes, diff --git a/libraries/rust/common/src/ibc/mock/misbehaviour.rs b/libraries/rust/common/src/ibc/mock/misbehaviour.rs index d1509ef3f..40c9dbec2 100644 --- a/libraries/rust/common/src/ibc/mock/misbehaviour.rs +++ b/libraries/rust/common/src/ibc/mock/misbehaviour.rs @@ -92,7 +92,7 @@ impl From for Any { Any { type_url: MOCK_MISBEHAVIOUR_TYPE_URL.to_string(), value: Protobuf::::encode_vec(&misbehaviour) - .expect("encoding to `Any` from `TmMisbehaviour`"), + } } } diff --git a/scripts/optimize-cosmwasm.sh b/scripts/optimize-cosmwasm.sh index a6a447775..00a7e9ddc 100755 --- a/scripts/optimize-cosmwasm.sh +++ b/scripts/optimize-cosmwasm.sh @@ -9,7 +9,7 @@ RUSTC_VERS="1.69.0" MAX_WASM_SIZE=800 # 800 KB -PROJECTS=("cw-common" "cw-ibc-core" "cw-icon-light-client" "cw-integration" "cw-mock-ibc-core" "cw-xcall-ibc-connection") +PROJECTS=("cw-common" "cw-ibc-core" "cw-icon-light-client" "cw-integration" "cw-mock-ibc-core" "cw-xcall-ibc-connection" "cw-wasm-light-client") # Install wasm-opt binary From 2fae1c44752a76bf0ada89080f6e8fb4bbb64113 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Wed, 27 Sep 2023 20:13:10 +0545 Subject: [PATCH 02/64] fix: add wasm proto --- Cargo.lock | 578 ++++++++++++++++-- Cargo.toml | 3 +- .../cw-ibc-core/src/ics02_client/handler.rs | 10 +- .../cw-ibc-core/src/ics02_client/mod.rs | 1 - .../src/ics03_connection/connection.rs | 9 +- .../cw-wasm-light-client/Cargo.toml | 4 +- .../cw-wasm-light-client/src/contract.rs | 3 +- .../src/ics08_wasm/client_message.rs | 250 ++++---- .../src/ics08_wasm/client_state.rs | 292 ++++----- .../src/ics08_wasm/consensus_state.rs | 129 ++-- .../src/ics08_wasm/mod.rs | 2 +- .../cw-wasm-light-client/src/lib.rs | 7 +- .../cw-wasm-light-client/src/msg.rs | 330 +++++----- .../src/ibc/core/ics23_commitment/merkle.rs | 7 +- .../rust/common/src/ibc/mock/client_state.rs | 3 +- .../common/src/ibc/mock/consensus_state.rs | 3 +- libraries/rust/common/src/ibc/mock/header.rs | 5 +- .../rust/common/src/ibc/mock/misbehaviour.rs | 3 +- .../src/icon/icon.lightclient.v1.wasm.rs | 189 ++++++ .../icon/icon.lightclient.v1.wasm.serde.rs | 502 +++++++++++++++ .../src/icon/icon.lightclient.wasm.v1.rs | 189 ++++++ .../icon/icon.lightclient.wasm.v1.serde.rs | 502 +++++++++++++++ libraries/rust/common/src/icon/mod.rs | 5 + .../common/src/icon/tendermint.light.serde.rs | 6 +- proto/buf.gen.rust.yaml | 4 +- proto/icon/lightclient/v1/wasm.proto | 47 ++ 26 files changed, 2487 insertions(+), 596 deletions(-) create mode 100644 libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs create mode 100644 libraries/rust/common/src/icon/icon.lightclient.v1.wasm.serde.rs create mode 100644 libraries/rust/common/src/icon/icon.lightclient.wasm.v1.rs create mode 100644 libraries/rust/common/src/icon/icon.lightclient.wasm.v1.serde.rs create mode 100644 proto/icon/lightclient/v1/wasm.proto diff --git a/Cargo.lock b/Cargo.lock index 3a0388bfd..f32b40bd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.7.6" @@ -42,12 +57,105 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2 1.0.59", + "quote 1.0.28", + "syn 2.0.18", +] + +[[package]] +name = "async-trait" +version = "0.1.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2d0f03b3640e3a630367e40c468cb7f309529c708ed1d88597047b0e7c6ef7" +dependencies = [ + "proc-macro2 1.0.59", + "quote 1.0.28", + "syn 2.0.18", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backtrace" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base16ct" version = "0.1.1" @@ -66,12 +174,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "base64" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" - [[package]] name = "base64ct" version = "1.6.0" @@ -210,8 +312,8 @@ dependencies = [ "dyn-clone", "hex", "hex-literal 0.3.4", - "ibc-proto 0.35.0", - "ics23 0.9.0", + "ibc-proto 0.26.0", + "ics23", "pbjson", "pbjson-types", "prost 0.11.9", @@ -248,7 +350,7 @@ dependencies = [ "hex", "hex-literal 0.3.4", "ibc-proto 0.26.0", - "ics23 0.9.0", + "ics23", "pbjson", "pbjson-types", "prost 0.11.9", @@ -439,7 +541,7 @@ dependencies = [ "getrandom", "hex", "hex-buffer-serde", - "ibc-proto 0.35.0", + "ibc-proto 0.26.0", "prost 0.11.9", "schemars 0.8.12", "serde", @@ -711,6 +813,7 @@ dependencies = [ name = "cw-wasm-light-client" version = "0.1.0" dependencies = [ + "base64 0.13.1", "bytes", "common 0.1.0", "cosmwasm", @@ -725,7 +828,7 @@ dependencies = [ "getrandom", "hex", "hex-literal 0.4.1", - "ibc-proto 0.35.0", + "ibc-proto 0.18.0", "prost 0.11.9", "schemars 0.8.12", "serde", @@ -1034,6 +1137,12 @@ dependencies = [ "paste", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "forward_ref" version = "1.0.0" @@ -1122,6 +1231,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + [[package]] name = "group" version = "0.12.1" @@ -1133,6 +1248,25 @@ dependencies = [ "subtle", ] +[[package]] +name = "h2" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1200,6 +1334,76 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + [[package]] name = "ibc" version = "0.32.0" @@ -1213,7 +1417,7 @@ dependencies = [ "dyn-clone", "erased-serde", "ibc-proto 0.26.0", - "ics23 0.9.0", + "ics23", "num-traits", "parity-scale-codec", "primitive-types", @@ -1235,37 +1439,33 @@ dependencies = [ [[package]] name = "ibc-proto" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9303a1308c886aea769ef0667c5caa422a78b01e9f8177fea8b91b08a4ff50c" +version = "0.18.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=main#5f59dd19265dbbbf6c9af7d628a4771d10c5cc9a" dependencies = [ "base64 0.13.1", - "borsh", "bytes", - "flex-error", - "parity-scale-codec", "prost 0.11.9", - "scale-info", "serde", - "subtle-encoding", - "tendermint-proto 0.29.1", + "tendermint-proto 0.28.0", + "tonic", ] [[package]] name = "ibc-proto" -version = "0.35.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "459ccbab879b749bf500ae13244593fa16fc64c1b3159f6b0753c169625a1e23" +checksum = "c9303a1308c886aea769ef0667c5caa422a78b01e9f8177fea8b91b08a4ff50c" dependencies = [ - "base64 0.21.4", + "base64 0.13.1", + "borsh", "bytes", "flex-error", - "ics23 0.10.2", + "parity-scale-codec", "prost 0.11.9", - "schemars 0.8.12", + "scale-info", "serde", "subtle-encoding", - "tendermint-proto 0.33.2", + "tendermint-proto 0.29.1", ] [[package]] @@ -1283,20 +1483,6 @@ dependencies = [ "sha3", ] -[[package]] -name = "ics23" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "442d4bab37956e76f739c864f246c825d87c0bb7f9afa65660c57833c91bf6d4" -dependencies = [ - "anyhow", - "bytes", - "hex", - "informalsystems-pbjson", - "prost 0.11.9", - "serde", -] - [[package]] name = "impl-serde" version = "0.4.0" @@ -1327,16 +1513,6 @@ dependencies = [ "hashbrown 0.12.3", ] -[[package]] -name = "informalsystems-pbjson" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4eecd90f87bea412eac91c6ef94f6b1e390128290898cbe14f2b926787ae1fb" -dependencies = [ - "base64 0.13.1", - "serde", -] - [[package]] name = "instant" version = "0.1.12" @@ -1426,12 +1602,44 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + [[package]] name = "multimap" version = "0.8.3" @@ -1468,6 +1676,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "object" +version = "0.30.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.18.0" @@ -1553,6 +1770,12 @@ dependencies = [ "serde", ] +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + [[package]] name = "petgraph" version = "0.6.3" @@ -1563,6 +1786,26 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pin-project" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +dependencies = [ + "proc-macro2 1.0.59", + "quote 1.0.28", + "syn 2.0.18", +] + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1585,6 +1828,12 @@ dependencies = [ "spki", ] +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "prettyplease" version = "0.1.25" @@ -1738,6 +1987,27 @@ dependencies = [ "proc-macro2 1.0.59", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -1823,6 +2093,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -2137,6 +2413,15 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.10.0" @@ -2164,6 +2449,16 @@ dependencies = [ "syn 0.15.44", ] +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "spki" version = "0.6.0" @@ -2253,6 +2548,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "tempfile" version = "3.5.0" @@ -2310,9 +2611,8 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c943f78c929cdf14553842f705f2c30324bc35b9179caaa5c9b80620f60652e6" +version = "0.28.0" +source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" dependencies = [ "bytes", "flex-error", @@ -2328,9 +2628,9 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.33.2" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639e5adffd77220d238a800a72c74c98d7e869290a6e4494c10b6b4e8f702f02" +checksum = "c943f78c929cdf14553842f705f2c30324bc35b9179caaa5c9b80620f60652e6" dependencies = [ "bytes", "flex-error", @@ -2365,7 +2665,7 @@ dependencies = [ "getrandom", "hex", "hex-literal 0.4.1", - "ibc-proto 0.35.0", + "ibc-proto 0.26.0", "prost 0.11.9", "serde", "serde_json", @@ -2426,6 +2726,69 @@ dependencies = [ "time-core", ] +[[package]] +name = "tokio" +version = "1.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +dependencies = [ + "autocfg", + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2 1.0.59", + "quote 1.0.28", + "syn 2.0.18", +] + +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.11" @@ -2452,6 +2815,70 @@ dependencies = [ "winnow", ] +[[package]] +name = "tonic" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.13.1", + "bytes", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost 0.11.9", + "prost-derive 0.11.9", + "tokio", + "tokio-stream", + "tokio-util", + "tower", + "tower-layer", + "tower-service", + "tracing", + "tracing-futures", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.37" @@ -2460,9 +2887,21 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2 1.0.59", + "quote 1.0.28", + "syn 2.0.18", +] + [[package]] name = "tracing-core" version = "0.1.31" @@ -2473,6 +2912,16 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + [[package]] name = "tracing-log" version = "0.1.3" @@ -2515,6 +2964,12 @@ dependencies = [ "tracing-serde", ] +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + [[package]] name = "typenum" version = "1.16.0" @@ -2563,6 +3018,15 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 27b5bf0e9..8e18672b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,8 @@ cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="main" cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="main" } cw2 = "1.0.1" -ibc-proto = { version = "0.35.0", default-features = false,features = ["std", "schemars","serde"]} +ibc-proto = { version = "0.26.0", default-features = false} + prost = { version = "0.11.8", default-features = false,features=["prost-derive"]} serde-json-wasm = {version="0.5.0", default-features = false} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs index 425b11c12..eab5c0516 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs @@ -131,9 +131,11 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> { message: RawMsgUpdateClient, ) -> Result { let client_id = to_ibc_client_id(&message.client_id)?; - let header = message.client_message.ok_or(ContractError::IbcClientError { - error: ClientError::MissingRawHeader, - })?; + let header = message + .client_message + .ok_or(ContractError::IbcClientError { + error: ClientError::MissingRawHeader, + })?; let client = self.get_light_client(deps.as_ref().storage, &client_id)?; let client_state = self.client_state(deps.as_ref(), &client_id)?; @@ -547,8 +549,6 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> { } } - - #[cfg(test)] mod tests { use cosmwasm_std::{from_binary, to_binary}; diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/mod.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/mod.rs index c942061b6..c9e814968 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/mod.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/mod.rs @@ -23,4 +23,3 @@ use cw_common::raw_types::Any; use events::{create_client_event, update_client_event, upgrade_client_event}; use std::time::Duration; - diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs index 6862cac36..10c5d63e4 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs @@ -27,9 +27,8 @@ impl<'a> CwIbcCoreContext<'a> { conn_id: &ConnectionId, conn_end: &ConnectionEnd, ) -> Result<(), ContractError> { - let data = conn_end - .encode_vec(); - + let data = conn_end.encode_vec(); + match self.ibc_store().connections().save(store, conn_id, &data) { Ok(_) => Ok(()), Err(error) => Err(ContractError::Std(error)), @@ -284,9 +283,7 @@ impl<'a> CwIbcCoreContext<'a> { ) -> Result<(), ContractError> { let connection_commit_key = commitment::connection_commitment_key(connection_id); - let connection_end_bytes = - connection_end - .encode_vec(); + let connection_end_bytes = connection_end.encode_vec(); let commitment_bytes = keccak256(&connection_end_bytes).to_vec(); diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml index c6177885b..d4fea0c14 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml @@ -49,8 +49,8 @@ cw-common = { path="../cw-common",default-features = false } prost = { workspace=true} serde-json-wasm = {workspace=true} debug_print = {workspace=true} -ibc-proto = { workspace=true} - +ibc-proto = {package = "ibc-proto", git="https://github.com/ComposableFi/composable-ibc.git", branch = "main"} +base64 = { version = "0.13", default-features = false, features = ["alloc"] } [dev-dependencies] cosmwasm = "0.7.2" diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 06b3a58f3..06b2c006e 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -21,10 +21,10 @@ use cw_common::raw_types::Any; use cw_common::types::VerifyChannelState; use crate::constants::{CLIENT_STATE_HASH, CONSENSUS_STATE_HASH, HEIGHT}; -use crate::ContractError; use crate::light_client::IconClient; use crate::state::CwContext; use crate::traits::{Config, IContext, ILightClient}; +use crate::ContractError; use cw_common::client_msg::{ ExecuteMsg, InstantiateMsg, LightClientPacketMessage, QueryMsg, VerifyClientConsensusState, VerifyClientFullState, VerifyConnectionState, @@ -532,4 +532,3 @@ pub fn ensure_owner(deps: Deps, info: &MessageInfo) -> Result<(), ContractError> } Ok(()) } - diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs index d84534b15..196aec083 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs @@ -17,22 +17,23 @@ use crate::msg::Base64; use crate::Bytes; use alloc::{ - boxed::Box, - string::{String, ToString}, - vec::Vec, + boxed::Box, + string::{String, ToString}, + vec::Vec, +}; +use common::ibc::{ + core::ics02_client::{client_message::ClientMessage as IbcClientMessage, error::Error}, + Height, }; use core::fmt::Display; #[cfg(feature = "cosmwasm")] use cosmwasm_schema::cw_serde; -use common::ibc::{ - core::ics02_client::{client_message::ClientMessage as IbcClientMessage, error::Error}, - protobuf::Protobuf, - Height, -}; -use ibc_proto::{ - google::protobuf::Any, - ibc::wasm::v1::{Header as RawHeader, Misbehaviour as RawMisbehaviour}, +use cw_common::raw_types::Protobuf; +use ibc_proto_composable::{ + google::protobuf::Any, + ibc::lightclients::wasm::v1::{Header as RawHeader, Misbehaviour as RawMisbehaviour}, }; + use prost::Message; pub const WASM_HEADER_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.Header"; @@ -41,173 +42,180 @@ pub const WASM_CLIENT_MESSAGE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.Client #[derive(Clone, Debug, PartialEq, Eq)] pub enum ClientMessage { - Header(Header), - Misbehaviour(Misbehaviour), + Header(Header), + Misbehaviour(Misbehaviour), } impl ClientMessage { - pub fn inner(&self) -> &AnyClientMessage { - match self { - ClientMessage::Header(h) => &h.inner, - ClientMessage::Misbehaviour(m) => &m.inner, - } - } - - pub fn into_inner(self) -> AnyClientMessage { - match self { - ClientMessage::Header(h) => *h.inner, - ClientMessage::Misbehaviour(m) => *m.inner, - } - } + pub fn inner(&self) -> &AnyClientMessage { + match self { + ClientMessage::Header(h) => &h.inner, + ClientMessage::Misbehaviour(m) => &m.inner, + } + } + + pub fn into_inner(self) -> AnyClientMessage { + match self { + ClientMessage::Header(h) => *h.inner, + ClientMessage::Misbehaviour(m) => *m.inner, + } + } } impl IbcClientMessage for ClientMessage where - AnyClientMessage: IbcClientMessage, - AnyClientMessage: TryFrom, - >::Error: Display, + AnyClientMessage: IbcClientMessage, + AnyClientMessage: TryFrom, + >::Error: Display, { - fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { - self.encode_vec() - } + fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { + self.encode_vec() + } } impl Protobuf for ClientMessage where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, { } impl TryFrom for ClientMessage where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, { - type Error = Error; - - fn try_from(any: Any) -> Result { - let msg = match &*any.type_url { - WASM_HEADER_TYPE_URL => - Self::Header(Header::decode(&*any.value).map_err(Error::decode_raw_header)?), - WASM_MISBEHAVIOUR_TYPE_URL => Self::Misbehaviour( - Misbehaviour::decode(&*any.value).map_err(Error::decode_raw_misbehaviour)?, - ), - _ => return Err(Error::malformed_header()), // TODO: choose a better error - }; - - Ok(msg) - } + type Error = Error; + + fn try_from(any: Any) -> Result { + let msg = match &*any.type_url { + WASM_HEADER_TYPE_URL => { + Self::Header(Header::decode(&*any.value).map_err(Error::decode_raw_header)?) + } + WASM_MISBEHAVIOUR_TYPE_URL => Self::Misbehaviour( + Misbehaviour::decode(&*any.value).map_err(Error::decode_raw_misbehaviour)?, + ), + _ => return Err(Error::malformed_header()), // TODO: choose a better error + }; + + Ok(msg) + } } impl From> for Any where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, { - fn from(msg: ClientMessage) -> Self { - match msg { - ClientMessage::Header(header) => Any { - value: header.encode_vec().expect("encode header"), - type_url: WASM_HEADER_TYPE_URL.to_string(), - }, - ClientMessage::Misbehaviour(misbheaviour) => Any { - value: misbheaviour.encode_vec().expect("encode misbehaviour"), - type_url: WASM_MISBEHAVIOUR_TYPE_URL.to_string(), - }, - } - } + fn from(msg: ClientMessage) -> Self { + match msg { + ClientMessage::Header(header) => Any { + value: header.encode_vec().expect("encode header"), + type_url: WASM_HEADER_TYPE_URL.to_string(), + }, + ClientMessage::Misbehaviour(misbheaviour) => Any { + value: misbheaviour.encode_vec().expect("encode misbehaviour"), + type_url: WASM_MISBEHAVIOUR_TYPE_URL.to_string(), + }, + } + } } impl Protobuf for Misbehaviour where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, { } impl TryFrom for Misbehaviour where - AnyClientMessage: TryFrom, - >::Error: Display, + AnyClientMessage: TryFrom, + >::Error: Display, { - type Error = String; - - fn try_from(raw: RawMisbehaviour) -> Result { - let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; - let inner = AnyClientMessage::try_from(any).map_err(|e| e.to_string())?; - Ok(Self { inner: Box::new(inner), data: raw.data }) - } + type Error = String; + + fn try_from(raw: RawMisbehaviour) -> Result { + let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; + let inner = AnyClientMessage::try_from(any).map_err(|e| e.to_string())?; + Ok(Self { + inner: Box::new(inner), + data: raw.data, + }) + } } impl Protobuf for Header where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, + AnyClientMessage: Clone, + AnyClientMessage: TryFrom, + >::Error: Display, { } impl TryFrom for Header where - AnyClientMessage: TryFrom, - >::Error: Display, + AnyClientMessage: TryFrom, + >::Error: Display, { - type Error = String; - - fn try_from(raw: RawHeader) -> Result { - let any = Any::decode(&mut &raw.data[..]) - .map_err(|e| format!("failed to decode raw header into Any: {e}"))?; - let inner = AnyClientMessage::try_from(any) - .map_err(|e| format!("failed to decode raw header into AnyClientMessage: {e}"))?; - - let header = Self { - inner: Box::new(inner), - data: raw.data, - height: raw - .height - .ok_or_else(|| { - "failed to decode raw header into Header: missing height".to_string() - })? - .into(), - }; - Ok(header) - } + type Error = String; + + fn try_from(raw: RawHeader) -> Result { + let any = Any::decode(&mut &raw.data[..]) + .map_err(|e| format!("failed to decode raw header into Any: {e}"))?; + let inner = AnyClientMessage::try_from(any) + .map_err(|e| format!("failed to decode raw header into AnyClientMessage: {e}"))?; + + let header = Self { + inner: Box::new(inner), + data: raw.data, + height: raw + .height + .ok_or_else(|| { + "failed to decode raw header into Header: missing height".to_string() + })? + .into(), + }; + Ok(header) + } } #[cfg_attr(feature = "cosmwasm", cw_serde)] #[cfg_attr(not(feature = "cosmwasm"), derive(Clone, Debug, PartialEq))] #[derive(Eq)] pub struct Header { - #[cfg_attr(feature = "cosmwasm", serde(skip))] - #[cfg_attr(feature = "cosmwasm", schemars(skip))] - pub inner: Box, - #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] - #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] - pub data: Bytes, - pub height: Height, + #[cfg_attr(feature = "cosmwasm", serde(skip))] + #[cfg_attr(feature = "cosmwasm", schemars(skip))] + pub inner: Box, + #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] + #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] + pub data: Bytes, + pub height: Height, } #[derive(Clone, Debug, PartialEq, Eq)] pub struct Misbehaviour { - // #[schemars(with = "String")] - // #[serde(with = "Base64", default)] - pub inner: Box, - pub data: Bytes, + // #[schemars(with = "String")] + // #[serde(with = "Base64", default)] + pub inner: Box, + pub data: Bytes, } impl From> for RawMisbehaviour { - fn from(value: Misbehaviour) -> Self { - RawMisbehaviour { data: value.data } - } + fn from(value: Misbehaviour) -> Self { + RawMisbehaviour { data: value.data } + } } impl From> for RawHeader { - fn from(value: Header) -> Self { - RawHeader { data: value.data, height: Some(value.height.into()) } - } + fn from(value: Header) -> Self { + RawHeader { + data: value.data, + height: Some(value.height.into()), + } + } } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs index 03f6910b4..4e9290ff6 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs @@ -17,30 +17,30 @@ use crate::msg::Base64; use crate::{client_def::WasmClient, Bytes}; use alloc::{ - boxed::Box, - string::{String, ToString}, - vec::Vec, + boxed::Box, + string::{String, ToString}, + vec::Vec, }; use core::{ - fmt::{Debug, Display}, - marker::PhantomData, - time::Duration, + fmt::{Debug, Display}, + marker::PhantomData, + time::Duration, }; #[cfg(feature = "cosmwasm")] use cosmwasm_schema::cw_serde; use ibc::{ - core::{ - ics02_client::{ - client_consensus::ConsensusState as IbcConsensusState, client_def::ClientDef, - client_state::ClientState as IbcClientState, - }, - ics24_host::identifier::ChainId, - }, - protobuf::Protobuf, - Height, + core::{ + ics02_client::{ + client_consensus::ConsensusState as IbcConsensusState, client_def::ClientDef, + client_state::ClientState as IbcClientState, + }, + ics24_host::identifier::ChainId, + }, + protobuf::Protobuf, + Height, }; use ibc_proto::{ - google::protobuf::Any, ibc::lightclients::wasm::v1::ClientState as RawClientState, + google::protobuf::Any, ibc::lightclients::wasm::v1::ClientState as RawClientState, }; use prost::Message; @@ -50,155 +50,163 @@ pub const WASM_CLIENT_STATE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.ClientSt #[cfg_attr(not(feature = "cosmwasm"), derive(Clone, Debug, PartialEq))] #[derive(Eq)] pub struct ClientState { - #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] - #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] - pub data: Bytes, - #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] - #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] - pub code_id: Bytes, - pub latest_height: Height, - #[cfg_attr(feature = "cosmwasm", serde(skip))] - #[cfg_attr(feature = "cosmwasm", schemars(skip))] - pub inner: Box, - #[cfg_attr(feature = "cosmwasm", serde(skip))] - #[cfg_attr(feature = "cosmwasm", schemars(skip))] - pub _phantom: PhantomData<(AnyConsensusState, AnyClient)>, + #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] + #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] + pub data: Bytes, + #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] + #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] + pub code_id: Bytes, + pub latest_height: Height, + #[cfg_attr(feature = "cosmwasm", serde(skip))] + #[cfg_attr(feature = "cosmwasm", schemars(skip))] + pub inner: Box, + #[cfg_attr(feature = "cosmwasm", serde(skip))] + #[cfg_attr(feature = "cosmwasm", schemars(skip))] + pub _phantom: PhantomData<(AnyConsensusState, AnyClient)>, } impl IbcClientState - for ClientState + for ClientState where - AnyClientState: TryFrom, - >::Error: Display, - AnyConsensusState: IbcConsensusState + Eq, - AnyConsensusState: TryFrom, - >::Error: Display, - AnyClient: ClientDef - + Debug - + Send - + Sync - + Eq, - AnyClientState: IbcClientState + Eq, - AnyClient::ClientMessage: TryFrom, - >::Error: Display, + AnyClientState: TryFrom, + >::Error: Display, + AnyConsensusState: IbcConsensusState + Eq, + AnyConsensusState: TryFrom, + >::Error: Display, + AnyClient: ClientDef + + Debug + + Send + + Sync + + Eq, + AnyClientState: IbcClientState + Eq, + AnyClient::ClientMessage: TryFrom, + >::Error: Display, { - type UpgradeOptions = Box; - type ClientDef = WasmClient; - - fn chain_id(&self) -> ChainId { - // self.inner.chain_id() - self.inner.chain_id() - } - - fn client_def(&self) -> Self::ClientDef { - let inner = self.inner.client_def(); - WasmClient { inner: Box::new(inner), _phantom: Default::default() } - } - - fn client_type(&self) -> String { - "08-wasm".to_string() - } - - fn latest_height(&self) -> Height { - self.latest_height - } - - fn frozen_height(&self) -> Option { - self.inner.frozen_height() - } - - fn upgrade( - self, - upgrade_height: Height, - upgrade_options: Self::UpgradeOptions, - chain_id: ChainId, - ) -> Self { - let inner = self.inner.upgrade(upgrade_height, *upgrade_options, chain_id); - Self { inner: Box::new(inner), ..self } - } - - fn expired(&self, elapsed: Duration) -> bool { - self.inner.expired(elapsed) - } - - fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { - self.encode_vec() - } + type UpgradeOptions = Box; + type ClientDef = WasmClient; + + fn chain_id(&self) -> ChainId { + // self.inner.chain_id() + self.inner.chain_id() + } + + fn client_def(&self) -> Self::ClientDef { + let inner = self.inner.client_def(); + WasmClient { + inner: Box::new(inner), + _phantom: Default::default(), + } + } + + fn client_type(&self) -> String { + "08-wasm".to_string() + } + + fn latest_height(&self) -> Height { + self.latest_height + } + + fn frozen_height(&self) -> Option { + self.inner.frozen_height() + } + + fn upgrade( + self, + upgrade_height: Height, + upgrade_options: Self::UpgradeOptions, + chain_id: ChainId, + ) -> Self { + let inner = self + .inner + .upgrade(upgrade_height, *upgrade_options, chain_id); + Self { + inner: Box::new(inner), + ..self + } + } + + fn expired(&self, elapsed: Duration) -> bool { + self.inner.expired(elapsed) + } + + fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { + self.encode_vec() + } } impl - ClientState + ClientState where - AnyClientState: TryFrom, - >::Error: Display, - AnyConsensusState: IbcConsensusState + Eq, - AnyConsensusState: TryFrom, - >::Error: Display, - AnyClient: ClientDef - + Debug - + Send - + Sync - + Eq, - AnyClientState: IbcClientState + Eq, - AnyClient::ClientMessage: TryFrom, - >::Error: Display, + AnyClientState: TryFrom, + >::Error: Display, + AnyConsensusState: IbcConsensusState + Eq, + AnyConsensusState: TryFrom, + >::Error: Display, + AnyClient: ClientDef + + Debug + + Send + + Sync + + Eq, + AnyClientState: IbcClientState + Eq, + AnyClient::ClientMessage: TryFrom, + >::Error: Display, { - pub fn to_any(&self) -> Any { - Any { - type_url: WASM_CLIENT_STATE_TYPE_URL.to_string(), - value: self - .encode_to_vec() - .expect("ClientState is always valid and can be encoded to Any"), - } - } + pub fn to_any(&self) -> Any { + Any { + type_url: WASM_CLIENT_STATE_TYPE_URL.to_string(), + value: self + .encode_to_vec() + .expect("ClientState is always valid and can be encoded to Any"), + } + } } impl TryFrom - for ClientState + for ClientState where - AnyClientState: TryFrom, - >::Error: Display, + AnyClientState: TryFrom, + >::Error: Display, { - type Error = String; - - fn try_from(raw: RawClientState) -> Result { - let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; - let inner = AnyClientState::try_from(any).map_err(|e| e.to_string())?; - Ok(Self { - data: raw.data, - code_id: raw.code_id, - inner: Box::new(inner), - latest_height: raw - .latest_height - .map(|h| Height::new(h.revision_number, h.revision_height)) - .unwrap_or_default(), - _phantom: Default::default(), - }) - } + type Error = String; + + fn try_from(raw: RawClientState) -> Result { + let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; + let inner = AnyClientState::try_from(any).map_err(|e| e.to_string())?; + Ok(Self { + data: raw.data, + code_id: raw.code_id, + inner: Box::new(inner), + latest_height: raw + .latest_height + .map(|h| Height::new(h.revision_number, h.revision_height)) + .unwrap_or_default(), + _phantom: Default::default(), + }) + } } impl - From> for RawClientState + From> for RawClientState where - AnyClientState: TryFrom, - >::Error: Display, + AnyClientState: TryFrom, + >::Error: Display, { - fn from(client_state: ClientState) -> Self { - Self { - data: client_state.data, - code_id: client_state.code_id, - latest_height: Some(client_state.latest_height.into()), - } - } + fn from(client_state: ClientState) -> Self { + Self { + data: client_state.data, + code_id: client_state.code_id, + latest_height: Some(client_state.latest_height.into()), + } + } } impl Protobuf - for ClientState + for ClientState where - AnyClientState: Clone, - AnyClientState: TryFrom, - >::Error: Display, - AnyConsensusState: Clone, - AnyClient: Clone, + AnyClientState: Clone, + AnyClientState: TryFrom, + >::Error: Display, + AnyConsensusState: Clone, + AnyClient: Clone, { } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs index 42dd961f9..848cf6298 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs @@ -17,26 +17,26 @@ use crate::msg::Base64; use crate::Bytes; use alloc::{ - boxed::Box, - string::{String, ToString}, - vec::Vec, + boxed::Box, + string::{String, ToString}, + vec::Vec, }; use core::{ - convert::Infallible, - fmt::{Debug, Display}, + convert::Infallible, + fmt::{Debug, Display}, }; #[cfg(feature = "cosmwasm")] use cosmwasm_schema::cw_serde; -use ibc::{ - core::{ - ics02_client::client_consensus::ConsensusState as IbcConsensusState, - ics23_commitment::commitment::CommitmentRoot, - }, - protobuf::Protobuf, - timestamp::Timestamp, +use common::ibc::{ + core::{ + ics02_client::client_consensus::ConsensusState as IbcConsensusState, + ics23_commitment::commitment::CommitmentRoot, + }, + protobuf::Protobuf, + timestamp::Timestamp, }; use ibc_proto::{ - google::protobuf::Any, ibc::lightclients::wasm::v1::ConsensusState as RawConsensusState, + google::protobuf::Any, ibc::lightclients::wasm::v1::ConsensusState as RawConsensusState, }; use prost::Message; @@ -46,79 +46,86 @@ pub const WASM_CONSENSUS_STATE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.Conse #[cfg_attr(not(feature = "cosmwasm"), derive(Clone, Debug, PartialEq))] #[derive(Eq)] pub struct ConsensusState { - #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] - #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] - pub data: Bytes, - pub timestamp: u64, - #[cfg_attr(feature = "cosmwasm", serde(skip))] - #[cfg_attr(feature = "cosmwasm", schemars(skip))] - pub inner: Box, + #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] + #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] + pub data: Bytes, + pub timestamp: u64, + #[cfg_attr(feature = "cosmwasm", serde(skip))] + #[cfg_attr(feature = "cosmwasm", schemars(skip))] + pub inner: Box, } impl IbcConsensusState for ConsensusState where - AnyConsensusState: Clone + Debug + Send + Sync, - AnyConsensusState: TryFrom, - >::Error: Display, + AnyConsensusState: Clone + Debug + Send + Sync, + AnyConsensusState: TryFrom, + >::Error: Display, { - type Error = Infallible; + type Error = Infallible; - fn root(&self) -> &CommitmentRoot { - unimplemented!() - } + fn root(&self) -> &CommitmentRoot { + unimplemented!() + } - fn timestamp(&self) -> Timestamp { - Timestamp::from_nanoseconds(self.timestamp).expect("timestamp is valid") - } + fn timestamp(&self) -> Timestamp { + Timestamp::from_nanoseconds(self.timestamp).expect("timestamp is valid") + } - fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { - self.encode_vec() - } + fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { + self.encode_vec() + } } impl ConsensusState where - AnyConsensusState: Clone + Debug + Send + Sync, - AnyConsensusState: TryFrom + IbcConsensusState, - >::Error: Display, + AnyConsensusState: Clone + Debug + Send + Sync, + AnyConsensusState: TryFrom + IbcConsensusState, + >::Error: Display, { - pub fn to_any(&self) -> Any { - Any { - type_url: WASM_CONSENSUS_STATE_TYPE_URL.to_string(), - value: self.encode_to_vec().expect( - "ConsensusState is always valid and can be encoded to Any", - ), - } - } + pub fn to_any(&self) -> Any { + Any { + type_url: WASM_CONSENSUS_STATE_TYPE_URL.to_string(), + value: self.encode_to_vec().expect( + "ConsensusState is always valid and can be encoded to Any", + ), + } + } } impl TryFrom for ConsensusState where - AnyConsensusState: TryFrom, - >::Error: Display, + AnyConsensusState: TryFrom, + >::Error: Display, { - type Error = String; + type Error = String; - fn try_from(raw: RawConsensusState) -> Result { - let any = Any::decode(&mut &raw.data[..]) - .map_err(|e| format!("failed to decode ConsensusState::data into Any: {e}"))?; - let inner = AnyConsensusState::try_from(any).map_err(|e| { - format!("failed to decode ConsensusState::data into ConsensusState: {e}") - })?; - Ok(Self { data: raw.data, timestamp: raw.timestamp, inner: Box::new(inner) }) - } + fn try_from(raw: RawConsensusState) -> Result { + let any = Any::decode(&mut &raw.data[..]) + .map_err(|e| format!("failed to decode ConsensusState::data into Any: {e}"))?; + let inner = AnyConsensusState::try_from(any).map_err(|e| { + format!("failed to decode ConsensusState::data into ConsensusState: {e}") + })?; + Ok(Self { + data: raw.data, + timestamp: raw.timestamp, + inner: Box::new(inner), + }) + } } impl From> for RawConsensusState { - fn from(value: ConsensusState) -> Self { - Self { data: value.data, timestamp: value.timestamp } - } + fn from(value: ConsensusState) -> Self { + Self { + data: value.data, + timestamp: value.timestamp, + } + } } impl Protobuf for ConsensusState where - AnyConsensusState: Clone, - AnyConsensusState: TryFrom, - >::Error: Display, + AnyConsensusState: Clone, + AnyConsensusState: TryFrom, + >::Error: Display, { } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs index 8170c0794..61e7fc88f 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs @@ -1,3 +1,3 @@ pub mod client_message; pub mod client_state; -pub mod consensus_state; \ No newline at end of file +pub mod consensus_state; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs index ff3e5eaee..1160c6c95 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs @@ -1,7 +1,7 @@ pub use cw_light_client_common::constants; pub mod contract; -// mod msg; -// mod ics08_wasm; +mod ics08_wasm; +mod msg; pub use cw_light_client_common::light_client; pub use cw_light_client_common::query_handler; @@ -9,3 +9,6 @@ pub use cw_light_client_common::state; pub use cw_light_client_common::traits; pub use cw_light_client_common::error::ContractError; +extern crate alloc; +extern crate core; +pub type Bytes = Vec; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs index 7229c591b..2b4594ae5 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -14,99 +14,149 @@ // limitations under the License. // use crate::{contract::HostFunctions, ics23::FakeInner, Bytes, ContractError}; -use core::{str::FromStr, time::Duration}; -use cosmwasm_schema::cw_serde; use common::ibc::{ - core::{ - ics02_client::trust_threshold::TrustThreshold, - ics23_commitment::commitment::{CommitmentPrefix, CommitmentProofBytes}, - ics24_host::Path, - }, - protobuf::Protobuf, - Height, + core::{ + ics23_commitment::commitment::{CommitmentPrefix, CommitmentProofBytes}, + ics24_host::Path, + }, + Height, }; +use core::{str::FromStr, time::Duration}; +use cosmwasm_schema::cw_serde; use cw_light_client_common::ContractError; -use ibc_proto::{google::protobuf::Any}; -use ics07_tendermint::{ - client_message::{ClientMessage, Header, Misbehaviour}, - client_state::ClientState, -}; -// use ics08_wasm::{ -// client_message::Header as WasmHeader, client_state::ClientState as WasmClientState, -// consensus_state::ConsensusState as WasmConsensusState, +use ibc_proto::google::protobuf::Any; +use std::convert::Infallible; +// use ics07_tendermint::{ +// client_message::{ClientMessage, Header, Misbehaviour}, +// client_state::ClientState, // }; +use crate::ics08_wasm::{ + client_message::Header as WasmHeader, client_state::ClientState as WasmClientState, + consensus_state::ConsensusState as WasmConsensusState, +}; use prost::Message; use serde::{Deserializer, Serializer}; #[cw_serde] pub struct HeightRaw { pub revision_number: u64, - + pub revision_height: u64, } struct Base64; impl Base64 { - pub fn serialize(v: &[u8], serializer: S) -> Result { - ibc_proto::base64::serialize(v, serializer) - } + pub fn serialize(v: &[u8], serializer: S) -> Result { + base64::serialize(v, serializer) + } - pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result, D::Error> { - ibc_proto::base64::deserialize(deserializer) - } + pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result, D::Error> { + base64::deserialize(deserializer) + } +} + +pub mod base64 { + use alloc::{string::String, vec::Vec}; + + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + + pub fn serialize(v: &[u8], serializer: S) -> Result { + let mut buf = String::new(); + base64::encode_config_buf(v, base64::STANDARD, &mut buf); + + String::serialize(&buf, serializer) + } + + pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result, D::Error> { + let base64 = String::deserialize(deserializer)?; + + let mut buf = Vec::new(); + base64::decode_config_buf(base64.as_bytes(), base64::STANDARD, &mut buf) + .map_err(serde::de::Error::custom)?; + + Ok(buf) + } } #[cw_serde] pub struct GenesisMetadata { - pub key: Vec, - pub value: Vec, + pub key: Vec, + pub value: Vec, } #[cw_serde] pub struct QueryResponse { - pub status: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub genesis_metadata: Option>, + pub status: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub genesis_metadata: Option>, } impl QueryResponse { - pub fn status(status: String) -> Self { - Self { status, genesis_metadata: None } - } - - pub fn genesis_metadata(genesis_metadata: Option>) -> Self { - Self { status: "".to_string(), genesis_metadata } - } + pub fn status(status: String) -> Self { + Self { + status, + genesis_metadata: None, + } + } + + pub fn genesis_metadata(genesis_metadata: Option>) -> Self { + Self { + status: "".to_string(), + genesis_metadata, + } + } } #[cw_serde] pub struct ContractResult { - pub is_valid: bool, - pub error_msg: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub data: Option>, - pub found_misbehaviour: bool, + pub is_valid: bool, + pub error_msg: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub data: Option>, + pub found_misbehaviour: bool, } impl ContractResult { - pub fn success() -> Self { - Self { is_valid: true, error_msg: "".to_string(), data: None, found_misbehaviour: false } - } - - pub fn error(msg: String) -> Self { - Self { is_valid: false, error_msg: msg, data: None, found_misbehaviour: false } - } - - pub fn misbehaviour(mut self, found: bool) -> Self { - self.found_misbehaviour = found; - self - } - - pub fn data(mut self, data: Vec) -> Self { - self.data = Some(data); - self - } + pub fn success() -> Self { + Self { + is_valid: true, + error_msg: "".to_string(), + data: None, + found_misbehaviour: false, + } + } + + pub fn error(msg: String) -> Self { + Self { + is_valid: false, + error_msg: msg, + data: None, + found_misbehaviour: false, + } + } + + pub fn misbehaviour(mut self, found: bool) -> Self { + self.found_misbehaviour = found; + self + } + + pub fn data(mut self, data: Vec) -> Self { + self.data = Some(data); + self + } +} + +#[derive(Eq, Default)] +#[cw_serde] +pub struct FakeInner; + +impl TryFrom for FakeInner { + type Error = Infallible; + + fn try_from(_: Any) -> Result { + Ok(FakeInner) + } } #[cw_serde] @@ -114,22 +164,22 @@ pub struct InstantiateMsg {} #[cw_serde] pub enum ExecuteMsg { - VerifyMembership(VerifyMembershipMsgRaw), - VerifyNonMembership(VerifyNonMembershipMsgRaw), - VerifyClientMessage(VerifyClientMessageRaw), - CheckForMisbehaviour(CheckForMisbehaviourMsgRaw), - UpdateStateOnMisbehaviour(UpdateStateOnMisbehaviourMsgRaw), - UpdateState(UpdateStateMsgRaw), - CheckSubstituteAndUpdateState(CheckSubstituteAndUpdateStateMsg), - VerifyUpgradeAndUpdateState(VerifyUpgradeAndUpdateStateMsgRaw), + VerifyMembership(VerifyMembershipMsgRaw), + VerifyNonMembership(VerifyNonMembershipMsgRaw), + VerifyClientMessage(VerifyClientMessageRaw), + CheckForMisbehaviour(CheckForMisbehaviourMsgRaw), + UpdateStateOnMisbehaviour(UpdateStateOnMisbehaviourMsgRaw), + UpdateState(UpdateStateMsgRaw), + CheckSubstituteAndUpdateState(CheckSubstituteAndUpdateStateMsg), + VerifyUpgradeAndUpdateState(VerifyUpgradeAndUpdateStateMsgRaw), } #[cw_serde] pub enum QueryMsg { - ClientTypeMsg(ClientTypeMsg), - GetLatestHeightsMsg(GetLatestHeightsMsg), - ExportMetadata(ExportMetadataMsg), - Status(StatusMsg), + ClientTypeMsg(ClientTypeMsg), + GetLatestHeightsMsg(GetLatestHeightsMsg), + ExportMetadata(ExportMetadataMsg), + Status(StatusMsg), } #[cw_serde] @@ -146,21 +196,21 @@ pub struct ExportMetadataMsg {} #[cw_serde] pub struct MerklePath { - pub key_path: Vec, + pub key_path: Vec, } #[cw_serde] pub struct VerifyMembershipMsgRaw { - #[schemars(with = "String")] - #[serde(with = "Base64", default)] - pub proof: Vec, - pub path: MerklePath, - #[schemars(with = "String")] - #[serde(with = "Base64", default)] - pub value: Vec, - pub height: HeightRaw, - pub delay_block_period: u64, - pub delay_time_period: u64, + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub proof: Vec, + pub path: MerklePath, + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub value: Vec, + pub height: HeightRaw, + pub delay_block_period: u64, + pub delay_time_period: u64, } // pub struct VerifyMembershipMsg { @@ -196,13 +246,13 @@ pub struct VerifyMembershipMsgRaw { #[cw_serde] pub struct VerifyNonMembershipMsgRaw { - #[schemars(with = "String")] - #[serde(with = "Base64", default)] - pub proof: Vec, - pub path: MerklePath, - pub height: HeightRaw, - pub delay_block_period: u64, - pub delay_time_period: u64, + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub proof: Vec, + pub path: MerklePath, + pub height: HeightRaw, + pub delay_block_period: u64, + pub delay_time_period: u64, } // pub struct VerifyNonMembershipMsg { @@ -236,103 +286,35 @@ pub struct VerifyNonMembershipMsgRaw { #[cw_serde] pub struct WasmMisbehaviour { - #[schemars(with = "String")] - #[serde(with = "Base64", default)] - pub data: Vec, + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub data: Vec, } #[cw_serde] pub enum ClientMessageRaw { - Header(WasmHeader), - Misbehaviour(WasmMisbehaviour), + Header(WasmHeader), + Misbehaviour(WasmMisbehaviour), } #[cw_serde] pub struct VerifyClientMessageRaw { - pub client_message: ClientMessageRaw, -} - -pub struct VerifyClientMessage { - pub client_message: ClientMessage, -} - -impl TryFrom for VerifyClientMessage { - type Error = ContractError; - - fn try_from(raw: VerifyClientMessageRaw) -> Result { - let client_message = Self::decode_client_message(raw.client_message)?; - Ok(Self { client_message }) - } -} - -impl VerifyClientMessage { - fn decode_client_message(raw: ClientMessageRaw) -> Result { - let client_message = match raw { - ClientMessageRaw::Header(header) => { - let any = Any::decode(&mut header.data.as_slice())?; - ClientMessage::Header(Header::decode_vec(&any.value)?) - }, - ClientMessageRaw::Misbehaviour(misbehaviour) => { - let any = Any::decode(&mut misbehaviour.data.as_slice())?; - ClientMessage::Misbehaviour(Misbehaviour::decode_vec(&any.value)?) - }, - }; - Ok(client_message) - } + pub client_message: ClientMessageRaw, } #[cw_serde] pub struct CheckForMisbehaviourMsgRaw { - pub client_message: ClientMessageRaw, -} - -pub struct CheckForMisbehaviourMsg { - pub client_message: ClientMessage, -} - -impl TryFrom for CheckForMisbehaviourMsg { - type Error = ContractError; - - fn try_from(raw: CheckForMisbehaviourMsgRaw) -> Result { - let client_message = VerifyClientMessage::decode_client_message(raw.client_message)?; - Ok(Self { client_message }) - } + pub client_message: ClientMessageRaw, } #[cw_serde] pub struct UpdateStateOnMisbehaviourMsgRaw { - pub client_message: ClientMessageRaw, -} - -pub struct UpdateStateOnMisbehaviourMsg { - pub client_message: ClientMessage, -} - -impl TryFrom for UpdateStateOnMisbehaviourMsg { - type Error = ContractError; - - fn try_from(raw: UpdateStateOnMisbehaviourMsgRaw) -> Result { - let client_message = VerifyClientMessage::decode_client_message(raw.client_message)?; - Ok(Self { client_message }) - } + pub client_message: ClientMessageRaw, } #[cw_serde] pub struct UpdateStateMsgRaw { - pub client_message: ClientMessageRaw, -} - -pub struct UpdateStateMsg { - pub client_message: ClientMessage, -} - -impl TryFrom for UpdateStateMsg { - type Error = ContractError; - - fn try_from(raw: UpdateStateMsgRaw) -> Result { - let client_message = VerifyClientMessage::decode_client_message(raw.client_message)?; - Ok(Self { client_message }) - } + pub client_message: ClientMessageRaw, } #[cw_serde] @@ -340,14 +322,14 @@ pub struct CheckSubstituteAndUpdateStateMsg {} #[cw_serde] pub struct VerifyUpgradeAndUpdateStateMsgRaw { - pub upgrade_client_state: WasmClientState, - pub upgrade_consensus_state: WasmConsensusState, - #[schemars(with = "String")] - #[serde(with = "Base64", default)] - pub proof_upgrade_client: Vec, - #[schemars(with = "String")] - #[serde(with = "Base64", default)] - pub proof_upgrade_consensus_state: Vec, + pub upgrade_client_state: WasmClientState, + pub upgrade_consensus_state: WasmConsensusState, + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub proof_upgrade_client: Vec, + #[schemars(with = "String")] + #[serde(with = "Base64", default)] + pub proof_upgrade_consensus_state: Vec, } // pub struct VerifyUpgradeAndUpdateStateMsg { @@ -356,5 +338,3 @@ pub struct VerifyUpgradeAndUpdateStateMsgRaw { // pub proof_upgrade_client: CommitmentProofBytes, // pub proof_upgrade_consensus_state: CommitmentProofBytes, // } - - diff --git a/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs b/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs index 3355dc1e7..02db4fe99 100644 --- a/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs +++ b/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs @@ -4,11 +4,8 @@ use tendermint::merkle::proof::ProofOps as TendermintProof; use ibc_proto::ibc::core::commitment::v1::MerklePath; use ibc_proto::ibc::core::commitment::v1::MerkleProof as RawMerkleProof; use ibc_proto::ibc::core::commitment::v1::MerkleRoot; -use ics23::commitment_proof::Proof; -use ics23::{ - calculate_existence_root, verify_membership, verify_non_membership, CommitmentProof, - NonExistenceProof, -}; + +use ics23::CommitmentProof; use crate::ibc::core::ics23_commitment::commitment::{CommitmentPrefix, CommitmentRoot}; use crate::ibc::core::ics23_commitment::error::CommitmentError; diff --git a/libraries/rust/common/src/ibc/mock/client_state.rs b/libraries/rust/common/src/ibc/mock/client_state.rs index a517a6ff2..b3c386882 100644 --- a/libraries/rust/common/src/ibc/mock/client_state.rs +++ b/libraries/rust/common/src/ibc/mock/client_state.rs @@ -143,8 +143,7 @@ impl From for Any { fn from(client_state: MockClientState) -> Self { Any { type_url: MOCK_CLIENT_STATE_TYPE_URL.to_string(), - value: Protobuf::::encode_vec(&client_state) - , + value: Protobuf::::encode_vec(&client_state).unwrap(), } } } diff --git a/libraries/rust/common/src/ibc/mock/consensus_state.rs b/libraries/rust/common/src/ibc/mock/consensus_state.rs index ba3ccc0e6..e344b19fa 100644 --- a/libraries/rust/common/src/ibc/mock/consensus_state.rs +++ b/libraries/rust/common/src/ibc/mock/consensus_state.rs @@ -89,8 +89,7 @@ impl From for Any { fn from(consensus_state: MockConsensusState) -> Self { Any { type_url: MOCK_CONSENSUS_STATE_TYPE_URL.to_string(), - value: Protobuf::::encode_vec(&consensus_state) - + value: Protobuf::::encode_vec(&consensus_state).unwrap(), } } } diff --git a/libraries/rust/common/src/ibc/mock/header.rs b/libraries/rust/common/src/ibc/mock/header.rs index 998a92b4b..1c079839c 100644 --- a/libraries/rust/common/src/ibc/mock/header.rs +++ b/libraries/rust/common/src/ibc/mock/header.rs @@ -112,8 +112,7 @@ impl From for Any { fn from(header: MockHeader) -> Self { Any { type_url: MOCK_HEADER_TYPE_URL.to_string(), - value: Protobuf::::encode_vec(&header) - + value: Protobuf::::encode_vec(&header).unwrap(), } } } @@ -126,7 +125,7 @@ mod tests { #[test] fn encode_any() { let header = MockHeader::new(Height::new(1, 10).unwrap()).with_timestamp(Timestamp::none()); - let bytes = >::encode_vec(&header); + let bytes = >::encode_vec(&header).unwrap(); assert_eq!( &bytes, diff --git a/libraries/rust/common/src/ibc/mock/misbehaviour.rs b/libraries/rust/common/src/ibc/mock/misbehaviour.rs index 40c9dbec2..f507b2790 100644 --- a/libraries/rust/common/src/ibc/mock/misbehaviour.rs +++ b/libraries/rust/common/src/ibc/mock/misbehaviour.rs @@ -91,8 +91,7 @@ impl From for Any { fn from(misbehaviour: Misbehaviour) -> Self { Any { type_url: MOCK_MISBEHAVIOUR_TYPE_URL.to_string(), - value: Protobuf::::encode_vec(&misbehaviour) - + value: Protobuf::::encode_vec(&misbehaviour).unwrap(), } } } diff --git a/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs b/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs new file mode 100644 index 000000000..5e5e3b38b --- /dev/null +++ b/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs @@ -0,0 +1,189 @@ +// @generated +/// Wasm light client's Client state +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ClientState { + #[prost(bytes="vec", tag="1")] + pub data: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="2")] + pub code_id: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="3")] + pub latest_height: ::core::option::Option, +} +/// Wasm light client's ConsensusState +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConsensusState { + #[prost(bytes="vec", tag="1")] + pub data: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="2")] + pub code_id: ::prost::alloc::vec::Vec, + /// timestamp that corresponds to the block height in which the ConsensusState + /// was stored. + #[prost(uint64, tag="3")] + pub timestamp: u64, + /// commitment root + #[prost(message, optional, tag="4")] + pub root: ::core::option::Option, +} +/// Wasm light client Header +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Header { + #[prost(bytes="vec", tag="1")] + pub data: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="2")] + pub height: ::core::option::Option, +} +/// Wasm light client Misbehaviour +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Misbehaviour { + #[prost(string, tag="1")] + pub client_id: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="2")] + pub data: ::prost::alloc::vec::Vec, +} +/// Encoded file descriptor set for the `icon.lightclient.v1.wasm` package +pub const FILE_DESCRIPTOR_SET: &[u8] = &[ + 0x0a, 0x94, 0x11, 0x0a, 0x1e, 0x69, 0x63, 0x6f, 0x6e, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x1a, 0x14, 0x67, + 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x30, 0x32, 0x2d, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x2f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x23, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x32, 0x33, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x01, 0x0a, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, + 0x49, 0x64, 0x12, 0x61, 0x0a, 0x0d, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x1c, 0xc8, 0xde, 0x1f, 0x00, 0xf2, + 0xde, 0x1f, 0x14, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, + 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x52, 0x0c, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x48, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x9d, 0x01, 0x0a, 0x0e, + 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3a, 0x0a, 0x04, 0x72, 0x6f, 0x6f, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, + 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x71, 0x0a, 0x06, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x15, 0xc8, 0xde, 0x1f, 0x00, 0xf2, + 0xde, 0x1f, 0x0d, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, + 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x5b, + 0x0a, 0x0c, 0x4d, 0x69, 0x73, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x12, 0x31, + 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x14, 0xf2, 0xde, 0x1f, 0x10, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x22, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xed, 0x01, 0x0a, 0x1c, + 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x42, 0x09, 0x57, 0x61, + 0x73, 0x6d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x69, 0x62, 0x63, + 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x35, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x2f, 0x6c, + 0x69, 0x67, 0x68, 0x74, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x30, 0x38, 0x2d, + 0x77, 0x61, 0x73, 0x6d, 0x3b, 0x77, 0x61, 0x73, 0x6d, 0xa2, 0x02, 0x04, 0x49, 0x4c, 0x56, 0x57, + 0xaa, 0x02, 0x18, 0x49, 0x63, 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x2e, 0x56, 0x31, 0x2e, 0x57, 0x61, 0x73, 0x6d, 0xca, 0x02, 0x18, 0x49, 0x63, + 0x6f, 0x6e, 0x5c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x56, + 0x31, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0xe2, 0x02, 0x24, 0x49, 0x63, 0x6f, 0x6e, 0x5c, 0x4c, 0x69, + 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x57, 0x61, 0x73, + 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1b, + 0x49, 0x63, 0x6f, 0x6e, 0x3a, 0x3a, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x57, 0x61, 0x73, 0x6d, 0x4a, 0xf1, 0x09, 0x0a, 0x06, + 0x12, 0x04, 0x01, 0x00, 0x2e, 0x01, 0x0a, 0x08, 0x0a, 0x01, 0x0c, 0x12, 0x03, 0x01, 0x00, 0x12, + 0x0a, 0x08, 0x0a, 0x01, 0x02, 0x12, 0x03, 0x02, 0x00, 0x21, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x00, + 0x12, 0x03, 0x04, 0x00, 0x1e, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x01, 0x12, 0x03, 0x05, 0x00, 0x25, + 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x02, 0x12, 0x03, 0x06, 0x00, 0x2d, 0x0a, 0x08, 0x0a, 0x01, 0x08, + 0x12, 0x03, 0x08, 0x00, 0x55, 0x0a, 0x09, 0x0a, 0x02, 0x08, 0x0b, 0x12, 0x03, 0x08, 0x00, 0x55, + 0x0a, 0x2e, 0x0a, 0x02, 0x04, 0x00, 0x12, 0x04, 0x0b, 0x00, 0x11, 0x01, 0x1a, 0x22, 0x20, 0x57, + 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x27, 0x73, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, + 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x00, 0x01, 0x12, 0x03, 0x0b, 0x08, 0x13, 0x0a, 0x0a, 0x0a, 0x03, + 0x04, 0x00, 0x07, 0x12, 0x03, 0x0c, 0x02, 0x32, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x00, 0x07, 0x81, + 0xf4, 0x03, 0x12, 0x03, 0x0c, 0x02, 0x32, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x00, 0x12, + 0x03, 0x0d, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x05, 0x12, 0x03, 0x0d, + 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x01, 0x12, 0x03, 0x0d, 0x1c, 0x20, + 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x03, 0x12, 0x03, 0x0d, 0x2c, 0x2d, 0x0a, 0x0b, + 0x0a, 0x04, 0x04, 0x00, 0x02, 0x01, 0x12, 0x03, 0x0e, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, + 0x00, 0x02, 0x01, 0x05, 0x12, 0x03, 0x0e, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, + 0x01, 0x01, 0x12, 0x03, 0x0e, 0x1c, 0x23, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x03, + 0x12, 0x03, 0x0e, 0x2c, 0x2d, 0x0a, 0x0c, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x02, 0x12, 0x04, 0x0f, + 0x02, 0x10, 0x56, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x06, 0x12, 0x03, 0x0f, 0x02, + 0x1f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x01, 0x12, 0x03, 0x0f, 0x20, 0x2d, 0x0a, + 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x03, 0x12, 0x03, 0x0f, 0x30, 0x31, 0x0a, 0x0c, 0x0a, + 0x05, 0x04, 0x00, 0x02, 0x02, 0x08, 0x12, 0x03, 0x10, 0x06, 0x55, 0x0a, 0x0f, 0x0a, 0x08, 0x04, + 0x00, 0x02, 0x02, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x10, 0x07, 0x23, 0x0a, 0x0f, 0x0a, 0x08, + 0x04, 0x00, 0x02, 0x02, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x10, 0x25, 0x54, 0x0a, 0x30, 0x0a, + 0x02, 0x04, 0x01, 0x12, 0x04, 0x14, 0x00, 0x1e, 0x01, 0x1a, 0x24, 0x20, 0x57, 0x61, 0x73, 0x6d, + 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x27, 0x73, 0x20, + 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, + 0x0a, 0x0a, 0x03, 0x04, 0x01, 0x01, 0x12, 0x03, 0x14, 0x08, 0x16, 0x0a, 0x0a, 0x0a, 0x03, 0x04, + 0x01, 0x07, 0x12, 0x03, 0x15, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x01, 0x07, 0x81, 0xf4, + 0x03, 0x12, 0x03, 0x15, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x00, 0x12, 0x03, + 0x16, 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x05, 0x12, 0x03, 0x16, 0x02, + 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x01, 0x12, 0x03, 0x16, 0x08, 0x0c, 0x0a, + 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x03, 0x12, 0x03, 0x16, 0x27, 0x28, 0x0a, 0x0b, 0x0a, + 0x04, 0x04, 0x01, 0x02, 0x01, 0x12, 0x03, 0x17, 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, + 0x02, 0x01, 0x05, 0x12, 0x03, 0x17, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, + 0x01, 0x12, 0x03, 0x17, 0x08, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x03, 0x12, + 0x03, 0x17, 0x27, 0x28, 0x0a, 0x66, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x02, 0x12, 0x03, 0x1b, 0x02, + 0x17, 0x1a, 0x59, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x20, 0x74, 0x68, + 0x61, 0x74, 0x20, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x64, 0x73, 0x20, 0x74, + 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x68, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x20, 0x69, 0x6e, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x74, 0x68, 0x65, 0x20, + 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, + 0x77, 0x61, 0x73, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x2e, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, + 0x04, 0x01, 0x02, 0x02, 0x05, 0x12, 0x03, 0x1b, 0x02, 0x08, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, + 0x02, 0x02, 0x01, 0x12, 0x03, 0x1b, 0x09, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, + 0x03, 0x12, 0x03, 0x1b, 0x15, 0x16, 0x0a, 0x1e, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x03, 0x12, 0x03, + 0x1d, 0x02, 0x31, 0x1a, 0x11, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, + 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x06, 0x12, + 0x03, 0x1d, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x01, 0x12, 0x03, 0x1d, + 0x28, 0x2c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x03, 0x12, 0x03, 0x1d, 0x2f, 0x30, + 0x0a, 0x26, 0x0a, 0x02, 0x04, 0x02, 0x12, 0x04, 0x21, 0x00, 0x26, 0x01, 0x1a, 0x1a, 0x20, 0x57, + 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x20, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x01, 0x12, + 0x03, 0x21, 0x08, 0x0e, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x07, 0x12, 0x03, 0x22, 0x02, 0x2d, + 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x02, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x22, 0x02, 0x2d, 0x0a, + 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x00, 0x12, 0x03, 0x24, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, + 0x04, 0x02, 0x02, 0x00, 0x05, 0x12, 0x03, 0x24, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, + 0x02, 0x00, 0x01, 0x12, 0x03, 0x24, 0x1c, 0x20, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, + 0x03, 0x12, 0x03, 0x24, 0x25, 0x26, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x01, 0x12, 0x03, + 0x25, 0x02, 0x74, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x06, 0x12, 0x03, 0x25, 0x02, + 0x1f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x01, 0x12, 0x03, 0x25, 0x20, 0x26, 0x0a, + 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x03, 0x12, 0x03, 0x25, 0x29, 0x2a, 0x0a, 0x0c, 0x0a, + 0x05, 0x04, 0x02, 0x02, 0x01, 0x08, 0x12, 0x03, 0x25, 0x2b, 0x73, 0x0a, 0x0f, 0x0a, 0x08, 0x04, + 0x02, 0x02, 0x01, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x25, 0x2c, 0x48, 0x0a, 0x0f, 0x0a, 0x08, + 0x04, 0x02, 0x02, 0x01, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x25, 0x4a, 0x72, 0x0a, 0x2c, 0x0a, + 0x02, 0x04, 0x03, 0x12, 0x04, 0x29, 0x00, 0x2e, 0x01, 0x1a, 0x20, 0x20, 0x57, 0x61, 0x73, 0x6d, + 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x4d, 0x69, + 0x73, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, + 0x03, 0x01, 0x12, 0x03, 0x29, 0x08, 0x14, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, 0x07, 0x12, 0x03, + 0x2a, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x03, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x2a, + 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x00, 0x12, 0x03, 0x2c, 0x02, 0x45, 0x0a, + 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x05, 0x12, 0x03, 0x2c, 0x02, 0x08, 0x0a, 0x0c, 0x0a, + 0x05, 0x04, 0x03, 0x02, 0x00, 0x01, 0x12, 0x03, 0x2c, 0x09, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, + 0x03, 0x02, 0x00, 0x03, 0x12, 0x03, 0x2c, 0x15, 0x16, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, + 0x00, 0x08, 0x12, 0x03, 0x2c, 0x17, 0x44, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x03, 0x02, 0x00, 0x08, + 0xee, 0xfb, 0x03, 0x12, 0x03, 0x2c, 0x18, 0x43, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x01, + 0x12, 0x03, 0x2d, 0x02, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x05, 0x12, 0x03, + 0x2d, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x12, 0x03, 0x2d, 0x09, + 0x0d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x03, 0x12, 0x03, 0x2d, 0x15, 0x16, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +]; +include!("icon.lightclient.v1.wasm.serde.rs"); +// @@protoc_insertion_point(module) \ No newline at end of file diff --git a/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.serde.rs b/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.serde.rs new file mode 100644 index 000000000..ff2adaf0c --- /dev/null +++ b/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.serde.rs @@ -0,0 +1,502 @@ +// @generated +impl serde::Serialize for ClientState { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if !self.data.is_empty() { + len += 1; + } + if !self.code_id.is_empty() { + len += 1; + } + if self.latest_height.is_some() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("icon.lightclient.v1.wasm.ClientState", len)?; + if !self.data.is_empty() { + struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; + } + if !self.code_id.is_empty() { + struct_ser.serialize_field("code_id", pbjson::private::base64::encode(&self.code_id).as_str())?; + } + if let Some(v) = self.latest_height.as_ref() { + struct_ser.serialize_field("latest_height", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for ClientState { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "data", + "code_id", + "codeId", + "latest_height", + "latestHeight", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Data, + CodeId, + LatestHeight, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "data" => Ok(GeneratedField::Data), + "codeId" | "code_id" => Ok(GeneratedField::CodeId), + "latestHeight" | "latest_height" => Ok(GeneratedField::LatestHeight), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = ClientState; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct icon.lightclient.v1.wasm.ClientState") + } + + fn visit_map(self, mut map: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut data__ = None; + let mut code_id__ = None; + let mut latest_height__ = None; + while let Some(k) = map.next_key()? { + match k { + GeneratedField::Data => { + if data__.is_some() { + return Err(serde::de::Error::duplicate_field("data")); + } + data__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::CodeId => { + if code_id__.is_some() { + return Err(serde::de::Error::duplicate_field("codeId")); + } + code_id__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::LatestHeight => { + if latest_height__.is_some() { + return Err(serde::de::Error::duplicate_field("latestHeight")); + } + latest_height__ = map.next_value()?; + } + } + } + Ok(ClientState { + data: data__.unwrap_or_default(), + code_id: code_id__.unwrap_or_default(), + latest_height: latest_height__, + }) + } + } + deserializer.deserialize_struct("icon.lightclient.v1.wasm.ClientState", FIELDS, GeneratedVisitor) + } +} +impl serde::Serialize for ConsensusState { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if !self.data.is_empty() { + len += 1; + } + if !self.code_id.is_empty() { + len += 1; + } + if self.timestamp != 0 { + len += 1; + } + if self.root.is_some() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("icon.lightclient.v1.wasm.ConsensusState", len)?; + if !self.data.is_empty() { + struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; + } + if !self.code_id.is_empty() { + struct_ser.serialize_field("code_id", pbjson::private::base64::encode(&self.code_id).as_str())?; + } + if self.timestamp != 0 { + struct_ser.serialize_field("timestamp", ToString::to_string(&self.timestamp).as_str())?; + } + if let Some(v) = self.root.as_ref() { + struct_ser.serialize_field("root", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for ConsensusState { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "data", + "code_id", + "codeId", + "timestamp", + "root", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Data, + CodeId, + Timestamp, + Root, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "data" => Ok(GeneratedField::Data), + "codeId" | "code_id" => Ok(GeneratedField::CodeId), + "timestamp" => Ok(GeneratedField::Timestamp), + "root" => Ok(GeneratedField::Root), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = ConsensusState; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct icon.lightclient.v1.wasm.ConsensusState") + } + + fn visit_map(self, mut map: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut data__ = None; + let mut code_id__ = None; + let mut timestamp__ = None; + let mut root__ = None; + while let Some(k) = map.next_key()? { + match k { + GeneratedField::Data => { + if data__.is_some() { + return Err(serde::de::Error::duplicate_field("data")); + } + data__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::CodeId => { + if code_id__.is_some() { + return Err(serde::de::Error::duplicate_field("codeId")); + } + code_id__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::Timestamp => { + if timestamp__.is_some() { + return Err(serde::de::Error::duplicate_field("timestamp")); + } + timestamp__ = + Some(map.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) + ; + } + GeneratedField::Root => { + if root__.is_some() { + return Err(serde::de::Error::duplicate_field("root")); + } + root__ = map.next_value()?; + } + } + } + Ok(ConsensusState { + data: data__.unwrap_or_default(), + code_id: code_id__.unwrap_or_default(), + timestamp: timestamp__.unwrap_or_default(), + root: root__, + }) + } + } + deserializer.deserialize_struct("icon.lightclient.v1.wasm.ConsensusState", FIELDS, GeneratedVisitor) + } +} +impl serde::Serialize for Header { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if !self.data.is_empty() { + len += 1; + } + if self.height.is_some() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("icon.lightclient.v1.wasm.Header", len)?; + if !self.data.is_empty() { + struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; + } + if let Some(v) = self.height.as_ref() { + struct_ser.serialize_field("height", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for Header { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "data", + "height", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Data, + Height, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "data" => Ok(GeneratedField::Data), + "height" => Ok(GeneratedField::Height), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = Header; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct icon.lightclient.v1.wasm.Header") + } + + fn visit_map(self, mut map: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut data__ = None; + let mut height__ = None; + while let Some(k) = map.next_key()? { + match k { + GeneratedField::Data => { + if data__.is_some() { + return Err(serde::de::Error::duplicate_field("data")); + } + data__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::Height => { + if height__.is_some() { + return Err(serde::de::Error::duplicate_field("height")); + } + height__ = map.next_value()?; + } + } + } + Ok(Header { + data: data__.unwrap_or_default(), + height: height__, + }) + } + } + deserializer.deserialize_struct("icon.lightclient.v1.wasm.Header", FIELDS, GeneratedVisitor) + } +} +impl serde::Serialize for Misbehaviour { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if !self.client_id.is_empty() { + len += 1; + } + if !self.data.is_empty() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("icon.lightclient.v1.wasm.Misbehaviour", len)?; + if !self.client_id.is_empty() { + struct_ser.serialize_field("client_id", &self.client_id)?; + } + if !self.data.is_empty() { + struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for Misbehaviour { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "client_id", + "clientId", + "data", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + ClientId, + Data, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "clientId" | "client_id" => Ok(GeneratedField::ClientId), + "data" => Ok(GeneratedField::Data), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = Misbehaviour; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct icon.lightclient.v1.wasm.Misbehaviour") + } + + fn visit_map(self, mut map: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut client_id__ = None; + let mut data__ = None; + while let Some(k) = map.next_key()? { + match k { + GeneratedField::ClientId => { + if client_id__.is_some() { + return Err(serde::de::Error::duplicate_field("clientId")); + } + client_id__ = Some(map.next_value()?); + } + GeneratedField::Data => { + if data__.is_some() { + return Err(serde::de::Error::duplicate_field("data")); + } + data__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + } + } + Ok(Misbehaviour { + client_id: client_id__.unwrap_or_default(), + data: data__.unwrap_or_default(), + }) + } + } + deserializer.deserialize_struct("icon.lightclient.v1.wasm.Misbehaviour", FIELDS, GeneratedVisitor) + } +} diff --git a/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.rs b/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.rs new file mode 100644 index 000000000..f45550ddf --- /dev/null +++ b/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.rs @@ -0,0 +1,189 @@ +// @generated +/// Wasm light client's Client state +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ClientState { + #[prost(bytes="vec", tag="1")] + pub data: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="2")] + pub code_id: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="3")] + pub latest_height: ::core::option::Option, +} +/// Wasm light client's ConsensusState +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConsensusState { + #[prost(bytes="vec", tag="1")] + pub data: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="2")] + pub code_id: ::prost::alloc::vec::Vec, + /// timestamp that corresponds to the block height in which the ConsensusState + /// was stored. + #[prost(uint64, tag="3")] + pub timestamp: u64, + /// commitment root + #[prost(message, optional, tag="4")] + pub root: ::core::option::Option, +} +/// Wasm light client Header +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Header { + #[prost(bytes="vec", tag="1")] + pub data: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag="2")] + pub height: ::core::option::Option, +} +/// Wasm light client Misbehaviour +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Misbehaviour { + #[prost(string, tag="1")] + pub client_id: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="2")] + pub data: ::prost::alloc::vec::Vec, +} +/// Encoded file descriptor set for the `icon.lightclient.wasm.v1` package +pub const FILE_DESCRIPTOR_SET: &[u8] = &[ + 0x0a, 0x93, 0x11, 0x0a, 0x1e, 0x69, 0x63, 0x6f, 0x6e, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x76, 0x31, 0x1a, 0x14, 0x67, + 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x30, 0x32, 0x2d, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x2f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x23, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x32, 0x33, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x01, 0x0a, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, + 0x49, 0x64, 0x12, 0x61, 0x0a, 0x0d, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x1c, 0xc8, 0xde, 0x1f, 0x00, 0xf2, + 0xde, 0x1f, 0x14, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, + 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x52, 0x0c, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x48, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x9d, 0x01, 0x0a, 0x0e, + 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3a, 0x0a, 0x04, 0x72, 0x6f, 0x6f, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, + 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x71, 0x0a, 0x06, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x15, 0xc8, 0xde, 0x1f, 0x00, 0xf2, + 0xde, 0x1f, 0x0d, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, + 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x5b, + 0x0a, 0x0c, 0x4d, 0x69, 0x73, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x12, 0x31, + 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x14, 0xf2, 0xde, 0x1f, 0x10, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x22, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xec, 0x01, 0x0a, 0x1c, + 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x57, 0x61, + 0x73, 0x6d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x69, 0x62, 0x63, + 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x35, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x2f, 0x6c, + 0x69, 0x67, 0x68, 0x74, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x30, 0x38, 0x2d, + 0x77, 0x61, 0x73, 0x6d, 0x3b, 0x77, 0x61, 0x73, 0x6d, 0xa2, 0x02, 0x03, 0x49, 0x4c, 0x57, 0xaa, + 0x02, 0x18, 0x49, 0x63, 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x57, 0x61, 0x73, 0x6d, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x18, 0x49, 0x63, 0x6f, + 0x6e, 0x5c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x57, 0x61, + 0x73, 0x6d, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x24, 0x49, 0x63, 0x6f, 0x6e, 0x5c, 0x4c, 0x69, 0x67, + 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, 0x56, 0x31, + 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1b, 0x49, + 0x63, 0x6f, 0x6e, 0x3a, 0x3a, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x3a, 0x3a, 0x57, 0x61, 0x73, 0x6d, 0x3a, 0x3a, 0x56, 0x31, 0x4a, 0xf1, 0x09, 0x0a, 0x06, 0x12, + 0x04, 0x01, 0x00, 0x2e, 0x01, 0x0a, 0x08, 0x0a, 0x01, 0x0c, 0x12, 0x03, 0x01, 0x00, 0x12, 0x0a, + 0x08, 0x0a, 0x01, 0x02, 0x12, 0x03, 0x02, 0x00, 0x21, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x00, 0x12, + 0x03, 0x04, 0x00, 0x1e, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x01, 0x12, 0x03, 0x05, 0x00, 0x25, 0x0a, + 0x09, 0x0a, 0x02, 0x03, 0x02, 0x12, 0x03, 0x06, 0x00, 0x2d, 0x0a, 0x08, 0x0a, 0x01, 0x08, 0x12, + 0x03, 0x08, 0x00, 0x55, 0x0a, 0x09, 0x0a, 0x02, 0x08, 0x0b, 0x12, 0x03, 0x08, 0x00, 0x55, 0x0a, + 0x2e, 0x0a, 0x02, 0x04, 0x00, 0x12, 0x04, 0x0b, 0x00, 0x11, 0x01, 0x1a, 0x22, 0x20, 0x57, 0x61, + 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x27, + 0x73, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, + 0x0a, 0x0a, 0x03, 0x04, 0x00, 0x01, 0x12, 0x03, 0x0b, 0x08, 0x13, 0x0a, 0x0a, 0x0a, 0x03, 0x04, + 0x00, 0x07, 0x12, 0x03, 0x0c, 0x02, 0x32, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x00, 0x07, 0x81, 0xf4, + 0x03, 0x12, 0x03, 0x0c, 0x02, 0x32, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x00, 0x12, 0x03, + 0x0d, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x05, 0x12, 0x03, 0x0d, 0x02, + 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x01, 0x12, 0x03, 0x0d, 0x1c, 0x20, 0x0a, + 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x03, 0x12, 0x03, 0x0d, 0x2c, 0x2d, 0x0a, 0x0b, 0x0a, + 0x04, 0x04, 0x00, 0x02, 0x01, 0x12, 0x03, 0x0e, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, + 0x02, 0x01, 0x05, 0x12, 0x03, 0x0e, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, + 0x01, 0x12, 0x03, 0x0e, 0x1c, 0x23, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x03, 0x12, + 0x03, 0x0e, 0x2c, 0x2d, 0x0a, 0x0c, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x02, 0x12, 0x04, 0x0f, 0x02, + 0x10, 0x56, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x06, 0x12, 0x03, 0x0f, 0x02, 0x1f, + 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x01, 0x12, 0x03, 0x0f, 0x20, 0x2d, 0x0a, 0x0c, + 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x03, 0x12, 0x03, 0x0f, 0x30, 0x31, 0x0a, 0x0c, 0x0a, 0x05, + 0x04, 0x00, 0x02, 0x02, 0x08, 0x12, 0x03, 0x10, 0x06, 0x55, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x00, + 0x02, 0x02, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x10, 0x07, 0x23, 0x0a, 0x0f, 0x0a, 0x08, 0x04, + 0x00, 0x02, 0x02, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x10, 0x25, 0x54, 0x0a, 0x30, 0x0a, 0x02, + 0x04, 0x01, 0x12, 0x04, 0x14, 0x00, 0x1e, 0x01, 0x1a, 0x24, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, + 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x27, 0x73, 0x20, 0x43, + 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, 0x0a, + 0x0a, 0x03, 0x04, 0x01, 0x01, 0x12, 0x03, 0x14, 0x08, 0x16, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x01, + 0x07, 0x12, 0x03, 0x15, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x01, 0x07, 0x81, 0xf4, 0x03, + 0x12, 0x03, 0x15, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x00, 0x12, 0x03, 0x16, + 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x05, 0x12, 0x03, 0x16, 0x02, 0x07, + 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x01, 0x12, 0x03, 0x16, 0x08, 0x0c, 0x0a, 0x0c, + 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x03, 0x12, 0x03, 0x16, 0x27, 0x28, 0x0a, 0x0b, 0x0a, 0x04, + 0x04, 0x01, 0x02, 0x01, 0x12, 0x03, 0x17, 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, + 0x01, 0x05, 0x12, 0x03, 0x17, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x01, + 0x12, 0x03, 0x17, 0x08, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x03, 0x12, 0x03, + 0x17, 0x27, 0x28, 0x0a, 0x66, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x02, 0x12, 0x03, 0x1b, 0x02, 0x17, + 0x1a, 0x59, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x20, 0x74, 0x68, 0x61, + 0x74, 0x20, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x64, 0x73, 0x20, 0x74, 0x6f, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x20, 0x69, 0x6e, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, + 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x77, + 0x61, 0x73, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x2e, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, + 0x01, 0x02, 0x02, 0x05, 0x12, 0x03, 0x1b, 0x02, 0x08, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, + 0x02, 0x01, 0x12, 0x03, 0x1b, 0x09, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, 0x03, + 0x12, 0x03, 0x1b, 0x15, 0x16, 0x0a, 0x1e, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x03, 0x12, 0x03, 0x1d, + 0x02, 0x31, 0x1a, 0x11, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x20, + 0x72, 0x6f, 0x6f, 0x74, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x06, 0x12, 0x03, + 0x1d, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x01, 0x12, 0x03, 0x1d, 0x28, + 0x2c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x03, 0x12, 0x03, 0x1d, 0x2f, 0x30, 0x0a, + 0x26, 0x0a, 0x02, 0x04, 0x02, 0x12, 0x04, 0x21, 0x00, 0x26, 0x01, 0x1a, 0x1a, 0x20, 0x57, 0x61, + 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x01, 0x12, 0x03, + 0x21, 0x08, 0x0e, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x07, 0x12, 0x03, 0x22, 0x02, 0x2d, 0x0a, + 0x0d, 0x0a, 0x06, 0x04, 0x02, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x22, 0x02, 0x2d, 0x0a, 0x0b, + 0x0a, 0x04, 0x04, 0x02, 0x02, 0x00, 0x12, 0x03, 0x24, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, + 0x02, 0x02, 0x00, 0x05, 0x12, 0x03, 0x24, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, + 0x00, 0x01, 0x12, 0x03, 0x24, 0x1c, 0x20, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x03, + 0x12, 0x03, 0x24, 0x25, 0x26, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x01, 0x12, 0x03, 0x25, + 0x02, 0x74, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x06, 0x12, 0x03, 0x25, 0x02, 0x1f, + 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x01, 0x12, 0x03, 0x25, 0x20, 0x26, 0x0a, 0x0c, + 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x03, 0x12, 0x03, 0x25, 0x29, 0x2a, 0x0a, 0x0c, 0x0a, 0x05, + 0x04, 0x02, 0x02, 0x01, 0x08, 0x12, 0x03, 0x25, 0x2b, 0x73, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x02, + 0x02, 0x01, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x25, 0x2c, 0x48, 0x0a, 0x0f, 0x0a, 0x08, 0x04, + 0x02, 0x02, 0x01, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x25, 0x4a, 0x72, 0x0a, 0x2c, 0x0a, 0x02, + 0x04, 0x03, 0x12, 0x04, 0x29, 0x00, 0x2e, 0x01, 0x1a, 0x20, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, + 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x4d, 0x69, 0x73, + 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, + 0x01, 0x12, 0x03, 0x29, 0x08, 0x14, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, 0x07, 0x12, 0x03, 0x2a, + 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x03, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x2a, 0x02, + 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x00, 0x12, 0x03, 0x2c, 0x02, 0x45, 0x0a, 0x0c, + 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x05, 0x12, 0x03, 0x2c, 0x02, 0x08, 0x0a, 0x0c, 0x0a, 0x05, + 0x04, 0x03, 0x02, 0x00, 0x01, 0x12, 0x03, 0x2c, 0x09, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, + 0x02, 0x00, 0x03, 0x12, 0x03, 0x2c, 0x15, 0x16, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, + 0x08, 0x12, 0x03, 0x2c, 0x17, 0x44, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x03, 0x02, 0x00, 0x08, 0xee, + 0xfb, 0x03, 0x12, 0x03, 0x2c, 0x18, 0x43, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x01, 0x12, + 0x03, 0x2d, 0x02, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x05, 0x12, 0x03, 0x2d, + 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x12, 0x03, 0x2d, 0x09, 0x0d, + 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x03, 0x12, 0x03, 0x2d, 0x15, 0x16, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +]; +include!("icon.lightclient.wasm.v1.serde.rs"); +// @@protoc_insertion_point(module) \ No newline at end of file diff --git a/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.serde.rs b/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.serde.rs new file mode 100644 index 000000000..68519e03b --- /dev/null +++ b/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.serde.rs @@ -0,0 +1,502 @@ +// @generated +impl serde::Serialize for ClientState { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if !self.data.is_empty() { + len += 1; + } + if !self.code_id.is_empty() { + len += 1; + } + if self.latest_height.is_some() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("icon.lightclient.wasm.v1.ClientState", len)?; + if !self.data.is_empty() { + struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; + } + if !self.code_id.is_empty() { + struct_ser.serialize_field("code_id", pbjson::private::base64::encode(&self.code_id).as_str())?; + } + if let Some(v) = self.latest_height.as_ref() { + struct_ser.serialize_field("latest_height", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for ClientState { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "data", + "code_id", + "codeId", + "latest_height", + "latestHeight", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Data, + CodeId, + LatestHeight, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "data" => Ok(GeneratedField::Data), + "codeId" | "code_id" => Ok(GeneratedField::CodeId), + "latestHeight" | "latest_height" => Ok(GeneratedField::LatestHeight), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = ClientState; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct icon.lightclient.wasm.v1.ClientState") + } + + fn visit_map(self, mut map: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut data__ = None; + let mut code_id__ = None; + let mut latest_height__ = None; + while let Some(k) = map.next_key()? { + match k { + GeneratedField::Data => { + if data__.is_some() { + return Err(serde::de::Error::duplicate_field("data")); + } + data__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::CodeId => { + if code_id__.is_some() { + return Err(serde::de::Error::duplicate_field("codeId")); + } + code_id__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::LatestHeight => { + if latest_height__.is_some() { + return Err(serde::de::Error::duplicate_field("latestHeight")); + } + latest_height__ = map.next_value()?; + } + } + } + Ok(ClientState { + data: data__.unwrap_or_default(), + code_id: code_id__.unwrap_or_default(), + latest_height: latest_height__, + }) + } + } + deserializer.deserialize_struct("icon.lightclient.wasm.v1.ClientState", FIELDS, GeneratedVisitor) + } +} +impl serde::Serialize for ConsensusState { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if !self.data.is_empty() { + len += 1; + } + if !self.code_id.is_empty() { + len += 1; + } + if self.timestamp != 0 { + len += 1; + } + if self.root.is_some() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("icon.lightclient.wasm.v1.ConsensusState", len)?; + if !self.data.is_empty() { + struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; + } + if !self.code_id.is_empty() { + struct_ser.serialize_field("code_id", pbjson::private::base64::encode(&self.code_id).as_str())?; + } + if self.timestamp != 0 { + struct_ser.serialize_field("timestamp", ToString::to_string(&self.timestamp).as_str())?; + } + if let Some(v) = self.root.as_ref() { + struct_ser.serialize_field("root", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for ConsensusState { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "data", + "code_id", + "codeId", + "timestamp", + "root", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Data, + CodeId, + Timestamp, + Root, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "data" => Ok(GeneratedField::Data), + "codeId" | "code_id" => Ok(GeneratedField::CodeId), + "timestamp" => Ok(GeneratedField::Timestamp), + "root" => Ok(GeneratedField::Root), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = ConsensusState; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct icon.lightclient.wasm.v1.ConsensusState") + } + + fn visit_map(self, mut map: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut data__ = None; + let mut code_id__ = None; + let mut timestamp__ = None; + let mut root__ = None; + while let Some(k) = map.next_key()? { + match k { + GeneratedField::Data => { + if data__.is_some() { + return Err(serde::de::Error::duplicate_field("data")); + } + data__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::CodeId => { + if code_id__.is_some() { + return Err(serde::de::Error::duplicate_field("codeId")); + } + code_id__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::Timestamp => { + if timestamp__.is_some() { + return Err(serde::de::Error::duplicate_field("timestamp")); + } + timestamp__ = + Some(map.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) + ; + } + GeneratedField::Root => { + if root__.is_some() { + return Err(serde::de::Error::duplicate_field("root")); + } + root__ = map.next_value()?; + } + } + } + Ok(ConsensusState { + data: data__.unwrap_or_default(), + code_id: code_id__.unwrap_or_default(), + timestamp: timestamp__.unwrap_or_default(), + root: root__, + }) + } + } + deserializer.deserialize_struct("icon.lightclient.wasm.v1.ConsensusState", FIELDS, GeneratedVisitor) + } +} +impl serde::Serialize for Header { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if !self.data.is_empty() { + len += 1; + } + if self.height.is_some() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("icon.lightclient.wasm.v1.Header", len)?; + if !self.data.is_empty() { + struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; + } + if let Some(v) = self.height.as_ref() { + struct_ser.serialize_field("height", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for Header { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "data", + "height", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Data, + Height, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "data" => Ok(GeneratedField::Data), + "height" => Ok(GeneratedField::Height), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = Header; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct icon.lightclient.wasm.v1.Header") + } + + fn visit_map(self, mut map: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut data__ = None; + let mut height__ = None; + while let Some(k) = map.next_key()? { + match k { + GeneratedField::Data => { + if data__.is_some() { + return Err(serde::de::Error::duplicate_field("data")); + } + data__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + GeneratedField::Height => { + if height__.is_some() { + return Err(serde::de::Error::duplicate_field("height")); + } + height__ = map.next_value()?; + } + } + } + Ok(Header { + data: data__.unwrap_or_default(), + height: height__, + }) + } + } + deserializer.deserialize_struct("icon.lightclient.wasm.v1.Header", FIELDS, GeneratedVisitor) + } +} +impl serde::Serialize for Misbehaviour { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> std::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if !self.client_id.is_empty() { + len += 1; + } + if !self.data.is_empty() { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("icon.lightclient.wasm.v1.Misbehaviour", len)?; + if !self.client_id.is_empty() { + struct_ser.serialize_field("client_id", &self.client_id)?; + } + if !self.data.is_empty() { + struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for Misbehaviour { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "client_id", + "clientId", + "data", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + ClientId, + Data, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> std::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> std::result::Result + where + E: serde::de::Error, + { + match value { + "clientId" | "client_id" => Ok(GeneratedField::ClientId), + "data" => Ok(GeneratedField::Data), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = Misbehaviour; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("struct icon.lightclient.wasm.v1.Misbehaviour") + } + + fn visit_map(self, mut map: V) -> std::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut client_id__ = None; + let mut data__ = None; + while let Some(k) = map.next_key()? { + match k { + GeneratedField::ClientId => { + if client_id__.is_some() { + return Err(serde::de::Error::duplicate_field("clientId")); + } + client_id__ = Some(map.next_value()?); + } + GeneratedField::Data => { + if data__.is_some() { + return Err(serde::de::Error::duplicate_field("data")); + } + data__ = + Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) + ; + } + } + } + Ok(Misbehaviour { + client_id: client_id__.unwrap_or_default(), + data: data__.unwrap_or_default(), + }) + } + } + deserializer.deserialize_struct("icon.lightclient.wasm.v1.Misbehaviour", FIELDS, GeneratedVisitor) + } +} diff --git a/libraries/rust/common/src/icon/mod.rs b/libraries/rust/common/src/icon/mod.rs index f3628fa00..e38262a56 100644 --- a/libraries/rust/common/src/icon/mod.rs +++ b/libraries/rust/common/src/icon/mod.rs @@ -5,6 +5,11 @@ pub mod icon { pub mod v1 { include!("icon.lightclient.v1.rs"); // @@protoc_insertion_point(icon.lightclient.v1) + // @@protoc_insertion_point(attribute:icon.lightclient.v1.wasm) + pub mod wasm { + include!("icon.lightclient.v1.wasm.rs"); + // @@protoc_insertion_point(icon.lightclient.v1.wasm) + } } } pub mod proto { diff --git a/libraries/rust/common/src/icon/tendermint.light.serde.rs b/libraries/rust/common/src/icon/tendermint.light.serde.rs index 4c9a225aa..84c95d54b 100644 --- a/libraries/rust/common/src/icon/tendermint.light.serde.rs +++ b/libraries/rust/common/src/icon/tendermint.light.serde.rs @@ -2160,13 +2160,13 @@ impl serde::Serialize for PublicKey { if let Some(v) = self.sum.as_ref() { match v { public_key::Sum::Ed25519(v) => { - struct_ser.serialize_field("ed25519", pbjson::private::base64::encode(v).as_str())?; + struct_ser.serialize_field("ed25519", pbjson::private::base64::encode(&v).as_str())?; } public_key::Sum::Secp256k1(v) => { - struct_ser.serialize_field("secp256k1", pbjson::private::base64::encode(v).as_str())?; + struct_ser.serialize_field("secp256k1", pbjson::private::base64::encode(&v).as_str())?; } public_key::Sum::Sr25519(v) => { - struct_ser.serialize_field("sr25519", pbjson::private::base64::encode(v).as_str())?; + struct_ser.serialize_field("sr25519", pbjson::private::base64::encode(&v).as_str())?; } } } diff --git a/proto/buf.gen.rust.yaml b/proto/buf.gen.rust.yaml index aa845e0e9..2a46c334b 100644 --- a/proto/buf.gen.rust.yaml +++ b/proto/buf.gen.rust.yaml @@ -20,6 +20,4 @@ plugins: strategy: all opt: - no_features - - name: grpc-gateway - out: .. - opt: logtostderr=true,allow_colon_final_segments=true \ No newline at end of file + \ No newline at end of file diff --git a/proto/icon/lightclient/v1/wasm.proto b/proto/icon/lightclient/v1/wasm.proto new file mode 100644 index 000000000..3e14eaf7d --- /dev/null +++ b/proto/icon/lightclient/v1/wasm.proto @@ -0,0 +1,47 @@ + +syntax = "proto3"; +package icon.lightclient.v1.wasm; + +import "gogoproto/gogo.proto"; +import "core/02-client/Client.proto"; +import "core/23-commitment/commitment.proto"; + +option go_package = "github.com/cosmos/ibc-go/v5/modules/light-clients/08-wasm;wasm"; + +// Wasm light client's Client state +message ClientState { + option (gogoproto.goproto_getters) = false; + bytes data = 1; + bytes code_id = 2; + icon.proto.core.client.Height latest_height = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"latest_height\""]; +} + +// Wasm light client's ConsensusState +message ConsensusState { + option (gogoproto.goproto_getters) = false; + bytes data = 1; + bytes code_id = 2; + + // timestamp that corresponds to the block height in which the ConsensusState + // was stored. + uint64 timestamp = 3; + // commitment root + icon.proto.core.commitment.MerkleRoot root = 4; +} // + +// Wasm light client Header +message Header { + option (gogoproto.goproto_getters) = false; + + bytes data = 1; + icon.proto.core.client.Height height = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"height\""]; +} + +// Wasm light client Misbehaviour +message Misbehaviour { + option (gogoproto.goproto_getters) = false; + + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + bytes data = 2; +} \ No newline at end of file From 776917b590eb833f8d4abf245a5585f112a0fade Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 28 Sep 2023 12:58:05 +0545 Subject: [PATCH 03/64] fix: import ics08wasm --- .../src/ics08_wasm/client_message.rs | 50 +- .../src/ics08_wasm/client_state.rs | 302 +++++------ .../src/ics08_wasm/consensus_state.rs | 140 ++--- .../src/ics08_wasm/mod.rs | 1 + .../src/ics08_wasm/wasm.rs | 508 ++++++++++++++++++ .../cw-wasm-light-client/src/lib.rs | 2 +- .../ibc/core/ics02_client/client_message.rs | 34 ++ .../common/src/ibc/core/ics02_client/mod.rs | 1 + .../src/icon/icon.lightclient.v1.wasm.rs | 260 ++++----- proto/icon/lightclient/v1/wasm.proto | 7 +- 10 files changed, 931 insertions(+), 374 deletions(-) create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/wasm.rs create mode 100644 libraries/rust/common/src/ibc/core/ics02_client/client_message.rs diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs index 196aec083..85c0d4fac 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs @@ -22,16 +22,18 @@ use alloc::{ vec::Vec, }; use common::ibc::{ - core::ics02_client::{client_message::ClientMessage as IbcClientMessage, error::Error}, + core::ics02_client::{client_message::ClientMessage as IbcClientMessage}, Height, }; use core::fmt::Display; #[cfg(feature = "cosmwasm")] use cosmwasm_schema::cw_serde; +use cosmwasm_std::StdError; use cw_common::raw_types::Protobuf; -use ibc_proto_composable::{ - google::protobuf::Any, - ibc::lightclients::wasm::v1::{Header as RawHeader, Misbehaviour as RawMisbehaviour}, +use ibc_proto::google::protobuf::Any; + +use crate::ics08_wasm::wasm::{ + Header as RawHeader, Misbehaviour as RawMisbehaviour, }; use prost::Message; @@ -68,7 +70,7 @@ where AnyClientMessage: TryFrom, >::Error: Display, { - fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { + fn encode_to_vec(&self) -> Result, StdError> { self.encode_vec() } } @@ -87,17 +89,17 @@ where AnyClientMessage: TryFrom, >::Error: Display, { - type Error = Error; + type Error = StdError; fn try_from(any: Any) -> Result { let msg = match &*any.type_url { WASM_HEADER_TYPE_URL => { - Self::Header(Header::decode(&*any.value).map_err(Error::decode_raw_header)?) + Self::Header(Header::decode(&*any.value).map_err(|e|StdError::GenericErr { msg:e.to_string() })?) } WASM_MISBEHAVIOUR_TYPE_URL => Self::Misbehaviour( - Misbehaviour::decode(&*any.value).map_err(Error::decode_raw_misbehaviour)?, + Misbehaviour::decode(&*any.value).map_err(|e|StdError::GenericErr { msg:e.to_string() })?, ), - _ => return Err(Error::malformed_header()), // TODO: choose a better error + _ => return Err(|e|StdError::GenericErr { msg:"Malformed Data".to_string() }), // TODO: choose a better error }; Ok(msg) @@ -149,13 +151,13 @@ where } } -impl Protobuf for Header -where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, -{ -} +// impl Protobuf for Header +// where +// AnyClientMessage: Clone, +// AnyClientMessage: TryFrom, +// >::Error: Display, +// { +// } impl TryFrom for Header where @@ -211,11 +213,11 @@ impl From> for RawMisbehaviour } } -impl From> for RawHeader { - fn from(value: Header) -> Self { - RawHeader { - data: value.data, - height: Some(value.height.into()), - } - } -} +// impl From> for RawHeader { +// fn from(value: Header) -> Self { +// RawHeader { +// data: value.data, +// height: Some(value.height.into()), +// } +// } +// } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs index 4e9290ff6..1d081cd4c 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs @@ -15,12 +15,14 @@ #[cfg(feature = "cosmwasm")] use crate::msg::Base64; -use crate::{client_def::WasmClient, Bytes}; +// use crate::{client_def::WasmClient, Bytes}; +use crate::Bytes; use alloc::{ boxed::Box, string::{String, ToString}, vec::Vec, }; +use cw_common::raw_types::Protobuf; use core::{ fmt::{Debug, Display}, marker::PhantomData, @@ -28,21 +30,21 @@ use core::{ }; #[cfg(feature = "cosmwasm")] use cosmwasm_schema::cw_serde; -use ibc::{ +use common::ibc::{ core::{ ics02_client::{ - client_consensus::ConsensusState as IbcConsensusState, client_def::ClientDef, + // client_consensus::ConsensusState as IbcConsensusState,// client_def::ClientDef, client_state::ClientState as IbcClientState, }, ics24_host::identifier::ChainId, }, - protobuf::Protobuf, Height, }; use ibc_proto::{ - google::protobuf::Any, ibc::lightclients::wasm::v1::ClientState as RawClientState, + google::protobuf::Any, }; use prost::Message; +use crate::ics08_wasm::wasm::{ClientState as RawClientState}; pub const WASM_CLIENT_STATE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.ClientState"; @@ -65,148 +67,148 @@ pub struct ClientState { pub _phantom: PhantomData<(AnyConsensusState, AnyClient)>, } -impl IbcClientState - for ClientState -where - AnyClientState: TryFrom, - >::Error: Display, - AnyConsensusState: IbcConsensusState + Eq, - AnyConsensusState: TryFrom, - >::Error: Display, - AnyClient: ClientDef - + Debug - + Send - + Sync - + Eq, - AnyClientState: IbcClientState + Eq, - AnyClient::ClientMessage: TryFrom, - >::Error: Display, -{ - type UpgradeOptions = Box; - type ClientDef = WasmClient; - - fn chain_id(&self) -> ChainId { - // self.inner.chain_id() - self.inner.chain_id() - } - - fn client_def(&self) -> Self::ClientDef { - let inner = self.inner.client_def(); - WasmClient { - inner: Box::new(inner), - _phantom: Default::default(), - } - } - - fn client_type(&self) -> String { - "08-wasm".to_string() - } - - fn latest_height(&self) -> Height { - self.latest_height - } - - fn frozen_height(&self) -> Option { - self.inner.frozen_height() - } - - fn upgrade( - self, - upgrade_height: Height, - upgrade_options: Self::UpgradeOptions, - chain_id: ChainId, - ) -> Self { - let inner = self - .inner - .upgrade(upgrade_height, *upgrade_options, chain_id); - Self { - inner: Box::new(inner), - ..self - } - } - - fn expired(&self, elapsed: Duration) -> bool { - self.inner.expired(elapsed) - } - - fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { - self.encode_vec() - } -} - -impl - ClientState -where - AnyClientState: TryFrom, - >::Error: Display, - AnyConsensusState: IbcConsensusState + Eq, - AnyConsensusState: TryFrom, - >::Error: Display, - AnyClient: ClientDef - + Debug - + Send - + Sync - + Eq, - AnyClientState: IbcClientState + Eq, - AnyClient::ClientMessage: TryFrom, - >::Error: Display, -{ - pub fn to_any(&self) -> Any { - Any { - type_url: WASM_CLIENT_STATE_TYPE_URL.to_string(), - value: self - .encode_to_vec() - .expect("ClientState is always valid and can be encoded to Any"), - } - } -} - -impl TryFrom - for ClientState -where - AnyClientState: TryFrom, - >::Error: Display, -{ - type Error = String; - - fn try_from(raw: RawClientState) -> Result { - let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; - let inner = AnyClientState::try_from(any).map_err(|e| e.to_string())?; - Ok(Self { - data: raw.data, - code_id: raw.code_id, - inner: Box::new(inner), - latest_height: raw - .latest_height - .map(|h| Height::new(h.revision_number, h.revision_height)) - .unwrap_or_default(), - _phantom: Default::default(), - }) - } -} - -impl - From> for RawClientState -where - AnyClientState: TryFrom, - >::Error: Display, -{ - fn from(client_state: ClientState) -> Self { - Self { - data: client_state.data, - code_id: client_state.code_id, - latest_height: Some(client_state.latest_height.into()), - } - } -} - -impl Protobuf - for ClientState -where - AnyClientState: Clone, - AnyClientState: TryFrom, - >::Error: Display, - AnyConsensusState: Clone, - AnyClient: Clone, -{ -} +// impl IbcClientState +// for ClientState +// where +// AnyClientState: TryFrom, +// >::Error: Display, +// AnyConsensusState: IbcConsensusState + Eq, +// AnyConsensusState: TryFrom, +// >::Error: Display, +// AnyClient: ClientDef +// + Debug +// + Send +// + Sync +// + Eq, +// AnyClientState: IbcClientState + Eq, +// AnyClient::ClientMessage: TryFrom, +// >::Error: Display, +// { +// type UpgradeOptions = Box; +// type ClientDef = WasmClient; + +// fn chain_id(&self) -> ChainId { +// // self.inner.chain_id() +// self.inner.chain_id() +// } + +// fn client_def(&self) -> Self::ClientDef { +// let inner = self.inner.client_def(); +// WasmClient { +// inner: Box::new(inner), +// _phantom: Default::default(), +// } +// } + +// fn client_type(&self) -> String { +// "08-wasm".to_string() +// } + +// fn latest_height(&self) -> Height { +// self.latest_height +// } + +// fn frozen_height(&self) -> Option { +// self.inner.frozen_height() +// } + +// fn upgrade( +// self, +// upgrade_height: Height, +// upgrade_options: Self::UpgradeOptions, +// chain_id: ChainId, +// ) -> Self { +// let inner = self +// .inner +// .upgrade(upgrade_height, *upgrade_options, chain_id); +// Self { +// inner: Box::new(inner), +// ..self +// } +// } + +// fn expired(&self, elapsed: Duration) -> bool { +// self.inner.expired(elapsed) +// } + +// fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { +// self.encode_vec() +// } +// } + +// impl +// ClientState +// where +// AnyClientState: TryFrom, +// >::Error: Display, +// AnyConsensusState: IbcConsensusState + Eq, +// AnyConsensusState: TryFrom, +// >::Error: Display, +// AnyClient: ClientDef +// + Debug +// + Send +// + Sync +// + Eq, +// AnyClientState: IbcClientState + Eq, +// AnyClient::ClientMessage: TryFrom, +// >::Error: Display, +// { +// pub fn to_any(&self) -> Any { +// Any { +// type_url: WASM_CLIENT_STATE_TYPE_URL.to_string(), +// value: self +// .encode_to_vec() +// .expect("ClientState is always valid and can be encoded to Any"), +// } +// } +// } + +// impl TryFrom +// for ClientState +// where +// AnyClientState: TryFrom, +// >::Error: Display, +// { +// type Error = String; + +// fn try_from(raw: RawClientState) -> Result { +// let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; +// let inner = AnyClientState::try_from(any).map_err(|e| e.to_string())?; +// Ok(Self { +// data: raw.data, +// code_id: raw.code_id, +// inner: Box::new(inner), +// latest_height: raw +// .latest_height +// .map(|h| Height::new(h.revision_number, h.revision_height)) +// .unwrap_or_default(), +// _phantom: Default::default(), +// }) +// } +// } + +// impl +// From> for RawClientState +// where +// AnyClientState: TryFrom, +// >::Error: Display, +// { +// fn from(client_state: ClientState) -> Self { +// Self { +// data: client_state.data, +// code_id: client_state.code_id, +// latest_height: Some(client_state.latest_height.into()), +// } +// } +// } + +// impl Protobuf +// for ClientState +// where +// AnyClientState: Clone, +// AnyClientState: TryFrom, +// >::Error: Display, +// AnyConsensusState: Clone, +// AnyClient: Clone, +// { +// } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs index 848cf6298..125fd6192 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs @@ -21,24 +21,27 @@ use alloc::{ string::{String, ToString}, vec::Vec, }; -use core::{ - convert::Infallible, - fmt::{Debug, Display}, -}; -#[cfg(feature = "cosmwasm")] -use cosmwasm_schema::cw_serde; use common::ibc::{ core::{ - ics02_client::client_consensus::ConsensusState as IbcConsensusState, + // ics02_client::client_consensus::ConsensusState as IbcConsensusState, ics23_commitment::commitment::CommitmentRoot, }, - protobuf::Protobuf, + // protobuf::Protobuf, timestamp::Timestamp, }; -use ibc_proto::{ - google::protobuf::Any, ibc::lightclients::wasm::v1::ConsensusState as RawConsensusState, +use cw_common::raw_types::Protobuf; +use ibc_proto::google::protobuf::Any; +use core::{ + convert::Infallible, + fmt::{Debug, Display}, }; +#[cfg(feature = "cosmwasm")] +use cosmwasm_schema::cw_serde; +// use ibc_proto::{ +// google::protobuf::Any, ibc::lightclients::wasm::v1::ConsensusState as RawConsensusState, +// }; use prost::Message; +use crate::ics08_wasm::wasm::{ConsensusState as RawConsensusState}; pub const WASM_CONSENSUS_STATE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.ConsensusState"; @@ -55,63 +58,63 @@ pub struct ConsensusState { pub inner: Box, } -impl IbcConsensusState for ConsensusState -where - AnyConsensusState: Clone + Debug + Send + Sync, - AnyConsensusState: TryFrom, - >::Error: Display, -{ - type Error = Infallible; +// impl IbcConsensusState for ConsensusState +// where +// AnyConsensusState: Clone + Debug + Send + Sync, +// AnyConsensusState: TryFrom, +// >::Error: Display, +// { +// type Error = Infallible; - fn root(&self) -> &CommitmentRoot { - unimplemented!() - } +// fn root(&self) -> &CommitmentRoot { +// unimplemented!() +// } - fn timestamp(&self) -> Timestamp { - Timestamp::from_nanoseconds(self.timestamp).expect("timestamp is valid") - } +// fn timestamp(&self) -> Timestamp { +// Timestamp::from_nanoseconds(self.timestamp).expect("timestamp is valid") +// } - fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { - self.encode_vec() - } -} +// fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { +// self.encode_vec() +// } +// } -impl ConsensusState -where - AnyConsensusState: Clone + Debug + Send + Sync, - AnyConsensusState: TryFrom + IbcConsensusState, - >::Error: Display, -{ - pub fn to_any(&self) -> Any { - Any { - type_url: WASM_CONSENSUS_STATE_TYPE_URL.to_string(), - value: self.encode_to_vec().expect( - "ConsensusState is always valid and can be encoded to Any", - ), - } - } -} +// impl ConsensusState +// where +// AnyConsensusState: Clone + Debug + Send + Sync, +// AnyConsensusState: TryFrom + IbcConsensusState, +// >::Error: Display, +// { +// pub fn to_any(&self) -> Any { +// Any { +// type_url: WASM_CONSENSUS_STATE_TYPE_URL.to_string(), +// value: self.encode_to_vec().expect( +// "ConsensusState is always valid and can be encoded to Any", +// ), +// } +// } +// } -impl TryFrom for ConsensusState -where - AnyConsensusState: TryFrom, - >::Error: Display, -{ - type Error = String; +// impl TryFrom for ConsensusState +// where +// AnyConsensusState: TryFrom, +// >::Error: Display, +// { +// type Error = String; - fn try_from(raw: RawConsensusState) -> Result { - let any = Any::decode(&mut &raw.data[..]) - .map_err(|e| format!("failed to decode ConsensusState::data into Any: {e}"))?; - let inner = AnyConsensusState::try_from(any).map_err(|e| { - format!("failed to decode ConsensusState::data into ConsensusState: {e}") - })?; - Ok(Self { - data: raw.data, - timestamp: raw.timestamp, - inner: Box::new(inner), - }) - } -} +// fn try_from(raw: RawConsensusState) -> Result { +// let any = Any::decode(&mut &raw.data[..]) +// .map_err(|e| format!("failed to decode ConsensusState::data into Any: {e}"))?; +// let inner = AnyConsensusState::try_from(any).map_err(|e| { +// format!("failed to decode ConsensusState::data into ConsensusState: {e}") +// })?; +// Ok(Self { +// data: raw.data, +// timestamp: raw.timestamp, +// inner: Box::new(inner), +// }) +// } +// } impl From> for RawConsensusState { fn from(value: ConsensusState) -> Self { @@ -122,10 +125,11 @@ impl From> for RawConsensus } } -impl Protobuf for ConsensusState -where - AnyConsensusState: Clone, - AnyConsensusState: TryFrom, - >::Error: Display, -{ -} +// impl Protobuf for ConsensusState +// where +// AnyConsensusState: Clone, +// AnyConsensusState: TryFrom, +// >::Error: Display, +// { + +// } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs index 61e7fc88f..6844d55be 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs @@ -1,3 +1,4 @@ pub mod client_message; pub mod client_state; pub mod consensus_state; +pub mod wasm; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/wasm.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/wasm.rs new file mode 100644 index 000000000..64f0a0dd4 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/wasm.rs @@ -0,0 +1,508 @@ +/// Message type to push new wasm code +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MsgPushNewWasmCode { + #[prost(string, tag = "1")] + pub signer: ::prost::alloc::string::String, + #[prost(bytes = "vec", tag = "3")] + pub code: ::prost::alloc::vec::Vec, +} +/// Response in case of successful handling +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MsgPushNewWasmCodeResponse { + #[prost(bytes = "vec", tag = "1")] + pub code_id: ::prost::alloc::vec::Vec, +} +/// Generated client implementations. +#[cfg(feature = "client")] +pub mod msg_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::{http::Uri, *}; + /// Msg defines the ibc/wasm Msg service. + #[derive(Debug, Clone)] + pub struct MsgClient { + inner: tonic::client::Grpc, + } + impl MsgClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: std::convert::TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl MsgClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + Send + 'static, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor(inner: T, interceptor: F) -> MsgClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + >>::Error: + Into + Send + Sync, + { + MsgClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// PushNewWasmCode defines a rpc handler method for PushNewWasmCode. + pub async fn push_new_wasm_code( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/ibc.lightclients.wasm.v1.Msg/PushNewWasmCode", + ); + self.inner.unary(request.into_request(), path, codec).await + } + } +} +/// Generated server implementations. +#[cfg(feature = "server")] +pub mod msg_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with MsgServer. + #[async_trait] + pub trait Msg: Send + Sync + 'static { + /// PushNewWasmCode defines a rpc handler method for PushNewWasmCode. + async fn push_new_wasm_code( + &self, + request: tonic::Request, + ) -> Result, tonic::Status>; + } + /// Msg defines the ibc/wasm Msg service. + #[derive(Debug)] + pub struct MsgServer { + inner: _Inner, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + } + struct _Inner(Arc); + impl MsgServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + let inner = _Inner(inner); + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + } + } + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + } + impl tonic::codegen::Service> for MsgServer + where + T: Msg, + B: Body + Send + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/ibc.lightclients.wasm.v1.Msg/PushNewWasmCode" => { + #[allow(non_camel_case_types)] + struct PushNewWasmCodeSvc(pub Arc); + impl tonic::server::UnaryService for PushNewWasmCodeSvc { + type Response = super::MsgPushNewWasmCodeResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = self.0.clone(); + let fut = async move { (*inner).push_new_wasm_code(request).await }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = PushNewWasmCodeSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + }, + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), + } + } + } + impl Clone for MsgServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(self.0.clone()) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::server::NamedService for MsgServer { + const NAME: &'static str = "ibc.lightclients.wasm.v1.Msg"; + } +} +/// WasmCode query +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WasmCodeQuery { + #[prost(string, tag = "1")] + pub code_id: ::prost::alloc::string::String, +} +/// WasmCode response +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WasmCodeResponse { + #[prost(bytes = "vec", tag = "1")] + pub code: ::prost::alloc::vec::Vec, +} +/// Generated client implementations. +#[cfg(feature = "client")] +pub mod query_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::{http::Uri, *}; + /// Query service for wasm module + #[derive(Debug, Clone)] + pub struct QueryClient { + inner: tonic::client::Grpc, + } + impl QueryClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: std::convert::TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl QueryClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + Send + 'static, + ::Error: Into + Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> QueryClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + >>::Error: + Into + Send + Sync, + { + QueryClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Get Wasm code for given code id + pub async fn wasm_code( + &mut self, + request: impl tonic::IntoRequest, + ) -> Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/ibc.lightclients.wasm.v1.Query/WasmCode"); + self.inner.unary(request.into_request(), path, codec).await + } + } +} +/// Generated server implementations. +#[cfg(feature = "server")] +pub mod query_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with QueryServer. + #[async_trait] + pub trait Query: Send + Sync + 'static { + /// Get Wasm code for given code id + async fn wasm_code( + &self, + request: tonic::Request, + ) -> Result, tonic::Status>; + } + /// Query service for wasm module + #[derive(Debug)] + pub struct QueryServer { + inner: _Inner, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + } + struct _Inner(Arc); + impl QueryServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + let inner = _Inner(inner); + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + } + } + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + } + impl tonic::codegen::Service> for QueryServer + where + T: Query, + B: Body + Send + 'static, + B::Error: Into + Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + let inner = self.inner.clone(); + match req.uri().path() { + "/ibc.lightclients.wasm.v1.Query/WasmCode" => { + #[allow(non_camel_case_types)] + struct WasmCodeSvc(pub Arc); + impl tonic::server::UnaryService for WasmCodeSvc { + type Response = super::WasmCodeResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = self.0.clone(); + let fut = async move { (*inner).wasm_code(request).await }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = WasmCodeSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + }, + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), + } + } + } + impl Clone for QueryServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + } + } + } + impl Clone for _Inner { + fn clone(&self) -> Self { + Self(self.0.clone()) + } + } + impl std::fmt::Debug for _Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } + } + impl tonic::server::NamedService for QueryServer { + const NAME: &'static str = "ibc.lightclients.wasm.v1.Query"; + } +} +/// Wasm light client's Client state +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ClientState { + #[prost(bytes = "vec", tag = "1")] + pub data: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "2")] + pub code_id: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "3")] + pub latest_height: ::core::option::Option, +} +/// Wasm light client's ConsensusState +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConsensusState { + #[prost(bytes = "vec", tag = "1")] + pub data: ::prost::alloc::vec::Vec, + /// timestamp that corresponds to the block height in which the ConsensusState + /// was stored. + #[prost(uint64, tag = "2")] + pub timestamp: u64, +} +/// Wasm light client Header +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Header { + #[prost(bytes = "vec", tag = "1")] + pub data: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + pub height: ::core::option::Option, +} +/// Wasm light client Misbehaviour +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Misbehaviour { + #[prost(bytes = "vec", tag = "1")] + pub data: ::prost::alloc::vec::Vec, +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs index 1160c6c95..bd469d7c3 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs @@ -1,6 +1,6 @@ pub use cw_light_client_common::constants; pub mod contract; -mod ics08_wasm; +//mod ics08_wasm; mod msg; pub use cw_light_client_common::light_client; diff --git a/libraries/rust/common/src/ibc/core/ics02_client/client_message.rs b/libraries/rust/common/src/ibc/core/ics02_client/client_message.rs new file mode 100644 index 000000000..88b4ac9f2 --- /dev/null +++ b/libraries/rust/common/src/ibc/core/ics02_client/client_message.rs @@ -0,0 +1,34 @@ +// Copyright 2022 ComposableFi +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use prost::alloc::vec::Vec; + +/// Abstract of consensus state update information +pub trait ClientMessage: Clone + core::fmt::Debug + Send + Sync { + fn downcast(self) -> Option + where + Self: 'static, + { + ::downcast_ref(&self).cloned() + } + + fn wrap(sub_state: &dyn core::any::Any) -> Option + where + Self: 'static, + { + sub_state.downcast_ref::().cloned() + } + + fn encode_to_vec(&self) -> Result, prost::EncodeError>; +} diff --git a/libraries/rust/common/src/ibc/core/ics02_client/mod.rs b/libraries/rust/common/src/ibc/core/ics02_client/mod.rs index b1dd7ca94..9ead991ee 100644 --- a/libraries/rust/common/src/ibc/core/ics02_client/mod.rs +++ b/libraries/rust/common/src/ibc/core/ics02_client/mod.rs @@ -7,3 +7,4 @@ pub mod events; pub mod header; pub mod height; pub mod misbehaviour; +pub mod client_message; diff --git a/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs b/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs index 5e5e3b38b..b94d3488e 100644 --- a/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs +++ b/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs @@ -46,7 +46,7 @@ pub struct Misbehaviour { } /// Encoded file descriptor set for the `icon.lightclient.v1.wasm` package pub const FILE_DESCRIPTOR_SET: &[u8] = &[ - 0x0a, 0x94, 0x11, 0x0a, 0x1e, 0x69, 0x63, 0x6f, 0x6e, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, + 0x0a, 0xba, 0x11, 0x0a, 0x1e, 0x69, 0x63, 0x6f, 0x6e, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x1a, 0x14, 0x67, @@ -55,135 +55,137 @@ pub const FILE_DESCRIPTOR_SET: &[u8] = &[ 0x65, 0x6e, 0x74, 0x2f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x23, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x32, 0x33, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x01, 0x0a, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, - 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, - 0x49, 0x64, 0x12, 0x61, 0x0a, 0x0d, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x1c, 0xc8, 0xde, 0x1f, 0x00, 0xf2, - 0xde, 0x1f, 0x14, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, - 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x52, 0x0c, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x48, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x9d, 0x01, 0x0a, 0x0e, - 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3a, 0x0a, 0x04, 0x72, 0x6f, 0x6f, - 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, - 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x71, 0x0a, 0x06, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x15, 0xc8, 0xde, 0x1f, 0x00, 0xf2, - 0xde, 0x1f, 0x0d, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, - 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x5b, - 0x0a, 0x0c, 0x4d, 0x69, 0x73, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x12, 0x31, - 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x14, 0xf2, 0xde, 0x1f, 0x10, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x22, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xed, 0x01, 0x0a, 0x1c, - 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x42, 0x09, 0x57, 0x61, - 0x73, 0x6d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x69, 0x62, 0x63, - 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x35, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x2f, 0x6c, - 0x69, 0x67, 0x68, 0x74, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x30, 0x38, 0x2d, - 0x77, 0x61, 0x73, 0x6d, 0x3b, 0x77, 0x61, 0x73, 0x6d, 0xa2, 0x02, 0x04, 0x49, 0x4c, 0x56, 0x57, - 0xaa, 0x02, 0x18, 0x49, 0x63, 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x2e, 0x56, 0x31, 0x2e, 0x57, 0x61, 0x73, 0x6d, 0xca, 0x02, 0x18, 0x49, 0x63, - 0x6f, 0x6e, 0x5c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x56, - 0x31, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0xe2, 0x02, 0x24, 0x49, 0x63, 0x6f, 0x6e, 0x5c, 0x4c, 0x69, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0xa3, 0x01, 0x0a, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x61, 0x0a, + 0x0d, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x42, 0x1c, 0xc8, 0xde, 0x1f, 0x00, 0xf2, 0xde, 0x1f, 0x14, 0x79, 0x61, + 0x6d, 0x6c, 0x3a, 0x22, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x22, 0x52, 0x0c, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x9d, 0x01, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, + 0x07, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, + 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3a, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x2e, + 0x4d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x04, 0x72, 0x6f, 0x6f, 0x74, + 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x71, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x42, 0x15, 0xc8, 0xde, 0x1f, 0x00, 0xf2, 0xde, 0x1f, 0x0d, 0x79, 0x61, + 0x6d, 0x6c, 0x3a, 0x22, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x52, 0x06, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x5b, 0x0a, 0x0c, 0x4d, 0x69, 0x73, + 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x12, 0x31, 0x0a, 0x09, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x14, 0xf2, 0xde, + 0x1f, 0x10, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, + 0x64, 0x22, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xed, 0x01, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x69, + 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, + 0x76, 0x31, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x42, 0x09, 0x57, 0x61, 0x73, 0x6d, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x69, 0x62, 0x63, 0x2d, 0x67, 0x6f, 0x2f, 0x76, + 0x37, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2d, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x30, 0x38, 0x2d, 0x77, 0x61, 0x73, 0x6d, 0x3b, + 0x77, 0x61, 0x73, 0x6d, 0xa2, 0x02, 0x04, 0x49, 0x4c, 0x56, 0x57, 0xaa, 0x02, 0x18, 0x49, 0x63, + 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x56, + 0x31, 0x2e, 0x57, 0x61, 0x73, 0x6d, 0xca, 0x02, 0x18, 0x49, 0x63, 0x6f, 0x6e, 0x5c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x57, 0x61, 0x73, - 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1b, - 0x49, 0x63, 0x6f, 0x6e, 0x3a, 0x3a, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x57, 0x61, 0x73, 0x6d, 0x4a, 0xf1, 0x09, 0x0a, 0x06, - 0x12, 0x04, 0x01, 0x00, 0x2e, 0x01, 0x0a, 0x08, 0x0a, 0x01, 0x0c, 0x12, 0x03, 0x01, 0x00, 0x12, - 0x0a, 0x08, 0x0a, 0x01, 0x02, 0x12, 0x03, 0x02, 0x00, 0x21, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x00, - 0x12, 0x03, 0x04, 0x00, 0x1e, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x01, 0x12, 0x03, 0x05, 0x00, 0x25, - 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x02, 0x12, 0x03, 0x06, 0x00, 0x2d, 0x0a, 0x08, 0x0a, 0x01, 0x08, - 0x12, 0x03, 0x08, 0x00, 0x55, 0x0a, 0x09, 0x0a, 0x02, 0x08, 0x0b, 0x12, 0x03, 0x08, 0x00, 0x55, - 0x0a, 0x2e, 0x0a, 0x02, 0x04, 0x00, 0x12, 0x04, 0x0b, 0x00, 0x11, 0x01, 0x1a, 0x22, 0x20, 0x57, - 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x27, 0x73, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, - 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x00, 0x01, 0x12, 0x03, 0x0b, 0x08, 0x13, 0x0a, 0x0a, 0x0a, 0x03, - 0x04, 0x00, 0x07, 0x12, 0x03, 0x0c, 0x02, 0x32, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x00, 0x07, 0x81, - 0xf4, 0x03, 0x12, 0x03, 0x0c, 0x02, 0x32, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x00, 0x12, - 0x03, 0x0d, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x05, 0x12, 0x03, 0x0d, - 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x01, 0x12, 0x03, 0x0d, 0x1c, 0x20, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x03, 0x12, 0x03, 0x0d, 0x2c, 0x2d, 0x0a, 0x0b, - 0x0a, 0x04, 0x04, 0x00, 0x02, 0x01, 0x12, 0x03, 0x0e, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x00, 0x02, 0x01, 0x05, 0x12, 0x03, 0x0e, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, - 0x01, 0x01, 0x12, 0x03, 0x0e, 0x1c, 0x23, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x03, - 0x12, 0x03, 0x0e, 0x2c, 0x2d, 0x0a, 0x0c, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x02, 0x12, 0x04, 0x0f, - 0x02, 0x10, 0x56, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x06, 0x12, 0x03, 0x0f, 0x02, - 0x1f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x01, 0x12, 0x03, 0x0f, 0x20, 0x2d, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x03, 0x12, 0x03, 0x0f, 0x30, 0x31, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x00, 0x02, 0x02, 0x08, 0x12, 0x03, 0x10, 0x06, 0x55, 0x0a, 0x0f, 0x0a, 0x08, 0x04, - 0x00, 0x02, 0x02, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x10, 0x07, 0x23, 0x0a, 0x0f, 0x0a, 0x08, - 0x04, 0x00, 0x02, 0x02, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x10, 0x25, 0x54, 0x0a, 0x30, 0x0a, - 0x02, 0x04, 0x01, 0x12, 0x04, 0x14, 0x00, 0x1e, 0x01, 0x1a, 0x24, 0x20, 0x57, 0x61, 0x73, 0x6d, - 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x27, 0x73, 0x20, - 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, - 0x0a, 0x0a, 0x03, 0x04, 0x01, 0x01, 0x12, 0x03, 0x14, 0x08, 0x16, 0x0a, 0x0a, 0x0a, 0x03, 0x04, - 0x01, 0x07, 0x12, 0x03, 0x15, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x01, 0x07, 0x81, 0xf4, - 0x03, 0x12, 0x03, 0x15, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x00, 0x12, 0x03, - 0x16, 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x05, 0x12, 0x03, 0x16, 0x02, - 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x01, 0x12, 0x03, 0x16, 0x08, 0x0c, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x03, 0x12, 0x03, 0x16, 0x27, 0x28, 0x0a, 0x0b, 0x0a, - 0x04, 0x04, 0x01, 0x02, 0x01, 0x12, 0x03, 0x17, 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, - 0x02, 0x01, 0x05, 0x12, 0x03, 0x17, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, - 0x01, 0x12, 0x03, 0x17, 0x08, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x03, 0x12, - 0x03, 0x17, 0x27, 0x28, 0x0a, 0x66, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x02, 0x12, 0x03, 0x1b, 0x02, - 0x17, 0x1a, 0x59, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x20, 0x74, 0x68, - 0x61, 0x74, 0x20, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x64, 0x73, 0x20, 0x74, - 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x68, 0x65, 0x69, 0x67, - 0x68, 0x74, 0x20, 0x69, 0x6e, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x74, 0x68, 0x65, 0x20, - 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, - 0x77, 0x61, 0x73, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x2e, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x01, 0x02, 0x02, 0x05, 0x12, 0x03, 0x1b, 0x02, 0x08, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, - 0x02, 0x02, 0x01, 0x12, 0x03, 0x1b, 0x09, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, - 0x03, 0x12, 0x03, 0x1b, 0x15, 0x16, 0x0a, 0x1e, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x03, 0x12, 0x03, - 0x1d, 0x02, 0x31, 0x1a, 0x11, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, - 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x06, 0x12, - 0x03, 0x1d, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x01, 0x12, 0x03, 0x1d, - 0x28, 0x2c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x03, 0x12, 0x03, 0x1d, 0x2f, 0x30, - 0x0a, 0x26, 0x0a, 0x02, 0x04, 0x02, 0x12, 0x04, 0x21, 0x00, 0x26, 0x01, 0x1a, 0x1a, 0x20, 0x57, - 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x20, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x01, 0x12, - 0x03, 0x21, 0x08, 0x0e, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x07, 0x12, 0x03, 0x22, 0x02, 0x2d, - 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x02, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x22, 0x02, 0x2d, 0x0a, - 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x00, 0x12, 0x03, 0x24, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x02, 0x02, 0x00, 0x05, 0x12, 0x03, 0x24, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, - 0x02, 0x00, 0x01, 0x12, 0x03, 0x24, 0x1c, 0x20, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, - 0x03, 0x12, 0x03, 0x24, 0x25, 0x26, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x01, 0x12, 0x03, - 0x25, 0x02, 0x74, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x06, 0x12, 0x03, 0x25, 0x02, - 0x1f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x01, 0x12, 0x03, 0x25, 0x20, 0x26, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x03, 0x12, 0x03, 0x25, 0x29, 0x2a, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x02, 0x02, 0x01, 0x08, 0x12, 0x03, 0x25, 0x2b, 0x73, 0x0a, 0x0f, 0x0a, 0x08, 0x04, - 0x02, 0x02, 0x01, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x25, 0x2c, 0x48, 0x0a, 0x0f, 0x0a, 0x08, - 0x04, 0x02, 0x02, 0x01, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x25, 0x4a, 0x72, 0x0a, 0x2c, 0x0a, - 0x02, 0x04, 0x03, 0x12, 0x04, 0x29, 0x00, 0x2e, 0x01, 0x1a, 0x20, 0x20, 0x57, 0x61, 0x73, 0x6d, - 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x4d, 0x69, - 0x73, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, - 0x03, 0x01, 0x12, 0x03, 0x29, 0x08, 0x14, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, 0x07, 0x12, 0x03, - 0x2a, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x03, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x2a, - 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x00, 0x12, 0x03, 0x2c, 0x02, 0x45, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x05, 0x12, 0x03, 0x2c, 0x02, 0x08, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x03, 0x02, 0x00, 0x01, 0x12, 0x03, 0x2c, 0x09, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x03, 0x02, 0x00, 0x03, 0x12, 0x03, 0x2c, 0x15, 0x16, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, - 0x00, 0x08, 0x12, 0x03, 0x2c, 0x17, 0x44, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x03, 0x02, 0x00, 0x08, - 0xee, 0xfb, 0x03, 0x12, 0x03, 0x2c, 0x18, 0x43, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x01, - 0x12, 0x03, 0x2d, 0x02, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x05, 0x12, 0x03, - 0x2d, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x12, 0x03, 0x2d, 0x09, - 0x0d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x03, 0x12, 0x03, 0x2d, 0x15, 0x16, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0xe2, 0x02, 0x24, 0x49, 0x63, 0x6f, 0x6e, 0x5c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1b, 0x49, 0x63, 0x6f, 0x6e, 0x3a, + 0x3a, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3a, 0x3a, 0x56, 0x31, + 0x3a, 0x3a, 0x57, 0x61, 0x73, 0x6d, 0x4a, 0xfc, 0x09, 0x0a, 0x06, 0x12, 0x04, 0x01, 0x00, 0x2f, + 0x01, 0x0a, 0x08, 0x0a, 0x01, 0x0c, 0x12, 0x03, 0x01, 0x00, 0x12, 0x0a, 0x08, 0x0a, 0x01, 0x02, + 0x12, 0x03, 0x02, 0x00, 0x21, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x00, 0x12, 0x03, 0x04, 0x00, 0x1e, + 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x01, 0x12, 0x03, 0x05, 0x00, 0x25, 0x0a, 0x09, 0x0a, 0x02, 0x03, + 0x02, 0x12, 0x03, 0x06, 0x00, 0x2d, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x03, 0x12, 0x03, 0x07, 0x00, + 0x23, 0x0a, 0x08, 0x0a, 0x01, 0x08, 0x12, 0x03, 0x09, 0x00, 0x55, 0x0a, 0x09, 0x0a, 0x02, 0x08, + 0x0b, 0x12, 0x03, 0x09, 0x00, 0x55, 0x0a, 0x2e, 0x0a, 0x02, 0x04, 0x00, 0x12, 0x04, 0x0c, 0x00, + 0x12, 0x01, 0x1a, 0x22, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x27, 0x73, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x00, 0x01, 0x12, 0x03, 0x0c, + 0x08, 0x13, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x00, 0x07, 0x12, 0x03, 0x0d, 0x02, 0x32, 0x0a, 0x0d, + 0x0a, 0x06, 0x04, 0x00, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x0d, 0x02, 0x32, 0x0a, 0x0b, 0x0a, + 0x04, 0x04, 0x00, 0x02, 0x00, 0x12, 0x03, 0x0e, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, + 0x02, 0x00, 0x05, 0x12, 0x03, 0x0e, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, + 0x01, 0x12, 0x03, 0x0e, 0x1c, 0x20, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x03, 0x12, + 0x03, 0x0e, 0x2c, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x01, 0x12, 0x03, 0x0f, 0x02, + 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x05, 0x12, 0x03, 0x0f, 0x02, 0x07, 0x0a, + 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x01, 0x12, 0x03, 0x0f, 0x1c, 0x23, 0x0a, 0x0c, 0x0a, + 0x05, 0x04, 0x00, 0x02, 0x01, 0x03, 0x12, 0x03, 0x0f, 0x2c, 0x2d, 0x0a, 0x0c, 0x0a, 0x04, 0x04, + 0x00, 0x02, 0x02, 0x12, 0x04, 0x10, 0x02, 0x11, 0x56, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, + 0x02, 0x06, 0x12, 0x03, 0x10, 0x02, 0x1f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x01, + 0x12, 0x03, 0x10, 0x20, 0x2d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x03, 0x12, 0x03, + 0x10, 0x30, 0x31, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x08, 0x12, 0x03, 0x11, 0x06, + 0x55, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x00, 0x02, 0x02, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x11, + 0x07, 0x23, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x00, 0x02, 0x02, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, + 0x11, 0x25, 0x54, 0x0a, 0x30, 0x0a, 0x02, 0x04, 0x01, 0x12, 0x04, 0x15, 0x00, 0x1f, 0x01, 0x1a, + 0x24, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x27, 0x73, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x01, 0x01, 0x12, 0x03, 0x15, 0x08, + 0x16, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x01, 0x07, 0x12, 0x03, 0x16, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, + 0x06, 0x04, 0x01, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x16, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, + 0x04, 0x01, 0x02, 0x00, 0x12, 0x03, 0x17, 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, + 0x00, 0x05, 0x12, 0x03, 0x17, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x01, + 0x12, 0x03, 0x17, 0x08, 0x0c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x03, 0x12, 0x03, + 0x17, 0x27, 0x28, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x01, 0x12, 0x03, 0x18, 0x02, 0x29, + 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x05, 0x12, 0x03, 0x18, 0x02, 0x07, 0x0a, 0x0c, + 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x01, 0x12, 0x03, 0x18, 0x08, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, + 0x04, 0x01, 0x02, 0x01, 0x03, 0x12, 0x03, 0x18, 0x27, 0x28, 0x0a, 0x66, 0x0a, 0x04, 0x04, 0x01, + 0x02, 0x02, 0x12, 0x03, 0x1c, 0x02, 0x17, 0x1a, 0x59, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x69, 0x6e, 0x20, 0x77, 0x68, 0x69, 0x63, + 0x68, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x77, 0x61, 0x73, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, + 0x2e, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, 0x05, 0x12, 0x03, 0x1c, 0x02, 0x08, + 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, 0x01, 0x12, 0x03, 0x1c, 0x09, 0x12, 0x0a, 0x0c, + 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, 0x03, 0x12, 0x03, 0x1c, 0x15, 0x16, 0x0a, 0x1e, 0x0a, 0x04, + 0x04, 0x01, 0x02, 0x03, 0x12, 0x03, 0x1e, 0x02, 0x31, 0x1a, 0x11, 0x20, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, + 0x04, 0x01, 0x02, 0x03, 0x06, 0x12, 0x03, 0x1e, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, + 0x02, 0x03, 0x01, 0x12, 0x03, 0x1e, 0x28, 0x2c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, + 0x03, 0x12, 0x03, 0x1e, 0x2f, 0x30, 0x0a, 0x26, 0x0a, 0x02, 0x04, 0x02, 0x12, 0x04, 0x22, 0x00, + 0x27, 0x01, 0x1a, 0x1a, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x0a, 0x0a, 0x0a, + 0x0a, 0x03, 0x04, 0x02, 0x01, 0x12, 0x03, 0x22, 0x08, 0x0e, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, + 0x07, 0x12, 0x03, 0x23, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x02, 0x07, 0x81, 0xf4, 0x03, + 0x12, 0x03, 0x23, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x00, 0x12, 0x03, 0x25, + 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x05, 0x12, 0x03, 0x25, 0x02, 0x07, + 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x01, 0x12, 0x03, 0x25, 0x1c, 0x20, 0x0a, 0x0c, + 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x03, 0x12, 0x03, 0x25, 0x25, 0x26, 0x0a, 0x0b, 0x0a, 0x04, + 0x04, 0x02, 0x02, 0x01, 0x12, 0x03, 0x26, 0x02, 0x74, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, + 0x01, 0x06, 0x12, 0x03, 0x26, 0x02, 0x1f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x01, + 0x12, 0x03, 0x26, 0x20, 0x26, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x03, 0x12, 0x03, + 0x26, 0x29, 0x2a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x08, 0x12, 0x03, 0x26, 0x2b, + 0x73, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x02, 0x02, 0x01, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x26, + 0x2c, 0x48, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x02, 0x02, 0x01, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, + 0x26, 0x4a, 0x72, 0x0a, 0x2c, 0x0a, 0x02, 0x04, 0x03, 0x12, 0x04, 0x2a, 0x00, 0x2f, 0x01, 0x1a, + 0x20, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x20, 0x4d, 0x69, 0x73, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, + 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, 0x01, 0x12, 0x03, 0x2a, 0x08, 0x14, 0x0a, 0x0a, 0x0a, + 0x03, 0x04, 0x03, 0x07, 0x12, 0x03, 0x2b, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x03, 0x07, + 0x81, 0xf4, 0x03, 0x12, 0x03, 0x2b, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x00, + 0x12, 0x03, 0x2d, 0x02, 0x45, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x05, 0x12, 0x03, + 0x2d, 0x02, 0x08, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x01, 0x12, 0x03, 0x2d, 0x09, + 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x03, 0x12, 0x03, 0x2d, 0x15, 0x16, 0x0a, + 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x08, 0x12, 0x03, 0x2d, 0x17, 0x44, 0x0a, 0x0f, 0x0a, + 0x08, 0x04, 0x03, 0x02, 0x00, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x2d, 0x18, 0x43, 0x0a, 0x0b, + 0x0a, 0x04, 0x04, 0x03, 0x02, 0x01, 0x12, 0x03, 0x2e, 0x02, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, + 0x03, 0x02, 0x01, 0x05, 0x12, 0x03, 0x2e, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, + 0x01, 0x01, 0x12, 0x03, 0x2e, 0x09, 0x0d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x03, + 0x12, 0x03, 0x2e, 0x15, 0x16, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, ]; include!("icon.lightclient.v1.wasm.serde.rs"); // @@protoc_insertion_point(module) \ No newline at end of file diff --git a/proto/icon/lightclient/v1/wasm.proto b/proto/icon/lightclient/v1/wasm.proto index 3e14eaf7d..70902208f 100644 --- a/proto/icon/lightclient/v1/wasm.proto +++ b/proto/icon/lightclient/v1/wasm.proto @@ -5,8 +5,9 @@ package icon.lightclient.v1.wasm; import "gogoproto/gogo.proto"; import "core/02-client/Client.proto"; import "core/23-commitment/commitment.proto"; +import "google/protobuf/any.proto"; -option go_package = "github.com/cosmos/ibc-go/v5/modules/light-clients/08-wasm;wasm"; +option go_package = "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm;wasm"; // Wasm light client's Client state message ClientState { @@ -44,4 +45,6 @@ message Misbehaviour { string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; bytes data = 2; -} \ No newline at end of file +} + + From 267637f9fb134d9aac07652d8a7bf697fcb2b03d Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Fri, 29 Sep 2023 08:44:02 +0545 Subject: [PATCH 04/64] fix: import wasm-08 --- Cargo.lock | 199 +++++++++++++++++- .../src/ics03_connection/connection.rs | 2 +- .../src/light_client.rs | 12 +- .../src/query_handler.rs | 45 ++-- .../cw-light-client-common/src/state.rs | 42 ++-- .../cw-light-client-common/src/traits.rs | 20 +- .../cw-wasm-light-client/Cargo.toml | 3 +- .../cw-wasm-light-client/src/msg.rs | 11 +- .../common/src/icon/tendermint.light.serde.rs | 6 +- 9 files changed, 277 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f32b40bd7..ff0f8c631 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -192,6 +192,18 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -313,7 +325,7 @@ dependencies = [ "hex", "hex-literal 0.3.4", "ibc-proto 0.26.0", - "ics23", + "ics23 0.9.0", "pbjson", "pbjson-types", "prost 0.11.9", @@ -327,7 +339,7 @@ dependencies = [ "sha2 0.10.6", "sha3", "subtle-encoding", - "tendermint", + "tendermint 0.29.1", "test-log", "test-utils", "time", @@ -350,7 +362,7 @@ dependencies = [ "hex", "hex-literal 0.3.4", "ibc-proto 0.26.0", - "ics23", + "ics23 0.9.0", "pbjson", "pbjson-types", "prost 0.11.9", @@ -364,7 +376,7 @@ dependencies = [ "sha2 0.10.6", "sha3", "subtle-encoding", - "tendermint", + "tendermint 0.29.1", "time", ] @@ -374,6 +386,15 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "cosmwasm" version = "0.7.2" @@ -627,7 +648,7 @@ dependencies = [ "cw-xcall-ibc-connection", "cw-xcall-lib", "hex", - "ibc", + "ibc 0.32.0", "prost 0.11.9", "strum", "strum_macros", @@ -828,7 +849,8 @@ dependencies = [ "getrandom", "hex", "hex-literal 0.4.1", - "ibc-proto 0.18.0", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=main)", + "ics08-wasm", "prost 0.11.9", "schemars 0.8.12", "serde", @@ -1094,6 +1116,16 @@ dependencies = [ "libc", ] +[[package]] +name = "eyre" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -1134,6 +1166,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c606d892c9de11507fa0dcffc116434f94e105d0bbdc4e405b61519464c49d7b" dependencies = [ + "eyre", "paste", ] @@ -1149,6 +1182,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" version = "0.3.28" @@ -1404,6 +1443,36 @@ dependencies = [ "tokio-io-timeout", ] +[[package]] +name = "ibc" +version = "0.15.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#19c0265110ce33a2d24a69b2e84de69861ee0b21" +dependencies = [ + "cosmwasm-schema", + "derive_more", + "flex-error", + "hex", + "ibc-derive", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "ics23 0.10.0", + "log", + "num-traits", + "parity-scale-codec", + "primitive-types", + "prost 0.11.9", + "safe-regex", + "scale-info", + "serde", + "serde_derive", + "serde_json", + "subtle-encoding", + "tendermint 0.28.0", + "tendermint-proto 0.28.0", + "time", + "tracing", + "uint", +] + [[package]] name = "ibc" version = "0.32.0" @@ -1417,7 +1486,7 @@ dependencies = [ "dyn-clone", "erased-serde", "ibc-proto 0.26.0", - "ics23", + "ics23 0.9.0", "num-traits", "parity-scale-codec", "primitive-types", @@ -1429,7 +1498,7 @@ dependencies = [ "serde_json", "sha2 0.10.6", "subtle-encoding", - "tendermint", + "tendermint 0.29.1", "tendermint-light-client-verifier", "tendermint-proto 0.29.1", "time", @@ -1437,6 +1506,18 @@ dependencies = [ "uint", ] +[[package]] +name = "ibc-derive" +version = "0.1.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#19c0265110ce33a2d24a69b2e84de69861ee0b21" +dependencies = [ + "convert_case", + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.59", + "quote 1.0.28", + "syn 1.0.109", +] + [[package]] name = "ibc-proto" version = "0.18.0" @@ -1450,6 +1531,18 @@ dependencies = [ "tonic", ] +[[package]] +name = "ibc-proto" +version = "0.18.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#19c0265110ce33a2d24a69b2e84de69861ee0b21" +dependencies = [ + "base64 0.13.1", + "bytes", + "prost 0.11.9", + "serde", + "tendermint-proto 0.28.0", +] + [[package]] name = "ibc-proto" version = "0.26.0" @@ -1468,6 +1561,20 @@ dependencies = [ "tendermint-proto 0.29.1", ] +[[package]] +name = "ics08-wasm" +version = "0.1.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#19c0265110ce33a2d24a69b2e84de69861ee0b21" +dependencies = [ + "cosmwasm-schema", + "hex", + "ibc 0.15.0", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "prost 0.11.9", + "serde", + "tendermint-proto 0.28.0", +] + [[package]] name = "ics23" version = "0.9.0" @@ -1483,6 +1590,17 @@ dependencies = [ "sha3", ] +[[package]] +name = "ics23" +version = "0.10.0" +source = "git+https://github.com/cosmos/ics23?rev=74ce807b7be39a7e0afb4e2efb8e28a57965f57b#74ce807b7be39a7e0afb4e2efb8e28a57965f57b" +dependencies = [ + "anyhow", + "bytes", + "hex", + "prost 0.11.9", +] + [[package]] name = "impl-serde" version = "0.4.0" @@ -1503,6 +1621,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "indexmap" version = "1.9.3" @@ -1710,9 +1834,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" dependencies = [ "arrayvec", + "bitvec", "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", + "serde", ] [[package]] @@ -1987,6 +2113,12 @@ dependencies = [ "proc-macro2 1.0.59", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -2184,6 +2316,7 @@ version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" dependencies = [ + "bitvec", "cfg-if", "derive_more", "parity-scale-codec", @@ -2554,6 +2687,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tempfile" version = "3.5.0" @@ -2567,6 +2706,32 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "tendermint" +version = "0.28.0" +source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "flex-error", + "futures", + "num-traits", + "once_cell", + "prost 0.11.9", + "prost-types", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto 0.28.0", + "time", + "zeroize", +] + [[package]] name = "tendermint" version = "0.29.1" @@ -2605,7 +2770,7 @@ dependencies = [ "derive_more", "flex-error", "serde", - "tendermint", + "tendermint 0.29.1", "time", ] @@ -2707,6 +2872,7 @@ version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" dependencies = [ + "serde", "time-core", "time-macros", ] @@ -2994,6 +3160,12 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "unicode-xid" version = "0.1.0" @@ -3207,6 +3379,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs index 10c5d63e4..f13112a4a 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs @@ -283,7 +283,7 @@ impl<'a> CwIbcCoreContext<'a> { ) -> Result<(), ContractError> { let connection_commit_key = commitment::connection_commitment_key(connection_id); - let connection_end_bytes = connection_end.encode_vec(); + let connection_end_bytes = connection_end.encode_vec().unwrap(); let commitment_bytes = keccak256(&connection_end_bytes).to_vec(); diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index c24fc45ee..528be1ff9 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -1,6 +1,6 @@ use crate::constants::TRUST_LEVEL; use crate::state::CwContext; -use crate::traits::{ConsensusStateUpdate, IContext, ILightClient}; +use crate::traits::{ConsensusStateUpdate, IContext, ILightClient, IQueryHandler}; use crate::ContractError; use common::icon::icon::lightclient::v1::ConsensusState; use common::icon::icon::lightclient::v1::{ClientState, TrustLevel}; @@ -11,12 +11,12 @@ use cosmwasm_std::Addr; use cw_common::cw_println; use prost::Message; -pub struct IconClient<'a> { - context: CwContext<'a>, +pub struct IconClient<'a,Q:IQueryHandler> { + context: CwContext<'a,Q>, } -impl<'a> IconClient<'a> { - pub fn new(context: CwContext<'a>) -> Self { +impl<'a,Q:IQueryHandler> IconClient<'a,Q> { + pub fn new(context: CwContext<'a,Q>) -> Self { Self { context } } pub fn has_quorum_of(n_validators: u64, votes: u64, trust_level: &TrustLevel) -> bool { @@ -97,7 +97,7 @@ impl<'a> IconClient<'a> { } } -impl ILightClient for IconClient<'_> { +impl<'a,Q:IQueryHandler> ILightClient for IconClient<'a,Q> { type Error = crate::ContractError; fn create_client( diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs index 9a578442a..6e1806656 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs @@ -2,7 +2,7 @@ use std::marker::PhantomData; use crate::{ state::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES}, - traits::Config, + traits::{Config, IQueryHandler}, ContractError, }; use common::{ @@ -19,23 +19,38 @@ use cw_storage_plus::Bound; use prost::Message; -pub struct QueryHandler {} +pub struct QueryHandler; -impl QueryHandler { - pub fn get_consensus_state( +impl IQueryHandler for QueryHandler { + fn get_consensus_state( storage: &dyn Storage, client_id: &str, height: u64, ) -> Result { let data = CONSENSUS_STATES - .load(storage, (client_id.to_string(), height)) - .map_err(|_e| ContractError::ConsensusStateNotFound { - height, - client_id: client_id.to_string(), - })?; - let state = ConsensusState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; + .load(storage, (client_id.to_string(), height)) + .map_err(|_e| ContractError::ConsensusStateNotFound { + height, + client_id: client_id.to_string(), + })?; + let state = ConsensusState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; + Ok(state) + } + + fn get_client_state( + storage: &dyn Storage, + client_id: &str, + ) -> Result { + let data = CLIENT_STATES + .load(storage, client_id.to_string()) + .map_err(|_e| ContractError::ClientStateNotFound(client_id.to_string()))?; + let state = ClientState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; Ok(state) } +} + +impl QueryHandler { + pub fn get_latest_consensus_state( storage: &dyn Storage, @@ -65,16 +80,6 @@ impl QueryHandler { }) } - pub fn get_client_state( - storage: &dyn Storage, - client_id: &str, - ) -> Result { - let data = CLIENT_STATES - .load(storage, client_id.to_string()) - .map_err(|_e| ContractError::ClientStateNotFound(client_id.to_string()))?; - let state = ClientState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; - Ok(state) - } pub fn get_config(storage: &dyn Storage) -> Result { CONFIG diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs index c0a65dd11..b5106b926 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs @@ -1,3 +1,5 @@ +use std::marker::PhantomData; + use common::icon::icon::lightclient::v1::ClientState; use common::icon::icon::lightclient::v1::ConsensusState; @@ -12,8 +14,9 @@ use cw_storage_plus::{Item, Map}; use debug_print::debug_eprintln; use prost::Message; - use crate::query_handler::QueryHandler; +use crate::traits::IQueryHandler; + use crate::traits::Config; use crate::traits::IContext; use crate::ContractError; @@ -25,26 +28,31 @@ pub const PROCESSED_HEIGHTS: Map<(ClientId, u64), u64> = Map::new("PROCESSED_HEI pub const CONFIG: Item = Item::new("CONFIG"); -pub struct CwContext<'a> { +pub struct CwContext<'a,Q:IQueryHandler> { pub storage: &'a mut dyn Storage, pub api: &'a dyn Api, pub env: Env, + pub query:PhantomData + } -impl<'a> CwContext<'a> { +impl<'a,Q:IQueryHandler> CwContext<'a,Q> { pub fn new(deps_mut: DepsMut<'a>, env: Env) -> Self { Self { storage: deps_mut.storage, api: deps_mut.api, env, + query:PhantomData::default() } } } -impl<'a> IContext for CwContext<'a> { +impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { type Error = ContractError; + + fn get_client_state(&self, client_id: &str) -> Result { - QueryHandler::get_client_state(self.storage, client_id) + Q::get_client_state(self.storage, client_id) } fn insert_client_state( @@ -310,12 +318,12 @@ mod tests { // Store client state let client_id = "my-client"; let client_state = ClientState::default(); - CwContext::new(deps.as_mut(), mock_env()) + CwContext::::new(deps.as_mut(), mock_env()) .insert_client_state(client_id, client_state.clone()) .unwrap(); // Retrieve client state - let context = CwContext::new(deps.as_mut(), mock_env()); + let context = CwContext::::new(deps.as_mut(), mock_env()); let result = context.get_client_state(client_id).unwrap(); assert_eq!(client_state, result); } @@ -328,12 +336,12 @@ mod tests { let client_id = "my-client"; let height = 1; let consensus_state = ConsensusState::default(); - CwContext::new(deps.as_mut(), mock_env()) + CwContext::::new(deps.as_mut(), mock_env()) .insert_consensus_state(client_id, height, consensus_state.clone()) .unwrap(); // Retrieve consensus state - let context = CwContext::new(deps.as_mut(), mock_env()); + let context = CwContext::::new(deps.as_mut(), mock_env()); let result = context.get_consensus_state(client_id, height).unwrap(); assert_eq!(consensus_state, result); } @@ -346,7 +354,7 @@ mod tests { let client_id = "my-client"; let height = 1; let time = 1571797419879305533; - CwContext::new(deps.as_mut(), mock_env()) + CwContext::::new(deps.as_mut(), mock_env()) .insert_timestamp_at_height(client_id, height) .unwrap(); @@ -364,7 +372,7 @@ mod tests { let msg = keccak256(b"test message"); let address = "8efcaf2c4ebbf88bf07f3bb44a2869c4c675ad7a"; let signature = hex!("c8b2b5eeb7b54620a0246b2355e42ce6d3bdf1648cd8eae298ebbbe5c3bacc197d5e8bfddb0f1e33778b7fc558c54d35e47c88daa24fff243aa743088e5503d701"); - let context = CwContext::new(deps.as_mut(), mock_env()); + let context = CwContext::::new(deps.as_mut(), mock_env()); let result = context.recover_signer(msg.as_slice(), &signature); assert_eq!(address, hex::encode(result.unwrap())); } @@ -391,7 +399,7 @@ mod tests { ); let address = "b040bff300eee91f7665ac8dcf89eb0871015306"; let signature = signed_header.signatures[0].clone(); - let context = CwContext::new(deps.as_mut(), mock_env()); + let context = CwContext::::new(deps.as_mut(), mock_env()); let result = context .recover_icon_signer(msg.as_slice(), &signature) .unwrap(); @@ -412,7 +420,7 @@ mod tests { ); let address = "b040bff300eee91f7665ac8dcf89eb0871015306"; let signature = signed_header.signatures[0].clone(); - let context = CwContext::new(deps.as_mut(), mock_env()); + let context = CwContext::::new(deps.as_mut(), mock_env()); let result = context .recover_icon_signer(msg.as_slice(), &signature) .unwrap(); @@ -429,7 +437,7 @@ mod tests { CONFIG.save(deps.as_mut().storage, &config).unwrap(); // Retrieve config - let context = CwContext::new(deps.as_mut(), mock_env()); + let context = CwContext::::new(deps.as_mut(), mock_env()); let result = context.get_config().unwrap(); assert_eq!(config, result); } @@ -440,7 +448,7 @@ mod tests { let env = mock_env(); let client_id = "client"; let state = ClientState::default(); - let mut ctx = CwContext::new(deps.as_mut(), env); + let mut ctx = CwContext::::new(deps.as_mut(), env); ctx.insert_client_state(client_id, state.clone()).unwrap(); let loaded = CLIENT_STATES.load(deps.as_ref().storage, client_id.to_string())?; @@ -455,7 +463,7 @@ mod tests { let client_id = "client"; let height = 100; let state = ConsensusState::default(); - let mut ctx = CwContext::new(deps.as_mut(), env); + let mut ctx = CwContext::::new(deps.as_mut(), env); ctx.insert_consensus_state(client_id, height, state.clone()) .unwrap(); @@ -470,7 +478,7 @@ mod tests { let mut deps = mock_dependencies(); let client_id = "client"; let height = 100; - let mut ctx = CwContext::new(deps.as_mut(), mock_env()); + let mut ctx = CwContext::::new(deps.as_mut(), mock_env()); ctx.insert_timestamp_at_height(client_id, height).unwrap(); let loaded = diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs index a5946d480..8bcda2619 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs @@ -4,9 +4,12 @@ use common::icon::icon::lightclient::v1::ConsensusState; use common::icon::icon::types::v1::SignedHeader; use cosmwasm_std::Addr; +use cosmwasm_std::Storage; use serde::Deserialize; use serde::Serialize; +use crate::ContractError; + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ConsensusStateUpdate { // commitment for updated consensusState @@ -74,7 +77,7 @@ pub trait ILightClient { } pub trait IStoreReader {} -pub trait IContext { +pub trait IContext{ type Error; fn get_client_state(&self, client_id: &str) -> Result; @@ -132,3 +135,18 @@ pub trait IContext { fn ensure_owner(&self, caller: Addr) -> Result<(), Self::Error>; fn ensure_ibc_host(&self, caller: Addr) -> Result<(), Self::Error>; } + + +pub trait IQueryHandler{ + fn get_consensus_state( + storage: &dyn Storage, + client_id: &str, + height: u64, + ) -> Result; + + fn get_client_state( + storage: &dyn Storage, + client_id: &str, + ) -> Result; + +} \ No newline at end of file diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml index d4fea0c14..584a13d2c 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml @@ -50,7 +50,8 @@ prost = { workspace=true} serde-json-wasm = {workspace=true} debug_print = {workspace=true} ibc-proto = {package = "ibc-proto", git="https://github.com/ComposableFi/composable-ibc.git", branch = "main"} -base64 = { version = "0.13", default-features = false, features = ["alloc"] } +base64 = { version = "0.13", default-features = false, features = ["alloc"] } +ics08-wasm={ git="https://github.com/ComposableFi/composable-ibc.git", features=["cosmwasm"],branch="master"} [dev-dependencies] cosmwasm = "0.7.2" diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs index 2b4594ae5..0bdc695cd 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -30,7 +30,7 @@ use std::convert::Infallible; // client_message::{ClientMessage, Header, Misbehaviour}, // client_state::ClientState, // }; -use crate::ics08_wasm::{ +use ics08_wasm::{ client_message::Header as WasmHeader, client_state::ClientState as WasmClientState, consensus_state::ConsensusState as WasmConsensusState, }; @@ -147,16 +147,17 @@ impl ContractResult { } } + #[derive(Eq, Default)] #[cw_serde] pub struct FakeInner; impl TryFrom for FakeInner { - type Error = Infallible; + type Error = Infallible; - fn try_from(_: Any) -> Result { - Ok(FakeInner) - } + fn try_from(_: Any) -> Result { + Ok(FakeInner) + } } #[cw_serde] diff --git a/libraries/rust/common/src/icon/tendermint.light.serde.rs b/libraries/rust/common/src/icon/tendermint.light.serde.rs index 84c95d54b..4c9a225aa 100644 --- a/libraries/rust/common/src/icon/tendermint.light.serde.rs +++ b/libraries/rust/common/src/icon/tendermint.light.serde.rs @@ -2160,13 +2160,13 @@ impl serde::Serialize for PublicKey { if let Some(v) = self.sum.as_ref() { match v { public_key::Sum::Ed25519(v) => { - struct_ser.serialize_field("ed25519", pbjson::private::base64::encode(&v).as_str())?; + struct_ser.serialize_field("ed25519", pbjson::private::base64::encode(v).as_str())?; } public_key::Sum::Secp256k1(v) => { - struct_ser.serialize_field("secp256k1", pbjson::private::base64::encode(&v).as_str())?; + struct_ser.serialize_field("secp256k1", pbjson::private::base64::encode(v).as_str())?; } public_key::Sum::Sr25519(v) => { - struct_ser.serialize_field("sr25519", pbjson::private::base64::encode(&v).as_str())?; + struct_ser.serialize_field("sr25519", pbjson::private::base64::encode(v).as_str())?; } } } From faef800f61e12b719e165332bb2a22cacac932fe Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Fri, 29 Sep 2023 11:55:09 +0545 Subject: [PATCH 05/64] fix: generalize context --- contracts/cosmwasm-vm/cw-common/src/utils.rs | 4 +- .../cosmwasm-vm/cw-ibc-core/src/contract.rs | 42 ++++++------ .../cw-ibc-core/src/ics02_client/handler.rs | 2 +- .../src/ics03_connection/connection.rs | 2 +- .../src/ics03_connection/handler.rs | 30 ++++----- .../cw-ibc-core/src/ics04_channel/handler.rs | 12 ++-- .../ics04_channel/packet/acknowledgement.rs | 20 +++--- .../ics04_channel/packet/receive_packet.rs | 14 ++-- .../src/ics04_channel/packet/send_packet.rs | 14 ++-- .../src/light_client.rs | 19 +++--- .../src/query_handler.rs | 29 ++++---- .../cw-light-client-common/src/state.rs | 67 ++++++++++--------- .../cw-light-client-common/src/traits.rs | 43 +++++------- .../cw-xcall-ibc-connection/src/contract.rs | 14 ++-- .../cw-xcall-ibc-connection/src/ibc.rs | 2 +- .../cw-xcall-ibc-connection/src/ibc_host.rs | 2 +- .../src/receive_packet.rs | 2 +- 17 files changed, 153 insertions(+), 165 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-common/src/utils.rs b/contracts/cosmwasm-vm/cw-common/src/utils.rs index c7f281884..6ac392795 100644 --- a/contracts/cosmwasm-vm/cw-common/src/utils.rs +++ b/contracts/cosmwasm-vm/cw-common/src/utils.rs @@ -4,7 +4,7 @@ macro_rules! cw_println { use cosmwasm_std::Api; let res = std::fmt::format(format_args!($($arg)*)); debug_print::debug_println!("{}",res); - $f.api.debug(&res); + $f.debug(&res); }}; } @@ -16,6 +16,6 @@ mod tests { fn test_print_macro() { let q = 10; let mut deps = mock_dependencies(); - cw_println!(deps.as_mut(), "hello {}", q); + cw_println!(deps.as_mut().api, "hello {}", q); } } diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/contract.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/contract.rs index c30f91692..5c16d6768 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/contract.rs @@ -61,7 +61,7 @@ impl<'a> CwIbcCoreContext<'a> { self.init_client_counter(deps.storage, u64::default())?; self.init_connection_counter(deps.storage, u64::default())?; self.set_owner(deps.storage, info.sender)?; - cw_println!(deps, "{:?}", info.funds); + cw_println!(deps.api, "{:?}", info.funds); Ok(Response::new().add_attribute("method", "instantiate")) } @@ -106,12 +106,12 @@ impl<'a> CwIbcCoreContext<'a> { self.register_client(deps, client_type, client_address) } CoreExecuteMsg::CreateClient { msg } => { - cw_println!(deps, "[IBCCore] CreateClient Called"); + cw_println!(deps.api, "[IBCCore] CreateClient Called"); let message: RawMsgCreateClient = Self::raw_from_hex(&msg)?; self.create_client(deps, info, env, message) } CoreExecuteMsg::UpdateClient { msg } => { - cw_println!(deps, "[IBCCore] UpdateClient Called"); + cw_println!(deps.api, "[IBCCore] UpdateClient Called"); let message: RawMsgUpdateClient = Self::raw_from_hex(&msg)?; self.update_client(deps, info, message) } @@ -122,58 +122,58 @@ impl<'a> CwIbcCoreContext<'a> { unimplemented!() } CoreExecuteMsg::ConnectionOpenInit { msg } => { - cw_println!(deps, "[IBCCore] Connection Open Init Called"); + cw_println!(deps.api, "[IBCCore] Connection Open Init Called"); let message: RawMsgConnectionOpenInit = Self::raw_from_hex(&msg)?; self.connection_open_init(deps, message) } CoreExecuteMsg::ConnectionOpenTry { msg } => { - cw_println!(deps, "[IBCCore] Connection Open Try Called"); + cw_println!(deps.api, "[IBCCore] Connection Open Try Called"); let message: RawMsgConnectionOpenTry = Self::raw_from_hex(&msg)?; self.connection_open_try(deps, info, env, message) } CoreExecuteMsg::ConnectionOpenAck { msg } => { - cw_println!(deps, "[IBCCore] Connection Open Ack Called"); + cw_println!(deps.api, "[IBCCore] Connection Open Ack Called"); let message: RawMsgConnectionOpenAck = Self::raw_from_hex(&msg)?; self.connection_open_ack(deps, info, env, message) } CoreExecuteMsg::ConnectionOpenConfirm { msg } => { - cw_println!(deps, "[IBCCore] Connection Open Confirm Called"); + cw_println!(deps.api, "[IBCCore] Connection Open Confirm Called"); let message: RawMsgConnectionOpenConfirm = Self::raw_from_hex(&msg)?; self.connection_open_confirm(deps, env, info, message) } CoreExecuteMsg::ChannelOpenInit { msg } => { - cw_println!(deps, "[IBCCore] Channel Open Init Called"); + cw_println!(deps.api, "[IBCCore] Channel Open Init Called"); let message = Self::raw_from_hex::(&msg)?; self.validate_channel_open_init(deps, info, &message) } CoreExecuteMsg::ChannelOpenTry { msg } => { - cw_println!(deps, "[IBCCore] Channel Open Try Called"); + cw_println!(deps.api, "[IBCCore] Channel Open Try Called"); let message: RawMsgChannelOpenTry = Self::raw_from_hex(&msg)?; self.validate_channel_open_try(deps, info, &message) } CoreExecuteMsg::ChannelOpenAck { msg } => { - cw_println!(deps, "[IBCCore] Channel Open Ack Called"); + cw_println!(deps.api, "[IBCCore] Channel Open Ack Called"); let message: RawMsgChannelOpenAck = Self::raw_from_hex(&msg)?; self.validate_channel_open_ack(deps, info, &message) } CoreExecuteMsg::ChannelOpenConfirm { msg } => { - cw_println!(deps, "[IBCCore] Channel Open Confirm Called"); + cw_println!(deps.api, "[IBCCore] Channel Open Confirm Called"); let message: RawMsgChannelOpenConfirm = Self::raw_from_hex(&msg)?; self.validate_channel_open_confirm(deps, info, &message) } CoreExecuteMsg::ChannelCloseInit { msg } => { - cw_println!(deps, "[IBCCore] Channel Close Init Called"); + cw_println!(deps.api, "[IBCCore] Channel Close Init Called"); let message: RawMsgChannelCloseInit = Self::raw_from_hex(&msg)?; self.validate_channel_close_init(deps, info, &message) } CoreExecuteMsg::ChannelCloseConfirm { msg } => { - cw_println!(deps, "[IBCCore] Channel Close Confirm Called"); + cw_println!(deps.api, "[IBCCore] Channel Close Confirm Called"); let message: RawMsgChannelCloseConfirm = Self::raw_from_hex(&msg)?; self.validate_channel_close_confirm(deps, info, &message) } CoreExecuteMsg::SendPacket { packet } => { - cw_println!(deps, "[IBCCore] Send Packet Called"); + cw_println!(deps.api, "[IBCCore] Send Packet Called"); let packet_bytes = packet.to_bytes().map_err(Into::::into)?; let packet: RawPacket = Message::decode(packet_bytes.as_slice()) .map_err(|error| ContractError::IbcDecodeError { error })?; @@ -181,18 +181,18 @@ impl<'a> CwIbcCoreContext<'a> { self.send_packet(deps, &env, info, packet) } CoreExecuteMsg::ReceivePacket { msg } => { - cw_println!(deps, "[IBCCore] Receive Packet Called"); + cw_println!(deps.api, "[IBCCore] Receive Packet Called"); let message = Self::raw_from_hex::(&msg)?; self.validate_receive_packet(deps, info, env, &message) } CoreExecuteMsg::AcknowledgementPacket { msg } => { - cw_println!(deps, "[IBCCore] Acknowledgement Packet Called"); + cw_println!(deps.api, "[IBCCore] Acknowledgement Packet Called"); let message = Self::raw_from_hex::(&msg)?; self.acknowledgement_packet_validate(deps, info, env, &message) } CoreExecuteMsg::TimeoutPacket { msg } => { - cw_println!(deps, "[IBCCore] Timeout Packet Called"); + cw_println!(deps.api, "[IBCCore] Timeout Packet Called"); let message = Self::raw_from_hex::(&msg)?; self.timeout_packet_validate( deps, @@ -202,7 +202,7 @@ impl<'a> CwIbcCoreContext<'a> { ) } CoreExecuteMsg::TimeoutOnClose { msg } => { - cw_println!(deps, "[IBCCore] Timeout On Close Called"); + cw_println!(deps.api, "[IBCCore] Timeout On Close Called"); let message = Self::raw_from_hex::(&msg)?; self.timeout_packet_validate( deps, @@ -212,7 +212,7 @@ impl<'a> CwIbcCoreContext<'a> { ) } CoreExecuteMsg::BindPort { port_id, address } => { - cw_println!(deps, "[IBCCore] Bind Port Called"); + cw_println!(deps.api, "[IBCCore] Bind Port Called"); let port_id = IbcPortId::from_str(&port_id).map_err(|error| { ContractError::IbcDecodeError { error: DecodeError::new(error.to_string()), @@ -232,7 +232,7 @@ impl<'a> CwIbcCoreContext<'a> { packet, acknowledgement, } => { - cw_println!(deps, "[IBCCore] Write Acknowledgement Called"); + cw_println!(deps.api, "[IBCCore] Write Acknowledgement Called"); let ack = acknowledgement.to_bytes()?; self.write_acknowledgement(deps, info, packet, ack) } @@ -279,7 +279,7 @@ impl<'a> CwIbcCoreContext<'a> { let res = self .consensus_state_any(deps, &IbcClientId::from_str(&client_id).unwrap()) .map_err(|_e| { - cw_println!(deps, "{_e:?}"); + cw_println!(deps.api, "{_e:?}"); ContractError::InvalidClientId { client_id } }) .unwrap(); diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs index eab5c0516..8be8aa6e4 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs @@ -132,7 +132,7 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> { ) -> Result { let client_id = to_ibc_client_id(&message.client_id)?; let header = message - .client_message + .header .ok_or(ContractError::IbcClientError { error: ClientError::MissingRawHeader, })?; diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs index f13112a4a..4385e4f7c 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/connection.rs @@ -27,7 +27,7 @@ impl<'a> CwIbcCoreContext<'a> { conn_id: &ConnectionId, conn_end: &ConnectionEnd, ) -> Result<(), ContractError> { - let data = conn_end.encode_vec(); + let data = conn_end.encode_vec().unwrap(); match self.ibc_store().connections().save(store, conn_id, &data) { Ok(_) => Ok(()), diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs index 2a279ad5a..e3ee09dd8 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs @@ -151,7 +151,7 @@ impl<'a> CwIbcCoreContext<'a> { env: Env, msg: RawMsgConnectionOpenAck, ) -> Result { - cw_println!(deps, "[ConnOpenAck]: Connection Open Ack"); + cw_println!(deps.api, "[ConnOpenAck]: Connection Open Ack"); let message_client_state = msg.client_state.ok_or(ContractError::IbcConnectionError { error: ConnectionError::MissingClientState, })?; @@ -161,13 +161,13 @@ impl<'a> CwIbcCoreContext<'a> { let message_version = to_ibc_version(msg.version)?; let host_height = self.host_height(&env)?; - cw_println!(deps, "[ConnOpenAck]: Host Height {:?}", host_height); + cw_println!(deps.api, "[ConnOpenAck]: Host Height {:?}", host_height); ensure_consensus_height_valid(&host_height, &consensus_height)?; - cw_println!(deps, "[ConnOpenAck]:Consensus Height Valid"); + cw_println!(deps.api, "[ConnOpenAck]:Consensus Height Valid"); self.validate_self_client(message_client_state.clone())?; - cw_println!(deps, "[ConnOpenAck]: Self Client Valid"); + cw_println!(deps.api, "[ConnOpenAck]: Self Client Valid"); let connection_id = to_ibc_connection_id(&msg.connection_id)?; let mut connection_end = self.connection_end(deps.storage, &connection_id)?; @@ -194,7 +194,7 @@ impl<'a> CwIbcCoreContext<'a> { }); } - cw_println!(deps, "[ConnOpenAck]: State Matched"); + cw_println!(deps.api, "[ConnOpenAck]: State Matched"); let consensus_state = self.consensus_state(deps.as_ref(), client_id, &proof_height)?; @@ -218,7 +218,7 @@ impl<'a> CwIbcCoreContext<'a> { to_vec(&counterparty_prefix)?, msg.proof_try, connection_path, - expected_connection_end.encode_vec(), + expected_connection_end.encode_vec().unwrap(), ); let client_state_path = commitment::client_state_path(counterparty_client_id); @@ -267,7 +267,7 @@ impl<'a> CwIbcCoreContext<'a> { )?; self.store_connection(deps.storage, &connection_id, &connection_end)?; - cw_println!(deps, "[ConnOpenAckReply]: Connection Stored"); + cw_println!(deps.api, "[ConnOpenAckReply]: Connection Stored"); self.update_connection_commitment(deps.storage, &connection_id, &connection_end)?; @@ -356,7 +356,7 @@ impl<'a> CwIbcCoreContext<'a> { cw_println!( deps, "[ConnOpenTry]: expected counterpart connection_end:{:?}", - HexString::from_bytes(&expected_connection_end.encode_vec()) + HexString::from_bytes(&expected_connection_end.encode_vec().unwrap()) ); let consensus_state = self.consensus_state(deps.as_ref(), &client_id, &proof_height)?; @@ -378,7 +378,7 @@ impl<'a> CwIbcCoreContext<'a> { to_vec(&counterparty_prefix).map_err(ContractError::Std)?, message.proof_init, counterparty_connection_path, - expected_connection_end.encode_vec(), + expected_connection_end.encode_vec().unwrap(), ); // this is verifying tendermint client state and shouldn't have icon-client as an argument @@ -442,7 +442,7 @@ impl<'a> CwIbcCoreContext<'a> { message_delay_period, ); - cw_println!(deps, "[ConnOpenTryReply]: conn end{:?}", conn_end); + cw_println!(deps.api, "[ConnOpenTryReply]: conn end{:?}", conn_end); let event = create_connection_event( IbcEventType::OpenTryConnection, @@ -483,7 +483,7 @@ impl<'a> CwIbcCoreContext<'a> { _info: MessageInfo, msg: RawMsgConnectionOpenConfirm, ) -> Result { - cw_println!(deps, "[ConnOpenConfirm]: Connection Open Confirm"); + cw_println!(deps.api, "[ConnOpenConfirm]: Connection Open Confirm"); let proof_height = to_ibc_height(msg.proof_height.clone())?; @@ -509,7 +509,7 @@ impl<'a> CwIbcCoreContext<'a> { let counterparty_client_id = counterparty.client_id(); let counterparty_prefix = counterparty.prefix(); let counterparty_conn_id = counterparty.connection_id().cloned(); - cw_println!(deps, "[ConnOpenConfirm]: CounterParty {:?}", &counterparty); + cw_println!(deps.api, "[ConnOpenConfirm]: CounterParty {:?}", &counterparty); ensure_connection_state(&connection_id, &connection_end, &State::TryOpen)?; @@ -530,7 +530,7 @@ impl<'a> CwIbcCoreContext<'a> { to_vec(&counterparty_prefix).map_err(ContractError::Std)?, msg.proof_ack, connection_path, - expected_connection_end.encode_vec(), + expected_connection_end.encode_vec().unwrap(), ); client.verify_connection_open_confirm(deps.as_ref(), verify_connection_state, client_id)?; @@ -550,11 +550,11 @@ impl<'a> CwIbcCoreContext<'a> { )?; self.store_connection(deps.storage, &connection_id, &connection_end)?; - cw_println!(deps, "[ConnOpenConfirmReply]: Connection Stored"); + cw_println!(deps.api, "[ConnOpenConfirmReply]: Connection Stored"); self.update_connection_commitment(deps.storage, &connection_id, &connection_end)?; - cw_println!(deps, "[ConnOpenConfirmReply]: Commitment Stored Stored"); + cw_println!(deps.api, "[ConnOpenConfirmReply]: Commitment Stored Stored"); Ok(Response::new() .add_attribute("method", "execute_connection_open_confirm") diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs index b7ac9b5e7..16145af1f 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs @@ -96,7 +96,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> { let contract_address = self.lookup_modules(deps.storage, message.port_id.clone().as_bytes().to_vec())?; - cw_println!(deps, "contract address is : {:?} ", contract_address); + cw_println!(deps.api, "contract address is : {:?} ", contract_address); channel_end.state = State::Init; self.store_channel_end(deps.storage, &src_port, &src_channel, &channel_end)?; @@ -165,12 +165,12 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> { }, }); } - cw_println!(deps, "Reached in channel open try"); + cw_println!(deps.api, "Reached in channel open try"); let connection_id = channel_end.connection_hops[0].clone(); let connection_end = self.connection_end(deps.storage, &connection_id)?; channel_open_try_msg_validate(&channel_end, &connection_end)?; - cw_println!(deps, "channel open try msg validate "); + cw_println!(deps.api, "channel open try msg validate "); let counter = self.channel_counter(deps.storage)?; let dest_channel = ChannelId::new(counter); // creating new channel_id @@ -209,7 +209,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> { }); } - cw_println!(deps, "after frozen check"); + cw_println!(deps.api, "after frozen check"); let expected_channel_end = ChannelEnd::new( State::Init, *channel_end.ordering(), @@ -236,7 +236,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> { client.verify_channel(deps.as_ref(), verify_channel_state)?; let contract_address = self.lookup_modules(deps.storage, dest_port.as_bytes().to_vec())?; - cw_println!(deps, "contract addres is {:?}", contract_address); + cw_println!(deps.api, "contract addres is {:?}", contract_address); channel_end.state = State::TryOpen; self.store_channel_end(deps.storage, &dest_port, &dest_channel, &channel_end)?; @@ -266,7 +266,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> { let data = cw_common::xcall_connection_msg::ExecuteMsg::IbcChannelOpen { msg: sub_message }; let data = to_binary(&data).map_err(ContractError::Std)?; - cw_println!(deps, "after converting data to binary "); + cw_println!(deps.api, "after converting data to binary "); let on_chan_open_try = create_channel_submesssage( contract_address, diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/acknowledgement.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/acknowledgement.rs index 789def45d..b23b0904e 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/acknowledgement.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/acknowledgement.rs @@ -38,7 +38,7 @@ impl<'a> CwIbcCoreContext<'a> { env: Env, msg: &RawMessageAcknowledgement, ) -> Result { - cw_println!(deps, "inside acknowledge packet validate "); + cw_println!(deps.api, "inside acknowledge packet validate "); let packet = msg.packet.clone().unwrap(); let src_port = to_ibc_port_id(&packet.source_port)?; let src_channel = to_ibc_channel_id(&packet.source_channel)?; @@ -58,7 +58,7 @@ impl<'a> CwIbcCoreContext<'a> { }, }); } - cw_println!(deps, "chan end on a state matched "); + cw_println!(deps.api, "chan end on a state matched "); let counterparty = Counterparty::new(dst_port.clone(), Some(dst_channel.clone())); if !chan_end_on_a.counterparty_matches(&counterparty) { @@ -69,7 +69,7 @@ impl<'a> CwIbcCoreContext<'a> { }, }); } - cw_println!(deps, "counterparty matched"); + cw_println!(deps.api, "counterparty matched"); let conn_id_on_a = &chan_end_on_a.connection_hops()[0]; let conn_end_on_a = self.connection_end(deps.storage, conn_id_on_a)?; @@ -87,13 +87,13 @@ impl<'a> CwIbcCoreContext<'a> { Sequence::from(packet.sequence), )?; cw_println!( - deps, + deps.api, "Commitment on a {:?}", hex::encode(commitment_on_a.clone()) ); cw_println!( - deps, + deps.api, "from packet the timeout height is :{:?}", packet_timeout_height ); @@ -103,7 +103,7 @@ impl<'a> CwIbcCoreContext<'a> { &packet_timestamp, ); cw_println!( - deps, + deps.api, "computed packet commitment {:?}", hex::encode(&compouted_packet_commitment) ); @@ -116,7 +116,7 @@ impl<'a> CwIbcCoreContext<'a> { }); } - cw_println!(deps, "packet commitment matched"); + cw_println!(deps.api, "packet commitment matched"); if let Order::Ordered = chan_end_on_a.ordering { let next_seq_ack = self.get_next_sequence_ack(deps.storage, &src_port, &src_channel)?; @@ -129,7 +129,7 @@ impl<'a> CwIbcCoreContext<'a> { }); } } - cw_println!(deps, "packet seq matched"); + cw_println!(deps.api, "packet seq matched"); let client_id_on_a = conn_end_on_a.client_id(); let client_state_on_a = self.client_state(deps.as_ref(), client_id_on_a)?; @@ -169,7 +169,7 @@ impl<'a> CwIbcCoreContext<'a> { )?; let acknowledgement = msg.acknowledgement.clone(); - cw_println!(deps, "after matching ackowledgement "); + cw_println!(deps.api, "after matching ackowledgement "); // Getting the module address for on packet timeout call let contract_address = self.lookup_modules(deps.storage, src_port.as_bytes().to_vec())?; @@ -231,7 +231,7 @@ impl<'a> CwIbcCoreContext<'a> { funds: vec![], }); cw_println!( - deps, + deps.api, "after creating client message {:?} ", create_client_message ); diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/receive_packet.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/receive_packet.rs index b33659fc9..f52440cf9 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/receive_packet.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/receive_packet.rs @@ -55,7 +55,7 @@ impl<'a> CwIbcCoreContext<'a> { let channel_end = self.get_channel_end(deps.storage, &dst_port, &dst_channel)?; ensure_channel_state(&dst_channel, &channel_end, &State::Open)?; - cw_println!(deps, "validate recevie packet state_matched"); + cw_println!(deps.api, "validate recevie packet state_matched"); let counterparty = Counterparty::new(src_port.clone(), Some(src_channel.clone())); if !channel_end.counterparty_matches(&counterparty) { @@ -101,7 +101,7 @@ impl<'a> CwIbcCoreContext<'a> { }) .map_err(Into::::into)?; } - cw_println!(deps, "client state created ",); + cw_println!(deps.api, "client state created ",); let consensus_state_of_a_on_b = self.consensus_state(deps.as_ref(), client_id, &proof_height)?; @@ -112,13 +112,13 @@ impl<'a> CwIbcCoreContext<'a> { &packet_timeout_height, &packet_timestamp, ); - cw_println!(deps, "packet is -> {:?}", msg.packet); + cw_println!(deps.api, "packet is -> {:?}", msg.packet); cw_println!( deps, "packet.data is -> {:?}", HexString::from_bytes(&packet.data) ); - cw_println!(deps, "expected commitement created {:?}", packet.sequence); + cw_println!(deps.api, "expected commitement created {:?}", packet.sequence); let commitment_path_on_a = commitment::packet_commitment_path( &src_port, @@ -126,7 +126,7 @@ impl<'a> CwIbcCoreContext<'a> { Sequence::from(packet.sequence), ); - cw_println!(deps, "verify connection delay passed"); + cw_println!(deps.api, "verify connection delay passed"); let verify_packet_data = VerifyPacketData { height: proof_height.to_string(), prefix: connection_end.counterparty().prefix().clone().into_vec(), @@ -139,7 +139,7 @@ impl<'a> CwIbcCoreContext<'a> { let client = self.get_light_client(deps.as_ref().storage, client_id)?; client.verify_packet_data(deps.as_ref(), verify_packet_data, client_id)?; - cw_println!(deps, "before packet already received "); + cw_println!(deps.api, "before packet already received "); let port_id = packet.destination_port.clone(); let contract_address = self.lookup_modules(deps.storage, port_id.as_bytes().to_vec())?; @@ -195,7 +195,7 @@ impl<'a> CwIbcCoreContext<'a> { None, )?; - cw_println!(deps, "event recieve packet: {:?}", event_recieve_packet); + cw_println!(deps.api, "event recieve packet: {:?}", event_recieve_packet); let sub_msg: SubMsg = SubMsg::reply_on_success(receive_packet_message, VALIDATE_ON_PACKET_RECEIVE_ON_MODULE); diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/send_packet.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/send_packet.rs index fca6ee1d0..ba36b74c5 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/send_packet.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/send_packet.rs @@ -45,7 +45,7 @@ impl<'a> CwIbcCoreContext<'a> { } let chan_end_on_a = self.get_channel_end(deps.storage, &src_port, &src_channel)?; - cw_println!(deps, "fetched channel_end"); + cw_println!(deps.api, "fetched channel_end"); if !chan_end_on_a.state_matches(&State::Open) { return Err(ContractError::IbcPacketError { @@ -55,7 +55,7 @@ impl<'a> CwIbcCoreContext<'a> { }, }); } - cw_println!(deps, " channel_end matched"); + cw_println!(deps.api, " channel_end matched"); let counterparty = Counterparty::new(dst_port.clone(), Some(dst_channel.clone())); if !chan_end_on_a.counterparty_matches(&counterparty) { @@ -66,7 +66,7 @@ impl<'a> CwIbcCoreContext<'a> { }, }); } - cw_println!(deps, " counterparty_matched"); + cw_println!(deps.api, " counterparty_matched"); let conn_id_on_a = &chan_end_on_a.connection_hops()[0]; let conn_end_on_a = self.connection_end(deps.storage, conn_id_on_a)?; @@ -89,11 +89,11 @@ impl<'a> CwIbcCoreContext<'a> { let counterparty_timestamp = to_ibc_timestamp(timestamp_at_height)?; // validate packet not expired before send self.validate_packet_not_expired(&packet, counterparty_height, counterparty_timestamp)?; - cw_println!(deps, " check pass: packet expired"); + cw_println!(deps.api, " check pass: packet expired"); let next_seq_send_on_a = self.get_next_sequence_send(deps.storage, &src_port, &src_channel)?; - cw_println!(deps, " fetched next seq send {:?}", next_seq_send_on_a); + cw_println!(deps.api, " fetched next seq send {:?}", next_seq_send_on_a); if Sequence::from(packet.sequence) != next_seq_send_on_a { return Err(ContractError::IbcPacketError { @@ -104,7 +104,7 @@ impl<'a> CwIbcCoreContext<'a> { }); } - cw_println!(deps, " packet seq and next seq matched"); + cw_println!(deps.api, " packet seq and next seq matched"); let packet_timeout_height = to_ibc_timeout_height(packet.timeout_height.clone())?; let packet_timestamp = to_ibc_timestamp(packet.timeout_timestamp)?; @@ -121,7 +121,7 @@ impl<'a> CwIbcCoreContext<'a> { &packet_timestamp, ), )?; - cw_println!(deps, " packet commitment stored"); + cw_println!(deps.api, " packet commitment stored"); let height = env.block.height; self.ibc_store().store_sent_packet( deps.storage, diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index 528be1ff9..dff847d40 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -1,6 +1,6 @@ use crate::constants::TRUST_LEVEL; use crate::state::CwContext; -use crate::traits::{ConsensusStateUpdate, IContext, ILightClient, IQueryHandler}; +use crate::traits::{ConsensusStateUpdate, IContext, ILightClient}; use crate::ContractError; use common::icon::icon::lightclient::v1::ConsensusState; use common::icon::icon::lightclient::v1::{ClientState, TrustLevel}; @@ -11,12 +11,13 @@ use cosmwasm_std::Addr; use cw_common::cw_println; use prost::Message; -pub struct IconClient<'a,Q:IQueryHandler> { - context: CwContext<'a,Q>, +pub struct IconClient { + context: C, } -impl<'a,Q:IQueryHandler> IconClient<'a,Q> { - pub fn new(context: CwContext<'a,Q>) -> Self { +impl IconClient { + + pub fn new(context: C) -> Self { Self { context } } pub fn has_quorum_of(n_validators: u64, votes: u64, trust_level: &TrustLevel) -> bool { @@ -36,7 +37,7 @@ impl<'a,Q:IQueryHandler> IconClient<'a,Q> { .get_network_type_section_decision_hash(&state.src_network_id, state.network_type_id); cw_println!( - self.context, + self.context.api(), "network type section decision hash {}", hex::encode(decision) ); @@ -64,7 +65,7 @@ impl<'a,Q:IQueryHandler> IconClient<'a,Q> { } } if !Self::has_quorum_of(num_validators, votes, trust_level) { - cw_println!(self.context, "Insuffcient Quorom detected"); + cw_println!(self.context.api(), "Insuffcient Quorom detected"); return Err(ContractError::InSuffcientQuorum); } Ok(true) @@ -97,7 +98,7 @@ impl<'a,Q:IQueryHandler> IconClient<'a,Q> { } } -impl<'a,Q:IQueryHandler> ILightClient for IconClient<'a,Q> { +impl ILightClient for IconClient { type Error = crate::ContractError; fn create_client( @@ -122,7 +123,7 @@ impl<'a,Q:IQueryHandler> ILightClient for IconClient<'a,Q> { consensus_state.clone(), )?; cw_println!( - self.context, + self.context.api(), "[CreateClient]: create client called with id {}", client_id ); diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs index 6e1806656..4b4e51afa 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs @@ -2,7 +2,7 @@ use std::marker::PhantomData; use crate::{ state::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES}, - traits::{Config, IQueryHandler}, + traits::{Config}, ContractError, }; use common::{ @@ -21,8 +21,9 @@ use prost::Message; pub struct QueryHandler; -impl IQueryHandler for QueryHandler { - fn get_consensus_state( + +impl QueryHandler { + pub fn get_consensus_state( storage: &dyn Storage, client_id: &str, height: u64, @@ -37,7 +38,7 @@ impl IQueryHandler for QueryHandler { Ok(state) } - fn get_client_state( + pub fn get_client_state( storage: &dyn Storage, client_id: &str, ) -> Result { @@ -47,10 +48,6 @@ impl IQueryHandler for QueryHandler { let state = ClientState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; Ok(state) } -} - -impl QueryHandler { - pub fn get_latest_consensus_state( storage: &dyn Storage, @@ -152,17 +149,17 @@ impl QueryHandler { path: &[u8], ) -> Result { cw_println!( - deps, + deps.api, "[LightClient]: Path Bytes {:?}", HexString::from_bytes(path) ); cw_println!( - deps, + deps.api, "[LightClient]: Value Bytes {:?}", HexString::from_bytes(value) ); let path = keccak256(path).to_vec(); - cw_println!(deps, "[LightClient]: client id is: {:?}", client_id); + cw_println!(deps.api, "[LightClient]: client id is: {:?}", client_id); let state = Self::get_client_state(deps.storage, client_id)?; @@ -180,30 +177,30 @@ impl QueryHandler { let consensus_state: ConsensusState = Self::get_consensus_state(deps.storage, client_id, height)?; cw_println!( - deps, + deps.api, "[LightClient]: Path Hash {:?}", HexString::from_bytes(&path) ); cw_println!( - deps, + deps.api, "[LightClient]: Value Hash {:?}", HexString::from_bytes(&value_hash) ); let leaf = keccak256(&[path, value_hash].concat()); cw_println!( - deps, + deps.api, "[LightClient]: Leaf Value {:?}", HexString::from_bytes(&leaf) ); let message_root = calculate_root(leaf, proof); cw_println!( - deps, + deps.api, "[LightClient]: Stored Message Root {:?} ", hex::encode(consensus_state.message_root.clone()) ); cw_println!( - deps, + deps.api, "[LightClient]: Calculated Message Root : {:?}", HexString::from_bytes(&message_root) ); diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs index b5106b926..a3197d6cb 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs @@ -15,7 +15,7 @@ use debug_print::debug_eprintln; use prost::Message; use crate::query_handler::QueryHandler; -use crate::traits::IQueryHandler; + use crate::traits::Config; use crate::traits::IContext; @@ -28,38 +28,36 @@ pub const PROCESSED_HEIGHTS: Map<(ClientId, u64), u64> = Map::new("PROCESSED_HEI pub const CONFIG: Item = Item::new("CONFIG"); -pub struct CwContext<'a,Q:IQueryHandler> { +pub struct CwContext<'a> { pub storage: &'a mut dyn Storage, pub api: &'a dyn Api, pub env: Env, - pub query:PhantomData } -impl<'a,Q:IQueryHandler> CwContext<'a,Q> { +impl<'a> CwContext<'a> { pub fn new(deps_mut: DepsMut<'a>, env: Env) -> Self { Self { storage: deps_mut.storage, api: deps_mut.api, env, - query:PhantomData::default() } } } -impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { - type Error = ContractError; +impl<'a> IContext for CwContext<'a> { + - fn get_client_state(&self, client_id: &str) -> Result { - Q::get_client_state(self.storage, client_id) + fn get_client_state(&self, client_id: &str) -> Result { + QueryHandler::get_client_state(self.storage, client_id) } fn insert_client_state( &mut self, client_id: &str, state: ClientState, - ) -> Result<(), Self::Error> { + ) -> Result<(),ContractError> { let data = state.encode_to_vec(); CLIENT_STATES .save(self.storage, client_id.to_string(), &data) @@ -70,7 +68,7 @@ impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { &self, client_id: &str, height: u64, - ) -> Result { + ) -> Result { QueryHandler::get_consensus_state(self.storage, client_id, height) } @@ -79,14 +77,14 @@ impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { client_id: &str, height: u64, state: ConsensusState, - ) -> Result<(), Self::Error> { + ) -> Result<(), ContractError> { let data = state.encode_to_vec(); CONSENSUS_STATES .save(self.storage, (client_id.to_string(), height), &data) .map_err(|_e| ContractError::FailedToSaveClientState) } - fn get_timestamp_at_height(&self, client_id: &str, height: u64) -> Result { + fn get_timestamp_at_height(&self, client_id: &str, height: u64) -> Result { QueryHandler::get_timestamp_at_height(self.storage, client_id, height) } @@ -108,11 +106,11 @@ impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { .map(|addr| addr.to_vec()) } - fn get_config(&self) -> Result { + fn get_config(&self) -> Result { QueryHandler::get_config(self.storage) } - fn insert_config(&mut self, config: &Config) -> Result<(), Self::Error> { + fn insert_config(&mut self, config: &Config) -> Result<(),ContractError> { CONFIG .save(self.storage, config) .map_err(|_e| ContractError::FailedToSaveConfig) @@ -122,7 +120,7 @@ impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { &mut self, client_id: &str, height: u64, - ) -> Result<(), Self::Error> { + ) -> Result<(), ContractError> { let time = self.env.block.time.nanos(); PROCESSED_TIMES .save(self.storage, (client_id.to_string(), height), &time) @@ -133,7 +131,7 @@ impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { &mut self, client_id: &str, height: u64, - ) -> Result<(), Self::Error> { + ) -> Result<(), ContractError> { let block_height = self.env.block.height; PROCESSED_HEIGHTS .save(self.storage, (client_id.to_string(), height), &block_height) @@ -152,7 +150,7 @@ impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { &self, client_id: &str, height: u64, - ) -> Result { + ) -> Result { QueryHandler::get_processed_time_at_height(self.storage, client_id, height) } @@ -160,18 +158,18 @@ impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { &self, client_id: &str, height: u64, - ) -> Result { + ) -> Result { QueryHandler::get_processed_blocknumber_at_height(self.storage, client_id, height) } - fn ensure_ibc_host(&self, caller: cosmwasm_std::Addr) -> Result<(), Self::Error> { + fn ensure_ibc_host(&self, caller: cosmwasm_std::Addr) -> Result<(),ContractError> { let config = self.get_config()?; if caller != config.ibc_host { return Err(ContractError::Unauthorized {}); } Ok(()) } - fn ensure_owner(&self, caller: cosmwasm_std::Addr) -> Result<(), Self::Error> { + fn ensure_owner(&self, caller: cosmwasm_std::Addr) -> Result<(),ContractError> { let config = self.get_config()?; debug_eprintln!("owner {:?} caller {}", config.owner, caller.to_string()); if caller != config.owner { @@ -179,6 +177,9 @@ impl<'a,Q:IQueryHandler> IContext for CwContext<'a,Q> { } Ok(()) } + fn api(&self)->& dyn Api { + return self.api + } } #[cfg(test)] @@ -318,12 +319,12 @@ mod tests { // Store client state let client_id = "my-client"; let client_state = ClientState::default(); - CwContext::::new(deps.as_mut(), mock_env()) + CwContext::new(deps.as_mut(), mock_env()) .insert_client_state(client_id, client_state.clone()) .unwrap(); // Retrieve client state - let context = CwContext::::new(deps.as_mut(), mock_env()); + let context = CwContext::new(deps.as_mut(), mock_env()); let result = context.get_client_state(client_id).unwrap(); assert_eq!(client_state, result); } @@ -336,12 +337,12 @@ mod tests { let client_id = "my-client"; let height = 1; let consensus_state = ConsensusState::default(); - CwContext::::new(deps.as_mut(), mock_env()) + CwContext::new(deps.as_mut(), mock_env()) .insert_consensus_state(client_id, height, consensus_state.clone()) .unwrap(); // Retrieve consensus state - let context = CwContext::::new(deps.as_mut(), mock_env()); + let context = CwContext::new(deps.as_mut(), mock_env()); let result = context.get_consensus_state(client_id, height).unwrap(); assert_eq!(consensus_state, result); } @@ -354,7 +355,7 @@ mod tests { let client_id = "my-client"; let height = 1; let time = 1571797419879305533; - CwContext::::new(deps.as_mut(), mock_env()) + CwContext::new(deps.as_mut(), mock_env()) .insert_timestamp_at_height(client_id, height) .unwrap(); @@ -372,7 +373,7 @@ mod tests { let msg = keccak256(b"test message"); let address = "8efcaf2c4ebbf88bf07f3bb44a2869c4c675ad7a"; let signature = hex!("c8b2b5eeb7b54620a0246b2355e42ce6d3bdf1648cd8eae298ebbbe5c3bacc197d5e8bfddb0f1e33778b7fc558c54d35e47c88daa24fff243aa743088e5503d701"); - let context = CwContext::::new(deps.as_mut(), mock_env()); + let context = CwContext::new(deps.as_mut(), mock_env()); let result = context.recover_signer(msg.as_slice(), &signature); assert_eq!(address, hex::encode(result.unwrap())); } @@ -399,7 +400,7 @@ mod tests { ); let address = "b040bff300eee91f7665ac8dcf89eb0871015306"; let signature = signed_header.signatures[0].clone(); - let context = CwContext::::new(deps.as_mut(), mock_env()); + let context = CwContext::new(deps.as_mut(), mock_env()); let result = context .recover_icon_signer(msg.as_slice(), &signature) .unwrap(); @@ -420,7 +421,7 @@ mod tests { ); let address = "b040bff300eee91f7665ac8dcf89eb0871015306"; let signature = signed_header.signatures[0].clone(); - let context = CwContext::::new(deps.as_mut(), mock_env()); + let context = CwContext::new(deps.as_mut(), mock_env()); let result = context .recover_icon_signer(msg.as_slice(), &signature) .unwrap(); @@ -437,7 +438,7 @@ mod tests { CONFIG.save(deps.as_mut().storage, &config).unwrap(); // Retrieve config - let context = CwContext::::new(deps.as_mut(), mock_env()); + let context = CwContext::new(deps.as_mut(), mock_env()); let result = context.get_config().unwrap(); assert_eq!(config, result); } @@ -448,7 +449,7 @@ mod tests { let env = mock_env(); let client_id = "client"; let state = ClientState::default(); - let mut ctx = CwContext::::new(deps.as_mut(), env); + let mut ctx = CwContext::new(deps.as_mut(), env); ctx.insert_client_state(client_id, state.clone()).unwrap(); let loaded = CLIENT_STATES.load(deps.as_ref().storage, client_id.to_string())?; @@ -463,7 +464,7 @@ mod tests { let client_id = "client"; let height = 100; let state = ConsensusState::default(); - let mut ctx = CwContext::::new(deps.as_mut(), env); + let mut ctx = CwContext::new(deps.as_mut(), env); ctx.insert_consensus_state(client_id, height, state.clone()) .unwrap(); @@ -478,7 +479,7 @@ mod tests { let mut deps = mock_dependencies(); let client_id = "client"; let height = 100; - let mut ctx = CwContext::::new(deps.as_mut(), mock_env()); + let mut ctx = CwContext::new(deps.as_mut(), mock_env()); ctx.insert_timestamp_at_height(client_id, height).unwrap(); let loaded = diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs index 8bcda2619..5f7d890d3 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs @@ -4,6 +4,7 @@ use common::icon::icon::lightclient::v1::ConsensusState; use common::icon::icon::types::v1::SignedHeader; use cosmwasm_std::Addr; +use cosmwasm_std::Api; use cosmwasm_std::Storage; use serde::Deserialize; use serde::Serialize; @@ -78,46 +79,46 @@ pub trait ILightClient { pub trait IStoreReader {} pub trait IContext{ - type Error; + - fn get_client_state(&self, client_id: &str) -> Result; + fn get_client_state(&self, client_id: &str) -> Result; fn insert_client_state( &mut self, client_id: &str, state: ClientState, - ) -> Result<(), Self::Error>; + ) -> Result<(), ContractError>; fn get_consensus_state( &self, client_id: &str, height: u64, - ) -> Result; + ) -> Result; fn insert_consensus_state( &mut self, client_id: &str, height: u64, state: ConsensusState, - ) -> Result<(), Self::Error>; + ) -> Result<(), ContractError>; - fn get_timestamp_at_height(&self, client_id: &str, height: u64) -> Result; + fn get_timestamp_at_height(&self, client_id: &str, height: u64) -> Result; fn insert_timestamp_at_height( &mut self, client_id: &str, height: u64, - ) -> Result<(), Self::Error>; + ) -> Result<(), ContractError>; fn insert_blocknumber_at_height( &mut self, client_id: &str, height: u64, - ) -> Result<(), Self::Error>; + ) -> Result<(), ContractError>; fn recover_signer(&self, msg: &[u8], signature: &[u8]) -> Option<[u8; 20]>; fn recover_icon_signer(&self, msg: &[u8], signature: &[u8]) -> Option>; - fn get_config(&self) -> Result; + fn get_config(&self) -> Result; - fn insert_config(&mut self, config: &Config) -> Result<(), Self::Error>; + fn insert_config(&mut self, config: &Config) -> Result<(), ContractError>; fn get_current_block_time(&self) -> u64; fn get_current_block_height(&self) -> u64; @@ -125,28 +126,16 @@ pub trait IContext{ &self, client_id: &str, height: u64, - ) -> Result; + ) -> Result; fn get_processed_block_at_height( &self, client_id: &str, height: u64, - ) -> Result; + ) -> Result; - fn ensure_owner(&self, caller: Addr) -> Result<(), Self::Error>; - fn ensure_ibc_host(&self, caller: Addr) -> Result<(), Self::Error>; + fn ensure_owner(&self, caller: Addr) -> Result<(), ContractError>; + fn ensure_ibc_host(&self, caller: Addr) -> Result<(), ContractError>; + fn api(&self)->& dyn Api; } -pub trait IQueryHandler{ - fn get_consensus_state( - storage: &dyn Storage, - client_id: &str, - height: u64, - ) -> Result; - - fn get_client_state( - storage: &dyn Storage, - client_id: &str, - ) -> Result; - -} \ No newline at end of file diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs index 020df5dab..6a68f0f09 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs @@ -427,14 +427,14 @@ impl<'a> CwIbcConnection<'a> { deps: DepsMut, msg: CwChannelOpenMsg, ) -> Result { - cw_println!(deps, "[IbcConnection]: Called On channel open"); + cw_println!(deps.api, "[IbcConnection]: Called On channel open"); println!("{msg:?}"); let channel = msg.channel(); let ibc_endpoint = channel.endpoint.clone(); check_order(&channel.order)?; - cw_println!(deps, "[IbcConnection]: check order pass"); + cw_println!(deps.api, "[IbcConnection]: check order pass"); self.setup_channel(deps, channel.clone())?; @@ -465,16 +465,16 @@ impl<'a> CwIbcConnection<'a> { msg: CwChannelConnectMsg, ) -> Result { let channel = msg.channel(); - cw_println!(deps, "[IBCConnection]: channel connect called"); + cw_println!(deps.api, "[IBCConnection]: channel connect called"); check_order(&channel.order)?; - cw_println!(deps, "[IBCConnection]: check order pass"); + cw_println!(deps.api, "[IBCConnection]: check order pass"); if let Some(counter_version) = msg.counterparty_version() { check_version(counter_version)?; } - cw_println!(deps, "[IBCConnection]: check version passed"); + cw_println!(deps.api, "[IBCConnection]: check version passed"); self.setup_channel(deps, channel.clone())?; Ok(Response::new() @@ -663,7 +663,7 @@ impl<'a> CwIbcConnection<'a> { self.get_counterparty_nid(deps.storage, &channel.connection_id, &destination.port_id)?; let connection_config = self.get_connection_config(deps.storage, &channel.connection_id)?; let ibc_config = IbcConfig::new(source, destination); - cw_println!(deps, "[IBCConnection]: save ibc config is {:?}", ibc_config); + cw_println!(deps.api, "[IBCConnection]: save ibc config is {:?}", ibc_config); self.store_ibc_config(deps.storage, &nid, &ibc_config)?; @@ -677,7 +677,7 @@ impl<'a> CwIbcConnection<'a> { }, )?; - cw_println!(deps, "[IBCConnection]: Channel Config Stored"); + cw_println!(deps.api, "[IBCConnection]: Channel Config Stored"); Ok(()) } diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc.rs index 3c3434557..e5da1f74d 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc.rs @@ -129,7 +129,7 @@ pub fn ibc_packet_receive( ) -> Result { let call_service = CwIbcConnection::default(); let _channel = msg.packet.dest.channel_id.clone(); - cw_println!(deps, "[IBCConnection]: Packet Received"); + cw_println!(deps.api, "[IBCConnection]: Packet Received"); let result = call_service.do_packet_receive(deps, msg.packet, msg.relayer); match result { diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs index f37f2fd20..004976b8f 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs @@ -62,7 +62,7 @@ impl<'a> CwIbcConnection<'a> { gas_limit: None, reply_on: cosmwasm_std::ReplyOn::Always, }; - cw_println!(deps, "{LOG_PREFIX} Packet Forwarded To IBCHost {ibc_host} "); + cw_println!(deps.api, "{LOG_PREFIX} Packet Forwarded To IBCHost {ibc_host} "); Ok(submessage) } diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/receive_packet.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/receive_packet.rs index 5841606ca..4782a7024 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/receive_packet.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/receive_packet.rs @@ -52,7 +52,7 @@ impl<'a> CwIbcConnection<'a> { self.store_incoming_packet(deps.storage, &channel, sn, packet)?; } } - cw_println!(deps, "[IBCConnection]: forwarding to xcall"); + cw_println!(deps.api, "[IBCConnection]: forwarding to xcall"); let data = n_message.data; let xcall_submessage = self.call_xcall_handle_message(deps.storage, &nid, data)?; From b44406d125ade7039af27c9342bf780aa5957d08 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Fri, 29 Sep 2023 12:14:06 +0545 Subject: [PATCH 06/64] fix: build deps --- Cargo.lock | 516 +----------------- .../cw-ibc-core/src/ics02_client/handler.rs | 12 +- .../src/ics03_connection/handler.rs | 26 +- .../cw-ibc-core/src/ics04_channel/handler.rs | 4 +- .../ics04_channel/packet/receive_packet.rs | 8 +- .../ics04_channel/packet/timeout_on_close.rs | 2 +- .../cw-ibc-core/tests/test_client.rs | 4 +- .../tests/test_execution_messages.rs | 2 +- .../src/light_client.rs | 9 +- .../src/query_handler.rs | 18 +- .../cw-light-client-common/src/state.rs | 27 +- .../cw-light-client-common/src/traits.rs | 10 +- .../cw-wasm-light-client/Cargo.toml | 3 +- .../cw-wasm-light-client/src/msg.rs | 24 +- .../cw-xcall-ibc-connection/src/contract.rs | 8 +- .../cw-xcall-ibc-connection/src/ibc_host.rs | 5 +- .../ibc/core/ics02_client/client_message.rs | 26 +- .../common/src/ibc/core/ics02_client/mod.rs | 2 +- 18 files changed, 92 insertions(+), 614 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff0f8c631..3a262ea46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,21 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "ahash" version = "0.7.6" @@ -57,105 +42,12 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" -[[package]] -name = "async-stream" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" -dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" -dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", -] - -[[package]] -name = "async-trait" -version = "0.1.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b2d0f03b3640e3a630367e40c468cb7f309529c708ed1d88597047b0e7c6ef7" -dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", -] - [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "axum" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" -dependencies = [ - "async-trait", - "axum-core", - "bitflags", - "bytes", - "futures-util", - "http", - "http-body", - "hyper", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "sync_wrapper", - "tower", - "tower-layer", - "tower-service", -] - -[[package]] -name = "axum-core" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http", - "http-body", - "mime", - "rustversion", - "tower-layer", - "tower-service", -] - -[[package]] -name = "backtrace" -version = "0.3.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base16ct" version = "0.1.1" @@ -849,7 +741,6 @@ dependencies = [ "getrandom", "hex", "hex-literal 0.4.1", - "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=main)", "ics08-wasm", "prost 0.11.9", "schemars 0.8.12", @@ -1170,12 +1061,6 @@ dependencies = [ "paste", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "forward_ref" version = "1.0.0" @@ -1270,12 +1155,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" - [[package]] name = "group" version = "0.12.1" @@ -1287,25 +1166,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "h2" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -1373,76 +1233,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "http" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] -name = "hyper" -version = "0.14.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-timeout" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" -dependencies = [ - "hyper", - "pin-project-lite", - "tokio", - "tokio-io-timeout", -] - [[package]] name = "ibc" version = "0.15.0" @@ -1453,7 +1243,7 @@ dependencies = [ "flex-error", "hex", "ibc-derive", - "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "ibc-proto 0.18.0", "ics23 0.10.0", "log", "num-traits", @@ -1518,19 +1308,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ibc-proto" -version = "0.18.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=main#5f59dd19265dbbbf6c9af7d628a4771d10c5cc9a" -dependencies = [ - "base64 0.13.1", - "bytes", - "prost 0.11.9", - "serde", - "tendermint-proto 0.28.0", - "tonic", -] - [[package]] name = "ibc-proto" version = "0.18.0" @@ -1569,7 +1346,7 @@ dependencies = [ "cosmwasm-schema", "hex", "ibc 0.15.0", - "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "ibc-proto 0.18.0", "prost 0.11.9", "serde", "tendermint-proto 0.28.0", @@ -1726,44 +1503,12 @@ dependencies = [ "regex-automata", ] -[[package]] -name = "matchit" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" - [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "multimap" version = "0.8.3" @@ -1800,15 +1545,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "object" -version = "0.30.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.18.0" @@ -1896,12 +1632,6 @@ dependencies = [ "serde", ] -[[package]] -name = "percent-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" - [[package]] name = "petgraph" version = "0.6.3" @@ -1912,26 +1642,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "pin-project" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" -dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", -] - [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1954,12 +1664,6 @@ dependencies = [ "spki", ] -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "prettyplease" version = "0.1.25" @@ -2119,27 +1823,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - [[package]] name = "rand_core" version = "0.5.1" @@ -2225,12 +1908,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - [[package]] name = "rustc-hex" version = "2.1.0" @@ -2546,15 +2223,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - [[package]] name = "smallvec" version = "1.10.0" @@ -2582,16 +2250,6 @@ dependencies = [ "syn 0.15.44", ] -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "spki" version = "0.6.0" @@ -2681,12 +2339,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "tap" version = "1.0.1" @@ -2892,69 +2544,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tokio" -version = "1.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" -dependencies = [ - "autocfg", - "backtrace", - "bytes", - "libc", - "mio", - "pin-project-lite", - "socket2", - "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-macros" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" -dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", -] - -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - [[package]] name = "toml" version = "0.5.11" @@ -2981,70 +2570,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tonic" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" -dependencies = [ - "async-stream", - "async-trait", - "axum", - "base64 0.13.1", - "bytes", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-timeout", - "percent-encoding", - "pin-project", - "prost 0.11.9", - "prost-derive 0.11.9", - "tokio", - "tokio-stream", - "tokio-util", - "tower", - "tower-layer", - "tower-service", - "tracing", - "tracing-futures", -] - -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "indexmap", - "pin-project", - "pin-project-lite", - "rand", - "slab", - "tokio", - "tokio-util", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - [[package]] name = "tracing" version = "0.1.37" @@ -3053,21 +2578,9 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "pin-project-lite", - "tracing-attributes", "tracing-core", ] -[[package]] -name = "tracing-attributes" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" -dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", -] - [[package]] name = "tracing-core" version = "0.1.31" @@ -3078,16 +2591,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "tracing-log" version = "0.1.3" @@ -3130,12 +2633,6 @@ dependencies = [ "tracing-serde", ] -[[package]] -name = "try-lock" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" - [[package]] name = "typenum" version = "1.16.0" @@ -3190,15 +2687,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs index 8be8aa6e4..e2ee6c752 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics02_client/handler.rs @@ -131,11 +131,9 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> { message: RawMsgUpdateClient, ) -> Result { let client_id = to_ibc_client_id(&message.client_id)?; - let header = message - .header - .ok_or(ContractError::IbcClientError { - error: ClientError::MissingRawHeader, - })?; + let header = message.header.ok_or(ContractError::IbcClientError { + error: ClientError::MissingRawHeader, + })?; let client = self.get_light_client(deps.as_ref().storage, &client_id)?; let client_state = self.client_state(deps.as_ref(), &client_id)?; @@ -151,7 +149,7 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> { let sub_msg: SubMsg = client.update_client(&client_id, &header)?; cw_println!( - deps, + deps.api, "Called Update Client On Lightclient for client id:{}", &message.client_id ); @@ -327,7 +325,7 @@ impl<'a> IbcClient for CwIbcCoreContext<'a> { cosmwasm_std::SubMsgResult::Ok(result) => match result.data { Some(data) => { let update_client_response: UpdateClientResponse = from_binary_response(&data)?; - cw_println!(deps, "Received Client Update Callback with data"); + cw_println!(deps.api, "Received Client Update Callback with data"); let client_id: ClientId = self.get_callback_data(deps.as_ref().storage, EXECUTE_UPDATE_CLIENT)?; self.clear_callback_data(deps.storage, EXECUTE_UPDATE_CLIENT); diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs index e3ee09dd8..1eae6e11e 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs @@ -208,7 +208,7 @@ impl<'a> CwIbcCoreContext<'a> { connection_end.delay_period(), ); cw_println!( - deps, + deps.api, "[ConnOpenAck]: Expected conn end {:?}", expected_connection_end ); @@ -338,7 +338,7 @@ impl<'a> CwIbcCoreContext<'a> { let prefix = self.commitment_prefix(deps.as_ref(), &env); cw_println!( - deps, + deps.api, "prefix_on_b is {:?}", from_utf8(&prefix.clone().into_vec()).unwrap() ); @@ -354,21 +354,21 @@ impl<'a> CwIbcCoreContext<'a> { ); cw_println!( - deps, + deps.api, "[ConnOpenTry]: expected counterpart connection_end:{:?}", HexString::from_bytes(&expected_connection_end.encode_vec().unwrap()) ); let consensus_state = self.consensus_state(deps.as_ref(), &client_id, &proof_height)?; cw_println!( - deps, + deps.api, "[ConnOpenTry]: root: {:?} ", HexString::from_bytes(consensus_state.root().as_bytes()) ); let counterparty_connection_path = commitment::connection_path(&counterparty_connection_id.clone().unwrap()); cw_println!( - deps, + deps.api, "[ConnOpenTry]: connkey: {:?}", HexString::from_bytes(&counterparty_connection_path) ); @@ -383,13 +383,13 @@ impl<'a> CwIbcCoreContext<'a> { // this is verifying tendermint client state and shouldn't have icon-client as an argument cw_println!( - deps, + deps.api, "[ConnOpenTry]: payload client state path {:?}", &counterparty_client_id ); let client_state_path = commitment::client_state_path(&counterparty_client_id); cw_println!( - deps, + deps.api, "[ConnOpenTry]: the clientstate value is {:?}", message_client_state.value ); @@ -429,7 +429,7 @@ impl<'a> CwIbcCoreContext<'a> { let connection_id = self.generate_connection_idenfier(deps.storage)?; cw_println!( - deps, + deps.api, "[ConnOpenTryReply]: connection id is{:?}", connection_id ); @@ -500,7 +500,7 @@ impl<'a> CwIbcCoreContext<'a> { } let prefix = self.commitment_prefix(deps.as_ref(), &env); cw_println!( - deps, + deps.api, "[ConnOpenConfirm]: Our Connection {:?}", connection_end ); @@ -509,7 +509,11 @@ impl<'a> CwIbcCoreContext<'a> { let counterparty_client_id = counterparty.client_id(); let counterparty_prefix = counterparty.prefix(); let counterparty_conn_id = counterparty.connection_id().cloned(); - cw_println!(deps.api, "[ConnOpenConfirm]: CounterParty {:?}", &counterparty); + cw_println!( + deps.api, + "[ConnOpenConfirm]: CounterParty {:?}", + &counterparty + ); ensure_connection_state(&connection_id, &connection_end, &State::TryOpen)?; @@ -535,7 +539,7 @@ impl<'a> CwIbcCoreContext<'a> { client.verify_connection_open_confirm(deps.as_ref(), verify_connection_state, client_id)?; cw_println!( - deps, + deps.api, "[ConnOpenConfirmReply]: CounterParty {:?}", counterparty ); diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs index 16145af1f..2e6f1b5b5 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs @@ -64,7 +64,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> { ) -> Result { // connection hops should be 1 cw_println!( - deps, + deps.api, "inside validate channel open init: input parameter: {:?}", message ); @@ -180,7 +180,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> { let source_channel = channel_end.remote.channel_id.clone().unwrap(); cw_println!( - deps, + deps.api, "stoed: channel id: {:?} portid :{:?} channel_end :{:?}", &dest_channel, &dest_port, diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/receive_packet.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/receive_packet.rs index f52440cf9..41c150f45 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/receive_packet.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/receive_packet.rs @@ -114,11 +114,15 @@ impl<'a> CwIbcCoreContext<'a> { ); cw_println!(deps.api, "packet is -> {:?}", msg.packet); cw_println!( - deps, + deps.api, "packet.data is -> {:?}", HexString::from_bytes(&packet.data) ); - cw_println!(deps.api, "expected commitement created {:?}", packet.sequence); + cw_println!( + deps.api, + "expected commitement created {:?}", + packet.sequence + ); let commitment_path_on_a = commitment::packet_commitment_path( &src_port, diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/timeout_on_close.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/timeout_on_close.rs index 3361b71fa..cd0537353 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/timeout_on_close.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/timeout_on_close.rs @@ -165,7 +165,7 @@ impl<'a> CwIbcCoreContext<'a> { verify_channel_state, next_seq_recv_verification_result, )?; - cw_println!(deps, "Light Client Validation Passed"); + cw_println!(deps.api, "Light Client Validation Passed"); if let Order::Ordered = channel_end.ordering { channel_end.state = State::Closed; diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs index b54a0985d..21a8d1fc5 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs @@ -536,7 +536,7 @@ fn check_for_update_client_message() { let update_client_message = RawMsgUpdateClient { client_id: client_id.to_string(), - client_message: Some(client_state.to_any()), + header: Some(client_state.to_any()), signer: signer.to_string(), }; @@ -598,7 +598,7 @@ fn fails_on_updating_non_existing_client() { let signer = Signer::from_str("new_signer").unwrap(); let update_client_message = RawMsgUpdateClient { client_id: client_id.to_string(), - client_message: Some(client_state.to_any()), + header: Some(client_state.to_any()), signer: signer.to_string(), }; diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_execution_messages.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_execution_messages.rs index 4817eb50c..d12d5c55c 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_execution_messages.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_execution_messages.rs @@ -182,7 +182,7 @@ fn test_for_update_client_execution_messages() { let msg_hex = RawMsgUpdateClient { client_id: "iconclient-0".to_string(), - client_message: Some(signed_header.to_any()), + header: Some(signed_header.to_any()), signer: "signeraddress".to_string(), }; diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index dff847d40..859593aab 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -1,5 +1,5 @@ use crate::constants::TRUST_LEVEL; -use crate::state::CwContext; + use crate::traits::{ConsensusStateUpdate, IContext, ILightClient}; use crate::ContractError; use common::icon::icon::lightclient::v1::ConsensusState; @@ -11,12 +11,11 @@ use cosmwasm_std::Addr; use cw_common::cw_println; use prost::Message; -pub struct IconClient { +pub struct IconClient { context: C, } -impl IconClient { - +impl IconClient { pub fn new(context: C) -> Self { Self { context } } @@ -98,7 +97,7 @@ impl IconClient { } } -impl ILightClient for IconClient { +impl ILightClient for IconClient { type Error = crate::ContractError; fn create_client( diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs index 4b4e51afa..88aac46c5 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs @@ -2,7 +2,7 @@ use std::marker::PhantomData; use crate::{ state::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES}, - traits::{Config}, + traits::Config, ContractError, }; use common::{ @@ -21,7 +21,6 @@ use prost::Message; pub struct QueryHandler; - impl QueryHandler { pub fn get_consensus_state( storage: &dyn Storage, @@ -29,13 +28,13 @@ impl QueryHandler { height: u64, ) -> Result { let data = CONSENSUS_STATES - .load(storage, (client_id.to_string(), height)) - .map_err(|_e| ContractError::ConsensusStateNotFound { - height, - client_id: client_id.to_string(), - })?; - let state = ConsensusState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; - Ok(state) + .load(storage, (client_id.to_string(), height)) + .map_err(|_e| ContractError::ConsensusStateNotFound { + height, + client_id: client_id.to_string(), + })?; + let state = ConsensusState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; + Ok(state) } pub fn get_client_state( @@ -77,7 +76,6 @@ impl QueryHandler { }) } - pub fn get_config(storage: &dyn Storage) -> Result { CONFIG .load(storage) diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs index a3197d6cb..6e5b6680b 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs @@ -1,5 +1,3 @@ -use std::marker::PhantomData; - use common::icon::icon::lightclient::v1::ClientState; use common::icon::icon::lightclient::v1::ConsensusState; @@ -13,9 +11,8 @@ use cosmwasm_std::Storage; use cw_storage_plus::{Item, Map}; use debug_print::debug_eprintln; -use prost::Message; use crate::query_handler::QueryHandler; - +use prost::Message; use crate::traits::Config; use crate::traits::IContext; @@ -32,7 +29,6 @@ pub struct CwContext<'a> { pub storage: &'a mut dyn Storage, pub api: &'a dyn Api, pub env: Env, - } impl<'a> CwContext<'a> { @@ -46,10 +42,7 @@ impl<'a> CwContext<'a> { } impl<'a> IContext for CwContext<'a> { - - - - fn get_client_state(&self, client_id: &str) -> Result { + fn get_client_state(&self, client_id: &str) -> Result { QueryHandler::get_client_state(self.storage, client_id) } @@ -57,7 +50,7 @@ impl<'a> IContext for CwContext<'a> { &mut self, client_id: &str, state: ClientState, - ) -> Result<(),ContractError> { + ) -> Result<(), ContractError> { let data = state.encode_to_vec(); CLIENT_STATES .save(self.storage, client_id.to_string(), &data) @@ -84,7 +77,7 @@ impl<'a> IContext for CwContext<'a> { .map_err(|_e| ContractError::FailedToSaveClientState) } - fn get_timestamp_at_height(&self, client_id: &str, height: u64) -> Result { + fn get_timestamp_at_height(&self, client_id: &str, height: u64) -> Result { QueryHandler::get_timestamp_at_height(self.storage, client_id, height) } @@ -106,11 +99,11 @@ impl<'a> IContext for CwContext<'a> { .map(|addr| addr.to_vec()) } - fn get_config(&self) -> Result { + fn get_config(&self) -> Result { QueryHandler::get_config(self.storage) } - fn insert_config(&mut self, config: &Config) -> Result<(),ContractError> { + fn insert_config(&mut self, config: &Config) -> Result<(), ContractError> { CONFIG .save(self.storage, config) .map_err(|_e| ContractError::FailedToSaveConfig) @@ -162,14 +155,14 @@ impl<'a> IContext for CwContext<'a> { QueryHandler::get_processed_blocknumber_at_height(self.storage, client_id, height) } - fn ensure_ibc_host(&self, caller: cosmwasm_std::Addr) -> Result<(),ContractError> { + fn ensure_ibc_host(&self, caller: cosmwasm_std::Addr) -> Result<(), ContractError> { let config = self.get_config()?; if caller != config.ibc_host { return Err(ContractError::Unauthorized {}); } Ok(()) } - fn ensure_owner(&self, caller: cosmwasm_std::Addr) -> Result<(),ContractError> { + fn ensure_owner(&self, caller: cosmwasm_std::Addr) -> Result<(), ContractError> { let config = self.get_config()?; debug_eprintln!("owner {:?} caller {}", config.owner, caller.to_string()); if caller != config.owner { @@ -177,8 +170,8 @@ impl<'a> IContext for CwContext<'a> { } Ok(()) } - fn api(&self)->& dyn Api { - return self.api + fn api(&self) -> &dyn Api { + self.api } } diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs index 5f7d890d3..1ee11f576 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs @@ -5,7 +5,7 @@ use common::icon::icon::types::v1::SignedHeader; use cosmwasm_std::Addr; use cosmwasm_std::Api; -use cosmwasm_std::Storage; + use serde::Deserialize; use serde::Serialize; @@ -78,9 +78,7 @@ pub trait ILightClient { } pub trait IStoreReader {} -pub trait IContext{ - - +pub trait IContext { fn get_client_state(&self, client_id: &str) -> Result; fn insert_client_state( @@ -135,7 +133,5 @@ pub trait IContext{ fn ensure_owner(&self, caller: Addr) -> Result<(), ContractError>; fn ensure_ibc_host(&self, caller: Addr) -> Result<(), ContractError>; - fn api(&self)->& dyn Api; + fn api(&self) -> &dyn Api; } - - diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml index 584a13d2c..cb3df7aff 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml @@ -49,9 +49,8 @@ cw-common = { path="../cw-common",default-features = false } prost = { workspace=true} serde-json-wasm = {workspace=true} debug_print = {workspace=true} -ibc-proto = {package = "ibc-proto", git="https://github.com/ComposableFi/composable-ibc.git", branch = "main"} base64 = { version = "0.13", default-features = false, features = ["alloc"] } -ics08-wasm={ git="https://github.com/ComposableFi/composable-ibc.git", features=["cosmwasm"],branch="master"} +ics08-wasm={ git="https://github.com/ComposableFi/composable-ibc.git",default-features = false, features=["cosmwasm"],branch="master"} [dev-dependencies] cosmwasm = "0.7.2" diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs index 0bdc695cd..9ca4e56c8 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -14,17 +14,10 @@ // limitations under the License. // use crate::{contract::HostFunctions, ics23::FakeInner, Bytes, ContractError}; -use common::ibc::{ - core::{ - ics23_commitment::commitment::{CommitmentPrefix, CommitmentProofBytes}, - ics24_host::Path, - }, - Height, -}; -use core::{str::FromStr, time::Duration}; + use cosmwasm_schema::cw_serde; -use cw_light_client_common::ContractError; -use ibc_proto::google::protobuf::Any; +use cw_common::raw_types::Any; + use std::convert::Infallible; // use ics07_tendermint::{ // client_message::{ClientMessage, Header, Misbehaviour}, @@ -34,7 +27,7 @@ use ics08_wasm::{ client_message::Header as WasmHeader, client_state::ClientState as WasmClientState, consensus_state::ConsensusState as WasmConsensusState, }; -use prost::Message; + use serde::{Deserializer, Serializer}; #[cw_serde] @@ -147,17 +140,16 @@ impl ContractResult { } } - #[derive(Eq, Default)] #[cw_serde] pub struct FakeInner; impl TryFrom for FakeInner { - type Error = Infallible; + type Error = Infallible; - fn try_from(_: Any) -> Result { - Ok(FakeInner) - } + fn try_from(_: Any) -> Result { + Ok(FakeInner) + } } #[cw_serde] diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs index 6a68f0f09..6aba9d447 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs @@ -650,7 +650,7 @@ impl<'a> CwIbcConnection<'a> { let our_port = self.get_port(deps.storage)?; cw_println!( - deps, + deps.api, "[IBCConnection]: Check if ports match : {:?} vs {:?}", our_port, source.port_id @@ -663,7 +663,11 @@ impl<'a> CwIbcConnection<'a> { self.get_counterparty_nid(deps.storage, &channel.connection_id, &destination.port_id)?; let connection_config = self.get_connection_config(deps.storage, &channel.connection_id)?; let ibc_config = IbcConfig::new(source, destination); - cw_println!(deps.api, "[IBCConnection]: save ibc config is {:?}", ibc_config); + cw_println!( + deps.api, + "[IBCConnection]: save ibc config is {:?}", + ibc_config + ); self.store_ibc_config(deps.storage, &nid, &ibc_config)?; diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs index 004976b8f..247598904 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs @@ -62,7 +62,10 @@ impl<'a> CwIbcConnection<'a> { gas_limit: None, reply_on: cosmwasm_std::ReplyOn::Always, }; - cw_println!(deps.api, "{LOG_PREFIX} Packet Forwarded To IBCHost {ibc_host} "); + cw_println!( + deps.api, + "{LOG_PREFIX} Packet Forwarded To IBCHost {ibc_host} " + ); Ok(submessage) } diff --git a/libraries/rust/common/src/ibc/core/ics02_client/client_message.rs b/libraries/rust/common/src/ibc/core/ics02_client/client_message.rs index 88b4ac9f2..1f0a4af68 100644 --- a/libraries/rust/common/src/ibc/core/ics02_client/client_message.rs +++ b/libraries/rust/common/src/ibc/core/ics02_client/client_message.rs @@ -16,19 +16,19 @@ use prost::alloc::vec::Vec; /// Abstract of consensus state update information pub trait ClientMessage: Clone + core::fmt::Debug + Send + Sync { - fn downcast(self) -> Option - where - Self: 'static, - { - ::downcast_ref(&self).cloned() - } + fn downcast(self) -> Option + where + Self: 'static, + { + ::downcast_ref(&self).cloned() + } - fn wrap(sub_state: &dyn core::any::Any) -> Option - where - Self: 'static, - { - sub_state.downcast_ref::().cloned() - } + fn wrap(sub_state: &dyn core::any::Any) -> Option + where + Self: 'static, + { + sub_state.downcast_ref::().cloned() + } - fn encode_to_vec(&self) -> Result, prost::EncodeError>; + fn encode_to_vec(&self) -> Result, prost::EncodeError>; } diff --git a/libraries/rust/common/src/ibc/core/ics02_client/mod.rs b/libraries/rust/common/src/ibc/core/ics02_client/mod.rs index 9ead991ee..7fd50537f 100644 --- a/libraries/rust/common/src/ibc/core/ics02_client/mod.rs +++ b/libraries/rust/common/src/ibc/core/ics02_client/mod.rs @@ -1,4 +1,5 @@ //! ICS 02: Client implementation for verifying remote IBC-enabled chains. +pub mod client_message; pub mod client_state; pub mod client_type; pub mod consensus_state; @@ -7,4 +8,3 @@ pub mod events; pub mod header; pub mod height; pub mod misbehaviour; -pub mod client_message; From 0aaa93d07c626afaa2a1242fa9b9b7aa24347fdc Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Fri, 29 Sep 2023 20:04:07 +0545 Subject: [PATCH 07/64] fix: fix deps issue --- Cargo.lock | 157 ++++++++++++++- .../cw-light-client-common/src/constants.rs | 11 ++ .../src/query_handler.rs | 42 +++- .../cw-light-client-common/src/state.rs | 13 +- .../cw-light-client-common/src/traits.rs | 20 +- .../cw-wasm-light-client/Cargo.toml | 5 +- .../cw-wasm-light-client/src/context.rs | 182 ++++++++++++++++++ .../cw-wasm-light-client/src/lib.rs | 2 +- .../cw-wasm-light-client/src/msg.rs | 21 +- 9 files changed, 414 insertions(+), 39 deletions(-) create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs diff --git a/Cargo.lock b/Cargo.lock index 3a262ea46..dfe41e7bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -278,6 +278,12 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "convert_case" version = "0.6.0" @@ -741,6 +747,9 @@ dependencies = [ "getrandom", "hex", "hex-literal 0.4.1", + "ibc 0.15.0", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git)", + "ics07-tendermint-cw", "ics08-wasm", "prost 0.11.9", "schemars 0.8.12", @@ -748,6 +757,7 @@ dependencies = [ "serde-json-wasm 0.5.1", "sha2 0.10.6", "sha3", + "tendermint-proto 0.28.0", "test-utils", "thiserror", ] @@ -854,8 +864,10 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ + "convert_case 0.4.0", "proc-macro2 1.0.59", "quote 1.0.28", + "rustc_version", "syn 1.0.109", ] @@ -1042,6 +1054,9 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ + "byteorder", + "rand", + "rustc-hex", "static_assertions", ] @@ -1236,14 +1251,14 @@ dependencies = [ [[package]] name = "ibc" version = "0.15.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#19c0265110ce33a2d24a69b2e84de69861ee0b21" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" dependencies = [ "cosmwasm-schema", "derive_more", "flex-error", "hex", "ibc-derive", - "ibc-proto 0.18.0", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", "ics23 0.10.0", "log", "num-traits", @@ -1255,6 +1270,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "sha2 0.10.6", "subtle-encoding", "tendermint 0.28.0", "tendermint-proto 0.28.0", @@ -1289,7 +1305,7 @@ dependencies = [ "sha2 0.10.6", "subtle-encoding", "tendermint 0.29.1", - "tendermint-light-client-verifier", + "tendermint-light-client-verifier 0.29.1", "tendermint-proto 0.29.1", "time", "tracing", @@ -1299,9 +1315,9 @@ dependencies = [ [[package]] name = "ibc-derive" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#19c0265110ce33a2d24a69b2e84de69861ee0b21" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" dependencies = [ - "convert_case", + "convert_case 0.6.0", "proc-macro-crate 1.3.1", "proc-macro2 1.0.59", "quote 1.0.28", @@ -1311,11 +1327,25 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.18.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#19c0265110ce33a2d24a69b2e84de69861ee0b21" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" +dependencies = [ + "base64 0.13.1", + "bytes", + "prost 0.11.9", + "schemars 0.8.12", + "serde", + "tendermint-proto 0.28.0", +] + +[[package]] +name = "ibc-proto" +version = "0.18.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git#19c0265110ce33a2d24a69b2e84de69861ee0b21" dependencies = [ "base64 0.13.1", "bytes", "prost 0.11.9", + "schemars 0.8.12", "serde", "tendermint-proto 0.28.0", ] @@ -1338,15 +1368,68 @@ dependencies = [ "tendermint-proto 0.29.1", ] +[[package]] +name = "ics07-tendermint" +version = "0.1.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" +dependencies = [ + "bytes", + "flex-error", + "hex", + "ibc 0.15.0", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "ics23 0.10.0", + "log", + "prost 0.11.9", + "serde", + "serde_json", + "subtle-encoding", + "tendermint 0.28.0", + "tendermint-light-client-verifier 0.28.0", + "tendermint-proto 0.28.0", + "time", +] + +[[package]] +name = "ics07-tendermint-cw" +version = "0.1.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" +dependencies = [ + "byteorder", + "cosmwasm-schema", + "cosmwasm-std", + "derive_more", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "ed25519-zebra", + "hex", + "ibc 0.15.0", + "ibc-derive", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "ics07-tendermint", + "ics08-wasm", + "ics23 0.10.0", + "prost 0.11.9", + "schemars 0.8.12", + "serde", + "sha2 0.10.6", + "sha3", + "tendermint 0.28.0", + "tendermint-light-client-verifier 0.28.0", + "tendermint-proto 0.28.0", + "thiserror", +] + [[package]] name = "ics08-wasm" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#19c0265110ce33a2d24a69b2e84de69861ee0b21" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" dependencies = [ "cosmwasm-schema", "hex", "ibc 0.15.0", - "ibc-proto 0.18.0", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", "prost 0.11.9", "serde", "tendermint-proto 0.28.0", @@ -1378,6 +1461,15 @@ dependencies = [ "prost 0.11.9", ] +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + [[package]] name = "impl-serde" version = "0.4.0" @@ -1664,6 +1756,12 @@ dependencies = [ "spki", ] +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "prettyplease" version = "0.1.25" @@ -1681,6 +1779,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ "fixed-hash", + "impl-codec", "impl-serde", "uint", ] @@ -1823,6 +1922,27 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -1914,6 +2034,15 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.37.19" @@ -2413,6 +2542,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "tendermint-light-client-verifier" +version = "0.28.0" +source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" +dependencies = [ + "derive_more", + "flex-error", + "serde", + "tendermint 0.28.0", + "time", +] + [[package]] name = "tendermint-light-client-verifier" version = "0.29.1" diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/constants.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/constants.rs index d8d080dae..dea925e03 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/constants.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/constants.rs @@ -1,4 +1,8 @@ use common::icon::icon::lightclient::v1::TrustLevel; +use cw_storage_plus::{Item, Map}; + +use crate::traits::Config; +type ClientId = String; pub const CLIENT_STATE_HASH: &str = "client_state_hash"; pub const CONSENSUS_STATE_HASH: &str = "consensus_state_hash"; @@ -7,3 +11,10 @@ pub const TRUST_LEVEL: TrustLevel = TrustLevel { numerator: 2, denominator: 3, }; + +pub const CLIENT_STATES: Map> = Map::new("CLIENT_STATES"); +pub const CONSENSUS_STATES: Map<(ClientId, u64), Vec> = Map::new("CONSENSUS_STATES"); +pub const PROCESSED_TIMES: Map<(ClientId, u64), u64> = Map::new("PROCESSED_TIMES"); +pub const PROCESSED_HEIGHTS: Map<(ClientId, u64), u64> = Map::new("PROCESSED_HEIGHTS"); + +pub const CONFIG: Item = Item::new("CONFIG"); diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs index 88aac46c5..4a7d6c679 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use crate::{ - state::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES}, + constants::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES}, traits::Config, ContractError, }; @@ -140,6 +140,35 @@ impl QueryHandler { deps: Deps, client_id: &str, height: u64, + delay_time_period: u64, + delay_block_period: u64, + proof: &[MerkleNode], + value: &[u8], + path: &[u8], + ) -> Result { + let client_state = Self::get_client_state(deps.storage, client_id)?; + let consensus_state: ConsensusState = + Self::get_consensus_state(deps.storage, client_id, height)?; + Self::verify_membership_inner( + deps, + client_id, + client_state, + consensus_state, + height, + delay_time_period, + delay_block_period, + proof, + value, + path, + ) + } + + pub fn verify_membership_inner( + deps: Deps, + client_id: &str, + client_state: ClientState, + consensus_state: ConsensusState, + height: u64, _delay_time_period: u64, _delay_block_period: u64, proof: &[MerkleNode], @@ -159,10 +188,8 @@ impl QueryHandler { let path = keccak256(path).to_vec(); cw_println!(deps.api, "[LightClient]: client id is: {:?}", client_id); - let state = Self::get_client_state(deps.storage, client_id)?; - - if state.frozen_height != 0 && height > state.frozen_height { - return Err(ContractError::ClientStateFrozen(state.frozen_height)); + if client_state.frozen_height != 0 && height > client_state.frozen_height { + return Err(ContractError::ClientStateFrozen(client_state.frozen_height)); } let mut value_hash = value.to_vec(); @@ -172,8 +199,7 @@ impl QueryHandler { // let _ = // self.validate_delay_args(client_id, height, delay_time_period, delay_block_period)?; - let consensus_state: ConsensusState = - Self::get_consensus_state(deps.storage, client_id, height)?; + cw_println!( deps.api, "[LightClient]: Path Hash {:?}", @@ -257,7 +283,7 @@ impl QueryHandler { mod tests { use cosmwasm_std::testing::MockStorage; - use crate::state::CONSENSUS_STATES; + use crate::constants::CONSENSUS_STATES; use super::QueryHandler; diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs index 6e5b6680b..35b0abaeb 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs @@ -8,22 +8,19 @@ use cosmwasm_std::DepsMut; use cosmwasm_std::Env; use cosmwasm_std::Storage; -use cw_storage_plus::{Item, Map}; use debug_print::debug_eprintln; +use crate::constants::CLIENT_STATES; +use crate::constants::CONFIG; +use crate::constants::CONSENSUS_STATES; +use crate::constants::PROCESSED_HEIGHTS; +use crate::constants::PROCESSED_TIMES; use crate::query_handler::QueryHandler; use prost::Message; use crate::traits::Config; use crate::traits::IContext; use crate::ContractError; -type ClientId = String; -pub const CLIENT_STATES: Map> = Map::new("CLIENT_STATES"); -pub const CONSENSUS_STATES: Map<(ClientId, u64), Vec> = Map::new("CONSENSUS_STATES"); -pub const PROCESSED_TIMES: Map<(ClientId, u64), u64> = Map::new("PROCESSED_TIMES"); -pub const PROCESSED_HEIGHTS: Map<(ClientId, u64), u64> = Map::new("PROCESSED_HEIGHTS"); - -pub const CONFIG: Item = Item::new("CONFIG"); pub struct CwContext<'a> { pub storage: &'a mut dyn Storage, diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs index 1ee11f576..e545de814 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs @@ -2,6 +2,7 @@ use common::icon::icon::lightclient::v1::ClientState; use common::icon::icon::lightclient::v1::ConsensusState; use common::icon::icon::types::v1::SignedHeader; +use common::utils::keccak256; use cosmwasm_std::Addr; use cosmwasm_std::Api; @@ -111,8 +112,23 @@ pub trait IContext { height: u64, ) -> Result<(), ContractError>; - fn recover_signer(&self, msg: &[u8], signature: &[u8]) -> Option<[u8; 20]>; - fn recover_icon_signer(&self, msg: &[u8], signature: &[u8]) -> Option>; + fn recover_signer(&self, msg: &[u8], signature: &[u8]) -> Option<[u8; 20]> { + if signature.len() != 65 { + return None; + } + let mut rs = [0u8; 64]; + rs[..].copy_from_slice(&signature[..64]); + let v = signature[64]; + let pubkey = self.api().secp256k1_recover_pubkey(msg, &rs, v).unwrap(); + let pubkey_hash = keccak256(&pubkey[1..]); + let address: Option<[u8; 20]> = pubkey_hash.as_slice()[12..].try_into().ok(); + address + } + + fn recover_icon_signer(&self, msg: &[u8], signature: &[u8]) -> Option> { + self.recover_signer(msg, signature) + .map(|addr| addr.to_vec()) + } fn get_config(&self) -> Result; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml index cb3df7aff..0e29fd2da 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml @@ -48,10 +48,13 @@ cw-light-client-common = { path="../cw-light-client-common",default-features = f cw-common = { path="../cw-common",default-features = false } prost = { workspace=true} serde-json-wasm = {workspace=true} +ibc-proto={git="https://github.com/ComposableFi/composable-ibc.git",default-features = false,features = ["json-schema"] } +ibc={git="https://github.com/ComposableFi/composable-ibc.git",default-features = false,branch="master"} +ics07-tendermint-cw={git="https://github.com/ComposableFi/composable-ibc.git",default-features = false,features=["library","rust-crypto"],branch="master"} debug_print = {workspace=true} base64 = { version = "0.13", default-features = false, features = ["alloc"] } ics08-wasm={ git="https://github.com/ComposableFi/composable-ibc.git",default-features = false, features=["cosmwasm"],branch="master"} - +tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", rev = "e81f7bf23d63ffbcd242381d1ce5e35da3515ff1", default-features = false } [dev-dependencies] cosmwasm = "0.7.2" hex-literal="*" diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs new file mode 100644 index 000000000..3ba6f1084 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs @@ -0,0 +1,182 @@ +use common::{ + ibc::Height, + icon::icon::lightclient::v1::{ClientState, ConsensusState}, + traits::AnyTypes, +}; +use cosmwasm_std::{Api, Env, Storage}; +use cw_common::raw_types::Any; +use cw_light_client_common::{traits::IContext, ContractError}; +use ics07_tendermint_cw::ics23::FakeInner; +use ics08_wasm::client_state::ClientState as WasmClientState; +use prost::Message; +use tendermint_proto::Protobuf; +pub struct CwContext<'a> { + pub storage: &'a mut dyn Storage, + pub api: &'a dyn Api, + pub env: Env, +} + +impl<'a> CwContext<'a> { + pub fn new(deps_mut: cosmwasm_std::DepsMut<'a>, env: Env) -> Self { + Self { + storage: deps_mut.storage, + api: deps_mut.api, + env, + } + } +} + +pub fn get_consensus_state_key(height: Height) -> Vec { + [ + "consensusStates/".to_string().into_bytes(), + format!("{height}").into_bytes(), + ] + .concat() +} + +pub fn to_wasm_client_state( + client_state: ClientState, + old_state: Vec, +) -> Result, ContractError> { + use ibc::Height; + let any = Any::decode(&*old_state).unwrap(); + let mut wasm_client_state = + WasmClientState::::decode_vec(&any.value).unwrap(); + wasm_client_state.data = client_state.to_any().encode_to_vec(); + wasm_client_state.latest_height = Height::new(0, client_state.latest_height); + let vec1 = wasm_client_state.to_any().encode_to_vec(); + Ok(vec1) +} + +impl<'a> IContext for CwContext<'a> { + fn get_client_state( + &self, + client_id: &str, + ) -> Result< + common::icon::icon::lightclient::v1::ClientState, + cw_light_client_common::ContractError, + > { + let any_bytes = self + .storage + .get(&"clientState".to_string().into_bytes()) + .ok_or(ContractError::ClientStateNotFound(client_id.to_string()))?; + let any_state = Any::decode(any_bytes.as_slice()).unwrap(); + ClientState::from_any(any_state).map_err(ContractError::DecodeError) + } + + fn insert_client_state( + &mut self, + _client_id: &str, + _state: common::icon::icon::lightclient::v1::ClientState, + ) -> Result<(), cw_light_client_common::ContractError> { + unimplemented!() + } + + fn get_consensus_state( + &self, + client_id: &str, + height: u64, + ) -> Result< + common::icon::icon::lightclient::v1::ConsensusState, + cw_light_client_common::ContractError, + > { + let ibc_height = Height::new(0, height).unwrap(); + let any_bytes = self + .storage + .get(&get_consensus_state_key(ibc_height)) + .ok_or(ContractError::ConsensusStateNotFound { + height, + client_id: client_id.to_string(), + })?; + let any_state = Any::decode(any_bytes.as_slice()).unwrap(); + ConsensusState::from_any(any_state).map_err(ContractError::DecodeError) + } + + fn insert_consensus_state( + &mut self, + _client_id: &str, + _height: u64, + _state: common::icon::icon::lightclient::v1::ConsensusState, + ) -> Result<(), cw_light_client_common::ContractError> { + unimplemented!() + } + + fn get_timestamp_at_height( + &self, + _client_id: &str, + _height: u64, + ) -> Result { + unimplemented!() + } + + fn insert_timestamp_at_height( + &mut self, + _client_id: &str, + _height: u64, + ) -> Result<(), cw_light_client_common::ContractError> { + unimplemented!() + } + + fn insert_blocknumber_at_height( + &mut self, + _client_id: &str, + _height: u64, + ) -> Result<(), cw_light_client_common::ContractError> { + unimplemented!() + } + + fn get_config( + &self, + ) -> Result { + unimplemented!() + } + + fn insert_config( + &mut self, + _config: &cw_light_client_common::traits::Config, + ) -> Result<(), cw_light_client_common::ContractError> { + unimplemented!() + } + + fn get_current_block_time(&self) -> u64 { + unimplemented!() + } + + fn get_current_block_height(&self) -> u64 { + unimplemented!() + } + + fn get_processed_time_at_height( + &self, + _client_id: &str, + _height: u64, + ) -> Result { + unimplemented!() + } + + fn get_processed_block_at_height( + &self, + _client_id: &str, + _height: u64, + ) -> Result { + unimplemented!() + } + + fn ensure_owner( + &self, + _caller: cosmwasm_std::Addr, + ) -> Result<(), cw_light_client_common::ContractError> { + unimplemented!() + } + + fn ensure_ibc_host( + &self, + _caller: cosmwasm_std::Addr, + ) -> Result<(), cw_light_client_common::ContractError> { + unimplemented!() + } + + fn api(&self) -> &dyn Api { + unimplemented!() + } +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs index bd469d7c3..49c225fff 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs @@ -1,6 +1,6 @@ pub use cw_light_client_common::constants; +mod context; pub mod contract; -//mod ics08_wasm; mod msg; pub use cw_light_client_common::light_client; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs index 9ca4e56c8..caacfc430 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -16,13 +16,12 @@ // use crate::{contract::HostFunctions, ics23::FakeInner, Bytes, ContractError}; use cosmwasm_schema::cw_serde; -use cw_common::raw_types::Any; -use std::convert::Infallible; // use ics07_tendermint::{ // client_message::{ClientMessage, Header, Misbehaviour}, // client_state::ClientState, // }; +use ics07_tendermint_cw::ics23::FakeInner; use ics08_wasm::{ client_message::Header as WasmHeader, client_state::ClientState as WasmClientState, consensus_state::ConsensusState as WasmConsensusState, @@ -140,17 +139,17 @@ impl ContractResult { } } -#[derive(Eq, Default)] -#[cw_serde] -pub struct FakeInner; +// #[derive(Eq, Default)] +// #[cw_serde] +// pub struct FakeInner; -impl TryFrom for FakeInner { - type Error = Infallible; +// impl TryFrom for FakeInner { +// type Error = Infallible; - fn try_from(_: Any) -> Result { - Ok(FakeInner) - } -} +// fn try_from(_: ibc_proto::google::protobuf::Any) -> Result { +// Ok(FakeInner) +// } +// } #[cw_serde] pub struct InstantiateMsg {} From 867ec903f565a9a66767115e66329816fde839f6 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Sat, 30 Sep 2023 12:04:55 +0545 Subject: [PATCH 08/64] fix: split query handler --- .../src/context.rs} | 1 + .../cw-icon-light-client/src/contract.rs | 4 +- .../cw-icon-light-client/src/lib.rs | 5 +- .../cw-icon-light-client/src/query_handler.rs | 50 ++ .../cw-light-client-common/src/lib.rs | 2 - .../src/light_client.rs | 1 + .../src/query_handler.rs | 307 ----------- .../cw-light-client-common/src/traits.rs | 275 ++++++++++ .../cw-wasm-light-client/src/context.rs | 133 +++-- .../cw-wasm-light-client/src/contract.rs | 482 ++---------------- .../cw-wasm-light-client/src/lib.rs | 6 +- .../cw-wasm-light-client/src/query_handler.rs | 37 ++ .../cw-wasm-light-client/src/utils.rs | 67 +++ 13 files changed, 542 insertions(+), 828 deletions(-) rename contracts/cosmwasm-vm/{cw-light-client-common/src/state.rs => cw-icon-light-client/src/context.rs} (99%) create mode 100644 contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs delete mode 100644 contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs similarity index 99% rename from contracts/cosmwasm-vm/cw-light-client-common/src/state.rs rename to contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs index 35b0abaeb..3f4b3a67d 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/state.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs @@ -8,6 +8,7 @@ use cosmwasm_std::DepsMut; use cosmwasm_std::Env; use cosmwasm_std::Storage; +use cw_light_client_common::traits::IQueryHandler; use debug_print::debug_eprintln; use crate::constants::CLIENT_STATES; diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs index ca8f456b0..91fd682da 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs @@ -4,6 +4,7 @@ use common::traits::AnyTypes; use cosmwasm_schema::cw_serde; use cw_common::ibc_types::IbcHeight; use cw_common::to_checked_address; +use cw_light_client_common::traits::IQueryHandler; #[cfg(feature = "mock")] use crate::mock_client::MockClient; @@ -21,8 +22,8 @@ use cw_common::raw_types::Any; use cw_common::types::VerifyChannelState; use crate::constants::{CLIENT_STATE_HASH, CONSENSUS_STATE_HASH, HEIGHT}; +use crate::context::CwContext; use crate::light_client::IconClient; -use crate::state::CwContext; use crate::traits::{Config, IContext, ILightClient}; use crate::ContractError; use cw_common::client_msg::{ @@ -553,6 +554,7 @@ mod tests { }; use common::traits::AnyTypes; use cw_common::client_msg::ExecuteMsg; + use cw_light_client_common::traits::IQueryHandler; use prost::Message; use super::{execute, instantiate, Config, InstantiateMsg, CONTRACT_NAME, CONTRACT_VERSION}; diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/lib.rs index 9bed4860b..8a234d3f8 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/lib.rs @@ -1,12 +1,13 @@ pub use cw_light_client_common::constants; +pub mod context; pub mod contract; +pub mod query_handler; pub use cw_light_client_common::light_client; #[cfg(feature = "mock")] pub mod mock_client; -pub use cw_light_client_common::query_handler; -pub use cw_light_client_common::state; + pub use cw_light_client_common::traits; pub use cw_light_client_common::error::ContractError; diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs new file mode 100644 index 000000000..3bdde2ba2 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs @@ -0,0 +1,50 @@ +use std::marker::PhantomData; + +use crate::{ + constants::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES}, + traits::Config, + ContractError, +}; +use common::{ + icon::icon::{ + lightclient::v1::{ClientState, ConsensusState}, + types::v1::MerkleNode, + }, + traits::AnyTypes, + utils::{calculate_root, keccak256}, +}; +use cosmwasm_std::{Deps, Order, StdResult, Storage}; +use cw_common::{cw_println, hex_string::HexString}; +use cw_light_client_common::traits::IQueryHandler; +use cw_storage_plus::Bound; + +use prost::Message; + +pub struct QueryHandler; +impl IQueryHandler for QueryHandler {} +#[cfg(test)] +mod tests { + use cosmwasm_std::testing::MockStorage; + + use crate::{constants::CONSENSUS_STATES, query_handler::IQueryHandler}; + + use super::QueryHandler; + + #[test] + fn test_previous_consensus() { + let mut store = MockStorage::new(); + CONSENSUS_STATES + .save(&mut store, ("test".to_string(), 100), &vec![1, 2, 4, 5]) + .unwrap(); + CONSENSUS_STATES + .save(&mut store, ("test".to_string(), 80), &vec![1, 2, 4, 5]) + .unwrap(); + CONSENSUS_STATES + .save(&mut store, ("test".to_string(), 70), &vec![1, 2, 4, 5]) + .unwrap(); + + let result = QueryHandler::get_previous_consensus(&store, 110, "test".to_string()).unwrap(); + + println!("{result:?}"); + } +} diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/lib.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/lib.rs index 1ef9e7d57..216812fb3 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/lib.rs @@ -1,7 +1,5 @@ pub mod constants; pub mod error; pub mod light_client; -pub mod query_handler; -pub mod state; pub mod traits; pub use crate::error::ContractError; diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index 859593aab..e92a6844a 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -1,5 +1,6 @@ use crate::constants::TRUST_LEVEL; +use crate::traits::IQueryHandler; use crate::traits::{ConsensusStateUpdate, IContext, ILightClient}; use crate::ContractError; use common::icon::icon::lightclient::v1::ConsensusState; diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs deleted file mode 100644 index 4a7d6c679..000000000 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/query_handler.rs +++ /dev/null @@ -1,307 +0,0 @@ -use std::marker::PhantomData; - -use crate::{ - constants::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES}, - traits::Config, - ContractError, -}; -use common::{ - icon::icon::{ - lightclient::v1::{ClientState, ConsensusState}, - types::v1::MerkleNode, - }, - traits::AnyTypes, - utils::{calculate_root, keccak256}, -}; -use cosmwasm_std::{Deps, Order, StdResult, Storage}; -use cw_common::{cw_println, hex_string::HexString}; -use cw_storage_plus::Bound; - -use prost::Message; - -pub struct QueryHandler; - -impl QueryHandler { - pub fn get_consensus_state( - storage: &dyn Storage, - client_id: &str, - height: u64, - ) -> Result { - let data = CONSENSUS_STATES - .load(storage, (client_id.to_string(), height)) - .map_err(|_e| ContractError::ConsensusStateNotFound { - height, - client_id: client_id.to_string(), - })?; - let state = ConsensusState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; - Ok(state) - } - - pub fn get_client_state( - storage: &dyn Storage, - client_id: &str, - ) -> Result { - let data = CLIENT_STATES - .load(storage, client_id.to_string()) - .map_err(|_e| ContractError::ClientStateNotFound(client_id.to_string()))?; - let state = ClientState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; - Ok(state) - } - - pub fn get_latest_consensus_state( - storage: &dyn Storage, - client_id: &str, - ) -> Result { - let state = CLIENT_STATES - .load(storage, client_id.to_string()) - .map_err(ContractError::Std)?; - let client_state = - ClientState::decode(state.as_slice()).map_err(ContractError::DecodeError)?; - - let consensus_state = - QueryHandler::get_consensus_state(storage, client_id, client_state.latest_height)?; - Ok(consensus_state) - } - - pub fn get_timestamp_at_height( - storage: &dyn Storage, - client_id: &str, - height: u64, - ) -> Result { - PROCESSED_TIMES - .load(storage, (client_id.to_string(), height)) - .map_err(|_e| ContractError::TimestampNotFound { - height, - client_id: client_id.to_string(), - }) - } - - pub fn get_config(storage: &dyn Storage) -> Result { - CONFIG - .load(storage) - .map_err(|_e| ContractError::ConfigNotFound) - } - - pub fn get_client_state_any( - storage: &dyn Storage, - client_id: &str, - ) -> Result, ContractError> { - let state = Self::get_client_state(storage, client_id)?; - let any_state = state.to_any(); - Ok(any_state.encode_to_vec()) - } - - pub fn get_consensus_state_any( - storage: &dyn Storage, - client_id: &str, - height: u64, - ) -> Result, ContractError> { - let state = Self::get_consensus_state(storage, client_id, height)?; - let any_state = state.to_any(); - Ok(any_state.encode_to_vec()) - } - - pub fn get_latest_height(storage: &dyn Storage, client_id: &str) -> Result { - let state = Self::get_client_state(storage, client_id)?; - - Ok(state.latest_height) - } - - pub fn get_processed_time_at_height( - storage: &dyn Storage, - client_id: &str, - height: u64, - ) -> Result { - PROCESSED_TIMES - .load(storage, (client_id.to_string(), height)) - .map_err(|_e| ContractError::ProcessedTimeNotFound { - client_id: client_id.to_string(), - height, - }) - } - pub fn get_processed_blocknumber_at_height( - storage: &dyn Storage, - client_id: &str, - height: u64, - ) -> Result { - PROCESSED_HEIGHTS - .load(storage, (client_id.to_string(), height)) - .map_err(|_e| ContractError::ProcessedHeightNotFound { - client_id: client_id.to_string(), - height, - }) - } - - /** - * @dev verifyMembership is a generic proof verification method which verifies a proof of the existence of a value at a given CommitmentPath at the specified height. - * The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24). - */ - pub fn verify_membership( - deps: Deps, - client_id: &str, - height: u64, - delay_time_period: u64, - delay_block_period: u64, - proof: &[MerkleNode], - value: &[u8], - path: &[u8], - ) -> Result { - let client_state = Self::get_client_state(deps.storage, client_id)?; - let consensus_state: ConsensusState = - Self::get_consensus_state(deps.storage, client_id, height)?; - Self::verify_membership_inner( - deps, - client_id, - client_state, - consensus_state, - height, - delay_time_period, - delay_block_period, - proof, - value, - path, - ) - } - - pub fn verify_membership_inner( - deps: Deps, - client_id: &str, - client_state: ClientState, - consensus_state: ConsensusState, - height: u64, - _delay_time_period: u64, - _delay_block_period: u64, - proof: &[MerkleNode], - value: &[u8], - path: &[u8], - ) -> Result { - cw_println!( - deps.api, - "[LightClient]: Path Bytes {:?}", - HexString::from_bytes(path) - ); - cw_println!( - deps.api, - "[LightClient]: Value Bytes {:?}", - HexString::from_bytes(value) - ); - let path = keccak256(path).to_vec(); - cw_println!(deps.api, "[LightClient]: client id is: {:?}", client_id); - - if client_state.frozen_height != 0 && height > client_state.frozen_height { - return Err(ContractError::ClientStateFrozen(client_state.frozen_height)); - } - - let mut value_hash = value.to_vec(); - if !value.is_empty() { - value_hash = keccak256(value).to_vec(); - } - - // let _ = - // self.validate_delay_args(client_id, height, delay_time_period, delay_block_period)?; - - cw_println!( - deps.api, - "[LightClient]: Path Hash {:?}", - HexString::from_bytes(&path) - ); - cw_println!( - deps.api, - "[LightClient]: Value Hash {:?}", - HexString::from_bytes(&value_hash) - ); - let leaf = keccak256(&[path, value_hash].concat()); - cw_println!( - deps.api, - "[LightClient]: Leaf Value {:?}", - HexString::from_bytes(&leaf) - ); - - let message_root = calculate_root(leaf, proof); - cw_println!( - deps.api, - "[LightClient]: Stored Message Root {:?} ", - hex::encode(consensus_state.message_root.clone()) - ); - cw_println!( - deps.api, - "[LightClient]: Calculated Message Root : {:?}", - HexString::from_bytes(&message_root) - ); - if consensus_state.message_root != message_root { - return Err(ContractError::InvalidMessageRoot(hex::encode(message_root))); - } - - Ok(true) - } - - /** - * @dev verifyNonMembership is a generic proof verification method which verifies the absence of a given CommitmentPath at a specified height. - * The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24). - */ - pub fn verify_non_membership( - deps: Deps, - client_id: &str, - height: u64, - delay_time_period: u64, - delay_block_period: u64, - proof: &[MerkleNode], - path: &[u8], - ) -> Result { - Self::verify_membership( - deps, - client_id, - height, - delay_time_period, - delay_block_period, - proof, - &[], - path, - ) - } - - pub fn get_previous_consensus( - storage: &dyn Storage, - height: u64, - client_id: String, - ) -> Result, ContractError> { - let key = (client_id, height); - let bound = Bound::Exclusive::<(String, u64)>((key, PhantomData)); - - let result = CONSENSUS_STATES - .range(storage, None, Some(bound), Order::Descending) - .take(1) - .collect::)>>>() - .map_err(ContractError::Std)?; - - let keys = result.into_iter().map(|t| t.0 .1).collect::>(); - Ok(keys) - } -} - -#[cfg(test)] -mod tests { - use cosmwasm_std::testing::MockStorage; - - use crate::constants::CONSENSUS_STATES; - - use super::QueryHandler; - - #[test] - fn test_previous_consensus() { - let mut store = MockStorage::new(); - CONSENSUS_STATES - .save(&mut store, ("test".to_string(), 100), &vec![1, 2, 4, 5]) - .unwrap(); - CONSENSUS_STATES - .save(&mut store, ("test".to_string(), 80), &vec![1, 2, 4, 5]) - .unwrap(); - CONSENSUS_STATES - .save(&mut store, ("test".to_string(), 70), &vec![1, 2, 4, 5]) - .unwrap(); - - let result = QueryHandler::get_previous_consensus(&store, 110, "test".to_string()).unwrap(); - - println!("{result:?}"); - } -} diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs index e545de814..65169c195 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs @@ -1,16 +1,34 @@ +use std::marker::PhantomData; + use common::icon::icon::lightclient::v1::ClientState; use common::icon::icon::lightclient::v1::ConsensusState; +use common::icon::icon::types::v1::MerkleNode; use common::icon::icon::types::v1::SignedHeader; +use common::utils::calculate_root; use common::utils::keccak256; use cosmwasm_std::Addr; use cosmwasm_std::Api; +use cosmwasm_std::Deps; +use cosmwasm_std::Order; +use cosmwasm_std::StdResult; +use cosmwasm_std::Storage; +use cw_common::cw_println; +use cw_common::hex_string::HexString; +use cw_storage_plus::Bound; use serde::Deserialize; use serde::Serialize; +use crate::constants::CLIENT_STATES; +use crate::constants::CONFIG; +use crate::constants::CONSENSUS_STATES; +use crate::constants::PROCESSED_HEIGHTS; +use crate::constants::PROCESSED_TIMES; use crate::ContractError; +use common::traits::AnyTypes; +use prost::Message; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ConsensusStateUpdate { @@ -78,6 +96,263 @@ pub trait ILightClient { ) -> Result; } +pub trait IQueryHandler { + fn get_consensus_state( + storage: &dyn Storage, + client_id: &str, + height: u64, + ) -> Result { + let data = CONSENSUS_STATES + .load(storage, (client_id.to_string(), height)) + .map_err(|_e| ContractError::ConsensusStateNotFound { + height, + client_id: client_id.to_string(), + })?; + let state = ConsensusState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; + Ok(state) + } + + fn get_client_state( + storage: &dyn Storage, + client_id: &str, + ) -> Result { + let data = CLIENT_STATES + .load(storage, client_id.to_string()) + .map_err(|_e| ContractError::ClientStateNotFound(client_id.to_string()))?; + let state = ClientState::decode(data.as_slice()).map_err(ContractError::DecodeError)?; + Ok(state) + } + + fn get_latest_consensus_state( + storage: &dyn Storage, + client_id: &str, + ) -> Result { + let state = CLIENT_STATES + .load(storage, client_id.to_string()) + .map_err(ContractError::Std)?; + let client_state = + ClientState::decode(state.as_slice()).map_err(ContractError::DecodeError)?; + + let consensus_state = + Self::get_consensus_state(storage, client_id, client_state.latest_height)?; + Ok(consensus_state) + } + + fn get_timestamp_at_height( + storage: &dyn Storage, + client_id: &str, + height: u64, + ) -> Result { + PROCESSED_TIMES + .load(storage, (client_id.to_string(), height)) + .map_err(|_e| ContractError::TimestampNotFound { + height, + client_id: client_id.to_string(), + }) + } + + fn get_config(storage: &dyn Storage) -> Result { + CONFIG + .load(storage) + .map_err(|_e| ContractError::ConfigNotFound) + } + + fn get_client_state_any( + storage: &dyn Storage, + client_id: &str, + ) -> Result, ContractError> { + let state = Self::get_client_state(storage, client_id)?; + let any_state = state.to_any(); + Ok(any_state.encode_to_vec()) + } + + fn get_consensus_state_any( + storage: &dyn Storage, + client_id: &str, + height: u64, + ) -> Result, ContractError> { + let state = Self::get_consensus_state(storage, client_id, height)?; + let any_state = state.to_any(); + Ok(any_state.encode_to_vec()) + } + + fn get_latest_height(storage: &dyn Storage, client_id: &str) -> Result { + let state = Self::get_client_state(storage, client_id)?; + + Ok(state.latest_height) + } + + fn get_processed_time_at_height( + storage: &dyn Storage, + client_id: &str, + height: u64, + ) -> Result { + PROCESSED_TIMES + .load(storage, (client_id.to_string(), height)) + .map_err(|_e| ContractError::ProcessedTimeNotFound { + client_id: client_id.to_string(), + height, + }) + } + fn get_processed_blocknumber_at_height( + storage: &dyn Storage, + client_id: &str, + height: u64, + ) -> Result { + PROCESSED_HEIGHTS + .load(storage, (client_id.to_string(), height)) + .map_err(|_e| ContractError::ProcessedHeightNotFound { + client_id: client_id.to_string(), + height, + }) + } + + /** + * @dev verifyMembership is a generic proof verification method which verifies a proof of the existence of a value at a given CommitmentPath at the specified height. + * The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24). + */ + fn verify_membership( + deps: Deps, + client_id: &str, + height: u64, + delay_time_period: u64, + delay_block_period: u64, + proof: &[MerkleNode], + value: &[u8], + path: &[u8], + ) -> Result { + let client_state = Self::get_client_state(deps.storage, client_id)?; + let consensus_state: ConsensusState = + Self::get_consensus_state(deps.storage, client_id, height)?; + Self::verify_membership_inner( + deps, + client_id, + client_state, + consensus_state, + height, + delay_time_period, + delay_block_period, + proof, + value, + path, + ) + } + + fn verify_membership_inner( + deps: Deps, + client_id: &str, + client_state: ClientState, + consensus_state: ConsensusState, + height: u64, + _delay_time_period: u64, + _delay_block_period: u64, + proof: &[MerkleNode], + value: &[u8], + path: &[u8], + ) -> Result { + cw_println!( + deps.api, + "[LightClient]: Path Bytes {:?}", + HexString::from_bytes(path) + ); + cw_println!( + deps.api, + "[LightClient]: Value Bytes {:?}", + HexString::from_bytes(value) + ); + let path = keccak256(path).to_vec(); + cw_println!(deps.api, "[LightClient]: client id is: {:?}", client_id); + + if client_state.frozen_height != 0 && height > client_state.frozen_height { + return Err(ContractError::ClientStateFrozen(client_state.frozen_height)); + } + + let mut value_hash = value.to_vec(); + if !value.is_empty() { + value_hash = keccak256(value).to_vec(); + } + + // let _ = + // self.validate_delay_args(client_id, height, delay_time_period, delay_block_period)?; + + cw_println!( + deps.api, + "[LightClient]: Path Hash {:?}", + HexString::from_bytes(&path) + ); + cw_println!( + deps.api, + "[LightClient]: Value Hash {:?}", + HexString::from_bytes(&value_hash) + ); + let leaf = keccak256(&[path, value_hash].concat()); + cw_println!( + deps.api, + "[LightClient]: Leaf Value {:?}", + HexString::from_bytes(&leaf) + ); + + let message_root = calculate_root(leaf, proof); + cw_println!( + deps.api, + "[LightClient]: Stored Message Root {:?} ", + hex::encode(consensus_state.message_root.clone()) + ); + cw_println!( + deps.api, + "[LightClient]: Calculated Message Root : {:?}", + HexString::from_bytes(&message_root) + ); + if consensus_state.message_root != message_root { + return Err(ContractError::InvalidMessageRoot(hex::encode(message_root))); + } + + Ok(true) + } + + /** + * @dev verifyNonMembership is a generic proof verification method which verifies the absence of a given CommitmentPath at a specified height. + * The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24). + */ + fn verify_non_membership( + deps: Deps, + client_id: &str, + height: u64, + delay_time_period: u64, + delay_block_period: u64, + proof: &[MerkleNode], + path: &[u8], + ) -> Result { + Self::verify_membership( + deps, + client_id, + height, + delay_time_period, + delay_block_period, + proof, + &[], + path, + ) + } + + fn get_previous_consensus( + storage: &dyn Storage, + height: u64, + client_id: String, + ) -> Result, ContractError> { + let key = (client_id, height); + let bound = Bound::Exclusive::<(String, u64)>((key, PhantomData)); + + let result = CONSENSUS_STATES + .range(storage, None, Some(bound), Order::Descending) + .take(1) + .collect::)>>>() + .map_err(ContractError::Std)?; + + let keys = result.into_iter().map(|t| t.0 .1).collect::>(); + Ok(keys) + } +} pub trait IStoreReader {} pub trait IContext { fn get_client_state(&self, client_id: &str) -> Result; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs index 3ba6f1084..d4756a59f 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs @@ -1,15 +1,22 @@ +use common::consensus_state::IConsensusState; use common::{ ibc::Height, icon::icon::lightclient::v1::{ClientState, ConsensusState}, traits::AnyTypes, }; use cosmwasm_std::{Api, Env, Storage}; -use cw_common::raw_types::Any; -use cw_light_client_common::{traits::IContext, ContractError}; + +use cw_light_client_common::traits::IQueryHandler; +use cw_light_client_common::{ + constants::{PROCESSED_HEIGHTS, PROCESSED_TIMES}, + traits::IContext, + ContractError, +}; use ics07_tendermint_cw::ics23::FakeInner; -use ics08_wasm::client_state::ClientState as WasmClientState; -use prost::Message; -use tendermint_proto::Protobuf; + +use crate::utils::{ + get_client_state_key, get_consensus_state_key, to_wasm_client_state, to_wasm_consensus_state, +}; pub struct CwContext<'a> { pub storage: &'a mut dyn Storage, pub api: &'a dyn Api, @@ -26,28 +33,6 @@ impl<'a> CwContext<'a> { } } -pub fn get_consensus_state_key(height: Height) -> Vec { - [ - "consensusStates/".to_string().into_bytes(), - format!("{height}").into_bytes(), - ] - .concat() -} - -pub fn to_wasm_client_state( - client_state: ClientState, - old_state: Vec, -) -> Result, ContractError> { - use ibc::Height; - let any = Any::decode(&*old_state).unwrap(); - let mut wasm_client_state = - WasmClientState::::decode_vec(&any.value).unwrap(); - wasm_client_state.data = client_state.to_any().encode_to_vec(); - wasm_client_state.latest_height = Height::new(0, client_state.latest_height); - let vec1 = wasm_client_state.to_any().encode_to_vec(); - Ok(vec1) -} - impl<'a> IContext for CwContext<'a> { fn get_client_state( &self, @@ -56,20 +41,21 @@ impl<'a> IContext for CwContext<'a> { common::icon::icon::lightclient::v1::ClientState, cw_light_client_common::ContractError, > { - let any_bytes = self - .storage - .get(&"clientState".to_string().into_bytes()) - .ok_or(ContractError::ClientStateNotFound(client_id.to_string()))?; - let any_state = Any::decode(any_bytes.as_slice()).unwrap(); - ClientState::from_any(any_state).map_err(ContractError::DecodeError) + QueryHandler::get_client_state(self.storage, client_id) } fn insert_client_state( &mut self, - _client_id: &str, - _state: common::icon::icon::lightclient::v1::ClientState, + client_id: &str, + client_state: common::icon::icon::lightclient::v1::ClientState, ) -> Result<(), cw_light_client_common::ContractError> { - unimplemented!() + let old_state = self + .storage + .get(&get_client_state_key()) + .ok_or(ContractError::ClientStateNotFound(client_id.to_string()))?; + let new_state = to_wasm_client_state(client_state, old_state)?; + self.storage.set(&get_client_state_key(), &new_state); + Ok(()) } fn get_consensus_state( @@ -80,49 +66,50 @@ impl<'a> IContext for CwContext<'a> { common::icon::icon::lightclient::v1::ConsensusState, cw_light_client_common::ContractError, > { - let ibc_height = Height::new(0, height).unwrap(); - let any_bytes = self - .storage - .get(&get_consensus_state_key(ibc_height)) - .ok_or(ContractError::ConsensusStateNotFound { - height, - client_id: client_id.to_string(), - })?; - let any_state = Any::decode(any_bytes.as_slice()).unwrap(); - ConsensusState::from_any(any_state).map_err(ContractError::DecodeError) + QueryHandler::get_consensus_state(self.storage, client_id, height) } fn insert_consensus_state( &mut self, _client_id: &str, - _height: u64, - _state: common::icon::icon::lightclient::v1::ConsensusState, + height: u64, + consensus_state: common::icon::icon::lightclient::v1::ConsensusState, ) -> Result<(), cw_light_client_common::ContractError> { - unimplemented!() + let ibc_height = Height::new(0, height).unwrap(); + let wasm_consensus_state = to_wasm_consensus_state(consensus_state); + self.storage + .set(&&get_consensus_state_key(ibc_height), &wasm_consensus_state); + Ok(()) } fn get_timestamp_at_height( &self, - _client_id: &str, - _height: u64, + client_id: &str, + height: u64, ) -> Result { - unimplemented!() + QueryHandler::get_processed_time_at_height(self.storage, client_id, height) } fn insert_timestamp_at_height( &mut self, - _client_id: &str, - _height: u64, - ) -> Result<(), cw_light_client_common::ContractError> { - unimplemented!() + client_id: &str, + height: u64, + ) -> Result<(), ContractError> { + let time = self.env.block.time.nanos(); + PROCESSED_TIMES + .save(self.storage, (client_id.to_string(), height), &time) + .map_err(|_e| ContractError::FailedToSaveProcessedTime) } fn insert_blocknumber_at_height( &mut self, - _client_id: &str, - _height: u64, - ) -> Result<(), cw_light_client_common::ContractError> { - unimplemented!() + client_id: &str, + height: u64, + ) -> Result<(), ContractError> { + let block_height = self.env.block.height; + PROCESSED_HEIGHTS + .save(self.storage, (client_id.to_string(), height), &block_height) + .map_err(|_e| ContractError::FailedToSaveProcessedTime) } fn get_config( @@ -139,27 +126,27 @@ impl<'a> IContext for CwContext<'a> { } fn get_current_block_time(&self) -> u64 { - unimplemented!() + self.env.block.time.nanos() } fn get_current_block_height(&self) -> u64 { - unimplemented!() + self.env.block.height } fn get_processed_time_at_height( &self, - _client_id: &str, - _height: u64, - ) -> Result { - unimplemented!() + client_id: &str, + height: u64, + ) -> Result { + QueryHandler::get_processed_time_at_height(self.storage, client_id, height) } fn get_processed_block_at_height( &self, - _client_id: &str, - _height: u64, - ) -> Result { - unimplemented!() + client_id: &str, + height: u64, + ) -> Result { + QueryHandler::get_processed_blocknumber_at_height(self.storage, client_id, height) } fn ensure_owner( @@ -177,6 +164,10 @@ impl<'a> IContext for CwContext<'a> { } fn api(&self) -> &dyn Api { - unimplemented!() + self.api } } + +pub struct QueryHandler; + +impl IQueryHandler for QueryHandler {} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 06b2c006e..8e5b3289e 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -3,7 +3,7 @@ use common::icon::icon::lightclient::v1::{ClientState, ConsensusState}; use common::traits::AnyTypes; use cosmwasm_schema::cw_serde; use cw_common::ibc_types::IbcHeight; -use cw_common::to_checked_address; +use cw_common::{cw_println, to_checked_address}; #[cfg(feature = "mock")] use crate::mock_client::MockClient; @@ -21,14 +21,11 @@ use cw_common::raw_types::Any; use cw_common::types::VerifyChannelState; use crate::constants::{CLIENT_STATE_HASH, CONSENSUS_STATE_HASH, HEIGHT}; +use crate::context::CwContext; use crate::light_client::IconClient; -use crate::state::CwContext; +use crate::msg::{ContractResult, ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::traits::{Config, IContext, ILightClient}; use crate::ContractError; -use cw_common::client_msg::{ - ExecuteMsg, InstantiateMsg, LightClientPacketMessage, QueryMsg, VerifyClientConsensusState, - VerifyClientFullState, VerifyConnectionState, -}; use prost::Message; // version info for migration info @@ -38,261 +35,57 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, msg: InstantiateMsg, ) -> Result { set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION) .map_err(|_e| ContractError::FailedToInitContract)?; - let ibc_host = to_checked_address(deps.as_ref(), msg.ibc_host.as_ref()); - let config = Config::new(info.sender, ibc_host); - let mut context = CwContext::new(deps, _env); - context.insert_config(&config)?; + let client_id = "08-wasm-0"; + let mut context = CwContext::new(deps, env); + let client_state = context.get_client_state(client_id)?; + context.insert_blocknumber_at_height(client_id, client_state.latest_height)?; + context.insert_timestamp_at_height(client_id, client_state.latest_height)?; + Ok(Response::default()) } #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps_mut: DepsMut, - _env: Env, + env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> Result { +) -> Result { match msg { - ExecuteMsg::CreateClient { - client_id, - client_state, - consensus_state, - } => { - let context = CwContext::new(deps_mut, _env); - let mut client = IconClient::new(context); - let client_state_any = - Any::decode(client_state.as_slice()).map_err(ContractError::DecodeError)?; - let consensus_state_any = - Any::decode(consensus_state.as_slice()).map_err(ContractError::DecodeError)?; - let client_state = ClientState::from_any(client_state_any.clone()) - .map_err(ContractError::DecodeError)?; - let consensus_state = ConsensusState::from_any(consensus_state_any.clone()) - .map_err(ContractError::DecodeError)?; - let update = - client.create_client(info.sender, &client_id, client_state, consensus_state)?; - - let mut response = Response::new() - .add_attribute( - CLIENT_STATE_HASH, - hex::encode(update.client_state_commitment), - ) - .add_attribute( - CONSENSUS_STATE_HASH, - hex::encode(update.consensus_state_commitment), - ) - .add_attribute(HEIGHT, update.height.to_string()); - - let client_response = CreateClientResponse::new( - ICON_CLIENT_TYPE.to_string(), - IbcHeight::new(1, update.height).unwrap().to_string(), - update.client_state_commitment.to_vec(), - update.consensus_state_commitment.into(), - client_state_any.encode_to_vec(), - consensus_state_any.encode_to_vec(), - ); - - response.data = to_binary(&client_response).ok(); - - Ok(response) - } - ExecuteMsg::UpdateClient { - client_id, - signed_header, - } => { - let context = CwContext::new(deps_mut, _env); + ExecuteMsg::VerifyMembership(_) => todo!(), + ExecuteMsg::VerifyNonMembership(_) => todo!(), + ExecuteMsg::VerifyClientMessage(_) => todo!(), + ExecuteMsg::CheckForMisbehaviour(_) => todo!(), + ExecuteMsg::UpdateStateOnMisbehaviour(_) => todo!(), + ExecuteMsg::UpdateState(msg) => { + cw_println!(deps_mut.api, "Received Header {:?}", msg); + let context = CwContext::new(deps_mut, env); let mut client = IconClient::new(context); - let header_any = Any::decode(signed_header.as_slice()).unwrap(); - let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; - let update = client.update_client(info.sender, &client_id, header)?; - let response_data = to_binary(&UpdateClientResponse { - height: to_ibc_height(update.height).map(|h| h.to_string())?, - client_id, - client_state_commitment: update.client_state_commitment.to_vec(), - consensus_state_commitment: update.consensus_state_commitment.to_vec(), - client_state_bytes: ClientState::any_from_value(&update.client_state_bytes) - .encode_to_vec(), - consensus_state_bytes: ConsensusState::any_from_value( - &update.consensus_state_bytes, - ) - .encode_to_vec(), - }) - .map_err(ContractError::Std)?; - Ok(Response::new() - .add_attribute( - CLIENT_STATE_HASH, - hex::encode(update.client_state_commitment), - ) - .add_attribute( - CONSENSUS_STATE_HASH, - hex::encode(update.consensus_state_commitment), - ) - .add_attribute(HEIGHT, update.height.to_string()) - .set_data(response_data)) - } - ExecuteMsg::Misbehaviour { - client_id: _, - misbehaviour: _, - } => { - todo!() - } - - ExecuteMsg::UpgradeClient { - upgraded_client_state: _, - upgraded_consensus_state: _, - proof_upgrade_client: _, - proof_upgrade_consensus_state: _, - } => { - todo!() - } + match msg.client_message { + crate::msg::ClientMessageRaw::Header(wasmheader) => { + let header_any = Any::decode(&*wasmheader.data).unwrap(); + let header = + SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; + let client_id = "08-wasm-0"; + let _update = client.update_client(info.sender, &client_id, header)?; + Ok(to_binary(&ContractResult::success()).unwrap()) + } + crate::msg::ClientMessageRaw::Misbehaviour(_) => { + Ok(to_binary(&ContractResult::success()).unwrap()) + } + } + } + ExecuteMsg::CheckSubstituteAndUpdateState(_) => todo!(), + ExecuteMsg::VerifyUpgradeAndUpdateState(_) => todo!(), } } -pub fn validate_channel_state( - client_id: &str, - deps: Deps, - state: &VerifyChannelState, -) -> Result { - let proofs_decoded = - MerkleProofs::decode(state.proof.as_slice()).map_err(ContractError::DecodeError)?; - let height = to_height_u64(&state.proof_height)?; - let result = QueryHandler::verify_membership( - deps, - client_id, - height, - 0, - 0, - &proofs_decoded.proofs, - &state.expected_counterparty_channel_end, - &state.counterparty_chan_end_path, - )?; - Ok(result) -} - -pub fn validate_connection_state( - client_id: &str, - deps: Deps, - state: &VerifyConnectionState, -) -> Result { - let proofs_decoded = - MerkleProofs::decode(state.proof.as_slice()).map_err(ContractError::DecodeError)?; - let height = to_height_u64(&state.proof_height)?; - - let result = QueryHandler::verify_membership( - deps, - client_id, - height, - 0, - 0, - &proofs_decoded.proofs, - &state.expected_counterparty_connection_end, - &state.counterparty_conn_end_path, - )?; - Ok(result) -} - -pub fn validate_client_state( - client_id: &str, - deps: Deps, - state: &VerifyClientFullState, -) -> Result { - let proofs_decoded = MerkleProofs::decode(state.client_state_proof.as_slice()) - .map_err(ContractError::DecodeError)?; - println!("starting validating client state"); - let height = to_height_u64(&state.proof_height)?; - let result = QueryHandler::verify_membership( - deps, - client_id, - height, - 0, - 0, - &proofs_decoded.proofs, - &state.expected_client_state, - &state.client_state_path, - )?; - Ok(result) -} - -pub fn validate_consensus_state( - client_id: &str, - deps: Deps, - state: &VerifyClientConsensusState, -) -> Result { - let proofs_decoded = MerkleProofs::decode(state.consensus_state_proof.as_slice()) - .map_err(ContractError::DecodeError)?; - let height = to_height_u64(&state.proof_height)?; - let result = QueryHandler::verify_membership( - deps, - client_id, - height, - 0, - 0, - &proofs_decoded.proofs, - &state.expected_conesenus_state, - &state.conesenus_state_path, - )?; - Ok(result) -} - -pub fn validate_next_seq_recv( - deps: Deps, - client_id: &str, - state: &LightClientPacketMessage, -) -> Result { - let result = match state { - LightClientPacketMessage::VerifyNextSequenceRecv { - height, - prefix: _, - proof, - root: _, - seq_recv_path, - sequence, - } => { - let proofs_decoded = - MerkleProofs::decode(proof.as_slice()).map_err(ContractError::DecodeError)?; - let height = to_height_u64(height)?; - - QueryHandler::verify_membership( - deps, - client_id, - height, - 0, - 0, - &proofs_decoded.proofs, - sequence.to_be_bytes().as_ref(), - seq_recv_path, - )? - } - LightClientPacketMessage::VerifyPacketReceiptAbsence { - height, - prefix: _, - proof, - root: _, - receipt_path, - } => { - let proofs_decoded = - MerkleProofs::decode(proof.as_slice()).map_err(ContractError::DecodeError)?; - let height = to_height_u64(height)?; - - QueryHandler::verify_non_membership( - deps, - client_id, - height, - 0, - 0, - &proofs_decoded.proofs, - receipt_path, - )? - } - }; - Ok(result) -} - fn to_height_u64(height: &str) -> Result { let heights = height.split('-').collect::>(); if heights.len() != 2 { @@ -321,190 +114,10 @@ pub fn any_from_byte(bytes: &[u8]) -> Result { #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::GetClientState { client_id } => { - let res = QueryHandler::get_client_state_any(deps.storage, &client_id).unwrap(); - to_binary(&res) - } - QueryMsg::GetConsensusState { client_id, height } => to_binary( - &QueryHandler::get_consensus_state_any(deps.storage, &client_id, height).unwrap(), - ), - - QueryMsg::GetLatestHeight { client_id } => { - to_binary(&QueryHandler::get_latest_height(deps.storage, &client_id).unwrap()) - } - QueryMsg::VerifyMembership { - client_id, - message_bytes, - proofs, - path, - height, - delay_time_period, - delay_block_period, - } => { - let proofs_decoded = MerkleProofs::decode(proofs.as_slice()) - .map_err(|e| StdError::GenericErr { msg: e.to_string() })?; - let result = QueryHandler::verify_membership( - deps, - &client_id, - height, - delay_time_period, - delay_block_period, - &proofs_decoded.proofs, - &message_bytes, - &path, - ) - .unwrap_or(false); - to_binary(&result) - } - QueryMsg::VerifyNonMembership { - client_id, - - proofs, - path, - height, - delay_time_period, - delay_block_period, - } => { - let proofs_decoded = MerkleProofs::decode(proofs.as_slice()) - .map_err(|e| StdError::GenericErr { msg: e.to_string() })?; - let result = QueryHandler::verify_non_membership( - deps, - &client_id, - height, - delay_time_period, - delay_block_period, - &proofs_decoded.proofs, - &path, - ) - .unwrap_or(false); - to_binary(&result) - } - QueryMsg::VerifyPacketData { - client_id, - verify_packet_data, - // packet_data, - } => { - let proofs_decoded = MerkleProofs::decode(verify_packet_data.proof.as_slice()) - .map_err(|e| StdError::GenericErr { msg: e.to_string() })?; - let height = to_height_u64(&verify_packet_data.height).unwrap(); - let result = QueryHandler::verify_membership( - deps, - &client_id, - height, - 0, - 0, - &proofs_decoded.proofs, - &verify_packet_data.commitment, - &verify_packet_data.commitment_path, - ) - .unwrap_or(false); - - to_binary(&result) - } - QueryMsg::VerifyPacketAcknowledgement { - client_id, - verify_packet_acknowledge, - // packet_data, - } => { - let proofs_decoded = MerkleProofs::decode(verify_packet_acknowledge.proof.as_slice()) - .map_err(|e| StdError::GenericErr { msg: e.to_string() })?; - let height = to_height_u64(&verify_packet_acknowledge.height).unwrap(); - let result = QueryHandler::verify_membership( - deps, - &client_id, - height, - 0, - 0, - &proofs_decoded.proofs, - &verify_packet_acknowledge.ack, - &verify_packet_acknowledge.ack_path, - ) - .unwrap_or(false); - - to_binary(&result) - } - QueryMsg::VerifyOpenConfirm { - client_id, - verify_connection_state, - // expected_response, - } => { - let result = validate_connection_state(&client_id, deps, &verify_connection_state) - .unwrap_or(false); - to_binary(&result) - } - QueryMsg::VerifyConnectionOpenTry(state) => { - println!("checking all the valid state "); - let client_valid = - validate_client_state(&state.client_id, deps, &state.verify_client_full_state) - .unwrap_or(false); - println!(" is valid clientstate {client_valid:?}"); - - let connection_valid = - validate_connection_state(&state.client_id, deps, &state.verify_connection_state) - .unwrap_or(false); - to_binary(&(client_valid && connection_valid)) - } - QueryMsg::VerifyConnectionOpenAck(state) => { - let connection_valid = - validate_connection_state(&state.client_id, deps, &state.verify_connection_state) - .unwrap(); - let client_valid = - validate_client_state(&state.client_id, deps, &state.verify_client_full_state) - .unwrap(); - - to_binary(&(client_valid && connection_valid)) - } - - QueryMsg::VerifyChannel { - verify_channel_state, - // message_info, - // endpoint, - } => { - // fix once we receive client id - let result = validate_channel_state( - &verify_channel_state.client_id, - deps, - &verify_channel_state, - ) - .unwrap(); - - to_binary(&result) - } - QueryMsg::PacketTimeout { - client_id, - next_seq_recv_verification_result, - } => { - let _sequence_valid = - validate_next_seq_recv(deps, &client_id, &next_seq_recv_verification_result) - .unwrap(); - to_binary(&_sequence_valid) - } - QueryMsg::TimeoutOnCLose { - client_id, - verify_channel_state, - next_seq_recv_verification_result, - } => { - let is_channel_valid = - validate_channel_state(&client_id, deps, &verify_channel_state).unwrap(); - let _sequence_valid = - validate_next_seq_recv(deps, &client_id, &next_seq_recv_verification_result) - .unwrap(); - - to_binary(&(is_channel_valid && _sequence_valid)) - } - QueryMsg::GetPreviousConsensusState { client_id, height } => { - let res: Vec = - QueryHandler::get_previous_consensus(deps.storage, height, client_id).unwrap(); - to_binary(&res) - } - QueryMsg::GetTimestampAtHeight { - client_id: _, - height: _, - } => to_binary(&0_u64), - QueryMsg::GetLatestConsensusState { client_id } => { - let res = QueryHandler::get_latest_consensus_state(deps.storage, &client_id).unwrap(); - to_binary(&res) - } + QueryMsg::ClientTypeMsg(_) => todo!(), + QueryMsg::GetLatestHeightsMsg(_) => todo!(), + QueryMsg::ExportMetadata(_) => todo!(), + QueryMsg::Status(_) => todo!(), } } @@ -517,18 +130,3 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result) -> impl ILightClient + '_ { - #[cfg(feature = "mock")] - return MockClient::new(context); - #[cfg(not(feature = "mock"))] - return IconClient::new(context); -} - -pub fn ensure_owner(deps: Deps, info: &MessageInfo) -> Result<(), ContractError> { - let config = QueryHandler::get_config(deps.storage)?; - if info.sender != config.owner { - return Err(ContractError::Unauthorized {}); - } - Ok(()) -} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs index 49c225fff..0114d5a0a 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs @@ -2,10 +2,10 @@ pub use cw_light_client_common::constants; mod context; pub mod contract; mod msg; - +pub mod query_handler; +pub mod utils; pub use cw_light_client_common::light_client; -pub use cw_light_client_common::query_handler; -pub use cw_light_client_common::state; + pub use cw_light_client_common::traits; pub use cw_light_client_common::error::ContractError; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs new file mode 100644 index 000000000..4159f8003 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs @@ -0,0 +1,37 @@ +use common::ibc::Height; +use cw_light_client_common::{traits::IQueryHandler, ContractError}; + +use crate::utils::{ + decode_client_state, decode_consensus_state, get_client_state_key, get_consensus_state_key, +}; + +pub struct QueryHandler; +impl IQueryHandler for QueryHandler { + fn get_client_state( + storage: &dyn cosmwasm_std::Storage, + client_id: &str, + ) -> Result< + common::icon::icon::lightclient::v1::ClientState, + cw_light_client_common::ContractError, + > { + let any_bytes = storage + .get(&get_client_state_key()) + .ok_or(ContractError::ClientStateNotFound(client_id.to_string()))?; + return decode_client_state(&any_bytes); + } + + fn get_consensus_state( + storage: &dyn cosmwasm_std::Storage, + client_id: &str, + height: u64, + ) -> Result { + let ibc_height = Height::new(0, height).unwrap(); + let any_bytes = storage.get(&get_consensus_state_key(ibc_height)).ok_or( + ContractError::ConsensusStateNotFound { + height, + client_id: client_id.to_string(), + }, + )?; + return decode_consensus_state(&any_bytes); + } +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs new file mode 100644 index 000000000..d7c95f7c4 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs @@ -0,0 +1,67 @@ +use common::{ + consensus_state::IConsensusState, + ibc::Height, + icon::icon::lightclient::v1::{ClientState, ConsensusState}, + traits::AnyTypes, +}; +use cw_common::raw_types::Any; +use cw_light_client_common::ContractError; +use ics07_tendermint_cw::ics23::FakeInner; +use ics08_wasm::client_state::ClientState as WasmClientState; +use prost::Message; +use tendermint_proto::Protobuf; +pub fn get_consensus_state_key(height: Height) -> Vec { + [ + "consensusStates/".to_string().into_bytes(), + format!("{height}").into_bytes(), + ] + .concat() +} + +pub fn get_client_state_key() -> Vec { + "clientState".to_string().into_bytes() +} + +pub fn to_wasm_client_state( + client_state: ClientState, + old_wasm_state: Vec, +) -> Result, ContractError> { + use ibc::Height; + let any = Any::decode(&*old_wasm_state).unwrap(); + let mut wasm_client_state = + WasmClientState::::decode_vec(&any.value).unwrap(); + wasm_client_state.data = client_state.to_any().encode_to_vec(); + wasm_client_state.latest_height = Height::new(0, client_state.latest_height); + let vec1 = wasm_client_state.to_any().encode_to_vec(); + Ok(vec1) +} + +pub fn to_wasm_consensus_state(consensus_state: ConsensusState) -> Vec { + let wasm_consensus_state = ics08_wasm::consensus_state::ConsensusState { + data: consensus_state.to_any().encode_to_vec(), + timestamp: consensus_state.timestamp().nanoseconds(), + inner: Box::new(FakeInner), + }; + wasm_consensus_state.to_any().encode_to_vec() +} + +pub fn decode_client_state(data: &[u8]) -> Result { + let any = Any::decode(data).unwrap(); + let wasm_state = + ics08_wasm::client_state::ClientState::::decode_vec( + &any.value, + ) + .unwrap(); + let any = Any::decode(&*wasm_state.data).unwrap(); + let state = ClientState::from_any(any).unwrap(); + Ok(state) +} + +pub fn decode_consensus_state(value: &[u8]) -> Result { + let any = Any::decode(&mut &*value).unwrap(); + let wasm_consensus_state = + ics08_wasm::consensus_state::ConsensusState::::decode_vec(&any.value).unwrap(); + let any = Any::decode(&mut &wasm_consensus_state.data[..]).unwrap(); + let any_consensus_state = ConsensusState::from_any(any).unwrap(); + Ok(any_consensus_state) +} From 1213cc5c215fdcb91cc8d02af8b72fb2fae61673 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Sat, 30 Sep 2023 12:17:58 +0545 Subject: [PATCH 09/64] fix: wrap result in response --- .../cw-icon-light-client/src/query_handler.rs | 20 -------- .../cw-wasm-light-client/src/context.rs | 10 +--- .../cw-wasm-light-client/src/contract.rs | 49 ++++++++++--------- .../cw-wasm-light-client/src/query_handler.rs | 4 +- 4 files changed, 29 insertions(+), 54 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs index 3bdde2ba2..eab204504 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/query_handler.rs @@ -1,24 +1,4 @@ -use std::marker::PhantomData; - -use crate::{ - constants::{CLIENT_STATES, CONFIG, CONSENSUS_STATES, PROCESSED_HEIGHTS, PROCESSED_TIMES}, - traits::Config, - ContractError, -}; -use common::{ - icon::icon::{ - lightclient::v1::{ClientState, ConsensusState}, - types::v1::MerkleNode, - }, - traits::AnyTypes, - utils::{calculate_root, keccak256}, -}; -use cosmwasm_std::{Deps, Order, StdResult, Storage}; -use cw_common::{cw_println, hex_string::HexString}; use cw_light_client_common::traits::IQueryHandler; -use cw_storage_plus::Bound; - -use prost::Message; pub struct QueryHandler; impl IQueryHandler for QueryHandler {} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs index d4756a59f..9acbd0d2f 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs @@ -1,9 +1,4 @@ -use common::consensus_state::IConsensusState; -use common::{ - ibc::Height, - icon::icon::lightclient::v1::{ClientState, ConsensusState}, - traits::AnyTypes, -}; +use common::ibc::Height; use cosmwasm_std::{Api, Env, Storage}; use cw_light_client_common::traits::IQueryHandler; @@ -12,7 +7,6 @@ use cw_light_client_common::{ traits::IContext, ContractError, }; -use ics07_tendermint_cw::ics23::FakeInner; use crate::utils::{ get_client_state_key, get_consensus_state_key, to_wasm_client_state, to_wasm_consensus_state, @@ -78,7 +72,7 @@ impl<'a> IContext for CwContext<'a> { let ibc_height = Height::new(0, height).unwrap(); let wasm_consensus_state = to_wasm_consensus_state(consensus_state); self.storage - .set(&&get_consensus_state_key(ibc_height), &wasm_consensus_state); + .set(&get_consensus_state_key(ibc_height), &wasm_consensus_state); Ok(()) } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 8e5b3289e..56b40424b 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -1,30 +1,24 @@ -use common::constants::ICON_CLIENT_TYPE; -use common::icon::icon::lightclient::v1::{ClientState, ConsensusState}; use common::traits::AnyTypes; use cosmwasm_schema::cw_serde; +use cw_common::cw_println; use cw_common::ibc_types::IbcHeight; -use cw_common::{cw_println, to_checked_address}; #[cfg(feature = "mock")] use crate::mock_client::MockClient; -use crate::query_handler::QueryHandler; -use common::icon::icon::types::v1::{MerkleProofs, SignedHeader}; + +use common::icon::icon::types::v1::SignedHeader; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; -use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, -}; +use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; use cw2::set_contract_version; -use cw_common::client_response::{CreateClientResponse, UpdateClientResponse}; + use cw_common::raw_types::Any; -use cw_common::types::VerifyChannelState; -use crate::constants::{CLIENT_STATE_HASH, CONSENSUS_STATE_HASH, HEIGHT}; use crate::context::CwContext; use crate::light_client::IconClient; use crate::msg::{ContractResult, ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::traits::{Config, IContext, ILightClient}; +use crate::traits::{IContext, ILightClient}; use crate::ContractError; use prost::Message; @@ -36,8 +30,8 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); pub fn instantiate( deps: DepsMut, env: Env, - info: MessageInfo, - msg: InstantiateMsg, + _info: MessageInfo, + _msg: InstantiateMsg, ) -> Result { set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION) .map_err(|_e| ContractError::FailedToInitContract)?; @@ -56,8 +50,20 @@ pub fn execute( env: Env, info: MessageInfo, msg: ExecuteMsg, +) -> Result { + let data = process_message(deps_mut, env, info, msg)?; + let mut response = Response::default(); + response.data = Some(data); + Ok(response) +} + +fn process_message( + deps_mut: DepsMut, + env: Env, + info: MessageInfo, + msg: ExecuteMsg, ) -> Result { - match msg { + let result: Result = match msg { ExecuteMsg::VerifyMembership(_) => todo!(), ExecuteMsg::VerifyNonMembership(_) => todo!(), ExecuteMsg::VerifyClientMessage(_) => todo!(), @@ -73,7 +79,7 @@ pub fn execute( let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; let client_id = "08-wasm-0"; - let _update = client.update_client(info.sender, &client_id, header)?; + let _update = client.update_client(info.sender, client_id, header)?; Ok(to_binary(&ContractResult::success()).unwrap()) } crate::msg::ClientMessageRaw::Misbehaviour(_) => { @@ -83,7 +89,8 @@ pub fn execute( } ExecuteMsg::CheckSubstituteAndUpdateState(_) => todo!(), ExecuteMsg::VerifyUpgradeAndUpdateState(_) => todo!(), - } + }; + Ok(result.unwrap()) } fn to_height_u64(height: &str) -> Result { @@ -105,14 +112,8 @@ pub fn any_from_byte(bytes: &[u8]) -> Result { Ok(any) } -// pub fn to_packet_response(packet_data: &[u8]) -> Result { -// let packet_data: PacketData = from_slice(packet_data).map_err(ContractError::Std)?; -// let data = to_binary(&PacketDataResponse::from(packet_data)).map_err(ContractError::Std)?; -// Ok(data) -// } - #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { +pub fn query(_deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::ClientTypeMsg(_) => todo!(), QueryMsg::GetLatestHeightsMsg(_) => todo!(), diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs index 4159f8003..0b666cb6f 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs @@ -17,7 +17,7 @@ impl IQueryHandler for QueryHandler { let any_bytes = storage .get(&get_client_state_key()) .ok_or(ContractError::ClientStateNotFound(client_id.to_string()))?; - return decode_client_state(&any_bytes); + decode_client_state(&any_bytes) } fn get_consensus_state( @@ -32,6 +32,6 @@ impl IQueryHandler for QueryHandler { client_id: client_id.to_string(), }, )?; - return decode_consensus_state(&any_bytes); + decode_consensus_state(&any_bytes) } } From 8252d6666e34b707695e6f4e03500317125e7855 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Sat, 30 Sep 2023 16:21:19 +0545 Subject: [PATCH 10/64] feat: add verify header --- .../src/light_client.rs | 55 ++++++++++------- .../cw-light-client-common/src/traits.rs | 9 ++- .../cw-wasm-light-client/src/context.rs | 9 +-- .../cw-wasm-light-client/src/contract.rs | 61 +++++++++++++++++-- 4 files changed, 102 insertions(+), 32 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index e92a6844a..648b001d6 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -108,7 +108,7 @@ impl ILightClient for IconClient { client_state: ClientState, consensus_state: ConsensusState, ) -> Result { - self.context.ensure_ibc_host(caller)?; + self.context.ensure_ibc_host(&caller)?; let exists = self.context.get_client_state(client_id).is_ok(); if exists { return Err(ContractError::ClientStateAlreadyExists( @@ -143,6 +143,38 @@ impl ILightClient for IconClient { client_id: &str, signed_header: SignedHeader, ) -> Result { + self.verify_header(&caller, client_id, &signed_header)?; + let state = self.context.get_client_state(client_id)?; + let btp_header = signed_header.header.clone().unwrap(); + + let consensus_state = btp_header.to_consensus_state(); + self.context.insert_client_state(client_id, state.clone())?; + self.context.insert_consensus_state( + client_id, + btp_header.main_height, + consensus_state.clone(), + )?; + self.context + .insert_timestamp_at_height(client_id, btp_header.main_height)?; + self.context + .insert_blocknumber_at_height(client_id, btp_header.main_height)?; + let commitment = keccak256(&consensus_state.encode_to_vec()); + + Ok(ConsensusStateUpdate { + consensus_state_commitment: commitment, + client_state_commitment: keccak256(&state.encode_to_vec()), + client_state_bytes: state.encode_to_vec(), + consensus_state_bytes: consensus_state.encode_to_vec(), + height: btp_header.main_height, + }) + } + + fn verify_header( + &mut self, + caller: &Addr, + client_id: &str, + signed_header: &SignedHeader, + ) -> Result<(), Self::Error> { self.context.ensure_ibc_host(caller)?; let btp_header = signed_header.header.clone().unwrap(); if self @@ -202,25 +234,6 @@ impl ILightClient for IconClient { state.latest_height = btp_header.main_height; } - let consensus_state = btp_header.to_consensus_state(); - self.context.insert_client_state(client_id, state.clone())?; - self.context.insert_consensus_state( - client_id, - btp_header.main_height, - consensus_state.clone(), - )?; - self.context - .insert_timestamp_at_height(client_id, btp_header.main_height)?; - self.context - .insert_blocknumber_at_height(client_id, btp_header.main_height)?; - let commitment = keccak256(&consensus_state.encode_to_vec()); - - Ok(ConsensusStateUpdate { - consensus_state_commitment: commitment, - client_state_commitment: keccak256(&state.encode_to_vec()), - client_state_bytes: state.encode_to_vec(), - consensus_state_bytes: consensus_state.encode_to_vec(), - height: btp_header.main_height, - }) + Ok(()) } } diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs index 65169c195..ef286239b 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs @@ -94,6 +94,13 @@ pub trait ILightClient { client_id: &str, header: SignedHeader, ) -> Result; + + fn verify_header( + &mut self, + caller: &Addr, + client_id: &str, + header: &SignedHeader, + ) -> Result<(), Self::Error>; } pub trait IQueryHandler { @@ -423,6 +430,6 @@ pub trait IContext { ) -> Result; fn ensure_owner(&self, caller: Addr) -> Result<(), ContractError>; - fn ensure_ibc_host(&self, caller: Addr) -> Result<(), ContractError>; + fn ensure_ibc_host(&self, caller: &Addr) -> Result<(), ContractError>; fn api(&self) -> &dyn Api; } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs index 9acbd0d2f..6173cf93a 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs @@ -1,6 +1,7 @@ use common::ibc::Height; use cosmwasm_std::{Api, Env, Storage}; +use crate::query_handler::QueryHandler; use cw_light_client_common::traits::IQueryHandler; use cw_light_client_common::{ constants::{PROCESSED_HEIGHTS, PROCESSED_TIMES}, @@ -152,16 +153,12 @@ impl<'a> IContext for CwContext<'a> { fn ensure_ibc_host( &self, - _caller: cosmwasm_std::Addr, + _caller: &cosmwasm_std::Addr, ) -> Result<(), cw_light_client_common::ContractError> { - unimplemented!() + Ok(()) } fn api(&self) -> &dyn Api { self.api } } - -pub struct QueryHandler; - -impl IQueryHandler for QueryHandler {} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 56b40424b..e9c255da1 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -2,11 +2,13 @@ use common::traits::AnyTypes; use cosmwasm_schema::cw_serde; use cw_common::cw_println; use cw_common::ibc_types::IbcHeight; +use cw_light_client_common::traits::IQueryHandler; #[cfg(feature = "mock")] use crate::mock_client::MockClient; +use crate::query_handler::QueryHandler; -use common::icon::icon::types::v1::SignedHeader; +use common::icon::icon::types::v1::{MerkleNode, MerkleProofs, SignedHeader}; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; @@ -64,9 +66,60 @@ fn process_message( msg: ExecuteMsg, ) -> Result { let result: Result = match msg { - ExecuteMsg::VerifyMembership(_) => todo!(), - ExecuteMsg::VerifyNonMembership(_) => todo!(), - ExecuteMsg::VerifyClientMessage(_) => todo!(), + ExecuteMsg::VerifyMembership(msg) => { + let height = msg.height.revision_height; + let client_id = "08-wasm-0"; + let proofs_decoded = + MerkleProofs::decode(msg.proof.as_slice()).map_err(ContractError::DecodeError)?; + let path = hex::decode(&msg.path.key_path.join("")).unwrap(); + + let ok = QueryHandler::verify_membership( + deps_mut.as_ref(), + client_id, + height, + msg.delay_time_period, + msg.delay_block_period, + &proofs_decoded.proofs, + &msg.value, + &path, + ) + .unwrap(); + + Ok(to_binary(&ContractResult::success()).unwrap()) + } + ExecuteMsg::VerifyNonMembership(msg) => { + let height = msg.height.revision_height; + let client_id = "08-wasm-0"; + let proofs_decoded = + MerkleProofs::decode(msg.proof.as_slice()).map_err(ContractError::DecodeError)?; + let path = hex::decode(&msg.path.key_path.join("")).unwrap(); + + let _ok = QueryHandler::verify_non_membership( + deps_mut.as_ref(), + client_id, + height, + msg.delay_time_period, + msg.delay_block_period, + &proofs_decoded.proofs, + &path, + ) + .unwrap(); + + Ok(to_binary(&ContractResult::success()).unwrap()) + } + ExecuteMsg::VerifyClientMessage(msg) => match msg.client_message { + crate::msg::ClientMessageRaw::Header(wasmheader) => { + let context = CwContext::new(deps_mut, env); + let mut client = IconClient::new(context); + let header_any = Any::decode(&*wasmheader.data).unwrap(); + let header = + SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; + let client_id = "08-wasm-0"; + let _update = client.update_client(info.sender, client_id, header)?; + Ok(to_binary(&ContractResult::success()).unwrap()) + } + crate::msg::ClientMessageRaw::Misbehaviour(_) => unimplemented!(), + }, ExecuteMsg::CheckForMisbehaviour(_) => todo!(), ExecuteMsg::UpdateStateOnMisbehaviour(_) => todo!(), ExecuteMsg::UpdateState(msg) => { From 502f07b3b74d022fd47af3afa2f8bddb46644869 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 11:15:59 +0545 Subject: [PATCH 11/64] feat: add genesis export --- .../cw-icon-light-client/src/context.rs | 2 +- .../cw-wasm-light-client/src/contract.rs | 18 +++--- .../cw-wasm-light-client/src/query_handler.rs | 56 ++++++++++++++++++- 3 files changed, 65 insertions(+), 11 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs index 3f4b3a67d..fac015d8e 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs @@ -153,7 +153,7 @@ impl<'a> IContext for CwContext<'a> { QueryHandler::get_processed_blocknumber_at_height(self.storage, client_id, height) } - fn ensure_ibc_host(&self, caller: cosmwasm_std::Addr) -> Result<(), ContractError> { + fn ensure_ibc_host(&self, caller: &cosmwasm_std::Addr) -> Result<(), ContractError> { let config = self.get_config()?; if caller != config.ibc_host { return Err(ContractError::Unauthorized {}); diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index e9c255da1..425060013 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -8,7 +8,7 @@ use cw_light_client_common::traits::IQueryHandler; use crate::mock_client::MockClient; use crate::query_handler::QueryHandler; -use common::icon::icon::types::v1::{MerkleNode, MerkleProofs, SignedHeader}; +use common::icon::icon::types::v1::{MerkleProofs, SignedHeader}; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; @@ -19,7 +19,7 @@ use cw_common::raw_types::Any; use crate::context::CwContext; use crate::light_client::IconClient; -use crate::msg::{ContractResult, ExecuteMsg, InstantiateMsg, QueryMsg}; +use crate::msg::{ContractResult, ExecuteMsg, InstantiateMsg, QueryMsg, QueryResponse}; use crate::traits::{IContext, ILightClient}; use crate::ContractError; use prost::Message; @@ -71,9 +71,9 @@ fn process_message( let client_id = "08-wasm-0"; let proofs_decoded = MerkleProofs::decode(msg.proof.as_slice()).map_err(ContractError::DecodeError)?; - let path = hex::decode(&msg.path.key_path.join("")).unwrap(); + let path = hex::decode(msg.path.key_path.join("")).unwrap(); - let ok = QueryHandler::verify_membership( + let _ok = QueryHandler::verify_membership( deps_mut.as_ref(), client_id, height, @@ -92,7 +92,7 @@ fn process_message( let client_id = "08-wasm-0"; let proofs_decoded = MerkleProofs::decode(msg.proof.as_slice()).map_err(ContractError::DecodeError)?; - let path = hex::decode(&msg.path.key_path.join("")).unwrap(); + let path = hex::decode(msg.path.key_path.join("")).unwrap(); let _ok = QueryHandler::verify_non_membership( deps_mut.as_ref(), @@ -166,11 +166,15 @@ pub fn any_from_byte(bytes: &[u8]) -> Result { } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(_deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + let client_id = "08-wasm-0"; match msg { QueryMsg::ClientTypeMsg(_) => todo!(), QueryMsg::GetLatestHeightsMsg(_) => todo!(), - QueryMsg::ExportMetadata(_) => todo!(), + QueryMsg::ExportMetadata(_) => { + let res = QueryHandler::get_genesis_metadata(deps.storage, client_id); + to_binary(&QueryResponse::genesis_metadata(Some(res))) + } QueryMsg::Status(_) => todo!(), } } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs index 0b666cb6f..86d703c06 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs @@ -1,11 +1,61 @@ use common::ibc::Height; -use cw_light_client_common::{traits::IQueryHandler, ContractError}; +use cosmwasm_std::{Order, StdResult}; +use cw_light_client_common::{constants::PROCESSED_HEIGHTS, traits::IQueryHandler, ContractError}; +use cw_storage_plus::Endian; -use crate::utils::{ - decode_client_state, decode_consensus_state, get_client_state_key, get_consensus_state_key, +use crate::{ + msg::GenesisMetadata, + utils::{ + decode_client_state, decode_consensus_state, get_client_state_key, get_consensus_state_key, + }, }; pub struct QueryHandler; + +impl QueryHandler { + pub fn processed_time_key(height: &Height, prefix: &mut Vec) -> Vec { + prefix.append(&mut "consensusStates/".to_string().into_bytes()); + prefix.append(&mut format!("{height}").into_bytes()); + prefix.append(&mut "/processedTime".to_string().into_bytes()); + prefix.clone() + } + + pub fn processed_height_key(height: &Height, prefix: &mut Vec) -> Vec { + prefix.append(&mut "consensusStates/".to_string().into_bytes()); + prefix.append(&mut format!("{height}").into_bytes()); + prefix.append(&mut "/processedHeight".to_string().into_bytes()); + prefix.clone() + } + pub fn get_genesis_metadata( + storage: &dyn cosmwasm_std::Storage, + client_id: &str, + ) -> Vec { + let heights = PROCESSED_HEIGHTS + .prefix(client_id.to_string()) + .keys(storage, None, None, Order::Ascending) + .collect::>>() + .unwrap(); + let mut gm: Vec = Vec::::new(); + for h in heights { + let processed_height = + Self::get_processed_blocknumber_at_height(storage, client_id, h).unwrap(); + let processed_time = Self::get_processed_time_at_height(storage, client_id, h).unwrap(); + let ibc_height = Height::new(0, h).unwrap(); + let processed_height_key = Self::processed_height_key(&ibc_height, &mut Vec::new()); + let processed_time_key = Self::processed_time_key(&ibc_height, &mut Vec::new()); + gm.push(GenesisMetadata { + key: processed_height_key.clone(), + value: processed_height.to_be_bytes().to_vec(), + }); + + gm.push(GenesisMetadata { + key: processed_time_key.clone(), + value: processed_time.to_be_bytes().to_vec(), + }); + } + gm + } +} impl IQueryHandler for QueryHandler { fn get_client_state( storage: &dyn cosmwasm_std::Storage, From 15fd93104d020fc37aa46560c556d2d048d1afee Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 13:12:42 +0545 Subject: [PATCH 12/64] fix: impl client status --- .../cw-wasm-light-client/src/constants.rs | 1 + .../cw-wasm-light-client/src/contract.rs | 27 ++++++++++--------- .../cw-wasm-light-client/src/lib.rs | 5 +++- .../cw-wasm-light-client/src/query_handler.rs | 24 ++++++++++++++--- 4 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs new file mode 100644 index 000000000..bf568c184 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs @@ -0,0 +1 @@ +pub const CLIENT_ID: &str= "08-wasm-0"; \ No newline at end of file diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 425060013..d7e392a9e 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -4,6 +4,7 @@ use cw_common::cw_println; use cw_common::ibc_types::IbcHeight; use cw_light_client_common::traits::IQueryHandler; +use crate::constants::CLIENT_ID; #[cfg(feature = "mock")] use crate::mock_client::MockClient; use crate::query_handler::QueryHandler; @@ -37,11 +38,11 @@ pub fn instantiate( ) -> Result { set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION) .map_err(|_e| ContractError::FailedToInitContract)?; - let client_id = "08-wasm-0"; + let mut context = CwContext::new(deps, env); - let client_state = context.get_client_state(client_id)?; - context.insert_blocknumber_at_height(client_id, client_state.latest_height)?; - context.insert_timestamp_at_height(client_id, client_state.latest_height)?; + let client_state = context.get_client_state(CLIENT_ID)?; + context.insert_blocknumber_at_height(CLIENT_ID, client_state.latest_height)?; + context.insert_timestamp_at_height(CLIENT_ID, client_state.latest_height)?; Ok(Response::default()) } @@ -68,7 +69,7 @@ fn process_message( let result: Result = match msg { ExecuteMsg::VerifyMembership(msg) => { let height = msg.height.revision_height; - let client_id = "08-wasm-0"; + let client_id = CLIENT_ID; let proofs_decoded = MerkleProofs::decode(msg.proof.as_slice()).map_err(ContractError::DecodeError)?; let path = hex::decode(msg.path.key_path.join("")).unwrap(); @@ -89,7 +90,7 @@ fn process_message( } ExecuteMsg::VerifyNonMembership(msg) => { let height = msg.height.revision_height; - let client_id = "08-wasm-0"; + let client_id = CLIENT_ID; let proofs_decoded = MerkleProofs::decode(msg.proof.as_slice()).map_err(ContractError::DecodeError)?; let path = hex::decode(msg.path.key_path.join("")).unwrap(); @@ -114,8 +115,7 @@ fn process_message( let header_any = Any::decode(&*wasmheader.data).unwrap(); let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; - let client_id = "08-wasm-0"; - let _update = client.update_client(info.sender, client_id, header)?; + let _update = client.update_client(info.sender, CLIENT_ID, header)?; Ok(to_binary(&ContractResult::success()).unwrap()) } crate::msg::ClientMessageRaw::Misbehaviour(_) => unimplemented!(), @@ -131,8 +131,7 @@ fn process_message( let header_any = Any::decode(&*wasmheader.data).unwrap(); let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; - let client_id = "08-wasm-0"; - let _update = client.update_client(info.sender, client_id, header)?; + let _update = client.update_client(info.sender, CLIENT_ID, header)?; Ok(to_binary(&ContractResult::success()).unwrap()) } crate::msg::ClientMessageRaw::Misbehaviour(_) => { @@ -167,15 +166,17 @@ pub fn any_from_byte(bytes: &[u8]) -> Result { #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - let client_id = "08-wasm-0"; + match msg { QueryMsg::ClientTypeMsg(_) => todo!(), QueryMsg::GetLatestHeightsMsg(_) => todo!(), QueryMsg::ExportMetadata(_) => { - let res = QueryHandler::get_genesis_metadata(deps.storage, client_id); + let res = QueryHandler::get_genesis_metadata(deps.storage, CLIENT_ID); to_binary(&QueryResponse::genesis_metadata(Some(res))) } - QueryMsg::Status(_) => todo!(), + QueryMsg::Status(_) => { + QueryHandler::get_client_status(deps) + }, } } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs index 0114d5a0a..69cfc6e59 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs @@ -1,6 +1,7 @@ -pub use cw_light_client_common::constants; + mod context; pub mod contract; + mod msg; pub mod query_handler; pub mod utils; @@ -12,3 +13,5 @@ pub use cw_light_client_common::error::ContractError; extern crate alloc; extern crate core; pub type Bytes = Vec; + +pub mod constants; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs index 86d703c06..2ee98b800 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs @@ -1,13 +1,14 @@ use common::ibc::Height; -use cosmwasm_std::{Order, StdResult}; + +use cosmwasm_std::{Order, StdResult, Deps, to_binary, Binary}; use cw_light_client_common::{constants::PROCESSED_HEIGHTS, traits::IQueryHandler, ContractError}; use cw_storage_plus::Endian; use crate::{ - msg::GenesisMetadata, + msg::{GenesisMetadata, QueryResponse}, utils::{ decode_client_state, decode_consensus_state, get_client_state_key, get_consensus_state_key, - }, + }, constants::CLIENT_ID, }; pub struct QueryHandler; @@ -55,6 +56,23 @@ impl QueryHandler { } gm } + + pub fn get_client_status(deps:Deps)->StdResult{ + + let client_state= QueryHandler::get_client_state(deps.storage,CLIENT_ID); + if client_state.is_err(){ + return to_binary(&QueryResponse::status("Unknown".to_string())); + } + let client_state=client_state.unwrap(); + if client_state.frozen_height>0 { + return to_binary(&QueryResponse::status("Frozen".to_string())); + } + + + to_binary(&QueryResponse::status("Active".to_string())) + + + } } impl IQueryHandler for QueryHandler { fn get_client_state( From 6728aee4aaa3df6f53fe9f4a8cbec3261be2f2c5 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 13:45:50 +0545 Subject: [PATCH 13/64] fix: fix unit test --- .../cw-light-client-common/src/light_client.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index 648b001d6..45d5a5289 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -144,9 +144,14 @@ impl ILightClient for IconClient { signed_header: SignedHeader, ) -> Result { self.verify_header(&caller, client_id, &signed_header)?; - let state = self.context.get_client_state(client_id)?; + + let mut state = self.context.get_client_state(client_id)?; let btp_header = signed_header.header.clone().unwrap(); + if state.latest_height < btp_header.main_height { + state.latest_height = btp_header.main_height; + } + let consensus_state = btp_header.to_consensus_state(); self.context.insert_client_state(client_id, state.clone())?; self.context.insert_consensus_state( @@ -230,9 +235,7 @@ impl ILightClient for IconClient { &signed_header.current_validators, )?; - if state.latest_height < btp_header.main_height { - state.latest_height = btp_header.main_height; - } + Ok(()) } From b26a30c2afc59bcae7a75984b26494ff73613b40 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 15:53:28 +0545 Subject: [PATCH 14/64] fix: add debug logs --- .../src/light_client.rs | 4 +-- .../cw-wasm-light-client/src/constants.rs | 2 +- .../cw-wasm-light-client/src/contract.rs | 34 +++++++++++++------ .../cw-wasm-light-client/src/lib.rs | 1 - .../cw-wasm-light-client/src/query_handler.rs | 21 +++++------- 5 files changed, 35 insertions(+), 27 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index 45d5a5289..fb30037a5 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -144,7 +144,7 @@ impl ILightClient for IconClient { signed_header: SignedHeader, ) -> Result { self.verify_header(&caller, client_id, &signed_header)?; - + let mut state = self.context.get_client_state(client_id)?; let btp_header = signed_header.header.clone().unwrap(); @@ -235,8 +235,6 @@ impl ILightClient for IconClient { &signed_header.current_validators, )?; - - Ok(()) } } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs index bf568c184..da4e59b54 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs @@ -1 +1 @@ -pub const CLIENT_ID: &str= "08-wasm-0"; \ No newline at end of file +pub const CLIENT_ID: &str = "08-wasm-0"; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index d7e392a9e..7ba558e81 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -38,11 +38,13 @@ pub fn instantiate( ) -> Result { set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION) .map_err(|_e| ContractError::FailedToInitContract)?; - + let mut context = CwContext::new(deps, env); + cw_println!(context.api(), "[WasmClient]: Contract Init Called"); let client_state = context.get_client_state(CLIENT_ID)?; context.insert_blocknumber_at_height(CLIENT_ID, client_state.latest_height)?; context.insert_timestamp_at_height(CLIENT_ID, client_state.latest_height)?; + cw_println!(context.api(), "[WasmClient]: Contract Init Complete"); Ok(Response::default()) } @@ -66,8 +68,14 @@ fn process_message( info: MessageInfo, msg: ExecuteMsg, ) -> Result { + cw_println!( + deps_mut.api, + "[WasmClient]: Contract Execute Called with {:?}", + msg + ); let result: Result = match msg { ExecuteMsg::VerifyMembership(msg) => { + cw_println!(deps_mut.api, "[WasmClient]: Verify Membership called"); let height = msg.height.revision_height; let client_id = CLIENT_ID; let proofs_decoded = @@ -85,10 +93,11 @@ fn process_message( &path, ) .unwrap(); - + cw_println!(deps_mut.api, "[WasmClient]: Verify Membership Complete"); Ok(to_binary(&ContractResult::success()).unwrap()) } ExecuteMsg::VerifyNonMembership(msg) => { + cw_println!(deps_mut.api, "[WasmClient]: Verify Non Membership Called"); let height = msg.height.revision_height; let client_id = CLIENT_ID; let proofs_decoded = @@ -105,12 +114,14 @@ fn process_message( &path, ) .unwrap(); - + cw_println!(deps_mut.api, "[WasmClient]: Verify Non Membership Complete"); Ok(to_binary(&ContractResult::success()).unwrap()) } ExecuteMsg::VerifyClientMessage(msg) => match msg.client_message { crate::msg::ClientMessageRaw::Header(wasmheader) => { let context = CwContext::new(deps_mut, env); + + cw_println!(context.api(), "[WasmClient]: Verify Clientmessage called"); let mut client = IconClient::new(context); let header_any = Any::decode(&*wasmheader.data).unwrap(); let header = @@ -123,15 +134,17 @@ fn process_message( ExecuteMsg::CheckForMisbehaviour(_) => todo!(), ExecuteMsg::UpdateStateOnMisbehaviour(_) => todo!(), ExecuteMsg::UpdateState(msg) => { - cw_println!(deps_mut.api, "Received Header {:?}", msg); - let context = CwContext::new(deps_mut, env); - let mut client = IconClient::new(context); + cw_println!(deps_mut.api, "Received Header {:?}", &msg); + match msg.client_message { crate::msg::ClientMessageRaw::Header(wasmheader) => { + let context = CwContext::new(deps_mut, env); + let mut client = IconClient::new(context); let header_any = Any::decode(&*wasmheader.data).unwrap(); let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; let _update = client.update_client(info.sender, CLIENT_ID, header)?; + Ok(to_binary(&ContractResult::success()).unwrap()) } crate::msg::ClientMessageRaw::Misbehaviour(_) => { @@ -166,17 +179,18 @@ pub fn any_from_byte(bytes: &[u8]) -> Result { #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { QueryMsg::ClientTypeMsg(_) => todo!(), QueryMsg::GetLatestHeightsMsg(_) => todo!(), - QueryMsg::ExportMetadata(_) => { + QueryMsg::ExportMetadata(msg) => { + cw_println!(deps.api, "Export metadata called {:?}", &msg); let res = QueryHandler::get_genesis_metadata(deps.storage, CLIENT_ID); to_binary(&QueryResponse::genesis_metadata(Some(res))) } - QueryMsg::Status(_) => { + QueryMsg::Status(msg) => { + cw_println!(deps.api, "Export metadata called {:?}", &msg); QueryHandler::get_client_status(deps) - }, + } } } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs index 69cfc6e59..68204b98c 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs @@ -1,4 +1,3 @@ - mod context; pub mod contract; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs index 2ee98b800..e514c8cd7 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs @@ -1,14 +1,15 @@ use common::ibc::Height; -use cosmwasm_std::{Order, StdResult, Deps, to_binary, Binary}; +use cosmwasm_std::{to_binary, Binary, Deps, Order, StdResult}; use cw_light_client_common::{constants::PROCESSED_HEIGHTS, traits::IQueryHandler, ContractError}; use cw_storage_plus::Endian; use crate::{ + constants::CLIENT_ID, msg::{GenesisMetadata, QueryResponse}, utils::{ decode_client_state, decode_consensus_state, get_client_state_key, get_consensus_state_key, - }, constants::CLIENT_ID, + }, }; pub struct QueryHandler; @@ -57,21 +58,17 @@ impl QueryHandler { gm } - pub fn get_client_status(deps:Deps)->StdResult{ - - let client_state= QueryHandler::get_client_state(deps.storage,CLIENT_ID); - if client_state.is_err(){ + pub fn get_client_status(deps: Deps) -> StdResult { + let client_state = QueryHandler::get_client_state(deps.storage, CLIENT_ID); + if client_state.is_err() { return to_binary(&QueryResponse::status("Unknown".to_string())); } - let client_state=client_state.unwrap(); - if client_state.frozen_height>0 { + let client_state = client_state.unwrap(); + if client_state.frozen_height > 0 { return to_binary(&QueryResponse::status("Frozen".to_string())); } - - - to_binary(&QueryResponse::status("Active".to_string())) - + to_binary(&QueryResponse::status("Active".to_string())) } } impl IQueryHandler for QueryHandler { From 16ac23124bfa0677d5c30f592d08f90f7254e978 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 17:52:40 +0545 Subject: [PATCH 15/64] fix: cleanup --- .../cw-light-client-common/src/error.rs | 3 + .../src/light_client.rs | 2 +- .../cw-wasm-light-client/src/context.rs | 5 +- .../cw-wasm-light-client/src/contract.rs | 39 +- .../src/ics08_wasm/client_message.rs | 223 -------- .../src/ics08_wasm/client_state.rs | 214 -------- .../src/ics08_wasm/consensus_state.rs | 135 ----- .../src/ics08_wasm/mod.rs | 4 - .../src/ics08_wasm/wasm.rs | 508 ------------------ .../cw-wasm-light-client/src/msg.rs | 105 +--- .../cw-wasm-light-client/src/query_handler.rs | 18 +- .../cw-wasm-light-client/src/utils.rs | 37 +- 12 files changed, 55 insertions(+), 1238 deletions(-) delete mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs delete mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs delete mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs delete mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs delete mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/wasm.rs diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/error.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/error.rs index f12ea8a82..42dd53a55 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/error.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/error.rs @@ -83,6 +83,9 @@ pub enum ContractError { #[error("Height {height:?} already updated ")] HeightAlreadyUpdated { height: u64 }, + + #[error("{error:?}")] + OtherError { error: String }, } impl From for ContractError { diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index fb30037a5..cffbd2e97 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -192,7 +192,7 @@ impl ILightClient for IconClient { }); } - let mut state = self.context.get_client_state(client_id)?; + let state = self.context.get_client_state(client_id)?; if signed_header.trusted_height > btp_header.main_height { return Err(ContractError::UpdateBlockOlderThanTrustedHeight); diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs index 6173cf93a..140769f17 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs @@ -1,4 +1,3 @@ -use common::ibc::Height; use cosmwasm_std::{Api, Env, Storage}; use crate::query_handler::QueryHandler; @@ -10,7 +9,7 @@ use cw_light_client_common::{ }; use crate::utils::{ - get_client_state_key, get_consensus_state_key, to_wasm_client_state, to_wasm_consensus_state, + get_client_state_key, get_consensus_state_key, to_wasm_client_state, to_wasm_consensus_state, to_ibc_height, }; pub struct CwContext<'a> { pub storage: &'a mut dyn Storage, @@ -70,7 +69,7 @@ impl<'a> IContext for CwContext<'a> { height: u64, consensus_state: common::icon::icon::lightclient::v1::ConsensusState, ) -> Result<(), cw_light_client_common::ContractError> { - let ibc_height = Height::new(0, height).unwrap(); + let ibc_height = to_ibc_height(height); let wasm_consensus_state = to_wasm_consensus_state(consensus_state); self.storage .set(&get_consensus_state_key(ibc_height), &wasm_consensus_state); diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 7ba558e81..17867e5de 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -1,7 +1,7 @@ use common::traits::AnyTypes; use cosmwasm_schema::cw_serde; use cw_common::cw_println; -use cw_common::ibc_types::IbcHeight; + use cw_light_client_common::traits::IQueryHandler; use crate::constants::CLIENT_ID; @@ -91,10 +91,10 @@ fn process_message( &proofs_decoded.proofs, &msg.value, &path, - ) - .unwrap(); + )?; cw_println!(deps_mut.api, "[WasmClient]: Verify Membership Complete"); - Ok(to_binary(&ContractResult::success()).unwrap()) + + to_binary(&ContractResult::success()).map_err(ContractError::Std) } ExecuteMsg::VerifyNonMembership(msg) => { cw_println!(deps_mut.api, "[WasmClient]: Verify Non Membership Called"); @@ -112,10 +112,9 @@ fn process_message( msg.delay_block_period, &proofs_decoded.proofs, &path, - ) - .unwrap(); + )?; cw_println!(deps_mut.api, "[WasmClient]: Verify Non Membership Complete"); - Ok(to_binary(&ContractResult::success()).unwrap()) + to_binary(&ContractResult::success()).map_err(ContractError::Std) } ExecuteMsg::VerifyClientMessage(msg) => match msg.client_message { crate::msg::ClientMessageRaw::Header(wasmheader) => { @@ -127,7 +126,7 @@ fn process_message( let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; let _update = client.update_client(info.sender, CLIENT_ID, header)?; - Ok(to_binary(&ContractResult::success()).unwrap()) + to_binary(&ContractResult::success()).map_err(ContractError::Std) } crate::msg::ClientMessageRaw::Misbehaviour(_) => unimplemented!(), }, @@ -145,10 +144,10 @@ fn process_message( SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; let _update = client.update_client(info.sender, CLIENT_ID, header)?; - Ok(to_binary(&ContractResult::success()).unwrap()) + to_binary(&ContractResult::success()).map_err(ContractError::Std) } crate::msg::ClientMessageRaw::Misbehaviour(_) => { - Ok(to_binary(&ContractResult::success()).unwrap()) + to_binary(&ContractResult::success()).map_err(ContractError::Std) } } } @@ -158,24 +157,10 @@ fn process_message( Ok(result.unwrap()) } -fn to_height_u64(height: &str) -> Result { - let heights = height.split('-').collect::>(); - if heights.len() != 2 { - return Err(ContractError::InvalidHeight); - } - heights[1] - .parse::() - .map_err(|_e| ContractError::InvalidHeight) -} -fn to_ibc_height(height: u64) -> Result { - IbcHeight::new(0, height).map_err(|_e| ContractError::InvalidHeight) -} -pub fn any_from_byte(bytes: &[u8]) -> Result { - let any = Any::decode(bytes).map_err(ContractError::DecodeError)?; - Ok(any) -} + + #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { @@ -185,7 +170,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { QueryMsg::ExportMetadata(msg) => { cw_println!(deps.api, "Export metadata called {:?}", &msg); let res = QueryHandler::get_genesis_metadata(deps.storage, CLIENT_ID); - to_binary(&QueryResponse::genesis_metadata(Some(res))) + to_binary(&QueryResponse::genesis_metadata(res.ok())) } QueryMsg::Status(msg) => { cw_println!(deps.api, "Export metadata called {:?}", &msg); diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs deleted file mode 100644 index 85c0d4fac..000000000 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_message.rs +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (C) 2022 ComposableFi. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[cfg(feature = "cosmwasm")] -use crate::msg::Base64; -use crate::Bytes; -use alloc::{ - boxed::Box, - string::{String, ToString}, - vec::Vec, -}; -use common::ibc::{ - core::ics02_client::{client_message::ClientMessage as IbcClientMessage}, - Height, -}; -use core::fmt::Display; -#[cfg(feature = "cosmwasm")] -use cosmwasm_schema::cw_serde; -use cosmwasm_std::StdError; -use cw_common::raw_types::Protobuf; -use ibc_proto::google::protobuf::Any; - -use crate::ics08_wasm::wasm::{ - Header as RawHeader, Misbehaviour as RawMisbehaviour, -}; - -use prost::Message; - -pub const WASM_HEADER_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.Header"; -pub const WASM_MISBEHAVIOUR_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.Misbehaviour"; -pub const WASM_CLIENT_MESSAGE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.ClientMessage"; - -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum ClientMessage { - Header(Header), - Misbehaviour(Misbehaviour), -} - -impl ClientMessage { - pub fn inner(&self) -> &AnyClientMessage { - match self { - ClientMessage::Header(h) => &h.inner, - ClientMessage::Misbehaviour(m) => &m.inner, - } - } - - pub fn into_inner(self) -> AnyClientMessage { - match self { - ClientMessage::Header(h) => *h.inner, - ClientMessage::Misbehaviour(m) => *m.inner, - } - } -} - -impl IbcClientMessage for ClientMessage -where - AnyClientMessage: IbcClientMessage, - AnyClientMessage: TryFrom, - >::Error: Display, -{ - fn encode_to_vec(&self) -> Result, StdError> { - self.encode_vec() - } -} - -impl Protobuf for ClientMessage -where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, -{ -} - -impl TryFrom for ClientMessage -where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, -{ - type Error = StdError; - - fn try_from(any: Any) -> Result { - let msg = match &*any.type_url { - WASM_HEADER_TYPE_URL => { - Self::Header(Header::decode(&*any.value).map_err(|e|StdError::GenericErr { msg:e.to_string() })?) - } - WASM_MISBEHAVIOUR_TYPE_URL => Self::Misbehaviour( - Misbehaviour::decode(&*any.value).map_err(|e|StdError::GenericErr { msg:e.to_string() })?, - ), - _ => return Err(|e|StdError::GenericErr { msg:"Malformed Data".to_string() }), // TODO: choose a better error - }; - - Ok(msg) - } -} - -impl From> for Any -where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, -{ - fn from(msg: ClientMessage) -> Self { - match msg { - ClientMessage::Header(header) => Any { - value: header.encode_vec().expect("encode header"), - type_url: WASM_HEADER_TYPE_URL.to_string(), - }, - ClientMessage::Misbehaviour(misbheaviour) => Any { - value: misbheaviour.encode_vec().expect("encode misbehaviour"), - type_url: WASM_MISBEHAVIOUR_TYPE_URL.to_string(), - }, - } - } -} - -impl Protobuf for Misbehaviour -where - AnyClientMessage: Clone, - AnyClientMessage: TryFrom, - >::Error: Display, -{ -} - -impl TryFrom for Misbehaviour -where - AnyClientMessage: TryFrom, - >::Error: Display, -{ - type Error = String; - - fn try_from(raw: RawMisbehaviour) -> Result { - let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; - let inner = AnyClientMessage::try_from(any).map_err(|e| e.to_string())?; - Ok(Self { - inner: Box::new(inner), - data: raw.data, - }) - } -} - -// impl Protobuf for Header -// where -// AnyClientMessage: Clone, -// AnyClientMessage: TryFrom, -// >::Error: Display, -// { -// } - -impl TryFrom for Header -where - AnyClientMessage: TryFrom, - >::Error: Display, -{ - type Error = String; - - fn try_from(raw: RawHeader) -> Result { - let any = Any::decode(&mut &raw.data[..]) - .map_err(|e| format!("failed to decode raw header into Any: {e}"))?; - let inner = AnyClientMessage::try_from(any) - .map_err(|e| format!("failed to decode raw header into AnyClientMessage: {e}"))?; - - let header = Self { - inner: Box::new(inner), - data: raw.data, - height: raw - .height - .ok_or_else(|| { - "failed to decode raw header into Header: missing height".to_string() - })? - .into(), - }; - Ok(header) - } -} - -#[cfg_attr(feature = "cosmwasm", cw_serde)] -#[cfg_attr(not(feature = "cosmwasm"), derive(Clone, Debug, PartialEq))] -#[derive(Eq)] -pub struct Header { - #[cfg_attr(feature = "cosmwasm", serde(skip))] - #[cfg_attr(feature = "cosmwasm", schemars(skip))] - pub inner: Box, - #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] - #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] - pub data: Bytes, - pub height: Height, -} - -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct Misbehaviour { - // #[schemars(with = "String")] - // #[serde(with = "Base64", default)] - pub inner: Box, - pub data: Bytes, -} - -impl From> for RawMisbehaviour { - fn from(value: Misbehaviour) -> Self { - RawMisbehaviour { data: value.data } - } -} - -// impl From> for RawHeader { -// fn from(value: Header) -> Self { -// RawHeader { -// data: value.data, -// height: Some(value.height.into()), -// } -// } -// } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs deleted file mode 100644 index 1d081cd4c..000000000 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/client_state.rs +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (C) 2022 ComposableFi. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[cfg(feature = "cosmwasm")] -use crate::msg::Base64; -// use crate::{client_def::WasmClient, Bytes}; -use crate::Bytes; -use alloc::{ - boxed::Box, - string::{String, ToString}, - vec::Vec, -}; -use cw_common::raw_types::Protobuf; -use core::{ - fmt::{Debug, Display}, - marker::PhantomData, - time::Duration, -}; -#[cfg(feature = "cosmwasm")] -use cosmwasm_schema::cw_serde; -use common::ibc::{ - core::{ - ics02_client::{ - // client_consensus::ConsensusState as IbcConsensusState,// client_def::ClientDef, - client_state::ClientState as IbcClientState, - }, - ics24_host::identifier::ChainId, - }, - Height, -}; -use ibc_proto::{ - google::protobuf::Any, -}; -use prost::Message; -use crate::ics08_wasm::wasm::{ClientState as RawClientState}; - -pub const WASM_CLIENT_STATE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.ClientState"; - -#[cfg_attr(feature = "cosmwasm", cw_serde)] -#[cfg_attr(not(feature = "cosmwasm"), derive(Clone, Debug, PartialEq))] -#[derive(Eq)] -pub struct ClientState { - #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] - #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] - pub data: Bytes, - #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] - #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] - pub code_id: Bytes, - pub latest_height: Height, - #[cfg_attr(feature = "cosmwasm", serde(skip))] - #[cfg_attr(feature = "cosmwasm", schemars(skip))] - pub inner: Box, - #[cfg_attr(feature = "cosmwasm", serde(skip))] - #[cfg_attr(feature = "cosmwasm", schemars(skip))] - pub _phantom: PhantomData<(AnyConsensusState, AnyClient)>, -} - -// impl IbcClientState -// for ClientState -// where -// AnyClientState: TryFrom, -// >::Error: Display, -// AnyConsensusState: IbcConsensusState + Eq, -// AnyConsensusState: TryFrom, -// >::Error: Display, -// AnyClient: ClientDef -// + Debug -// + Send -// + Sync -// + Eq, -// AnyClientState: IbcClientState + Eq, -// AnyClient::ClientMessage: TryFrom, -// >::Error: Display, -// { -// type UpgradeOptions = Box; -// type ClientDef = WasmClient; - -// fn chain_id(&self) -> ChainId { -// // self.inner.chain_id() -// self.inner.chain_id() -// } - -// fn client_def(&self) -> Self::ClientDef { -// let inner = self.inner.client_def(); -// WasmClient { -// inner: Box::new(inner), -// _phantom: Default::default(), -// } -// } - -// fn client_type(&self) -> String { -// "08-wasm".to_string() -// } - -// fn latest_height(&self) -> Height { -// self.latest_height -// } - -// fn frozen_height(&self) -> Option { -// self.inner.frozen_height() -// } - -// fn upgrade( -// self, -// upgrade_height: Height, -// upgrade_options: Self::UpgradeOptions, -// chain_id: ChainId, -// ) -> Self { -// let inner = self -// .inner -// .upgrade(upgrade_height, *upgrade_options, chain_id); -// Self { -// inner: Box::new(inner), -// ..self -// } -// } - -// fn expired(&self, elapsed: Duration) -> bool { -// self.inner.expired(elapsed) -// } - -// fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { -// self.encode_vec() -// } -// } - -// impl -// ClientState -// where -// AnyClientState: TryFrom, -// >::Error: Display, -// AnyConsensusState: IbcConsensusState + Eq, -// AnyConsensusState: TryFrom, -// >::Error: Display, -// AnyClient: ClientDef -// + Debug -// + Send -// + Sync -// + Eq, -// AnyClientState: IbcClientState + Eq, -// AnyClient::ClientMessage: TryFrom, -// >::Error: Display, -// { -// pub fn to_any(&self) -> Any { -// Any { -// type_url: WASM_CLIENT_STATE_TYPE_URL.to_string(), -// value: self -// .encode_to_vec() -// .expect("ClientState is always valid and can be encoded to Any"), -// } -// } -// } - -// impl TryFrom -// for ClientState -// where -// AnyClientState: TryFrom, -// >::Error: Display, -// { -// type Error = String; - -// fn try_from(raw: RawClientState) -> Result { -// let any = Any::decode(&mut &raw.data[..]).map_err(|e| e.to_string())?; -// let inner = AnyClientState::try_from(any).map_err(|e| e.to_string())?; -// Ok(Self { -// data: raw.data, -// code_id: raw.code_id, -// inner: Box::new(inner), -// latest_height: raw -// .latest_height -// .map(|h| Height::new(h.revision_number, h.revision_height)) -// .unwrap_or_default(), -// _phantom: Default::default(), -// }) -// } -// } - -// impl -// From> for RawClientState -// where -// AnyClientState: TryFrom, -// >::Error: Display, -// { -// fn from(client_state: ClientState) -> Self { -// Self { -// data: client_state.data, -// code_id: client_state.code_id, -// latest_height: Some(client_state.latest_height.into()), -// } -// } -// } - -// impl Protobuf -// for ClientState -// where -// AnyClientState: Clone, -// AnyClientState: TryFrom, -// >::Error: Display, -// AnyConsensusState: Clone, -// AnyClient: Clone, -// { -// } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs deleted file mode 100644 index 125fd6192..000000000 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/consensus_state.rs +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2022 ComposableFi. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[cfg(feature = "cosmwasm")] -use crate::msg::Base64; -use crate::Bytes; -use alloc::{ - boxed::Box, - string::{String, ToString}, - vec::Vec, -}; -use common::ibc::{ - core::{ - // ics02_client::client_consensus::ConsensusState as IbcConsensusState, - ics23_commitment::commitment::CommitmentRoot, - }, - // protobuf::Protobuf, - timestamp::Timestamp, -}; -use cw_common::raw_types::Protobuf; -use ibc_proto::google::protobuf::Any; -use core::{ - convert::Infallible, - fmt::{Debug, Display}, -}; -#[cfg(feature = "cosmwasm")] -use cosmwasm_schema::cw_serde; -// use ibc_proto::{ -// google::protobuf::Any, ibc::lightclients::wasm::v1::ConsensusState as RawConsensusState, -// }; -use prost::Message; -use crate::ics08_wasm::wasm::{ConsensusState as RawConsensusState}; - -pub const WASM_CONSENSUS_STATE_TYPE_URL: &str = "/ibc.lightclients.wasm.v1.ConsensusState"; - -#[cfg_attr(feature = "cosmwasm", cw_serde)] -#[cfg_attr(not(feature = "cosmwasm"), derive(Clone, Debug, PartialEq))] -#[derive(Eq)] -pub struct ConsensusState { - #[cfg_attr(feature = "cosmwasm", schemars(with = "String"))] - #[cfg_attr(feature = "cosmwasm", serde(with = "Base64", default))] - pub data: Bytes, - pub timestamp: u64, - #[cfg_attr(feature = "cosmwasm", serde(skip))] - #[cfg_attr(feature = "cosmwasm", schemars(skip))] - pub inner: Box, -} - -// impl IbcConsensusState for ConsensusState -// where -// AnyConsensusState: Clone + Debug + Send + Sync, -// AnyConsensusState: TryFrom, -// >::Error: Display, -// { -// type Error = Infallible; - -// fn root(&self) -> &CommitmentRoot { -// unimplemented!() -// } - -// fn timestamp(&self) -> Timestamp { -// Timestamp::from_nanoseconds(self.timestamp).expect("timestamp is valid") -// } - -// fn encode_to_vec(&self) -> Result, tendermint_proto::Error> { -// self.encode_vec() -// } -// } - -// impl ConsensusState -// where -// AnyConsensusState: Clone + Debug + Send + Sync, -// AnyConsensusState: TryFrom + IbcConsensusState, -// >::Error: Display, -// { -// pub fn to_any(&self) -> Any { -// Any { -// type_url: WASM_CONSENSUS_STATE_TYPE_URL.to_string(), -// value: self.encode_to_vec().expect( -// "ConsensusState is always valid and can be encoded to Any", -// ), -// } -// } -// } - -// impl TryFrom for ConsensusState -// where -// AnyConsensusState: TryFrom, -// >::Error: Display, -// { -// type Error = String; - -// fn try_from(raw: RawConsensusState) -> Result { -// let any = Any::decode(&mut &raw.data[..]) -// .map_err(|e| format!("failed to decode ConsensusState::data into Any: {e}"))?; -// let inner = AnyConsensusState::try_from(any).map_err(|e| { -// format!("failed to decode ConsensusState::data into ConsensusState: {e}") -// })?; -// Ok(Self { -// data: raw.data, -// timestamp: raw.timestamp, -// inner: Box::new(inner), -// }) -// } -// } - -impl From> for RawConsensusState { - fn from(value: ConsensusState) -> Self { - Self { - data: value.data, - timestamp: value.timestamp, - } - } -} - -// impl Protobuf for ConsensusState -// where -// AnyConsensusState: Clone, -// AnyConsensusState: TryFrom, -// >::Error: Display, -// { - -// } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs deleted file mode 100644 index 6844d55be..000000000 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod client_message; -pub mod client_state; -pub mod consensus_state; -pub mod wasm; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/wasm.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/wasm.rs deleted file mode 100644 index 64f0a0dd4..000000000 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/ics08_wasm/wasm.rs +++ /dev/null @@ -1,508 +0,0 @@ -/// Message type to push new wasm code -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct MsgPushNewWasmCode { - #[prost(string, tag = "1")] - pub signer: ::prost::alloc::string::String, - #[prost(bytes = "vec", tag = "3")] - pub code: ::prost::alloc::vec::Vec, -} -/// Response in case of successful handling -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct MsgPushNewWasmCodeResponse { - #[prost(bytes = "vec", tag = "1")] - pub code_id: ::prost::alloc::vec::Vec, -} -/// Generated client implementations. -#[cfg(feature = "client")] -pub mod msg_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::{http::Uri, *}; - /// Msg defines the ibc/wasm Msg service. - #[derive(Debug, Clone)] - pub struct MsgClient { - inner: tonic::client::Grpc, - } - impl MsgClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: std::convert::TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl MsgClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor(inner: T, interceptor: F) -> MsgClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - >>::Error: - Into + Send + Sync, - { - MsgClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// PushNewWasmCode defines a rpc handler method for PushNewWasmCode. - pub async fn push_new_wasm_code( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/ibc.lightclients.wasm.v1.Msg/PushNewWasmCode", - ); - self.inner.unary(request.into_request(), path, codec).await - } - } -} -/// Generated server implementations. -#[cfg(feature = "server")] -pub mod msg_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with MsgServer. - #[async_trait] - pub trait Msg: Send + Sync + 'static { - /// PushNewWasmCode defines a rpc handler method for PushNewWasmCode. - async fn push_new_wasm_code( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - } - /// Msg defines the ibc/wasm Msg service. - #[derive(Debug)] - pub struct MsgServer { - inner: _Inner, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - } - struct _Inner(Arc); - impl MsgServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - let inner = _Inner(inner); - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - } - } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - } - impl tonic::codegen::Service> for MsgServer - where - T: Msg, - B: Body + Send + 'static, - B::Error: Into + Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - let inner = self.inner.clone(); - match req.uri().path() { - "/ibc.lightclients.wasm.v1.Msg/PushNewWasmCode" => { - #[allow(non_camel_case_types)] - struct PushNewWasmCodeSvc(pub Arc); - impl tonic::server::UnaryService for PushNewWasmCodeSvc { - type Response = super::MsgPushNewWasmCodeResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).push_new_wasm_code(request).await }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = PushNewWasmCodeSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - }, - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), - } - } - } - impl Clone for MsgServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - } - } - } - impl Clone for _Inner { - fn clone(&self) -> Self { - Self(self.0.clone()) - } - } - impl std::fmt::Debug for _Inner { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self.0) - } - } - impl tonic::server::NamedService for MsgServer { - const NAME: &'static str = "ibc.lightclients.wasm.v1.Msg"; - } -} -/// WasmCode query -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct WasmCodeQuery { - #[prost(string, tag = "1")] - pub code_id: ::prost::alloc::string::String, -} -/// WasmCode response -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct WasmCodeResponse { - #[prost(bytes = "vec", tag = "1")] - pub code: ::prost::alloc::vec::Vec, -} -/// Generated client implementations. -#[cfg(feature = "client")] -pub mod query_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::{http::Uri, *}; - /// Query service for wasm module - #[derive(Debug, Clone)] - pub struct QueryClient { - inner: tonic::client::Grpc, - } - impl QueryClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: std::convert::TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl QueryClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> QueryClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - >>::Error: - Into + Send + Sync, - { - QueryClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Get Wasm code for given code id - pub async fn wasm_code( - &mut self, - request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/ibc.lightclients.wasm.v1.Query/WasmCode"); - self.inner.unary(request.into_request(), path, codec).await - } - } -} -/// Generated server implementations. -#[cfg(feature = "server")] -pub mod query_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with QueryServer. - #[async_trait] - pub trait Query: Send + Sync + 'static { - /// Get Wasm code for given code id - async fn wasm_code( - &self, - request: tonic::Request, - ) -> Result, tonic::Status>; - } - /// Query service for wasm module - #[derive(Debug)] - pub struct QueryServer { - inner: _Inner, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - } - struct _Inner(Arc); - impl QueryServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - let inner = _Inner(inner); - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - } - } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - } - impl tonic::codegen::Service> for QueryServer - where - T: Query, - B: Body + Send + 'static, - B::Error: Into + Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - let inner = self.inner.clone(); - match req.uri().path() { - "/ibc.lightclients.wasm.v1.Query/WasmCode" => { - #[allow(non_camel_case_types)] - struct WasmCodeSvc(pub Arc); - impl tonic::server::UnaryService for WasmCodeSvc { - type Response = super::WasmCodeResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).wasm_code(request).await }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = WasmCodeSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec).apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - }, - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), - } - } - } - impl Clone for QueryServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - } - } - } - impl Clone for _Inner { - fn clone(&self) -> Self { - Self(self.0.clone()) - } - } - impl std::fmt::Debug for _Inner { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self.0) - } - } - impl tonic::server::NamedService for QueryServer { - const NAME: &'static str = "ibc.lightclients.wasm.v1.Query"; - } -} -/// Wasm light client's Client state -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ClientState { - #[prost(bytes = "vec", tag = "1")] - pub data: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", tag = "2")] - pub code_id: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "3")] - pub latest_height: ::core::option::Option, -} -/// Wasm light client's ConsensusState -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ConsensusState { - #[prost(bytes = "vec", tag = "1")] - pub data: ::prost::alloc::vec::Vec, - /// timestamp that corresponds to the block height in which the ConsensusState - /// was stored. - #[prost(uint64, tag = "2")] - pub timestamp: u64, -} -/// Wasm light client Header -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Header { - #[prost(bytes = "vec", tag = "1")] - pub data: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "2")] - pub height: ::core::option::Option, -} -/// Wasm light client Misbehaviour -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Misbehaviour { - #[prost(bytes = "vec", tag = "1")] - pub data: ::prost::alloc::vec::Vec, -} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs index caacfc430..c7efd0e20 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -1,26 +1,4 @@ -// Copyright (C) 2022 ComposableFi. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// use crate::{contract::HostFunctions, ics23::FakeInner, Bytes, ContractError}; - use cosmwasm_schema::cw_serde; - -// use ics07_tendermint::{ -// client_message::{ClientMessage, Header, Misbehaviour}, -// client_state::ClientState, -// }; use ics07_tendermint_cw::ics23::FakeInner; use ics08_wasm::{ client_message::Header as WasmHeader, client_state::ClientState as WasmClientState, @@ -100,6 +78,7 @@ impl QueryResponse { } } + #[cw_serde] pub struct ContractResult { pub is_valid: bool, @@ -108,7 +87,7 @@ pub struct ContractResult { pub data: Option>, pub found_misbehaviour: bool, } - +#[allow(dead_code)] impl ContractResult { pub fn success() -> Self { Self { @@ -139,17 +118,6 @@ impl ContractResult { } } -// #[derive(Eq, Default)] -// #[cw_serde] -// pub struct FakeInner; - -// impl TryFrom for FakeInner { -// type Error = Infallible; - -// fn try_from(_: ibc_proto::google::protobuf::Any) -> Result { -// Ok(FakeInner) -// } -// } #[cw_serde] pub struct InstantiateMsg {} @@ -205,36 +173,7 @@ pub struct VerifyMembershipMsgRaw { pub delay_time_period: u64, } -// pub struct VerifyMembershipMsg { -// pub prefix: CommitmentPrefix, -// pub proof: CommitmentProofBytes, -// pub path: Path, -// pub value: Vec, -// pub height: Height, -// pub delay_block_period: u64, -// pub delay_time_period: u64, -// } - -// impl TryFrom for VerifyMembershipMsg { -// type Error = ContractError; - -// fn try_from(mut raw: VerifyMembershipMsgRaw) -> Result { -// let proof = CommitmentProofBytes::try_from(raw.proof)?; -// let prefix = raw.path.key_path.remove(0).into_bytes(); -// let path_str = raw.path.key_path.join(""); -// let path = Path::from_str(&path_str)?; -// let height = Height::from(raw.height); -// Ok(Self { -// proof, -// path, -// value: raw.value, -// height, -// prefix: CommitmentPrefix::try_from(prefix)?, -// delay_block_period: raw.delay_block_period, -// delay_time_period: raw.delay_time_period, -// }) -// } -// } + #[cw_serde] pub struct VerifyNonMembershipMsgRaw { @@ -247,35 +186,6 @@ pub struct VerifyNonMembershipMsgRaw { pub delay_time_period: u64, } -// pub struct VerifyNonMembershipMsg { -// pub prefix: CommitmentPrefix, -// pub proof: CommitmentProofBytes, -// pub path: Path, -// pub height: Height, -// pub delay_block_period: u64, -// pub delay_time_period: u64, -// } - -// impl TryFrom for VerifyNonMembershipMsg { -// type Error = ContractError; - -// fn try_from(mut raw: VerifyNonMembershipMsgRaw) -> Result { -// let proof = CommitmentProofBytes::try_from(raw.proof)?; -// let prefix = raw.path.key_path.remove(0).into_bytes(); -// let path_str = raw.path.key_path.join(""); -// let path = Path::from_str(&path_str)?; -// let height = Height::from(raw.height); -// Ok(Self { -// proof, -// path, -// height, -// prefix: CommitmentPrefix::try_from(prefix)?, -// delay_block_period: raw.delay_block_period, -// delay_time_period: raw.delay_time_period, -// }) -// } -// } - #[cw_serde] pub struct WasmMisbehaviour { #[schemars(with = "String")] @@ -322,11 +232,4 @@ pub struct VerifyUpgradeAndUpdateStateMsgRaw { #[schemars(with = "String")] #[serde(with = "Base64", default)] pub proof_upgrade_consensus_state: Vec, -} - -// pub struct VerifyUpgradeAndUpdateStateMsg { -// pub upgrade_client_state: WasmClientState, -// pub upgrade_consensus_state: WasmConsensusState, -// pub proof_upgrade_client: CommitmentProofBytes, -// pub proof_upgrade_consensus_state: CommitmentProofBytes, -// } +} \ No newline at end of file diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs index e514c8cd7..14e88a2cf 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs @@ -1,14 +1,14 @@ -use common::ibc::Height; + use cosmwasm_std::{to_binary, Binary, Deps, Order, StdResult}; use cw_light_client_common::{constants::PROCESSED_HEIGHTS, traits::IQueryHandler, ContractError}; -use cw_storage_plus::Endian; +use ibc::Height; use crate::{ constants::CLIENT_ID, msg::{GenesisMetadata, QueryResponse}, utils::{ - decode_client_state, decode_consensus_state, get_client_state_key, get_consensus_state_key, + decode_client_state, decode_consensus_state, get_client_state_key, get_consensus_state_key, to_ibc_height, }, }; @@ -31,7 +31,7 @@ impl QueryHandler { pub fn get_genesis_metadata( storage: &dyn cosmwasm_std::Storage, client_id: &str, - ) -> Vec { + ) -> Result,ContractError> { let heights = PROCESSED_HEIGHTS .prefix(client_id.to_string()) .keys(storage, None, None, Order::Ascending) @@ -40,9 +40,9 @@ impl QueryHandler { let mut gm: Vec = Vec::::new(); for h in heights { let processed_height = - Self::get_processed_blocknumber_at_height(storage, client_id, h).unwrap(); - let processed_time = Self::get_processed_time_at_height(storage, client_id, h).unwrap(); - let ibc_height = Height::new(0, h).unwrap(); + Self::get_processed_blocknumber_at_height(storage, client_id, h)?; + let processed_time = Self::get_processed_time_at_height(storage, client_id, h)?; + let ibc_height = to_ibc_height(h); let processed_height_key = Self::processed_height_key(&ibc_height, &mut Vec::new()); let processed_time_key = Self::processed_time_key(&ibc_height, &mut Vec::new()); gm.push(GenesisMetadata { @@ -55,7 +55,7 @@ impl QueryHandler { value: processed_time.to_be_bytes().to_vec(), }); } - gm + Ok(gm) } pub fn get_client_status(deps: Deps) -> StdResult { @@ -90,7 +90,7 @@ impl IQueryHandler for QueryHandler { client_id: &str, height: u64, ) -> Result { - let ibc_height = Height::new(0, height).unwrap(); + let ibc_height = to_ibc_height(height); let any_bytes = storage.get(&get_consensus_state_key(ibc_height)).ok_or( ContractError::ConsensusStateNotFound { height, diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs index d7c95f7c4..61e32f910 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs @@ -1,6 +1,6 @@ use common::{ consensus_state::IConsensusState, - ibc::Height, + icon::icon::lightclient::v1::{ClientState, ConsensusState}, traits::AnyTypes, }; @@ -10,6 +10,7 @@ use ics07_tendermint_cw::ics23::FakeInner; use ics08_wasm::client_state::ClientState as WasmClientState; use prost::Message; use tendermint_proto::Protobuf; +use ibc::Height; pub fn get_consensus_state_key(height: Height) -> Vec { [ "consensusStates/".to_string().into_bytes(), @@ -26,12 +27,12 @@ pub fn to_wasm_client_state( client_state: ClientState, old_wasm_state: Vec, ) -> Result, ContractError> { - use ibc::Height; - let any = Any::decode(&*old_wasm_state).unwrap(); + let any = any_from_byte(&*old_wasm_state)?; let mut wasm_client_state = - WasmClientState::::decode_vec(&any.value).unwrap(); + WasmClientState::::decode_vec(&any.value) + .map_err(|e| ContractError::OtherError { error: e.to_string() })?; wasm_client_state.data = client_state.to_any().encode_to_vec(); - wasm_client_state.latest_height = Height::new(0, client_state.latest_height); + wasm_client_state.latest_height = to_ibc_height(client_state.latest_height); let vec1 = wasm_client_state.to_any().encode_to_vec(); Ok(vec1) } @@ -46,22 +47,32 @@ pub fn to_wasm_consensus_state(consensus_state: ConsensusState) -> Vec { } pub fn decode_client_state(data: &[u8]) -> Result { - let any = Any::decode(data).unwrap(); + let any = Any::decode(data).map_err(ContractError::DecodeError)?; let wasm_state = ics08_wasm::client_state::ClientState::::decode_vec( &any.value, ) - .unwrap(); - let any = Any::decode(&*wasm_state.data).unwrap(); - let state = ClientState::from_any(any).unwrap(); + .map_err(|e| ContractError::OtherError { error: e.to_string() })?; + let any = Any::decode(&*wasm_state.data).map_err(ContractError::DecodeError)?; + let state = ClientState::from_any(any).map_err(ContractError::DecodeError)?; Ok(state) } pub fn decode_consensus_state(value: &[u8]) -> Result { - let any = Any::decode(&mut &*value).unwrap(); + let any = Any::decode(&mut &*value).map_err(ContractError::DecodeError)?; let wasm_consensus_state = - ics08_wasm::consensus_state::ConsensusState::::decode_vec(&any.value).unwrap(); - let any = Any::decode(&mut &wasm_consensus_state.data[..]).unwrap(); - let any_consensus_state = ConsensusState::from_any(any).unwrap(); + ics08_wasm::consensus_state::ConsensusState::::decode_vec(&any.value) + .map_err(|e| ContractError::OtherError { error: e.to_string() })?; + let any = Any::decode(&mut &wasm_consensus_state.data[..]).map_err(ContractError::DecodeError)?; + let any_consensus_state = ConsensusState::from_any(any).map_err(ContractError::DecodeError)?; Ok(any_consensus_state) } + +pub fn to_ibc_height(height: u64) -> Height{ + Height::new(0, height) +} + +pub fn any_from_byte(bytes: &[u8]) -> Result { + let any = Any::decode(bytes).map_err(ContractError::DecodeError)?; + Ok(any) +} From 62a9828d342f95ae717e3db1e39038a30f7826a1 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 17:54:32 +0545 Subject: [PATCH 16/64] chore: pass build --- .../cw-wasm-light-client/src/context.rs | 3 +- .../cw-wasm-light-client/src/contract.rs | 7 +---- .../cw-wasm-light-client/src/msg.rs | 6 +--- .../cw-wasm-light-client/src/query_handler.rs | 7 ++--- .../cw-wasm-light-client/src/utils.rs | 30 ++++++++++++------- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs index 140769f17..09e5a3d0c 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/context.rs @@ -9,7 +9,8 @@ use cw_light_client_common::{ }; use crate::utils::{ - get_client_state_key, get_consensus_state_key, to_wasm_client_state, to_wasm_consensus_state, to_ibc_height, + get_client_state_key, get_consensus_state_key, to_ibc_height, to_wasm_client_state, + to_wasm_consensus_state, }; pub struct CwContext<'a> { pub storage: &'a mut dyn Storage, diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 17867e5de..b0ac5ae02 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -93,7 +93,7 @@ fn process_message( &path, )?; cw_println!(deps_mut.api, "[WasmClient]: Verify Membership Complete"); - + to_binary(&ContractResult::success()).map_err(ContractError::Std) } ExecuteMsg::VerifyNonMembership(msg) => { @@ -157,11 +157,6 @@ fn process_message( Ok(result.unwrap()) } - - - - - #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs index c7efd0e20..e6157bfe6 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -78,7 +78,6 @@ impl QueryResponse { } } - #[cw_serde] pub struct ContractResult { pub is_valid: bool, @@ -118,7 +117,6 @@ impl ContractResult { } } - #[cw_serde] pub struct InstantiateMsg {} @@ -173,8 +171,6 @@ pub struct VerifyMembershipMsgRaw { pub delay_time_period: u64, } - - #[cw_serde] pub struct VerifyNonMembershipMsgRaw { #[schemars(with = "String")] @@ -232,4 +228,4 @@ pub struct VerifyUpgradeAndUpdateStateMsgRaw { #[schemars(with = "String")] #[serde(with = "Base64", default)] pub proof_upgrade_consensus_state: Vec, -} \ No newline at end of file +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs index 14e88a2cf..438780465 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/query_handler.rs @@ -1,5 +1,3 @@ - - use cosmwasm_std::{to_binary, Binary, Deps, Order, StdResult}; use cw_light_client_common::{constants::PROCESSED_HEIGHTS, traits::IQueryHandler, ContractError}; use ibc::Height; @@ -8,7 +6,8 @@ use crate::{ constants::CLIENT_ID, msg::{GenesisMetadata, QueryResponse}, utils::{ - decode_client_state, decode_consensus_state, get_client_state_key, get_consensus_state_key, to_ibc_height, + decode_client_state, decode_consensus_state, get_client_state_key, get_consensus_state_key, + to_ibc_height, }, }; @@ -31,7 +30,7 @@ impl QueryHandler { pub fn get_genesis_metadata( storage: &dyn cosmwasm_std::Storage, client_id: &str, - ) -> Result,ContractError> { + ) -> Result, ContractError> { let heights = PROCESSED_HEIGHTS .prefix(client_id.to_string()) .keys(storage, None, None, Order::Ascending) diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs index 61e32f910..a530e1530 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs @@ -1,16 +1,15 @@ use common::{ consensus_state::IConsensusState, - icon::icon::lightclient::v1::{ClientState, ConsensusState}, traits::AnyTypes, }; use cw_common::raw_types::Any; use cw_light_client_common::ContractError; +use ibc::Height; use ics07_tendermint_cw::ics23::FakeInner; use ics08_wasm::client_state::ClientState as WasmClientState; use prost::Message; use tendermint_proto::Protobuf; -use ibc::Height; pub fn get_consensus_state_key(height: Height) -> Vec { [ "consensusStates/".to_string().into_bytes(), @@ -27,10 +26,13 @@ pub fn to_wasm_client_state( client_state: ClientState, old_wasm_state: Vec, ) -> Result, ContractError> { - let any = any_from_byte(&*old_wasm_state)?; - let mut wasm_client_state = - WasmClientState::::decode_vec(&any.value) - .map_err(|e| ContractError::OtherError { error: e.to_string() })?; + let any = any_from_byte(&old_wasm_state)?; + let mut wasm_client_state = WasmClientState::::decode_vec( + &any.value, + ) + .map_err(|e| ContractError::OtherError { + error: e.to_string(), + })?; wasm_client_state.data = client_state.to_any().encode_to_vec(); wasm_client_state.latest_height = to_ibc_height(client_state.latest_height); let vec1 = wasm_client_state.to_any().encode_to_vec(); @@ -52,7 +54,9 @@ pub fn decode_client_state(data: &[u8]) -> Result { ics08_wasm::client_state::ClientState::::decode_vec( &any.value, ) - .map_err(|e| ContractError::OtherError { error: e.to_string() })?; + .map_err(|e| ContractError::OtherError { + error: e.to_string(), + })?; let any = Any::decode(&*wasm_state.data).map_err(ContractError::DecodeError)?; let state = ClientState::from_any(any).map_err(ContractError::DecodeError)?; Ok(state) @@ -61,14 +65,18 @@ pub fn decode_client_state(data: &[u8]) -> Result { pub fn decode_consensus_state(value: &[u8]) -> Result { let any = Any::decode(&mut &*value).map_err(ContractError::DecodeError)?; let wasm_consensus_state = - ics08_wasm::consensus_state::ConsensusState::::decode_vec(&any.value) - .map_err(|e| ContractError::OtherError { error: e.to_string() })?; - let any = Any::decode(&mut &wasm_consensus_state.data[..]).map_err(ContractError::DecodeError)?; + ics08_wasm::consensus_state::ConsensusState::::decode_vec(&any.value).map_err( + |e| ContractError::OtherError { + error: e.to_string(), + }, + )?; + let any = + Any::decode(&mut &wasm_consensus_state.data[..]).map_err(ContractError::DecodeError)?; let any_consensus_state = ConsensusState::from_any(any).map_err(ContractError::DecodeError)?; Ok(any_consensus_state) } -pub fn to_ibc_height(height: u64) -> Height{ +pub fn to_ibc_height(height: u64) -> Height { Height::new(0, height) } From 4fd580e3d4abedab5a7461d6406e0b229b7bf048 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 17:59:39 +0545 Subject: [PATCH 17/64] fix: proto changes --- .../src/icon/icon.lightclient.v1.wasm.rs | 191 ------- .../icon/icon.lightclient.v1.wasm.serde.rs | 502 ------------------ .../src/icon/icon.lightclient.wasm.v1.rs | 189 ------- .../icon/icon.lightclient.wasm.v1.serde.rs | 502 ------------------ libraries/rust/common/src/icon/mod.rs | 6 - proto/buf.gen.rust.yaml | 4 +- proto/icon/lightclient/v1/wasm.proto | 50 -- 7 files changed, 3 insertions(+), 1441 deletions(-) delete mode 100644 libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs delete mode 100644 libraries/rust/common/src/icon/icon.lightclient.v1.wasm.serde.rs delete mode 100644 libraries/rust/common/src/icon/icon.lightclient.wasm.v1.rs delete mode 100644 libraries/rust/common/src/icon/icon.lightclient.wasm.v1.serde.rs delete mode 100644 proto/icon/lightclient/v1/wasm.proto diff --git a/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs b/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs deleted file mode 100644 index b94d3488e..000000000 --- a/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.rs +++ /dev/null @@ -1,191 +0,0 @@ -// @generated -/// Wasm light client's Client state -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ClientState { - #[prost(bytes="vec", tag="1")] - pub data: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", tag="2")] - pub code_id: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="3")] - pub latest_height: ::core::option::Option, -} -/// Wasm light client's ConsensusState -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ConsensusState { - #[prost(bytes="vec", tag="1")] - pub data: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", tag="2")] - pub code_id: ::prost::alloc::vec::Vec, - /// timestamp that corresponds to the block height in which the ConsensusState - /// was stored. - #[prost(uint64, tag="3")] - pub timestamp: u64, - /// commitment root - #[prost(message, optional, tag="4")] - pub root: ::core::option::Option, -} -/// Wasm light client Header -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Header { - #[prost(bytes="vec", tag="1")] - pub data: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="2")] - pub height: ::core::option::Option, -} -/// Wasm light client Misbehaviour -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Misbehaviour { - #[prost(string, tag="1")] - pub client_id: ::prost::alloc::string::String, - #[prost(bytes="vec", tag="2")] - pub data: ::prost::alloc::vec::Vec, -} -/// Encoded file descriptor set for the `icon.lightclient.v1.wasm` package -pub const FILE_DESCRIPTOR_SET: &[u8] = &[ - 0x0a, 0xba, 0x11, 0x0a, 0x1e, 0x69, 0x63, 0x6f, 0x6e, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x1a, 0x14, 0x67, - 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x30, 0x32, 0x2d, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x2f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x23, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x32, 0x33, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0xa3, 0x01, 0x0a, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x61, 0x0a, - 0x0d, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, - 0x69, 0x67, 0x68, 0x74, 0x42, 0x1c, 0xc8, 0xde, 0x1f, 0x00, 0xf2, 0xde, 0x1f, 0x14, 0x79, 0x61, - 0x6d, 0x6c, 0x3a, 0x22, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, - 0x74, 0x22, 0x52, 0x0c, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x9d, 0x01, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x73, 0x65, - 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, - 0x07, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, - 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3a, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x2e, - 0x4d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, 0x04, 0x72, 0x6f, 0x6f, 0x74, - 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x71, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x65, - 0x69, 0x67, 0x68, 0x74, 0x42, 0x15, 0xc8, 0xde, 0x1f, 0x00, 0xf2, 0xde, 0x1f, 0x0d, 0x79, 0x61, - 0x6d, 0x6c, 0x3a, 0x22, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x52, 0x06, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x5b, 0x0a, 0x0c, 0x4d, 0x69, 0x73, - 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x12, 0x31, 0x0a, 0x09, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x14, 0xf2, 0xde, - 0x1f, 0x10, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, - 0x64, 0x22, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xed, 0x01, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x69, - 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, - 0x76, 0x31, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x42, 0x09, 0x57, 0x61, 0x73, 0x6d, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x69, 0x62, 0x63, 0x2d, 0x67, 0x6f, 0x2f, 0x76, - 0x37, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2d, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x30, 0x38, 0x2d, 0x77, 0x61, 0x73, 0x6d, 0x3b, - 0x77, 0x61, 0x73, 0x6d, 0xa2, 0x02, 0x04, 0x49, 0x4c, 0x56, 0x57, 0xaa, 0x02, 0x18, 0x49, 0x63, - 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x56, - 0x31, 0x2e, 0x57, 0x61, 0x73, 0x6d, 0xca, 0x02, 0x18, 0x49, 0x63, 0x6f, 0x6e, 0x5c, 0x4c, 0x69, - 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x57, 0x61, 0x73, - 0x6d, 0xe2, 0x02, 0x24, 0x49, 0x63, 0x6f, 0x6e, 0x5c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, 0x47, 0x50, 0x42, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1b, 0x49, 0x63, 0x6f, 0x6e, 0x3a, - 0x3a, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3a, 0x3a, 0x56, 0x31, - 0x3a, 0x3a, 0x57, 0x61, 0x73, 0x6d, 0x4a, 0xfc, 0x09, 0x0a, 0x06, 0x12, 0x04, 0x01, 0x00, 0x2f, - 0x01, 0x0a, 0x08, 0x0a, 0x01, 0x0c, 0x12, 0x03, 0x01, 0x00, 0x12, 0x0a, 0x08, 0x0a, 0x01, 0x02, - 0x12, 0x03, 0x02, 0x00, 0x21, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x00, 0x12, 0x03, 0x04, 0x00, 0x1e, - 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x01, 0x12, 0x03, 0x05, 0x00, 0x25, 0x0a, 0x09, 0x0a, 0x02, 0x03, - 0x02, 0x12, 0x03, 0x06, 0x00, 0x2d, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x03, 0x12, 0x03, 0x07, 0x00, - 0x23, 0x0a, 0x08, 0x0a, 0x01, 0x08, 0x12, 0x03, 0x09, 0x00, 0x55, 0x0a, 0x09, 0x0a, 0x02, 0x08, - 0x0b, 0x12, 0x03, 0x09, 0x00, 0x55, 0x0a, 0x2e, 0x0a, 0x02, 0x04, 0x00, 0x12, 0x04, 0x0c, 0x00, - 0x12, 0x01, 0x1a, 0x22, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x27, 0x73, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x00, 0x01, 0x12, 0x03, 0x0c, - 0x08, 0x13, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x00, 0x07, 0x12, 0x03, 0x0d, 0x02, 0x32, 0x0a, 0x0d, - 0x0a, 0x06, 0x04, 0x00, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x0d, 0x02, 0x32, 0x0a, 0x0b, 0x0a, - 0x04, 0x04, 0x00, 0x02, 0x00, 0x12, 0x03, 0x0e, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, - 0x02, 0x00, 0x05, 0x12, 0x03, 0x0e, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, - 0x01, 0x12, 0x03, 0x0e, 0x1c, 0x20, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x03, 0x12, - 0x03, 0x0e, 0x2c, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x01, 0x12, 0x03, 0x0f, 0x02, - 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x05, 0x12, 0x03, 0x0f, 0x02, 0x07, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x01, 0x12, 0x03, 0x0f, 0x1c, 0x23, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x00, 0x02, 0x01, 0x03, 0x12, 0x03, 0x0f, 0x2c, 0x2d, 0x0a, 0x0c, 0x0a, 0x04, 0x04, - 0x00, 0x02, 0x02, 0x12, 0x04, 0x10, 0x02, 0x11, 0x56, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, - 0x02, 0x06, 0x12, 0x03, 0x10, 0x02, 0x1f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x01, - 0x12, 0x03, 0x10, 0x20, 0x2d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x03, 0x12, 0x03, - 0x10, 0x30, 0x31, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x08, 0x12, 0x03, 0x11, 0x06, - 0x55, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x00, 0x02, 0x02, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x11, - 0x07, 0x23, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x00, 0x02, 0x02, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, - 0x11, 0x25, 0x54, 0x0a, 0x30, 0x0a, 0x02, 0x04, 0x01, 0x12, 0x04, 0x15, 0x00, 0x1f, 0x01, 0x1a, - 0x24, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x27, 0x73, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x01, 0x01, 0x12, 0x03, 0x15, 0x08, - 0x16, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x01, 0x07, 0x12, 0x03, 0x16, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, - 0x06, 0x04, 0x01, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x16, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, - 0x04, 0x01, 0x02, 0x00, 0x12, 0x03, 0x17, 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, - 0x00, 0x05, 0x12, 0x03, 0x17, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x01, - 0x12, 0x03, 0x17, 0x08, 0x0c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x03, 0x12, 0x03, - 0x17, 0x27, 0x28, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x01, 0x12, 0x03, 0x18, 0x02, 0x29, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x05, 0x12, 0x03, 0x18, 0x02, 0x07, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x01, 0x12, 0x03, 0x18, 0x08, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x01, 0x02, 0x01, 0x03, 0x12, 0x03, 0x18, 0x27, 0x28, 0x0a, 0x66, 0x0a, 0x04, 0x04, 0x01, - 0x02, 0x02, 0x12, 0x03, 0x1c, 0x02, 0x17, 0x1a, 0x59, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x69, 0x6e, 0x20, 0x77, 0x68, 0x69, 0x63, - 0x68, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x77, 0x61, 0x73, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, - 0x2e, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, 0x05, 0x12, 0x03, 0x1c, 0x02, 0x08, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, 0x01, 0x12, 0x03, 0x1c, 0x09, 0x12, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, 0x03, 0x12, 0x03, 0x1c, 0x15, 0x16, 0x0a, 0x1e, 0x0a, 0x04, - 0x04, 0x01, 0x02, 0x03, 0x12, 0x03, 0x1e, 0x02, 0x31, 0x1a, 0x11, 0x20, 0x63, 0x6f, 0x6d, 0x6d, - 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x01, 0x02, 0x03, 0x06, 0x12, 0x03, 0x1e, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, - 0x02, 0x03, 0x01, 0x12, 0x03, 0x1e, 0x28, 0x2c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, - 0x03, 0x12, 0x03, 0x1e, 0x2f, 0x30, 0x0a, 0x26, 0x0a, 0x02, 0x04, 0x02, 0x12, 0x04, 0x22, 0x00, - 0x27, 0x01, 0x1a, 0x1a, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x0a, 0x0a, 0x0a, - 0x0a, 0x03, 0x04, 0x02, 0x01, 0x12, 0x03, 0x22, 0x08, 0x0e, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, - 0x07, 0x12, 0x03, 0x23, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x02, 0x07, 0x81, 0xf4, 0x03, - 0x12, 0x03, 0x23, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x00, 0x12, 0x03, 0x25, - 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x05, 0x12, 0x03, 0x25, 0x02, 0x07, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x01, 0x12, 0x03, 0x25, 0x1c, 0x20, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x03, 0x12, 0x03, 0x25, 0x25, 0x26, 0x0a, 0x0b, 0x0a, 0x04, - 0x04, 0x02, 0x02, 0x01, 0x12, 0x03, 0x26, 0x02, 0x74, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, - 0x01, 0x06, 0x12, 0x03, 0x26, 0x02, 0x1f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x01, - 0x12, 0x03, 0x26, 0x20, 0x26, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x03, 0x12, 0x03, - 0x26, 0x29, 0x2a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x08, 0x12, 0x03, 0x26, 0x2b, - 0x73, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x02, 0x02, 0x01, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x26, - 0x2c, 0x48, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x02, 0x02, 0x01, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, - 0x26, 0x4a, 0x72, 0x0a, 0x2c, 0x0a, 0x02, 0x04, 0x03, 0x12, 0x04, 0x2a, 0x00, 0x2f, 0x01, 0x1a, - 0x20, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x20, 0x4d, 0x69, 0x73, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, - 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, 0x01, 0x12, 0x03, 0x2a, 0x08, 0x14, 0x0a, 0x0a, 0x0a, - 0x03, 0x04, 0x03, 0x07, 0x12, 0x03, 0x2b, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x03, 0x07, - 0x81, 0xf4, 0x03, 0x12, 0x03, 0x2b, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x00, - 0x12, 0x03, 0x2d, 0x02, 0x45, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x05, 0x12, 0x03, - 0x2d, 0x02, 0x08, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x01, 0x12, 0x03, 0x2d, 0x09, - 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x03, 0x12, 0x03, 0x2d, 0x15, 0x16, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x08, 0x12, 0x03, 0x2d, 0x17, 0x44, 0x0a, 0x0f, 0x0a, - 0x08, 0x04, 0x03, 0x02, 0x00, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x2d, 0x18, 0x43, 0x0a, 0x0b, - 0x0a, 0x04, 0x04, 0x03, 0x02, 0x01, 0x12, 0x03, 0x2e, 0x02, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x03, 0x02, 0x01, 0x05, 0x12, 0x03, 0x2e, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, - 0x01, 0x01, 0x12, 0x03, 0x2e, 0x09, 0x0d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x03, - 0x12, 0x03, 0x2e, 0x15, 0x16, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -]; -include!("icon.lightclient.v1.wasm.serde.rs"); -// @@protoc_insertion_point(module) \ No newline at end of file diff --git a/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.serde.rs b/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.serde.rs deleted file mode 100644 index ff2adaf0c..000000000 --- a/libraries/rust/common/src/icon/icon.lightclient.v1.wasm.serde.rs +++ /dev/null @@ -1,502 +0,0 @@ -// @generated -impl serde::Serialize for ClientState { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.data.is_empty() { - len += 1; - } - if !self.code_id.is_empty() { - len += 1; - } - if self.latest_height.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("icon.lightclient.v1.wasm.ClientState", len)?; - if !self.data.is_empty() { - struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; - } - if !self.code_id.is_empty() { - struct_ser.serialize_field("code_id", pbjson::private::base64::encode(&self.code_id).as_str())?; - } - if let Some(v) = self.latest_height.as_ref() { - struct_ser.serialize_field("latest_height", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ClientState { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "data", - "code_id", - "codeId", - "latest_height", - "latestHeight", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Data, - CodeId, - LatestHeight, - } - impl<'de> serde::Deserialize<'de> for GeneratedField { - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = GeneratedField; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(formatter, "expected one of: {:?}", &FIELDS) - } - - #[allow(unused_variables)] - fn visit_str(self, value: &str) -> std::result::Result - where - E: serde::de::Error, - { - match value { - "data" => Ok(GeneratedField::Data), - "codeId" | "code_id" => Ok(GeneratedField::CodeId), - "latestHeight" | "latest_height" => Ok(GeneratedField::LatestHeight), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ClientState; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct icon.lightclient.v1.wasm.ClientState") - } - - fn visit_map(self, mut map: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut data__ = None; - let mut code_id__ = None; - let mut latest_height__ = None; - while let Some(k) = map.next_key()? { - match k { - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::CodeId => { - if code_id__.is_some() { - return Err(serde::de::Error::duplicate_field("codeId")); - } - code_id__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::LatestHeight => { - if latest_height__.is_some() { - return Err(serde::de::Error::duplicate_field("latestHeight")); - } - latest_height__ = map.next_value()?; - } - } - } - Ok(ClientState { - data: data__.unwrap_or_default(), - code_id: code_id__.unwrap_or_default(), - latest_height: latest_height__, - }) - } - } - deserializer.deserialize_struct("icon.lightclient.v1.wasm.ClientState", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ConsensusState { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.data.is_empty() { - len += 1; - } - if !self.code_id.is_empty() { - len += 1; - } - if self.timestamp != 0 { - len += 1; - } - if self.root.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("icon.lightclient.v1.wasm.ConsensusState", len)?; - if !self.data.is_empty() { - struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; - } - if !self.code_id.is_empty() { - struct_ser.serialize_field("code_id", pbjson::private::base64::encode(&self.code_id).as_str())?; - } - if self.timestamp != 0 { - struct_ser.serialize_field("timestamp", ToString::to_string(&self.timestamp).as_str())?; - } - if let Some(v) = self.root.as_ref() { - struct_ser.serialize_field("root", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ConsensusState { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "data", - "code_id", - "codeId", - "timestamp", - "root", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Data, - CodeId, - Timestamp, - Root, - } - impl<'de> serde::Deserialize<'de> for GeneratedField { - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = GeneratedField; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(formatter, "expected one of: {:?}", &FIELDS) - } - - #[allow(unused_variables)] - fn visit_str(self, value: &str) -> std::result::Result - where - E: serde::de::Error, - { - match value { - "data" => Ok(GeneratedField::Data), - "codeId" | "code_id" => Ok(GeneratedField::CodeId), - "timestamp" => Ok(GeneratedField::Timestamp), - "root" => Ok(GeneratedField::Root), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ConsensusState; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct icon.lightclient.v1.wasm.ConsensusState") - } - - fn visit_map(self, mut map: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut data__ = None; - let mut code_id__ = None; - let mut timestamp__ = None; - let mut root__ = None; - while let Some(k) = map.next_key()? { - match k { - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::CodeId => { - if code_id__.is_some() { - return Err(serde::de::Error::duplicate_field("codeId")); - } - code_id__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Timestamp => { - if timestamp__.is_some() { - return Err(serde::de::Error::duplicate_field("timestamp")); - } - timestamp__ = - Some(map.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Root => { - if root__.is_some() { - return Err(serde::de::Error::duplicate_field("root")); - } - root__ = map.next_value()?; - } - } - } - Ok(ConsensusState { - data: data__.unwrap_or_default(), - code_id: code_id__.unwrap_or_default(), - timestamp: timestamp__.unwrap_or_default(), - root: root__, - }) - } - } - deserializer.deserialize_struct("icon.lightclient.v1.wasm.ConsensusState", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Header { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.data.is_empty() { - len += 1; - } - if self.height.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("icon.lightclient.v1.wasm.Header", len)?; - if !self.data.is_empty() { - struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; - } - if let Some(v) = self.height.as_ref() { - struct_ser.serialize_field("height", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Header { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "data", - "height", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Data, - Height, - } - impl<'de> serde::Deserialize<'de> for GeneratedField { - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = GeneratedField; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(formatter, "expected one of: {:?}", &FIELDS) - } - - #[allow(unused_variables)] - fn visit_str(self, value: &str) -> std::result::Result - where - E: serde::de::Error, - { - match value { - "data" => Ok(GeneratedField::Data), - "height" => Ok(GeneratedField::Height), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Header; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct icon.lightclient.v1.wasm.Header") - } - - fn visit_map(self, mut map: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut data__ = None; - let mut height__ = None; - while let Some(k) = map.next_key()? { - match k { - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Height => { - if height__.is_some() { - return Err(serde::de::Error::duplicate_field("height")); - } - height__ = map.next_value()?; - } - } - } - Ok(Header { - data: data__.unwrap_or_default(), - height: height__, - }) - } - } - deserializer.deserialize_struct("icon.lightclient.v1.wasm.Header", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Misbehaviour { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.client_id.is_empty() { - len += 1; - } - if !self.data.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("icon.lightclient.v1.wasm.Misbehaviour", len)?; - if !self.client_id.is_empty() { - struct_ser.serialize_field("client_id", &self.client_id)?; - } - if !self.data.is_empty() { - struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Misbehaviour { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "client_id", - "clientId", - "data", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ClientId, - Data, - } - impl<'de> serde::Deserialize<'de> for GeneratedField { - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = GeneratedField; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(formatter, "expected one of: {:?}", &FIELDS) - } - - #[allow(unused_variables)] - fn visit_str(self, value: &str) -> std::result::Result - where - E: serde::de::Error, - { - match value { - "clientId" | "client_id" => Ok(GeneratedField::ClientId), - "data" => Ok(GeneratedField::Data), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Misbehaviour; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct icon.lightclient.v1.wasm.Misbehaviour") - } - - fn visit_map(self, mut map: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut client_id__ = None; - let mut data__ = None; - while let Some(k) = map.next_key()? { - match k { - GeneratedField::ClientId => { - if client_id__.is_some() { - return Err(serde::de::Error::duplicate_field("clientId")); - } - client_id__ = Some(map.next_value()?); - } - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - } - } - Ok(Misbehaviour { - client_id: client_id__.unwrap_or_default(), - data: data__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("icon.lightclient.v1.wasm.Misbehaviour", FIELDS, GeneratedVisitor) - } -} diff --git a/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.rs b/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.rs deleted file mode 100644 index f45550ddf..000000000 --- a/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.rs +++ /dev/null @@ -1,189 +0,0 @@ -// @generated -/// Wasm light client's Client state -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ClientState { - #[prost(bytes="vec", tag="1")] - pub data: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", tag="2")] - pub code_id: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="3")] - pub latest_height: ::core::option::Option, -} -/// Wasm light client's ConsensusState -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ConsensusState { - #[prost(bytes="vec", tag="1")] - pub data: ::prost::alloc::vec::Vec, - #[prost(bytes="vec", tag="2")] - pub code_id: ::prost::alloc::vec::Vec, - /// timestamp that corresponds to the block height in which the ConsensusState - /// was stored. - #[prost(uint64, tag="3")] - pub timestamp: u64, - /// commitment root - #[prost(message, optional, tag="4")] - pub root: ::core::option::Option, -} -/// Wasm light client Header -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Header { - #[prost(bytes="vec", tag="1")] - pub data: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag="2")] - pub height: ::core::option::Option, -} -/// Wasm light client Misbehaviour -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Misbehaviour { - #[prost(string, tag="1")] - pub client_id: ::prost::alloc::string::String, - #[prost(bytes="vec", tag="2")] - pub data: ::prost::alloc::vec::Vec, -} -/// Encoded file descriptor set for the `icon.lightclient.wasm.v1` package -pub const FILE_DESCRIPTOR_SET: &[u8] = &[ - 0x0a, 0x93, 0x11, 0x0a, 0x1e, 0x69, 0x63, 0x6f, 0x6e, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x76, 0x31, 0x1a, 0x14, 0x67, - 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x30, 0x32, 0x2d, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x2f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x23, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x32, 0x33, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x01, 0x0a, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, - 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, - 0x49, 0x64, 0x12, 0x61, 0x0a, 0x0d, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x1c, 0xc8, 0xde, 0x1f, 0x00, 0xf2, - 0xde, 0x1f, 0x14, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, - 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x52, 0x0c, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x48, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x9d, 0x01, 0x0a, 0x0e, - 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x12, 0x17, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3a, 0x0a, 0x04, 0x72, 0x6f, 0x6f, - 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x52, - 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x71, 0x0a, 0x06, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x63, 0x6f, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x2e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x42, 0x15, 0xc8, 0xde, 0x1f, 0x00, 0xf2, - 0xde, 0x1f, 0x0d, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, - 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x5b, - 0x0a, 0x0c, 0x4d, 0x69, 0x73, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x12, 0x31, - 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x14, 0xf2, 0xde, 0x1f, 0x10, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x22, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xec, 0x01, 0x0a, 0x1c, - 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x57, 0x61, - 0x73, 0x6d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x69, 0x62, 0x63, - 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x35, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x2f, 0x6c, - 0x69, 0x67, 0x68, 0x74, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x30, 0x38, 0x2d, - 0x77, 0x61, 0x73, 0x6d, 0x3b, 0x77, 0x61, 0x73, 0x6d, 0xa2, 0x02, 0x03, 0x49, 0x4c, 0x57, 0xaa, - 0x02, 0x18, 0x49, 0x63, 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x2e, 0x57, 0x61, 0x73, 0x6d, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x18, 0x49, 0x63, 0x6f, - 0x6e, 0x5c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x57, 0x61, - 0x73, 0x6d, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x24, 0x49, 0x63, 0x6f, 0x6e, 0x5c, 0x4c, 0x69, 0x67, - 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, 0x56, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1b, 0x49, - 0x63, 0x6f, 0x6e, 0x3a, 0x3a, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x3a, 0x3a, 0x57, 0x61, 0x73, 0x6d, 0x3a, 0x3a, 0x56, 0x31, 0x4a, 0xf1, 0x09, 0x0a, 0x06, 0x12, - 0x04, 0x01, 0x00, 0x2e, 0x01, 0x0a, 0x08, 0x0a, 0x01, 0x0c, 0x12, 0x03, 0x01, 0x00, 0x12, 0x0a, - 0x08, 0x0a, 0x01, 0x02, 0x12, 0x03, 0x02, 0x00, 0x21, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x00, 0x12, - 0x03, 0x04, 0x00, 0x1e, 0x0a, 0x09, 0x0a, 0x02, 0x03, 0x01, 0x12, 0x03, 0x05, 0x00, 0x25, 0x0a, - 0x09, 0x0a, 0x02, 0x03, 0x02, 0x12, 0x03, 0x06, 0x00, 0x2d, 0x0a, 0x08, 0x0a, 0x01, 0x08, 0x12, - 0x03, 0x08, 0x00, 0x55, 0x0a, 0x09, 0x0a, 0x02, 0x08, 0x0b, 0x12, 0x03, 0x08, 0x00, 0x55, 0x0a, - 0x2e, 0x0a, 0x02, 0x04, 0x00, 0x12, 0x04, 0x0b, 0x00, 0x11, 0x01, 0x1a, 0x22, 0x20, 0x57, 0x61, - 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x27, - 0x73, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, - 0x0a, 0x0a, 0x03, 0x04, 0x00, 0x01, 0x12, 0x03, 0x0b, 0x08, 0x13, 0x0a, 0x0a, 0x0a, 0x03, 0x04, - 0x00, 0x07, 0x12, 0x03, 0x0c, 0x02, 0x32, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x00, 0x07, 0x81, 0xf4, - 0x03, 0x12, 0x03, 0x0c, 0x02, 0x32, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x00, 0x12, 0x03, - 0x0d, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x05, 0x12, 0x03, 0x0d, 0x02, - 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x01, 0x12, 0x03, 0x0d, 0x1c, 0x20, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x03, 0x12, 0x03, 0x0d, 0x2c, 0x2d, 0x0a, 0x0b, 0x0a, - 0x04, 0x04, 0x00, 0x02, 0x01, 0x12, 0x03, 0x0e, 0x02, 0x2e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, - 0x02, 0x01, 0x05, 0x12, 0x03, 0x0e, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, - 0x01, 0x12, 0x03, 0x0e, 0x1c, 0x23, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x03, 0x12, - 0x03, 0x0e, 0x2c, 0x2d, 0x0a, 0x0c, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x02, 0x12, 0x04, 0x0f, 0x02, - 0x10, 0x56, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x06, 0x12, 0x03, 0x0f, 0x02, 0x1f, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x01, 0x12, 0x03, 0x0f, 0x20, 0x2d, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x00, 0x02, 0x02, 0x03, 0x12, 0x03, 0x0f, 0x30, 0x31, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x00, 0x02, 0x02, 0x08, 0x12, 0x03, 0x10, 0x06, 0x55, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x00, - 0x02, 0x02, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x10, 0x07, 0x23, 0x0a, 0x0f, 0x0a, 0x08, 0x04, - 0x00, 0x02, 0x02, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x10, 0x25, 0x54, 0x0a, 0x30, 0x0a, 0x02, - 0x04, 0x01, 0x12, 0x04, 0x14, 0x00, 0x1e, 0x01, 0x1a, 0x24, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, - 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x27, 0x73, 0x20, 0x43, - 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x0a, 0x0a, - 0x0a, 0x03, 0x04, 0x01, 0x01, 0x12, 0x03, 0x14, 0x08, 0x16, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x01, - 0x07, 0x12, 0x03, 0x15, 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x01, 0x07, 0x81, 0xf4, 0x03, - 0x12, 0x03, 0x15, 0x02, 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x00, 0x12, 0x03, 0x16, - 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x05, 0x12, 0x03, 0x16, 0x02, 0x07, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x01, 0x12, 0x03, 0x16, 0x08, 0x0c, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x03, 0x12, 0x03, 0x16, 0x27, 0x28, 0x0a, 0x0b, 0x0a, 0x04, - 0x04, 0x01, 0x02, 0x01, 0x12, 0x03, 0x17, 0x02, 0x29, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, - 0x01, 0x05, 0x12, 0x03, 0x17, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x01, - 0x12, 0x03, 0x17, 0x08, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x03, 0x12, 0x03, - 0x17, 0x27, 0x28, 0x0a, 0x66, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x02, 0x12, 0x03, 0x1b, 0x02, 0x17, - 0x1a, 0x59, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x20, 0x74, 0x68, 0x61, - 0x74, 0x20, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x64, 0x73, 0x20, 0x74, 0x6f, - 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, - 0x74, 0x20, 0x69, 0x6e, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, - 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x77, - 0x61, 0x73, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x2e, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x01, 0x02, 0x02, 0x05, 0x12, 0x03, 0x1b, 0x02, 0x08, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, - 0x02, 0x01, 0x12, 0x03, 0x1b, 0x09, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x02, 0x03, - 0x12, 0x03, 0x1b, 0x15, 0x16, 0x0a, 0x1e, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x03, 0x12, 0x03, 0x1d, - 0x02, 0x31, 0x1a, 0x11, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x20, - 0x72, 0x6f, 0x6f, 0x74, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x06, 0x12, 0x03, - 0x1d, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x01, 0x12, 0x03, 0x1d, 0x28, - 0x2c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x03, 0x03, 0x12, 0x03, 0x1d, 0x2f, 0x30, 0x0a, - 0x26, 0x0a, 0x02, 0x04, 0x02, 0x12, 0x04, 0x21, 0x00, 0x26, 0x01, 0x1a, 0x1a, 0x20, 0x57, 0x61, - 0x73, 0x6d, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x01, 0x12, 0x03, - 0x21, 0x08, 0x0e, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x07, 0x12, 0x03, 0x22, 0x02, 0x2d, 0x0a, - 0x0d, 0x0a, 0x06, 0x04, 0x02, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x22, 0x02, 0x2d, 0x0a, 0x0b, - 0x0a, 0x04, 0x04, 0x02, 0x02, 0x00, 0x12, 0x03, 0x24, 0x02, 0x27, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x02, 0x02, 0x00, 0x05, 0x12, 0x03, 0x24, 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, - 0x00, 0x01, 0x12, 0x03, 0x24, 0x1c, 0x20, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x03, - 0x12, 0x03, 0x24, 0x25, 0x26, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x01, 0x12, 0x03, 0x25, - 0x02, 0x74, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x06, 0x12, 0x03, 0x25, 0x02, 0x1f, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x01, 0x12, 0x03, 0x25, 0x20, 0x26, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x03, 0x12, 0x03, 0x25, 0x29, 0x2a, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x02, 0x02, 0x01, 0x08, 0x12, 0x03, 0x25, 0x2b, 0x73, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x02, - 0x02, 0x01, 0x08, 0xe9, 0xfb, 0x03, 0x12, 0x03, 0x25, 0x2c, 0x48, 0x0a, 0x0f, 0x0a, 0x08, 0x04, - 0x02, 0x02, 0x01, 0x08, 0xee, 0xfb, 0x03, 0x12, 0x03, 0x25, 0x4a, 0x72, 0x0a, 0x2c, 0x0a, 0x02, - 0x04, 0x03, 0x12, 0x04, 0x29, 0x00, 0x2e, 0x01, 0x1a, 0x20, 0x20, 0x57, 0x61, 0x73, 0x6d, 0x20, - 0x6c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x4d, 0x69, 0x73, - 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x75, 0x72, 0x0a, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, - 0x01, 0x12, 0x03, 0x29, 0x08, 0x14, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, 0x07, 0x12, 0x03, 0x2a, - 0x02, 0x2d, 0x0a, 0x0d, 0x0a, 0x06, 0x04, 0x03, 0x07, 0x81, 0xf4, 0x03, 0x12, 0x03, 0x2a, 0x02, - 0x2d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x00, 0x12, 0x03, 0x2c, 0x02, 0x45, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x05, 0x12, 0x03, 0x2c, 0x02, 0x08, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x03, 0x02, 0x00, 0x01, 0x12, 0x03, 0x2c, 0x09, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, - 0x02, 0x00, 0x03, 0x12, 0x03, 0x2c, 0x15, 0x16, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, - 0x08, 0x12, 0x03, 0x2c, 0x17, 0x44, 0x0a, 0x0f, 0x0a, 0x08, 0x04, 0x03, 0x02, 0x00, 0x08, 0xee, - 0xfb, 0x03, 0x12, 0x03, 0x2c, 0x18, 0x43, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x01, 0x12, - 0x03, 0x2d, 0x02, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x05, 0x12, 0x03, 0x2d, - 0x02, 0x07, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x12, 0x03, 0x2d, 0x09, 0x0d, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x03, 0x12, 0x03, 0x2d, 0x15, 0x16, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -]; -include!("icon.lightclient.wasm.v1.serde.rs"); -// @@protoc_insertion_point(module) \ No newline at end of file diff --git a/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.serde.rs b/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.serde.rs deleted file mode 100644 index 68519e03b..000000000 --- a/libraries/rust/common/src/icon/icon.lightclient.wasm.v1.serde.rs +++ /dev/null @@ -1,502 +0,0 @@ -// @generated -impl serde::Serialize for ClientState { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.data.is_empty() { - len += 1; - } - if !self.code_id.is_empty() { - len += 1; - } - if self.latest_height.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("icon.lightclient.wasm.v1.ClientState", len)?; - if !self.data.is_empty() { - struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; - } - if !self.code_id.is_empty() { - struct_ser.serialize_field("code_id", pbjson::private::base64::encode(&self.code_id).as_str())?; - } - if let Some(v) = self.latest_height.as_ref() { - struct_ser.serialize_field("latest_height", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ClientState { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "data", - "code_id", - "codeId", - "latest_height", - "latestHeight", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Data, - CodeId, - LatestHeight, - } - impl<'de> serde::Deserialize<'de> for GeneratedField { - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = GeneratedField; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(formatter, "expected one of: {:?}", &FIELDS) - } - - #[allow(unused_variables)] - fn visit_str(self, value: &str) -> std::result::Result - where - E: serde::de::Error, - { - match value { - "data" => Ok(GeneratedField::Data), - "codeId" | "code_id" => Ok(GeneratedField::CodeId), - "latestHeight" | "latest_height" => Ok(GeneratedField::LatestHeight), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ClientState; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct icon.lightclient.wasm.v1.ClientState") - } - - fn visit_map(self, mut map: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut data__ = None; - let mut code_id__ = None; - let mut latest_height__ = None; - while let Some(k) = map.next_key()? { - match k { - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::CodeId => { - if code_id__.is_some() { - return Err(serde::de::Error::duplicate_field("codeId")); - } - code_id__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::LatestHeight => { - if latest_height__.is_some() { - return Err(serde::de::Error::duplicate_field("latestHeight")); - } - latest_height__ = map.next_value()?; - } - } - } - Ok(ClientState { - data: data__.unwrap_or_default(), - code_id: code_id__.unwrap_or_default(), - latest_height: latest_height__, - }) - } - } - deserializer.deserialize_struct("icon.lightclient.wasm.v1.ClientState", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for ConsensusState { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.data.is_empty() { - len += 1; - } - if !self.code_id.is_empty() { - len += 1; - } - if self.timestamp != 0 { - len += 1; - } - if self.root.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("icon.lightclient.wasm.v1.ConsensusState", len)?; - if !self.data.is_empty() { - struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; - } - if !self.code_id.is_empty() { - struct_ser.serialize_field("code_id", pbjson::private::base64::encode(&self.code_id).as_str())?; - } - if self.timestamp != 0 { - struct_ser.serialize_field("timestamp", ToString::to_string(&self.timestamp).as_str())?; - } - if let Some(v) = self.root.as_ref() { - struct_ser.serialize_field("root", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for ConsensusState { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "data", - "code_id", - "codeId", - "timestamp", - "root", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Data, - CodeId, - Timestamp, - Root, - } - impl<'de> serde::Deserialize<'de> for GeneratedField { - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = GeneratedField; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(formatter, "expected one of: {:?}", &FIELDS) - } - - #[allow(unused_variables)] - fn visit_str(self, value: &str) -> std::result::Result - where - E: serde::de::Error, - { - match value { - "data" => Ok(GeneratedField::Data), - "codeId" | "code_id" => Ok(GeneratedField::CodeId), - "timestamp" => Ok(GeneratedField::Timestamp), - "root" => Ok(GeneratedField::Root), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = ConsensusState; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct icon.lightclient.wasm.v1.ConsensusState") - } - - fn visit_map(self, mut map: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut data__ = None; - let mut code_id__ = None; - let mut timestamp__ = None; - let mut root__ = None; - while let Some(k) = map.next_key()? { - match k { - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::CodeId => { - if code_id__.is_some() { - return Err(serde::de::Error::duplicate_field("codeId")); - } - code_id__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Timestamp => { - if timestamp__.is_some() { - return Err(serde::de::Error::duplicate_field("timestamp")); - } - timestamp__ = - Some(map.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) - ; - } - GeneratedField::Root => { - if root__.is_some() { - return Err(serde::de::Error::duplicate_field("root")); - } - root__ = map.next_value()?; - } - } - } - Ok(ConsensusState { - data: data__.unwrap_or_default(), - code_id: code_id__.unwrap_or_default(), - timestamp: timestamp__.unwrap_or_default(), - root: root__, - }) - } - } - deserializer.deserialize_struct("icon.lightclient.wasm.v1.ConsensusState", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Header { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.data.is_empty() { - len += 1; - } - if self.height.is_some() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("icon.lightclient.wasm.v1.Header", len)?; - if !self.data.is_empty() { - struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; - } - if let Some(v) = self.height.as_ref() { - struct_ser.serialize_field("height", v)?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Header { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "data", - "height", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - Data, - Height, - } - impl<'de> serde::Deserialize<'de> for GeneratedField { - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = GeneratedField; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(formatter, "expected one of: {:?}", &FIELDS) - } - - #[allow(unused_variables)] - fn visit_str(self, value: &str) -> std::result::Result - where - E: serde::de::Error, - { - match value { - "data" => Ok(GeneratedField::Data), - "height" => Ok(GeneratedField::Height), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Header; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct icon.lightclient.wasm.v1.Header") - } - - fn visit_map(self, mut map: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut data__ = None; - let mut height__ = None; - while let Some(k) = map.next_key()? { - match k { - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - GeneratedField::Height => { - if height__.is_some() { - return Err(serde::de::Error::duplicate_field("height")); - } - height__ = map.next_value()?; - } - } - } - Ok(Header { - data: data__.unwrap_or_default(), - height: height__, - }) - } - } - deserializer.deserialize_struct("icon.lightclient.wasm.v1.Header", FIELDS, GeneratedVisitor) - } -} -impl serde::Serialize for Misbehaviour { - #[allow(deprecated)] - fn serialize(&self, serializer: S) -> std::result::Result - where - S: serde::Serializer, - { - use serde::ser::SerializeStruct; - let mut len = 0; - if !self.client_id.is_empty() { - len += 1; - } - if !self.data.is_empty() { - len += 1; - } - let mut struct_ser = serializer.serialize_struct("icon.lightclient.wasm.v1.Misbehaviour", len)?; - if !self.client_id.is_empty() { - struct_ser.serialize_field("client_id", &self.client_id)?; - } - if !self.data.is_empty() { - struct_ser.serialize_field("data", pbjson::private::base64::encode(&self.data).as_str())?; - } - struct_ser.end() - } -} -impl<'de> serde::Deserialize<'de> for Misbehaviour { - #[allow(deprecated)] - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - const FIELDS: &[&str] = &[ - "client_id", - "clientId", - "data", - ]; - - #[allow(clippy::enum_variant_names)] - enum GeneratedField { - ClientId, - Data, - } - impl<'de> serde::Deserialize<'de> for GeneratedField { - fn deserialize(deserializer: D) -> std::result::Result - where - D: serde::Deserializer<'de>, - { - struct GeneratedVisitor; - - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = GeneratedField; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(formatter, "expected one of: {:?}", &FIELDS) - } - - #[allow(unused_variables)] - fn visit_str(self, value: &str) -> std::result::Result - where - E: serde::de::Error, - { - match value { - "clientId" | "client_id" => Ok(GeneratedField::ClientId), - "data" => Ok(GeneratedField::Data), - _ => Err(serde::de::Error::unknown_field(value, FIELDS)), - } - } - } - deserializer.deserialize_identifier(GeneratedVisitor) - } - } - struct GeneratedVisitor; - impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = Misbehaviour; - - fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - formatter.write_str("struct icon.lightclient.wasm.v1.Misbehaviour") - } - - fn visit_map(self, mut map: V) -> std::result::Result - where - V: serde::de::MapAccess<'de>, - { - let mut client_id__ = None; - let mut data__ = None; - while let Some(k) = map.next_key()? { - match k { - GeneratedField::ClientId => { - if client_id__.is_some() { - return Err(serde::de::Error::duplicate_field("clientId")); - } - client_id__ = Some(map.next_value()?); - } - GeneratedField::Data => { - if data__.is_some() { - return Err(serde::de::Error::duplicate_field("data")); - } - data__ = - Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0) - ; - } - } - } - Ok(Misbehaviour { - client_id: client_id__.unwrap_or_default(), - data: data__.unwrap_or_default(), - }) - } - } - deserializer.deserialize_struct("icon.lightclient.wasm.v1.Misbehaviour", FIELDS, GeneratedVisitor) - } -} diff --git a/libraries/rust/common/src/icon/mod.rs b/libraries/rust/common/src/icon/mod.rs index e38262a56..0bdf8e031 100644 --- a/libraries/rust/common/src/icon/mod.rs +++ b/libraries/rust/common/src/icon/mod.rs @@ -4,12 +4,6 @@ pub mod icon { // @@protoc_insertion_point(attribute:icon.lightclient.v1) pub mod v1 { include!("icon.lightclient.v1.rs"); - // @@protoc_insertion_point(icon.lightclient.v1) - // @@protoc_insertion_point(attribute:icon.lightclient.v1.wasm) - pub mod wasm { - include!("icon.lightclient.v1.wasm.rs"); - // @@protoc_insertion_point(icon.lightclient.v1.wasm) - } } } pub mod proto { diff --git a/proto/buf.gen.rust.yaml b/proto/buf.gen.rust.yaml index 2a46c334b..aa845e0e9 100644 --- a/proto/buf.gen.rust.yaml +++ b/proto/buf.gen.rust.yaml @@ -20,4 +20,6 @@ plugins: strategy: all opt: - no_features - \ No newline at end of file + - name: grpc-gateway + out: .. + opt: logtostderr=true,allow_colon_final_segments=true \ No newline at end of file diff --git a/proto/icon/lightclient/v1/wasm.proto b/proto/icon/lightclient/v1/wasm.proto deleted file mode 100644 index 70902208f..000000000 --- a/proto/icon/lightclient/v1/wasm.proto +++ /dev/null @@ -1,50 +0,0 @@ - -syntax = "proto3"; -package icon.lightclient.v1.wasm; - -import "gogoproto/gogo.proto"; -import "core/02-client/Client.proto"; -import "core/23-commitment/commitment.proto"; -import "google/protobuf/any.proto"; - -option go_package = "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm;wasm"; - -// Wasm light client's Client state -message ClientState { - option (gogoproto.goproto_getters) = false; - bytes data = 1; - bytes code_id = 2; - icon.proto.core.client.Height latest_height = 3 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"latest_height\""]; -} - -// Wasm light client's ConsensusState -message ConsensusState { - option (gogoproto.goproto_getters) = false; - bytes data = 1; - bytes code_id = 2; - - // timestamp that corresponds to the block height in which the ConsensusState - // was stored. - uint64 timestamp = 3; - // commitment root - icon.proto.core.commitment.MerkleRoot root = 4; -} // - -// Wasm light client Header -message Header { - option (gogoproto.goproto_getters) = false; - - bytes data = 1; - icon.proto.core.client.Height height = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"height\""]; -} - -// Wasm light client Misbehaviour -message Misbehaviour { - option (gogoproto.goproto_getters) = false; - - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - bytes data = 2; -} - - From 46833b4dc410118182b50a73b482bf2a24aff679 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 18:07:19 +0545 Subject: [PATCH 18/64] fix: split traits --- .../src/light_client.rs | 2 - .../cw-light-client-common/src/traits/mod.rs | 74 +++++++++ .../src/traits/trait_context.rs | 104 ++++++++++++ .../src/traits/trait_light_client.rs | 72 +++++++++ .../trait_query_handler.rs} | 150 +----------------- 5 files changed, 252 insertions(+), 150 deletions(-) create mode 100644 contracts/cosmwasm-vm/cw-light-client-common/src/traits/mod.rs create mode 100644 contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_context.rs create mode 100644 contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_light_client.rs rename contracts/cosmwasm-vm/cw-light-client-common/src/{traits.rs => traits/trait_query_handler.rs} (67%) diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index cffbd2e97..a4f14fcda 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -1,6 +1,4 @@ use crate::constants::TRUST_LEVEL; - -use crate::traits::IQueryHandler; use crate::traits::{ConsensusStateUpdate, IContext, ILightClient}; use crate::ContractError; use common::icon::icon::lightclient::v1::ConsensusState; diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/mod.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/mod.rs new file mode 100644 index 000000000..ee8ee0221 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/mod.rs @@ -0,0 +1,74 @@ +pub mod trait_context; +pub mod trait_light_client; +pub mod trait_query_handler; + +pub use trait_context::IContext; +pub use trait_light_client::ILightClient; +pub use trait_query_handler::IQueryHandler; + +use std::marker::PhantomData; + +use common::icon::icon::lightclient::v1::ClientState; +use common::icon::icon::lightclient::v1::ConsensusState; + +use common::icon::icon::types::v1::MerkleNode; +use common::icon::icon::types::v1::SignedHeader; +use common::utils::calculate_root; +use common::utils::keccak256; +use cosmwasm_std::Addr; + +use cosmwasm_std::Api; + +use cosmwasm_std::Deps; +use cosmwasm_std::Order; +use cosmwasm_std::StdResult; +use cosmwasm_std::Storage; +use cw_common::cw_println; +use cw_common::hex_string::HexString; +use cw_storage_plus::Bound; +use serde::Deserialize; +use serde::Serialize; + +use crate::constants::CLIENT_STATES; +use crate::constants::CONFIG; +use crate::constants::CONSENSUS_STATES; +use crate::constants::PROCESSED_HEIGHTS; +use crate::constants::PROCESSED_TIMES; +use crate::ContractError; +use common::traits::AnyTypes; +use prost::Message; + + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ConsensusStateUpdate { + // commitment for updated consensusState + pub consensus_state_commitment: [u8; 32], + pub client_state_commitment: [u8; 32], + pub consensus_state_bytes: Vec, + pub client_state_bytes: Vec, + // updated height + pub height: u64, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct Config { + pub owner: Addr, + pub ibc_host: Addr, +} + +impl Config { + pub fn new(owner: Addr, ibc_host: Addr) -> Self { + Self { owner, ibc_host } + } +} + +impl Default for Config { + fn default() -> Self { + Self { + owner: Addr::unchecked("test"), + ibc_host: Addr::unchecked("ibc_host"), + } + } +} + + diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_context.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_context.rs new file mode 100644 index 000000000..146721da1 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_context.rs @@ -0,0 +1,104 @@ +use std::marker::PhantomData; + +use common::icon::icon::lightclient::v1::ClientState; +use common::icon::icon::lightclient::v1::ConsensusState; + +use common::icon::icon::types::v1::MerkleNode; +use common::icon::icon::types::v1::SignedHeader; +use common::utils::calculate_root; +use common::utils::keccak256; +use cosmwasm_std::Addr; + +use cosmwasm_std::Api; + +use cosmwasm_std::Deps; +use cosmwasm_std::Order; +use cosmwasm_std::StdResult; +use cosmwasm_std::Storage; +use cw_common::cw_println; +use cw_common::hex_string::HexString; +use cw_storage_plus::Bound; +use serde::Deserialize; +use serde::Serialize; + +use crate::constants::CLIENT_STATES; +use crate::constants::CONFIG; +use crate::constants::CONSENSUS_STATES; +use crate::constants::PROCESSED_HEIGHTS; +use crate::constants::PROCESSED_TIMES; +use crate::ContractError; +use common::traits::AnyTypes; +use prost::Message; +use super::*; +pub trait IContext { + fn get_client_state(&self, client_id: &str) -> Result; + + fn insert_client_state( + &mut self, + client_id: &str, + state: ClientState, + ) -> Result<(), ContractError>; + + fn get_consensus_state( + &self, + client_id: &str, + height: u64, + ) -> Result; + fn insert_consensus_state( + &mut self, + client_id: &str, + height: u64, + state: ConsensusState, + ) -> Result<(), ContractError>; + + fn get_timestamp_at_height(&self, client_id: &str, height: u64) -> Result; + fn insert_timestamp_at_height( + &mut self, + client_id: &str, + height: u64, + ) -> Result<(), ContractError>; + fn insert_blocknumber_at_height( + &mut self, + client_id: &str, + height: u64, + ) -> Result<(), ContractError>; + + fn recover_signer(&self, msg: &[u8], signature: &[u8]) -> Option<[u8; 20]> { + if signature.len() != 65 { + return None; + } + let mut rs = [0u8; 64]; + rs[..].copy_from_slice(&signature[..64]); + let v = signature[64]; + let pubkey = self.api().secp256k1_recover_pubkey(msg, &rs, v).unwrap(); + let pubkey_hash = keccak256(&pubkey[1..]); + let address: Option<[u8; 20]> = pubkey_hash.as_slice()[12..].try_into().ok(); + address + } + + fn recover_icon_signer(&self, msg: &[u8], signature: &[u8]) -> Option> { + self.recover_signer(msg, signature) + .map(|addr| addr.to_vec()) + } + + fn get_config(&self) -> Result; + + fn insert_config(&mut self, config: &Config) -> Result<(), ContractError>; + + fn get_current_block_time(&self) -> u64; + fn get_current_block_height(&self) -> u64; + fn get_processed_time_at_height( + &self, + client_id: &str, + height: u64, + ) -> Result; + fn get_processed_block_at_height( + &self, + client_id: &str, + height: u64, + ) -> Result; + + fn ensure_owner(&self, caller: Addr) -> Result<(), ContractError>; + fn ensure_ibc_host(&self, caller: &Addr) -> Result<(), ContractError>; + fn api(&self) -> &dyn Api; +} diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_light_client.rs new file mode 100644 index 000000000..25e9ac3f7 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_light_client.rs @@ -0,0 +1,72 @@ +use std::marker::PhantomData; + +use common::icon::icon::lightclient::v1::ClientState; +use common::icon::icon::lightclient::v1::ConsensusState; + +use common::icon::icon::types::v1::MerkleNode; +use common::icon::icon::types::v1::SignedHeader; +use common::utils::calculate_root; +use common::utils::keccak256; +use cosmwasm_std::Addr; + +use cosmwasm_std::Api; + +use cosmwasm_std::Deps; +use cosmwasm_std::Order; +use cosmwasm_std::StdResult; +use cosmwasm_std::Storage; +use cw_common::cw_println; +use cw_common::hex_string::HexString; +use cw_storage_plus::Bound; +use serde::Deserialize; +use serde::Serialize; + +use crate::constants::CLIENT_STATES; +use crate::constants::CONFIG; +use crate::constants::CONSENSUS_STATES; +use crate::constants::PROCESSED_HEIGHTS; +use crate::constants::PROCESSED_TIMES; +use crate::ContractError; +use common::traits::AnyTypes; +use prost::Message; +use super::*; +pub trait ILightClient { + type Error; + /** + * @dev createClient creates a new client with the given state. + * If succeeded, it returns a commitment for the initial state. + */ + fn create_client( + &mut self, + caller: Addr, + client_id: &str, + client_state: ClientState, + consensus_state: ConsensusState, + ) -> Result; + + /** + * @dev updateClient updates the client corresponding to `clientId`. + * If succeeded, it returns a commitment for the updated state. + * If there are no updates for consensus state, this function should returns an empty array as `updates`. + * + * NOTE: updateClient is intended to perform the followings: + * 1. verify a given client message(e.g. header) + * 2. check misbehaviour such like duplicate block height + * 3. if misbehaviour is found, update state accordingly and return + * 4. update state(s) with the client message + * 5. persist the state(s) on the host + */ + fn update_client( + &mut self, + caller: Addr, + client_id: &str, + header: SignedHeader, + ) -> Result; + + fn verify_header( + &mut self, + caller: &Addr, + client_id: &str, + header: &SignedHeader, + ) -> Result<(), Self::Error>; +} \ No newline at end of file diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_query_handler.rs similarity index 67% rename from contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_query_handler.rs index ef286239b..82019644c 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_query_handler.rs @@ -29,80 +29,7 @@ use crate::constants::PROCESSED_TIMES; use crate::ContractError; use common::traits::AnyTypes; use prost::Message; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ConsensusStateUpdate { - // commitment for updated consensusState - pub consensus_state_commitment: [u8; 32], - pub client_state_commitment: [u8; 32], - pub consensus_state_bytes: Vec, - pub client_state_bytes: Vec, - // updated height - pub height: u64, -} - -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] -pub struct Config { - pub owner: Addr, - pub ibc_host: Addr, -} - -impl Config { - pub fn new(owner: Addr, ibc_host: Addr) -> Self { - Self { owner, ibc_host } - } -} - -impl Default for Config { - fn default() -> Self { - Self { - owner: Addr::unchecked("test"), - ibc_host: Addr::unchecked("ibc_host"), - } - } -} - -pub trait ILightClient { - type Error; - /** - * @dev createClient creates a new client with the given state. - * If succeeded, it returns a commitment for the initial state. - */ - fn create_client( - &mut self, - caller: Addr, - client_id: &str, - client_state: ClientState, - consensus_state: ConsensusState, - ) -> Result; - - /** - * @dev updateClient updates the client corresponding to `clientId`. - * If succeeded, it returns a commitment for the updated state. - * If there are no updates for consensus state, this function should returns an empty array as `updates`. - * - * NOTE: updateClient is intended to perform the followings: - * 1. verify a given client message(e.g. header) - * 2. check misbehaviour such like duplicate block height - * 3. if misbehaviour is found, update state accordingly and return - * 4. update state(s) with the client message - * 5. persist the state(s) on the host - */ - fn update_client( - &mut self, - caller: Addr, - client_id: &str, - header: SignedHeader, - ) -> Result; - - fn verify_header( - &mut self, - caller: &Addr, - client_id: &str, - header: &SignedHeader, - ) -> Result<(), Self::Error>; -} - +use super::*; pub trait IQueryHandler { fn get_consensus_state( storage: &dyn Storage, @@ -359,77 +286,4 @@ pub trait IQueryHandler { let keys = result.into_iter().map(|t| t.0 .1).collect::>(); Ok(keys) } -} -pub trait IStoreReader {} -pub trait IContext { - fn get_client_state(&self, client_id: &str) -> Result; - - fn insert_client_state( - &mut self, - client_id: &str, - state: ClientState, - ) -> Result<(), ContractError>; - - fn get_consensus_state( - &self, - client_id: &str, - height: u64, - ) -> Result; - fn insert_consensus_state( - &mut self, - client_id: &str, - height: u64, - state: ConsensusState, - ) -> Result<(), ContractError>; - - fn get_timestamp_at_height(&self, client_id: &str, height: u64) -> Result; - fn insert_timestamp_at_height( - &mut self, - client_id: &str, - height: u64, - ) -> Result<(), ContractError>; - fn insert_blocknumber_at_height( - &mut self, - client_id: &str, - height: u64, - ) -> Result<(), ContractError>; - - fn recover_signer(&self, msg: &[u8], signature: &[u8]) -> Option<[u8; 20]> { - if signature.len() != 65 { - return None; - } - let mut rs = [0u8; 64]; - rs[..].copy_from_slice(&signature[..64]); - let v = signature[64]; - let pubkey = self.api().secp256k1_recover_pubkey(msg, &rs, v).unwrap(); - let pubkey_hash = keccak256(&pubkey[1..]); - let address: Option<[u8; 20]> = pubkey_hash.as_slice()[12..].try_into().ok(); - address - } - - fn recover_icon_signer(&self, msg: &[u8], signature: &[u8]) -> Option> { - self.recover_signer(msg, signature) - .map(|addr| addr.to_vec()) - } - - fn get_config(&self) -> Result; - - fn insert_config(&mut self, config: &Config) -> Result<(), ContractError>; - - fn get_current_block_time(&self) -> u64; - fn get_current_block_height(&self) -> u64; - fn get_processed_time_at_height( - &self, - client_id: &str, - height: u64, - ) -> Result; - fn get_processed_block_at_height( - &self, - client_id: &str, - height: u64, - ) -> Result; - - fn ensure_owner(&self, caller: Addr) -> Result<(), ContractError>; - fn ensure_ibc_host(&self, caller: &Addr) -> Result<(), ContractError>; - fn api(&self) -> &dyn Api; -} +} \ No newline at end of file From ba1473aa7f2eb2b09639338477d533abdbc388e2 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 18:12:43 +0545 Subject: [PATCH 19/64] chore: pass build --- .../traits/{trait_context.rs => context.rs} | 26 +----------- ...{trait_light_client.rs => light_client.rs} | 26 ------------ .../cw-light-client-common/src/traits/mod.rs | 42 +++---------------- ...rait_query_handler.rs => query_handler.rs} | 13 +----- 4 files changed, 9 insertions(+), 98 deletions(-) rename contracts/cosmwasm-vm/cw-light-client-common/src/traits/{trait_context.rs => context.rs} (79%) rename contracts/cosmwasm-vm/cw-light-client-common/src/traits/{trait_light_client.rs => light_client.rs} (69%) rename contracts/cosmwasm-vm/cw-light-client-common/src/traits/{trait_query_handler.rs => query_handler.rs} (98%) diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_context.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/context.rs similarity index 79% rename from contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_context.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/traits/context.rs index 146721da1..dd6f68c1c 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_context.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/context.rs @@ -1,34 +1,10 @@ -use std::marker::PhantomData; - use common::icon::icon::lightclient::v1::ClientState; use common::icon::icon::lightclient::v1::ConsensusState; - -use common::icon::icon::types::v1::MerkleNode; -use common::icon::icon::types::v1::SignedHeader; -use common::utils::calculate_root; use common::utils::keccak256; use cosmwasm_std::Addr; - use cosmwasm_std::Api; - -use cosmwasm_std::Deps; -use cosmwasm_std::Order; -use cosmwasm_std::StdResult; -use cosmwasm_std::Storage; -use cw_common::cw_println; -use cw_common::hex_string::HexString; -use cw_storage_plus::Bound; -use serde::Deserialize; -use serde::Serialize; - -use crate::constants::CLIENT_STATES; -use crate::constants::CONFIG; -use crate::constants::CONSENSUS_STATES; -use crate::constants::PROCESSED_HEIGHTS; -use crate::constants::PROCESSED_TIMES; use crate::ContractError; -use common::traits::AnyTypes; -use prost::Message; + use super::*; pub trait IContext { fn get_client_state(&self, client_id: &str) -> Result; diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/light_client.rs similarity index 69% rename from contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_light_client.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/traits/light_client.rs index 25e9ac3f7..3ff83c112 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/light_client.rs @@ -1,34 +1,8 @@ -use std::marker::PhantomData; - use common::icon::icon::lightclient::v1::ClientState; use common::icon::icon::lightclient::v1::ConsensusState; - -use common::icon::icon::types::v1::MerkleNode; use common::icon::icon::types::v1::SignedHeader; -use common::utils::calculate_root; -use common::utils::keccak256; use cosmwasm_std::Addr; -use cosmwasm_std::Api; - -use cosmwasm_std::Deps; -use cosmwasm_std::Order; -use cosmwasm_std::StdResult; -use cosmwasm_std::Storage; -use cw_common::cw_println; -use cw_common::hex_string::HexString; -use cw_storage_plus::Bound; -use serde::Deserialize; -use serde::Serialize; - -use crate::constants::CLIENT_STATES; -use crate::constants::CONFIG; -use crate::constants::CONSENSUS_STATES; -use crate::constants::PROCESSED_HEIGHTS; -use crate::constants::PROCESSED_TIMES; -use crate::ContractError; -use common::traits::AnyTypes; -use prost::Message; use super::*; pub trait ILightClient { type Error; diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/mod.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/mod.rs index ee8ee0221..34c64057b 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/mod.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/mod.rs @@ -1,44 +1,16 @@ -pub mod trait_context; -pub mod trait_light_client; -pub mod trait_query_handler; +pub mod context; +pub mod light_client; +pub mod query_handler; -pub use trait_context::IContext; -pub use trait_light_client::ILightClient; -pub use trait_query_handler::IQueryHandler; +pub use context::IContext; +pub use light_client::ILightClient; +pub use query_handler::IQueryHandler; -use std::marker::PhantomData; - -use common::icon::icon::lightclient::v1::ClientState; -use common::icon::icon::lightclient::v1::ConsensusState; - -use common::icon::icon::types::v1::MerkleNode; -use common::icon::icon::types::v1::SignedHeader; -use common::utils::calculate_root; -use common::utils::keccak256; use cosmwasm_std::Addr; -use cosmwasm_std::Api; - -use cosmwasm_std::Deps; -use cosmwasm_std::Order; -use cosmwasm_std::StdResult; -use cosmwasm_std::Storage; -use cw_common::cw_println; -use cw_common::hex_string::HexString; -use cw_storage_plus::Bound; use serde::Deserialize; use serde::Serialize; -use crate::constants::CLIENT_STATES; -use crate::constants::CONFIG; -use crate::constants::CONSENSUS_STATES; -use crate::constants::PROCESSED_HEIGHTS; -use crate::constants::PROCESSED_TIMES; -use crate::ContractError; -use common::traits::AnyTypes; -use prost::Message; - - #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ConsensusStateUpdate { // commitment for updated consensusState @@ -70,5 +42,3 @@ impl Default for Config { } } } - - diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs similarity index 98% rename from contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_query_handler.rs rename to contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs index 82019644c..5bcfe4b78 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/trait_query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs @@ -1,16 +1,9 @@ use std::marker::PhantomData; - use common::icon::icon::lightclient::v1::ClientState; use common::icon::icon::lightclient::v1::ConsensusState; - use common::icon::icon::types::v1::MerkleNode; -use common::icon::icon::types::v1::SignedHeader; use common::utils::calculate_root; use common::utils::keccak256; -use cosmwasm_std::Addr; - -use cosmwasm_std::Api; - use cosmwasm_std::Deps; use cosmwasm_std::Order; use cosmwasm_std::StdResult; @@ -18,9 +11,8 @@ use cosmwasm_std::Storage; use cw_common::cw_println; use cw_common::hex_string::HexString; use cw_storage_plus::Bound; -use serde::Deserialize; -use serde::Serialize; +use super::*; use crate::constants::CLIENT_STATES; use crate::constants::CONFIG; use crate::constants::CONSENSUS_STATES; @@ -29,7 +21,6 @@ use crate::constants::PROCESSED_TIMES; use crate::ContractError; use common::traits::AnyTypes; use prost::Message; -use super::*; pub trait IQueryHandler { fn get_consensus_state( storage: &dyn Storage, @@ -286,4 +277,4 @@ pub trait IQueryHandler { let keys = result.into_iter().map(|t| t.0 .1).collect::>(); Ok(keys) } -} \ No newline at end of file +} From 5e710fb21341ddef7021b4cb76b1e9d4f319c7bd Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 2 Oct 2023 18:15:03 +0545 Subject: [PATCH 20/64] fix: remove inner --- .../src/traits/context.rs | 2 +- .../src/traits/light_client.rs | 2 +- .../src/traits/query_handler.rs | 28 +------------------ 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/context.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/context.rs index dd6f68c1c..1a7c26e4b 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/context.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/context.rs @@ -1,9 +1,9 @@ +use crate::ContractError; use common::icon::icon::lightclient::v1::ClientState; use common::icon::icon::lightclient::v1::ConsensusState; use common::utils::keccak256; use cosmwasm_std::Addr; use cosmwasm_std::Api; -use crate::ContractError; use super::*; pub trait IContext { diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/light_client.rs index 3ff83c112..f91d606cc 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/light_client.rs @@ -43,4 +43,4 @@ pub trait ILightClient { client_id: &str, header: &SignedHeader, ) -> Result<(), Self::Error>; -} \ No newline at end of file +} diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs index 5bcfe4b78..8b097b4d7 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs @@ -1,4 +1,3 @@ -use std::marker::PhantomData; use common::icon::icon::lightclient::v1::ClientState; use common::icon::icon::lightclient::v1::ConsensusState; use common::icon::icon::types::v1::MerkleNode; @@ -11,6 +10,7 @@ use cosmwasm_std::Storage; use cw_common::cw_println; use cw_common::hex_string::HexString; use cw_storage_plus::Bound; +use std::marker::PhantomData; use super::*; use crate::constants::CLIENT_STATES; @@ -149,32 +149,6 @@ pub trait IQueryHandler { let client_state = Self::get_client_state(deps.storage, client_id)?; let consensus_state: ConsensusState = Self::get_consensus_state(deps.storage, client_id, height)?; - Self::verify_membership_inner( - deps, - client_id, - client_state, - consensus_state, - height, - delay_time_period, - delay_block_period, - proof, - value, - path, - ) - } - - fn verify_membership_inner( - deps: Deps, - client_id: &str, - client_state: ClientState, - consensus_state: ConsensusState, - height: u64, - _delay_time_period: u64, - _delay_block_period: u64, - proof: &[MerkleNode], - value: &[u8], - path: &[u8], - ) -> Result { cw_println!( deps.api, "[LightClient]: Path Bytes {:?}", From 5a224dbae2fcd464573aa15e8b95cb14236bb596 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Tue, 3 Oct 2023 10:47:30 +0545 Subject: [PATCH 21/64] fix: query handler --- .../cw-light-client-common/src/traits/query_handler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs index 8b097b4d7..019e0f078 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs @@ -140,8 +140,8 @@ pub trait IQueryHandler { deps: Deps, client_id: &str, height: u64, - delay_time_period: u64, - delay_block_period: u64, + _delay_time_period: u64, + _delay_block_period: u64, proof: &[MerkleNode], value: &[u8], path: &[u8], From e0a16aa500f9ae6511efd1815f900af25c9d8c88 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Tue, 3 Oct 2023 16:19:08 +0545 Subject: [PATCH 22/64] fix: add tests --- .../cw-wasm-light-client/src/contract.rs | 33 +++++------ .../cw-wasm-light-client/src/lib.rs | 2 +- .../cw-wasm-light-client/src/msg.rs | 1 + .../cw-wasm-light-client/tests/setup.rs | 49 +++++++++++++++ .../tests/test_execute.rs | 59 +++++++++++++++++++ .../tests/test_instantiate.rs | 38 ++++++++++++ 6 files changed, 164 insertions(+), 18 deletions(-) create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs create mode 100644 contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index b0ac5ae02..2393020d4 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -73,7 +73,7 @@ fn process_message( "[WasmClient]: Contract Execute Called with {:?}", msg ); - let result: Result = match msg { + match msg { ExecuteMsg::VerifyMembership(msg) => { cw_println!(deps_mut.api, "[WasmClient]: Verify Membership called"); let height = msg.height.revision_height; @@ -82,7 +82,7 @@ fn process_message( MerkleProofs::decode(msg.proof.as_slice()).map_err(ContractError::DecodeError)?; let path = hex::decode(msg.path.key_path.join("")).unwrap(); - let _ok = QueryHandler::verify_membership( + QueryHandler::verify_membership( deps_mut.as_ref(), client_id, height, @@ -94,7 +94,7 @@ fn process_message( )?; cw_println!(deps_mut.api, "[WasmClient]: Verify Membership Complete"); - to_binary(&ContractResult::success()).map_err(ContractError::Std) + Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) } ExecuteMsg::VerifyNonMembership(msg) => { cw_println!(deps_mut.api, "[WasmClient]: Verify Non Membership Called"); @@ -104,7 +104,7 @@ fn process_message( MerkleProofs::decode(msg.proof.as_slice()).map_err(ContractError::DecodeError)?; let path = hex::decode(msg.path.key_path.join("")).unwrap(); - let _ok = QueryHandler::verify_non_membership( + QueryHandler::verify_non_membership( deps_mut.as_ref(), client_id, height, @@ -114,7 +114,8 @@ fn process_message( &path, )?; cw_println!(deps_mut.api, "[WasmClient]: Verify Non Membership Complete"); - to_binary(&ContractResult::success()).map_err(ContractError::Std) + + Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) } ExecuteMsg::VerifyClientMessage(msg) => match msg.client_message { crate::msg::ClientMessageRaw::Header(wasmheader) => { @@ -125,13 +126,11 @@ fn process_message( let header_any = Any::decode(&*wasmheader.data).unwrap(); let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; - let _update = client.update_client(info.sender, CLIENT_ID, header)?; - to_binary(&ContractResult::success()).map_err(ContractError::Std) + client.update_client(info.sender, CLIENT_ID, header)?; + Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) } crate::msg::ClientMessageRaw::Misbehaviour(_) => unimplemented!(), }, - ExecuteMsg::CheckForMisbehaviour(_) => todo!(), - ExecuteMsg::UpdateStateOnMisbehaviour(_) => todo!(), ExecuteMsg::UpdateState(msg) => { cw_println!(deps_mut.api, "Received Header {:?}", &msg); @@ -142,19 +141,16 @@ fn process_message( let header_any = Any::decode(&*wasmheader.data).unwrap(); let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; - let _update = client.update_client(info.sender, CLIENT_ID, header)?; - - to_binary(&ContractResult::success()).map_err(ContractError::Std) + client.update_client(info.sender, CLIENT_ID, header)?; + Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) } crate::msg::ClientMessageRaw::Misbehaviour(_) => { - to_binary(&ContractResult::success()).map_err(ContractError::Std) + Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) } } } - ExecuteMsg::CheckSubstituteAndUpdateState(_) => todo!(), - ExecuteMsg::VerifyUpgradeAndUpdateState(_) => todo!(), - }; - Ok(result.unwrap()) + _ => todo!(), + } } #[cfg_attr(not(feature = "library"), entry_point)] @@ -171,6 +167,9 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { cw_println!(deps.api, "Export metadata called {:?}", &msg); QueryHandler::get_client_status(deps) } + QueryMsg::GetClientState {} => { + to_binary(&QueryHandler::get_client_state(deps.storage, CLIENT_ID).unwrap()) + } } } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs index 68204b98c..654f11ee7 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/lib.rs @@ -1,7 +1,7 @@ mod context; pub mod contract; -mod msg; +pub mod msg; pub mod query_handler; pub mod utils; pub use cw_light_client_common::light_client; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs index e6157bfe6..9ff5d792a 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -138,6 +138,7 @@ pub enum QueryMsg { GetLatestHeightsMsg(GetLatestHeightsMsg), ExportMetadata(ExportMetadataMsg), Status(StatusMsg), + GetClientState {}, } #[cw_serde] diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs index f5975dba3..4ea6d5575 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs @@ -1,3 +1,4 @@ +use common::{ibc::dynamic_typing::AsAny, icon::icon::types::v1::BtpHeader, traits::AnyTypes}; #[cfg(test)] use cosmwasm_std::{ coins, @@ -7,6 +8,16 @@ use cosmwasm_std::{ }, Addr, BlockInfo, ContractInfo, Empty, Env, MessageInfo, OwnedDeps, Timestamp, TransactionInfo, }; +use cosmwasm_std::{DepsMut, Storage}; +use cw_common::raw_types::Any; +use cw_wasm_light_client::{ + query_handler::QueryHandler, + utils::{ + get_client_state_key, get_consensus_state_key, to_ibc_height, to_wasm_consensus_state, + }, +}; +use ics07_tendermint_cw::ics23::FakeInner; +use prost::Message; pub struct MockEnvBuilder { env: Env, @@ -84,3 +95,41 @@ fn test() { assert_eq!(mock, mock_env) } + +pub struct TestContext {} + +impl Default for TestContext { + fn default() -> Self { + TestContext {} + } +} + +impl TestContext { + pub fn init(&self, storage: &mut dyn Storage, header: &BtpHeader) { + let client_state = header.to_client_state(1000000, 0); + let consensus_state = header.to_consensus_state(); + let client_key = get_client_state_key(); + let consensus_key = get_consensus_state_key(to_ibc_height(client_state.latest_height)); + let client_state_any = client_state.to_any(); + + let wasm_client = ics08_wasm::client_state::ClientState:: { + data: client_state_any.encode_to_vec(), + code_id: vec![1], + latest_height: to_ibc_height(client_state.latest_height), + inner: Box::new(FakeInner), + _phantom: std::marker::PhantomData, + }; + let wasm_any_bytes = wasm_client.to_any().encode_to_vec(); + + storage.set(&client_key, &wasm_any_bytes); + + let wasm_consensus = to_wasm_consensus_state(consensus_state); + + storage.set(&consensus_key, &wasm_consensus) + } + + pub fn for_instantiate() -> TestContext { + let context = TestContext::default(); + context + } +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs new file mode 100644 index 000000000..778a1643e --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs @@ -0,0 +1,59 @@ +use crate::setup::TestContext; +use common::{ + icon::icon::types::v1::{BtpHeader, SignedHeader}, + traits::AnyTypes, +}; +use cosmwasm_std::{ + testing::{mock_dependencies, mock_env, mock_info}, + Coin, +}; +use cw_common::raw_types::Any; +use cw_wasm_light_client::traits::IQueryHandler; +use cw_wasm_light_client::{ + constants::CLIENT_ID, + contract::execute, + msg::{ExecuteMsg, UpdateStateMsgRaw}, + query_handler::QueryHandler, + utils::to_ibc_height, +}; +use ics07_tendermint_cw::ics23::FakeInner; +use prost::Message; +use test_utils::{get_test_headers, get_test_signed_headers}; +mod setup; + +#[test] +pub fn test_update_success() { + let mut deps = mock_dependencies(); + let env = mock_env(); + let info = mock_info("sender", &vec![Coin::new(100, "test")]); + let header = &get_test_headers()[0]; + let context = TestContext::for_instantiate(); + context.init(deps.as_mut().storage, header); + + let signed_header: &SignedHeader = &get_test_signed_headers()[1].clone(); + let header_any: Any = signed_header.to_any(); + let block_height = signed_header.header.clone().unwrap().main_height; + let wasm_header = ics08_wasm::client_message::Header:: { + inner: Box::new(FakeInner), + data: header_any.encode_to_vec(), + height: to_ibc_height(block_height), + }; + + let msg = ExecuteMsg::UpdateState(UpdateStateMsgRaw { + client_message: cw_wasm_light_client::msg::ClientMessageRaw::Header(wasm_header), + }); + let _result = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); + + let updated_client_state = + QueryHandler::get_client_state(deps.as_ref().storage, CLIENT_ID).unwrap(); + + assert_eq!(updated_client_state.latest_height, block_height); + + let consensus_state= QueryHandler::get_consensus_state(deps.as_ref().storage, CLIENT_ID, block_height).unwrap(); + + + assert_eq!( + consensus_state.message_root, + signed_header.header.clone().unwrap().message_root + ) +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs new file mode 100644 index 000000000..c69db05c0 --- /dev/null +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs @@ -0,0 +1,38 @@ +use cosmwasm_std::{ + testing::{mock_dependencies, mock_env, mock_info}, + Coin, +}; +use cw_wasm_light_client::contract::instantiate; +use cw_wasm_light_client::msg::InstantiateMsg; +use test_utils::get_test_headers; + +use crate::setup::TestContext; +mod setup; + +#[test] +pub fn instantiate_success() { + let mut deps = mock_dependencies(); + let env = mock_env(); + let info = mock_info("sender", &vec![Coin::new(100, "test")]); + let header = &get_test_headers()[0]; + let context = TestContext::for_instantiate(); + context.init(deps.as_mut().storage, header); + let msg = InstantiateMsg {}; + let result = instantiate(deps.as_mut(), env, info, msg); + println!("{:?}", result); + assert!(result.is_ok()) +} + +#[test] +#[should_panic(expected = "ClientStateNotFound(\"08-wasm-0\")")] +pub fn instantiate_fails_on_uninitialized_storage() { + let mut deps = mock_dependencies(); + let env = mock_env(); + let info = mock_info("sender", &vec![Coin::new(100, "test")]); + let header = &get_test_headers()[0]; + let context = TestContext::for_instantiate(); + + let msg = InstantiateMsg {}; + let result = instantiate(deps.as_mut(), env, info, msg); + result.unwrap(); +} From d4f2c389d1a68fe97943e65e328a5496d35e13f1 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Wed, 4 Oct 2023 15:16:06 +0545 Subject: [PATCH 23/64] fix: add update test --- .../cw-wasm-light-client/src/msg.rs | 2 ++ .../cw-wasm-light-client/src/utils.rs | 13 +++++++++++ .../cw-wasm-light-client/tests/setup.rs | 23 ++++++------------- .../tests/test_execute.rs | 22 ++++++------------ .../tests/test_instantiate.rs | 8 +++---- 5 files changed, 33 insertions(+), 35 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs index 9ff5d792a..ad5bd51d6 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -1,4 +1,6 @@ +use common::icon::icon::types::v1::SignedMsgType; use cosmwasm_schema::cw_serde; +use cw_common::raw_types::Any; use ics07_tendermint_cw::ics23::FakeInner; use ics08_wasm::{ client_message::Header as WasmHeader, client_state::ClientState as WasmClientState, diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs index a530e1530..d8d462bd1 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs @@ -10,6 +10,8 @@ use ics07_tendermint_cw::ics23::FakeInner; use ics08_wasm::client_state::ClientState as WasmClientState; use prost::Message; use tendermint_proto::Protobuf; +use ics08_wasm::client_message::Header as WasmHeader; +use common::icon::icon::types::v1::SignedHeader; pub fn get_consensus_state_key(height: Height) -> Vec { [ "consensusStates/".to_string().into_bytes(), @@ -84,3 +86,14 @@ pub fn any_from_byte(bytes: &[u8]) -> Result { let any = Any::decode(bytes).map_err(ContractError::DecodeError)?; Ok(any) } + +pub fn to_wasm_header(signed_header:&SignedHeader)->WasmHeader{ + let header_any: Any = signed_header.to_any(); + let block_height = signed_header.header.clone().unwrap().main_height; + let wasm_header = WasmHeader:: { + inner: Box::new(FakeInner), + data: header_any.encode_to_vec(), + height: to_ibc_height(block_height), + }; + wasm_header +} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs index 4ea6d5575..5a7c1e976 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/setup.rs @@ -1,4 +1,5 @@ -use common::{ibc::dynamic_typing::AsAny, icon::icon::types::v1::BtpHeader, traits::AnyTypes}; +use common::{icon::icon::types::v1::BtpHeader, traits::AnyTypes}; +use cosmwasm_std::Storage; #[cfg(test)] use cosmwasm_std::{ coins, @@ -8,13 +9,9 @@ use cosmwasm_std::{ }, Addr, BlockInfo, ContractInfo, Empty, Env, MessageInfo, OwnedDeps, Timestamp, TransactionInfo, }; -use cosmwasm_std::{DepsMut, Storage}; -use cw_common::raw_types::Any; -use cw_wasm_light_client::{ - query_handler::QueryHandler, - utils::{ - get_client_state_key, get_consensus_state_key, to_ibc_height, to_wasm_consensus_state, - }, + +use cw_wasm_light_client::utils::{ + get_client_state_key, get_consensus_state_key, to_ibc_height, to_wasm_consensus_state, }; use ics07_tendermint_cw::ics23::FakeInner; use prost::Message; @@ -96,14 +93,9 @@ fn test() { assert_eq!(mock, mock_env) } +#[derive(Default)] pub struct TestContext {} -impl Default for TestContext { - fn default() -> Self { - TestContext {} - } -} - impl TestContext { pub fn init(&self, storage: &mut dyn Storage, header: &BtpHeader) { let client_state = header.to_client_state(1000000, 0); @@ -129,7 +121,6 @@ impl TestContext { } pub fn for_instantiate() -> TestContext { - let context = TestContext::default(); - context + TestContext::default() } } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs index 778a1643e..cf56681c5 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs @@ -1,14 +1,11 @@ use crate::setup::TestContext; -use common::{ - icon::icon::types::v1::{BtpHeader, SignedHeader}, - traits::AnyTypes, -}; +use common::{icon::icon::types::v1::SignedHeader, traits::AnyTypes}; use cosmwasm_std::{ testing::{mock_dependencies, mock_env, mock_info}, Coin, }; use cw_common::raw_types::Any; -use cw_wasm_light_client::traits::IQueryHandler; +use cw_wasm_light_client::{traits::IQueryHandler, utils::to_wasm_header}; use cw_wasm_light_client::{ constants::CLIENT_ID, contract::execute, @@ -24,20 +21,15 @@ mod setup; #[test] pub fn test_update_success() { let mut deps = mock_dependencies(); - let env = mock_env(); - let info = mock_info("sender", &vec![Coin::new(100, "test")]); + let _env = mock_env(); + let info = mock_info("sender", &[Coin::new(100, "test")]); let header = &get_test_headers()[0]; let context = TestContext::for_instantiate(); context.init(deps.as_mut().storage, header); let signed_header: &SignedHeader = &get_test_signed_headers()[1].clone(); - let header_any: Any = signed_header.to_any(); let block_height = signed_header.header.clone().unwrap().main_height; - let wasm_header = ics08_wasm::client_message::Header:: { - inner: Box::new(FakeInner), - data: header_any.encode_to_vec(), - height: to_ibc_height(block_height), - }; + let wasm_header = to_wasm_header(signed_header); let msg = ExecuteMsg::UpdateState(UpdateStateMsgRaw { client_message: cw_wasm_light_client::msg::ClientMessageRaw::Header(wasm_header), @@ -49,8 +41,8 @@ pub fn test_update_success() { assert_eq!(updated_client_state.latest_height, block_height); - let consensus_state= QueryHandler::get_consensus_state(deps.as_ref().storage, CLIENT_ID, block_height).unwrap(); - + let consensus_state = + QueryHandler::get_consensus_state(deps.as_ref().storage, CLIENT_ID, block_height).unwrap(); assert_eq!( consensus_state.message_root, diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs index c69db05c0..2c13f070a 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs @@ -13,7 +13,7 @@ mod setup; pub fn instantiate_success() { let mut deps = mock_dependencies(); let env = mock_env(); - let info = mock_info("sender", &vec![Coin::new(100, "test")]); + let info = mock_info("sender", &[Coin::new(100, "test")]); let header = &get_test_headers()[0]; let context = TestContext::for_instantiate(); context.init(deps.as_mut().storage, header); @@ -28,9 +28,9 @@ pub fn instantiate_success() { pub fn instantiate_fails_on_uninitialized_storage() { let mut deps = mock_dependencies(); let env = mock_env(); - let info = mock_info("sender", &vec![Coin::new(100, "test")]); - let header = &get_test_headers()[0]; - let context = TestContext::for_instantiate(); + let info = mock_info("sender", &[Coin::new(100, "test")]); + let _header = &get_test_headers()[0]; + let _context = TestContext::for_instantiate(); let msg = InstantiateMsg {}; let result = instantiate(deps.as_mut(), env, info, msg); From 5878febda79e9d9867765061c4e420c52ab7798d Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 11:45:15 +0545 Subject: [PATCH 24/64] fix: downgrade --- Cargo.lock | 1008 +++++++++-------- Cargo.toml | 19 +- .../src/ics03_connection/handler.rs | 2 +- .../cw-ibc-core/src/ics04_channel/handler.rs | 4 +- .../ics04_channel/packet/timeout_on_close.rs | 2 +- .../tests/channel/test_acknowledgement.rs | 2 +- .../tests/channel/test_channel_closeinit.rs | 2 +- .../tests/channel/test_close_confirm.rs | 2 +- .../tests/channel/test_execution_channel.rs | 20 +- .../tests/channel/test_open_ack.rs | 2 +- .../tests/channel/test_open_confirm.rs | 2 +- .../tests/channel/test_timeout_on_close.rs | 2 +- .../channel/test_write_acknowledgement.rs | 15 +- .../cw-ibc-core/tests/test_channel.rs | 2 +- .../cw-ibc-core/tests/test_connection.rs | 4 +- .../cw-ibc-core/tests/test_port.rs | 2 +- .../cw-icon-light-client/Cargo.toml | 4 +- .../cosmwasm-vm/cw-integration/Cargo.toml | 2 +- .../tests/test_host_lightclient.rs | 4 +- .../tests/test_xcall_connection.rs | 2 +- .../cw-light-client-common/Cargo.toml | 4 +- .../cw-mock-ibc-connection/Cargo.toml | 2 +- .../cosmwasm-vm/cw-mock-ibc-core/Cargo.toml | 2 +- .../cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml | 2 +- .../cosmwasm-vm/cw-mock-ibc-dapp/src/admin.rs | 6 +- .../cw-mock-ibc-dapp/src/ibc_host.rs | 2 +- .../cw-wasm-light-client/Cargo.toml | 14 +- .../cw-wasm-light-client/src/msg.rs | 3 +- .../cw-wasm-light-client/src/utils.rs | 12 +- .../tests/test_execute.rs | 10 +- .../tests/test_instantiate.rs | 2 +- .../cw-xcall-ibc-connection/Cargo.toml | 2 +- .../cw-xcall-ibc-connection/src/ibc_host.rs | 2 +- .../cw-xcall-ibc-connection/src/xcall.rs | 4 +- .../tests/test_ibc_functions.rs | 64 +- .../tests/test_receive_packet.rs | 14 +- rust-toolchain.toml | 4 + scripts/optimize-cosmwasm.sh | 1 + 38 files changed, 671 insertions(+), 581 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/Cargo.lock b/Cargo.lock index dfe41e7bf..bbc519d6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,22 +25,25 @@ dependencies = [ ] [[package]] -name = "android-tzdata" -version = "0.1.1" +name = "aho-corasick" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" @@ -54,6 +57,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base64" version = "0.11.0" @@ -66,6 +75,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" + [[package]] name = "base64ct" version = "1.6.0" @@ -84,6 +99,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "bitvec" version = "1.0.1" @@ -114,6 +135,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bnum" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128a44527fc0d6abf05f9eda748b9027536e12dff93f5acc8449f51583309350" + [[package]] name = "borsh" version = "0.10.3" @@ -133,7 +160,7 @@ dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", - "proc-macro2 1.0.59", + "proc-macro2 1.0.69", "syn 1.0.109", ] @@ -143,8 +170,8 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -154,8 +181,8 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -167,25 +194,19 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" dependencies = [ "serde", ] -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - [[package]] name = "cfg-if" version = "1.0.0" @@ -194,11 +215,10 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ - "android-tzdata", "num-traits", ] @@ -209,7 +229,7 @@ dependencies = [ "bytes", "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "debug_print", "derive_more", "displaydoc", @@ -228,7 +248,7 @@ dependencies = [ "serde", "serde-json-wasm 0.5.1", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "subtle-encoding", "tendermint 0.29.1", @@ -241,12 +261,12 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/icon-project/IBC-Integration.git?branch=main#8b3dbac3e846fdc2bf36861a3c0f65b917acda43" +source = "git+https://github.com/icon-project/IBC-Integration.git?branch=main#49ff4ade6cd0d2dfe3d7b58a5d74fd4ea6294633" dependencies = [ "bytes", "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "debug_print", "derive_more", "displaydoc", @@ -265,7 +285,7 @@ dependencies = [ "serde", "serde-json-wasm 0.5.1", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "subtle-encoding", "tendermint 0.29.1", @@ -274,9 +294,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "convert_case" @@ -308,34 +328,34 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.6" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c0e41be7e6c7d7ab3c61cdc32fcfaa14f948491a401cbc1c74bb33b6f4b851" +checksum = "a6fb22494cf7d23d0c348740e06e5c742070b2991fd41db77bba0bcfbae1a723" dependencies = [ "digest 0.10.7", "ed25519-zebra", - "k256", + "k256 0.13.1", "rand_core 0.6.4", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "1.2.6" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a7ee2798c92c00dd17bebb4210f81d5f647e5e92d847959b7977e0fd29a3500" +checksum = "6e199424486ea97d6b211db6387fd72e26b4a439d40cc23140b2d8305728055b" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.2.6" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "407aca6f1671a08b60db8167f03bb7cb6b2378f0ddd9a030367b66ba33c2fd41" +checksum = "fef683a9c1c4eabd6d31515719d0d2cc66952c4c87f7eb192bfc90384517dc34" dependencies = [ "cosmwasm-schema-derive", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "serde_json", "thiserror", @@ -343,40 +363,40 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.6" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d1e00b8fd27ff923c10303023626358e23a6f9079f8ebec23a8b4b0bfcd4b3" +checksum = "9567025acbb4c0c008178393eb53b3ac3c2e492c25949d3bf415b9cbe80772d8" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "cosmwasm-std" -version = "1.2.6" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5fdfd112b070055f068fad079d490117c8e905a588b92a5a7c9276d029930" +checksum = "7d89d680fb60439b7c5947b15f9c84b961b88d1f8a3b20c4bd178a3f87db8bae" dependencies = [ - "base64 0.13.1", + "base64 0.21.4", + "bnum", "cosmwasm-crypto", "cosmwasm-derive", "derivative", "forward_ref", "hex", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", - "sha2 0.10.6", + "sha2 0.10.8", "thiserror", - "uint", ] [[package]] name = "cosmwasm-storage" -version = "1.2.6" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af9e21c4f58986fd20184d7685e1c43c5732c9309337b09307d5952fd34dba6e" +checksum = "54a1c574d30feffe4b8121e61e839c231a5ce21901221d2fb4d5c945968a4f00" dependencies = [ "cosmwasm-std", "serde", @@ -384,9 +404,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -409,6 +429,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "crypto-bigint" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -454,7 +486,7 @@ dependencies = [ "common 0.1.0", "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall-lib", "debug_print", "getrandom", @@ -462,7 +494,7 @@ dependencies = [ "hex-buffer-serde", "ibc-proto 0.26.0", "prost 0.11.9", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", "serde_json", @@ -481,17 +513,17 @@ dependencies = [ "cw-common", "cw-icon-light-client", "cw-multi-test", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw2", "debug_print", "getrandom", "hex", "hex-literal 0.4.1", "prost 0.11.9", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "test-utils", "thiserror", @@ -506,20 +538,19 @@ dependencies = [ "cosmwasm", "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cw-common", "cw-light-client-common", - "cw-storage-plus 1.1.0", + "cw-storage-plus 0.15.1", "cw2", "debug_print", "getrandom", "hex", "hex-literal 0.4.1", "prost 0.11.9", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "test-utils", "thiserror", @@ -533,7 +564,6 @@ dependencies = [ "common 0.1.0", "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cw-common", "cw-ibc-core", "cw-icon-light-client", @@ -541,7 +571,7 @@ dependencies = [ "cw-mock-dapp-multi", "cw-mock-ibc-core", "cw-multi-test", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", "cw-xcall-ibc-connection", "cw-xcall-lib", @@ -561,15 +591,14 @@ dependencies = [ "cosmwasm", "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cw-common", - "cw-storage-plus 1.1.0", + "cw-storage-plus 0.15.1", "debug_print", "getrandom", "hex", "hex-literal 0.4.1", "prost 0.11.9", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", "test-utils", @@ -579,16 +608,16 @@ dependencies = [ [[package]] name = "cw-mock-dapp" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=main#59960dcb8bcfb43e7e079ebe7e86dbf9baf05160" +source = "git+https://github.com/icon-project/xCall.git?branch=main#caaf7a0bfb8513504b08900124ca242b9e6b2466" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=main)", "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall-lib", "cw2", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", "thiserror", @@ -597,16 +626,16 @@ dependencies = [ [[package]] name = "cw-mock-dapp-multi" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=main#59960dcb8bcfb43e7e079ebe7e86dbf9baf05160" +source = "git+https://github.com/icon-project/xCall.git?branch=main#caaf7a0bfb8513504b08900124ca242b9e6b2466" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=main)", "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall-lib", "cw2", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", "thiserror", @@ -620,16 +649,15 @@ dependencies = [ "cosmwasm", "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cw-common", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", "cw-xcall-lib", "cw2", "debug_print", "getrandom", "hex", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "thiserror", ] @@ -641,14 +669,13 @@ dependencies = [ "common 0.1.0", "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cw-common", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", "cw2", "getrandom", "hex", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "thiserror", ] @@ -661,45 +688,55 @@ dependencies = [ "cosmwasm", "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cw-common", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw2", "debug_print", "getrandom", "hex", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "thiserror", ] [[package]] name = "cw-multi-test" -version = "0.16.4" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a18afd2e201221c6d72a57f0886ef2a22151bbc9e6db7af276fde8a91081042" +checksum = "127c7bb95853b8e828bdab97065c81cb5ddc20f7339180b61b2300565aaa99d1" dependencies = [ "anyhow", "cosmwasm-std", - "cw-storage-plus 1.0.1", + "cw-storage-plus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cw-utils", "derivative", "itertools", - "k256", + "k256 0.11.6", "prost 0.9.0", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "thiserror", ] [[package]] name = "cw-storage-plus" -version = "1.0.1" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a5083c258acd68386734f428a5a171b29f7d733151ae83090c6fcc9417ffa" +checksum = "dc6cf70ef7686e2da9ad7b067c5942cd3e88dd9453f7af42f54557f8af300fb0" dependencies = [ "cosmwasm-std", - "schemars 0.8.12", + "schemars 0.8.15", + "serde", +] + +[[package]] +name = "cw-storage-plus" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f0e92a069d62067f3472c62e30adedb4cab1754725c0f2a682b3128d2bf3c79" +dependencies = [ + "cosmwasm-std", + "schemars 0.8.15", "serde", ] @@ -709,20 +746,20 @@ version = "1.1.0" source = "git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw#238b520c3e193226143eedb717a3ed76187d11de" dependencies = [ "cosmwasm-std", - "schemars 0.8.12", + "schemars 0.8.15", "serde", ] [[package]] name = "cw-utils" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c80e93d1deccb8588db03945016a292c3c631e6325d349ebb35d2db6f4f946f7" +checksum = "1b9f351a4e4d81ef7c890e44d903f8c0bdcdc00f094fd3a181eaf70c0eec7a3a" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw2", - "schemars 0.8.12", + "schemars 0.8.15", "semver", "serde", "thiserror", @@ -738,10 +775,8 @@ dependencies = [ "cosmwasm", "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cw-common", "cw-light-client-common", - "cw-storage-plus 1.1.0", "cw2", "debug_print", "getrandom", @@ -752,10 +787,10 @@ dependencies = [ "ics07-tendermint-cw", "ics08-wasm", "prost 0.11.9", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "tendermint-proto 0.28.0", "test-utils", @@ -765,17 +800,17 @@ dependencies = [ [[package]] name = "cw-xcall" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=main#59960dcb8bcfb43e7e079ebe7e86dbf9baf05160" +source = "git+https://github.com/icon-project/xCall.git?branch=main#caaf7a0bfb8513504b08900124ca242b9e6b2466" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=main)", "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall-lib", "cw2", "debug_print", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "thiserror", ] @@ -788,16 +823,15 @@ dependencies = [ "cosmwasm", "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", "cw-common", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", "cw-xcall-lib", "cw2", "debug_print", "getrandom", "hex", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "thiserror", ] @@ -805,30 +839,31 @@ dependencies = [ [[package]] name = "cw-xcall-lib" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=main#59960dcb8bcfb43e7e079ebe7e86dbf9baf05160" +source = "git+https://github.com/icon-project/xCall.git?branch=main#caaf7a0bfb8513504b08900124ca242b9e6b2466" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw2", "debug_print", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "thiserror", ] [[package]] name = "cw2" -version = "1.0.1" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb70cee2cf0b4a8ff7253e6bc6647107905e8eb37208f87d54f67810faa62f8" +checksum = "9431d14f64f49e41c6ef5561ed11a5391c417d0cb16455dea8cdcb9037a8d197" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.0.1", - "schemars 0.8.12", + "cw-storage-plus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schemars 0.8.15", "serde", + "thiserror", ] [[package]] @@ -847,14 +882,24 @@ dependencies = [ "zeroize", ] +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "derivative" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -865,8 +910,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "convert_case 0.4.0", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "rustc_version", "syn 1.0.109", ] @@ -887,6 +932,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -897,9 +943,9 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", ] [[package]] @@ -910,9 +956,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" [[package]] name = "ecdsa" @@ -920,10 +966,24 @@ version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", + "der 0.6.1", + "elliptic-curve 0.12.3", + "rfc6979 0.3.1", + "signature 1.6.4", +] + +[[package]] +name = "ecdsa" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +dependencies = [ + "der 0.7.8", + "digest 0.10.7", + "elliptic-curve 0.13.6", + "rfc6979 0.4.0", + "signature 2.1.0", + "spki 0.7.2", ] [[package]] @@ -932,7 +992,7 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.6.4", ] [[package]] @@ -965,9 +1025,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" @@ -975,48 +1035,62 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ - "base16ct", - "crypto-bigint", - "der", + "base16ct 0.1.1", + "crypto-bigint 0.4.9", + "der 0.6.1", "digest 0.10.7", - "ff", + "ff 0.12.1", "generic-array", - "group", - "pkcs8", + "group 0.12.1", + "pkcs8 0.9.0", "rand_core 0.6.4", - "sec1", + "sec1 0.3.0", "subtle", "zeroize", ] [[package]] -name = "erased-serde" -version = "0.3.25" +name = "elliptic-curve" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2b0c2380453a92ea8b6c8e5f64ecaafccddde8ceab55ff7a8ac1029f894569" +checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" dependencies = [ - "serde", + "base16ct 0.2.0", + "crypto-bigint 0.5.3", + "digest 0.10.7", + "ff 0.13.0", + "generic-array", + "group 0.13.0", + "pkcs8 0.10.2", + "rand_core 0.6.4", + "sec1 0.7.3", + "subtle", + "zeroize", ] [[package]] -name = "errno" -version = "0.3.1" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "erased-serde" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", + "serde", ] [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "errno" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "cc", "libc", + "windows-sys", ] [[package]] @@ -1031,12 +1105,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.9.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "ff" @@ -1048,6 +1119,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "fixed-hash" version = "0.8.0" @@ -1157,13 +1238,14 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -1176,7 +1258,18 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ - "ff", + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", "rand_core 0.6.4", "subtle", ] @@ -1200,16 +1293,16 @@ dependencies = [ ] [[package]] -name = "heck" -version = "0.4.1" +name = "hashbrown" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" [[package]] -name = "hermit-abi" -version = "0.3.1" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hex" @@ -1248,10 +1341,19 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys", +] + [[package]] name = "ibc" version = "0.15.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" dependencies = [ "cosmwasm-schema", "derive_more", @@ -1270,7 +1372,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "subtle-encoding", "tendermint 0.28.0", "tendermint-proto 0.28.0", @@ -1302,7 +1404,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "subtle-encoding", "tendermint 0.29.1", "tendermint-light-client-verifier 0.29.1", @@ -1315,24 +1417,24 @@ dependencies = [ [[package]] name = "ibc-derive" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" dependencies = [ "convert_case 0.6.0", "proc-macro-crate 1.3.1", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "ibc-proto" version = "0.18.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" dependencies = [ "base64 0.13.1", "bytes", "prost 0.11.9", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "tendermint-proto 0.28.0", ] @@ -1340,12 +1442,12 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.18.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git#19c0265110ce33a2d24a69b2e84de69861ee0b21" +source = "git+https://github.com/ComposableFi/composable-ibc.git#2a8ed31167e6d5444337ac49cb4d0b916cb22677" dependencies = [ "base64 0.13.1", "bytes", "prost 0.11.9", - "schemars 0.8.12", + "schemars 0.8.15", "serde", "tendermint-proto 0.28.0", ] @@ -1371,7 +1473,7 @@ dependencies = [ [[package]] name = "ics07-tendermint" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" dependencies = [ "bytes", "flex-error", @@ -1393,7 +1495,7 @@ dependencies = [ [[package]] name = "ics07-tendermint-cw" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" dependencies = [ "byteorder", "cosmwasm-schema", @@ -1411,9 +1513,9 @@ dependencies = [ "ics08-wasm", "ics23 0.10.0", "prost 0.11.9", - "schemars 0.8.12", + "schemars 0.8.15", "serde", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "tendermint 0.28.0", "tendermint-light-client-verifier 0.28.0", @@ -1424,7 +1526,7 @@ dependencies = [ [[package]] name = "ics08-wasm" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#44b05025ba055a444c38708426cdcdbee363df18" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" dependencies = [ "cosmwasm-schema", "hex", @@ -1446,7 +1548,7 @@ dependencies = [ "hex", "prost 0.11.9", "ripemd", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", ] @@ -1485,8 +1587,8 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -1498,32 +1600,12 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "1.9.3" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", + "equivalent", + "hashbrown 0.14.1", ] [[package]] @@ -1537,9 +1619,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "k256" @@ -1548,9 +1630,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" dependencies = [ "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", + "sha2 0.10.8", +] + +[[package]] +name = "k256" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa 0.16.8", + "elliptic-curve 0.13.6", + "once_cell", + "sha2 0.10.8", + "signature 2.1.0", ] [[package]] @@ -1570,21 +1666,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.145" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "linux-raw-sys" -version = "0.3.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "log" -version = "0.4.18" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "matchers" @@ -1592,14 +1688,14 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "multimap" @@ -1623,16 +1719,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -1657,9 +1753,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parity-scale-codec" -version = "3.5.0" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" dependencies = [ "arrayvec", "bitvec", @@ -1671,21 +1767,21 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ "proc-macro-crate 1.3.1", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pbjson" @@ -1726,9 +1822,9 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", "indexmap", @@ -1736,9 +1832,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1752,8 +1848,18 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ - "der", - "spki", + "der 0.6.1", + "spki 0.6.0", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.8", + "spki 0.7.2", ] [[package]] @@ -1768,15 +1874,15 @@ version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ - "proc-macro2 1.0.59", + "proc-macro2 1.0.69", "syn 1.0.109", ] [[package]] name = "primitive-types" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", @@ -1809,14 +1915,14 @@ version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" dependencies = [ - "unicode-xid 0.1.0", + "unicode-xid", ] [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -1871,8 +1977,8 @@ checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" dependencies = [ "anyhow", "itertools", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -1884,8 +1990,8 @@ checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -1909,11 +2015,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ - "proc-macro2 1.0.59", + "proc-macro2 1.0.69", ] [[package]] @@ -1964,16 +2070,19 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.8.4" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" dependencies = [ - "regex-syntax 0.7.2", + "aho-corasick", + "memchr", + "regex-automata 0.4.1", + "regex-syntax 0.8.1", ] [[package]] @@ -1985,6 +2094,17 @@ dependencies = [ "regex-syntax 0.6.29", ] +[[package]] +name = "regex-automata" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.1", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -1993,9 +2113,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33" [[package]] name = "rfc6979" @@ -2003,11 +2123,21 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ - "crypto-bigint", + "crypto-bigint 0.4.9", "hmac", "zeroize", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -2023,8 +2153,8 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -2045,37 +2175,36 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.19" +version = "0.38.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" dependencies = [ - "bitflags", + "bitflags 2.4.0", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "safe-proc-macro2" -version = "1.0.36" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "814c536dcd27acf03296c618dab7ad62d28e70abd7ba41d3f34a2ce707a2c666" +checksum = "7fd85be67db87168aa3c13fd0da99f48f2ab005dccad5af5626138dc1df20eb6" dependencies = [ - "unicode-xid 0.2.4", + "unicode-ident", ] [[package]] @@ -2118,9 +2247,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" dependencies = [ "bitvec", "cfg-if", @@ -2131,13 +2260,13 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ "proc-macro-crate 1.3.1", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -2154,12 +2283,12 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" dependencies = [ "dyn-clone", - "schemars_derive 0.8.12", + "schemars_derive 0.8.15", "serde", "serde_json", ] @@ -2170,20 +2299,20 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73ab7f0b9b64633747a68dce4ed6318bbf30e3befe67df7624ad83abb7295c09" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "serde_derive_internals 0.25.0", "syn 1.0.109", ] [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "serde_derive_internals 0.26.0", "syn 1.0.109", ] @@ -2194,25 +2323,39 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ - "base16ct", - "der", + "base16ct 0.1.1", + "der 0.6.1", "generic-array", - "pkcs8", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct 0.2.0", + "der 0.7.8", + "generic-array", + "pkcs8 0.10.2", "subtle", "zeroize", ] [[package]] name = "semver" -version = "1.0.17" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -2237,22 +2380,22 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.9" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" +checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", ] [[package]] @@ -2261,8 +2404,8 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dbab34ca63057a1f15280bdf3c39f2b1eb1b54c17e98360e511637aef7418c6" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -2272,16 +2415,16 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -2290,13 +2433,13 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.12" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" +checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", ] [[package]] @@ -2314,9 +2457,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -2335,9 +2478,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] @@ -2352,11 +2495,21 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "snafu" @@ -2386,7 +2539,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" dependencies = [ "base64ct", - "der", + "der 0.6.1", +] + +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der 0.7.8", ] [[package]] @@ -2397,9 +2560,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strum" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" @@ -2408,8 +2571,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck", - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "rustversion", "syn 1.0.109", ] @@ -2443,7 +2606,7 @@ checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" dependencies = [ "proc-macro2 0.4.30", "quote 0.6.13", - "unicode-xid 0.1.0", + "unicode-xid", ] [[package]] @@ -2452,19 +2615,19 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.18" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "unicode-ident", ] @@ -2476,15 +2639,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.5.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", "redox_syscall", "rustix", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -2505,7 +2668,7 @@ dependencies = [ "serde_bytes", "serde_json", "serde_repr", - "signature", + "signature 1.6.4", "subtle", "subtle-encoding", "tendermint-proto 0.28.0", @@ -2533,8 +2696,8 @@ dependencies = [ "serde_bytes", "serde_json", "serde_repr", - "sha2 0.10.6", - "signature", + "sha2 0.10.8", + "signature 1.6.4", "subtle", "subtle-encoding", "tendermint-proto 0.29.1", @@ -2604,12 +2767,12 @@ dependencies = [ [[package]] name = "test-log" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f0c854faeb68a048f0f2dc410c5ddae3bf83854ef0e4977d58306a5edef50e" +checksum = "d9601d162c1d77e62c1ea0bc8116cd1caf143ce3af947536c3c9052a1677fe0c" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", + "proc-macro2 1.0.69", + "quote 1.0.33", "syn 1.0.109", ] @@ -2631,22 +2794,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", ] [[package]] @@ -2696,15 +2859,15 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "toml_datetime", @@ -2776,9 +2939,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "uint" @@ -2794,9 +2957,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" @@ -2810,12 +2973,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - [[package]] name = "valuable" version = "0.1.0" @@ -2836,13 +2993,14 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "which" -version = "4.4.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" dependencies = [ "either", - "libc", + "home", "once_cell", + "rustix", ] [[package]] @@ -2867,143 +3025,77 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.4.6" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" dependencies = [ "memchr", ] @@ -3032,7 +3124,7 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2 1.0.59", - "quote 1.0.28", - "syn 2.0.18", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", ] diff --git a/Cargo.toml b/Cargo.toml index 8e18672b9..2cfeecaf2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,16 +13,21 @@ repository = "https://github.com/icon-project/ibc-integration.git" version="0.1.0" [workspace.dependencies] -cosmwasm-std = {version="1.2.2",default-features = false,features = ["iterator", "ibc3","staking"]} -cosmwasm-storage = "1.2.2" -cosmwasm-schema = "1.2.2" -schemars = "0.8.12" +#cosmwasm-std = {version="1.2.2",default-features = false,features = ["iterator", "ibc3","staking"]} +#cosmwasm-storage = "1.2.2" +#cosmwasm-schema = "1.2.2" +#schemars = "0.8.12" +cosmwasm-schema = "1.1.3" +cosmwasm-std = {version=">=1.1.3",default-features = false} +schemars = "0.8.10" +serde = { version = "1.0.145", default-features = false, features = ["derive"] } +thiserror = { version = "1.0.31" } cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", branch="fix-raw"} cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="main"} cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="main"} cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="main" } cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="main" } -cw2 = "1.0.1" +cw2 = {version="1.0.1",default-features = false} ibc-proto = { version = "0.26.0", default-features = false} @@ -30,10 +35,10 @@ prost = { version = "0.11.8", default-features = false,features=["prost-derive"] serde-json-wasm = {version="0.5.0", default-features = false} serde_json = "1.0.96" -serde = { version = "1.0.154", default-features = false, features = ["derive"] } +#serde = { version = "1.0.154", default-features = false, features = ["derive"] } bytes = { version = "1.4.0", default-features = false } -thiserror = { version = "1.0.39" } +#thiserror = { version = "1.0.39" } hex ={ version = "0.4.3", default-features = false } debug_print = "1.0.0" diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs index 1eae6e11e..e45b7d948 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics03_connection/handler.rs @@ -237,7 +237,7 @@ impl<'a> CwIbcCoreContext<'a> { to_vec(&counterparty_prefix)?, msg.proof_consensus, consensus_state_path_on_b, - consensus_state.clone().as_bytes(), + consensus_state.as_bytes(), ); let payload = VerifyConnectionPayload { client_id: client_id.to_string(), diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs index 2e6f1b5b5..f38b0f434 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/handler.rs @@ -225,7 +225,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> { proof_height: proof_height.to_string(), counterparty_prefix: prefix_on_a.clone().into_vec(), proof: message.proof_init.clone(), - root: consensus_state.clone().root().into_vec(), + root: consensus_state.root().into_vec(), counterparty_chan_end_path: chan_end_path_on_a, expected_counterparty_channel_end: vector, client_id: connection_end.client_id().to_string(), @@ -356,7 +356,7 @@ impl<'a> ValidateChannel for CwIbcCoreContext<'a> { proof_height: proof_height.to_string(), counterparty_prefix: counterparty_prefix.clone().into_vec(), proof: message.proof_try.clone(), - root: consensus_state.clone().root().into_vec(), + root: consensus_state.root().into_vec(), counterparty_chan_end_path: chan_end_path_on_b, expected_counterparty_channel_end: vector, client_id: client_id.to_string(), diff --git a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/timeout_on_close.rs b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/timeout_on_close.rs index cd0537353..348a6c0a3 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/timeout_on_close.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/src/ics04_channel/packet/timeout_on_close.rs @@ -121,7 +121,7 @@ impl<'a> CwIbcCoreContext<'a> { proof_height: proof_height.to_string(), counterparty_prefix: prefix_on_b.clone().into_vec(), proof: msg.proof_close.clone(), - root: consensus_state_of_b_on_a.clone().root().into_vec(), + root: consensus_state_of_b_on_a.root().into_vec(), counterparty_chan_end_path: chan_end_path_on_b, expected_counterparty_channel_end: vector.unwrap(), client_id: connection_end.client_id().to_string(), diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_acknowledgement.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_acknowledgement.rs index 68562708c..6fa3f4362 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_acknowledgement.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_acknowledgement.rs @@ -26,7 +26,7 @@ fn test_acknowledgement_packet_validate_ordered() { mock_lightclient_query(test_context.mock_queries, &mut deps); let res = contract.acknowledgement_packet_validate(deps.as_mut(), info, env, &msg); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); } diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_channel_closeinit.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_channel_closeinit.rs index ff00fa4ff..63a5df152 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_channel_closeinit.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_channel_closeinit.rs @@ -48,7 +48,7 @@ fn test_validate_close_init_channel() { info.funds, EXECUTE_ON_CHANNEL_CLOSE_INIT, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!(res.unwrap().messages[0], on_chan_open_init) } diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_close_confirm.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_close_confirm.rs index 15b644f9b..ffa503323 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_close_confirm.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_close_confirm.rs @@ -126,7 +126,7 @@ fn test_validate_close_confirm_channel() { mock_lightclient_query(test_context.mock_queries, &mut deps); let res = contract.validate_channel_close_confirm(deps.as_mut(), info, &msg); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( res.unwrap().messages[0].id, diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_execution_channel.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_execution_channel.rs index eda6319ab..29cd927c2 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_execution_channel.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_execution_channel.rs @@ -40,7 +40,7 @@ fn test_for_channel_open_init_execution_message() { msg: HexString::from_bytes(&msg.encode_to_vec()), }, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!(res.unwrap().messages[0].id, 41); } @@ -74,7 +74,7 @@ fn test_for_channel_open_try_execution_message() { msg: HexString::from_bytes(&msg.encode_to_vec()), }, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!(res.unwrap().messages[0].id, EXECUTE_ON_CHANNEL_OPEN_TRY); @@ -106,7 +106,7 @@ fn test_for_channel_open_ack_execution() { msg: HexString::from_bytes(&msg.encode_to_vec()), }, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( @@ -147,7 +147,7 @@ fn test_for_channel_open_confirm() { msg: HexString::from_bytes(&msg.encode_to_vec()), }, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( @@ -185,7 +185,7 @@ fn test_for_channel_close_init() { msg: HexString::from_bytes(&msg.encode_to_vec()), }, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!(res.as_ref().unwrap().messages[0].id, 45); @@ -216,7 +216,7 @@ fn test_for_channel_close_confirm() { msg: HexString::from_bytes(&msg.encode_to_vec()), }, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( @@ -266,7 +266,7 @@ fn test_for_packet_send() { packet: HexString::from_bytes(&raw.encode_to_vec()), }, ); - println!("{:?},", res); + println!("{res:?},"); assert!(res.is_ok()); assert_eq!(res.as_ref().unwrap().attributes[0].value, "send_packet"); assert_eq!(res.unwrap().events[0].ty, "send_packet") @@ -298,7 +298,7 @@ fn test_for_recieve_packet() { msg: HexString::from_bytes(&msg.encode_to_vec()), }, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( res.unwrap().messages[0].id, @@ -324,7 +324,7 @@ fn test_for_recieve_packet() { }), }; let response = contract.reply(deps.as_mut(), env, reply_message); - println!("{:?}", response); + println!("{response:?}"); assert!(response.is_ok()); assert_eq!(response.unwrap().events[0].ty, "write_acknowledgement"); } @@ -356,7 +356,7 @@ fn test_for_ack_execute() { msg: HexString::from_bytes(&msg.encode_to_vec()), }, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_ack.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_ack.rs index a9994193a..0a5bcf94e 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_ack.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_ack.rs @@ -54,7 +54,7 @@ fn test_validate_open_ack_channel() { mock_lightclient_query(test_context.mock_queries, &mut deps); let res = contract.validate_channel_open_ack(deps.as_mut(), info, &msg); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( res.unwrap().messages[0].id, diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_confirm.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_confirm.rs index e957ccde8..197dafa4f 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_confirm.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_confirm.rs @@ -49,7 +49,7 @@ fn test_validate_open_confirm_channel() { mock_lightclient_query(test_context.mock_queries, &mut deps); let res = contract.validate_channel_open_confirm(deps.as_mut(), info, &msg); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( res.unwrap().messages[0].id, diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout_on_close.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout_on_close.rs index 9fff8a5dc..180149d26 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout_on_close.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout_on_close.rs @@ -19,7 +19,7 @@ fn test_timeout_on_close_packet_validate_to_light_client() { let res = contract.timeout_on_close_packet_validate_to_light_client(deps.as_mut(), info, env, msg); - print!("{:?}", res); + print!("{res:?}"); assert!(res.is_ok()); assert_eq!( res.unwrap().messages[0].id, diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_write_acknowledgement.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_write_acknowledgement.rs index d795ba3a0..642ff4f30 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_write_acknowledgement.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_write_acknowledgement.rs @@ -58,12 +58,7 @@ pub fn setup_test( ); contract - .store_channel_end( - &mut deps.storage, - &dst_port.clone(), - &dst_channel.clone(), - &chan_end_on_b, - ) + .store_channel_end(&mut deps.storage, &dst_port, &dst_channel, &chan_end_on_b) .unwrap(); let conn_id_on_b = &chan_end_on_b.connection_hops()[0]; contract @@ -137,7 +132,7 @@ fn test_write_acknowledgement() { test_context.init_receive_packet(deps.as_mut().storage, &contract); mock_lightclient_query(test_context.mock_queries, &mut deps); let res = contract.validate_receive_packet(deps.as_mut(), info, env, &msg); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( res.unwrap().messages[0].id, @@ -164,7 +159,7 @@ pub fn test_write_acknowledgement_fails_unauthorized() { test_context.init_receive_packet(deps.as_mut().storage, &contract); mock_lightclient_query(test_context.mock_queries, &mut deps); let res = contract.validate_receive_packet(deps.as_mut(), info, env, &msg); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( res.unwrap().messages[0].id, @@ -192,7 +187,7 @@ pub fn test_write_acknowledgement_fails_invalid_ack() { mock_lightclient_query(test_context.mock_queries, &mut deps); let res = contract.validate_receive_packet(deps.as_mut(), info, env, &msg); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( res.unwrap().messages[0].id, @@ -222,7 +217,7 @@ pub fn test_write_acknowledgement_fails_invalid_channel_state() { test_context.init_receive_packet(deps.as_mut().storage, &contract); mock_lightclient_query(test_context.mock_queries.clone(), &mut deps); let res = contract.validate_receive_packet(deps.as_mut(), info, env, &msg); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( res.unwrap().messages[0].id, diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_channel.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_channel.rs index 082d5a003..db43dbaa4 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_channel.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_channel.rs @@ -532,7 +532,7 @@ fn test_validate_open_init_channel() { EXECUTE_ON_CHANNEL_OPEN_INIT, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!(res.unwrap().messages[0], on_chan_open_init) diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs index 0ce552cca..df0c0f4e2 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs @@ -215,7 +215,7 @@ fn connection_open_init() { .unwrap(); let res = contract.connection_open_init(deps.as_mut(), res_msg); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); } @@ -450,7 +450,7 @@ fn connection_open_ack_validate() { mock_lightclient_query(test_context.mock_queries, &mut deps); let res = contract.connection_open_ack(deps.as_mut(), info, env, message); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()) } diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_port.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_port.rs index 87ce22efd..37206eddc 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_port.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_port.rs @@ -13,7 +13,7 @@ fn test_store_module_by_port() { let module_id = common::ibc::core::ics26_routing::context::ModuleId::from_str("contractaddress").unwrap(); let port_id = PortId::default(); - ctx.store_module_by_port(&mut deps.storage, &port_id.clone(), module_id.clone()) + ctx.store_module_by_port(&mut deps.storage, &port_id, module_id.clone()) .unwrap(); let result = ctx.lookup_module_by_port(&mut deps.storage, &port_id); diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml index d870f0f75..761974abd 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml @@ -33,8 +33,8 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} -cosmwasm-storage = {workspace=true} -cw-storage-plus = {workspace=true} +#cosmwasm-storage = {workspace=true} +cw-storage-plus = "0.15.1" cw2 = {workspace=true} schemars = {workspace=true} serde = { workspace=true} diff --git a/contracts/cosmwasm-vm/cw-integration/Cargo.toml b/contracts/cosmwasm-vm/cw-integration/Cargo.toml index e0e9e449e..39b4e2879 100644 --- a/contracts/cosmwasm-vm/cw-integration/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-integration/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} -cosmwasm-storage = {workspace=true} +#cosmwasm-storage = {workspace=true} cw-storage-plus = {workspace=true} cw-common={path="../cw-common"} common = { path="../../../libraries/rust/common", default-features = false } diff --git a/contracts/cosmwasm-vm/cw-integration/tests/test_host_lightclient.rs b/contracts/cosmwasm-vm/cw-integration/tests/test_host_lightclient.rs index 578da82cf..1437c0af6 100644 --- a/contracts/cosmwasm-vm/cw-integration/tests/test_host_lightclient.rs +++ b/contracts/cosmwasm-vm/cw-integration/tests/test_host_lightclient.rs @@ -440,7 +440,7 @@ fn test_icon_to_arcway_handshake() -> TestContext { assert!(response.is_ok()); println!("Create Client OK"); let client_id = get_client_id(&response.unwrap()); - println!("Clientid is {}", client_id); + println!("Clientid is {client_id}"); let result = call_connection_open_try(&mut ctx); println!("Conn Open Try Ok {:?}", &result); @@ -494,7 +494,7 @@ fn test_archway_to_icon_handshake() -> TestContext { assert!(response.is_ok()); println!("Create Client OK"); let client_id = get_client_id(&response.unwrap()); - println!("Clientid is {}", client_id); + println!("Clientid is {client_id}"); let result = call_connection_open_init(&mut ctx); diff --git a/contracts/cosmwasm-vm/cw-integration/tests/test_xcall_connection.rs b/contracts/cosmwasm-vm/cw-integration/tests/test_xcall_connection.rs index dbf2c5a29..3892998b9 100644 --- a/contracts/cosmwasm-vm/cw-integration/tests/test_xcall_connection.rs +++ b/contracts/cosmwasm-vm/cw-integration/tests/test_xcall_connection.rs @@ -71,7 +71,7 @@ fn send_packet_success() { let src = ctx.get_xcall_ibc_connection().to_string(); let result = call_send_call_message( &mut ctx, - &format!("nid/{}", MOCK_CONTRACT_TO_ADDR), + &format!("nid/{MOCK_CONTRACT_TO_ADDR}"), vec![src], vec!["somedestination".to_string()], vec![1, 2, 3], diff --git a/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml b/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml index 787deb2d3..24fbaabe3 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" [dependencies] cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} -cosmwasm-storage = {workspace=true} -cw-storage-plus = {workspace=true} +#cosmwasm-storage = {workspace=true} +cw-storage-plus = "0.15.1" thiserror = { workspace=true} prost = { workspace=true} hex ={workspace=true } diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-connection/Cargo.toml b/contracts/cosmwasm-vm/cw-mock-ibc-connection/Cargo.toml index 663b58271..3cec5db18 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-connection/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-mock-ibc-connection/Cargo.toml @@ -32,7 +32,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} -cosmwasm-storage = {workspace=true} +#cosmwasm-storage = {workspace=true} cw-storage-plus = {workspace=true} cw2 = {workspace=true} schemars = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml b/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml index 4fda9910c..c1cba6692 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml @@ -42,7 +42,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} -cosmwasm-storage = {workspace=true} +#cosmwasm-storage = {workspace=true} cw-storage-plus = {workspace=true} cw2 = {workspace=true} schemars = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml b/contracts/cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml index d4d0783c3..d65385c4c 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml @@ -32,7 +32,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} -cosmwasm-storage = {workspace=true} +#cosmwasm-storage = {workspace=true} cw-storage-plus = {workspace=true} cw2 = {workspace=true} schemars = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-dapp/src/admin.rs b/contracts/cosmwasm-vm/cw-mock-ibc-dapp/src/admin.rs index abf96249b..50a2b3c50 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-dapp/src/admin.rs +++ b/contracts/cosmwasm-vm/cw-mock-ibc-dapp/src/admin.rs @@ -95,10 +95,8 @@ impl<'a> CwIbcConnection<'a> { return Err(ContractError::AdminAddressCannotBeNull {}); } - if !new_admin.to_string().chars().all(|x| x.is_alphanumeric()) { - return Err(ContractError::InvalidAddress { - address: new_admin.to_string(), - }); + if !new_admin.chars().all(|x| x.is_alphanumeric()) { + return Err(ContractError::InvalidAddress { address: new_admin }); } self.ensure_owner(store, &info)?; diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-dapp/src/ibc_host.rs b/contracts/cosmwasm-vm/cw-mock-ibc-dapp/src/ibc_host.rs index 32061da31..553bb6b44 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-dapp/src/ibc_host.rs +++ b/contracts/cosmwasm-vm/cw-mock-ibc-dapp/src/ibc_host.rs @@ -114,7 +114,7 @@ mod tests { let packet = RawPacket::default(); let res = connection.call_host_send_message(deps.as_mut(), info, packet.clone()); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); let expected_ibc_host = connection diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml index 0e29fd2da..6a7c127e1 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml @@ -31,14 +31,12 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -cosmwasm-schema = {workspace=true} -cosmwasm-std = {workspace=true} -cosmwasm-storage = {workspace=true} -cw-storage-plus = {workspace=true} -cw2 = {workspace=true} -schemars = {workspace=true} -serde = { workspace=true} -thiserror = { workspace=true} +cosmwasm-schema = "1.1.3" +cosmwasm-std = {version="1.1.3",default-features = false} +schemars = "0.8.10" +serde = { version = "1.0.145", default-features = false, features = ["derive"] } +thiserror = { version = "1.0.31" } +cw2 = {workspace=true,default-features = false} sha2 = { version = "0.10.6", default-features = false } hex ={workspace=true } sha3 = { version = "0.10.6", default-features = false } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs index ad5bd51d6..0b6703a1c 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/msg.rs @@ -1,6 +1,5 @@ -use common::icon::icon::types::v1::SignedMsgType; use cosmwasm_schema::cw_serde; -use cw_common::raw_types::Any; + use ics07_tendermint_cw::ics23::FakeInner; use ics08_wasm::{ client_message::Header as WasmHeader, client_state::ClientState as WasmClientState, diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs index d8d462bd1..f23804fca 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs @@ -1,3 +1,4 @@ +use common::icon::icon::types::v1::SignedHeader; use common::{ consensus_state::IConsensusState, icon::icon::lightclient::v1::{ClientState, ConsensusState}, @@ -7,11 +8,10 @@ use cw_common::raw_types::Any; use cw_light_client_common::ContractError; use ibc::Height; use ics07_tendermint_cw::ics23::FakeInner; +use ics08_wasm::client_message::Header as WasmHeader; use ics08_wasm::client_state::ClientState as WasmClientState; use prost::Message; use tendermint_proto::Protobuf; -use ics08_wasm::client_message::Header as WasmHeader; -use common::icon::icon::types::v1::SignedHeader; pub fn get_consensus_state_key(height: Height) -> Vec { [ "consensusStates/".to_string().into_bytes(), @@ -87,13 +87,13 @@ pub fn any_from_byte(bytes: &[u8]) -> Result { Ok(any) } -pub fn to_wasm_header(signed_header:&SignedHeader)->WasmHeader{ +pub fn to_wasm_header(signed_header: &SignedHeader) -> WasmHeader { let header_any: Any = signed_header.to_any(); let block_height = signed_header.header.clone().unwrap().main_height; - let wasm_header = WasmHeader:: { + + WasmHeader:: { inner: Box::new(FakeInner), data: header_any.encode_to_vec(), height: to_ibc_height(block_height), - }; - wasm_header + } } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs index cf56681c5..29451ef94 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_execute.rs @@ -1,20 +1,18 @@ use crate::setup::TestContext; -use common::{icon::icon::types::v1::SignedHeader, traits::AnyTypes}; +use common::icon::icon::types::v1::SignedHeader; use cosmwasm_std::{ testing::{mock_dependencies, mock_env, mock_info}, Coin, }; -use cw_common::raw_types::Any; -use cw_wasm_light_client::{traits::IQueryHandler, utils::to_wasm_header}; + use cw_wasm_light_client::{ constants::CLIENT_ID, contract::execute, msg::{ExecuteMsg, UpdateStateMsgRaw}, query_handler::QueryHandler, - utils::to_ibc_height, }; -use ics07_tendermint_cw::ics23::FakeInner; -use prost::Message; +use cw_wasm_light_client::{traits::IQueryHandler, utils::to_wasm_header}; + use test_utils::{get_test_headers, get_test_signed_headers}; mod setup; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs index 2c13f070a..de38a9626 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs @@ -19,7 +19,7 @@ pub fn instantiate_success() { context.init(deps.as_mut().storage, header); let msg = InstantiateMsg {}; let result = instantiate(deps.as_mut(), env, info, msg); - println!("{:?}", result); + println!("{result:?}"); assert!(result.is_ok()) } diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/Cargo.toml b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/Cargo.toml index f0ce8c480..95d82a2a9 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/Cargo.toml @@ -32,7 +32,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} -cosmwasm-storage = {workspace=true} +#cosmwasm-storage = {workspace=true} cw-storage-plus = {workspace=true} cw2 = {workspace=true} schemars = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs index 247598904..cc752c097 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs @@ -139,7 +139,7 @@ mod tests { let packet = RawPacket::default(); let res = connection.call_host_send_message(deps.as_mut(), info, packet.clone()); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); let expected_ibc_host = connection diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/xcall.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/xcall.rs index 537b67a4c..6d060622f 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/xcall.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/xcall.rs @@ -15,7 +15,7 @@ impl<'a> CwIbcConnection<'a> { ) -> Result { let xcall_host = self.get_xcall_host(store)?; let xcall_msg = cw_xcall_lib::xcall_msg::ExecuteMsg::HandleMessage { - from: nid.clone(), + from_nid: nid.clone(), msg, }; let call_message: CosmosMsg = CosmosMsg::Wasm(WasmMsg::Execute { @@ -69,7 +69,7 @@ mod tests { let expected_xcall_host = connection.get_xcall_host(store).unwrap().to_string(); let expected_xcall_msg = - cw_xcall_lib::xcall_msg::ExecuteMsg::HandleMessage { msg, from: nid }; + cw_xcall_lib::xcall_msg::ExecuteMsg::HandleMessage { msg, from_nid: nid }; let expected_call_message = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: expected_xcall_host, msg: to_binary(&expected_xcall_msg).unwrap(), diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc_functions.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc_functions.rs index 047c23046..ddebd34be 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc_functions.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc_functions.rs @@ -14,7 +14,7 @@ use cw_xcall_ibc_connection::ack::{on_ack_failure, on_ack_sucess}; use cw_xcall_ibc_connection::types::config::Config; use cw_xcall_lib::network_address::{NetId, NetworkAddress}; -use cw_xcall::types::response::CallServiceMessageResponse; +use cw_xcall::types::response::CSMessageResponse; use cw_xcall_ibc_connection::msg::InstantiateMsg; use cw_xcall_ibc_connection::types::channel_config::ChannelConfig; use cw_xcall_ibc_connection::types::message::Message; @@ -26,8 +26,8 @@ use account::alice; use cosmwasm_std::from_binary; use cw_common::xcall_connection_msg::{ExecuteMsg, QueryMsg}; -use cw_xcall::types::message::CallServiceMessage; -use cw_xcall::types::request::CallServiceMessageRequest; +use cw_xcall::types::message::CSMessage; +use cw_xcall::types::request::CSMessageRequest; use cw_xcall_ibc_connection::state::CwIbcConnection; #[test] @@ -130,7 +130,7 @@ fn success_on_open_channel_open_init_unordered_channel() { .unwrap(); let result = contract.execute(deps.as_mut(), mock_env, mock_info, execute_msg); - println!("{:?}", result); + println!("{result:?}"); assert!(result.is_ok()) } @@ -448,7 +448,7 @@ fn sucess_receive_packet_for_call_message_request() { .add_owner(mock_deps.as_mut().storage, mock_info.clone().sender) .unwrap(); - let data = CallServiceMessageRequest::new( + let data = CSMessageRequest::new( NetworkAddress::new("nid", mock_info.sender.as_str()), Addr::unchecked("alice"), 1, @@ -457,7 +457,7 @@ fn sucess_receive_packet_for_call_message_request() { vec![], ); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let message: Message = Message { sn: Nullable::new(Some(1)), fee: 0, @@ -528,7 +528,7 @@ fn sucess_receive_packet_for_call_message_request() { .unwrap(); let result = contract.execute(mock_deps.as_mut(), mock_env, mock_info, execute_message); - println!("{:?}", result); + println!("{result:?}"); assert!(result.is_ok()); } @@ -564,7 +564,7 @@ fn sucess_on_ack_packet() { channel_id: "channel-3".to_string(), }; - let data = CallServiceMessageRequest::new( + let data = CSMessageRequest::new( NetworkAddress::new("nid", mock_info.sender.as_str()), Addr::unchecked("alice"), 1, @@ -591,7 +591,7 @@ fn sucess_on_ack_packet() { contract .store_channel_config(mock_deps.as_mut().storage, &channel, &channel_config) .unwrap(); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let packet = IbcPacket::new(to_binary(&message).unwrap(), src, dst, 0, timeout); @@ -651,7 +651,7 @@ fn fails_receive_packet_for_call_message_request() { .add_owner(mock_deps.as_mut().storage, mock_info.clone().sender) .unwrap(); - let data = CallServiceMessageRequest::new( + let data = CSMessageRequest::new( NetworkAddress::new("nid", mock_info.sender.as_str()), Addr::unchecked("alice"), 1, @@ -660,7 +660,7 @@ fn fails_receive_packet_for_call_message_request() { vec![], ); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let timeout_block = IbcTimeoutBlock { revision: 0, @@ -813,7 +813,7 @@ fn fails_on_configure_connection_unauthorized() { fn test_ack_success_on_call_request() { let mock_info = create_mock_info("alice", "umlg", 2000); - let data = CallServiceMessageRequest::new( + let data = CSMessageRequest::new( NetworkAddress::new("nid", mock_info.sender.as_str()), Addr::unchecked("alice"), 1, @@ -822,7 +822,7 @@ fn test_ack_success_on_call_request() { vec![], ); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let timeout_block = IbcTimeoutBlock { revision: 0, @@ -850,12 +850,12 @@ fn test_ack_success_on_call_request() { #[test] fn test_ack_success_on_call_response() { - let data = cw_xcall::types::response::CallServiceMessageResponse::new( + let data = cw_xcall::types::response::CSMessageResponse::new( 0, cw_xcall::types::response::CallServiceResponseType::CallServiceResponseSuccess, ); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let timeout_block = IbcTimeoutBlock { revision: 0, @@ -885,7 +885,7 @@ fn test_ack_success_on_call_response() { fn test_ack_failure_on_call_request() { let mock_info = create_mock_info("alice", "umlg", 2000); - let data = CallServiceMessageRequest::new( + let data = CSMessageRequest::new( NetworkAddress::new("nid", mock_info.sender.as_str()), Addr::unchecked("alice"), 1, @@ -894,7 +894,7 @@ fn test_ack_failure_on_call_request() { vec![], ); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let timeout_block = IbcTimeoutBlock { revision: 0, @@ -922,12 +922,12 @@ fn test_ack_failure_on_call_request() { #[test] fn test_ack_failure_on_call_response() { - let data = CallServiceMessageResponse::new( + let data = CSMessageResponse::new( 0, cw_xcall::types::response::CallServiceResponseType::CallServiceResponseSuccess, ); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let timeout_block = IbcTimeoutBlock { revision: 0, @@ -974,12 +974,12 @@ fn test_handle_response() { .add_owner(mock_deps.as_mut().storage, mock_info.clone().sender) .unwrap(); - let data = CallServiceMessageResponse::new( + let data = CSMessageResponse::new( 0, cw_xcall::types::response::CallServiceResponseType::CallServiceResponseSuccess, ); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let message = Message { sn: Nullable::new(Some(0)), fee: 0, @@ -1033,7 +1033,7 @@ fn test_handle_response() { }, ); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()) } @@ -1042,9 +1042,9 @@ fn test_handle_response() { fn test_for_call_service_request_from_rlp_bytes() { let hex_decode_rlp_data = hex::decode("f1976e69642f736f6d65636f6e74726163746164647265737393736f6d65636f6e7472616374616464726573730100f800c0").unwrap(); - let cs_message_request = CallServiceMessageRequest::try_from(&hex_decode_rlp_data).unwrap(); + let cs_message_request = CSMessageRequest::try_from(&hex_decode_rlp_data).unwrap(); - let expected_data = CallServiceMessageRequest::new( + let expected_data = CSMessageRequest::new( NetworkAddress::new("nid", "somecontractaddress"), Addr::unchecked("somecontractaddress"), 1, @@ -1059,9 +1059,9 @@ fn test_for_call_service_request_from_rlp_bytes() { #[test] fn test_for_call_service_response_from_rlp_bytes() { let hex_decode_rlp_data = hex::decode("c20100").unwrap(); - let cs_response_message = CallServiceMessageResponse::try_from(&hex_decode_rlp_data).unwrap(); + let cs_response_message = CSMessageResponse::try_from(&hex_decode_rlp_data).unwrap(); - let expected_data = CallServiceMessageResponse::new( + let expected_data = CSMessageResponse::new( 1, cw_xcall::types::response::CallServiceResponseType::CallServiceResponseFailure, ); @@ -1072,11 +1072,11 @@ fn test_for_call_service_response_from_rlp_bytes() { fn test_for_call_message_data_from_rlp_bytes() { let hex_decode = hex::decode("f401b2f1976e69642f736f6d65636f6e74726163746164647265737393736f6d65636f6e7472616374616464726573730100f800c0").unwrap(); - let cs_message = CallServiceMessage::try_from(hex_decode).unwrap(); + let cs_message = CSMessage::try_from(hex_decode).unwrap(); - let cs_message_request = CallServiceMessageRequest::try_from(cs_message.payload()).unwrap(); + let cs_message_request = CSMessageRequest::try_from(cs_message.payload()).unwrap(); - let expected_data = CallServiceMessageRequest::new( + let expected_data = CSMessageRequest::new( NetworkAddress::new("nid", "somecontractaddress"), Addr::unchecked("somecontractaddress"), 1, @@ -1092,11 +1092,11 @@ fn test_for_call_message_data_from_rlp_bytes() { fn test_call_message_from_raw_message() { let data=hex::decode("f401b2f1976e69642f736f6d65636f6e74726163746164647265737393736f6d65636f6e7472616374616464726573730100f800c0").unwrap(); - let cs_message = CallServiceMessage::try_from(data).unwrap(); + let cs_message = CSMessage::try_from(data).unwrap(); - let cs_message_request = CallServiceMessageRequest::try_from(cs_message.payload()).unwrap(); + let cs_message_request = CSMessageRequest::try_from(cs_message.payload()).unwrap(); - let expected_data = CallServiceMessageRequest::new( + let expected_data = CSMessageRequest::new( NetworkAddress::new("nid", "somecontractaddress"), Addr::unchecked("somecontractaddress"), 1, diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_receive_packet.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_receive_packet.rs index 81afdcb18..480fa1d32 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_receive_packet.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_receive_packet.rs @@ -9,9 +9,9 @@ use cosmwasm_std::{ }; use cw_xcall::types::{ - message::CallServiceMessage, - request::CallServiceMessageRequest, - response::CallServiceMessageResponse, + message::CSMessage, + request::CSMessageRequest, + response::CSMessageResponse, rlp::{self}, }; use cw_xcall_ibc_connection::{ @@ -36,7 +36,7 @@ fn test_receive_packet_for_call_message_request() { .set_xcall_host(mock_deps.as_mut().storage, Addr::unchecked("xcallhost")) .unwrap(); - let data = CallServiceMessageRequest::new( + let data = CSMessageRequest::new( NetworkAddress::new("nid", mock_info.sender.as_str()), Addr::unchecked(alice().to_string()), 1, @@ -45,7 +45,7 @@ fn test_receive_packet_for_call_message_request() { vec![], ); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let message: Message = Message { sn: common::rlp::Nullable::new(Some(0)), fee: 0, @@ -90,12 +90,12 @@ fn test_receive_packet_for_call_message_response() { contract .set_xcall_host(mock_deps.as_mut().storage, Addr::unchecked("xcallhost")) .unwrap(); - let data = CallServiceMessageResponse::new( + let data = CSMessageResponse::new( 1, cw_xcall::types::response::CallServiceResponseType::CallServiceResponseSuccess, ); - let message: CallServiceMessage = data.try_into().unwrap(); + let message: CSMessage = data.try_into().unwrap(); let message: Message = Message { sn: common::rlp::Nullable::new(Some(0)), fee: 0, diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000..4bd462616 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly-2022-12-31" +targets = [ "wasm32-unknown-unknown"] +profile = "minimal" \ No newline at end of file diff --git a/scripts/optimize-cosmwasm.sh b/scripts/optimize-cosmwasm.sh index 00a7e9ddc..ccf714cab 100755 --- a/scripts/optimize-cosmwasm.sh +++ b/scripts/optimize-cosmwasm.sh @@ -49,6 +49,7 @@ done cosmwasm-check artifacts/archway/cw_ibc_core.wasm cosmwasm-check artifacts/archway/cw_icon_light_client.wasm cosmwasm-check artifacts/archway/cw_xcall_ibc_connection.wasm +cosmwasm-check artifacts/archway/cw_wasm_light_client.wasm # Update version From 63d22fc7555e83df051caa32546d35fa88b29ae2 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 12:31:18 +0545 Subject: [PATCH 25/64] fix: downgrade cosmwasm --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2cfeecaf2..25b258aa7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ version="0.1.0" #cosmwasm-schema = "1.2.2" #schemars = "0.8.12" cosmwasm-schema = "1.1.3" -cosmwasm-std = {version=">=1.1.3",default-features = false} +cosmwasm-std = {version="=1.1.3",default-features = false} schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } From 8369a585e35f199cfa71283474fb60d6eeb24a4d Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 12:33:18 +0545 Subject: [PATCH 26/64] fix: update test utils --- libraries/rust/test-utils/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/rust/test-utils/Cargo.toml b/libraries/rust/test-utils/Cargo.toml index c1b9ccce5..3bea284fc 100644 --- a/libraries/rust/test-utils/Cargo.toml +++ b/libraries/rust/test-utils/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] serde = { workspace=true} serde_json = "1.0" -cosmwasm-std = {workspace=true, features = ["iterator", "ibc3"]} +cosmwasm-std = {workspace=true} prost = { workspace=true} ibc-proto = { workspace=true} #ibc = { version = "0.32.0", default-features = false, features = ["parity-scale-codec", "mocks-no-std", "serde", "borsh"]} From 51cfaf17603bb6a05c806f204e9e082c5da59908 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 12:35:04 +0545 Subject: [PATCH 27/64] fix: point to downgraded xcall --- Cargo.toml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 25b258aa7..1a0b0bb69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,10 +23,11 @@ schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", branch="fix-raw"} -cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="main"} -cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="main"} -cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="main" } -cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="main" } + +cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3"} +cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3"} +cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3" } +cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3" } cw2 = {version="1.0.1",default-features = false} ibc-proto = { version = "0.26.0", default-features = false} From 6f1151858a52c8a0a0608d9b06245e628b04bf7f Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 12:57:24 +0545 Subject: [PATCH 28/64] fix: lower multi test --- Cargo.lock | 3130 ----------------- Cargo.toml | 1 + contracts/cosmwasm-vm/cw-common/Cargo.toml | 2 +- .../cosmwasm-vm/cw-mock-ibc-core/Cargo.toml | 2 +- .../cw-wasm-light-client/Cargo.toml | 2 +- libraries/rust/test-utils/Cargo.toml | 9 +- 6 files changed, 8 insertions(+), 3138 deletions(-) delete mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index bbc519d6f..000000000 --- a/Cargo.lock +++ /dev/null @@ -1,3130 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", -] - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - -[[package]] -name = "bech32" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bnum" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128a44527fc0d6abf05f9eda748b9027536e12dff93f5acc8449f51583309350" - -[[package]] -name = "borsh" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" -dependencies = [ - "borsh-derive", - "hashbrown 0.13.2", -] - -[[package]] -name = "borsh-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" -dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", - "proc-macro-crate 0.1.5", - "proc-macro2 1.0.69", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" -dependencies = [ - "serde", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" -dependencies = [ - "num-traits", -] - -[[package]] -name = "common" -version = "0.1.0" -dependencies = [ - "bytes", - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "debug_print", - "derive_more", - "displaydoc", - "dyn-clone", - "hex", - "hex-literal 0.3.4", - "ibc-proto 0.26.0", - "ics23 0.9.0", - "pbjson", - "pbjson-types", - "prost 0.11.9", - "prost-types", - "rlp-derive", - "rustc-hex", - "safe-regex", - "serde", - "serde-json-wasm 0.5.1", - "serde_json", - "sha2 0.10.8", - "sha3", - "subtle-encoding", - "tendermint 0.29.1", - "test-log", - "test-utils", - "time", - "tracing-subscriber", -] - -[[package]] -name = "common" -version = "0.1.0" -source = "git+https://github.com/icon-project/IBC-Integration.git?branch=main#49ff4ade6cd0d2dfe3d7b58a5d74fd4ea6294633" -dependencies = [ - "bytes", - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "debug_print", - "derive_more", - "displaydoc", - "dyn-clone", - "hex", - "hex-literal 0.3.4", - "ibc-proto 0.26.0", - "ics23 0.9.0", - "pbjson", - "pbjson-types", - "prost 0.11.9", - "prost-types", - "rlp-derive", - "rustc-hex", - "safe-regex", - "serde", - "serde-json-wasm 0.5.1", - "serde_json", - "sha2 0.10.8", - "sha3", - "subtle-encoding", - "tendermint 0.29.1", - "time", -] - -[[package]] -name = "const-oid" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "cosmwasm" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8709ce7dabeac33f4132cab84fda3796ac484d82c91ff5ccfb4ed61227af4bb5" -dependencies = [ - "base64 0.11.0", - "schemars 0.5.1", - "serde", - "serde-json-wasm 0.1.3", - "snafu", -] - -[[package]] -name = "cosmwasm-crypto" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6fb22494cf7d23d0c348740e06e5c742070b2991fd41db77bba0bcfbae1a723" -dependencies = [ - "digest 0.10.7", - "ed25519-zebra", - "k256 0.13.1", - "rand_core 0.6.4", - "thiserror", -] - -[[package]] -name = "cosmwasm-derive" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e199424486ea97d6b211db6387fd72e26b4a439d40cc23140b2d8305728055b" -dependencies = [ - "syn 1.0.109", -] - -[[package]] -name = "cosmwasm-schema" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fef683a9c1c4eabd6d31515719d0d2cc66952c4c87f7eb192bfc90384517dc34" -dependencies = [ - "cosmwasm-schema-derive", - "schemars 0.8.15", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "cosmwasm-schema-derive" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9567025acbb4c0c008178393eb53b3ac3c2e492c25949d3bf415b9cbe80772d8" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "cosmwasm-std" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d89d680fb60439b7c5947b15f9c84b961b88d1f8a3b20c4bd178a3f87db8bae" -dependencies = [ - "base64 0.21.4", - "bnum", - "cosmwasm-crypto", - "cosmwasm-derive", - "derivative", - "forward_ref", - "hex", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "sha2 0.10.8", - "thiserror", -] - -[[package]] -name = "cosmwasm-storage" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a1c574d30feffe4b8121e61e839c231a5ce21901221d2fb4d5c945968a4f00" -dependencies = [ - "cosmwasm-std", - "serde", -] - -[[package]] -name = "cpufeatures" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" -dependencies = [ - "libc", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-bigint" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-ng" -version = "4.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.6.4", - "subtle-ng", - "zeroize", -] - -[[package]] -name = "cw-common" -version = "0.1.0" -dependencies = [ - "bech32", - "bytes", - "common 0.1.0", - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall-lib", - "debug_print", - "getrandom", - "hex", - "hex-buffer-serde", - "ibc-proto 0.26.0", - "prost 0.11.9", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "serde_json", - "test-utils", -] - -[[package]] -name = "cw-ibc-core" -version = "0.1.0" -dependencies = [ - "anyhow", - "bytes", - "common 0.1.0", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-icon-light-client", - "cw-multi-test", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2", - "debug_print", - "getrandom", - "hex", - "hex-literal 0.4.1", - "prost 0.11.9", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "sha2 0.10.8", - "sha3", - "test-utils", - "thiserror", -] - -[[package]] -name = "cw-icon-light-client" -version = "0.1.0" -dependencies = [ - "bytes", - "common 0.1.0", - "cosmwasm", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-light-client-common", - "cw-storage-plus 0.15.1", - "cw2", - "debug_print", - "getrandom", - "hex", - "hex-literal 0.4.1", - "prost 0.11.9", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "sha2 0.10.8", - "sha3", - "test-utils", - "thiserror", -] - -[[package]] -name = "cw-integration" -version = "0.1.0" -dependencies = [ - "anyhow", - "common 0.1.0", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-ibc-core", - "cw-icon-light-client", - "cw-mock-dapp", - "cw-mock-dapp-multi", - "cw-mock-ibc-core", - "cw-multi-test", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall", - "cw-xcall-ibc-connection", - "cw-xcall-lib", - "hex", - "ibc 0.32.0", - "prost 0.11.9", - "strum", - "strum_macros", - "test-utils", -] - -[[package]] -name = "cw-light-client-common" -version = "0.1.0" -dependencies = [ - "common 0.1.0", - "cosmwasm", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-storage-plus 0.15.1", - "debug_print", - "getrandom", - "hex", - "hex-literal 0.4.1", - "prost 0.11.9", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "test-utils", - "thiserror", -] - -[[package]] -name = "cw-mock-dapp" -version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=main#caaf7a0bfb8513504b08900124ca242b9e6b2466" -dependencies = [ - "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=main)", - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall-lib", - "cw2", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "thiserror", -] - -[[package]] -name = "cw-mock-dapp-multi" -version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=main#caaf7a0bfb8513504b08900124ca242b9e6b2466" -dependencies = [ - "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=main)", - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall-lib", - "cw2", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "thiserror", -] - -[[package]] -name = "cw-mock-ibc-connection" -version = "0.1.0" -dependencies = [ - "common 0.1.0", - "cosmwasm", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall", - "cw-xcall-lib", - "cw2", - "debug_print", - "getrandom", - "hex", - "schemars 0.8.15", - "serde", - "thiserror", -] - -[[package]] -name = "cw-mock-ibc-core" -version = "0.1.0" -dependencies = [ - "common 0.1.0", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall", - "cw2", - "getrandom", - "hex", - "schemars 0.8.15", - "serde", - "thiserror", -] - -[[package]] -name = "cw-mock-ibc-dapp" -version = "0.1.0" -dependencies = [ - "common 0.1.0", - "cosmwasm", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2", - "debug_print", - "getrandom", - "hex", - "schemars 0.8.15", - "serde", - "thiserror", -] - -[[package]] -name = "cw-multi-test" -version = "0.16.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "127c7bb95853b8e828bdab97065c81cb5ddc20f7339180b61b2300565aaa99d1" -dependencies = [ - "anyhow", - "cosmwasm-std", - "cw-storage-plus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cw-utils", - "derivative", - "itertools", - "k256 0.11.6", - "prost 0.9.0", - "schemars 0.8.15", - "serde", - "thiserror", -] - -[[package]] -name = "cw-storage-plus" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6cf70ef7686e2da9ad7b067c5942cd3e88dd9453f7af42f54557f8af300fb0" -dependencies = [ - "cosmwasm-std", - "schemars 0.8.15", - "serde", -] - -[[package]] -name = "cw-storage-plus" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0e92a069d62067f3472c62e30adedb4cab1754725c0f2a682b3128d2bf3c79" -dependencies = [ - "cosmwasm-std", - "schemars 0.8.15", - "serde", -] - -[[package]] -name = "cw-storage-plus" -version = "1.1.0" -source = "git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw#238b520c3e193226143eedb717a3ed76187d11de" -dependencies = [ - "cosmwasm-std", - "schemars 0.8.15", - "serde", -] - -[[package]] -name = "cw-utils" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9f351a4e4d81ef7c890e44d903f8c0bdcdc00f094fd3a181eaf70c0eec7a3a" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw2", - "schemars 0.8.15", - "semver", - "serde", - "thiserror", -] - -[[package]] -name = "cw-wasm-light-client" -version = "0.1.0" -dependencies = [ - "base64 0.13.1", - "bytes", - "common 0.1.0", - "cosmwasm", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-light-client-common", - "cw2", - "debug_print", - "getrandom", - "hex", - "hex-literal 0.4.1", - "ibc 0.15.0", - "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git)", - "ics07-tendermint-cw", - "ics08-wasm", - "prost 0.11.9", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "sha2 0.10.8", - "sha3", - "tendermint-proto 0.28.0", - "test-utils", - "thiserror", -] - -[[package]] -name = "cw-xcall" -version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=main#caaf7a0bfb8513504b08900124ca242b9e6b2466" -dependencies = [ - "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=main)", - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall-lib", - "cw2", - "debug_print", - "schemars 0.8.15", - "serde", - "thiserror", -] - -[[package]] -name = "cw-xcall-ibc-connection" -version = "0.1.0" -dependencies = [ - "common 0.1.0", - "cosmwasm", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall", - "cw-xcall-lib", - "cw2", - "debug_print", - "getrandom", - "hex", - "schemars 0.8.15", - "serde", - "thiserror", -] - -[[package]] -name = "cw-xcall-lib" -version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=main#caaf7a0bfb8513504b08900124ca242b9e6b2466" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2", - "debug_print", - "schemars 0.8.15", - "serde", - "thiserror", -] - -[[package]] -name = "cw2" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9431d14f64f49e41c6ef5561ed11a5391c417d0cb16455dea8cdcb9037a8d197" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schemars 0.8.15", - "serde", - "thiserror", -] - -[[package]] -name = "debug_print" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f215f9b7224f49fb73256115331f677d868b34d18b65dbe4db392e6021eea90" - -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case 0.4.0", - "proc-macro2 1.0.69", - "quote 1.0.33", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "const-oid", - "crypto-common", - "subtle", -] - -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - -[[package]] -name = "dyn-clone" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" - -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der 0.6.1", - "elliptic-curve 0.12.3", - "rfc6979 0.3.1", - "signature 1.6.4", -] - -[[package]] -name = "ecdsa" -version = "0.16.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" -dependencies = [ - "der 0.7.8", - "digest 0.10.7", - "elliptic-curve 0.13.6", - "rfc6979 0.4.0", - "signature 2.1.0", - "spki 0.7.2", -] - -[[package]] -name = "ed25519" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" -dependencies = [ - "signature 1.6.4", -] - -[[package]] -name = "ed25519-consensus" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" -dependencies = [ - "curve25519-dalek-ng", - "hex", - "rand_core 0.6.4", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "ed25519-zebra" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" -dependencies = [ - "curve25519-dalek", - "hashbrown 0.12.3", - "hex", - "rand_core 0.6.4", - "serde", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct 0.1.1", - "crypto-bigint 0.4.9", - "der 0.6.1", - "digest 0.10.7", - "ff 0.12.1", - "generic-array", - "group 0.12.1", - "pkcs8 0.9.0", - "rand_core 0.6.4", - "sec1 0.3.0", - "subtle", - "zeroize", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" -dependencies = [ - "base16ct 0.2.0", - "crypto-bigint 0.5.3", - "digest 0.10.7", - "ff 0.13.0", - "generic-array", - "group 0.13.0", - "pkcs8 0.10.2", - "rand_core 0.6.4", - "sec1 0.7.3", - "subtle", - "zeroize", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "erased-serde" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" -dependencies = [ - "serde", -] - -[[package]] -name = "errno" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "eyre" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" -dependencies = [ - "indenter", - "once_cell", -] - -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "fixed-hash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" -dependencies = [ - "byteorder", - "rand", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - -[[package]] -name = "flex-error" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c606d892c9de11507fa0dcffc116434f94e105d0bbdc4e405b61519464c49d7b" -dependencies = [ - "eyre", - "paste", -] - -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futures" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-io" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-sink" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" - -[[package]] -name = "futures-task" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" - -[[package]] -name = "futures-util" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" -dependencies = [ - "futures-core", - "futures-sink", - "futures-task", - "pin-project-lite", - "pin-utils", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", - "zeroize", -] - -[[package]] -name = "getrandom" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff 0.12.1", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff 0.13.0", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.6", -] - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.3", -] - -[[package]] -name = "hashbrown" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-buffer-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e84645a601cf4a58f40673d51c111d1b5f847b711559c076ebcb779606a6d0" -dependencies = [ - "hex", - "serde", -] - -[[package]] -name = "hex-literal" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "home" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "ibc" -version = "0.15.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" -dependencies = [ - "cosmwasm-schema", - "derive_more", - "flex-error", - "hex", - "ibc-derive", - "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", - "ics23 0.10.0", - "log", - "num-traits", - "parity-scale-codec", - "primitive-types", - "prost 0.11.9", - "safe-regex", - "scale-info", - "serde", - "serde_derive", - "serde_json", - "sha2 0.10.8", - "subtle-encoding", - "tendermint 0.28.0", - "tendermint-proto 0.28.0", - "time", - "tracing", - "uint", -] - -[[package]] -name = "ibc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030b54b02c3f35ea7265da2beedf0d7d22492208919a6582f980ff3eae82c2d0" -dependencies = [ - "bytes", - "cfg-if", - "derive_more", - "displaydoc", - "dyn-clone", - "erased-serde", - "ibc-proto 0.26.0", - "ics23 0.9.0", - "num-traits", - "parity-scale-codec", - "primitive-types", - "prost 0.11.9", - "safe-regex", - "scale-info", - "serde", - "serde_derive", - "serde_json", - "sha2 0.10.8", - "subtle-encoding", - "tendermint 0.29.1", - "tendermint-light-client-verifier 0.29.1", - "tendermint-proto 0.29.1", - "time", - "tracing", - "uint", -] - -[[package]] -name = "ibc-derive" -version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" -dependencies = [ - "convert_case 0.6.0", - "proc-macro-crate 1.3.1", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "ibc-proto" -version = "0.18.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" -dependencies = [ - "base64 0.13.1", - "bytes", - "prost 0.11.9", - "schemars 0.8.15", - "serde", - "tendermint-proto 0.28.0", -] - -[[package]] -name = "ibc-proto" -version = "0.18.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git#2a8ed31167e6d5444337ac49cb4d0b916cb22677" -dependencies = [ - "base64 0.13.1", - "bytes", - "prost 0.11.9", - "schemars 0.8.15", - "serde", - "tendermint-proto 0.28.0", -] - -[[package]] -name = "ibc-proto" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9303a1308c886aea769ef0667c5caa422a78b01e9f8177fea8b91b08a4ff50c" -dependencies = [ - "base64 0.13.1", - "borsh", - "bytes", - "flex-error", - "parity-scale-codec", - "prost 0.11.9", - "scale-info", - "serde", - "subtle-encoding", - "tendermint-proto 0.29.1", -] - -[[package]] -name = "ics07-tendermint" -version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" -dependencies = [ - "bytes", - "flex-error", - "hex", - "ibc 0.15.0", - "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", - "ics23 0.10.0", - "log", - "prost 0.11.9", - "serde", - "serde_json", - "subtle-encoding", - "tendermint 0.28.0", - "tendermint-light-client-verifier 0.28.0", - "tendermint-proto 0.28.0", - "time", -] - -[[package]] -name = "ics07-tendermint-cw" -version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" -dependencies = [ - "byteorder", - "cosmwasm-schema", - "cosmwasm-std", - "derive_more", - "digest 0.10.7", - "ed25519", - "ed25519-consensus", - "ed25519-zebra", - "hex", - "ibc 0.15.0", - "ibc-derive", - "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", - "ics07-tendermint", - "ics08-wasm", - "ics23 0.10.0", - "prost 0.11.9", - "schemars 0.8.15", - "serde", - "sha2 0.10.8", - "sha3", - "tendermint 0.28.0", - "tendermint-light-client-verifier 0.28.0", - "tendermint-proto 0.28.0", - "thiserror", -] - -[[package]] -name = "ics08-wasm" -version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" -dependencies = [ - "cosmwasm-schema", - "hex", - "ibc 0.15.0", - "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", - "prost 0.11.9", - "serde", - "tendermint-proto 0.28.0", -] - -[[package]] -name = "ics23" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca44b684ce1859cff746ff46f5765ab72e12e3c06f76a8356db8f9a2ecf43f17" -dependencies = [ - "anyhow", - "bytes", - "hex", - "prost 0.11.9", - "ripemd", - "sha2 0.10.8", - "sha3", -] - -[[package]] -name = "ics23" -version = "0.10.0" -source = "git+https://github.com/cosmos/ics23?rev=74ce807b7be39a7e0afb4e2efb8e28a57965f57b#74ce807b7be39a7e0afb4e2efb8e28a57965f57b" -dependencies = [ - "anyhow", - "bytes", - "hex", - "prost 0.11.9", -] - -[[package]] -name = "impl-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "indenter" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" - -[[package]] -name = "indexmap" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" -dependencies = [ - "equivalent", - "hashbrown 0.14.1", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" - -[[package]] -name = "k256" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" -dependencies = [ - "cfg-if", - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.8", -] - -[[package]] -name = "k256" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" -dependencies = [ - "cfg-if", - "ecdsa 0.16.8", - "elliptic-curve 0.13.6", - "once_cell", - "sha2 0.10.8", - "signature 2.1.0", -] - -[[package]] -name = "keccak" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.149" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" - -[[package]] -name = "linux-raw-sys" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "multimap" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "num-traits" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "parity-scale-codec" -version = "3.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" -dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pbjson" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048f9ac93c1eab514f9470c4bc8d97ca2a0a236b84f45cc19d69a59fc11467f6" -dependencies = [ - "base64 0.13.1", - "serde", -] - -[[package]] -name = "pbjson-build" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdbb7b706f2afc610f3853550cdbbf6372fd324824a087806bd4480ea4996e24" -dependencies = [ - "heck", - "itertools", - "prost 0.11.9", - "prost-types", -] - -[[package]] -name = "pbjson-types" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a88c8d87f99a4ac14325e7a4c24af190fca261956e3b82dd7ed67e77e6c7043" -dependencies = [ - "bytes", - "chrono", - "pbjson", - "pbjson-build", - "prost 0.11.9", - "prost-build", - "serde", -] - -[[package]] -name = "petgraph" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" -dependencies = [ - "fixedbitset", - "indexmap", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der 0.6.1", - "spki 0.6.0", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der 0.7.8", - "spki 0.7.2", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "prettyplease" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" -dependencies = [ - "proc-macro2 1.0.69", - "syn 1.0.109", -] - -[[package]] -name = "primitive-types" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-serde", - "uint", -] - -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml", -] - -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit", -] - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "proc-macro2" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prost" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" -dependencies = [ - "bytes", - "prost-derive 0.9.0", -] - -[[package]] -name = "prost" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" -dependencies = [ - "bytes", - "prost-derive 0.11.9", -] - -[[package]] -name = "prost-build" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" -dependencies = [ - "bytes", - "heck", - "itertools", - "lazy_static", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost 0.11.9", - "prost-types", - "regex", - "syn 1.0.109", - "tempfile", - "which", -] - -[[package]] -name = "prost-derive" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "prost-derive" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "prost-types" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" -dependencies = [ - "prost 0.11.9", -] - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2 1.0.69", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "regex" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata 0.4.1", - "regex-syntax 0.8.1", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.1", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33" - -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint 0.4.9", - "hmac", - "zeroize", -] - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "rustix" -version = "0.38.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" -dependencies = [ - "bitflags 2.4.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - -[[package]] -name = "ryu" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" - -[[package]] -name = "safe-proc-macro2" -version = "1.0.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd85be67db87168aa3c13fd0da99f48f2ab005dccad5af5626138dc1df20eb6" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "safe-quote" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e530f7831f3feafcd5f1aae406ac205dd998436b4007c8e80f03eca78a88f7" -dependencies = [ - "safe-proc-macro2", -] - -[[package]] -name = "safe-regex" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15289bf322e0673d52756a18194167f2378ec1a15fe884af6e2d2cb934822b0" -dependencies = [ - "safe-regex-macro", -] - -[[package]] -name = "safe-regex-compiler" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba76fae590a2aa665279deb1f57b5098cbace01a0c5e60e262fcf55f7c51542" -dependencies = [ - "safe-proc-macro2", - "safe-quote", -] - -[[package]] -name = "safe-regex-macro" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c2e96b5c03f158d1b16ba79af515137795f4ad4e8de3f790518aae91f1d127" -dependencies = [ - "safe-proc-macro2", - "safe-regex-compiler", -] - -[[package]] -name = "scale-info" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" -dependencies = [ - "bitvec", - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "schemars" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "273d9b56198caf703e271dcc07b28f2e794971750ace6585399d40e2af9f4823" -dependencies = [ - "schemars_derive 0.5.0", - "serde", - "serde_json", -] - -[[package]] -name = "schemars" -version = "0.8.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" -dependencies = [ - "dyn-clone", - "schemars_derive 0.8.15", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ab7f0b9b64633747a68dce4ed6318bbf30e3befe67df7624ad83abb7295c09" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "serde_derive_internals 0.25.0", - "syn 1.0.109", -] - -[[package]] -name = "schemars_derive" -version = "0.8.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "serde_derive_internals 0.26.0", - "syn 1.0.109", -] - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct 0.1.1", - "der 0.6.1", - "generic-array", - "pkcs8 0.9.0", - "subtle", - "zeroize", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct 0.2.0", - "der 0.7.8", - "generic-array", - "pkcs8 0.10.2", - "subtle", - "zeroize", -] - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "serde" -version = "1.0.188" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-json-wasm" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77cf509484e297252a195b1338a6d45843fe11ef234259f67649e8729934f443" -dependencies = [ - "serde", -] - -[[package]] -name = "serde-json-wasm" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_bytes" -version = "0.11.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.188" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "serde_derive_internals" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dbab34ca63057a1f15280bdf3c39f2b1eb1b54c17e98360e511637aef7418c6" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "serde_derive_internals" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "serde_json" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_repr" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest 0.10.7", - "keccak", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "signature" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "smallvec" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" - -[[package]] -name = "snafu" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0bf93d08d6a44363b47d737f1f5bebbf5e6a1eaaa3d4c128ceeaca6b718292" -dependencies = [ - "doc-comment", - "snafu-derive", -] - -[[package]] -name = "snafu-derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624e94bd38e471f67883b467711e7a7ad7dbe284f5fb7e661dc8a671fc5b26a0" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der 0.6.1", -] - -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der 0.7.8", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" - -[[package]] -name = "strum_macros" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" -dependencies = [ - "heck", - "proc-macro2 1.0.69", - "quote 1.0.33", - "rustversion", - "syn 1.0.109", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "subtle-encoding" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dcb1ed7b8330c5eed5441052651dd7a12c75e2ed88f2ec024ae1fa3a5e59945" -dependencies = [ - "zeroize", -] - -[[package]] -name = "subtle-ng" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "unicode-ident", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tempfile" -version = "3.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall", - "rustix", - "windows-sys", -] - -[[package]] -name = "tendermint" -version = "0.28.0" -source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" -dependencies = [ - "bytes", - "digest 0.10.7", - "ed25519", - "flex-error", - "futures", - "num-traits", - "once_cell", - "prost 0.11.9", - "prost-types", - "serde", - "serde_bytes", - "serde_json", - "serde_repr", - "signature 1.6.4", - "subtle", - "subtle-encoding", - "tendermint-proto 0.28.0", - "time", - "zeroize", -] - -[[package]] -name = "tendermint" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda53c85447577769cdfc94c10a56f34afef2c00e4108badb57fce6b1a0c75eb" -dependencies = [ - "bytes", - "digest 0.10.7", - "ed25519", - "ed25519-consensus", - "flex-error", - "futures", - "num-traits", - "once_cell", - "prost 0.11.9", - "prost-types", - "serde", - "serde_bytes", - "serde_json", - "serde_repr", - "sha2 0.10.8", - "signature 1.6.4", - "subtle", - "subtle-encoding", - "tendermint-proto 0.29.1", - "time", - "zeroize", -] - -[[package]] -name = "tendermint-light-client-verifier" -version = "0.28.0" -source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" -dependencies = [ - "derive_more", - "flex-error", - "serde", - "tendermint 0.28.0", - "time", -] - -[[package]] -name = "tendermint-light-client-verifier" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c3dc3c75f7a5708ac0bf98374b2b1a2cf17b3a45ddfd5faab3c111aff7fc0e" -dependencies = [ - "derive_more", - "flex-error", - "serde", - "tendermint 0.29.1", - "time", -] - -[[package]] -name = "tendermint-proto" -version = "0.28.0" -source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" -dependencies = [ - "bytes", - "flex-error", - "num-derive", - "num-traits", - "prost 0.11.9", - "prost-types", - "serde", - "serde_bytes", - "subtle-encoding", - "time", -] - -[[package]] -name = "tendermint-proto" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c943f78c929cdf14553842f705f2c30324bc35b9179caaa5c9b80620f60652e6" -dependencies = [ - "bytes", - "flex-error", - "num-derive", - "num-traits", - "prost 0.11.9", - "prost-types", - "serde", - "serde_bytes", - "subtle-encoding", - "time", -] - -[[package]] -name = "test-log" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9601d162c1d77e62c1ea0bc8116cd1caf143ce3af947536c3c9052a1677fe0c" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "test-utils" -version = "0.1.0" -dependencies = [ - "common 0.1.0", - "cosmwasm-std", - "cw-multi-test", - "getrandom", - "hex", - "hex-literal 0.4.1", - "ibc-proto 0.26.0", - "prost 0.11.9", - "serde", - "serde_json", -] - -[[package]] -name = "thiserror" -version = "1.0.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "time" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" -dependencies = [ - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" - -[[package]] -name = "time-macros" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" -dependencies = [ - "time-core", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-serde" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" -dependencies = [ - "serde", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "serde", - "serde_json", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", - "tracing-serde", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "winnow" -version = "0.5.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] diff --git a/Cargo.toml b/Cargo.toml index 1a0b0bb69..84e0c8592 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,7 @@ serde_json = "1.0.96" bytes = { version = "1.4.0", default-features = false } #thiserror = { version = "1.0.39" } hex ={ version = "0.4.3", default-features = false } +hex-literal={version ="*"} debug_print = "1.0.0" [profile.release] diff --git a/contracts/cosmwasm-vm/cw-common/Cargo.toml b/contracts/cosmwasm-vm/cw-common/Cargo.toml index 6b36c9903..d1513f5a1 100644 --- a/contracts/cosmwasm-vm/cw-common/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-common/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] cosmwasm-schema = {workspace=true} -cosmwasm-std = {workspace=true, features=["ibc3"]} +cosmwasm-std = { workspace=true} serde = { workspace=true} cw-storage-plus = {workspace=true} serde_json = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml b/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml index c1cba6692..16eb8ce6d 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml @@ -51,7 +51,7 @@ thiserror = { workspace=true} cw-common = { path="../cw-common" } common = { path="../../../libraries/rust/common", default-features = false } hex={workspace=true} -cw-xcall={package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="main"} +cw-xcall={workspace=true} [dev-dependencies] getrandom = {version = "0.2", default-features = false, features = ["custom"]} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml index 6a7c127e1..95aa45f70 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml @@ -32,7 +32,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] cosmwasm-schema = "1.1.3" -cosmwasm-std = {version="1.1.3",default-features = false} +cosmwasm-std = { workspace=true} schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } diff --git a/libraries/rust/test-utils/Cargo.toml b/libraries/rust/test-utils/Cargo.toml index 3bea284fc..7ef09ad6b 100644 --- a/libraries/rust/test-utils/Cargo.toml +++ b/libraries/rust/test-utils/Cargo.toml @@ -7,15 +7,14 @@ edition = "2021" [dependencies] serde = { workspace=true} -serde_json = "1.0" +serde_json = {workspace=true} cosmwasm-std = {workspace=true} prost = { workspace=true} ibc-proto = { workspace=true} -#ibc = { version = "0.32.0", default-features = false, features = ["parity-scale-codec", "mocks-no-std", "serde", "borsh"]} -hex="*" -hex-literal="*" +hex={workspace=true} +hex-literal={workspace=true} common={path="../common"} -cw-multi-test = "0.16.4" +cw-multi-test = "0.15.1" [dev-dependencies] From 98562f6fb5c315016f8c1681aa9d648bd8e3b2ec Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 13:39:46 +0545 Subject: [PATCH 29/64] fix: lock on 1.6 --- Cargo.toml | 2 +- contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml | 2 +- contracts/cosmwasm-vm/cw-integration/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 84e0c8592..e28cd0310 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ version="0.1.0" #cosmwasm-schema = "1.2.2" #schemars = "0.8.12" cosmwasm-schema = "1.1.3" -cosmwasm-std = {version="=1.1.3",default-features = false} +cosmwasm-std = {version="=1.1.6",default-features = false} schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } diff --git a/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml b/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml index ae1e8cf5f..897b4476a 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml @@ -50,7 +50,7 @@ debug_print = {workspace=true} [dev-dependencies] getrandom = {version = "0.2", default-features = false, features = ["custom"]} -cw-multi-test = "0.16.4" +cw-multi-test = "0.15.1" cw-icon-light-client = { path="../cw-icon-light-client",default-features = false } anyhow="1.0.71" test-utils={path="../../../libraries/rust/test-utils"} diff --git a/contracts/cosmwasm-vm/cw-integration/Cargo.toml b/contracts/cosmwasm-vm/cw-integration/Cargo.toml index 39b4e2879..e8d79a9cc 100644 --- a/contracts/cosmwasm-vm/cw-integration/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-integration/Cargo.toml @@ -20,7 +20,7 @@ strum_macros = "0.24" [dev-dependencies] hex = "0.4.3" -cw-multi-test = "0.16.4" +cw-multi-test = "0.15.1" cw-xcall-ibc-connection = { path="../cw-xcall-ibc-connection" } cw-mock-ibc-core = { path="../cw-mock-ibc-core" } cw-mock-dapp = { workspace=true} From 81a731156db25e8149fb78f78489bc21e8418334 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 14:31:22 +0545 Subject: [PATCH 30/64] fix: revert downgrade --- Cargo.lock | 2993 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 16 +- 2 files changed, 3001 insertions(+), 8 deletions(-) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..682fcf604 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2993 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive", + "hashbrown 0.13.2", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate 0.1.5", + "proc-macro2 1.0.69", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +dependencies = [ + "serde", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "num-traits", +] + +[[package]] +name = "common" +version = "0.1.0" +dependencies = [ + "bytes", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "debug_print", + "derive_more", + "displaydoc", + "dyn-clone", + "hex", + "hex-literal 0.3.4", + "ibc-proto 0.26.0", + "ics23 0.9.0", + "pbjson", + "pbjson-types", + "prost 0.11.9", + "prost-types", + "rlp-derive", + "rustc-hex", + "safe-regex", + "serde", + "serde-json-wasm 0.5.1", + "serde_json", + "sha2 0.10.8", + "sha3", + "subtle-encoding", + "tendermint 0.29.1", + "test-log", + "test-utils", + "time", + "tracing-subscriber", +] + +[[package]] +name = "common" +version = "0.1.0" +source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#98562f6fb5c315016f8c1681aa9d648bd8e3b2ec" +dependencies = [ + "bytes", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "debug_print", + "derive_more", + "displaydoc", + "dyn-clone", + "hex", + "hex-literal 0.3.4", + "ibc-proto 0.26.0", + "ics23 0.9.0", + "pbjson", + "pbjson-types", + "prost 0.11.9", + "prost-types", + "rlp-derive", + "rustc-hex", + "safe-regex", + "serde", + "serde-json-wasm 0.5.1", + "serde_json", + "sha2 0.10.8", + "sha3", + "subtle-encoding", + "tendermint 0.29.1", + "time", +] + +[[package]] +name = "const-oid" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "cosmwasm" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8709ce7dabeac33f4132cab84fda3796ac484d82c91ff5ccfb4ed61227af4bb5" +dependencies = [ + "base64 0.11.0", + "schemars 0.5.1", + "serde", + "serde-json-wasm 0.1.3", + "snafu", +] + +[[package]] +name = "cosmwasm-crypto" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6fb22494cf7d23d0c348740e06e5c742070b2991fd41db77bba0bcfbae1a723" +dependencies = [ + "digest 0.10.7", + "ed25519-zebra", + "k256", + "rand_core 0.6.4", + "thiserror", +] + +[[package]] +name = "cosmwasm-derive" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e199424486ea97d6b211db6387fd72e26b4a439d40cc23140b2d8305728055b" +dependencies = [ + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-schema" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fef683a9c1c4eabd6d31515719d0d2cc66952c4c87f7eb192bfc90384517dc34" +dependencies = [ + "cosmwasm-schema-derive", + "schemars 0.8.15", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9567025acbb4c0c008178393eb53b3ac3c2e492c25949d3bf415b9cbe80772d8" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-std" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1240e76655f4b858b3fb94befbf48e253e92c6640d9d674a1491d15f10bc4d72" +dependencies = [ + "base64 0.13.1", + "cosmwasm-crypto", + "cosmwasm-derive", + "derivative", + "forward_ref", + "hex", + "schemars 0.8.15", + "serde", + "serde-json-wasm 0.4.1", + "thiserror", + "uint", +] + +[[package]] +name = "cosmwasm-storage" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4ffcc2d75f4957ec4e7e9f059b45c5de4edfac8f1ec41df5a42b962ccb6b3" +dependencies = [ + "cosmwasm-std", + "serde", +] + +[[package]] +name = "cpufeatures" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-ng" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.6.4", + "subtle-ng", + "zeroize", +] + +[[package]] +name = "cw-common" +version = "0.1.0" +dependencies = [ + "bech32", + "bytes", + "common 0.1.0", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-xcall-lib", + "debug_print", + "getrandom", + "hex", + "hex-buffer-serde", + "ibc-proto 0.26.0", + "prost 0.11.9", + "schemars 0.8.15", + "serde", + "serde-json-wasm 0.5.1", + "serde_json", + "test-utils", +] + +[[package]] +name = "cw-ibc-core" +version = "0.1.0" +dependencies = [ + "anyhow", + "bytes", + "common 0.1.0", + "cosmwasm-schema", + "cosmwasm-std", + "cw-common", + "cw-icon-light-client", + "cw-multi-test", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw2 1.1.0", + "debug_print", + "getrandom", + "hex", + "hex-literal 0.4.1", + "prost 0.11.9", + "schemars 0.8.15", + "serde", + "serde-json-wasm 0.5.1", + "sha2 0.10.8", + "sha3", + "test-utils", + "thiserror", +] + +[[package]] +name = "cw-icon-light-client" +version = "0.1.0" +dependencies = [ + "bytes", + "common 0.1.0", + "cosmwasm", + "cosmwasm-schema", + "cosmwasm-std", + "cw-common", + "cw-light-client-common", + "cw-storage-plus 0.15.1", + "cw2 1.1.0", + "debug_print", + "getrandom", + "hex", + "hex-literal 0.4.1", + "prost 0.11.9", + "schemars 0.8.15", + "serde", + "serde-json-wasm 0.5.1", + "sha2 0.10.8", + "sha3", + "test-utils", + "thiserror", +] + +[[package]] +name = "cw-integration" +version = "0.1.0" +dependencies = [ + "anyhow", + "common 0.1.0", + "cosmwasm-schema", + "cosmwasm-std", + "cw-common", + "cw-ibc-core", + "cw-icon-light-client", + "cw-mock-dapp", + "cw-mock-dapp-multi", + "cw-mock-ibc-core", + "cw-multi-test", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-xcall", + "cw-xcall-ibc-connection", + "cw-xcall-lib", + "hex", + "ibc 0.32.0", + "prost 0.11.9", + "strum", + "strum_macros", + "test-utils", +] + +[[package]] +name = "cw-light-client-common" +version = "0.1.0" +dependencies = [ + "common 0.1.0", + "cosmwasm", + "cosmwasm-schema", + "cosmwasm-std", + "cw-common", + "cw-storage-plus 0.15.1", + "debug_print", + "getrandom", + "hex", + "hex-literal 0.4.1", + "prost 0.11.9", + "schemars 0.8.15", + "serde", + "serde-json-wasm 0.5.1", + "test-utils", + "thiserror", +] + +[[package]] +name = "cw-mock-dapp" +version = "0.1.0" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#12179c66d5f5d0a4099ce78614f1858ad2deaab2" +dependencies = [ + "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-xcall-lib", + "cw2 1.1.0", + "schemars 0.8.15", + "serde", + "serde-json-wasm 0.5.1", + "thiserror", +] + +[[package]] +name = "cw-mock-dapp-multi" +version = "0.1.0" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#12179c66d5f5d0a4099ce78614f1858ad2deaab2" +dependencies = [ + "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-xcall-lib", + "cw2 1.1.0", + "schemars 0.8.15", + "serde", + "serde-json-wasm 0.5.1", + "thiserror", +] + +[[package]] +name = "cw-mock-ibc-connection" +version = "0.1.0" +dependencies = [ + "common 0.1.0", + "cosmwasm", + "cosmwasm-schema", + "cosmwasm-std", + "cw-common", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-xcall", + "cw-xcall-lib", + "cw2 1.1.0", + "debug_print", + "getrandom", + "hex", + "schemars 0.8.15", + "serde", + "thiserror", +] + +[[package]] +name = "cw-mock-ibc-core" +version = "0.1.0" +dependencies = [ + "common 0.1.0", + "cosmwasm-schema", + "cosmwasm-std", + "cw-common", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-xcall", + "cw2 1.1.0", + "getrandom", + "hex", + "schemars 0.8.15", + "serde", + "thiserror", +] + +[[package]] +name = "cw-mock-ibc-dapp" +version = "0.1.0" +dependencies = [ + "common 0.1.0", + "cosmwasm", + "cosmwasm-schema", + "cosmwasm-std", + "cw-common", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw2 1.1.0", + "debug_print", + "getrandom", + "hex", + "schemars 0.8.15", + "serde", + "thiserror", +] + +[[package]] +name = "cw-multi-test" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8e81b4a7821d5eeba0d23f737c16027b39a600742ca8c32eb980895ffd270f4" +dependencies = [ + "anyhow", + "cosmwasm-std", + "cosmwasm-storage", + "cw-storage-plus 0.15.1", + "cw-utils", + "derivative", + "itertools", + "prost 0.9.0", + "schemars 0.8.15", + "serde", + "thiserror", +] + +[[package]] +name = "cw-storage-plus" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6cf70ef7686e2da9ad7b067c5942cd3e88dd9453f7af42f54557f8af300fb0" +dependencies = [ + "cosmwasm-std", + "schemars 0.8.15", + "serde", +] + +[[package]] +name = "cw-storage-plus" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f0e92a069d62067f3472c62e30adedb4cab1754725c0f2a682b3128d2bf3c79" +dependencies = [ + "cosmwasm-std", + "schemars 0.8.15", + "serde", +] + +[[package]] +name = "cw-storage-plus" +version = "1.1.0" +source = "git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw#238b520c3e193226143eedb717a3ed76187d11de" +dependencies = [ + "cosmwasm-std", + "schemars 0.8.15", + "serde", +] + +[[package]] +name = "cw-utils" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae0b69fa7679de78825b4edeeec045066aa2b2c4b6e063d80042e565bb4da5c" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw2 0.15.1", + "schemars 0.8.15", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "cw-wasm-light-client" +version = "0.1.0" +dependencies = [ + "base64 0.13.1", + "bytes", + "common 0.1.0", + "cosmwasm", + "cosmwasm-schema", + "cosmwasm-std", + "cw-common", + "cw-light-client-common", + "cw2 1.1.0", + "debug_print", + "getrandom", + "hex", + "hex-literal 0.4.1", + "ibc 0.15.0", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git)", + "ics07-tendermint-cw", + "ics08-wasm", + "prost 0.11.9", + "schemars 0.8.15", + "serde", + "serde-json-wasm 0.5.1", + "sha2 0.10.8", + "sha3", + "tendermint-proto 0.28.0", + "test-utils", + "thiserror", +] + +[[package]] +name = "cw-xcall" +version = "0.1.0" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#12179c66d5f5d0a4099ce78614f1858ad2deaab2" +dependencies = [ + "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-xcall-lib", + "cw2 1.1.0", + "debug_print", + "schemars 0.8.15", + "serde", + "thiserror", +] + +[[package]] +name = "cw-xcall-ibc-connection" +version = "0.1.0" +dependencies = [ + "common 0.1.0", + "cosmwasm", + "cosmwasm-schema", + "cosmwasm-std", + "cw-common", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-xcall", + "cw-xcall-lib", + "cw2 1.1.0", + "debug_print", + "getrandom", + "hex", + "schemars 0.8.15", + "serde", + "thiserror", +] + +[[package]] +name = "cw-xcall-lib" +version = "0.1.0" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#12179c66d5f5d0a4099ce78614f1858ad2deaab2" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw2 1.1.0", + "debug_print", + "schemars 0.8.15", + "serde", + "thiserror", +] + +[[package]] +name = "cw2" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5abb8ecea72e09afff830252963cb60faf945ce6cef2c20a43814516082653da" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 0.15.1", + "schemars 0.8.15", + "serde", +] + +[[package]] +name = "cw2" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ac2dc7a55ad64173ca1e0a46697c31b7a5c51342f55a1e84a724da4eb99908" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schemars 0.8.15", + "serde", + "thiserror", +] + +[[package]] +name = "debug_print" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f215f9b7224f49fb73256115331f677d868b34d18b65dbe4db392e6021eea90" + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case 0.4.0", + "proc-macro2 1.0.69", + "quote 1.0.33", + "rustc_version", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", +] + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "dyn-clone" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" + +[[package]] +name = "ecdsa" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature 2.1.0", + "spki", +] + +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature 1.6.4", +] + +[[package]] +name = "ed25519-consensus" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" +dependencies = [ + "curve25519-dalek-ng", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek", + "hashbrown 0.12.3", + "hex", + "rand_core 0.6.4", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "elliptic-curve" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "erased-serde" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" +dependencies = [ + "serde", +] + +[[package]] +name = "errno" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "eyre" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flex-error" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c606d892c9de11507fa0dcffc116434f94e105d0bbdc4e405b61519464c49d7b" +dependencies = [ + "eyre", + "paste", +] + +[[package]] +name = "forward_ref" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-core", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", +] + +[[package]] +name = "hashbrown" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-buffer-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e84645a601cf4a58f40673d51c111d1b5f847b711559c076ebcb779606a6d0" +dependencies = [ + "hex", + "serde", +] + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "ibc" +version = "0.15.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +dependencies = [ + "cosmwasm-schema", + "derive_more", + "flex-error", + "hex", + "ibc-derive", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "ics23 0.10.0", + "log", + "num-traits", + "parity-scale-codec", + "primitive-types", + "prost 0.11.9", + "safe-regex", + "scale-info", + "serde", + "serde_derive", + "serde_json", + "sha2 0.10.8", + "subtle-encoding", + "tendermint 0.28.0", + "tendermint-proto 0.28.0", + "time", + "tracing", + "uint", +] + +[[package]] +name = "ibc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "030b54b02c3f35ea7265da2beedf0d7d22492208919a6582f980ff3eae82c2d0" +dependencies = [ + "bytes", + "cfg-if", + "derive_more", + "displaydoc", + "dyn-clone", + "erased-serde", + "ibc-proto 0.26.0", + "ics23 0.9.0", + "num-traits", + "parity-scale-codec", + "primitive-types", + "prost 0.11.9", + "safe-regex", + "scale-info", + "serde", + "serde_derive", + "serde_json", + "sha2 0.10.8", + "subtle-encoding", + "tendermint 0.29.1", + "tendermint-light-client-verifier 0.29.1", + "tendermint-proto 0.29.1", + "time", + "tracing", + "uint", +] + +[[package]] +name = "ibc-derive" +version = "0.1.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +dependencies = [ + "convert_case 0.6.0", + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "ibc-proto" +version = "0.18.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +dependencies = [ + "base64 0.13.1", + "bytes", + "prost 0.11.9", + "schemars 0.8.15", + "serde", + "tendermint-proto 0.28.0", +] + +[[package]] +name = "ibc-proto" +version = "0.18.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +dependencies = [ + "base64 0.13.1", + "bytes", + "prost 0.11.9", + "schemars 0.8.15", + "serde", + "tendermint-proto 0.28.0", +] + +[[package]] +name = "ibc-proto" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9303a1308c886aea769ef0667c5caa422a78b01e9f8177fea8b91b08a4ff50c" +dependencies = [ + "base64 0.13.1", + "borsh", + "bytes", + "flex-error", + "parity-scale-codec", + "prost 0.11.9", + "scale-info", + "serde", + "subtle-encoding", + "tendermint-proto 0.29.1", +] + +[[package]] +name = "ics07-tendermint" +version = "0.1.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +dependencies = [ + "bytes", + "flex-error", + "hex", + "ibc 0.15.0", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "ics23 0.10.0", + "log", + "prost 0.11.9", + "serde", + "serde_json", + "subtle-encoding", + "tendermint 0.28.0", + "tendermint-light-client-verifier 0.28.0", + "tendermint-proto 0.28.0", + "time", +] + +[[package]] +name = "ics07-tendermint-cw" +version = "0.1.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +dependencies = [ + "byteorder", + "cosmwasm-schema", + "cosmwasm-std", + "derive_more", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "ed25519-zebra", + "hex", + "ibc 0.15.0", + "ibc-derive", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "ics07-tendermint", + "ics08-wasm", + "ics23 0.10.0", + "prost 0.11.9", + "schemars 0.8.15", + "serde", + "sha2 0.10.8", + "sha3", + "tendermint 0.28.0", + "tendermint-light-client-verifier 0.28.0", + "tendermint-proto 0.28.0", + "thiserror", +] + +[[package]] +name = "ics08-wasm" +version = "0.1.0" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +dependencies = [ + "cosmwasm-schema", + "hex", + "ibc 0.15.0", + "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", + "prost 0.11.9", + "serde", + "tendermint-proto 0.28.0", +] + +[[package]] +name = "ics23" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca44b684ce1859cff746ff46f5765ab72e12e3c06f76a8356db8f9a2ecf43f17" +dependencies = [ + "anyhow", + "bytes", + "hex", + "prost 0.11.9", + "ripemd", + "sha2 0.10.8", + "sha3", +] + +[[package]] +name = "ics23" +version = "0.10.0" +source = "git+https://github.com/cosmos/ics23?rev=74ce807b7be39a7e0afb4e2efb8e28a57965f57b#74ce807b7be39a7e0afb4e2efb8e28a57965f57b" +dependencies = [ + "anyhow", + "bytes", + "hex", + "prost 0.11.9", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "indexmap" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +dependencies = [ + "equivalent", + "hashbrown 0.14.1", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "k256" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.8", + "signature 2.1.0", +] + +[[package]] +name = "keccak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" + +[[package]] +name = "linux-raw-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parity-scale-codec" +version = "3.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pbjson" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048f9ac93c1eab514f9470c4bc8d97ca2a0a236b84f45cc19d69a59fc11467f6" +dependencies = [ + "base64 0.13.1", + "serde", +] + +[[package]] +name = "pbjson-build" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdbb7b706f2afc610f3853550cdbbf6372fd324824a087806bd4480ea4996e24" +dependencies = [ + "heck", + "itertools", + "prost 0.11.9", + "prost-types", +] + +[[package]] +name = "pbjson-types" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a88c8d87f99a4ac14325e7a4c24af190fca261956e3b82dd7ed67e77e6c7043" +dependencies = [ + "bytes", + "chrono", + "pbjson", + "pbjson-build", + "prost 0.11.9", + "prost-build", + "serde", +] + +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2 1.0.69", + "syn 1.0.109", +] + +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proc-macro2" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" +dependencies = [ + "bytes", + "prost-derive 0.9.0", +] + +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost-build" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +dependencies = [ + "bytes", + "heck", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost 0.11.9", + "prost-types", + "regex", + "syn 1.0.109", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "prost-types" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +dependencies = [ + "prost 0.11.9", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2 1.0.69", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "regex" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.1", + "regex-syntax 0.8.1", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.1", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33" + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "rlp-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "safe-proc-macro2" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd85be67db87168aa3c13fd0da99f48f2ab005dccad5af5626138dc1df20eb6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "safe-quote" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77e530f7831f3feafcd5f1aae406ac205dd998436b4007c8e80f03eca78a88f7" +dependencies = [ + "safe-proc-macro2", +] + +[[package]] +name = "safe-regex" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15289bf322e0673d52756a18194167f2378ec1a15fe884af6e2d2cb934822b0" +dependencies = [ + "safe-regex-macro", +] + +[[package]] +name = "safe-regex-compiler" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba76fae590a2aa665279deb1f57b5098cbace01a0c5e60e262fcf55f7c51542" +dependencies = [ + "safe-proc-macro2", + "safe-quote", +] + +[[package]] +name = "safe-regex-macro" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c2e96b5c03f158d1b16ba79af515137795f4ad4e8de3f790518aae91f1d127" +dependencies = [ + "safe-proc-macro2", + "safe-regex-compiler", +] + +[[package]] +name = "scale-info" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", +] + +[[package]] +name = "scale-info-derive" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "schemars" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "273d9b56198caf703e271dcc07b28f2e794971750ace6585399d40e2af9f4823" +dependencies = [ + "schemars_derive 0.5.0", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" +dependencies = [ + "dyn-clone", + "schemars_derive 0.8.15", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab7f0b9b64633747a68dce4ed6318bbf30e3befe67df7624ad83abb7295c09" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "serde_derive_internals 0.25.0", + "syn 1.0.109", +] + +[[package]] +name = "schemars_derive" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "serde_derive_internals 0.26.0", + "syn 1.0.109", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + +[[package]] +name = "serde" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-json-wasm" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77cf509484e297252a195b1338a6d45843fe11ef234259f67649e8729934f443" +dependencies = [ + "serde", +] + +[[package]] +name = "serde-json-wasm" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" +dependencies = [ + "serde", +] + +[[package]] +name = "serde-json-wasm" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_bytes" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", +] + +[[package]] +name = "serde_derive_internals" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dbab34ca63057a1f15280bdf3c39f2b1eb1b54c17e98360e511637aef7418c6" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "serde_derive_internals" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "serde_json" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" + +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "smallvec" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" + +[[package]] +name = "snafu" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0bf93d08d6a44363b47d737f1f5bebbf5e6a1eaaa3d4c128ceeaca6b718292" +dependencies = [ + "doc-comment", + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624e94bd38e471f67883b467711e7a7ad7dbe284f5fb7e661dc8a671fc5b26a0" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2 1.0.69", + "quote 1.0.33", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "subtle-encoding" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcb1ed7b8330c5eed5441052651dd7a12c75e2ed88f2ec024ae1fa3a5e59945" +dependencies = [ + "zeroize", +] + +[[package]] +name = "subtle-ng" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys", +] + +[[package]] +name = "tendermint" +version = "0.28.0" +source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "flex-error", + "futures", + "num-traits", + "once_cell", + "prost 0.11.9", + "prost-types", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "signature 1.6.4", + "subtle", + "subtle-encoding", + "tendermint-proto 0.28.0", + "time", + "zeroize", +] + +[[package]] +name = "tendermint" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda53c85447577769cdfc94c10a56f34afef2c00e4108badb57fce6b1a0c75eb" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "flex-error", + "futures", + "num-traits", + "once_cell", + "prost 0.11.9", + "prost-types", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2 0.10.8", + "signature 1.6.4", + "subtle", + "subtle-encoding", + "tendermint-proto 0.29.1", + "time", + "zeroize", +] + +[[package]] +name = "tendermint-light-client-verifier" +version = "0.28.0" +source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" +dependencies = [ + "derive_more", + "flex-error", + "serde", + "tendermint 0.28.0", + "time", +] + +[[package]] +name = "tendermint-light-client-verifier" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11c3dc3c75f7a5708ac0bf98374b2b1a2cf17b3a45ddfd5faab3c111aff7fc0e" +dependencies = [ + "derive_more", + "flex-error", + "serde", + "tendermint 0.29.1", + "time", +] + +[[package]] +name = "tendermint-proto" +version = "0.28.0" +source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" +dependencies = [ + "bytes", + "flex-error", + "num-derive", + "num-traits", + "prost 0.11.9", + "prost-types", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + +[[package]] +name = "tendermint-proto" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c943f78c929cdf14553842f705f2c30324bc35b9179caaa5c9b80620f60652e6" +dependencies = [ + "bytes", + "flex-error", + "num-derive", + "num-traits", + "prost 0.11.9", + "prost-types", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + +[[package]] +name = "test-log" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9601d162c1d77e62c1ea0bc8116cd1caf143ce3af947536c3c9052a1677fe0c" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "test-utils" +version = "0.1.0" +dependencies = [ + "common 0.1.0", + "cosmwasm-std", + "cw-multi-test", + "getrandom", + "hex", + "hex-literal 0.4.1", + "ibc-proto 0.26.0", + "prost 0.11.9", + "serde", + "serde_json", +] + +[[package]] +name = "thiserror" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +dependencies = [ + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +dependencies = [ + "time-core", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "winnow" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" +dependencies = [ + "memchr", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", +] diff --git a/Cargo.toml b/Cargo.toml index e28cd0310..7470b25f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,17 +17,17 @@ version="0.1.0" #cosmwasm-storage = "1.2.2" #cosmwasm-schema = "1.2.2" #schemars = "0.8.12" -cosmwasm-schema = "1.1.3" -cosmwasm-std = {version="=1.1.6",default-features = false} -schemars = "0.8.10" +cosmwasm-schema = {version="1.2.2",default-features = false} +cosmwasm-std = {version="1.2.2",default-features = false,features = ["ibc3"]} +schemars = {version="0.8.10",default-features = false} serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } -cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", branch="fix-raw"} +cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", branch="fix-raw",default-features = false} -cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3"} -cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3"} -cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3" } -cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3" } +cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3",default-features = false} +cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3",default-features = false} +cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3" ,default-features = false} +cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3",default-features = false } cw2 = {version="1.0.1",default-features = false} ibc-proto = { version = "0.26.0", default-features = false} From cc122ebf6e468ae8dfbefbf7b3eacea97b33b7c1 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 15:22:58 +0545 Subject: [PATCH 31/64] fix: try disable features --- Cargo.lock | 30 +++++++------------ Cargo.toml | 8 ++--- .../cw-icon-light-client/src/context.rs | 2 +- .../cosmwasm-vm/cw-integration/Cargo.toml | 2 -- scripts/optimize-cosmwasm.sh | 2 +- 5 files changed, 15 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 682fcf604..03c6b9624 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -243,7 +243,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#98562f6fb5c315016f8c1681aa9d648bd8e3b2ec" +source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#81a731156db25e8149fb78f78489bc21e8418334" dependencies = [ "bytes", "cosmwasm-schema", @@ -356,9 +356,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.1.6" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1240e76655f4b858b3fb94befbf48e253e92c6640d9d674a1491d15f10bc4d72" +checksum = "ecc01051aab3bb88d5efe0b90f24a6df1ca96a873b12fc21b862b17539c84ee9" dependencies = [ "base64 0.13.1", "cosmwasm-crypto", @@ -368,16 +368,17 @@ dependencies = [ "hex", "schemars 0.8.15", "serde", - "serde-json-wasm 0.4.1", + "serde-json-wasm 0.5.1", + "sha2 0.10.8", "thiserror", "uint", ] [[package]] name = "cosmwasm-storage" -version = "1.1.6" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e4ffcc2d75f4957ec4e7e9f059b45c5de4edfac8f1ec41df5a42b962ccb6b3" +checksum = "5e719b9895ef880f172bfe698c975aa6ce5712abb2d0162148d51f346706df80" dependencies = [ "cosmwasm-std", "serde", @@ -577,7 +578,7 @@ dependencies = [ [[package]] name = "cw-mock-dapp" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#12179c66d5f5d0a4099ce78614f1858ad2deaab2" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#06b15102a9eabd2c6f5813dfd917605a82fca489" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", @@ -594,7 +595,7 @@ dependencies = [ [[package]] name = "cw-mock-dapp-multi" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#12179c66d5f5d0a4099ce78614f1858ad2deaab2" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#06b15102a9eabd2c6f5813dfd917605a82fca489" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", @@ -767,7 +768,7 @@ dependencies = [ [[package]] name = "cw-xcall" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#12179c66d5f5d0a4099ce78614f1858ad2deaab2" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#06b15102a9eabd2c6f5813dfd917605a82fca489" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", @@ -805,7 +806,7 @@ dependencies = [ [[package]] name = "cw-xcall-lib" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#12179c66d5f5d0a4099ce78614f1858ad2deaab2" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#06b15102a9eabd2c6f5813dfd917605a82fca489" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -2237,15 +2238,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde-json-wasm" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" -dependencies = [ - "serde", -] - [[package]] name = "serde-json-wasm" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 7470b25f8..6feb90202 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,12 +13,8 @@ repository = "https://github.com/icon-project/ibc-integration.git" version="0.1.0" [workspace.dependencies] -#cosmwasm-std = {version="1.2.2",default-features = false,features = ["iterator", "ibc3","staking"]} -#cosmwasm-storage = "1.2.2" -#cosmwasm-schema = "1.2.2" -#schemars = "0.8.12" -cosmwasm-schema = {version="1.2.2",default-features = false} -cosmwasm-std = {version="1.2.2",default-features = false,features = ["ibc3"]} +cosmwasm-schema = {version="1.4.0",default-features = false} +cosmwasm-std = {version="1.4.0",default-features = false,features = ["ibc3"]} schemars = {version="0.8.10",default-features = false} serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs index fac015d8e..90832904c 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs @@ -155,7 +155,7 @@ impl<'a> IContext for CwContext<'a> { fn ensure_ibc_host(&self, caller: &cosmwasm_std::Addr) -> Result<(), ContractError> { let config = self.get_config()?; - if caller != config.ibc_host { + if *caller != config.ibc_host { return Err(ContractError::Unauthorized {}); } Ok(()) diff --git a/contracts/cosmwasm-vm/cw-integration/Cargo.toml b/contracts/cosmwasm-vm/cw-integration/Cargo.toml index e8d79a9cc..85ab267df 100644 --- a/contracts/cosmwasm-vm/cw-integration/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-integration/Cargo.toml @@ -9,7 +9,6 @@ edition = "2021" [dependencies] cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} -#cosmwasm-storage = {workspace=true} cw-storage-plus = {workspace=true} cw-common={path="../cw-common"} common = { path="../../../libraries/rust/common", default-features = false } @@ -29,7 +28,6 @@ cw-icon-light-client = { path="../cw-icon-light-client" } cw-ibc-core={path="../cw-ibc-core"} cw-xcall-lib={workspace=true} cw-xcall = {workspace=true} -#cw-xcall={path="../cw-xcall"} anyhow="*" test-utils={path="../../../libraries/rust/test-utils"} diff --git a/scripts/optimize-cosmwasm.sh b/scripts/optimize-cosmwasm.sh index ccf714cab..b1b8fce9c 100755 --- a/scripts/optimize-cosmwasm.sh +++ b/scripts/optimize-cosmwasm.sh @@ -36,7 +36,7 @@ cargo clean rustup target add wasm32-unknown-unknown cargo install cosmwasm-check --locked -RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude test-utils --release --lib --target wasm32-unknown-unknown +RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude test-utils --release --lib --target wasm32-unknown-unknown --no-default-features for WASM in ./target/wasm32-unknown-unknown/release/*.wasm; do NAME=$(basename "$WASM" .wasm)${SUFFIX}.wasm echo "Creating intermediate hash for $NAME ..." From 87e220db35e4d66c1b3b7f7fad28c3d393eda9ce Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 15:31:30 +0545 Subject: [PATCH 32/64] fix: upgrade cw-storage-plus --- Cargo.lock | 62 +++++++++++-------- .../cw-icon-light-client/Cargo.toml | 2 +- .../cw-light-client-common/Cargo.toml | 2 +- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03c6b9624..e9bc5badd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,6 +69,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" + [[package]] name = "base64ct" version = "1.6.0" @@ -123,6 +129,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bnum" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128a44527fc0d6abf05f9eda748b9027536e12dff93f5acc8449f51583309350" + [[package]] name = "borsh" version = "0.10.3" @@ -356,11 +368,12 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc01051aab3bb88d5efe0b90f24a6df1ca96a873b12fc21b862b17539c84ee9" +checksum = "7d89d680fb60439b7c5947b15f9c84b961b88d1f8a3b20c4bd178a3f87db8bae" dependencies = [ - "base64 0.13.1", + "base64 0.21.4", + "bnum", "cosmwasm-crypto", "cosmwasm-derive", "derivative", @@ -371,14 +384,13 @@ dependencies = [ "serde-json-wasm 0.5.1", "sha2 0.10.8", "thiserror", - "uint", ] [[package]] name = "cosmwasm-storage" -version = "1.2.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719b9895ef880f172bfe698c975aa6ce5712abb2d0162148d51f346706df80" +checksum = "54a1c574d30feffe4b8121e61e839c231a5ce21901221d2fb4d5c945968a4f00" dependencies = [ "cosmwasm-std", "serde", @@ -484,7 +496,7 @@ dependencies = [ "cw-icon-light-client", "cw-multi-test", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2 1.1.0", + "cw2 1.1.1", "debug_print", "getrandom", "hex", @@ -510,8 +522,8 @@ dependencies = [ "cosmwasm-std", "cw-common", "cw-light-client-common", - "cw-storage-plus 0.15.1", - "cw2 1.1.0", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw2 1.1.1", "debug_print", "getrandom", "hex", @@ -562,7 +574,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-common", - "cw-storage-plus 0.15.1", + "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "debug_print", "getrandom", "hex", @@ -578,14 +590,14 @@ dependencies = [ [[package]] name = "cw-mock-dapp" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#06b15102a9eabd2c6f5813dfd917605a82fca489" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#b9be4b32443ba222e809ca6a18d55c606c3e8907" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall-lib", - "cw2 1.1.0", + "cw2 1.1.1", "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", @@ -595,14 +607,14 @@ dependencies = [ [[package]] name = "cw-mock-dapp-multi" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#06b15102a9eabd2c6f5813dfd917605a82fca489" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#b9be4b32443ba222e809ca6a18d55c606c3e8907" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall-lib", - "cw2 1.1.0", + "cw2 1.1.1", "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", @@ -621,7 +633,7 @@ dependencies = [ "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", "cw-xcall-lib", - "cw2 1.1.0", + "cw2 1.1.1", "debug_print", "getrandom", "hex", @@ -640,7 +652,7 @@ dependencies = [ "cw-common", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", - "cw2 1.1.0", + "cw2 1.1.1", "getrandom", "hex", "schemars 0.8.15", @@ -658,7 +670,7 @@ dependencies = [ "cosmwasm-std", "cw-common", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2 1.1.0", + "cw2 1.1.1", "debug_print", "getrandom", "hex", @@ -745,7 +757,7 @@ dependencies = [ "cosmwasm-std", "cw-common", "cw-light-client-common", - "cw2 1.1.0", + "cw2 1.1.1", "debug_print", "getrandom", "hex", @@ -768,14 +780,14 @@ dependencies = [ [[package]] name = "cw-xcall" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#06b15102a9eabd2c6f5813dfd917605a82fca489" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#b9be4b32443ba222e809ca6a18d55c606c3e8907" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall-lib", - "cw2 1.1.0", + "cw2 1.1.1", "debug_print", "schemars 0.8.15", "serde", @@ -794,7 +806,7 @@ dependencies = [ "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", "cw-xcall-lib", - "cw2 1.1.0", + "cw2 1.1.1", "debug_print", "getrandom", "hex", @@ -806,12 +818,12 @@ dependencies = [ [[package]] name = "cw-xcall-lib" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#06b15102a9eabd2c6f5813dfd917605a82fca489" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#b9be4b32443ba222e809ca6a18d55c606c3e8907" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2 1.1.0", + "cw2 1.1.1", "debug_print", "schemars 0.8.15", "serde", @@ -833,9 +845,9 @@ dependencies = [ [[package]] name = "cw2" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ac2dc7a55ad64173ca1e0a46697c31b7a5c51342f55a1e84a724da4eb99908" +checksum = "9431d14f64f49e41c6ef5561ed11a5391c417d0cb16455dea8cdcb9037a8d197" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml index 761974abd..9ed406222 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml @@ -34,7 +34,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} #cosmwasm-storage = {workspace=true} -cw-storage-plus = "0.15.1" +cw-storage-plus = {workspace=true} cw2 = {workspace=true} schemars = {workspace=true} serde = { workspace=true} diff --git a/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml b/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml index 24fbaabe3..0b5ecd9f3 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} #cosmwasm-storage = {workspace=true} -cw-storage-plus = "0.15.1" +cw-storage-plus ={workspace=true} thiserror = { workspace=true} prost = { workspace=true} hex ={workspace=true } From 8fd4fbb1444975b85a8c8688e6429eff9139c475 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 15:41:47 +0545 Subject: [PATCH 33/64] fix: lock to 1.4 --- Cargo.toml | 5 ++++- contracts/cosmwasm-vm/cw-common/Cargo.toml | 2 +- contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml | 4 ++-- contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml | 4 ++-- contracts/cosmwasm-vm/cw-integration/Cargo.toml | 4 ++-- contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml | 4 ++-- contracts/cosmwasm-vm/cw-mock-ibc-connection/Cargo.toml | 4 ++-- contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml | 4 ++-- contracts/cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml | 4 ++-- contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml | 4 ++-- contracts/cosmwasm-vm/cw-xcall-ibc-connection/Cargo.toml | 4 ++-- libraries/rust/test-utils/Cargo.toml | 2 +- scripts/optimize-cosmwasm.sh | 2 +- 13 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6feb90202..ed17d1ba4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ cosmwasm-std = {version="1.4.0",default-features = false,features = ["ibc3"]} schemars = {version="0.8.10",default-features = false} serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } -cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", branch="fix-raw",default-features = false} +cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", branch="fix-raw"} cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3",default-features = false} cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3",default-features = false} @@ -26,6 +26,9 @@ cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="fix/co cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3",default-features = false } cw2 = {version="1.0.1",default-features = false} +common = { path="./libraries/rust/common" } +cw-common = { path="./contracts/cosmwasm-vm/cw-common" } + ibc-proto = { version = "0.26.0", default-features = false} prost = { version = "0.11.8", default-features = false,features=["prost-derive"]} diff --git a/contracts/cosmwasm-vm/cw-common/Cargo.toml b/contracts/cosmwasm-vm/cw-common/Cargo.toml index d1513f5a1..4c54059f8 100644 --- a/contracts/cosmwasm-vm/cw-common/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-common/Cargo.toml @@ -18,7 +18,7 @@ serde_json = {workspace=true} hex-buffer-serde = "0.4.0" schemars = {workspace=true} hex = { workspace=true} -common = { path="../../../libraries/rust/common" } +common = { workspace=true } ibc-proto = { workspace=true} prost = { workspace=true} serde-json-wasm = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml b/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml index 897b4476a..9955d7f08 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml @@ -41,8 +41,8 @@ sha2 = { version = "0.10.6", default-features = false } hex ={workspace=true } sha3 = { version = "0.10.6", default-features = false } bytes = { workspace=true } -common = { path="../../../libraries/rust/common", default-features = false } -cw-common = { path="../cw-common",default-features = false } +common = { workspace=true, default-features = false } +cw-common = { workspace=true,default-features = false } prost = { workspace=true} serde-json-wasm = {workspace=true} debug_print = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml index 9ed406222..c7f91a447 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml @@ -43,8 +43,8 @@ sha2 = { version = "0.10.6", default-features = false } hex ={workspace=true } sha3 = { version = "0.10.6", default-features = false } bytes = { workspace=true } -common = { path="../../../libraries/rust/common", default-features = false } -cw-common = { path="../cw-common",default-features = false } +common = { workspace=true, default-features = false } +cw-common = { workspace=true,default-features = false } cw-light-client-common = { path="../cw-light-client-common",default-features = false } prost = { workspace=true} serde-json-wasm = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-integration/Cargo.toml b/contracts/cosmwasm-vm/cw-integration/Cargo.toml index 85ab267df..667c4c92c 100644 --- a/contracts/cosmwasm-vm/cw-integration/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-integration/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" cosmwasm-schema = {workspace=true} cosmwasm-std = {workspace=true} cw-storage-plus = {workspace=true} -cw-common={path="../cw-common"} -common = { path="../../../libraries/rust/common", default-features = false } +cw-common={workspace=true} +common = { workspace=true, default-features = false } ibc = { version = "0.32.0", default-features = false, features = ["parity-scale-codec", "mocks-no-std", "serde"]} prost = { workspace=true} strum="*" diff --git a/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml b/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml index 0b5ecd9f3..58064b40f 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-light-client-common/Cargo.toml @@ -17,8 +17,8 @@ schemars = {workspace=true} serde = { workspace=true} serde-json-wasm = {workspace=true} debug_print = {workspace=true} -cw-common = { path="../cw-common",default-features = false } -common = { path="../../../libraries/rust/common", default-features = false } +cw-common = { workspace=true,default-features = false } +common = { workspace=true, default-features = false } [dev-dependencies] cosmwasm = "0.7.2" diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-connection/Cargo.toml b/contracts/cosmwasm-vm/cw-mock-ibc-connection/Cargo.toml index 3cec5db18..53abc4b3f 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-connection/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-mock-ibc-connection/Cargo.toml @@ -38,8 +38,8 @@ cw2 = {workspace=true} schemars = {workspace=true} serde = { workspace=true} thiserror = { workspace=true} -common = { path="../../../libraries/rust/common" } -cw-common = { path="../cw-common" } +common = { workspace=true } +cw-common = { workspace=true } hex={workspace=true} debug_print={workspace=true} cw-xcall-lib={workspace=true} diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml b/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml index 16eb8ce6d..c8ec2bfe0 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-mock-ibc-core/Cargo.toml @@ -48,8 +48,8 @@ cw2 = {workspace=true} schemars = {workspace=true} serde = { workspace=true} thiserror = { workspace=true} -cw-common = { path="../cw-common" } -common = { path="../../../libraries/rust/common", default-features = false } +cw-common = { workspace=true } +common = { workspace=true, default-features = false } hex={workspace=true} cw-xcall={workspace=true} diff --git a/contracts/cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml b/contracts/cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml index d65385c4c..7806be807 100644 --- a/contracts/cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-mock-ibc-dapp/Cargo.toml @@ -38,8 +38,8 @@ cw2 = {workspace=true} schemars = {workspace=true} serde = { workspace=true} thiserror = { workspace=true} -common = { path="../../../libraries/rust/common" } -cw-common = { path="../cw-common" } +common = { workspace=true } +cw-common = { workspace=true } hex={workspace=true} debug_print={workspace=true} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml index 95aa45f70..aa13afc14 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/Cargo.toml @@ -41,9 +41,9 @@ sha2 = { version = "0.10.6", default-features = false } hex ={workspace=true } sha3 = { version = "0.10.6", default-features = false } bytes = { workspace=true } -common = { path="../../../libraries/rust/common", default-features = false } +common = { workspace=true } cw-light-client-common = { path="../cw-light-client-common",default-features = false } -cw-common = { path="../cw-common",default-features = false } +cw-common = { workspace=true } prost = { workspace=true} serde-json-wasm = {workspace=true} ibc-proto={git="https://github.com/ComposableFi/composable-ibc.git",default-features = false,features = ["json-schema"] } diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/Cargo.toml b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/Cargo.toml index 95d82a2a9..0d8999b46 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/Cargo.toml @@ -38,8 +38,8 @@ cw2 = {workspace=true} schemars = {workspace=true} serde = { workspace=true} thiserror = { workspace=true} -common = { path="../../../libraries/rust/common" } -cw-common = { path="../cw-common" } +common = { workspace=true } +cw-common = { workspace=true } hex={workspace=true} debug_print={workspace=true} cw-xcall-lib={workspace=true} diff --git a/libraries/rust/test-utils/Cargo.toml b/libraries/rust/test-utils/Cargo.toml index 7ef09ad6b..0c73e71cb 100644 --- a/libraries/rust/test-utils/Cargo.toml +++ b/libraries/rust/test-utils/Cargo.toml @@ -13,7 +13,7 @@ prost = { workspace=true} ibc-proto = { workspace=true} hex={workspace=true} hex-literal={workspace=true} -common={path="../common"} +common={workspace=true} cw-multi-test = "0.15.1" [dev-dependencies] diff --git a/scripts/optimize-cosmwasm.sh b/scripts/optimize-cosmwasm.sh index b1b8fce9c..ccf714cab 100755 --- a/scripts/optimize-cosmwasm.sh +++ b/scripts/optimize-cosmwasm.sh @@ -36,7 +36,7 @@ cargo clean rustup target add wasm32-unknown-unknown cargo install cosmwasm-check --locked -RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude test-utils --release --lib --target wasm32-unknown-unknown --no-default-features +RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude test-utils --release --lib --target wasm32-unknown-unknown for WASM in ./target/wasm32-unknown-unknown/release/*.wasm; do NAME=$(basename "$WASM" .wasm)${SUFFIX}.wasm echo "Creating intermediate hash for $NAME ..." From 4d9c8d9910811408d1a5503e8cde05868ba37def Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 18:46:54 +0545 Subject: [PATCH 34/64] fix: move cw-multi test --- Cargo.lock | 10 +++---- Cargo.toml | 3 +- .../cosmwasm-vm/cw-integration/tests/setup.rs | 30 +++++++++++++++++-- .../tests/test_host_lightclient.rs | 4 ++- .../tests/test_xcall_connection.rs | 2 +- libraries/rust/test-utils/Cargo.toml | 4 +-- libraries/rust/test-utils/src/lib.rs | 21 +------------ 7 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9bc5badd..c05806f98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -255,7 +255,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#81a731156db25e8149fb78f78489bc21e8418334" +source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#8fd4fbb1444975b85a8c8688e6429eff9139c475" dependencies = [ "bytes", "cosmwasm-schema", @@ -590,7 +590,7 @@ dependencies = [ [[package]] name = "cw-mock-dapp" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#b9be4b32443ba222e809ca6a18d55c606c3e8907" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#a5160ae8c87a939ad8f441cd5b5651b3888b6e7b" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", @@ -607,7 +607,7 @@ dependencies = [ [[package]] name = "cw-mock-dapp-multi" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#b9be4b32443ba222e809ca6a18d55c606c3e8907" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#a5160ae8c87a939ad8f441cd5b5651b3888b6e7b" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", @@ -780,7 +780,7 @@ dependencies = [ [[package]] name = "cw-xcall" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#b9be4b32443ba222e809ca6a18d55c606c3e8907" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#a5160ae8c87a939ad8f441cd5b5651b3888b6e7b" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", @@ -818,7 +818,7 @@ dependencies = [ [[package]] name = "cw-xcall-lib" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#b9be4b32443ba222e809ca6a18d55c606c3e8907" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#a5160ae8c87a939ad8f441cd5b5651b3888b6e7b" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/Cargo.toml b/Cargo.toml index ed17d1ba4..183eea1b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,10 +14,11 @@ version="0.1.0" [workspace.dependencies] cosmwasm-schema = {version="1.4.0",default-features = false} -cosmwasm-std = {version="1.4.0",default-features = false,features = ["ibc3"]} +cosmwasm-std = {version="1.4.0",default-features = false} schemars = {version="0.8.10",default-features = false} serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } + cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", branch="fix-raw"} cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3",default-features = false} diff --git a/contracts/cosmwasm-vm/cw-integration/tests/setup.rs b/contracts/cosmwasm-vm/cw-integration/tests/setup.rs index b36db7d9d..ab28a107b 100644 --- a/contracts/cosmwasm-vm/cw-integration/tests/setup.rs +++ b/contracts/cosmwasm-vm/cw-integration/tests/setup.rs @@ -3,10 +3,11 @@ use std::{collections::HashMap, str::FromStr}; use cosmwasm_std::{ coins, testing::{mock_dependencies, mock_info, MockApi, MockQuerier, MockStorage}, - Addr, Empty, IbcEndpoint, MessageInfo, OwnedDeps, + Addr, Attribute, Empty, Event, IbcEndpoint, MessageInfo, OwnedDeps, }; +use cw_common::ibc_types::IbcEventType; use cw_integration::TestSteps; -use cw_multi_test::{App, Contract, ContractWrapper, Executor}; +use cw_multi_test::{App, AppResponse, Contract, ContractWrapper, Executor}; use cw_xcall_ibc_connection::state::IbcConfig; use test_utils::{IntegrationData, RawPayload}; @@ -355,3 +356,28 @@ pub fn setup_context(data: Option) -> TestContext { caller: None, } } + +pub fn get_event(res: &AppResponse, event: &str) -> Option> { + let event = res + .events + .iter() + .filter(|e| e.ty == event) + .collect::>(); + if !event.is_empty() { + let map = to_attribute_map(&event[0].attributes); + return Some(map); + } + None +} + +pub fn get_event_name(event_type: IbcEventType) -> String { + format!("wasm-{}", event_type.as_str()) +} + +pub fn to_attribute_map(attrs: &Vec) -> HashMap { + let mut map = HashMap::new(); + for attr in attrs { + map.insert(attr.key.clone(), attr.value.clone()); + } + map +} diff --git a/contracts/cosmwasm-vm/cw-integration/tests/test_host_lightclient.rs b/contracts/cosmwasm-vm/cw-integration/tests/test_host_lightclient.rs index 1437c0af6..219e42077 100644 --- a/contracts/cosmwasm-vm/cw-integration/tests/test_host_lightclient.rs +++ b/contracts/cosmwasm-vm/cw-integration/tests/test_host_lightclient.rs @@ -18,7 +18,9 @@ use setup::{ init_xcall_app_contract, init_xcall_ibc_connection_contract, setup_context, TestContext, COUNTERPARTY_NID, PORT, }; -use test_utils::{get_event, get_event_name, load_raw_payloads}; +use test_utils::load_raw_payloads; + +use crate::setup::{get_event, get_event_name}; fn setup_test(payload_file: &str) -> TestContext { let integration_data = load_raw_payloads(payload_file); diff --git a/contracts/cosmwasm-vm/cw-integration/tests/test_xcall_connection.rs b/contracts/cosmwasm-vm/cw-integration/tests/test_xcall_connection.rs index 3892998b9..22fc8c648 100644 --- a/contracts/cosmwasm-vm/cw-integration/tests/test_xcall_connection.rs +++ b/contracts/cosmwasm-vm/cw-integration/tests/test_xcall_connection.rs @@ -11,8 +11,8 @@ use setup::{ init_mock_ibc_core_contract, init_xcall_app_contract, init_xcall_ibc_connection_contract, TestContext, }; -use test_utils::get_event; +use crate::setup::get_event; use crate::setup::setup_context; const MOCK_CONTRACT_TO_ADDR: &str = "cosmoscontract"; diff --git a/libraries/rust/test-utils/Cargo.toml b/libraries/rust/test-utils/Cargo.toml index 0c73e71cb..5d89dfb73 100644 --- a/libraries/rust/test-utils/Cargo.toml +++ b/libraries/rust/test-utils/Cargo.toml @@ -14,8 +14,8 @@ ibc-proto = { workspace=true} hex={workspace=true} hex-literal={workspace=true} common={workspace=true} -cw-multi-test = "0.15.1" -[dev-dependencies] +[dev-dependencies] +cw-multi-test = "0.15.1" getrandom = {version = "0.2", default-features = false, features = ["custom"]} diff --git a/libraries/rust/test-utils/src/lib.rs b/libraries/rust/test-utils/src/lib.rs index bb2e9e89c..81e03e89d 100644 --- a/libraries/rust/test-utils/src/lib.rs +++ b/libraries/rust/test-utils/src/lib.rs @@ -6,15 +6,13 @@ use std::{ path::PathBuf, }; -use common::ibc::events::IbcEventType; -use cw_multi_test::AppResponse; use ibc_proto::ibc::core::channel::v1::Packet; use serde::Deserialize; use common::icon::icon::types::v1::BtpHeader; use common::icon::icon::types::v1::MerkleNode; use common::icon::icon::types::v1::SignedHeader; -use cosmwasm_std::{Attribute, Event}; +use cosmwasm_std::Attribute; #[derive(Debug, Deserialize, Default, Clone)] pub struct IntegrationData { @@ -256,20 +254,3 @@ pub fn to_attribute_map(attrs: &Vec) -> HashMap { } map } - -pub fn get_event(res: &AppResponse, event: &str) -> Option> { - let event = res - .events - .iter() - .filter(|e| e.ty == event) - .collect::>(); - if !event.is_empty() { - let map = to_attribute_map(&event[0].attributes); - return Some(map); - } - None -} - -pub fn get_event_name(event_type: IbcEventType) -> String { - format!("wasm-{}", event_type.as_str()) -} From d4fe981afb549a2e9d232f2aed92c33eec7dce5d Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 12 Oct 2023 20:11:49 +0545 Subject: [PATCH 35/64] chore: pass build --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 183eea1b0..e3082129f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ hex ={ version = "0.4.3", default-features = false } hex-literal={version ="*"} debug_print = "1.0.0" + [profile.release] opt-level = 'z' debug = false From 0dbf213796b2f35a0ee418d608982b10a7a0d937 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Tue, 31 Oct 2023 16:02:38 +0545 Subject: [PATCH 36/64] fix: fix branch --- Cargo.lock | 436 +++---------------- Cargo.toml | 2 +- contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml | 4 +- libraries/rust/test-utils/Cargo.toml | 2 +- scripts/optimize-cosmwasm.sh | 2 +- 5 files changed, 62 insertions(+), 384 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c05806f98..730ae5bc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,17 +13,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", -] - [[package]] name = "aho-corasick" version = "1.1.2" @@ -135,51 +124,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "128a44527fc0d6abf05f9eda748b9027536e12dff93f5acc8449f51583309350" -[[package]] -name = "borsh" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" -dependencies = [ - "borsh-derive", - "hashbrown 0.13.2", -] - -[[package]] -name = "borsh-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" -dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", - "proc-macro-crate 0.1.5", - "proc-macro2 1.0.69", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - [[package]] name = "byte-slice-cast" version = "1.2.2" @@ -234,7 +178,7 @@ dependencies = [ "ics23 0.9.0", "pbjson", "pbjson-types", - "prost 0.11.9", + "prost", "prost-types", "rlp-derive", "rustc-hex", @@ -255,7 +199,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#8fd4fbb1444975b85a8c8688e6429eff9139c475" +source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#d4fe981afb549a2e9d232f2aed92c33eec7dce5d" dependencies = [ "bytes", "cosmwasm-schema", @@ -271,7 +215,7 @@ dependencies = [ "ics23 0.9.0", "pbjson", "pbjson-types", - "prost 0.11.9", + "prost", "prost-types", "rlp-derive", "rustc-hex", @@ -386,16 +330,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cosmwasm-storage" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a1c574d30feffe4b8121e61e839c231a5ce21901221d2fb4d5c945968a4f00" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cpufeatures" version = "0.2.9" @@ -475,7 +409,7 @@ dependencies = [ "hex", "hex-buffer-serde", "ibc-proto 0.26.0", - "prost 0.11.9", + "prost", "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", @@ -494,14 +428,13 @@ dependencies = [ "cosmwasm-std", "cw-common", "cw-icon-light-client", - "cw-multi-test", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2 1.1.1", + "cw2", "debug_print", "getrandom", "hex", "hex-literal 0.4.1", - "prost 0.11.9", + "prost", "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", @@ -523,12 +456,12 @@ dependencies = [ "cw-common", "cw-light-client-common", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2 1.1.1", + "cw2", "debug_print", "getrandom", "hex", "hex-literal 0.4.1", - "prost 0.11.9", + "prost", "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", @@ -538,33 +471,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw-integration" -version = "0.1.0" -dependencies = [ - "anyhow", - "common 0.1.0", - "cosmwasm-schema", - "cosmwasm-std", - "cw-common", - "cw-ibc-core", - "cw-icon-light-client", - "cw-mock-dapp", - "cw-mock-dapp-multi", - "cw-mock-ibc-core", - "cw-multi-test", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall", - "cw-xcall-ibc-connection", - "cw-xcall-lib", - "hex", - "ibc 0.32.0", - "prost 0.11.9", - "strum", - "strum_macros", - "test-utils", -] - [[package]] name = "cw-light-client-common" version = "0.1.0" @@ -579,7 +485,7 @@ dependencies = [ "getrandom", "hex", "hex-literal 0.4.1", - "prost 0.11.9", + "prost", "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", @@ -587,40 +493,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw-mock-dapp" -version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#a5160ae8c87a939ad8f441cd5b5651b3888b6e7b" -dependencies = [ - "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall-lib", - "cw2 1.1.1", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "thiserror", -] - -[[package]] -name = "cw-mock-dapp-multi" -version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#a5160ae8c87a939ad8f441cd5b5651b3888b6e7b" -dependencies = [ - "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw-xcall-lib", - "cw2 1.1.1", - "schemars 0.8.15", - "serde", - "serde-json-wasm 0.5.1", - "thiserror", -] - [[package]] name = "cw-mock-ibc-connection" version = "0.1.0" @@ -633,7 +505,7 @@ dependencies = [ "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", "cw-xcall-lib", - "cw2 1.1.1", + "cw2", "debug_print", "getrandom", "hex", @@ -652,7 +524,7 @@ dependencies = [ "cw-common", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", - "cw2 1.1.1", + "cw2", "getrandom", "hex", "schemars 0.8.15", @@ -670,7 +542,7 @@ dependencies = [ "cosmwasm-std", "cw-common", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2 1.1.1", + "cw2", "debug_print", "getrandom", "hex", @@ -679,36 +551,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw-multi-test" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e81b4a7821d5eeba0d23f737c16027b39a600742ca8c32eb980895ffd270f4" -dependencies = [ - "anyhow", - "cosmwasm-std", - "cosmwasm-storage", - "cw-storage-plus 0.15.1", - "cw-utils", - "derivative", - "itertools", - "prost 0.9.0", - "schemars 0.8.15", - "serde", - "thiserror", -] - -[[package]] -name = "cw-storage-plus" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6cf70ef7686e2da9ad7b067c5942cd3e88dd9453f7af42f54557f8af300fb0" -dependencies = [ - "cosmwasm-std", - "schemars 0.8.15", - "serde", -] - [[package]] name = "cw-storage-plus" version = "1.1.0" @@ -730,21 +572,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cw-utils" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae0b69fa7679de78825b4edeeec045066aa2b2c4b6e063d80042e565bb4da5c" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw2 0.15.1", - "schemars 0.8.15", - "semver", - "serde", - "thiserror", -] - [[package]] name = "cw-wasm-light-client" version = "0.1.0" @@ -757,16 +584,16 @@ dependencies = [ "cosmwasm-std", "cw-common", "cw-light-client-common", - "cw2 1.1.1", + "cw2", "debug_print", "getrandom", "hex", "hex-literal 0.4.1", - "ibc 0.15.0", + "ibc", "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git)", "ics07-tendermint-cw", "ics08-wasm", - "prost 0.11.9", + "prost", "schemars 0.8.15", "serde", "serde-json-wasm 0.5.1", @@ -780,14 +607,14 @@ dependencies = [ [[package]] name = "cw-xcall" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#a5160ae8c87a939ad8f441cd5b5651b3888b6e7b" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#d2a21f13e5de2d8f64780f3d9958eb62d7c9c5fa" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall-lib", - "cw2 1.1.1", + "cw2", "debug_print", "schemars 0.8.15", "serde", @@ -806,7 +633,7 @@ dependencies = [ "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", "cw-xcall", "cw-xcall-lib", - "cw2 1.1.1", + "cw2", "debug_print", "getrandom", "hex", @@ -818,31 +645,18 @@ dependencies = [ [[package]] name = "cw-xcall-lib" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#a5160ae8c87a939ad8f441cd5b5651b3888b6e7b" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#d2a21f13e5de2d8f64780f3d9958eb62d7c9c5fa" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", - "cw2 1.1.1", + "cw2", "debug_print", "schemars 0.8.15", "serde", "thiserror", ] -[[package]] -name = "cw2" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5abb8ecea72e09afff830252963cb60faf945ce6cef2c20a43814516082653da" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 0.15.1", - "schemars 0.8.15", - "serde", -] - [[package]] name = "cw2" version = "1.1.1" @@ -1023,15 +837,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "erased-serde" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" -dependencies = [ - "serde", -] - [[package]] name = "errno" version = "0.3.5" @@ -1208,16 +1013,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", -] - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.3", + "ahash", ] [[package]] @@ -1294,7 +1090,7 @@ dependencies = [ "num-traits", "parity-scale-codec", "primitive-types", - "prost 0.11.9", + "prost", "safe-regex", "scale-info", "serde", @@ -1309,46 +1105,13 @@ dependencies = [ "uint", ] -[[package]] -name = "ibc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030b54b02c3f35ea7265da2beedf0d7d22492208919a6582f980ff3eae82c2d0" -dependencies = [ - "bytes", - "cfg-if", - "derive_more", - "displaydoc", - "dyn-clone", - "erased-serde", - "ibc-proto 0.26.0", - "ics23 0.9.0", - "num-traits", - "parity-scale-codec", - "primitive-types", - "prost 0.11.9", - "safe-regex", - "scale-info", - "serde", - "serde_derive", - "serde_json", - "sha2 0.10.8", - "subtle-encoding", - "tendermint 0.29.1", - "tendermint-light-client-verifier 0.29.1", - "tendermint-proto 0.29.1", - "time", - "tracing", - "uint", -] - [[package]] name = "ibc-derive" version = "0.1.0" source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" dependencies = [ "convert_case 0.6.0", - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2 1.0.69", "quote 1.0.33", "syn 1.0.109", @@ -1361,7 +1124,7 @@ source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2 dependencies = [ "base64 0.13.1", "bytes", - "prost 0.11.9", + "prost", "schemars 0.8.15", "serde", "tendermint-proto 0.28.0", @@ -1374,7 +1137,7 @@ source = "git+https://github.com/ComposableFi/composable-ibc.git#2a8ed31167e6d54 dependencies = [ "base64 0.13.1", "bytes", - "prost 0.11.9", + "prost", "schemars 0.8.15", "serde", "tendermint-proto 0.28.0", @@ -1387,12 +1150,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9303a1308c886aea769ef0667c5caa422a78b01e9f8177fea8b91b08a4ff50c" dependencies = [ "base64 0.13.1", - "borsh", "bytes", "flex-error", - "parity-scale-codec", - "prost 0.11.9", - "scale-info", + "prost", "serde", "subtle-encoding", "tendermint-proto 0.29.1", @@ -1406,16 +1166,16 @@ dependencies = [ "bytes", "flex-error", "hex", - "ibc 0.15.0", + "ibc", "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", "ics23 0.10.0", "log", - "prost 0.11.9", + "prost", "serde", "serde_json", "subtle-encoding", "tendermint 0.28.0", - "tendermint-light-client-verifier 0.28.0", + "tendermint-light-client-verifier", "tendermint-proto 0.28.0", "time", ] @@ -1434,19 +1194,19 @@ dependencies = [ "ed25519-consensus", "ed25519-zebra", "hex", - "ibc 0.15.0", + "ibc", "ibc-derive", "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", "ics07-tendermint", "ics08-wasm", "ics23 0.10.0", - "prost 0.11.9", + "prost", "schemars 0.8.15", "serde", "sha2 0.10.8", "sha3", "tendermint 0.28.0", - "tendermint-light-client-verifier 0.28.0", + "tendermint-light-client-verifier", "tendermint-proto 0.28.0", "thiserror", ] @@ -1458,9 +1218,9 @@ source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2 dependencies = [ "cosmwasm-schema", "hex", - "ibc 0.15.0", + "ibc", "ibc-proto 0.18.0 (git+https://github.com/ComposableFi/composable-ibc.git?branch=master)", - "prost 0.11.9", + "prost", "serde", "tendermint-proto 0.28.0", ] @@ -1474,7 +1234,7 @@ dependencies = [ "anyhow", "bytes", "hex", - "prost 0.11.9", + "prost", "ripemd", "sha2 0.10.8", "sha3", @@ -1488,7 +1248,7 @@ dependencies = [ "anyhow", "bytes", "hex", - "prost 0.11.9", + "prost", ] [[package]] @@ -1687,7 +1447,7 @@ version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2 1.0.69", "quote 1.0.33", "syn 1.0.109", @@ -1717,7 +1477,7 @@ checksum = "bdbb7b706f2afc610f3853550cdbbf6372fd324824a087806bd4480ea4996e24" dependencies = [ "heck", "itertools", - "prost 0.11.9", + "prost", "prost-types", ] @@ -1731,7 +1491,7 @@ dependencies = [ "chrono", "pbjson", "pbjson-build", - "prost 0.11.9", + "prost", "prost-build", "serde", ] @@ -1796,15 +1556,6 @@ dependencies = [ "uint", ] -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml", -] - [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -1833,16 +1584,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" -dependencies = [ - "bytes", - "prost-derive 0.9.0", -] - [[package]] name = "prost" version = "0.11.9" @@ -1850,7 +1591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive 0.11.9", + "prost-derive", ] [[package]] @@ -1867,7 +1608,7 @@ dependencies = [ "multimap", "petgraph", "prettyplease", - "prost 0.11.9", + "prost", "prost-types", "regex", "syn 1.0.109", @@ -1875,19 +1616,6 @@ dependencies = [ "which", ] -[[package]] -name = "prost-derive" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - [[package]] name = "prost-derive" version = "0.11.9" @@ -1907,7 +1635,7 @@ version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost 0.11.9", + "prost", ] [[package]] @@ -2070,9 +1798,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.18" +version = "0.38.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" +checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" dependencies = [ "bitflags 2.4.0", "errno", @@ -2081,12 +1809,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - [[package]] name = "ryu" version = "1.0.15" @@ -2159,7 +1881,7 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate", "proc-macro2 1.0.69", "quote 1.0.33", "syn 1.0.109", @@ -2234,9 +1956,9 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" dependencies = [ "serde_derive", ] @@ -2270,9 +1992,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2 1.0.69", "quote 1.0.33", @@ -2425,25 +2147,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" - -[[package]] -name = "strum_macros" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" -dependencies = [ - "heck", - "proc-macro2 1.0.69", - "quote 1.0.33", - "rustversion", - "syn 1.0.109", -] - [[package]] name = "subtle" version = "2.5.0" @@ -2529,7 +2232,7 @@ dependencies = [ "futures", "num-traits", "once_cell", - "prost 0.11.9", + "prost", "prost-types", "serde", "serde_bytes", @@ -2552,18 +2255,16 @@ dependencies = [ "bytes", "digest 0.10.7", "ed25519", - "ed25519-consensus", "flex-error", "futures", "num-traits", "once_cell", - "prost 0.11.9", + "prost", "prost-types", "serde", "serde_bytes", "serde_json", "serde_repr", - "sha2 0.10.8", "signature 1.6.4", "subtle", "subtle-encoding", @@ -2584,19 +2285,6 @@ dependencies = [ "time", ] -[[package]] -name = "tendermint-light-client-verifier" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c3dc3c75f7a5708ac0bf98374b2b1a2cf17b3a45ddfd5faab3c111aff7fc0e" -dependencies = [ - "derive_more", - "flex-error", - "serde", - "tendermint 0.29.1", - "time", -] - [[package]] name = "tendermint-proto" version = "0.28.0" @@ -2606,7 +2294,7 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost 0.11.9", + "prost", "prost-types", "serde", "serde_bytes", @@ -2624,7 +2312,7 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost 0.11.9", + "prost", "prost-types", "serde", "serde_bytes", @@ -2634,13 +2322,13 @@ dependencies = [ [[package]] name = "test-log" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9601d162c1d77e62c1ea0bc8116cd1caf143ce3af947536c3c9052a1677fe0c" +checksum = "f66edd6b6cd810743c0c71e1d085e92b01ce6a72782032e3f794c8284fe4bcdd" dependencies = [ "proc-macro2 1.0.69", "quote 1.0.33", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] @@ -2649,12 +2337,11 @@ version = "0.1.0" dependencies = [ "common 0.1.0", "cosmwasm-std", - "cw-multi-test", "getrandom", "hex", "hex-literal 0.4.1", "ibc-proto 0.26.0", - "prost 0.11.9", + "prost", "serde", "serde_json", ] @@ -2715,15 +2402,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "toml_datetime" version = "0.6.3" diff --git a/Cargo.toml b/Cargo.toml index e3082129f..8bb1a6f0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "libraries/rust/common", ] -exclude = ["contracts/cosmwasm-vm/archway"] +exclude = ["contracts/cosmwasm-vm/archway","contracts/cosmwasm-vm/cw-integration"] [workspace.package] diff --git a/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml b/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml index 9955d7f08..415a991e1 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml @@ -31,7 +31,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] cosmwasm-schema = {workspace=true} -cosmwasm-std = {workspace=true} +cosmwasm-std = {workspace=true,features = ["ibc3"]} cw-storage-plus = {workspace=true} cw2 = {workspace=true} schemars = {workspace=true} @@ -50,7 +50,7 @@ debug_print = {workspace=true} [dev-dependencies] getrandom = {version = "0.2", default-features = false, features = ["custom"]} -cw-multi-test = "0.15.1" +#cw-multi-test = "0.15.1" cw-icon-light-client = { path="../cw-icon-light-client",default-features = false } anyhow="1.0.71" test-utils={path="../../../libraries/rust/test-utils"} diff --git a/libraries/rust/test-utils/Cargo.toml b/libraries/rust/test-utils/Cargo.toml index 5d89dfb73..92bf68e81 100644 --- a/libraries/rust/test-utils/Cargo.toml +++ b/libraries/rust/test-utils/Cargo.toml @@ -17,5 +17,5 @@ common={workspace=true} [dev-dependencies] -cw-multi-test = "0.15.1" +#cw-multi-test = "0.15.1" getrandom = {version = "0.2", default-features = false, features = ["custom"]} diff --git a/scripts/optimize-cosmwasm.sh b/scripts/optimize-cosmwasm.sh index ccf714cab..7a2f2256a 100755 --- a/scripts/optimize-cosmwasm.sh +++ b/scripts/optimize-cosmwasm.sh @@ -36,7 +36,7 @@ cargo clean rustup target add wasm32-unknown-unknown cargo install cosmwasm-check --locked -RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude test-utils --release --lib --target wasm32-unknown-unknown +RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude cw-integration --release --lib --target wasm32-unknown-unknown for WASM in ./target/wasm32-unknown-unknown/release/*.wasm; do NAME=$(basename "$WASM" .wasm)${SUFFIX}.wasm echo "Creating intermediate hash for $NAME ..." From d3f22fb440911b386fd00b2be2221fa432afc0d1 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Fri, 10 Nov 2023 11:20:42 +0545 Subject: [PATCH 37/64] fix: add height --- contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs | 6 ++++-- contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 2393020d4..660d8f073 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -126,10 +126,12 @@ fn process_message( let header_any = Any::decode(&*wasmheader.data).unwrap(); let header = SignedHeader::from_any(header_any).map_err(ContractError::DecodeError)?; - client.update_client(info.sender, CLIENT_ID, header)?; + client.verify_header(&info.sender, CLIENT_ID, &header)?; Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) } - crate::msg::ClientMessageRaw::Misbehaviour(_) => unimplemented!(), + crate::msg::ClientMessageRaw::Misbehaviour(_) => { + Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) + }, }, ExecuteMsg::UpdateState(msg) => { cw_println!(deps_mut.api, "Received Header {:?}", &msg); diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs index f23804fca..e08845dee 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/utils.rs @@ -79,7 +79,7 @@ pub fn decode_consensus_state(value: &[u8]) -> Result Height { - Height::new(0, height) + Height::new(1, height) } pub fn any_from_byte(bytes: &[u8]) -> Result { From 0231df600fe1c6d38c467a4a786be7f766fb2738 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Fri, 10 Nov 2023 11:30:23 +0545 Subject: [PATCH 38/64] fix: cleanup --- .../cw-wasm-light-client/src/contract.rs | 2 +- .../src/ibc/core/ics23_commitment/merkle.rs | 187 ------------------ scripts/optimize-cosmwasm.sh | 2 +- 3 files changed, 2 insertions(+), 189 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 660d8f073..628d71d5c 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -131,7 +131,7 @@ fn process_message( } crate::msg::ClientMessageRaw::Misbehaviour(_) => { Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) - }, + } }, ExecuteMsg::UpdateState(msg) => { cw_println!(deps_mut.api, "Received Header {:?}", &msg); diff --git a/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs b/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs index 02db4fe99..682678c5d 100644 --- a/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs +++ b/libraries/rust/common/src/ibc/core/ics23_commitment/merkle.rs @@ -64,193 +64,6 @@ impl From for RawMerkleProof { } } -// impl MerkleProof { -// pub fn verify_membership( -// &self, -// specs: &ProofSpecs, -// root: MerkleRoot, -// keys: MerklePath, -// value: Vec, -// start_index: usize, -// ) -> Result<(), CommitmentError> { -// // validate arguments -// if self.proofs.is_empty() { -// return Err(CommitmentError::EmptyMerkleProof); -// } -// if root.hash.is_empty() { -// return Err(CommitmentError::EmptyMerkleRoot); -// } -// let num = self.proofs.len(); -// let ics23_specs = Vec::::from(specs.clone()); -// if ics23_specs.len() != num { -// return Err(CommitmentError::NumberOfSpecsMismatch); -// } -// if keys.key_path.len() != num { -// return Err(CommitmentError::NumberOfKeysMismatch); -// } -// if value.is_empty() { -// return Err(CommitmentError::EmptyVerifiedValue); -// } - -// let mut subroot = value.clone(); -// let mut value = value; -// // keys are represented from root-to-leaf -// for ((proof, spec), key) in self -// .proofs -// .iter() -// .zip(ics23_specs.iter()) -// .zip(keys.key_path.iter().rev()) -// .skip(start_index) -// { -// match &proof.proof { -// Some(Proof::Exist(existence_proof)) => { -// subroot = -// calculate_existence_root::(existence_proof) -// .map_err(|_| CommitmentError::InvalidMerkleProof)?; - -// if !verify_membership::( -// proof, -// spec, -// &subroot, -// key.as_bytes(), -// &value, -// ) { -// return Err(CommitmentError::VerificationFailure); -// } -// value = subroot.clone(); -// } -// _ => return Err(CommitmentError::InvalidMerkleProof), -// } -// } - -// if root.hash != subroot { -// return Err(CommitmentError::VerificationFailure); -// } - -// Ok(()) -// } - -// pub fn verify_non_membership( -// &self, -// specs: &ProofSpecs, -// root: MerkleRoot, -// keys: MerklePath, -// ) -> Result<(), CommitmentError> { -// // validate arguments -// if self.proofs.is_empty() { -// return Err(CommitmentError::EmptyMerkleProof); -// } -// if root.hash.is_empty() { -// return Err(CommitmentError::EmptyMerkleRoot); -// } -// let num = self.proofs.len(); -// let ics23_specs = Vec::::from(specs.clone()); -// if ics23_specs.len() != num { -// return Err(CommitmentError::NumberOfSpecsMismatch); -// } -// if keys.key_path.len() != num { -// return Err(CommitmentError::NumberOfKeysMismatch); -// } - -// // verify the absence of key in lowest subtree -// let proof = self -// .proofs -// .get(0) -// .ok_or(CommitmentError::InvalidMerkleProof)?; -// let spec = ics23_specs -// .get(0) -// .ok_or(CommitmentError::InvalidMerkleProof)?; -// // keys are represented from root-to-leaf -// let key = keys -// .key_path -// .get(num - 1) -// .ok_or(CommitmentError::InvalidMerkleProof)?; -// match &proof.proof { -// Some(Proof::Nonexist(non_existence_proof)) => { -// let subroot = calculate_non_existence_root(non_existence_proof)?; - -// if !verify_non_membership::( -// proof, -// spec, -// &subroot, -// key.as_bytes(), -// ) { -// return Err(CommitmentError::VerificationFailure); -// } - -// // verify membership proofs starting from index 1 with value = subroot -// self.verify_membership(specs, root, keys, subroot, 1) -// } -// _ => Err(CommitmentError::InvalidMerkleProof), -// } -// } -// } - -// // TODO move to ics23 -// fn calculate_non_existence_root(proof: &NonExistenceProof) -> Result, CommitmentError> { -// if let Some(left) = &proof.left { -// calculate_existence_root::(left) -// .map_err(|_| CommitmentError::InvalidMerkleProof) -// } else if let Some(right) = &proof.right { -// calculate_existence_root::(right) -// .map_err(|_| CommitmentError::InvalidMerkleProof) -// } else { -// Err(CommitmentError::InvalidMerkleProof) -// } -// } - -// Merkle Proof serialization notes: -// "Proof" id currently defined in a number of forms and included in a number of places -// - TmProof: in tendermint-rs/src/merkle/proof.rs:Proof -// - RawProofOps: in tendermint-proto/tendermint.crypto.rs:ProofOps -// - RawMerkleProof: in ibc-proto/ibc.core.commitment.v1.rs:MerkleProof -// - structure that includes a RawProofOps in its only `proof` field. -// #[derive(Clone, PartialEq, ::prost::Message)] -// pub struct MerkleProof { -// #[prost(message, optional, tag="1")] -// pub proof: ::core::option::Option<::tendermint_proto::crypto::ProofOps>, -// } -// - Vec: RawMerkleProof is not explicitly used but, serialized as Vec, it is -// included in all handshake messages that require proofs (i.e. all except the two `OpenInit`), -// and also in all queries that require proofs -// - MerkleProof: Domain type for RawMerkleProof, currently not used and identical to RawMerkleProof. -// This will change with verification implementation. -// - CommitmentProof: Defined in ibc-rs as Vec and currently used in all its messages -// -// Here are a couple of flows that illustrate the different conversions: -// IBC Messages and Handlers: sink happens in the handle verification -// Vec -> CommitmentProof -> RawMerkleProof -> MerkleProof -// -// Relayer: from the proof in the query response to the proof being included in a message -// TmProof -> RawProofOps => RawMerkleProof -> MerkleProof -> verify() -// -> MerkleProof -> RawMerkleProof -> CommitmentProof -> Vec -// Note: current implementation for ^ is simplified since verification is not yet implemented: -// TmProof -> RawProofOps => RawMerkleProof -> CommitmentProof -> Vec -// -// Implementations of (de)serializers and conversions: -// - commitment.rs: -// Vec <-> CommitmentProof -// CommitmentProof <-> RawMerkleProof -// - merkle.rs: -// RawMerkleProof <-> MerkleProof -// - tendermint-rs/src/merkle/proof.rs: -// TmProof <-> RawProofOps -// - cosmos.rs:abci_query() converts from query proof to Merkle proof: -// RawProofOps => RawMerkleProof -// -// impl TryFrom for MerkleProof { -// type Error = Error; -// fn try_from(value: RawMerkleProof) -> Result { -// Ok(MerkleProof { proof: value.proofs.into_iter().map(|v| v.into()).collect() }) -// } -// } -// -// impl From for RawMerkleProof { -// fn from(value: MerkleProof) -> Self { -// RawMerkleProof { proof: value.proof } -// } -// } - pub fn convert_tm_to_ics_merkle_proof( tm_proof: &TendermintProof, ) -> Result { diff --git a/scripts/optimize-cosmwasm.sh b/scripts/optimize-cosmwasm.sh index 7a2f2256a..3ff542e46 100755 --- a/scripts/optimize-cosmwasm.sh +++ b/scripts/optimize-cosmwasm.sh @@ -34,7 +34,7 @@ cargo fmt --all cargo clean rustup target add wasm32-unknown-unknown -cargo install cosmwasm-check --locked +cargo install cosmwasm-check@1.4.1 --locked RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude cw-integration --release --lib --target wasm32-unknown-unknown for WASM in ./target/wasm32-unknown-unknown/release/*.wasm; do From d1cd765888436c9e79a970b95f7b4b117dcc425e Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Fri, 10 Nov 2023 11:38:19 +0545 Subject: [PATCH 39/64] chore: pass build --- contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs | 2 +- contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs index fe7fd6cd4..407a81da7 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/contract.rs @@ -302,7 +302,7 @@ impl<'a> CwIbcConnection<'a> { info: MessageInfo, msg: InstantiateMsg, ) -> Result { - let owner = info.clone().sender; + let owner = info.sender; self.add_owner(store, owner.clone())?; self.update_admin(store, owner)?; diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs index 309aafc6b..eab50532b 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/ibc_host.rs @@ -134,7 +134,7 @@ mod tests { let packet = RawPacket::default(); let res = connection.call_host_send_message(deps.as_mut(), packet.clone()); - println!("{:?}", res); + println!("{res:?}"); assert!(res.is_ok()); let expected_ibc_host = connection From 1e5daa824b80b6653b1e53c8bd94b4c8c8710d29 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 23 Nov 2023 10:47:50 +0545 Subject: [PATCH 40/64] fix: remove toolchain.toml --- rust-toolchain.toml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 4bd462616..000000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,4 +0,0 @@ -[toolchain] -channel = "nightly-2022-12-31" -targets = [ "wasm32-unknown-unknown"] -profile = "minimal" \ No newline at end of file From d2eb1ac6c83de203d10c0488c8c450d1017f0586 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 11 Dec 2023 17:24:24 +0545 Subject: [PATCH 41/64] fix: fix verify membership --- Cargo.lock | 622 ++++++++++-------- Cargo.toml | 8 +- contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml | 2 +- .../src/traits/query_handler.rs | 1 + .../cw-wasm-light-client/src/contract.rs | 37 +- 5 files changed, 380 insertions(+), 290 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f325eb63..aaf539f0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom", "once_cell", @@ -60,9 +60,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -84,9 +84,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "bitvec" @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128a44527fc0d6abf05f9eda748b9027536e12dff93f5acc8449f51583309350" +checksum = "ab9008b6bb9fc80b5277f2fe481c09e828743d9151203e804583eb4c9e15b31d" [[package]] name = "byte-slice-cast" @@ -167,7 +167,7 @@ dependencies = [ "bytes", "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "debug_print", "derive_more", "displaydoc", @@ -199,12 +199,12 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/icon-project/IBC-Integration.git?branch=main#10754826b6fd861c016e39d92761f8354ede8040" +source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#1e5daa824b80b6653b1e53c8bd94b4c8c8710d29" dependencies = [ "bytes", "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "debug_print", "derive_more", "displaydoc", @@ -266,11 +266,12 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6fb22494cf7d23d0c348740e06e5c742070b2991fd41db77bba0bcfbae1a723" +checksum = "d8bb3c77c3b7ce472056968c745eb501c440fbc07be5004eba02782c35bfbbe3" dependencies = [ "digest 0.10.7", + "ecdsa", "ed25519-zebra", "k256", "rand_core 0.6.4", @@ -279,21 +280,21 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e199424486ea97d6b211db6387fd72e26b4a439d40cc23140b2d8305728055b" +checksum = "fea73e9162e6efde00018d55ed0061e93a108b5d6ec4548b4f8ce3c706249687" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fef683a9c1c4eabd6d31515719d0d2cc66952c4c87f7eb192bfc90384517dc34" +checksum = "0df41ea55f2946b6b43579659eec048cc2f66e8c8e2e3652fc5e5e476f673856" dependencies = [ "cosmwasm-schema-derive", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "serde_json", "thiserror", @@ -301,50 +302,42 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9567025acbb4c0c008178393eb53b3ac3c2e492c25949d3bf415b9cbe80772d8" +checksum = "43609e92ce1b9368aa951b334dd354a2d0dd4d484931a5f83ae10e12a26c8ba9" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "cosmwasm-std" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d89d680fb60439b7c5947b15f9c84b961b88d1f8a3b20c4bd178a3f87db8bae" +checksum = "04d6864742e3a7662d024b51a94ea81c9af21db6faea2f9a6d2232bb97c6e53e" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", + "bech32", "bnum", "cosmwasm-crypto", "cosmwasm-derive", "derivative", "forward_ref", "hex", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "serde-json-wasm 0.5.1", "sha2 0.10.8", + "static_assertions", "thiserror", ] -[[package]] -name = "cosmwasm-storage" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a1c574d30feffe4b8121e61e839c231a5ce21901221d2fb4d5c945968a4f00" -dependencies = [ - "cosmwasm-std", - "serde", -] - [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -357,9 +350,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -412,7 +405,7 @@ dependencies = [ "common 0.1.0", "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "cw-xcall-lib", "debug_print", "getrandom", @@ -420,7 +413,7 @@ dependencies = [ "hex-buffer-serde", "ibc-proto 0.26.0", "prost", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "serde-json-wasm 0.5.1", "serde_json", @@ -438,14 +431,14 @@ dependencies = [ "cosmwasm-std", "cw-common", "cw-icon-light-client", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "cw2", "debug_print", "getrandom", "hex", "hex-literal 0.4.1", "prost", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "serde-json-wasm 0.5.1", "sha2 0.10.8", @@ -465,14 +458,14 @@ dependencies = [ "cosmwasm-std", "cw-common", "cw-light-client-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "cw2", "debug_print", "getrandom", "hex", "hex-literal 0.4.1", "prost", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "serde-json-wasm 0.5.1", "sha2 0.10.8", @@ -490,13 +483,13 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "debug_print", "getrandom", "hex", "hex-literal 0.4.1", "prost", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "serde-json-wasm 0.5.1", "test-utils", @@ -512,14 +505,14 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "cw-xcall", "cw-xcall-lib", "cw2", "debug_print", "getrandom", "hex", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "thiserror", ] @@ -532,12 +525,12 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "cw-xcall", "cw2", "getrandom", "hex", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "thiserror", ] @@ -551,12 +544,12 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "cw2", "debug_print", "getrandom", "hex", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "thiserror", ] @@ -564,21 +557,21 @@ dependencies = [ [[package]] name = "cw-storage-plus" version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0e92a069d62067f3472c62e30adedb4cab1754725c0f2a682b3128d2bf3c79" +source = "git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw#238b520c3e193226143eedb717a3ed76187d11de" dependencies = [ "cosmwasm-std", - "schemars 0.8.15", + "schemars 0.8.16", "serde", ] [[package]] name = "cw-storage-plus" -version = "1.1.0" -source = "git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw#238b520c3e193226143eedb717a3ed76187d11de" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" dependencies = [ "cosmwasm-std", - "schemars 0.8.15", + "schemars 0.8.16", "serde", ] @@ -604,7 +597,7 @@ dependencies = [ "ics07-tendermint-cw", "ics08-wasm", "prost", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "serde-json-wasm 0.5.1", "sha2 0.10.8", @@ -617,17 +610,16 @@ dependencies = [ [[package]] name = "cw-xcall" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?tag=v0.1.0-alpha.5#7f250bc9c6560591ccc16289cb8159dd100bbe76" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#d2a21f13e5de2d8f64780f3d9958eb62d7c9c5fa" dependencies = [ - "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=main)", + "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "cw-xcall-lib", "cw2", "debug_print", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "thiserror", ] @@ -641,14 +633,14 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-common", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "cw-xcall", "cw-xcall-lib", "cw2", "debug_print", "getrandom", "hex", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "thiserror", ] @@ -656,29 +648,29 @@ dependencies = [ [[package]] name = "cw-xcall-lib" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?tag=v0.1.0-alpha.5#7f250bc9c6560591ccc16289cb8159dd100bbe76" +source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#d2a21f13e5de2d8f64780f3d9958eb62d7c9c5fa" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", - "cw-storage-plus 1.1.0 (git+https://github.com/icon-project/cw-storage-plus.git?branch=fix-raw)", + "cw-storage-plus 1.1.0", "cw2", "debug_print", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "thiserror", ] [[package]] name = "cw2" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9431d14f64f49e41c6ef5561ed11a5391c417d0cb16455dea8cdcb9037a8d197" +checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schemars 0.8.15", + "cw-storage-plus 1.2.0", + "schemars 0.8.16", + "semver", "serde", "thiserror", ] @@ -705,7 +697,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] @@ -717,7 +709,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "convert_case 0.4.0", - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "rustc_version", "syn 1.0.109", @@ -750,9 +742,9 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.38", + "syn 2.0.40", ] [[package]] @@ -763,21 +755,21 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dyn-clone" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" +checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", "digest 0.10.7", "elliptic-curve", "rfc6979", - "signature 2.1.0", + "signature 2.2.0", "spki", ] @@ -826,9 +818,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -843,6 +835,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "env_logger" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +dependencies = [ + "log", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -851,19 +852,19 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "eyre" -version = "0.6.8" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +checksum = "8bbb8258be8305fb0237d7b295f47bb24ff1b136a535f473baf40e70468515aa" dependencies = [ "indenter", "once_cell", @@ -891,9 +892,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ - "byteorder", - "rand", - "rustc-hex", "static_assertions", ] @@ -927,9 +925,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -941,9 +939,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -951,33 +949,33 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-core", "futures-sink", @@ -999,9 +997,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", @@ -1030,9 +1028,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" @@ -1083,13 +1081,13 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "ibc" version = "0.15.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#50eb36a8a1c4f67ae573ac447f6b1ba46f37791c" dependencies = [ "cosmwasm-schema", "derive_more", @@ -1120,11 +1118,11 @@ dependencies = [ [[package]] name = "ibc-derive" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#50eb36a8a1c4f67ae573ac447f6b1ba46f37791c" dependencies = [ "convert_case 0.6.0", - "proc-macro-crate", - "proc-macro2 1.0.69", + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] @@ -1132,12 +1130,12 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.18.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#50eb36a8a1c4f67ae573ac447f6b1ba46f37791c" dependencies = [ "base64 0.13.1", "bytes", "prost", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "tendermint-proto 0.28.0", ] @@ -1145,12 +1143,12 @@ dependencies = [ [[package]] name = "ibc-proto" version = "0.18.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +source = "git+https://github.com/ComposableFi/composable-ibc.git#50eb36a8a1c4f67ae573ac447f6b1ba46f37791c" dependencies = [ "base64 0.13.1", "bytes", "prost", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "tendermint-proto 0.28.0", ] @@ -1173,7 +1171,7 @@ dependencies = [ [[package]] name = "ics07-tendermint" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#50eb36a8a1c4f67ae573ac447f6b1ba46f37791c" dependencies = [ "bytes", "flex-error", @@ -1195,7 +1193,7 @@ dependencies = [ [[package]] name = "ics07-tendermint-cw" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#50eb36a8a1c4f67ae573ac447f6b1ba46f37791c" dependencies = [ "byteorder", "cosmwasm-schema", @@ -1213,7 +1211,7 @@ dependencies = [ "ics08-wasm", "ics23 0.10.0", "prost", - "schemars 0.8.15", + "schemars 0.8.16", "serde", "sha2 0.10.8", "sha3", @@ -1226,7 +1224,7 @@ dependencies = [ [[package]] name = "ics08-wasm" version = "0.1.0" -source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#2a8ed31167e6d5444337ac49cb4d0b916cb22677" +source = "git+https://github.com/ComposableFi/composable-ibc.git?branch=master#50eb36a8a1c4f67ae573ac447f6b1ba46f37791c" dependencies = [ "cosmwasm-schema", "hex", @@ -1263,15 +1261,6 @@ dependencies = [ "prost", ] -[[package]] -name = "impl-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" -dependencies = [ - "parity-scale-codec", -] - [[package]] name = "impl-serde" version = "0.4.0" @@ -1287,7 +1276,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] @@ -1300,12 +1289,12 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.3", ] [[package]] @@ -1319,22 +1308,22 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "k256" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", "once_cell", "sha2 0.10.8", - "signature 2.1.0", + "signature 2.2.0", ] [[package]] @@ -1354,15 +1343,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "log" @@ -1407,7 +1396,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] @@ -1423,9 +1412,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -1441,9 +1430,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parity-scale-codec" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ "arrayvec", "bitvec", @@ -1455,12 +1444,12 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.69", + "proc-macro-crate 2.0.1", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] @@ -1540,19 +1529,13 @@ dependencies = [ "spki", ] -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "prettyplease" version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "syn 1.0.109", ] @@ -1563,7 +1546,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", - "impl-codec", "impl-serde", "uint", ] @@ -1575,7 +1557,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +dependencies = [ + "toml_datetime", + "toml_edit 0.20.2", ] [[package]] @@ -1589,9 +1581,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -1636,7 +1628,7 @@ checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] @@ -1665,7 +1657,7 @@ version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", ] [[package]] @@ -1674,27 +1666,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - [[package]] name = "rand_core" version = "0.5.1" @@ -1712,23 +1683,23 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.10.0" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.1", - "regex-syntax 0.8.1", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -1742,13 +1713,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.1", + "regex-syntax 0.8.2", ] [[package]] @@ -1759,9 +1730,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rfc6979" @@ -1788,7 +1759,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] @@ -1810,22 +1781,22 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.19" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "safe-proc-macro2" @@ -1876,9 +1847,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "bitvec", "cfg-if", @@ -1889,12 +1860,12 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.69", + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] @@ -1912,12 +1883,12 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", - "schemars_derive 0.8.15", + "schemars_derive 0.8.16", "serde", "serde_json", ] @@ -1928,7 +1899,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73ab7f0b9b64633747a68dce4ed6318bbf30e3befe67df7624ad83abb7295c09" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "serde_derive_internals 0.25.0", "syn 1.0.109", @@ -1936,11 +1907,11 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "serde_derive_internals 0.26.0", "syn 1.0.109", @@ -1968,9 +1939,9 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -2004,13 +1975,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.38", + "syn 2.0.40", ] [[package]] @@ -2019,7 +1990,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dbab34ca63057a1f15280bdf3c39f2b1eb1b54c17e98360e511637aef7418c6" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] @@ -2030,16 +2001,16 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -2048,13 +2019,13 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.38", + "syn 2.0.40", ] [[package]] @@ -2108,9 +2079,9 @@ checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", "rand_core 0.6.4", @@ -2118,9 +2089,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "snafu" @@ -2145,9 +2116,9 @@ dependencies = [ [[package]] name = "spki" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", @@ -2197,18 +2168,18 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.38" +version = "2.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "13fa70a4ee923979ffb522cacce59d34421ebdea5625e1073c4326ef9d2dd42e" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", "unicode-ident", ] @@ -2221,15 +2192,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", "redox_syscall", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2334,13 +2305,24 @@ dependencies = [ [[package]] name = "test-log" -version = "0.2.13" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6159ab4116165c99fc88cce31f99fa2c9dbe08d3691cb38da02fc3b45f357d2b" +dependencies = [ + "env_logger", + "test-log-macros", + "tracing-subscriber", +] + +[[package]] +name = "test-log-macros" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f66edd6b6cd810743c0c71e1d085e92b01ce6a72782032e3f794c8284fe4bcdd" +checksum = "7ba277e77219e9eea169e8508942db1bf5d8a41ff2db9b20aab5a5aadc9fa25d" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.38", + "syn 2.0.40", ] [[package]] @@ -2360,22 +2342,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.38", + "syn 2.0.40", ] [[package]] @@ -2431,22 +2413,32 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -2454,12 +2446,12 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -2475,9 +2467,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -2588,7 +2580,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -2597,13 +2598,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -2612,47 +2628,89 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" -version = "0.5.16" +version = "0.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" +checksum = "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff" dependencies = [ "memchr", ] @@ -2668,9 +2726,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] @@ -2681,7 +2739,7 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2 1.0.70", "quote 1.0.33", - "syn 2.0.38", + "syn 2.0.40", ] diff --git a/Cargo.toml b/Cargo.toml index 59ef52a18..1c05f7865 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,10 +23,10 @@ cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", br common = { path="./libraries/rust/common" } cw-common = { path="./contracts/cosmwasm-vm/cw-common" } -cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", tag="v0.1.0-alpha.5"} -cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", tag="v0.1.0-alpha.5"} -cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", tag="v0.1.0-alpha.5" } -cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", tag="v0.1.0-alpha.5" } +cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3"} +cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3"} +cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3" } +cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3" } cw2 = {version="1.0.1",default-features = false} ibc-proto = { version = "0.26.0", default-features = false} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml b/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml index 415a991e1..5e63e2744 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-ibc-core/Cargo.toml @@ -31,7 +31,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] cosmwasm-schema = {workspace=true} -cosmwasm-std = {workspace=true,features = ["ibc3"]} +cosmwasm-std = {workspace=true} cw-storage-plus = {workspace=true} cw2 = {workspace=true} schemars = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs index 019e0f078..47340d565 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs @@ -165,6 +165,7 @@ pub trait IQueryHandler { if client_state.frozen_height != 0 && height > client_state.frozen_height { return Err(ContractError::ClientStateFrozen(client_state.frozen_height)); } + cw_println!(deps.api, "[LightClient]: value is: {:?}", value); let mut value_hash = value.to_vec(); if !value.is_empty() { diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 628d71d5c..8e71701d2 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -74,13 +74,28 @@ fn process_message( msg ); match msg { - ExecuteMsg::VerifyMembership(msg) => { + ExecuteMsg::VerifyMembership(mut msg) => { cw_println!(deps_mut.api, "[WasmClient]: Verify Membership called"); let height = msg.height.revision_height; + if msg.proof == "empty".as_bytes() { + msg.proof = vec![]; + } let client_id = CLIENT_ID; let proofs_decoded = MerkleProofs::decode(msg.proof.as_slice()).map_err(ContractError::DecodeError)?; - let path = hex::decode(msg.path.key_path.join("")).unwrap(); + cw_println!( + deps_mut.api, + "[WasmClient]: Contract Execute Called with Path {:?}", + msg.path.key_path + ); + let fullpath = msg.path.key_path[1].clone(); + cw_println!(deps_mut.api, "[WasmClient]: Full Path is {:?}", fullpath); + let path = fullpath.as_bytes().to_vec(); + let (skip, value) = unwrap_any_type(deps_mut.as_ref(), &msg.value); + + if skip { + return Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?); + } QueryHandler::verify_membership( deps_mut.as_ref(), @@ -89,9 +104,10 @@ fn process_message( msg.delay_time_period, msg.delay_block_period, &proofs_decoded.proofs, - &msg.value, + &value, &path, )?; + cw_println!(deps_mut.api, "[WasmClient]: Verify Membership Complete"); Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) @@ -175,6 +191,21 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { } } +pub fn unwrap_any_type(deps: Deps, value: &[u8]) -> (bool, Vec) { + let any_result = Any::decode(value); + match any_result { + Ok(any) => { + let type_url = any.type_url.to_string(); + match type_url.as_ref() { + "/ibc.lightclients.tendermint.v1.ClientState" => return (false, any.value), + "/ibc.lightclients.tendermint.v1.ConsensusState" => return (true, any.value), + _ => return (false, value.to_vec()), + } + } + Err(e) => (false, value.to_vec()), + } +} + #[cw_serde] pub struct MigrateMsg {} From bab070a5faf020b74d383864fd6cda6e19b121a3 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Wed, 3 Jan 2024 14:52:34 +0545 Subject: [PATCH 42/64] fix: ack hashing --- .../cw-icon-light-client/src/contract.rs | 8 ++++++++ .../src/traits/query_handler.rs | 9 ++++++++- .../cw-wasm-light-client/src/contract.rs | 19 +++++++++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs index 91fd682da..1c03d5dc9 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs @@ -171,6 +171,7 @@ pub fn validate_channel_state( &proofs_decoded.proofs, &state.expected_counterparty_channel_end, &state.counterparty_chan_end_path, + true, )?; Ok(result) } @@ -193,6 +194,7 @@ pub fn validate_connection_state( &proofs_decoded.proofs, &state.expected_counterparty_connection_end, &state.counterparty_conn_end_path, + true, )?; Ok(result) } @@ -215,6 +217,7 @@ pub fn validate_client_state( &proofs_decoded.proofs, &state.expected_client_state, &state.client_state_path, + true, )?; Ok(result) } @@ -236,6 +239,7 @@ pub fn validate_consensus_state( &proofs_decoded.proofs, &state.expected_conesenus_state, &state.conesenus_state_path, + true, )?; Ok(result) } @@ -267,6 +271,7 @@ pub fn validate_next_seq_recv( &proofs_decoded.proofs, sequence.to_be_bytes().as_ref(), seq_recv_path, + true, )? } LightClientPacketMessage::VerifyPacketReceiptAbsence { @@ -353,6 +358,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { &proofs_decoded.proofs, &message_bytes, &path, + true, ) .unwrap_or(false); to_binary(&result) @@ -397,6 +403,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { &proofs_decoded.proofs, &verify_packet_data.commitment, &verify_packet_data.commitment_path, + true, ) .unwrap_or(false); @@ -419,6 +426,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { &proofs_decoded.proofs, &verify_packet_acknowledge.ack, &verify_packet_acknowledge.ack_path, + true, ) .unwrap_or(false); diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs index 47340d565..8bfddc968 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs @@ -3,6 +3,7 @@ use common::icon::icon::lightclient::v1::ConsensusState; use common::icon::icon::types::v1::MerkleNode; use common::utils::calculate_root; use common::utils::keccak256; +use common::utils::sha256; use cosmwasm_std::Deps; use cosmwasm_std::Order; use cosmwasm_std::StdResult; @@ -145,6 +146,7 @@ pub trait IQueryHandler { proof: &[MerkleNode], value: &[u8], path: &[u8], + use_keccak: bool, ) -> Result { let client_state = Self::get_client_state(deps.storage, client_id)?; let consensus_state: ConsensusState = @@ -169,7 +171,11 @@ pub trait IQueryHandler { let mut value_hash = value.to_vec(); if !value.is_empty() { - value_hash = keccak256(value).to_vec(); + value_hash = if use_keccak { + keccak256(value).to_vec() + } else { + value.to_vec() + }; } // let _ = @@ -232,6 +238,7 @@ pub trait IQueryHandler { proof, &[], path, + true, ) } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 8e71701d2..b761f9a1b 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -97,7 +97,7 @@ fn process_message( return Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?); } - QueryHandler::verify_membership( + let mut res = QueryHandler::verify_membership( deps_mut.as_ref(), client_id, height, @@ -106,7 +106,22 @@ fn process_message( &proofs_decoded.proofs, &value, &path, - )?; + true, + ); + if res.is_err() { + res = QueryHandler::verify_membership( + deps_mut.as_ref(), + client_id, + height, + msg.delay_time_period, + msg.delay_block_period, + &proofs_decoded.proofs, + &value, + &path, + false, + ); + } + res.unwrap(); cw_println!(deps_mut.api, "[WasmClient]: Verify Membership Complete"); From 47d6376b5578d8dac9eca70c3031bd2ea35d3cf4 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Wed, 3 Jan 2024 16:05:05 +0545 Subject: [PATCH 43/64] doc: add build note --- Cargo.lock | 8 ++-- Cargo.toml | 10 ++--- .../cw-wasm-light-client/README.md | 40 ++++--------------- 3 files changed, 16 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aaf539f0c..f06ef3591 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -199,7 +199,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#1e5daa824b80b6653b1e53c8bd94b4c8c8710d29" +source = "git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client#d2eb1ac6c83de203d10c0488c8c450d1017f0586" dependencies = [ "bytes", "cosmwasm-schema", @@ -609,8 +609,8 @@ dependencies = [ [[package]] name = "cw-xcall" -version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#d2a21f13e5de2d8f64780f3d9958eb62d7c9c5fa" +version = "0.2.0" +source = "git+https://github.com/icon-project/xCall.git?branch=main#a61aefea5e3458ba32c12d6b477dcc89984d4dc6" dependencies = [ "common 0.1.0 (git+https://github.com/icon-project/IBC-Integration.git?branch=feat/cw-wasm-light-client)", "cosmwasm-schema", @@ -648,7 +648,7 @@ dependencies = [ [[package]] name = "cw-xcall-lib" version = "0.1.0" -source = "git+https://github.com/icon-project/xCall.git?branch=fix/cosmwasm-1.3#d2a21f13e5de2d8f64780f3d9958eb62d7c9c5fa" +source = "git+https://github.com/icon-project/xCall.git?branch=main#a61aefea5e3458ba32c12d6b477dcc89984d4dc6" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/Cargo.toml b/Cargo.toml index 1c05f7865..b7ed3785d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ version="0.1.0" [workspace.dependencies] cosmwasm-schema = {version="1.4.0",default-features = false} -cosmwasm-std = {version="1.4.0",default-features = false} +cosmwasm-std = {version="1.4.0",default-features = false,features = ["ibc3"]} schemars = {version="0.8.10",default-features = false} serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } @@ -23,10 +23,10 @@ cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", br common = { path="./libraries/rust/common" } cw-common = { path="./contracts/cosmwasm-vm/cw-common" } -cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3"} -cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3"} -cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3" } -cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="fix/cosmwasm-1.3" } +cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="main"} +cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="main"} +cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="main" } +cw-mock-dapp-multi = { git="https://github.com/icon-project/xCall.git", branch="main" } cw2 = {version="1.0.1",default-features = false} ibc-proto = { version = "0.26.0", default-features = false} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/README.md b/contracts/cosmwasm-vm/cw-wasm-light-client/README.md index e66c6f741..f786a4758 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/README.md +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/README.md @@ -1,33 +1,7 @@ -# Deviations from IBC Tendermint LightClient - -This LightClient was meant to be used for [ICON-IBC Integration](https://github.com/icon-project/IBC-Integration). So, it is made to accomodate all the changes made on IBC Integration such that IBC can be established between ICON and Cosmos based chains. - -The IBC Tendermint LightClient is originally available as module. One of the major deviations in ICON LightClient was to implement it under smart contract environment. - -All other deviations can be found [here](). - -## Changes -The major changes in Icon LightClient Implementation includes: - -- [createClient](#createclient) -- [updateClient](#updateclient) -- [verifyNonMembership](#verifynonmembership) - -## createClient -The IBC Tendermint LightClient sets the *type, clientState, consensusState, blockTimestamp* and *blockHeight* while creating client. - -Our Implementation sets just the *clientState, consensusState* and *blockHeight*. - -## updateClient -In case of IBC Tendermint LightClient, while updating client, the headers are verfied for adjacent or non-adjacent updates. - -In our ICON LightClient relay can update non-adjacent blocks provided that it is within the trusting period and can provide a previous trusted height.It can also update older blocks upto certain time limit from latest updated height in clientstate. - -Similarly, in our ICON LightClient implementation, we are not using the actual block headers, but the BTP headers where we just verify if the incoming BTP header height is always greater than the previous one. Then we store a mapping of BTP block height and actual block height as well as BTP block height and actual block timestamp. - -In IBC Tendermint LightClient, the update is based on block height but in our ICON LightClient, the update is based on BTP block height and epoch. - -## verifyNonMembership -Both IBC Tendermint Lightclient and ICON LightClient uses MerkelProof for verifying membership and non-membership. - -In IBC Tendermint Lightclient, the verifyNonMembership verifies the absence of key. But in case of ICON LightClient, we need to verify that the value of key is empty. \ No newline at end of file +## Wasm LightClient +Implementation of icon lightclient compatible with ics-08 standard. +Since the centauri chain currently does not support features like "staking" in wasm build, we need to disable "ibc3" feature flag in comswasm-std dependency before building it. We cant build entire workspace because other projects depend on "ibc3" feature being enabled, so we have to do standalone build for wasm lightclient. +We can build the lightclient using following command +` +cargo build -p cw-wasm-light-client --release --target wasm32-unknown-unknown +` From 9bcec3b1a4d36f2a918fbaeadd4eee1f18fa69af Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 4 Jan 2024 12:10:23 +0545 Subject: [PATCH 44/64] chore: pass build --- .../src/traits/query_handler.rs | 2 +- .../cosmwasm-vm/cw-wasm-light-client/src/contract.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs index 8bfddc968..99d9ed57a 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs @@ -3,7 +3,7 @@ use common::icon::icon::lightclient::v1::ConsensusState; use common::icon::icon::types::v1::MerkleNode; use common::utils::calculate_root; use common::utils::keccak256; -use common::utils::sha256; + use cosmwasm_std::Deps; use cosmwasm_std::Order; use cosmwasm_std::StdResult; diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index b761f9a1b..8ede71c2a 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -94,7 +94,7 @@ fn process_message( let (skip, value) = unwrap_any_type(deps_mut.as_ref(), &msg.value); if skip { - return Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?); + return to_binary(&ContractResult::success()).map_err(ContractError::Std); } let mut res = QueryHandler::verify_membership( @@ -206,18 +206,18 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { } } -pub fn unwrap_any_type(deps: Deps, value: &[u8]) -> (bool, Vec) { +pub fn unwrap_any_type(_deps: Deps, value: &[u8]) -> (bool, Vec) { let any_result = Any::decode(value); match any_result { Ok(any) => { let type_url = any.type_url.to_string(); match type_url.as_ref() { - "/ibc.lightclients.tendermint.v1.ClientState" => return (false, any.value), - "/ibc.lightclients.tendermint.v1.ConsensusState" => return (true, any.value), - _ => return (false, value.to_vec()), + "/ibc.lightclients.tendermint.v1.ClientState" => (false, any.value), + "/ibc.lightclients.tendermint.v1.ConsensusState" => (true, any.value), + _ => (false, value.to_vec()), } } - Err(e) => (false, value.to_vec()), + Err(_e) => (false, value.to_vec()), } } From 585cc2b004f83fc6a7a0c624308860f64d6796cd Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 4 Jan 2024 21:38:41 +0545 Subject: [PATCH 45/64] fix: do sha256 --- .../cosmwasm-vm/cw-icon-light-client/src/contract.rs | 8 -------- .../cw-light-client-common/src/traits/query_handler.rs | 8 +------- .../cosmwasm-vm/cw-wasm-light-client/src/contract.rs | 5 ++--- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs index 1c03d5dc9..91fd682da 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs @@ -171,7 +171,6 @@ pub fn validate_channel_state( &proofs_decoded.proofs, &state.expected_counterparty_channel_end, &state.counterparty_chan_end_path, - true, )?; Ok(result) } @@ -194,7 +193,6 @@ pub fn validate_connection_state( &proofs_decoded.proofs, &state.expected_counterparty_connection_end, &state.counterparty_conn_end_path, - true, )?; Ok(result) } @@ -217,7 +215,6 @@ pub fn validate_client_state( &proofs_decoded.proofs, &state.expected_client_state, &state.client_state_path, - true, )?; Ok(result) } @@ -239,7 +236,6 @@ pub fn validate_consensus_state( &proofs_decoded.proofs, &state.expected_conesenus_state, &state.conesenus_state_path, - true, )?; Ok(result) } @@ -271,7 +267,6 @@ pub fn validate_next_seq_recv( &proofs_decoded.proofs, sequence.to_be_bytes().as_ref(), seq_recv_path, - true, )? } LightClientPacketMessage::VerifyPacketReceiptAbsence { @@ -358,7 +353,6 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { &proofs_decoded.proofs, &message_bytes, &path, - true, ) .unwrap_or(false); to_binary(&result) @@ -403,7 +397,6 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { &proofs_decoded.proofs, &verify_packet_data.commitment, &verify_packet_data.commitment_path, - true, ) .unwrap_or(false); @@ -426,7 +419,6 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { &proofs_decoded.proofs, &verify_packet_acknowledge.ack, &verify_packet_acknowledge.ack_path, - true, ) .unwrap_or(false); diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs index 99d9ed57a..0075e80e3 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs @@ -146,7 +146,6 @@ pub trait IQueryHandler { proof: &[MerkleNode], value: &[u8], path: &[u8], - use_keccak: bool, ) -> Result { let client_state = Self::get_client_state(deps.storage, client_id)?; let consensus_state: ConsensusState = @@ -171,11 +170,7 @@ pub trait IQueryHandler { let mut value_hash = value.to_vec(); if !value.is_empty() { - value_hash = if use_keccak { - keccak256(value).to_vec() - } else { - value.to_vec() - }; + value_hash = keccak256(value).to_vec(); } // let _ = @@ -238,7 +233,6 @@ pub trait IQueryHandler { proof, &[], path, - true, ) } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 8ede71c2a..fa60f8dbe 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -1,4 +1,5 @@ use common::traits::AnyTypes; +use common::utils::sha256; use cosmwasm_schema::cw_serde; use cw_common::cw_println; @@ -106,7 +107,6 @@ fn process_message( &proofs_decoded.proofs, &value, &path, - true, ); if res.is_err() { res = QueryHandler::verify_membership( @@ -116,9 +116,8 @@ fn process_message( msg.delay_time_period, msg.delay_block_period, &proofs_decoded.proofs, - &value, + &sha256(value), &path, - false, ); } res.unwrap(); From a1664c55fe3f8f5348f00df158117a5dcfeca44d Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 8 Jan 2024 20:41:22 +0545 Subject: [PATCH 46/64] fix: check misbehaviour --- Cargo.toml | 2 +- contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cf8d89a1a..24490cac0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ version="0.1.1" [workspace.dependencies] cosmwasm-schema = {version="1.4.0",default-features = false} -cosmwasm-std = {version="1.4.0",default-features = false,features = ["ibc3"]} +cosmwasm-std = {version="1.4.0",default-features = false} schemars = {version="0.8.10",default-features = false} serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index fa60f8dbe..a242ac537 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -180,7 +180,10 @@ fn process_message( Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) } } - } + }, + ExecuteMsg::UpdateStateOnMisbehaviour(_)=>{ + Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) + }, _ => todo!(), } } From 257a93b11d6656c8baa68b1eabce60b3d42d04c3 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Fri, 19 Jan 2024 10:22:43 +0545 Subject: [PATCH 47/64] chore: pass build --- .../cw-wasm-light-client/src/contract.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index a242ac537..9c7cb50b1 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -93,6 +93,7 @@ fn process_message( cw_println!(deps_mut.api, "[WasmClient]: Full Path is {:?}", fullpath); let path = fullpath.as_bytes().to_vec(); let (skip, value) = unwrap_any_type(deps_mut.as_ref(), &msg.value); + cw_println!(deps_mut.api, "[WasmClient]: Full Value is {:?}", &value); if skip { return to_binary(&ContractResult::success()).map_err(ContractError::Std); @@ -184,7 +185,18 @@ fn process_message( ExecuteMsg::UpdateStateOnMisbehaviour(_)=>{ Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) }, - _ => todo!(), + ExecuteMsg::VerifyUpgradeAndUpdateState(msg)=>{ + todo!() + + }, + ExecuteMsg::CheckSubstituteAndUpdateState(msg)=>{ + todo!() + }, + ExecuteMsg::CheckForMisbehaviour(msg)=>{ + let mut result=ContractResult::success(); + result.found_misbehaviour=false; + Ok(to_binary(&result).map_err(ContractError::Std)?) + }, } } From 763fd48ebf464d8de67e825ef8e9012204cf92e1 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 29 Jan 2024 02:49:06 +0545 Subject: [PATCH 48/64] fix:resolve comments --- contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml | 2 +- .../cw-light-client-common/src/traits/query_handler.rs | 8 ++------ .../cosmwasm-vm/cw-wasm-light-client/src/contract.rs | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml index c7f91a447..49db039dd 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml +++ b/contracts/cosmwasm-vm/cw-icon-light-client/Cargo.toml @@ -45,7 +45,7 @@ sha3 = { version = "0.10.6", default-features = false } bytes = { workspace=true } common = { workspace=true, default-features = false } cw-common = { workspace=true,default-features = false } -cw-light-client-common = { path="../cw-light-client-common",default-features = false } +cw-light-client-common = { workspace=true, default-features = false } prost = { workspace=true} serde-json-wasm = {workspace=true} debug_print = {workspace=true} diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs index 0075e80e3..13a0b53ac 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs @@ -53,14 +53,10 @@ pub trait IQueryHandler { storage: &dyn Storage, client_id: &str, ) -> Result { - let state = CLIENT_STATES - .load(storage, client_id.to_string()) - .map_err(ContractError::Std)?; - let client_state = - ClientState::decode(state.as_slice()).map_err(ContractError::DecodeError)?; + let latest_height=Self::get_latest_height(storage, client_id)?; let consensus_state = - Self::get_consensus_state(storage, client_id, client_state.latest_height)?; + Self::get_consensus_state(storage, client_id, latest_height)?; Ok(consensus_state) } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 9c7cb50b1..dc6ac4b83 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -78,6 +78,7 @@ fn process_message( ExecuteMsg::VerifyMembership(mut msg) => { cw_println!(deps_mut.api, "[WasmClient]: Verify Membership called"); let height = msg.height.revision_height; + // "empty" is sent by relayer because native IBC doesnt support empty proofs. if msg.proof == "empty".as_bytes() { msg.proof = vec![]; } From c121bfdfc16f2d69ef8c11c01aadce235f89d293 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 29 Jan 2024 03:33:58 +0545 Subject: [PATCH 49/64] chore: pass build --- Cargo.toml | 5 +++- .../src/traits/query_handler.rs | 5 ++-- .../cw-wasm-light-client/src/contract.rs | 25 +++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 24490cac0..fb7159241 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ version="0.1.1" [workspace.dependencies] cosmwasm-schema = {version="1.4.0",default-features = false} -cosmwasm-std = {version="1.4.0",default-features = false} +cosmwasm-std = {version="1.4.0",default-features = false, features = ["ibc3"]} schemars = {version="0.8.10",default-features = false} serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } @@ -23,6 +23,9 @@ cw-storage-plus = {git="https://github.com/icon-project/cw-storage-plus.git", br common = { path="./libraries/rust/common" } cw-common = { path="./contracts/cosmwasm-vm/cw-common" } +cw-light-client-common= {path="./contracts/cosmwasm-vm/cw-light-client-common"} + + cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xCall.git", branch="main"} cw-xcall = {package="cw-xcall", git="https://github.com/icon-project/xCall.git", branch="main"} cw-mock-dapp = { git="https://github.com/icon-project/xCall.git", branch="main" } diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs index 13a0b53ac..3d9e2e2c2 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/traits/query_handler.rs @@ -53,10 +53,9 @@ pub trait IQueryHandler { storage: &dyn Storage, client_id: &str, ) -> Result { - let latest_height=Self::get_latest_height(storage, client_id)?; + let latest_height = Self::get_latest_height(storage, client_id)?; - let consensus_state = - Self::get_consensus_state(storage, client_id, latest_height)?; + let consensus_state = Self::get_consensus_state(storage, client_id, latest_height)?; Ok(consensus_state) } diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index dc6ac4b83..13608b6e7 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -182,22 +182,21 @@ fn process_message( Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) } } - }, - ExecuteMsg::UpdateStateOnMisbehaviour(_)=>{ + } + ExecuteMsg::UpdateStateOnMisbehaviour(_) => { Ok(to_binary(&ContractResult::success()).map_err(ContractError::Std)?) - }, - ExecuteMsg::VerifyUpgradeAndUpdateState(msg)=>{ + } + ExecuteMsg::VerifyUpgradeAndUpdateState(_msg) => { todo!() - - }, - ExecuteMsg::CheckSubstituteAndUpdateState(msg)=>{ - todo!() - }, - ExecuteMsg::CheckForMisbehaviour(msg)=>{ - let mut result=ContractResult::success(); - result.found_misbehaviour=false; + } + ExecuteMsg::CheckSubstituteAndUpdateState(_msg) => { + todo!() + } + ExecuteMsg::CheckForMisbehaviour(_msg) => { + let mut result = ContractResult::success(); + result.found_misbehaviour = false; Ok(to_binary(&result).map_err(ContractError::Std)?) - }, + } } } From 71f1126322abba7d570093595f2588191bc7a029 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 29 Jan 2024 05:55:32 +0545 Subject: [PATCH 50/64] fix: remove unnecessary hash --- .../cw-wasm-light-client/src/contract.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 13608b6e7..6342c9711 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -95,12 +95,12 @@ fn process_message( let path = fullpath.as_bytes().to_vec(); let (skip, value) = unwrap_any_type(deps_mut.as_ref(), &msg.value); cw_println!(deps_mut.api, "[WasmClient]: Full Value is {:?}", &value); - + // in case of consensusstate we skip verification since its not viable for icon chain. if skip { return to_binary(&ContractResult::success()).map_err(ContractError::Std); } - let mut res = QueryHandler::verify_membership( + QueryHandler::verify_membership( deps_mut.as_ref(), client_id, height, @@ -109,20 +109,7 @@ fn process_message( &proofs_decoded.proofs, &value, &path, - ); - if res.is_err() { - res = QueryHandler::verify_membership( - deps_mut.as_ref(), - client_id, - height, - msg.delay_time_period, - msg.delay_block_period, - &proofs_decoded.proofs, - &sha256(value), - &path, - ); - } - res.unwrap(); + )?; cw_println!(deps_mut.api, "[WasmClient]: Verify Membership Complete"); From 2b04afaa29344bdfc90a2a67f1bd65406b61b4ba Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Mon, 29 Jan 2024 06:04:42 +0545 Subject: [PATCH 51/64] chore: pass build --- contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs index 6342c9711..0db608e0c 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/contract.rs @@ -1,5 +1,5 @@ use common::traits::AnyTypes; -use common::utils::sha256; + use cosmwasm_schema::cw_serde; use cw_common::cw_println; From c3dd1213351f9fa8289834f7f13c1740a3cc696b Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Tue, 20 Feb 2024 13:52:57 +0545 Subject: [PATCH 52/64] fix: rename client id --- contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs index da4e59b54..623173c7d 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/src/constants.rs @@ -1 +1 @@ -pub const CLIENT_ID: &str = "08-wasm-0"; +pub const CLIENT_ID: &str = "08-iconwasm-0"; From 94976155c5039c5477af26d6fc0a6b25960aeac0 Mon Sep 17 00:00:00 2001 From: AntonAndell Date: Tue, 23 Jan 2024 10:24:06 +0100 Subject: [PATCH 53/64] fix: Fix reverse sign on timestamp check for request timeout --- .../java/ibc/ics04/channel/IBCPacket.java | 5 +- .../java/ibc/ics04/channel/PacketTest.java | 65 ++++++++++++++++++- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/contracts/javascore/ibc/src/main/java/ibc/ics04/channel/IBCPacket.java b/contracts/javascore/ibc/src/main/java/ibc/ics04/channel/IBCPacket.java index 548588506..593401ebe 100644 --- a/contracts/javascore/ibc/src/main/java/ibc/ics04/channel/IBCPacket.java +++ b/contracts/javascore/ibc/src/main/java/ibc/ics04/channel/IBCPacket.java @@ -228,9 +228,10 @@ public void _requestTimeout(MsgRequestTimeoutPacket msg) { boolean heightTimeout = revisionHeight.compareTo(BigInteger.ZERO) > 0 && BigInteger.valueOf(Context.getBlockHeight()) .compareTo(revisionHeight) >= 0; - boolean timeTimeout = packet.getTimeoutTimestamp().compareTo(BigInteger.ZERO) > 0 + BigInteger timeoutTimestamp = packet.getTimeoutTimestamp(); + boolean timeTimeout = timeoutTimestamp.compareTo(BigInteger.ZERO) > 0 && BigInteger.valueOf(Context.getBlockTimestamp()) - .compareTo(packet.getTimeoutTimestamp()) < 0; + .compareTo(timeoutTimestamp) >= 0; Context.require(heightTimeout || timeTimeout, "Packet has not yet timed out"); byte[] commitmentPath = IBCCommitment.packetCommitmentPath(packet.getSourcePort(), diff --git a/contracts/javascore/ibc/src/test/java/ibc/ics04/channel/PacketTest.java b/contracts/javascore/ibc/src/test/java/ibc/ics04/channel/PacketTest.java index abf929dd1..4709532cf 100644 --- a/contracts/javascore/ibc/src/test/java/ibc/ics04/channel/PacketTest.java +++ b/contracts/javascore/ibc/src/test/java/ibc/ics04/channel/PacketTest.java @@ -540,7 +540,7 @@ void requestTimeout_UnOrdered() { packet.invoke(owner, "setChannel", portId, channelId, baseChannel); Height timeoutHeight = new Height(); timeoutHeight.setRevisionHeight(BigInteger.valueOf(sm.getBlock().getHeight())); - MsgRequestTimeoutPacket timeoutPacket=new MsgRequestTimeoutPacket(); + MsgRequestTimeoutPacket timeoutPacket = new MsgRequestTimeoutPacket(); basePacket.setTimeoutHeight(timeoutHeight); basePacket.setTimeoutTimestamp(BigInteger.valueOf(sm.getBlock().getTimestamp())); byte[] commitmentPath = IBCCommitment.packetReceiptCommitmentKey(basePacket.getSourcePort(), @@ -562,7 +562,7 @@ void requestTimeout_Ordered() { packet.invoke(owner, "setChannel", portId, channelId, baseChannel); Height timeoutHeight = new Height(); timeoutHeight.setRevisionHeight(BigInteger.valueOf(sm.getBlock().getHeight())); - MsgRequestTimeoutPacket timeoutPacket=new MsgRequestTimeoutPacket(); + MsgRequestTimeoutPacket timeoutPacket = new MsgRequestTimeoutPacket(); basePacket.setTimeoutHeight(timeoutHeight); basePacket.setTimeoutTimestamp(BigInteger.valueOf(sm.getBlock().getTimestamp())); byte[] commitmentPath = IBCCommitment.nextSequenceRecvCommitmentKey(basePacket.getSourcePort(), @@ -578,6 +578,67 @@ void requestTimeout_Ordered() { ByteUtil.join(commitmentPath, Proto.encodeFixed64(basePacket.getSequence(), false))); } + @Test + void requestTimeout_timestamp() { + // Arrange + baseChannel.setOrdering(Channel.Order.ORDER_UNORDERED); + packet.invoke(owner, "setChannel", portId, channelId, baseChannel); + MsgRequestTimeoutPacket timeoutPacket = new MsgRequestTimeoutPacket(); + basePacket.setTimeoutTimestamp(BigInteger.valueOf(sm.getBlock().getTimestamp())); + byte[] commitmentPath = IBCCommitment.packetReceiptCommitmentKey(basePacket.getSourcePort(), + basePacket.getSourceChannel(), basePacket.getSequence()); + timeoutPacket.setPacket(basePacket.encode()); + timeoutPacket.setProofHeight(new byte[0]); + timeoutPacket.setProof(new byte[0]); + // Act + packet.invoke(owner, "_requestTimeout", timeoutPacket); + + // Assert + verify(packetSpy).sendBTPMessage(clientId, commitmentPath); + } + + @Test + void requestTimeout_NotYetTimedOut_Timestamp() { + // Arrange + baseChannel.setOrdering(Channel.Order.ORDER_UNORDERED); + packet.invoke(owner, "setChannel", portId, channelId, baseChannel); + MsgRequestTimeoutPacket timeoutPacket = new MsgRequestTimeoutPacket(); + basePacket.setTimeoutTimestamp(BigInteger.valueOf(sm.getBlock().getTimestamp()).multiply(BigInteger.TWO)); + byte[] commitmentPath = IBCCommitment.packetReceiptCommitmentKey(basePacket.getSourcePort(), + basePacket.getSourceChannel(), basePacket.getSequence()); + timeoutPacket.setPacket(basePacket.encode()); + timeoutPacket.setProofHeight(new byte[0]); + timeoutPacket.setProof(new byte[0]); + String expectedErrorMessage = "Packet has not yet timed out"; + + // Act + Executable beforeTimeout = () -> packet.invoke(owner, "_requestTimeout", timeoutPacket); + AssertionError e = assertThrows(AssertionError.class, beforeTimeout); + assertTrue(e.getMessage().contains(expectedErrorMessage)); + } + + @Test + void requestTimeout_NotYetTimedOut_Height() { + // Arrange + baseChannel.setOrdering(Channel.Order.ORDER_UNORDERED); + packet.invoke(owner, "setChannel", portId, channelId, baseChannel); + Height timeoutHeight = new Height(); + timeoutHeight.setRevisionHeight(BigInteger.valueOf(sm.getBlock().getHeight()).multiply(BigInteger.TWO)); + MsgRequestTimeoutPacket timeoutPacket = new MsgRequestTimeoutPacket(); + basePacket.setTimeoutHeight(timeoutHeight); + byte[] commitmentPath = IBCCommitment.packetReceiptCommitmentKey(basePacket.getSourcePort(), + basePacket.getSourceChannel(), basePacket.getSequence()); + timeoutPacket.setPacket(basePacket.encode()); + timeoutPacket.setProofHeight(new byte[0]); + timeoutPacket.setProof(new byte[0]); + String expectedErrorMessage = "Packet has not yet timed out"; + + // Act + Executable beforeTimeout = () -> packet.invoke(owner, "_requestTimeout", timeoutPacket); + AssertionError e = assertThrows(AssertionError.class, beforeTimeout); + assertTrue(e.getMessage().contains(expectedErrorMessage)); + } + @Test void timeoutPacket_unOrdered() { // Arrange From 9a7876bcebc95c56ac9e1303fe0f436b545e738e Mon Sep 17 00:00:00 2001 From: undefined <107839945+bishalbikram@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:11:26 +0545 Subject: [PATCH 54/64] chore: update test coverage for ibc client (#846) --- .../cosmwasm-vm/cw-ibc-core/tests/setup.rs | 75 +- .../cw-ibc-core/tests/test_client.rs | 943 +++++------------- 2 files changed, 349 insertions(+), 669 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/setup.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/setup.rs index 5a08acf87..2a1bb77e0 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/setup.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/setup.rs @@ -34,8 +34,8 @@ use cosmwasm_std::{ mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR, }, - to_binary, Addr, Binary, BlockInfo, ContractInfo, ContractResult, Empty, Env, IbcEndpoint, - MessageInfo, OwnedDeps, SystemResult, Timestamp, TransactionInfo, WasmQuery, + to_binary, Addr, Binary, BlockInfo, ContractInfo, ContractResult, DepsMut, Empty, Env, + IbcEndpoint, MessageInfo, OwnedDeps, SystemResult, Timestamp, TransactionInfo, WasmQuery, }; use common::{ @@ -580,6 +580,7 @@ use cw_common::ibc_types::IbcClientId; use cw_ibc_core::context::CwIbcCoreContext; use cw_ibc_core::ics04_channel::Counterparty; use cw_ibc_core::ics04_channel::State; +use cw_ibc_core::traits::IbcClient; use cw_ibc_core::ConnectionEnd; use cw_ibc_core::{compute_packet_commitment, ChannelEnd, Sequence}; use prost::Message; @@ -631,6 +632,7 @@ pub struct TestContext { pub module_address: Option, pub packet: Option, pub client_id: IbcClientId, + pub client_type: ClientType, pub connection_id: ConnectionId, pub env: Env, pub height: Height, @@ -653,6 +655,7 @@ impl TestContext { port_id: PortId::default(), channel_id: ChannelId::default(), lightclient: Some(LightClient::new("lightclient".to_string())), + client_type: ClientType::new("iconclient".to_string()), packet: None, mock_queries: HashMap::::new(), module_address: Some(Addr::unchecked("moduleaddress")), @@ -831,6 +834,13 @@ impl TestContext { ctx } + pub fn for_client_state(env: Env) -> Self { + let mut ctx = TestContext::default(env); + ctx.client_id = ClientId::from_str("iconclient-0").unwrap(); + + ctx + } + fn setup_channel_end( mut ctx: TestContext, state: State, @@ -1029,6 +1039,31 @@ impl TestContext { self.save_consensus_state(storage, self.client_state.clone().unwrap().latest_height); } + pub fn init_connection_delay( + &mut self, + storage: &mut dyn Storage, + contract: &CwIbcCoreContext, + ) { + contract + .store_last_processed_on(storage, &self.env, &self.client_id) + .unwrap(); + } + + pub fn init_client_state(&mut self, deps: DepsMut, contract: &CwIbcCoreContext) { + self.init_context(deps.storage, &contract); + self.save_consensus_state( + deps.storage, + self.client_state.clone().unwrap().latest_height, + ); + contract.init_client_counter(deps.storage, 0).unwrap(); + self.save_client_commitment( + deps.storage, + &contract, + &self.client_state.clone().unwrap().encode_to_vec(), + ); + self.save_register_client(deps, &contract); + } + pub fn save_next_sequence_send(&self, storage: &mut dyn Storage, contract: &CwIbcCoreContext) { if let Some(packet) = self.packet.clone() { contract @@ -1081,6 +1116,42 @@ impl TestContext { } } + pub fn save_connection_to_client( + &self, + storage: &mut dyn Storage, + contract: &CwIbcCoreContext, + ) { + contract + .store_connection_to_client(storage, &self.client_id, &self.connection_id) + .unwrap(); + } + + pub fn save_client_commitment( + &self, + storage: &mut dyn Storage, + contract: &CwIbcCoreContext, + client_state_hash: &Vec, + ) { + contract + .store_client_commitment( + storage, + &self.env, + &self.client_id, + client_state_hash.clone(), + ) + .unwrap(); + } + + pub fn save_register_client(&self, deps: DepsMut, contract: &CwIbcCoreContext) { + if let Some(lightclient) = self.lightclient.clone() { + let addr = Addr::unchecked(lightclient.get_address()); + + contract + .register_client(deps, self.client_type.clone(), addr) + .unwrap(); + } + } + pub fn save_channel_end(&self, storage: &mut dyn Storage, contract: &CwIbcCoreContext) { if let Some(channel_end) = self.channel_end.clone() { contract diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs index 7340eacb9..e6d422990 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_client.rs @@ -1,20 +1,23 @@ pub mod setup; -use std::collections::HashMap; use std::str::FromStr; +use cosmwasm_std::Timestamp; +use std::time::Duration; + use common::client_state::{get_default_icon_client_state, IClientState}; use common::ibc::{signer::Signer, Height}; use common::icon::icon::lightclient::v1::{ClientState, ConsensusState}; use common::traits::AnyTypes; use common::utils::keccak256; -use cosmwasm_std::testing::mock_env; -use cosmwasm_std::{to_binary, Addr, Binary, Event, Reply, SubMsgResponse}; +use cosmwasm_std::testing::{mock_dependencies, mock_env}; +use cosmwasm_std::{to_binary, to_vec, Addr, Event, Reply, SubMsgResponse}; use cw_common::client_response::{ - CreateClientResponse, MisbehaviourResponse, UpdateClientResponse, UpgradeClientResponse, + MisbehaviourResponse, UpdateClientResponse, UpgradeClientResponse, }; +use cw_common::commitment; use cw_common::raw_types::client::{ RawMsgCreateClient, RawMsgSubmitMisbehaviour, RawMsgUpdateClient, RawMsgUpgradeClient, }; @@ -23,6 +26,7 @@ use cw_common::raw_types::Any; use common::ibc::core::ics02_client::client_type::ClientType; use common::ibc::core::ics24_host::identifier::ClientId; use common::ibc::mock::header::MockHeader; +use cw_ibc_core::conversions::{to_ibc_client_id, to_ibc_connection_id}; use cw_ibc_core::light_client::light_client::LightClient; use cw_ibc_core::{ context::CwIbcCoreContext, @@ -32,7 +36,7 @@ use cw_ibc_core::{ }, traits::IbcClient, }; -use cw_ibc_core::{EXECUTE_CREATE_CLIENT, EXECUTE_UPDATE_CLIENT, EXECUTE_UPGRADE_CLIENT}; +use cw_ibc_core::{EXECUTE_UPDATE_CLIENT, EXECUTE_UPGRADE_CLIENT}; use prost::Message; use setup::*; @@ -243,35 +247,17 @@ fn check_for_genereted_client_id_event() { #[test] fn check_for_create_client_message() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); let contract = CwIbcCoreContext::default(); let info = create_mock_info("alice", "umlg", 2000); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); - - let client_state: ClientState = get_dummy_client_state(); - - let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], - } - .try_into() - .unwrap(); - - let client_type = ClientType::new("iconclient".to_string()); - let light_client = Addr::unchecked("lightclient"); - contract - .register_client(deps.as_mut(), client_type, light_client) - .unwrap(); - - let signer = Signer::from_str("new_signer").unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); let create_client_message = RawMsgCreateClient { - client_state: Some(client_state.to_any()), - consensus_state: Some(consenus_state.to_any()), - signer: signer.to_string(), + client_state: Some(ctx.client_state.unwrap().to_any()), + consensus_state: Some(ctx.consensus_state.unwrap().to_any()), + signer: "new_signer".to_string(), }; let response = contract @@ -279,155 +265,54 @@ fn check_for_create_client_message() { .unwrap(); assert_eq!(response.messages[0].id, 21); - assert_eq!(response.attributes[1].value, "create_client"); } #[test] fn check_for_client_state_from_storage() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); let contract = CwIbcCoreContext::default(); let info = create_mock_info("alice", "umlg", 2000); - let client_type = ClientType::new("iconclient".to_string()); - let client_id = ClientId::new(client_type.clone(), 0).unwrap(); - let mut test_context = TestContext::default(mock_env()); - test_context.client_id = client_id; - test_context.init_context(deps.as_mut().storage, &contract); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); - - let client_state: ClientState = test_context.client_state.clone().unwrap(); - let consenus_state: ConsensusState = test_context.consensus_state.clone().unwrap(); - let light_client = Addr::unchecked("lightclient"); - contract - .register_client(deps.as_mut(), client_type.clone(), light_client) - .unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); - let signer = Signer::from_str("new_signer").unwrap(); + let client_state: ClientState = ctx.client_state.clone().unwrap(); + let consenus_state: ConsensusState = ctx.consensus_state.clone().unwrap(); let create_client_message = RawMsgCreateClient { client_state: Some(client_state.to_any()), consensus_state: Some(consenus_state.to_any()), - signer: signer.to_string(), + signer: "new_signer".to_string(), }; contract .create_client(deps.as_mut(), info, mock_env(), create_client_message) .unwrap(); - let mock_reponse_data = CreateClientResponse::new( - client_type.as_str().to_string(), - "10-15".to_string(), - keccak256(&client_state.encode_to_vec()).to_vec(), - keccak256(&consenus_state.encode_to_vec()).to_vec(), - client_state.to_any().encode_to_vec(), - consenus_state.to_any().encode_to_vec(), - ); - - let mock_data_binary = to_binary(&mock_reponse_data).unwrap(); - - let event = Event::new("empty"); - - let _reply_message = Reply { - id: EXECUTE_CREATE_CLIENT, - result: cosmwasm_std::SubMsgResult::Ok(SubMsgResponse { - events: vec![event], - data: Some(mock_data_binary), - }), - }; - - mock_lightclient_query(test_context.mock_queries, &mut deps); - - let client_id = - common::ibc::core::ics24_host::identifier::ClientId::from_str("iconclient-0").unwrap(); - - let client_state = contract.client_state(deps.as_ref(), &client_id).unwrap(); + mock_lightclient_query(ctx.mock_queries, &mut deps); + let client_state = contract + .client_state(deps.as_ref(), &ctx.client_id) + .unwrap(); assert_eq!(client_state.client_type().as_str(), "iconclient"); } #[test] fn check_for_consensus_state_from_storage() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); let contract = CwIbcCoreContext::default(); - let info = create_mock_info("alice", "umlg", 2000); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); - - let client_state: ClientState = get_dummy_client_state(); - - let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - message_root: vec![1, 2, 3, 4], - next_proof_context_hash: vec![1, 2, 3, 4], - } - .try_into() - .unwrap(); - - let client_type = ClientType::new("iconclient".to_string()); - let light_client = Addr::unchecked("lightclient"); - contract - .register_client(deps.as_mut(), client_type.clone(), light_client) - .unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); - let signer = Signer::from_str("new_signer").unwrap(); - - let create_client_message = RawMsgCreateClient { - client_state: Some(client_state.to_any()), - consensus_state: Some(consenus_state.to_any()), - signer: signer.to_string(), - }; - - contract - .create_client(deps.as_mut(), info, mock_env(), create_client_message) - .unwrap(); - - let mock_reponse_data = CreateClientResponse::new( - client_type.as_str().to_string(), - client_state.latest_height().to_string(), - keccak256(&client_state.encode_to_vec()).to_vec(), - keccak256(&consenus_state.encode_to_vec()).to_vec(), - client_state.to_any().encode_to_vec(), - consenus_state.to_any().encode_to_vec(), - ); - - let mock_data_binary = to_binary(&mock_reponse_data).unwrap(); - - let event = Event::new("empty"); - - let _reply_message = Reply { - id: EXECUTE_CREATE_CLIENT, - result: cosmwasm_std::SubMsgResult::Ok(SubMsgResponse { - events: vec![event], - data: Some(mock_data_binary), - }), - }; - let client_id = - common::ibc::core::ics24_host::identifier::ClientId::from_str("iconclient-0").unwrap(); - - let mut query_map = HashMap::::new(); - query_map = mock_consensus_state_query( - query_map, - &client_id, - &consenus_state, - client_state.latest_height, - ); - mock_lightclient_query(query_map, &mut deps); - - // contract - // .execute_create_client_reply(deps.as_mut(), get_mock_env(), reply_message) - // .unwrap(); - - let height = client_state.latest_height(); - - let consensus_state_result = contract.consensus_state(deps.as_ref(), &client_id, &height); + let height = &ctx.client_state.unwrap().latest_height(); + let consensus_state_result = contract.consensus_state(deps.as_ref(), &ctx.client_id, &height); assert!(consensus_state_result.is_ok()); assert_eq!( - [1, 2, 3, 4], + "message_root".as_bytes().to_vec(), consensus_state_result.unwrap().root().as_bytes() ) } @@ -435,71 +320,39 @@ fn check_for_consensus_state_from_storage() { #[test] #[should_panic(expected = "InvalidNextClientSequence")] fn fails_on_create_client_message_without_proper_initialisation() { + let ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); let contract = CwIbcCoreContext::default(); let info = create_mock_info("alice", "umlg", 2000); - let client_state: ClientState = get_dummy_client_state(); - - let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], - } - .try_into() - .unwrap(); - - let client_type = ClientType::new("iconclient".to_string()); - let light_client = Addr::unchecked("lightclient"); - contract - .register_client(deps.as_mut(), client_type, light_client) - .unwrap(); - - let signer = Signer::from_str("new_signer").unwrap(); - - let create_client_message = RawMsgCreateClient { - client_state: Some(client_state.to_any()), - consensus_state: Some(consenus_state.to_any()), - signer: signer.to_string(), + let msg = RawMsgCreateClient { + client_state: Some(ctx.client_state.unwrap().to_any()), + consensus_state: Some(ctx.consensus_state.unwrap().to_any()), + signer: "new_signer".to_string(), }; - contract - .create_client(deps.as_mut(), info, mock_env(), create_client_message) + .create_client(deps.as_mut(), info, mock_env(), msg) .unwrap(); } #[test] fn check_for_update_client_message() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); let contract = CwIbcCoreContext::default(); let info = create_mock_info("alice", "umlg", 2000); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); + let client_state: ClientState = ctx.client_state.clone().unwrap(); + let consenus_state: ConsensusState = ctx.consensus_state.clone().unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); - let client_state: ClientState = get_dummy_client_state(); - - let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], - } - .try_into() - .unwrap(); - - let client_type = ClientType::new("iconclient".to_string()); - let light_client = Addr::unchecked("lightclient"); - contract - .register_client(deps.as_mut(), client_type, light_client) - .unwrap(); - - let signer = Signer::from_str("new_signer").unwrap(); + mock_lightclient_query(ctx.mock_queries, &mut deps); let create_client_message = RawMsgCreateClient { client_state: Some(client_state.to_any()), consensus_state: Some(consenus_state.to_any()), - signer: signer.to_string(), + signer: "signer".to_string(), }; - let response = contract .create_client( deps.as_mut(), @@ -509,19 +362,8 @@ fn check_for_update_client_message() { ) .unwrap(); assert_eq!(response.messages[0].id, 21); - let client_id = ClientId::from_str("iconclient-0").unwrap(); - let mut query_map = HashMap::::new(); - query_map = mock_consensus_state_query( - query_map, - &client_id, - &consenus_state, - client_state.latest_height().revision_height(), - ); - query_map = mock_client_state_query(query_map, &client_id, &client_state); - mock_lightclient_query(query_map, &mut deps); assert_eq!(response.attributes[1].value, "create_client"); - let client_id = ClientId::from_str("iconclient-0").unwrap(); let msg = RawMsgCreateClient { client_state: Some(client_state.to_any()), @@ -532,33 +374,28 @@ fn check_for_update_client_message() { .create_client(deps.as_mut(), info.clone(), mock_env(), msg) .unwrap(); - let client_state: ClientState = get_dummy_client_state(); - let update_client_message = RawMsgUpdateClient { - client_id: client_id.to_string(), + client_id: ctx.client_id.to_string(), header: Some(client_state.to_any()), - signer: signer.to_string(), + signer: "signer".to_string(), }; - let result = contract .update_client(deps.as_mut(), info, update_client_message) .unwrap(); - assert_eq!(client_id.as_str(), result.attributes[1].value); + assert_eq!(ctx.client_id.as_str(), result.attributes[1].value); let mock_reponse_data = UpdateClientResponse::new( "10-15".to_string(), - client_id.as_str().to_string(), + ctx.client_id.as_str().to_string(), keccak256(&client_state.encode_to_vec()).to_vec(), keccak256(&consenus_state.encode_to_vec()).to_vec(), client_state.encode_to_vec(), consenus_state.encode_to_vec(), ); - let mock_data_binary = to_binary(&mock_reponse_data).unwrap(); let event = Event::new("empty"); - let reply_message = Reply { id: EXECUTE_UPDATE_CLIENT, result: cosmwasm_std::SubMsgResult::Ok(SubMsgResponse { @@ -575,11 +412,8 @@ fn check_for_update_client_message() { let result = update_response.unwrap(); assert_eq!("execute_update_client_reply", result.attributes[0].value); - assert_eq!("10-15", result.attributes[1].value); - assert_eq!("update_client", result.events[0].ty); - assert_eq!("iconclient-0", result.events[0].attributes[0].value) } @@ -607,6 +441,31 @@ fn fails_on_updating_non_existing_client() { .unwrap(); } +#[test] +#[should_panic( + expected = "IbcClientError { error: ClientFrozen { client_id: ClientId(\"iconclient-0\") } }" +)] +fn fails_update_client_for_frozen_client() { + let mut ctx = TestContext::for_client_state(get_mock_env()); + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("alice", "umlg", 2000); + + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 10; + } + + ctx.init_client_state(deps.as_mut(), &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + let msg = RawMsgUpdateClient { + client_id: ctx.client_id.to_string(), + header: Some(get_dummy_client_state().to_any()), + signer: "new_signer".to_string(), + }; + contract.update_client(deps.as_mut(), info, msg).unwrap(); +} + #[test] #[should_panic(expected = "IbcClientError { error: Other { description: \"response_error\" } }")] fn fails_on_error_ressponse() { @@ -624,60 +483,20 @@ fn fails_on_error_ressponse() { #[test] fn check_for_upgrade_client() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); - - let info = create_mock_info("alice", "umlg", 2000); - let env = get_mock_env(); - let contract = CwIbcCoreContext::default(); + let info = create_mock_info("alice", "umlg", 2000); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); - - contract - .ibc_store() - .expected_time_per_block() - .save(deps.as_mut().storage, &(env.block.time.seconds())) - .unwrap(); - - let client_type = ClientType::new("iconclient".to_string()); - let light_client = Addr::unchecked("lightclient"); - - contract - .register_client(deps.as_mut(), client_type.clone(), light_client) - .unwrap(); - - let client_state = ClientState { - trusting_period: 2000000000, - ..get_dummy_client_state() - }; - - let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], + if let Some(client_state) = &mut ctx.client_state { + client_state.trusting_period = 2000000000; } - .try_into() - .unwrap(); - - let mock_reponse_data = CreateClientResponse::new( - client_type.as_str().to_string(), - "0-100".to_string(), - keccak256(&client_state.encode_to_vec()).to_vec(), - keccak256(&consenus_state.encode_to_vec()).to_vec(), - client_state.to_any().encode_to_vec(), - consenus_state.to_any().encode_to_vec(), - ); - let _mock_data_binary = to_binary(&mock_reponse_data).unwrap(); + let client_state = ctx.client_state.clone().unwrap(); + let consenus_state: ConsensusState = ctx.consensus_state.clone().unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); - let _event = Event::new("empty"); - - let client_id = ClientId::from_str("iconclient-0").unwrap(); - let mut query_map = HashMap::::new(); - query_map = mock_consensus_state_query(query_map, &client_id, &consenus_state, 100); - query_map = mock_client_state_query(query_map, &client_id, &client_state); - mock_lightclient_query(query_map, &mut deps); + mock_lightclient_query(ctx.mock_queries, &mut deps); let msg = RawMsgCreateClient { client_state: Some(client_state.to_any()), @@ -688,30 +507,17 @@ fn check_for_upgrade_client() { .create_client(deps.as_mut(), info.clone(), mock_env(), msg) .unwrap(); - let upgrade_client_state = ClientState { - trusting_period: 2000000000, - ..get_dummy_client_state() - } - .to_any(); - - let upgrade_consenus_state: Any = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root_new".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], - } - .to_any(); - let signer = Signer::from_str("new_signer").unwrap(); - let upgrdade_client_message = RawMsgUpgradeClient { - client_id: client_id.to_string(), - client_state: upgrade_client_state.into(), - consensus_state: upgrade_consenus_state.into(), + client_id: ctx.client_id.to_string(), + client_state: Some(client_state.to_any()), + consensus_state: Some(consenus_state.to_any()), proof_upgrade_client: get_dummy_merkle_proof().encode_to_vec(), proof_upgrade_consensus_state: get_dummy_merkle_proof().encode_to_vec(), - signer: signer.to_string(), + signer: "new_signer".to_string(), }; let result = contract - .upgrade_client(deps.as_mut(), info, env, upgrdade_client_message) + .upgrade_client(deps.as_mut(), info, ctx.env, upgrdade_client_message) .unwrap(); assert_eq!("upgrade_client", result.attributes[0].value) @@ -720,52 +526,13 @@ fn check_for_upgrade_client() { #[test] #[should_panic(expected = "IbcClientError { error: HeaderNotWithinTrustPeriod")] fn fails_on_upgrade_client_invalid_trusting_period() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); - - let info = create_mock_info("alice", "umlg", 2000); - let env = get_mock_env(); - let contract = CwIbcCoreContext::default(); + let info = create_mock_info("alice", "umlg", 2000); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); - - contract - .ibc_store() - .expected_time_per_block() - .save(deps.as_mut().storage, &(env.block.time.seconds())) - .unwrap(); - - let client_type = ClientType::new("iconclient".to_string()); - let light_client = Addr::unchecked("lightclient"); - - contract - .register_client(deps.as_mut(), client_type, light_client) - .unwrap(); - let client_state: ClientState = get_dummy_client_state(); - - let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], - } - .try_into() - .unwrap(); - - let client_id = ClientId::from_str("iconclient-0").unwrap(); - let mut query_map = HashMap::::new(); - query_map = mock_consensus_state_query(query_map, &client_id, &consenus_state, 100); - query_map = mock_client_state_query(query_map, &client_id, &client_state); - mock_lightclient_query(query_map, &mut deps); - - let msg = RawMsgCreateClient { - client_state: Some(client_state.to_any()), - consensus_state: Some(consenus_state.to_any()), - signer: "signer".to_string(), - }; - contract - .create_client(deps.as_mut(), info.clone(), mock_env(), msg) - .unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); let upgrade_client_state: Any = common::icon::icon::lightclient::v1::ClientState { trusting_period: 200000000, @@ -776,224 +543,140 @@ fn fails_on_upgrade_client_invalid_trusting_period() { ..get_default_icon_client_state() } .to_any(); - let upgrade_consenus_state: Any = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root_new".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], - } - .to_any(); - let signer = Signer::from_str("new_signer").unwrap(); let upgrdade_client_message = RawMsgUpgradeClient { - client_id: client_id.to_string(), + client_id: ctx.client_id.to_string(), client_state: upgrade_client_state.into(), - consensus_state: upgrade_consenus_state.into(), + consensus_state: Some(ctx.consensus_state.unwrap().to_any()), proof_upgrade_client: get_dummy_merkle_proof().encode_to_vec(), proof_upgrade_consensus_state: get_dummy_merkle_proof().encode_to_vec(), - signer: signer.to_string(), + signer: "new_signer".to_string(), }; - contract - .upgrade_client(deps.as_mut(), info, env, upgrdade_client_message) + .upgrade_client(deps.as_mut(), info, ctx.env, upgrdade_client_message) .unwrap(); } #[test] -#[should_panic( - expected = " IbcClientError { error: ClientFrozen { client_id: ClientId(\"iconclient-0\") } }" -)] -fn fails_on_upgrade_client_frozen_client() { +#[should_panic(expected = "InvalidConsensusStateTimestamp")] +fn fails_on_upgrade_client_invalid_consensus_state_timestamp() { + let mut ctx = TestContext::default(get_mock_env()); let mut deps = deps(); - + let contract = CwIbcCoreContext::default(); let info = create_mock_info("alice", "umlg", 2000); - let env = get_mock_env(); - let contract = CwIbcCoreContext::default(); + let block_time = Duration::from_secs(1); + ctx.env.block.time = Timestamp::from_nanos(block_time.as_nanos() as u64); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + let upgrdade_client_message = RawMsgUpgradeClient { + client_id: ctx.client_id.to_string(), + client_state: Some(ctx.client_state.unwrap().to_any()), + consensus_state: Some(ctx.consensus_state.unwrap().to_any()), + proof_upgrade_client: get_dummy_merkle_proof().encode_to_vec(), + proof_upgrade_consensus_state: get_dummy_merkle_proof().encode_to_vec(), + signer: "signer".to_string(), + }; contract - .ibc_store() - .expected_time_per_block() - .save(deps.as_mut().storage, &(env.block.time.seconds())) + .upgrade_client(deps.as_mut(), info, ctx.env, upgrdade_client_message) .unwrap(); +} - let client_type = ClientType::new("iconclient".to_string()); - let light_client = Addr::unchecked("lightclient"); - - contract - .register_client(deps.as_mut(), client_type.clone(), light_client) - .unwrap(); - let client_id = ClientId::from_str("iconclient-0").unwrap(); - let client_state = ClientState { - frozen_height: 3, - ..get_dummy_client_state() - }; +#[test] +#[should_panic( + expected = " IbcClientError { error: ClientFrozen { client_id: ClientId(\"iconclient-0\") } }" +)] +fn fails_on_upgrade_client_frozen_client() { + let mut ctx = TestContext::for_client_state(get_mock_env()); + let mut deps = deps(); + let info = create_mock_info("alice", "umlg", 2000); + let contract = CwIbcCoreContext::default(); - let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 3; } - .try_into() - .unwrap(); - let mut query_map = HashMap::::new(); - query_map = mock_consensus_state_query( - query_map, - &client_id, - &consenus_state, - client_state.latest_height().revision_height(), - ); - query_map = mock_client_state_query(query_map, &client_id, &client_state); - mock_lightclient_query(query_map, &mut deps); - let _mock_reponse_data = CreateClientResponse::new( - client_type.as_str().to_string(), - "0-100".to_string(), - keccak256(&client_state.encode_to_vec()).to_vec(), - keccak256(&consenus_state.encode_to_vec()).to_vec(), - client_state.to_any().encode_to_vec(), - consenus_state.to_any().encode_to_vec(), - ); + ctx.init_client_state(deps.as_mut(), &contract); + let client_state = ctx.client_state.clone().unwrap(); + let consensus_state: ConsensusState = ctx.consensus_state.clone().unwrap(); + + mock_lightclient_query(ctx.mock_queries, &mut deps); - let client_id = ClientId::from_str("iconclient-0").unwrap(); let msg = RawMsgCreateClient { client_state: Some(client_state.to_any()), - consensus_state: Some(consenus_state.to_any()), + consensus_state: Some(consensus_state.to_any()), signer: "signer".to_string(), }; contract .create_client(deps.as_mut(), info.clone(), mock_env(), msg) .unwrap(); - let upgrade_client_state: Any = common::icon::icon::lightclient::v1::ClientState { - trusting_period: 200000000, - frozen_height: 0, - max_clock_drift: 5, - latest_height: 100, - - ..get_default_icon_client_state() - } - .to_any(); - - let upgrade_consenus_state: Any = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root_new".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], - } - .to_any(); - let signer = Signer::from_str("new_signer").unwrap(); - let upgrdade_client_message = RawMsgUpgradeClient { - client_id: client_id.to_string(), - client_state: upgrade_client_state.into(), - consensus_state: upgrade_consenus_state.into(), + client_id: ctx.client_id.to_string(), + client_state: Some(client_state.to_any()), + consensus_state: Some(consensus_state.to_any()), proof_upgrade_client: get_dummy_merkle_proof().encode_to_vec(), proof_upgrade_consensus_state: get_dummy_merkle_proof().encode_to_vec(), - signer: signer.to_string(), + signer: "new_signer".to_string(), }; contract - .upgrade_client(deps.as_mut(), info, env, upgrdade_client_message) + .upgrade_client(deps.as_mut(), info, ctx.env, upgrdade_client_message) .unwrap(); } #[test] fn check_for_execute_upgrade_client() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); - let info = create_mock_info("alice", "umlg", 2000); - let env = get_mock_env(); - let contract = CwIbcCoreContext::default(); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); - - contract - .ibc_store() - .expected_time_per_block() - .save(deps.as_mut().storage, &(env.block.time.seconds())) - .unwrap(); - - let client_type = ClientType::new("iconclient".to_string()); - let light_client = Addr::unchecked("lightclient"); - - contract - .register_client(deps.as_mut(), client_type, light_client) - .unwrap(); - - let client_state = ClientState { - trusting_period: 2000000000, - ..get_dummy_client_state() - }; - - let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], + if let Some(client_state) = &mut ctx.client_state { + client_state.trusting_period = 2000000000; } - .try_into() - .unwrap(); - let client_id = ClientId::from_str("iconclient-0").unwrap(); - let mut query_map = HashMap::::new(); - query_map = mock_consensus_state_query( - query_map, - &client_id, - &consenus_state, - client_state.latest_height().revision_height(), - ); - query_map = mock_client_state_query(query_map, &client_id, &client_state); - mock_lightclient_query(query_map, &mut deps); + let client_state = ctx.client_state.clone().unwrap(); + let consensus_state: ConsensusState = ctx.consensus_state.clone().unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); + + mock_lightclient_query(ctx.mock_queries, &mut deps); let msg = RawMsgCreateClient { client_state: Some(client_state.to_any()), - consensus_state: Some(consenus_state.to_any()), + consensus_state: Some(consensus_state.to_any()), signer: "signer".to_string(), }; contract .create_client(deps.as_mut(), info.clone(), mock_env(), msg) .unwrap(); - let upgrade_client_state = ClientState { - trusting_period: 2000000000, - ..get_dummy_client_state() - } - .to_any(); - - let upgrade_consenus_state: Any = common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root_new".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], - } - .to_any(); - let signer = Signer::from_str("new_signer").unwrap(); - let upgrdade_client_message = RawMsgUpgradeClient { - client_id: client_id.to_string(), - client_state: upgrade_client_state.clone().into(), - consensus_state: upgrade_consenus_state.clone().into(), + client_id: ctx.client_id.to_string(), + client_state: Some(client_state.clone().to_any()), + consensus_state: Some(consensus_state.clone().to_any()), proof_upgrade_client: get_dummy_merkle_proof().encode_to_vec(), proof_upgrade_consensus_state: get_dummy_merkle_proof().encode_to_vec(), - signer: signer.to_string(), + signer: "new_signer".to_string(), }; contract - .upgrade_client(deps.as_mut(), info, env, upgrdade_client_message) + .upgrade_client(deps.as_mut(), info, ctx.env, upgrdade_client_message) .unwrap(); let upgrade_client_response = UpgradeClientResponse::new( - keccak256(&upgrade_client_state.value).to_vec(), - upgrade_client_state.encode_to_vec(), - keccak256(&upgrade_consenus_state.value).to_vec(), - upgrade_consenus_state.encode_to_vec(), - client_id.to_string(), + keccak256(&client_state.encode_to_vec()).to_vec(), + client_state.encode_to_vec(), + keccak256(&consensus_state.encode_to_vec()).to_vec(), + consensus_state.encode_to_vec(), + ctx.client_id.to_string(), "0-100".to_string(), ); - let mock_data_binary = to_binary(&upgrade_client_response).unwrap(); - let event = Event::new("empty"); - + let mock_data_binary = to_binary(&upgrade_client_response).unwrap(); let reply_message = Reply { id: EXECUTE_UPGRADE_CLIENT, result: cosmwasm_std::SubMsgResult::Ok(SubMsgResponse { @@ -1007,7 +690,6 @@ fn check_for_execute_upgrade_client() { .unwrap(); assert_eq!("iconclient-0", result.attributes[1].value); - assert_eq!("upgrade_client", result.events[0].ty) } @@ -1016,48 +698,27 @@ fn check_for_execute_upgrade_client() { expected = "IbcValidationError { error: InvalidLength { id: \"hello\", length: 5, min: 9, max: 64 } }" )] fn fails_on_invalid_client_identifier_on_execute_upgrade_client() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); - - let env = get_mock_env(); - let contract = CwIbcCoreContext::default(); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); - - contract - .ibc_store() - .expected_time_per_block() - .save(deps.as_mut().storage, &(env.block.time.seconds())) - .unwrap(); - - let upgrade_client_state: ClientState = ClientState { - trusting_period: 2000000000, - ..get_dummy_client_state() - }; - - let upgrade_consenus_state: ConsensusState = - common::icon::icon::lightclient::v1::ConsensusState { - message_root: "message_root_new".as_bytes().to_vec(), - next_proof_context_hash: vec![1, 2, 3, 4], - } - .try_into() - .unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); let upgrade_client_response = UpgradeClientResponse::new( - upgrade_client_state.get_keccak_hash().to_vec(), - upgrade_client_state.encode_to_vec(), - upgrade_consenus_state.get_keccak_hash().to_vec(), - upgrade_consenus_state.encode_to_vec(), + ctx.client_state.clone().unwrap().get_keccak_hash().to_vec(), + ctx.client_state.unwrap().encode_to_vec(), + ctx.consensus_state + .clone() + .unwrap() + .get_keccak_hash() + .to_vec(), + ctx.consensus_state.unwrap().encode_to_vec(), "hello".to_string(), "0-100".to_string(), ); - let mock_data_binary = to_binary(&upgrade_client_response).unwrap(); - let event = Event::new("empty"); - + let mock_data_binary = to_binary(&upgrade_client_response).unwrap(); let reply_message = Reply { id: EXECUTE_UPGRADE_CLIENT, result: cosmwasm_std::SubMsgResult::Ok(SubMsgResponse { @@ -1074,29 +735,18 @@ fn fails_on_invalid_client_identifier_on_execute_upgrade_client() { #[test] #[should_panic(expected = "IbcClientError { error: Other { description: \"UnknownResponse\" } }")] fn fails_on_unknown_response_on_execute_upgrade_client() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); - - let env = get_mock_env(); - let contract = CwIbcCoreContext::default(); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); - - contract - .ibc_store() - .expected_time_per_block() - .save(deps.as_mut().storage, &(env.block.time.seconds())) - .unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); let reply_message = Reply { id: EXECUTE_UPGRADE_CLIENT, result: cosmwasm_std::SubMsgResult::Err("UnknownResponse".to_string()), }; - contract - .execute_upgrade_client_reply(deps.as_mut(), get_mock_env(), reply_message) + .execute_upgrade_client_reply(deps.as_mut(), ctx.env, reply_message) .unwrap(); } @@ -1105,24 +755,11 @@ fn fails_on_unknown_response_on_execute_upgrade_client() { expected = "IbcClientError { error: Other { description: \"Invalid Response Data\" } }" )] fn fails_on_null_response_data_on_execute_upgrade_client() { + let ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); - - let env = get_mock_env(); - let contract = CwIbcCoreContext::default(); - contract - .init_client_counter(deps.as_mut().storage, 0) - .unwrap(); - - contract - .ibc_store() - .expected_time_per_block() - .save(deps.as_mut().storage, &(env.block.time.seconds())) - .unwrap(); - let event = Event::new("empty"); - let reply_message = Reply { id: EXECUTE_UPGRADE_CLIENT, result: cosmwasm_std::SubMsgResult::Ok(SubMsgResponse { @@ -1132,7 +769,7 @@ fn fails_on_null_response_data_on_execute_upgrade_client() { }; contract - .execute_upgrade_client_reply(deps.as_mut(), get_mock_env(), reply_message) + .execute_upgrade_client_reply(deps.as_mut(), ctx.env, reply_message) .unwrap(); } @@ -1141,55 +778,36 @@ fn fails_on_null_response_data_on_execute_upgrade_client() { expected = "IbcClientError { error: Other { description: \"Client Implementation Already Exist\" } }" )] fn fails_on_storing_already_registered_client_into_registry() { - let mut mock_deps = deps(); + let mut ctx = TestContext::for_client_state(get_mock_env()); + let mut deps = deps(); let contract = CwIbcCoreContext::default(); - let client_type = ClientType::new("new_client_type".to_string()); - let light_client_address = "light-client".to_string(); - contract - .store_client_into_registry( - mock_deps.as_mut().storage, - client_type.clone(), - light_client_address.clone(), - ) - .unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); + + let lightclient = ctx.lightclient.unwrap().get_address(); let result = contract - .get_client_from_registry(mock_deps.as_ref().storage, client_type.clone()) + .get_client_from_registry(deps.as_ref().storage, ctx.client_type.clone()) .unwrap(); - - assert_eq!(light_client_address, result); + assert_eq!(lightclient, result); contract - .register_client( - mock_deps.as_mut(), - client_type, - Addr::unchecked(light_client_address), - ) + .register_client(deps.as_mut(), ctx.client_type, Addr::unchecked(lightclient)) .unwrap(); } #[test] fn success_on_getting_client() { - let mut mock_deps = deps(); + let mut ctx = TestContext::for_client_state(get_mock_env()); + let mut deps = deps(); let contract = CwIbcCoreContext::default(); - let client_type = ClientType::new("new_client_type".to_string()); - let client_id = ClientId::new(client_type, 0).unwrap(); - - let client_address = LightClient::new("newclientaddress".to_string()); - contract - .store_client_implementations( - mock_deps.as_mut().storage, - &client_id, - client_address.clone(), - ) - .unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); let result = contract - .get_light_client(mock_deps.as_ref().storage, &client_id) + .get_light_client(deps.as_ref().storage, &ctx.client_id) .unwrap(); - assert_eq!(result, client_address) + assert_eq!(result, ctx.lightclient.unwrap()) } #[test] @@ -1208,71 +826,106 @@ fn fails_on_getting_client_empty_client() { } #[test] -fn success_on_getting_client_state() { - let mut deps = deps(); - let contract = CwIbcCoreContext::default(); - let info = create_mock_info("alice", "umlg", 2000); +fn test_get_commitment() { + let ctx = TestContext::default(mock_env()); + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); - contract - .init_client_counter(deps.as_mut().storage, 0) + let client_state_hash = to_vec(&ctx.client_state.clone().unwrap()).unwrap(); + let client_key = commitment::client_state_commitment_key(&ctx.client_id); + + ctx.save_client_commitment(deps.as_mut().storage, &contract, &client_state_hash); + + let res = contract + .get_commitment(deps.as_ref().storage, client_key) .unwrap(); + assert_eq!(res, client_state_hash); +} - let client_state: ClientState = get_dummy_client_state(); +#[test] +#[should_panic(expected = "InvalidCommitmentKey")] +fn fail_test_get_commitment() { + let ctx = TestContext::default(mock_env()); + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); + let client_state_hash = to_vec(&get_dummy_client_state()).unwrap(); - let consenus_state: ConsensusState = get_dummy_consensus_state(); + ctx.save_client_commitment(deps.as_mut().storage, &contract, &client_state_hash); - let client_type = ClientType::new("iconclient".to_string()); - let light_client = Addr::unchecked("lightclient"); - contract - .register_client(deps.as_mut(), client_type.clone(), light_client) + let rand_client = to_ibc_client_id("randclient").unwrap(); + let client_key = commitment::client_state_commitment_key(&rand_client); + + let res = contract + .get_commitment(deps.as_ref().storage, client_key) .unwrap(); + assert_eq!(res, client_state_hash); +} - let signer = Signer::from_str("new_signer").unwrap(); +#[test] +fn test_get_connection() { + let ctx = TestContext::default(mock_env()); + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); - let create_client_message = RawMsgCreateClient { - client_state: Some(client_state.to_any()), - consensus_state: Some(consenus_state.to_any()), - signer: signer.to_string(), - }; + ctx.save_connection(deps.as_mut().storage, &contract); + + let res = contract.get_connection(deps.as_ref().storage, &ctx.connection_id); + assert!(res.is_ok()); +} + +#[test] +#[should_panic(expected = "InvalidConnectiontId { connection_id: \"ibcconnection\" }")] +fn fail_test_get_connection() { + let ctx = TestContext::default(mock_env()); + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); + + ctx.save_connection(deps.as_mut().storage, &contract); + + let connection_id = to_ibc_connection_id("ibcconnection").unwrap(); contract - .create_client(deps.as_mut(), info, mock_env(), create_client_message) + .get_connection(deps.as_ref().storage, &connection_id) .unwrap(); +} - let mock_reponse_data = CreateClientResponse::new( - client_type.as_str().to_string(), - "10-15".to_string(), - keccak256(&client_state.encode_to_vec()).to_vec(), - keccak256(&consenus_state.encode_to_vec()).to_vec(), - client_state.to_any().encode_to_vec(), - consenus_state.to_any().encode_to_vec(), - ); +#[test] +fn test_client_state_any() { + let mut ctx = TestContext::for_client_state(mock_env()); + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); - let mock_data_binary = to_binary(&mock_reponse_data).unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); - let event = Event::new("empty"); + let res = contract + .client_state_any(deps.as_ref(), &ctx.client_id) + .unwrap(); + assert_eq!(res, ctx.client_state.unwrap().to_any()); +} - let _reply_message = Reply { - id: EXECUTE_CREATE_CLIENT, - result: cosmwasm_std::SubMsgResult::Ok(SubMsgResponse { - events: vec![event], - data: Some(mock_data_binary), - }), - }; +#[test] +fn success_on_getting_client_state() { + let mut ctx = TestContext::for_client_state(mock_env()); + let mut deps = deps(); + let contract = CwIbcCoreContext::default(); + let info = create_mock_info("alice", "umlg", 2000); - let client_id = ClientId::from_str("iconclient-0").unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); - let mut query_map = HashMap::::new(); - query_map = mock_consensus_state_query( - query_map, - &client_id, - &consenus_state, - client_state.latest_height().revision_height(), - ); - query_map = mock_client_state_query(query_map, &client_id, &client_state); - mock_lightclient_query(query_map, &mut deps); + let create_client_message = RawMsgCreateClient { + client_state: Some(ctx.client_state.unwrap().to_any()), + consensus_state: Some(ctx.consensus_state.unwrap().to_any()), + signer: "new_signer".to_string(), + }; + contract + .create_client(deps.as_mut(), info, mock_env(), create_client_message) + .unwrap(); - let state = contract.client_state(deps.as_ref(), &client_id).unwrap(); + mock_lightclient_query(ctx.mock_queries, &mut deps); + let state = contract + .client_state(deps.as_ref(), &ctx.client_id) + .unwrap(); assert_eq!(None, state.frozen_height()) } @@ -1291,112 +944,68 @@ fn fails_on_getting_client_state() { #[test] fn success_on_misbehaviour_validate() { + let mut ctx = TestContext::for_client_state(get_mock_env()); let mut deps = deps(); let contract = CwIbcCoreContext::default(); let info = create_mock_info("alice", "umlg", 2000); - contract - .init_client_counter(deps.as_mut().storage, 10) - .unwrap(); - let client_state: ClientState = get_dummy_client_state(); + ctx.init_client_state(deps.as_mut(), &contract); - let client_id = ClientId::from_str("iconlightclient-10").unwrap(); - - contract - .store_client_implementations( - deps.as_mut().storage, - &client_id, - LightClient::new("clientaddress".to_string()), - ) - .unwrap(); - - contract - .store_client_commitment( - deps.as_mut().storage, - &get_mock_env(), - &client_id, - client_state.get_keccak_hash().to_vec(), - ) - .unwrap(); let height = mock_height(10, 15).unwrap(); let mock_header = MockHeader::new(height); let misbehaviour = common::ibc::mock::misbehaviour::Misbehaviour { - client_id: to_mock_client_id(&client_id), + client_id: to_mock_client_id(&ctx.client_id), header1: mock_header, header2: mock_header, }; let misbehaviour: Any = misbehaviour.into(); let misbehaviour_message = RawMsgSubmitMisbehaviour { - client_id: client_id.to_string(), + client_id: ctx.client_id.to_string(), misbehaviour: Some(misbehaviour), signer: get_dummy_account_id().to_string(), }; - let mut query_map = HashMap::::new(); - query_map = mock_client_state_query(query_map, &client_id, &client_state); - mock_lightclient_query(query_map, &mut deps); + mock_lightclient_query(ctx.mock_queries, &mut deps); let result = contract.misbehaviour(deps.as_mut(), info, misbehaviour_message); - assert!(result.is_ok()) } #[test] #[should_panic( - expected = "IbcClientError { error: ClientFrozen { client_id: ClientId(\"iconlightclient-10\") } }" + expected = "IbcClientError { error: ClientFrozen { client_id: ClientId(\"default-0\") } }" )] fn fails_on_frozen_client_on_misbehaviour_validate() { + let mut ctx = TestContext::default(get_mock_env()); let mut deps = deps(); let contract = CwIbcCoreContext::default(); let info = create_mock_info("alice", "umlg", 2000); - contract - .init_client_counter(deps.as_mut().storage, 10) - .unwrap(); - let client_state = ClientState { - frozen_height: 10, - ..get_dummy_client_state() - }; + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 10; + } - let client_id = ClientId::from_str("iconlightclient-10").unwrap(); + ctx.init_client_state(deps.as_mut(), &contract); - contract - .store_client_implementations( - deps.as_mut().storage, - &client_id, - LightClient::new("clientaddress".to_string()), - ) - .unwrap(); - - contract - .store_client_commitment( - deps.as_mut().storage, - &get_mock_env(), - &client_id, - client_state.get_keccak_hash().to_vec(), - ) - .unwrap(); let height = mock_height(10, 15).unwrap(); let mock_header = MockHeader::new(height); let misbehaviour: Any = common::ibc::mock::misbehaviour::Misbehaviour { - client_id: to_mock_client_id(&client_id), + client_id: to_mock_client_id(&ctx.client_id), header1: mock_header, header2: mock_header, } .into(); let misbehaviour_message = RawMsgSubmitMisbehaviour { - client_id: client_id.to_string(), + client_id: ctx.client_id.to_string(), misbehaviour: misbehaviour.into(), signer: get_dummy_account_id().to_string(), }; - let mut query_map = HashMap::::new(); - query_map = mock_client_state_query(query_map, &client_id, &client_state); - mock_lightclient_query(query_map, &mut deps); + mock_lightclient_query(ctx.mock_queries, &mut deps); contract .misbehaviour(deps.as_mut(), info, misbehaviour_message) From 670e92e790cff40728878ef48d4d1894081dc9b0 Mon Sep 17 00:00:00 2001 From: undefined <107839945+bishalbikram@users.noreply.github.com> Date: Fri, 15 Mar 2024 19:10:06 +0545 Subject: [PATCH 55/64] chore: update test coverage for ics03-connection (#848) * chore: update test coverage for ibc client * chore: improve test coverage for ibc connection --- .../cw-ibc-core/tests/test_connection.rs | 394 ++++++++++++------ .../cw-ibc-core/tests/test_port.rs | 14 + 2 files changed, 271 insertions(+), 137 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs index 0ce552cca..89c80cce9 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs @@ -1,5 +1,4 @@ -use std::collections::HashMap; - +use cosmwasm_std::Timestamp; use std::time::Duration; pub mod setup; @@ -11,15 +10,11 @@ use common::icon::icon::lightclient::v1::ClientState; use common::traits::AnyTypes; use cosmwasm_std::testing::mock_dependencies; use cosmwasm_std::testing::mock_env; -use cosmwasm_std::to_binary; -use cosmwasm_std::Binary; use cosmwasm_std::Addr; use cw_common::get_address_storage_prefix; -use cw_common::raw_types::connection::RawMsgConnectionOpenInit; - use cw_ibc_core::context::CwIbcCoreContext; use cw_ibc_core::conversions::to_ibc_client_id; @@ -29,8 +24,6 @@ use cw_ibc_core::ics03_connection::event::CONN_ID_ATTRIBUTE_KEY; use cw_ibc_core::ics03_connection::event::COUNTERPARTY_CLIENT_ID_ATTRIBUTE_KEY; use cw_ibc_core::ics03_connection::event::COUNTERPARTY_CONN_ID_ATTRIBUTE_KEY; -//use cw_ibc_core::ics03_connection::event::create_open_init_event; - use common::ibc::core::ics03_connection::connection::Counterparty; use common::ibc::core::ics03_connection::connection::State; use common::ibc::core::ics03_connection::version::get_compatible_versions; @@ -39,7 +32,6 @@ use common::ibc::core::ics23_commitment::commitment::CommitmentPrefix; use common::ibc::core::ics24_host::identifier::ConnectionId; use common::ibc::events::IbcEventType; use cw_common::ibc_types::IbcClientId; -use cw_ibc_core::light_client::light_client::LightClient; use cw_ibc_core::ConnectionEnd; use prost::Message; use setup::*; @@ -184,39 +176,136 @@ fn test_commitment_prefix() { #[test] fn connection_open_init() { let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + + let msg = get_dummy_raw_msg_conn_open_init(); + let mut ctx = TestContext::for_connection_open_init(get_mock_env(), &msg); + ctx.init_connection_open_init(deps.as_mut().storage, &contract); + + mock_lightclient_query(ctx.mock_queries, &mut deps); + + let res = contract.connection_open_init(deps.as_mut(), msg); + assert!(res.is_ok()); +} + +#[test] +#[should_panic(expected = "ClientFrozen")] +fn fail_connection_open_init_for_frozen_client() { + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + + let msg = get_dummy_raw_msg_conn_open_init(); + let mut ctx = TestContext::for_connection_open_init(get_mock_env(), &msg); + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 1; + } + + ctx.init_connection_open_init(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); - let res_msg = RawMsgConnectionOpenInit { - client_id: "iconclient-0".to_string(), - counterparty: Some(get_dummy_raw_counterparty(None)), - version: None, - delay_period: 0, - signer: get_dummy_bech32_account(), - }; - let client_id = to_ibc_client_id(&res_msg.client_id).unwrap(); + contract.connection_open_init(deps.as_mut(), msg).unwrap(); +} +#[test] +#[should_panic(expected = "IbcConnectionError { error: EmptyVersions }")] +fn fail_connection_open_init_for_incompatible_version() { + let mut deps = deps(); let contract = CwIbcCoreContext::new(); - let client_state: ClientState = get_dummy_client_state(); + + let mut msg = get_dummy_raw_msg_conn_open_init(); + if let Some(version) = &mut msg.version { + version.identifier = "2".to_string() + } + + let mut ctx = TestContext::for_connection_open_init(get_mock_env(), &msg); + ctx.init_connection_open_init(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract.connection_open_init(deps.as_mut(), msg).unwrap(); +} + +#[test] +#[should_panic(expected = "ClientFrozen")] +fn fail_connection_open_ack_for_frozen_client() { + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("alice", "umlg", 2000); + + let msg = get_dummy_raw_msg_conn_open_ack(10, 10); + let mut ctx = TestContext::for_connection_open_ack(get_mock_env(), &msg); + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 10; + } + + ctx.init_connection_open_ack(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + contract - .store_client_implementations( - deps.as_mut().storage, - &client_id, - LightClient::new("lightclient".to_string()), - ) + .connection_open_ack(deps.as_mut(), info, ctx.env, msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "ConnectionMismatch")] +fn fail_connection_open_ack_for_mismatch_connection_version() { + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("alice", "umlg", 2000); + + let mut msg = get_dummy_raw_msg_conn_open_ack(10, 10); + if let Some(version) = &mut msg.version { + version.identifier = "2".to_string(); + } + + let mut ctx = TestContext::for_connection_open_ack(get_mock_env(), &msg); + ctx.init_connection_open_ack(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .connection_open_ack(deps.as_mut(), info, ctx.env, msg) .unwrap(); +} + +#[test] +#[should_panic(expected = "ClientFrozen")] +fn fail_connection_open_try_for_frozen_client() { + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("alice", "umlg", 2000); - let cl = client_state.to_any().encode_to_vec(); - let mut query_map = HashMap::::new(); - let client_state_query = LightClient::build_client_state_query(&client_id).unwrap(); - query_map.insert(client_state_query, to_binary(&cl).unwrap()); + let msg = get_dummy_raw_msg_conn_open_try(10, 10); + let mut ctx = TestContext::for_connection_open_try(get_mock_env(), &msg); + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 10; + } + + ctx.init_connection_open_init(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); - mock_lightclient_query(query_map, &mut deps); contract - .connection_next_sequence_init(&mut deps.storage, u64::default()) + .connection_open_try(deps.as_mut(), info, ctx.env, msg.clone()) .unwrap(); +} - let res = contract.connection_open_init(deps.as_mut(), res_msg); - println!("{:?}", res); - assert!(res.is_ok()); +#[test] +#[should_panic(expected = "ClientFrozen")] +fn fail_connection_open_confirm_for_frozen_client() { + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("alice", "umlg", 2000); + + let msg = get_dummy_raw_msg_conn_open_confirm(); + let mut ctx = TestContext::for_connection_open_confirm(get_mock_env(), &msg); + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 1; + } + + ctx.init_connection_open_confirm(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .connection_open_confirm(deps.as_mut(), ctx.env, info, msg) + .unwrap(); } #[test] @@ -224,13 +313,7 @@ fn connection_open_init() { fn test_validate_open_init_connection_fail() { let mut deps = deps(); let contract = CwIbcCoreContext::default(); - let message = RawMsgConnectionOpenInit { - client_id: "client_id_on_a".to_string(), - counterparty: Some(get_dummy_raw_counterparty(None)), - version: None, - delay_period: 0, - signer: get_dummy_bech32_account(), - }; + let message = get_dummy_raw_msg_conn_open_init(); contract .connection_open_init(deps.as_mut(), message) @@ -239,57 +322,53 @@ fn test_validate_open_init_connection_fail() { #[test] fn create_connection_open_init_event() { - let connection_id = ConnectionId::new(10); - let client_id = ClientId::default(); - let counterparty_client_id = ClientId::default(); + let ctx_a = TestContext::default(get_mock_env()); + let ctx_b = TestContext::default(get_mock_env()); + let event = create_connection_event( IbcEventType::OpenInitConnection, - &connection_id, - &client_id, - &counterparty_client_id, + &ctx_a.connection_id, + &ctx_b.client_id, + &ctx_b.client_id, None, ) .unwrap(); assert_eq!(IbcEventType::OpenInitConnection.as_str(), event.ty); - assert_eq!("connection-10", event.attributes[0].value); + assert_eq!("connection-0", event.attributes[0].value); assert_eq!("default-0", event.attributes[1].value); assert_eq!("default-0", event.attributes[2].value); } #[test] fn create_connection_open_ack_event() { - let connection_id = ConnectionId::new(10); - let client_id = ClientId::default(); - let counterparty_client_id = ClientId::default(); - let counterparty_connection_id = ConnectionId::new(20); + let ctx_a = TestContext::default(get_mock_env()); + let ctx_b = TestContext::default(get_mock_env()); let event = create_connection_event( IbcEventType::OpenAckConnection, - &connection_id, - &client_id, - &counterparty_client_id, - Some(counterparty_connection_id), + &ctx_a.connection_id, + &ctx_a.client_id, + &ctx_b.client_id, + Some(ctx_b.connection_id), ) .unwrap(); assert_eq!(IbcEventType::OpenAckConnection.as_str(), event.ty); - assert_eq!("connection-10", event.attributes[0].value); + assert_eq!("connection-0", event.attributes[0].value); assert_eq!("default-0", event.attributes[1].value); - assert_eq!("connection-20", event.attributes[3].value); + assert_eq!("connection-0", event.attributes[3].value); } #[test] fn create_connection_open_try_event() { - let connection_id = ConnectionId::new(10); - let client_id = ClientId::default(); - let counterparty_client_id = ClientId::default(); - let counterparty_connection_id = ConnectionId::new(20); + let ctx_a = TestContext::default(get_mock_env()); + let ctx_b = TestContext::default(get_mock_env()); let event = create_connection_event( IbcEventType::OpenTryConnection, - &connection_id, - &client_id, - &counterparty_client_id, - Some(counterparty_connection_id), + &ctx_a.connection_id, + &ctx_b.client_id, + &ctx_b.client_id, + Some(ctx_b.connection_id), ) .unwrap(); assert_eq!(IbcEventType::OpenTryConnection.as_str(), event.ty); @@ -297,21 +376,36 @@ fn create_connection_open_try_event() { #[test] fn create_conection_open_confirm_event() { - let connection_id_on_b = ConnectionId::new(10); - let client_id_on_b = ClientId::default(); - let counterparty_connection_id_on_a = ConnectionId::new(2); - let counterparty_client_id_on_a = ClientId::default(); + let ctx_a = TestContext::default(get_mock_env()); + let ctx_b = TestContext::default(get_mock_env()); + let event = create_connection_event( IbcEventType::OpenConfirmConnection, - &connection_id_on_b, - &client_id_on_b, - &counterparty_client_id_on_a, - Some(counterparty_connection_id_on_a), + &ctx_a.connection_id, + &ctx_a.client_id, + &ctx_b.client_id, + Some(ctx_b.connection_id), ) .unwrap(); assert_eq!(IbcEventType::OpenConfirmConnection.as_str(), event.ty); - assert_eq!("connection-10", event.attributes[0].value); + assert_eq!("connection-0", event.attributes[0].value); +} + +#[test] +#[should_panic(expected = "InvalidEventType")] +fn fail_create_connection_event() { + let ctx_a = TestContext::default(get_mock_env()); + let ctx_b = TestContext::default(get_mock_env()); + + create_connection_event( + IbcEventType::Timeout, + &ctx_a.connection_id, + &ctx_a.client_id, + &ctx_b.client_id, + None, + ) + .unwrap(); } #[test] @@ -465,12 +559,6 @@ fn connection_validate_delay() { .store_last_processed_on(deps.as_mut().storage, &env, conn_end.client_id()) .unwrap(); - contract - .ibc_store() - .expected_time_per_block() - .save(deps.as_mut().storage, &(env.block.time.seconds())) - .unwrap(); - let result = contract.verify_connection_delay_passed(&deps.storage, env, packet_proof_height, conn_end); assert!(result.is_ok()) @@ -491,16 +579,79 @@ fn connection_validate_delay_fails() { } #[test] -fn test_block_delay() { - let mut deps = deps(); - let env = get_mock_env(); - let delay_time = Duration::new(1, 1); +#[should_panic(expected = "overflow")] +fn fail_verify_connection_delay_passed_on_timestamp_overflow() { + let mut ctx = TestContext::default(get_mock_env()); + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); + + ctx.env.block.time = Timestamp::from_seconds(u64::MAX); + + contract + .store_last_processed_on(deps.as_mut().storage, &ctx.env, &ctx.client_id) + .unwrap(); + + contract + .verify_connection_delay_passed( + deps.as_ref().storage, + ctx.env, + mock_height(1, 1).unwrap(), + ctx.connection_end.unwrap(), + ) + .unwrap(); +} + +#[test] +#[should_panic(expected = "NotEnoughTimeElapsed")] +fn fail_verify_connection_delay_passed_on_not_enough_time_elapsed() { + let mut ctx = TestContext::default(get_mock_env()); + let mut deps = mock_dependencies(); let contract = CwIbcCoreContext::new(); + contract - .ibc_store() - .expected_time_per_block() - .save(deps.as_mut().storage, &(env.block.time.seconds())) + .store_last_processed_on(deps.as_mut().storage, &ctx.env, &ctx.client_id) .unwrap(); + + ctx.env.block.time = Timestamp::from_nanos(10); + + contract + .verify_connection_delay_passed( + deps.as_ref().storage, + ctx.env, + mock_height(1, 1).unwrap(), + ctx.connection_end.unwrap(), + ) + .unwrap(); +} + +#[test] +#[should_panic(expected = "NotEnoughBlocksElapsed")] +fn fail_verify_connection_delay_passed_on_not_enough_block_elapsed() { + let mut ctx = TestContext::default(get_mock_env()); + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); + + contract + .store_last_processed_on(deps.as_mut().storage, &ctx.env, &ctx.client_id) + .unwrap(); + + ctx.env.block.height = 12344; + + contract + .verify_connection_delay_passed( + deps.as_ref().storage, + ctx.env, + mock_height(1, 1).unwrap(), + ctx.connection_end.unwrap(), + ) + .unwrap(); +} + +#[test] +fn test_block_delay() { + let delay_time = Duration::new(1, 1); + let contract = CwIbcCoreContext::new(); + let result = contract.calc_block_delay(&delay_time); assert_eq!(1, result) } @@ -589,13 +740,7 @@ fn connection_open_confirm_validate_fails_of_connection_state_mismatch() { fn connection_check_open_init_validate_fails() { let mut deps = deps(); - let mut message = RawMsgConnectionOpenInit { - client_id: "client_id_on_a".to_string(), - counterparty: Some(get_dummy_raw_counterparty(None)), - version: None, - delay_period: 0, - signer: get_dummy_bech32_account(), - }; + let mut message = get_dummy_raw_msg_conn_open_init(); let contract = CwIbcCoreContext::new(); let mut test_context = TestContext::for_connection_open_init(mock_env(), &message); @@ -614,13 +759,7 @@ fn connection_check_open_init_validate_fails() { fn connection_open_init_fails_of_clientstate() { let mut deps = deps(); - let message = RawMsgConnectionOpenInit { - client_id: "client_id_on_a".to_string(), - counterparty: Some(get_dummy_raw_counterparty(None)), - version: None, - delay_period: 0, - signer: get_dummy_bech32_account(), - }; + let message = get_dummy_raw_msg_conn_open_init(); let client_id = ClientId::default(); let contract = CwIbcCoreContext::new(); @@ -651,13 +790,7 @@ fn connection_open_init_fails_of_clientstate() { fn connection_open_init_validate_invalid_client_id() { let mut deps = deps(); let contract = CwIbcCoreContext::new(); - let mut message = RawMsgConnectionOpenInit { - client_id: "client_id_on_a".to_string(), - counterparty: Some(get_dummy_raw_counterparty(None)), - version: None, - delay_period: 0, - signer: get_dummy_bech32_account(), - }; + let mut message = get_dummy_raw_msg_conn_open_init(); let mut test_context = TestContext::for_connection_open_init(mock_env(), &message); test_context.init_context(deps.as_mut().storage, &contract); mock_lightclient_query(test_context.mock_queries, &mut deps); @@ -695,30 +828,26 @@ fn test_update_connection_commitment() { #[test] fn test_check_connection() { + let ctx = TestContext::default(get_mock_env()); let mut deps = deps(); - let commitment_prefix = - common::ibc::core::ics23_commitment::commitment::CommitmentPrefix::try_from( - "hello".to_string().as_bytes().to_vec(), - ); - let counter_party = Counterparty::new(IbcClientId::default(), None, commitment_prefix.unwrap()); - let conn_end = ConnectionEnd::new( - State::Open, - IbcClientId::default(), - counter_party, - vec![Version::default()], - Duration::default(), - ); - let client_id = ClientId::default(); - let conn_id = ConnectionId::new(5); let contract = CwIbcCoreContext::new(); + + let res = contract.check_for_connection(&mut deps.storage, &ctx.client_id); + assert!(res.is_ok()); +} + +#[test] +#[should_panic(expected = "IbcConnectionError { error: ConnectionExists(\"connection-0\") }")] +fn fail_check_for_connection_on_connection_exist() { + let ctx = TestContext::default(get_mock_env()); + let mut deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); + + ctx.save_connection_to_client(deps.as_mut().storage, &contract); + contract - .store_connection(deps.as_mut().storage, &conn_id, &conn_end) - .unwrap(); - contract - .connection_end(deps.as_ref().storage, &conn_id) + .check_for_connection(deps.as_ref().storage, &ctx.client_id) .unwrap(); - let res = contract.check_for_connection(&mut deps.storage, &client_id); - assert!(res.is_ok()); } #[test] @@ -737,13 +866,7 @@ fn test_connection_seq_on_a_fails_without_initialising() { fn connection_open_init_fails() { let mut deps = deps(); - let message = RawMsgConnectionOpenInit { - client_id: "client_id_on_a".to_string(), - counterparty: Some(get_dummy_raw_counterparty(None)), - version: None, - delay_period: 0, - signer: get_dummy_bech32_account(), - }; + let message = get_dummy_raw_msg_conn_open_init(); let contract = CwIbcCoreContext::new(); let client_state: ClientState = get_dummy_client_state(); @@ -769,9 +892,6 @@ fn connection_open_ack_validate_fails_of_connection_mismatch() { let info = create_mock_info("alice", "umlg", 2000); let env = get_mock_env(); let contract = CwIbcCoreContext::default(); - contract - .connection_next_sequence_init(&mut deps.storage, u128::default().try_into().unwrap()) - .unwrap(); let message = get_dummy_raw_msg_conn_open_ack(10, 10); let mut test_context = TestContext::for_connection_open_ack(env.clone(), &message); diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_port.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_port.rs index 87ce22efd..660cb4fdd 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_port.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_port.rs @@ -94,3 +94,17 @@ fn channel_capability_path() { assert!(result.is_ok()); assert_eq!("ports/defaultPort/channels/channel-0", result.unwrap()) } + +#[test] +fn test_get_all_ports() { + let mut deps = deps(); + let ctx = CwIbcCoreContext::default(); + let address = "contractaddress".to_string(); + let port_id = PortId::default(); + + ctx.bind_port(&mut deps.storage, &port_id.clone(), address.clone()) + .unwrap(); + + let res: Result, cosmwasm_std::StdError> = ctx.get_all_ports(&deps.storage); + assert_eq!(res.unwrap(), vec![port_id.as_str().to_string()]); +} From 8a30139afe4dc740f2d2c17d64b7ceeb8c561016 Mon Sep 17 00:00:00 2001 From: undefined <107839945+bishalbikram@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:43:57 +0545 Subject: [PATCH 56/64] chore: add test coverage for cosmwasm ibc core (#850) --- .../tests/channel/test_acknowledgement.rs | 159 ++++++++- .../tests/channel/test_channel_closeinit.rs | 21 ++ .../tests/channel/test_close_confirm.rs | 21 ++ .../cw-ibc-core/tests/channel/test_handler.rs | 114 +++++++ .../tests/channel/test_open_ack.rs | 86 +++++ .../tests/channel/test_open_confirm.rs | 63 ++++ .../cw-ibc-core/tests/channel/test_packet.rs | 17 + .../tests/channel/test_receive_packet.rs | 151 ++++++++- .../cw-ibc-core/tests/channel/test_timeout.rs | 316 +++++------------- .../tests/channel/test_timeout_on_close.rs | 135 +++++++- .../cw-ibc-core/tests/test_channel.rs | 57 +++- .../cw-ibc-core/tests/test_connection.rs | 12 + .../cw-ibc-core/tests/test_host.rs | 10 + 13 files changed, 913 insertions(+), 249 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_acknowledgement.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_acknowledgement.rs index 68562708c..ddfced715 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_acknowledgement.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_acknowledgement.rs @@ -1,6 +1,9 @@ +use super::*; + +use cosmwasm_std::to_vec; use cw_ibc_core::conversions::to_ibc_channel_id; -use super::*; +use common::ibc::core::ics04_channel::commitment::AcknowledgementCommitment; #[test] fn test_acknowledgement_packet_validate_ordered() { @@ -89,3 +92,157 @@ fn test_acknowledgement_packet_validate_fail_missing_channel() { .acknowledgement_packet_validate(deps.as_mut(), info, env, &msg) .unwrap(); } + +#[test] +#[should_panic(expected = "ChannelClosed")] +fn acknowledgement_packet_validate_fail_on_channel_close() { + let msg = get_dummy_raw_msg_acknowledgement(10); + let mut ctx = TestContext::for_acknowledge_packet(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + if let Some(chann_end) = &mut ctx.channel_end { + chann_end.state = State::Closed + } + + ctx.init_acknowledge_packet(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .acknowledgement_packet_validate(deps.as_mut(), info, ctx.env, &msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "InvalidPacketCounterparty")] +fn acknowledgement_packet_validate_fail_on_invalid_packet_counterparty() { + let mut msg = get_dummy_raw_msg_acknowledgement(10); + let mut ctx = TestContext::for_acknowledge_packet(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + ctx.init_acknowledge_packet(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + if let Some(packet) = &mut msg.packet { + packet.destination_port = "different_port".to_string(); + } + + contract + .acknowledgement_packet_validate(deps.as_mut(), info, ctx.env, &msg) + .unwrap(); +} + +#[test] +#[should_panic( + expected = "IbcPacketError { error: IncorrectPacketCommitment { sequence: Sequence(1) } }" +)] +fn acknowledgement_packet_validate_fail_for_incorrect_packet_commitment() { + let mut msg = get_dummy_raw_msg_acknowledgement(10); + let mut ctx = TestContext::for_acknowledge_packet(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + ctx.init_acknowledge_packet(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + if let Some(packet) = &mut msg.packet { + packet.timeout_height = Some(RawHeight { + revision_height: 100, + revision_number: 100, + }); + } + + contract + .acknowledgement_packet_validate(deps.as_mut(), info, ctx.env, &msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "InvalidPacketSequence")] +fn acknowledgement_packet_validate_fail_for_invalid_packet_sequence() { + let msg = get_dummy_raw_msg_acknowledgement(10); + let mut ctx = TestContext::for_acknowledge_packet(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + if let Some(chann_end) = &mut ctx.channel_end { + chann_end.ordering = Order::Ordered + } + + ctx.init_acknowledge_packet(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + let packet = msg.clone().packet.unwrap(); + let dest_port = to_ibc_port_id(&packet.source_port).unwrap(); + let dest_channel = to_ibc_channel_id(&packet.source_channel).unwrap(); + + contract + .store_next_sequence_ack( + deps.as_mut().storage, + &dest_port, + &dest_channel, + &Sequence::from_str("2").unwrap(), + ) + .unwrap(); + + contract + .acknowledgement_packet_validate(deps.as_mut(), info, ctx.env, &msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "FrozenClient")] +fn acknowledgement_packet_validate_fail_for_frozen_client() { + let msg = get_dummy_raw_msg_acknowledgement(10); + let mut ctx = TestContext::for_acknowledge_packet(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 10 + } + + ctx.init_acknowledge_packet(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .acknowledgement_packet_validate(deps.as_mut(), info, ctx.env, &msg) + .unwrap(); +} + +#[test] +fn test_get_packet_acknowledgement() { + let ctx = TestContext::default(get_mock_env()); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + + let sequence = Sequence::from_str("0").unwrap(); + let ack_commitment = AcknowledgementCommitment::from(to_vec("ack").unwrap()); + + contract + .store_packet_acknowledgement( + deps.as_mut().storage, + &ctx.port_id, + &ctx.channel_id, + sequence, + ack_commitment.clone(), + ) + .unwrap(); + + let res = contract + .get_packet_acknowledgement( + deps.as_ref().storage, + &ctx.port_id, + &ctx.channel_id, + sequence, + ) + .unwrap(); + + assert_eq!(ack_commitment, res); +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_channel_closeinit.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_channel_closeinit.rs index ff00fa4ff..4992b9b3e 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_channel_closeinit.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_channel_closeinit.rs @@ -228,3 +228,24 @@ fn test_on_chan_close_init_submessage() { channel_close_init_validate.channel().order ); } + +#[test] +#[should_panic(expected = "ClientFrozen")] +fn fail_test_validate_chanel_close_init_for_frozen_client() { + let msg = get_dummy_raw_msg_chan_close_init(); + let mut ctx = TestContext::for_channel_close_init(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::default(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 1 + } + + ctx.init_channel_close_init(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .validate_channel_close_init(deps.as_mut(), info, &msg) + .unwrap(); +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_close_confirm.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_close_confirm.rs index 15b644f9b..baeff443c 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_close_confirm.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_close_confirm.rs @@ -234,3 +234,24 @@ pub fn test_channel_close_confirm_validate_fail_connection_hops() { }; channel_close_confirm_validate(&channel_id, &channel_end).unwrap(); } + +#[test] +#[should_panic(expected = "FrozenClient")] +fn fail_test_validate_channel_close_confirm_for_frozen_client() { + let msg = get_dummy_raw_msg_chan_close_confirm(10); + let mut ctx = TestContext::for_channel_close_confirm(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::default(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 1 + } + + ctx.init_channel_close_confirm(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .validate_channel_close_confirm(deps.as_mut(), info, &msg) + .unwrap(); +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_handler.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_handler.rs index b0226ec48..e58e7f8f3 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_handler.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_handler.rs @@ -1,5 +1,12 @@ use super::*; +use common::ibc::core::ics04_channel::channel::Order; +use common::ibc::core::ics24_host::identifier::PortId; + +use cw_ibc_core::ics03_connection::State as ConnectionState; +use cw_ibc_core::ics04_channel::{open_init, open_try}; +use cw_ibc_core::{context::CwIbcCoreContext, ConnectionEnd}; + #[test] #[should_panic(expected = "UndefinedConnectionCounterparty")] fn test_validate_open_try_channel_fail_missing_counterparty() { @@ -20,3 +27,110 @@ fn test_validate_open_try_channel_fail_missing_counterparty() { .validate_channel_open_try(deps.as_mut(), info, &raw) .unwrap(); } + +#[test] +#[should_panic(expected = "InvalidConnectionHopsLength")] +fn fail_test_validate_open_init_channel_on_invalid_connection_hops_length() { + let mut deps = deps(); + let contract = CwIbcCoreContext::default(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + let mut raw_channel = get_dummy_raw_channel_end(Some(0)); + raw_channel.connection_hops = Vec::new(); + + let msg = RawMsgChannelOpenInit { + port_id: PortId::default().to_string(), + channel: Some(raw_channel), + signer: get_dummy_bech32_account(), + }; + contract + .validate_channel_open_init(deps.as_mut(), info, &msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "InvalidVersionLengthConnection")] +fn fail_channel_open_init_msg_validate_on_invalid_version_length_of_connection() { + let ctx = TestContext::default(get_mock_env()); + + let conn_end = ConnectionEnd::new( + ctx.connection_end().state.clone(), + ctx.client_id.clone(), + ctx.connection_end().counterparty().clone(), + Vec::new(), + ctx.connection_end().delay_period().clone(), + ); + open_init::channel_open_init_msg_validate(&ctx.channel_end(), conn_end).unwrap(); +} + +#[test] +#[should_panic(expected = "ChannelFeatureNotSupportedByConnection")] +fn fail_channel_open_init_msg_validate_on_channel_feature_not_supported() { + let mut ctx = TestContext::default(get_mock_env()); + if let Some(chann_end) = &mut ctx.channel_end { + chann_end.ordering = Order::None + } + + open_init::channel_open_init_msg_validate(&ctx.channel_end(), ctx.connection_end()).unwrap(); +} + +#[test] +#[should_panic(expected = "ConnectionNotOpen")] +fn fail_channel_open_try_msg_validate_on_invalid_connection_state() { + let mut ctx = TestContext::default(get_mock_env()); + if let Some(conn_end) = &mut ctx.connection_end { + conn_end.state = ConnectionState::Init; + } + + open_try::channel_open_try_msg_validate(&ctx.channel_end(), &ctx.connection_end()).unwrap(); +} + +#[test] +#[should_panic(expected = "ChannelFeatureNotSupportedByConnection")] +fn fail_channel_open_try_msg_validate_on_feature_not_supported() { + let mut ctx = TestContext::default(get_mock_env()); + if let Some(chann_end) = &mut ctx.channel_end { + chann_end.ordering = Order::None + } + + open_try::channel_open_try_msg_validate(&ctx.channel_end(), &ctx.connection_end()).unwrap(); +} + +#[test] +#[should_panic(expected = "ClientFrozen")] +fn fail_test_validate_open_init_channel_for_frozen_client() { + let mut ctx = TestContext::default(get_mock_env()); + let mut deps = deps(); + let contract = CwIbcCoreContext::default(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 1 + } + + ctx.init_channel_open_init(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + let msg = get_dummy_raw_msg_chan_open_init(Some(0)); + contract + .validate_channel_open_init(deps.as_mut(), info, &msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "InvalidConnectionHopsLength")] +fn fail_test_validate_open_try_channel_on_invalid_connection_hops_length() { + let mut deps = deps(); + let contract = CwIbcCoreContext::default(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + let mut raw_channel = get_dummy_raw_channel_end(Some(0)); + raw_channel.connection_hops = Vec::new(); + + let mut msg = get_dummy_raw_msg_chan_open_try(0); + msg.channel = Some(raw_channel); + + contract + .validate_channel_open_try(deps.as_mut(), info, &msg) + .unwrap(); +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_ack.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_ack.rs index a9994193a..c34e4e72c 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_ack.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_ack.rs @@ -1,5 +1,6 @@ use super::*; use cosmwasm_std::IbcChannel; +use cw_ibc_core::ics04_channel::open_ack; use cw_ibc_core::{ conversions::to_ibc_channel_id, @@ -190,3 +191,88 @@ fn test_channel_open_try_validate() { let res = channel_open_try_msg_validate(&channel, &connection_end); assert!(res.is_ok()); } + +#[test] +#[should_panic(expected = "UnknownOrderType")] +fn fail_channel_open_ack_msg_validate_on_unknown_order() { + let mut ctx = TestContext::default(get_mock_env()); + if let Some(chann_end) = &mut ctx.channel_end { + chann_end.remote = common::ibc::core::ics04_channel::channel::Counterparty::default(); + chann_end.ordering = Order::None + } + + open_ack::on_chan_open_ack_submessage( + &ctx.channel_end(), + &ctx.port_id, + &ctx.channel_id, + &ctx.connection_id, + ) + .unwrap(); +} + +#[test] +fn test_channel_open_ack_msg_validate_on_ordered_type() { + let mut ctx = TestContext::default(get_mock_env()); + if let Some(chann_end) = &mut ctx.channel_end { + chann_end.remote = common::ibc::core::ics04_channel::channel::Counterparty::default(); + chann_end.ordering = Order::Ordered + } + + let res = Some( + open_ack::on_chan_open_ack_submessage( + &ctx.channel_end(), + &ctx.port_id, + &ctx.channel_id, + &ctx.connection_id, + ) + .unwrap(), + ); + + let res_exist = match res { + Some(_) => true, + None => false, + }; + assert_eq!(res_exist, true); +} + +#[test] +#[should_panic(expected = "FrozenClient")] +fn fail_test_validate_open_try_channel_for_frozen_client() { + let msg = get_dummy_raw_msg_chan_open_try(10); + let mut ctx = TestContext::for_channel_open_try(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::default(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 1 + } + + ctx.init_channel_open_try(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .validate_channel_open_try(deps.as_mut(), info, &msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "FrozenClient")] +fn fail_test_validate_channel_open_ack_for_frozen_client() { + let msg = get_dummy_raw_msg_chan_open_ack(10); + let mut ctx = TestContext::for_channel_open_ack(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::default(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 1 + } + + ctx.init_channel_open_ack(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .validate_channel_open_ack(deps.as_mut(), info, &msg) + .unwrap(); +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_confirm.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_confirm.rs index e957ccde8..6cea7b20b 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_confirm.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_open_confirm.rs @@ -1,4 +1,5 @@ use cosmwasm_std::IbcChannel; +use cw_ibc_core::ics04_channel::open_confirm; use cw_ibc_core::{ conversions::to_ibc_channel_id, @@ -139,3 +140,65 @@ pub fn test_on_chan_open_confirm_submessage() { assert_eq!(res.unwrap(), expected); } + +#[test] +#[should_panic(expected = "UnknownOrderType")] +fn fail_channel_open_confirm_msg_validate_on_unknown_order() { + let mut ctx = TestContext::default(get_mock_env()); + if let Some(chann_end) = &mut ctx.channel_end { + chann_end.remote = common::ibc::core::ics04_channel::channel::Counterparty::default(); + chann_end.ordering = Order::None + } + + open_confirm::on_chan_open_confirm_submessage( + &ctx.channel_end(), + &ctx.port_id, + &ctx.channel_id, + ) + .unwrap(); +} + +#[test] +fn test_channel_open_confirm_msg_validate_on_ordered_type() { + let mut ctx = TestContext::default(get_mock_env()); + if let Some(chann_end) = &mut ctx.channel_end { + chann_end.remote = common::ibc::core::ics04_channel::channel::Counterparty::default(); + chann_end.ordering = Order::Ordered + } + + let res = Some( + open_confirm::on_chan_open_confirm_submessage( + &ctx.channel_end(), + &ctx.port_id, + &ctx.channel_id, + ) + .unwrap(), + ); + + let res_exist = match res { + Some(_) => true, + None => false, + }; + assert_eq!(res_exist, true); +} + +#[test] +#[should_panic(expected = "FrozenClient")] +fn fail_test_validate_channel_open_confirm_for_frozen_client() { + let msg = get_dummy_raw_msg_chan_open_confirm(10); + let mut ctx = TestContext::for_channel_open_confirm(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::default(); + let info = create_mock_info("channel-creater", "umlg", 2000); + + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 1 + } + + ctx.init_channel_open_confirm(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .validate_channel_open_confirm(deps.as_mut(), info, &msg) + .unwrap(); +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_packet.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_packet.rs index cbf0f2858..7970ffe50 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_packet.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_packet.rs @@ -234,3 +234,20 @@ fn test_packet_send_fails_on_timedout_timestamp() { .send_packet(deps.as_mut(), &mock_env(), info, packet) .unwrap(); } + +#[test] +#[should_panic(expected = "Unauthorized")] +fn test_send_packet_fail_for_unauthenticated_capability() { + let packet = get_dummy_raw_packet(110, Timestamp::default().nanoseconds()); + let mut ctx = TestContext::for_send_packet(get_mock_env(), &packet); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + let info = create_mock_info("module", "test", 100); + + ctx.init_send_packet(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .send_packet(deps.as_mut(), &ctx.env, info, packet) + .unwrap(); +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_receive_packet.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_receive_packet.rs index fb5e304c3..ee001072d 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_receive_packet.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_receive_packet.rs @@ -1,13 +1,14 @@ use common::ibc::core::ics03_connection::connection::State as ConnectionState; +use common::ibc::core::ics04_channel::commitment::AcknowledgementCommitment; use common::ibc::core::ics04_channel::packet::Receipt; +use common::ibc::core::ics04_channel::timeout::TimeoutHeight; use common::ibc::timestamp::Timestamp; +use cosmwasm_std::to_vec; use cw_common::raw_types::channel::RawMsgRecvPacket; use cw_common::types::Ack; -use cw_ibc_core::conversions::to_ibc_channel_id; - -use cw_ibc_core::conversions::to_ibc_port_id; +use cw_ibc_core::conversions::{to_ibc_channel_id, to_ibc_port_id, to_ibc_timeout_block}; use cw_ibc_core::VALIDATE_ON_PACKET_RECEIVE_ON_MODULE; @@ -269,6 +270,139 @@ fn test_receive_packet_no_op_on_packet_already_received() { .validate_receive_packet(deps.as_mut(), info, env, &msg) .unwrap(); } + +#[test] +fn test_is_packet_already_received_for_none_ordered_channel() { + let msg = get_dummy_raw_msg_recv_packet(10); + let mut ctx = TestContext::for_receive_packet(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + + ctx.init_receive_packet(deps.as_mut().storage, &contract); + if let Some(channel_end) = &mut ctx.channel_end { + channel_end.ordering = Order::None; + } + + let packet = msg.packet.clone().unwrap(); + let des_port = to_ibc_port_id(&packet.destination_port).unwrap(); + let des_channel = to_ibc_channel_id(&packet.destination_channel).unwrap(); + + let res = contract + .is_packet_already_received( + deps.as_ref(), + &ctx.channel_end(), + &des_port, + &des_channel, + msg.packet.unwrap().sequence.into(), + ) + .unwrap(); + + assert_eq!(res, false) +} + +#[test] +#[should_panic( + expected = "InvalidPacketSequence { given_sequence: Sequence(1), next_sequence: Sequence(0) }" +)] +fn test_is_packet_already_received_fail_for_invalid_packet_sequence() { + let msg = get_dummy_raw_msg_recv_packet(10); + let mut ctx = TestContext::for_receive_packet(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + + if let Some(channel_end) = &mut ctx.channel_end { + channel_end.ordering = Order::Ordered; + } + + let packet = msg.packet.clone().unwrap(); + let des_port = to_ibc_port_id(&packet.destination_port).unwrap(); + let des_channel = to_ibc_channel_id(&packet.destination_channel).unwrap(); + + contract + .store_next_sequence_recv( + deps.as_mut().storage, + &des_port, + &des_channel, + &Sequence::from(0), + ) + .unwrap(); + + contract + .is_packet_already_received( + deps.as_ref(), + &ctx.channel_end(), + &des_port, + &des_channel, + msg.packet.unwrap().sequence.into(), + ) + .unwrap(); +} + +#[test] +fn test_is_packet_already_received() { + let msg = get_dummy_raw_msg_recv_packet(10); + let mut ctx = TestContext::for_receive_packet(get_mock_env(), &msg); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + + if let Some(channel_end) = &mut ctx.channel_end { + channel_end.ordering = Order::Ordered; + } + + let packet = msg.packet.clone().unwrap(); + let des_port = to_ibc_port_id(&packet.destination_port).unwrap(); + let des_channel = to_ibc_channel_id(&packet.destination_channel).unwrap(); + + contract + .store_next_sequence_recv( + deps.as_mut().storage, + &des_port, + &des_channel, + &Sequence::from(1), + ) + .unwrap(); + + let res = contract + .is_packet_already_received( + deps.as_ref(), + &ctx.channel_end(), + &des_port, + &des_channel, + msg.packet.unwrap().sequence.into(), + ) + .unwrap(); + + assert_eq!(res, false) +} + +#[test] +#[should_panic(expected = "{ error: AcknowledgementExists { sequence: Sequence(1) } }")] +fn fail_test_validate_write_acknowledgement() { + let msg = get_dummy_raw_msg_recv_packet(10); + let mut deps = deps(); + let contract = CwIbcCoreContext::new(); + + let packet = msg.packet.unwrap(); + let sequence = packet.sequence.into(); + let dest_port = to_ibc_port_id(&packet.destination_port).unwrap(); + let dest_channel = to_ibc_channel_id(&packet.destination_channel).unwrap(); + let ack_commitment = AcknowledgementCommitment::from(to_vec("0").unwrap()); + + contract + .store_packet_acknowledgement( + deps.as_mut().storage, + &dest_port, + &dest_channel, + sequence, + ack_commitment, + ) + .unwrap(); + + contract + .validate_write_acknowledgement(deps.as_mut().storage, &packet) + .unwrap(); +} + #[test] fn execute_receive_packet() { let contract = CwIbcCoreContext::default(); @@ -407,3 +541,14 @@ fn test_lookup_module_packet() { assert!(res.is_ok()); assert_eq!("contractaddress", res.unwrap()) } + +#[test] +fn test_timeout_height_to_str() { + let contract = CwIbcCoreContext::new(); + + let timeout_height = TimeoutHeight::from(mock_height(1, 1).unwrap()); + let timeout = to_ibc_timeout_block(&timeout_height); + + let res = contract.timeout_height_to_str(timeout); + assert_eq!(res, "1-1".to_string()) +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout.rs index 78ea42633..eb3b0f05f 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout.rs @@ -1,3 +1,6 @@ +use common::icon::icon::proto::core::channel::channel::Order; + +use cw_common::types::TimeoutMsgType; use cw_ibc_core::{light_client::light_client::LightClient, VALIDATE_ON_PACKET_TIMEOUT_ON_MODULE}; use super::*; @@ -131,7 +134,9 @@ fn test_timeout_packet_validate_to_light_client() { mock_lightclient_query(test_context.mock_queries, &mut deps); - let res = contract.timeout_packet_validate_to_light_client(deps.as_mut(), info, env, msg); + let res = + contract.timeout_packet_validate(deps.as_mut(), env, info, TimeoutMsgType::Timeout(msg)); + println!("{res:?}"); assert!(res.is_ok()); assert_eq!( @@ -155,129 +160,12 @@ fn test_timeout_packet_fails_if_height_not_expired() { let mut test_context = TestContext::for_packet_timeout(env.clone(), &msg); test_context.init_timeout_packet(deps.as_mut().storage, &contract); - // let packet = &msg.packet.clone().unwrap(); - // let src_port = to_ibc_port_id(&packet.source_port).unwrap(); - // let src_channel = to_ibc_channel_id(&packet.source_channel).unwrap(); - - // let dst_port = to_ibc_port_id(&packet.destination_port).unwrap(); - // let dst_channel = to_ibc_channel_id(&packet.destination_channel).unwrap(); - - // let packet_timeout_height = to_ibc_timeout_height(packet.timeout_height.clone()).unwrap(); - // let packet_timestamp = to_ibc_timestamp(packet.timeout_timestamp).unwrap(); - // let packet_sequence = Sequence::from(packet.sequence); - // let proof_height = to_ibc_height(msg.proof_height.clone()).unwrap(); - // let _next_sequence_recv = Sequence::from(msg.next_sequence_recv); - - // let chan_end_on_a_ordered = ChannelEnd::new( - // State::Open, - // Order::Ordered, - // Counterparty::new(dst_port, Some(dst_channel)), - // vec![IbcConnectionId::default()], - // Version::new("ics20-1".to_string()), - // ); - // contract - // .store_channel_end( - // &mut deps.storage, - // &src_port.clone(), - // &src_channel.clone(), - // &chan_end_on_a_ordered, - // ) - // .unwrap(); - // let conn_prefix = common::ibc::core::ics23_commitment::commitment::CommitmentPrefix::try_from( - // "hello".to_string().as_bytes().to_vec(), - // ); - - // let conn_end_on_a = ConnectionEnd::new( - // ConnectionState::Open, - // ClientId::default(), - // ConnectionCounterparty::new( - // ClientId::default(), - // Some(ConnectionId::default()), - // conn_prefix.unwrap(), - // ), - // get_compatible_versions(), - // ZERO_DURATION, - // ); - // contract - // .store_connection( - // &mut deps.storage, - // &chan_end_on_a_ordered.connection_hops()[0].clone(), - // &conn_end_on_a, - // ) - // .unwrap(); - // let packet_commitment = - // compute_packet_commitment(&packet.data, &packet_timeout_height, &packet_timestamp); - - // contract - // .store_packet_commitment( - // &mut deps.storage, - // &src_port, - // &src_channel, - // packet_sequence, - // packet_commitment, - // ) - // .unwrap(); - - // let client_state: ClientState = get_dummy_client_state(); - - // let client = client_state.to_any().encode_to_vec(); - // contract - // .store_client_state( - // &mut deps.storage, - // &env, - // &IbcClientId::default(), - // client, - // client_state.get_keccak_hash().to_vec(), - // ) - // .unwrap(); - // let _client_type = IbcClientType::new("iconclient".to_string()); - - // let light_client = LightClient::new("lightclient".to_string()); - // contract - // .store_client_implementations( - // &mut deps.storage, - // &IbcClientId::default(), - // light_client.clone(), - // ) - // .unwrap(); - let timestamp_query = LightClient::get_timestamp_at_height_query(&IbcClientId::default(), proof_height).unwrap(); let mut mocks = test_context.mock_queries.clone(); mocks.insert(timestamp_query, to_binary(&0_u64).unwrap()); mock_lightclient_query(mocks, &mut deps); - // contract - // .bind_port(&mut deps.storage, &src_port, "moduleaddress".to_string()) - // .unwrap(); - - // let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - // message_root: vec![1, 2, 3, 4], - // next_proof_context_hash: vec![1, 2, 3], - // } - // .try_into() - // .unwrap(); - - // let consenus_state_any = consenus_state.to_any().encode_to_vec(); - // contract - // .store_consensus_state( - // &mut deps.storage, - // &IbcClientId::default(), - // proof_height, - // consenus_state_any, - // consenus_state.get_keccak_hash().to_vec(), - // ) - // .unwrap(); - // let env = get_mock_env(); - // contract - // .ibc_store() - // .expected_time_per_block() - // .save(deps.as_mut().storage, &(env.block.time.seconds())) - // .unwrap(); - // let light_client = LightClient::new("lightclient".to_string()); - // contract - // .store_client_implementations(deps.as_mut().storage, &IbcClientId::default(), light_client) - // .unwrap(); contract .timeout_packet_validate_to_light_client(deps.as_mut(), info, env, msg) .unwrap(); @@ -298,91 +186,6 @@ fn test_timeout_packet_fails_if_timestamp_not_expired() { let mut test_context = TestContext::for_packet_timeout(env.clone(), &msg); test_context.init_timeout_packet(deps.as_mut().storage, &contract); - // let packet = &msg.packet.clone().unwrap(); - // let src_port = to_ibc_port_id(&packet.source_port).unwrap(); - // let src_channel = to_ibc_channel_id(&packet.source_channel).unwrap(); - - // let dst_port = to_ibc_port_id(&packet.destination_port).unwrap(); - // let dst_channel = to_ibc_channel_id(&packet.destination_channel).unwrap(); - - // let packet_timeout_height = to_ibc_timeout_height(packet.timeout_height.clone()).unwrap(); - // let packet_timestamp = to_ibc_timestamp(packet.timeout_timestamp).unwrap(); - // let packet_sequence = Sequence::from(packet.sequence); - // let proof_height = to_ibc_height(msg.proof_height.clone()).unwrap(); - // let _next_sequence_recv = Sequence::from(msg.next_sequence_recv); - - // let chan_end_on_a_ordered = ChannelEnd::new( - // State::Open, - // Order::Ordered, - // Counterparty::new(dst_port, Some(dst_channel)), - // vec![IbcConnectionId::default()], - // Version::new("ics20-1".to_string()), - // ); - // contract - // .store_channel_end( - // &mut deps.storage, - // &src_port.clone(), - // &src_channel.clone(), - // &chan_end_on_a_ordered, - // ) - // .unwrap(); - // let conn_prefix = common::ibc::core::ics23_commitment::commitment::CommitmentPrefix::try_from( - // "hello".to_string().as_bytes().to_vec(), - // ); - - // let conn_end_on_a = ConnectionEnd::new( - // ConnectionState::Open, - // ClientId::default(), - // ConnectionCounterparty::new( - // ClientId::default(), - // Some(ConnectionId::default()), - // conn_prefix.unwrap(), - // ), - // get_compatible_versions(), - // ZERO_DURATION, - // ); - // contract - // .store_connection( - // &mut deps.storage, - // &chan_end_on_a_ordered.connection_hops()[0].clone(), - // &conn_end_on_a, - // ) - // .unwrap(); - // let packet_commitment = - // compute_packet_commitment(&packet.data, &packet_timeout_height, &packet_timestamp); - - // contract - // .store_packet_commitment( - // &mut deps.storage, - // &src_port, - // &src_channel, - // packet_sequence, - // packet_commitment, - // ) - // .unwrap(); - - // let client_state: ClientState = get_dummy_client_state(); - - // let client = client_state.to_any().encode_to_vec(); - // contract - // .store_client_commitment( - // &mut deps.storage, - // &env, - // &IbcClientId::default(), - - // client_state.get_keccak_hash().to_vec(), - // ) - // .unwrap(); - // let _client_type = IbcClientType::new("iconclient".to_string()); - - // let light_client = LightClient::new("lightclient".to_string()); - // contract - // .store_client_implementations( - // &mut deps.storage, - // &IbcClientId::default(), - // light_client.clone(), - // ) - // .unwrap(); let timestamp_query = LightClient::get_timestamp_at_height_query(&IbcClientId::default(), proof_height).unwrap(); let mut mocks = test_context.mock_queries.clone(); @@ -393,38 +196,83 @@ fn test_timeout_packet_fails_if_timestamp_not_expired() { ); mock_lightclient_query(mocks, &mut deps); - // contract - // .bind_port(&mut deps.storage, &src_port, "moduleaddress".to_string()) - // .unwrap(); - - // let consenus_state: ConsensusState = common::icon::icon::lightclient::v1::ConsensusState { - // message_root: vec![1, 2, 3, 4], - // next_proof_context_hash: vec![1, 2, 3], - // } - // .try_into() - // .unwrap(); - - // let consenus_state_any = consenus_state.to_any().encode_to_vec(); - // contract - // .store_consensus_commitment( - // &mut deps.storage, - // &IbcClientId::default(), - // proof_height, - - // consenus_state.get_keccak_hash().to_vec(), - // ) - // .unwrap(); - // let env = get_mock_env(); - // contract - // .ibc_store() - // .expected_time_per_block() - // .save(deps.as_mut().storage, &(env.block.time.seconds())) - // .unwrap(); - // let light_client = LightClient::new("lightclient".to_string()); - // contract - // .store_client_implementations(deps.as_mut().storage, &IbcClientId::default(), light_client) - // .unwrap(); contract .timeout_packet_validate_to_light_client(deps.as_mut(), info, env, msg) .unwrap(); } + +#[test] +#[should_panic(expected = "ChannelClosed")] +fn test_timeout_packet_fails_for_closed_connection() { + let proof_height = 50; + let timeout_height = proof_height - 1; + let timeout_timestamp = 0; + let msg = get_dummy_raw_msg_timeout(proof_height, timeout_height, timeout_timestamp); + + let mut ctx = TestContext::for_packet_timeout(get_mock_env(), &msg); + let contract = CwIbcCoreContext::default(); + let mut deps = deps(); + let info = create_mock_info("channel-creater", "umlg", 20000000); + + if let Some(channel_end) = &mut ctx.channel_end { + channel_end.state = cw_ibc_core::ics04_channel::State::Closed; + } + + ctx.init_timeout_packet(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .timeout_packet_validate_to_light_client(deps.as_mut(), info, ctx.env, msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "InvalidPacketSequence")] +fn test_timeout_packet_fails_for_invalid_packet_sequence() { + let proof_height = 50; + let timeout_height = proof_height - 1; + let timeout_timestamp = 0; + let mut msg = get_dummy_raw_msg_timeout(proof_height, timeout_height, timeout_timestamp); + msg.next_sequence_recv = 20; + + let mut ctx = TestContext::for_packet_timeout(get_mock_env(), &msg); + let contract = CwIbcCoreContext::default(); + let mut deps = deps(); + let info = create_mock_info("channel-creater", "umlg", 20000000); + + if let Some(channel_end) = &mut ctx.channel_end { + channel_end.ordering = channel::Order::Ordered; + } + + ctx.init_timeout_packet(deps.as_mut().storage, &contract); + ctx.save_timestamp_at_height(proof_height, 0); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .timeout_packet_validate_to_light_client(deps.as_mut(), info, ctx.env, msg) + .unwrap(); +} + +#[test] +fn test_timeout_packet_for_ordered_channel() { + let proof_height = 50; + let timeout_height = proof_height - 1; + let timeout_timestamp = 0; + let msg = get_dummy_raw_msg_timeout(proof_height, timeout_height, timeout_timestamp); + + let mut ctx = TestContext::for_packet_timeout(get_mock_env(), &msg); + let contract = CwIbcCoreContext::default(); + let mut deps = deps(); + let info = create_mock_info("channel-creater", "umlg", 20000000); + + if let Some(channel_end) = &mut ctx.channel_end { + channel_end.ordering = channel::Order::Ordered; + } + + ctx.init_timeout_packet(deps.as_mut().storage, &contract); + ctx.save_timestamp_at_height(proof_height, 0); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + let res = contract.timeout_packet_validate_to_light_client(deps.as_mut(), info, ctx.env, msg); + assert!(res.is_ok()) +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout_on_close.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout_on_close.rs index 9fff8a5dc..eb7c0a61d 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout_on_close.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/channel/test_timeout_on_close.rs @@ -1,3 +1,4 @@ +use cw_common::types::TimeoutMsgType; use cw_ibc_core::VALIDATE_ON_PACKET_TIMEOUT_ON_MODULE; use super::*; @@ -17,8 +18,12 @@ fn test_timeout_on_close_packet_validate_to_light_client() { mock_lightclient_query(test_context.mock_queries, &mut deps); - let res = - contract.timeout_on_close_packet_validate_to_light_client(deps.as_mut(), info, env, msg); + let res = contract.timeout_packet_validate( + deps.as_mut(), + env, + info, + TimeoutMsgType::TimeoutOnClose(msg), + ); print!("{:?}", res); assert!(res.is_ok()); assert_eq!( @@ -26,3 +31,129 @@ fn test_timeout_on_close_packet_validate_to_light_client() { VALIDATE_ON_PACKET_TIMEOUT_ON_MODULE ) } + +#[test] +#[should_panic(expected = "InvalidPacketCounterparty")] +fn test_timeout_on_close_packet_validate_to_light_client_fails_on_invalid_channel_counterparty() { + let height = 2; + let timeout_timestamp = 5; + let mut msg = get_dummy_raw_msg_timeout_on_close(height, timeout_timestamp); + + let mut ctx = TestContext::for_packet_timeout_on_close(get_mock_env(), &msg); + let contract = CwIbcCoreContext::default(); + let mut deps = deps(); + let info = create_mock_info("channel-creater", "umlg", 20000000); + + ctx.init_timeout_packet_on_close(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + if let Some(packet) = &mut msg.packet { + packet.destination_port = "different_port".to_string(); + } + + contract + .timeout_on_close_packet_validate_to_light_client(deps.as_mut(), info, ctx.env, msg) + .unwrap(); +} + +#[test] +#[should_panic( + expected = "IbcPacketError { error: IncorrectPacketCommitment { sequence: Sequence(1) } }" +)] +fn test_timeout_on_close_packet_validate_to_light_client_fails_on_incorrect_packet_commitment() { + let height = 2; + let timeout_timestamp = 5; + let mut msg = get_dummy_raw_msg_timeout_on_close(height, timeout_timestamp); + + let mut ctx = TestContext::for_packet_timeout_on_close(get_mock_env(), &msg); + let contract = CwIbcCoreContext::default(); + let mut deps = deps(); + let info = create_mock_info("channel-creater", "umlg", 20000000); + + ctx.init_timeout_packet_on_close(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + if let Some(packet) = &mut msg.packet { + packet.timeout_timestamp = 100; + } + + contract + .timeout_on_close_packet_validate_to_light_client(deps.as_mut(), info, ctx.env, msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "FrozenClient")] +fn test_timeout_on_close_packet_validate_to_light_client_fails_for_frozen_client() { + let height = 2; + let timeout_timestamp = 5; + let msg = get_dummy_raw_msg_timeout_on_close(height, timeout_timestamp); + + let mut ctx = TestContext::for_packet_timeout_on_close(get_mock_env(), &msg); + let contract = CwIbcCoreContext::default(); + let mut deps = deps(); + let info = create_mock_info("channel-creater", "umlg", 20000000); + + if let Some(client_state) = &mut ctx.client_state { + client_state.frozen_height = 10; + } + + ctx.init_timeout_packet_on_close(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .timeout_on_close_packet_validate_to_light_client(deps.as_mut(), info, ctx.env, msg) + .unwrap(); +} + +#[test] +#[should_panic(expected = "InvalidPacketSequence")] +fn test_timeout_on_close_packet_validate_to_light_client_fails_on_invalid_packet_sequence() { + let height = 2; + let timeout_timestamp = 5; + let mut msg = get_dummy_raw_msg_timeout_on_close(height, timeout_timestamp); + msg.next_sequence_recv = 2; + + let mut ctx = TestContext::for_packet_timeout_on_close(get_mock_env(), &msg); + let contract = CwIbcCoreContext::default(); + let mut deps = deps(); + let info = create_mock_info("channel-creater", "umlg", 20000000); + + if let Some(channel_end) = &mut ctx.channel_end { + channel_end.ordering = Order::Ordered; + } + + ctx.init_timeout_packet_on_close(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + contract + .timeout_on_close_packet_validate_to_light_client(deps.as_mut(), info, ctx.env, msg) + .unwrap(); +} + +#[test] +fn test_timeout_on_close_packet_validate_to_light_client_for_orderd_channel() { + let height = 2; + let timeout_timestamp = 5; + let msg = get_dummy_raw_msg_timeout_on_close(height, timeout_timestamp); + + let mut ctx = TestContext::for_packet_timeout_on_close(get_mock_env(), &msg); + let contract = CwIbcCoreContext::default(); + let mut deps = deps(); + let info = create_mock_info("channel-creater", "umlg", 20000000); + + if let Some(channel_end) = &mut ctx.channel_end { + channel_end.ordering = Order::Ordered; + } + + ctx.init_timeout_packet_on_close(deps.as_mut().storage, &contract); + mock_lightclient_query(ctx.mock_queries, &mut deps); + + let res = contract.timeout_on_close_packet_validate_to_light_client( + deps.as_mut(), + info, + ctx.env, + msg, + ); + assert!(res.is_ok()) +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_channel.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_channel.rs index 082d5a003..64d2b28fd 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_channel.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_channel.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::{str::FromStr, time::Duration}; use common::traits::AnyTypes; -use cosmwasm_std::testing::mock_env; +use cosmwasm_std::testing::{mock_dependencies, mock_env}; use cosmwasm_std::{ to_binary, Addr, Event, IbcEndpoint, IbcPacket, IbcPacketReceiveMsg, IbcTimeout, IbcTimeoutBlock, Reply, SubMsgResponse, SubMsgResult, @@ -19,17 +19,13 @@ use common::ibc::{ events::IbcEventType, }; use cw_common::ibc_types::{IbcClientId, IbcConnectionId, IbcPortId}; -use cw_common::raw_types::channel::RawPacket; +use cw_common::raw_types::channel::*; use cw_common::raw_types::to_raw_packet; use cw_ibc_core::conversions::{to_ibc_channel, to_ibc_channel_id, to_ibc_height, to_ibc_port_id}; -use cw_ibc_core::ics04_channel::open_init::{ - create_channel_submesssage, on_chan_open_init_submessage, -}; - use cw_ibc_core::ics04_channel::{ - create_channel_event, create_packet_event, EXECUTE_ON_CHANNEL_OPEN_INIT, + create_channel_event, create_packet_event, open_init, EXECUTE_ON_CHANNEL_OPEN_INIT, EXECUTE_ON_CHANNEL_OPEN_TRY, }; use cw_ibc_core::light_client::light_client::LightClient; @@ -517,7 +513,7 @@ fn test_validate_open_init_channel() { let res = contract.validate_channel_open_init(deps.as_mut(), info.clone(), &raw); - let expected = on_chan_open_init_submessage( + let expected = open_init::on_chan_open_init_submessage( &test_context.channel_end(), &test_context.port_id, &test_context.channel_id, @@ -525,7 +521,7 @@ fn test_validate_open_init_channel() { ); let data = cw_common::ibc_dapp_msg::ExecuteMsg::IbcChannelOpen { msg: expected }; let data = to_binary(&data).unwrap(); - let on_chan_open_init = create_channel_submesssage( + let on_chan_open_init = open_init::create_channel_submesssage( "moduleaddress".to_string(), data, info.funds, @@ -667,3 +663,46 @@ fn test_get_channel_fail() { ctx.get_channel_end(mock_deps.as_ref().storage, &port_id, &channel_id) .unwrap(); } + +#[test] +#[should_panic(expected = "ChannelNotFound")] +fn fail_test_channel_end_not_found() { + let ctx = TestContext::default(get_mock_env()); + let deps = mock_dependencies(); + let contract = CwIbcCoreContext::new(); + + contract + .channel_end(deps.as_ref().storage, &ctx.port_id, &ctx.channel_id) + .unwrap(); +} + +#[test] +#[should_panic(expected = "InvalidEventType")] +fn fail_create_channel_event() { + let ctx = TestContext::default(get_mock_env()); + + create_channel_event( + IbcEventType::AppModule, + &ctx.port_id.to_string(), + &ctx.channel_id.to_string(), + &ctx.channel_end(), + ) + .unwrap(); +} + +#[test] +#[should_panic(expected = "InvalidEventType")] +fn fail_create_packet_event() { + let ctx = TestContext::default(get_mock_env()); + + let packet = get_dummy_raw_packet(10, 1); + + create_packet_event( + IbcEventType::CreateClient, + &packet, + &Order::Unordered, + &ctx.connection_id, + Some(Vec::new()), + ) + .unwrap(); +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs index 89c80cce9..bec0cd989 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_connection.rs @@ -1,4 +1,5 @@ use cosmwasm_std::Timestamp; +use std::str::FromStr; use std::time::Duration; pub mod setup; @@ -32,6 +33,7 @@ use common::ibc::core::ics23_commitment::commitment::CommitmentPrefix; use common::ibc::core::ics24_host::identifier::ConnectionId; use common::ibc::events::IbcEventType; use cw_common::ibc_types::IbcClientId; +use cw_ibc_core::validations::ensure_consensus_height_valid; use cw_ibc_core::ConnectionEnd; use prost::Message; use setup::*; @@ -905,3 +907,13 @@ fn connection_open_ack_validate_fails_of_connection_mismatch() { .connection_open_ack(deps.as_mut(), info, env, message) .unwrap(); } + +#[test] +#[should_panic(expected = "InvalidConsensusHeight")] +fn test_ensure_consensus_height_valid() { + ensure_consensus_height_valid( + &common::ibc::core::ics02_client::height::Height::from_str("10-10").unwrap(), + &common::ibc::core::ics02_client::height::Height::from_str("11-11").unwrap(), + ) + .unwrap() +} diff --git a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_host.rs b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_host.rs index 4e1806966..ab42ce1a9 100644 --- a/contracts/cosmwasm-vm/cw-ibc-core/tests/test_host.rs +++ b/contracts/cosmwasm-vm/cw-ibc-core/tests/test_host.rs @@ -136,6 +136,16 @@ fn test_set_expected_time_per_block() { assert!(result.is_ok()) } +#[test] +fn test_calc_block_delay_with_zero_deplay_period_time() { + let contract = CwIbcCoreContext::default(); + + let delay_period_time = Duration::from_secs(0); + let res = contract.calc_block_delay(&delay_period_time); + + assert_eq!(res, 0); +} + #[test] fn test_get_expected_time_per_block() { let mut deps = deps(); From 17ce3392f9b5fd138d0f39d576df5447c9ea9b50 Mon Sep 17 00:00:00 2001 From: AntonAndell Date: Mon, 25 Mar 2024 07:48:56 +0100 Subject: [PATCH 57/64] docs: Add explanation on how a connection can be manually verified (#838) doc: Add explanation on how a connection can be manually verified --- docs/adr/ICON_IBC.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/adr/ICON_IBC.md b/docs/adr/ICON_IBC.md index ee82cbdfd..8356d75cc 100644 --- a/docs/adr/ICON_IBC.md +++ b/docs/adr/ICON_IBC.md @@ -34,10 +34,24 @@ func updateConnectionCommitment(connection): sendBTPMessage(join(clientKey, clientState)); sendBTPMessage(join(consensusKey, latestConsensusState)); sendBTPMessage(join(connectionKey, connection)) -} + ``` During connection establishment all self client validation is skipped, and will have to be done manually when opening a new channel. +### Manual connection verification +(These steps can be omitted if the connection was established by a relay that you trust) +To verify that a counterparty has stored the correct clientState or consensus state, find the latest BTP block that should be on the client and compare that to what is on the light client. +Easiest way is to manually verify it on the counterparty client by fetching the client or consensus state directly from the client. But can also be proved through verifyMembership on the lightClient on ICON. + +A btp block can be fetched [Block](https://github.com/icon-project/goloop/blob/master/doc/btp2_extension.md) GET request. +Which can then be compared with the states in the light client: +``` +GetConsensusState { client_id: String, height: u64 }, +#[returns(Vec)] +GetLatestConsensusState { client_id: String }, +#[returns(Vec)] +GetClientState { client_id: String }, +``` ## ICS-04 For BTP blocks and the ICON lightclient we have two restrictions: From 5bd6c106fd652d05ba883b92ac1dc6632efa7919 Mon Sep 17 00:00:00 2001 From: ForwardSlashBack <142098649+ForwardSlashBack@users.noreply.github.com> Date: Mon, 25 Mar 2024 03:09:29 -0400 Subject: [PATCH 58/64] fix: add reference to CI workflow to fix error (#839) Co-authored-by: ForwardSlashBack --- .github/workflows/runner-start.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/runner-start.yml b/.github/workflows/runner-start.yml index 20d41a4bd..987f71422 100644 --- a/.github/workflows/runner-start.yml +++ b/.github/workflows/runner-start.yml @@ -40,7 +40,7 @@ jobs: repository: icon-project/ibc-relay - name: Start EC2 instance id: start - uses: machulav/ec2-github-runner + uses: machulav/ec2-github-runner@v2 with: mode: start github-token: ${{ secrets.GH_RUNNER_PAT }} @@ -49,4 +49,4 @@ jobs: subnet-id: subnet-f1fcd4df security-group-id: sg-03cb8034e27e1caeb pre-runner-script: | - ./build.sh ${{ inputs.relayer_version == '' && steps.relay.outputs.release || inputs.relayer_version }} \ No newline at end of file + ./build.sh ${{ inputs.relayer_version == '' && steps.relay.outputs.release || inputs.relayer_version }} From 545da5c738259dd2f3572fe48a6432dc90a33912 Mon Sep 17 00:00:00 2001 From: undefined <107839945+bishalbikram@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:08:36 +0545 Subject: [PATCH 59/64] chore: add unit test coverage for icon light client (#851) --- .../cw-icon-light-client/src/contract.rs | 132 +++++++++++++++- .../cw-icon-light-client/src/light_client.rs | 66 +++++++- .../cw-icon-light-client/src/state.rs | 142 ++++++++++++++++++ 3 files changed, 335 insertions(+), 5 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs index 92728e03a..0dee73030 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs @@ -539,15 +539,15 @@ mod tests { use common::icon::icon::types::v1::{BtpHeader, SignedHeader}; use cosmwasm_std::{ testing::{mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage}, - Addr, OwnedDeps, Response, + to_binary, Addr, OwnedDeps, Response, }; use cw2::get_contract_version; - use cw_common::raw_types::Any; + use cw_common::{client_msg::QueryMsg, raw_types::Any}; use test_utils::{get_test_headers, get_test_signed_headers, to_attribute_map}; use crate::{ constants::{CLIENT_STATE_HASH, CONSENSUS_STATE_HASH}, - contract::to_height_u64, + contract::{ensure_owner, query, to_height_u64}, query_handler::QueryHandler, ContractError, }; @@ -878,4 +878,130 @@ mod tests { Err(ContractError::HeightAlreadyUpdated { height: 82873 }) ); } + + #[test] + fn test_query_client_state() { + let start_header = &get_test_headers()[0]; + let client_id = "test_client".to_string(); + let deps = init_client(&client_id, start_header, None); + + let msg = QueryMsg::GetClientState { + client_id: client_id.clone(), + }; + let res = query(deps.as_ref(), mock_env(), msg).unwrap(); + + let state = + QueryHandler::get_client_state_any(deps.as_ref().storage, client_id.as_str()).unwrap(); + assert_eq!(res, to_binary(&state).unwrap()); + } + + #[test] + fn test_query_consensus_state() { + let start_header = &get_test_headers()[0]; + let client_id = "test_client".to_string(); + let deps = init_client(&client_id, start_header, None); + + let msg = QueryMsg::GetConsensusState { + client_id: client_id.clone(), + height: start_header.main_height, + }; + let res = query(deps.as_ref(), mock_env(), msg).unwrap(); + + let state = QueryHandler::get_consensus_state_any( + deps.as_ref().storage, + client_id.as_str(), + start_header.main_height, + ) + .unwrap(); + assert_eq!(res, to_binary(&state).unwrap()); + } + + #[test] + fn test_query_latest_height() { + let start_header = &get_test_headers()[0]; + let client_id = "test_client".to_string(); + let deps = init_client(&client_id, start_header, None); + + let msg = QueryMsg::GetLatestHeight { + client_id: client_id.clone(), + }; + let res = query(deps.as_ref(), mock_env(), msg).unwrap(); + + let height = + QueryHandler::get_latest_height(deps.as_ref().storage, client_id.as_str()).unwrap(); + assert_eq!(res, to_binary(&height).unwrap()); + } + + #[test] + fn test_query_latest_consensus_state() { + let start_header = &get_test_headers()[0]; + let client_id = "test_client".to_string(); + let deps = init_client(&client_id, start_header, None); + + let msg = QueryMsg::GetLatestConsensusState { + client_id: client_id.clone(), + }; + let res = query(deps.as_ref(), mock_env(), msg).unwrap(); + + let state = + QueryHandler::get_latest_consensus_state(deps.as_ref().storage, client_id.as_str()) + .unwrap(); + assert_eq!(res, to_binary(&state).unwrap()); + } + + #[test] + #[should_panic(expected = "Std(NotFound { kind: \"alloc::vec::Vec")] + fn test_query_latest_consensus_state_fail() { + let start_header = &get_test_headers()[0]; + let client_id = "test_client".to_string(); + let deps = init_client(&client_id, start_header, None); + + let msg = QueryMsg::GetLatestConsensusState { + client_id: "another_client".to_string(), + }; + query(deps.as_ref(), mock_env(), msg).unwrap(); + } + + #[test] + fn test_query_previous_consensus_state() { + let start_header = &get_test_headers()[0]; + let client_id = "test_client".to_string(); + let deps = init_client(&client_id, start_header, None); + + let msg = QueryMsg::GetPreviousConsensusState { + client_id: client_id.clone(), + height: start_header.main_height, + }; + let res = query(deps.as_ref(), mock_env(), msg).unwrap(); + + let state = QueryHandler::get_previous_consensus( + deps.as_ref().storage, + start_header.main_height, + client_id, + ) + .unwrap(); + assert_eq!(res, to_binary(&state).unwrap()); + } + + #[test] + fn test_ensure_owner() { + let start_header = &get_test_headers()[0]; + let client_id = "test_client".to_string(); + let deps = init_client(&client_id, start_header, None); + let info = mock_info(SENDER, &[]); + + let res = ensure_owner(deps.as_ref(), &info); + assert!(res.is_ok()) + } + + #[test] + #[should_panic(expected = "Unauthorized")] + fn test_ensure_owner_unauthorized() { + let start_header = &get_test_headers()[0]; + let client_id = "test_client".to_string(); + let deps = init_client(&client_id, start_header, None); + let info = mock_info("not_owner", &[]); + + ensure_owner(deps.as_ref(), &info).unwrap() + } } diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/light_client.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/light_client.rs index c24fc45ee..b3f6130c8 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/light_client.rs @@ -85,11 +85,11 @@ impl<'a> IconClient<'a> { .get_processed_block_at_height(client_id, height)?; let current_time = self.context.get_current_block_time(); let current_height = self.context.get_current_block_height(); - if !current_time >= (processed_time + delay_time) { + if current_time < (processed_time + delay_time) { return Err(ContractError::NotEnoughtTimeElapsed); } - if !current_height >= (processed_height + delay_block) { + if current_height < (processed_height + delay_block) { return Err(ContractError::NotEnoughtBlocksElapsed); } @@ -223,3 +223,65 @@ impl ILightClient for IconClient<'_> { }) } } + +#[cfg(test)] +mod test { + use super::*; + use cosmwasm_std::testing::{mock_dependencies, mock_env}; + use test_utils::get_test_headers; + + #[test] + fn test_validate_delay_args() { + let mut deps = mock_dependencies(); + let ctx = CwContext::new(deps.as_mut(), mock_env()); + let mut icon_client = IconClient::new(ctx); + + let height = 12_345; + let client_id = "icon_client"; + + icon_client + .context + .insert_blocknumber_at_height(client_id, height) + .unwrap(); + + icon_client + .context + .insert_timestamp_at_height(client_id, height) + .unwrap(); + + let res = icon_client + .validate_delay_args(client_id, height, 0, 0) + .unwrap(); + assert_eq!(res, ()); + + let err = icon_client + .validate_delay_args(client_id, height, 1, 0) + .unwrap_err(); + assert_eq!(err, ContractError::NotEnoughtTimeElapsed); + + let err = icon_client + .validate_delay_args(client_id, height, 0, 1) + .unwrap_err(); + assert_eq!(err, ContractError::NotEnoughtBlocksElapsed) + } + + #[test] + #[should_panic(expected = "InSuffcientQuorum")] + fn check_block_proof_with_empty_validators() { + let header = &get_test_headers()[0]; + let mut deps = mock_dependencies(); + let ctx = CwContext::new(deps.as_mut(), mock_env()); + let mut icon_client = IconClient::new(ctx); + + let client_id = "icon_client"; + let client_state = ClientState::default(); + icon_client + .context + .insert_client_state(client_id, client_state) + .unwrap(); + + icon_client + .check_block_proof(client_id, header, &Vec::new(), &Vec::new()) + .unwrap(); + } +} diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/state.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/state.rs index c0a65dd11..24c3db518 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/state.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/state.rs @@ -369,6 +369,18 @@ mod tests { assert_eq!(address, hex::encode(result.unwrap())); } + #[test] + fn test_recover_signer_for_none_value() { + let mut deps = mock_dependencies(); + let context = CwContext::new(deps.as_mut(), mock_env()); + + let msg = keccak256(b"test message"); + let signature = hex!("c8b2b5eeb7b5462ce6d3bdf1648cd8eae2"); + + let result = context.recover_signer(msg.as_slice(), &signature); + assert!(result.is_none()); + } + #[test] fn test_cwcontext_recover_signer_relay_data() { let mut deps = mock_dependencies(); @@ -491,4 +503,134 @@ mod tests { assert_eq!(mock_env().block.height, loaded); Ok(()) } + + #[test] + fn test_ensure_owner() { + let mut deps = mock_dependencies(); + let config = Config::default(); + let mut contract = CwContext::new(deps.as_mut(), mock_env()); + + contract.insert_config(&config).unwrap(); + + let res = contract.ensure_owner(Addr::unchecked("test")); + assert!(res.is_ok()) + } + + #[test] + #[should_panic(expected = "Unauthorized")] + fn test_ensure_owner_unauthorized() { + let mut deps = mock_dependencies(); + let config = Config::default(); + let mut contract = CwContext::new(deps.as_mut(), mock_env()); + + contract.insert_config(&config).unwrap(); + + contract + .ensure_owner(Addr::unchecked("regular_user")) + .unwrap() + } + + #[test] + #[should_panic(expected = "Unauthorized")] + fn test_ensure_host_unauthorized() { + let mut deps = mock_dependencies(); + let config = Config::default(); + let mut contract = CwContext::new(deps.as_mut(), mock_env()); + + contract.insert_config(&config).unwrap(); + + contract + .ensure_ibc_host(Addr::unchecked("regular_host")) + .unwrap() + } + + #[test] + fn test_get_current_block_time() { + let mut deps = mock_dependencies(); + let contract = CwContext::new(deps.as_mut(), mock_env()); + + let res = contract.get_current_block_time(); + assert_eq!(res, contract.env.block.time.nanos()); + } + + #[test] + fn test_get_current_block_height() { + let mut deps = mock_dependencies(); + let contract = CwContext::new(deps.as_mut(), mock_env()); + + let res = contract.get_current_block_height(); + assert_eq!(res, contract.env.block.height); + } + + #[test] + fn test_get_processed_time_at_height() { + let mut deps = mock_dependencies(); + let mut contract = CwContext::new(deps.as_mut(), mock_env()); + + let height = 2; + let client_id = "test_client"; + + contract + .insert_timestamp_at_height(client_id, height) + .unwrap(); + + let res = contract + .get_processed_time_at_height(client_id, height) + .unwrap(); + + assert_eq!(res, contract.env.block.time.nanos()) + } + + #[test] + #[should_panic(expected = "ProcessedTimeNotFound")] + fn fail_test_get_processed_time_at_height() { + let mut deps = mock_dependencies(); + let mut contract = CwContext::new(deps.as_mut(), mock_env()); + + let height = 2; + let client_id = "test_client"; + + contract + .insert_timestamp_at_height(client_id, height) + .unwrap(); + + contract.get_processed_time_at_height(client_id, 3).unwrap(); + } + + #[test] + fn test_get_processed_block_number_at_height() { + let mut deps = mock_dependencies(); + let mut contract = CwContext::new(deps.as_mut(), mock_env()); + + let height = 2; + let client_id = "test_client"; + + contract + .insert_blocknumber_at_height(client_id, height) + .unwrap(); + + let res = contract + .get_processed_block_at_height(client_id, height) + .unwrap(); + + assert_eq!(res, contract.env.block.height) + } + + #[test] + #[should_panic(expected = "ProcessedHeightNotFound")] + fn fail_test_get_processed_block_number_at_height() { + let mut deps = mock_dependencies(); + let mut contract = CwContext::new(deps.as_mut(), mock_env()); + + let height = 2; + let client_id = "test_client"; + + contract + .insert_blocknumber_at_height(client_id, height) + .unwrap(); + + contract + .get_processed_block_at_height(client_id, 3) + .unwrap(); + } } From 8160977dae729567121cc914a6e35afa392b20f2 Mon Sep 17 00:00:00 2001 From: DeepakBomjan <44976635+DeepakBomjan@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:06:06 +0545 Subject: [PATCH 60/64] ci: add injectived, and neutornd binary (#858) * ci: add injectived, and neutornd binary * ci: update archwayd to v6.0.0 * ci: update archwayd to v6.0.0 --- .github/deployer/init_script.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/deployer/init_script.sh b/.github/deployer/init_script.sh index 8d928dcf0..bba984229 100755 --- a/.github/deployer/init_script.sh +++ b/.github/deployer/init_script.sh @@ -11,7 +11,9 @@ KMS_ID="KMS_ID_HERE" DEPLOYR_HOME="/home/deployr" GO_VERS="1.20.6" JAVA_VERS="11.0.18_10" -ARCHWAY_VERS="0.4.0" +ARCHWAY_VERS="6.0.0" +INJECTIVE_VERS="1.12.1-1705909076" +NEUTRON_VERS="3.0.2" set -x export GOROOT=/usr/local/go @@ -54,7 +56,7 @@ export TMOUT PROMPT_COMMAND='history -a >(logger -t "[$USER] $SSH_CONNECTION")' EOF -apt-get install auditd audispd-plugins -y +apt-get install auditd audispd-plugins unzip -y systemctl enable auditd systemctl start auditd @@ -103,8 +105,22 @@ tar xf OpenJDK11U-jdk_x64_linux_hotspot_$${JAVA_VERS}.tar.gz -C /opt/java go install github.com/icon-project/goloop/cmd/goloop@latest # Install archway -wget -q https://github.com/archway-network/archway/releases/download/v$${ARCHWAY_VERS}/archway_$${ARCHWAY_VERS}_linux_amd64.tar.gz -tar xf archway_$${ARCHWAY_VERS}_linux_amd64.tar.gz -C /usr/local/bin +wget -q https://github.com/archway-network/archway/releases/download/v$${ARCHWAY_VERS}/archway_$${ARCHWAY_VERS}_linux_amd64.zip +unzip archway_$${ARCHWAY_VERS}_linux_amd64.zip +sudo archwayd /usr/local/bin + +# Install injectived +wget -q https://github.com/InjectiveLabs/injective-chain-releases/releases/download/v$${INJECTIVE_VERS}/linux-amd64.zip +unzip linux-amd64.zip +sudo cp injectived peggo /usr/bin +sudo cp libwasmvm.x86_64.so /usr/lib +sudo chmod +x /usr/bin/injectived +sudo chmod +x /usr/bin/peggo + +# Install neutron +wget -q https://github.com/neutron-org/neutron/releases/download/v$${NEUTRON_VERS}/neutrond-linux-amd64 +sudo cp neutrond-linux-amd64 /usr/local/bin/neutrond +sudo chmod +x /usr/local/bin/neutrond # Install boto3, yq, and jq apt-get install python3-pip -y From c277c320238f5955e9243d7860e382a375233a98 Mon Sep 17 00:00:00 2001 From: undefined <107839945+bishalbikram@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:24:45 +0545 Subject: [PATCH 61/64] chore: add test coverage for xcall-ibc-connection (#853) --- .../cw-xcall-ibc-connection/src/assertion.rs | 101 +++ .../cw-xcall-ibc-connection/src/fee.rs | 59 ++ .../cw-xcall-ibc-connection/tests/setup.rs | 226 ++++++- .../tests/test_admin.rs | 129 ++-- .../tests/test_call_service.rs | 35 +- .../cw-xcall-ibc-connection/tests/test_ibc.rs | 84 +++ .../tests/test_ibc_functions.rs | 589 ++++++++++-------- .../tests/test_owner.rs | 24 +- 8 files changed, 900 insertions(+), 347 deletions(-) create mode 100644 contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc.rs diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/assertion.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/assertion.rs index 809702ba0..646134e47 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/assertion.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/assertion.rs @@ -145,3 +145,104 @@ impl<'a> CwIbcConnection<'a> { Ok(()) } } + +#[cfg(test)] +mod test { + use crate::state::CwIbcConnection; + use cosmwasm_std::{ + testing::{mock_dependencies, mock_info}, + Addr, + }; + + #[test] + fn test_ensure_length() { + let contract = CwIbcConnection::new(); + + let res = contract.ensure_data_length(20 as usize); + assert!(res.is_ok()) + } + + #[test] + #[should_panic(expected = "MaxDataSizeExceeded")] + fn test_ensure_length_fail() { + let contract = CwIbcConnection::new(); + + contract.ensure_data_length(u64::MAX as usize).unwrap(); + } + + #[test] + fn test_ensure_rollback_length() { + let contract = CwIbcConnection::new(); + + let rollback_size: Vec = Vec::new(); + let res = contract.ensure_rollback_length(&rollback_size); + assert!(res.is_ok()) + } + + #[test] + #[should_panic(expected = "MaxRollbackSizeExceeded")] + fn test_ensure_rollback_length_fail() { + let contract = CwIbcConnection::new(); + + let rollback_size: Vec = vec![0; 2048]; + contract.ensure_rollback_length(&rollback_size).unwrap() + } + + #[test] + fn test_ensure_owner() { + let mut deps = mock_dependencies(); + let contract = CwIbcConnection::new(); + let info = mock_info("owner", &[]); + + contract + .add_owner(deps.as_mut().storage, Addr::unchecked("owner")) + .unwrap(); + + let res = contract.ensure_owner(deps.as_ref().storage, &info).unwrap(); + assert_eq!(res, ()) + } + + #[test] + #[should_panic(expected = "Unauthorized")] + fn test_ensure_owner_fail() { + let mut deps = mock_dependencies(); + let contract = CwIbcConnection::new(); + let info = mock_info("owner", &[]); + + contract + .add_owner(deps.as_mut().storage, Addr::unchecked("test_owner")) + .unwrap(); + + contract.ensure_owner(deps.as_ref().storage, &info).unwrap(); + } + + #[test] + #[should_panic(expected = "OnlyIbcHandler")] + fn test_ensure_xcall_handler_fail() { + let mut deps = mock_dependencies(); + let contract = CwIbcConnection::new(); + + contract + .set_xcall_host(deps.as_mut().storage, Addr::unchecked("xcall_host")) + .unwrap(); + + contract + .ensure_xcall_handler(deps.as_ref().storage, Addr::unchecked("ibc_host")) + .unwrap() + } + + #[test] + #[should_panic(expected = "OnlyIbcHandler")] + fn test_ensure_ibc_handler_fail() { + let mut deps = mock_dependencies(); + let contract = CwIbcConnection::new(); + + contract + .set_ibc_host(deps.as_mut().storage, Addr::unchecked("ibc_host")) + .unwrap(); + + contract + .ensure_ibc_handler(deps.as_ref().storage, Addr::unchecked("xcall_host")) + .unwrap() + } +} diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/fee.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/fee.rs index c61dc0786..d7cf9d6f8 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/fee.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/src/fee.rs @@ -54,3 +54,62 @@ impl<'a> CwIbcConnection<'a> { self.get_unclaimed_packet_fee(store, &nid, &address) } } + +#[cfg(test)] +mod test { + use cosmwasm_std::testing::{mock_dependencies, mock_info}; + use cosmwasm_std::Response; + use cw_xcall_lib::network_address::NetId; + + use super::CwIbcConnection; + + #[test] + #[should_panic(expected = "NoFeesAccrued")] + fn test_claim_fees_on_zero_unclaimed_fee() { + let mut deps = mock_dependencies(); + let contract = CwIbcConnection::new(); + let info = mock_info("relayer", &[]); + + let nid = NetId::from("default".to_string()); + + contract + .claim_fees(deps.as_mut(), info, nid, "relayer".to_string()) + .unwrap(); + } + + #[test] + fn test_set_fee() { + let mut deps = mock_dependencies(); + let contract = CwIbcConnection::new(); + + let nid = NetId::from("default".to_string()); + + let res = contract + .set_fee(deps.as_mut().storage, nid, 1_000, 1_000) + .unwrap(); + + assert_eq!(res, Response::new()) + } + + #[test] + fn test_reset_unclaimed_ack_fees() { + let mut deps = mock_dependencies(); + let contract = CwIbcConnection::new(); + + let nid = NetId::from("default".to_string()); + + contract + .add_unclaimed_ack_fees(deps.as_mut().storage, &nid, 1, 10) + .unwrap(); + + let ack_fee = contract.get_unclaimed_ack_fee(deps.as_ref().storage, nid.as_str(), 1); + assert_eq!(ack_fee, 10); + + contract + .reset_unclaimed_ack_fees(deps.as_mut().storage, nid.as_str(), 1) + .unwrap(); + + let ack_fee = contract.get_unclaimed_ack_fee(deps.as_ref().storage, nid.as_str(), 1); + assert_eq!(ack_fee, 0) + } +} diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/setup.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/setup.rs index fe8ca92fa..75c6c402c 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/setup.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/setup.rs @@ -1,10 +1,23 @@ +use cw_xcall_lib::network_address::NetId; +use std::str::FromStr; + use cosmwasm_std::{ coins, testing::{ mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR, }, - Addr, BlockInfo, ContractInfo, Empty, Env, MessageInfo, OwnedDeps, Timestamp, TransactionInfo, + to_binary, Addr, BlockInfo, ContractInfo, DepsMut, Empty, Env, Event, IbcChannel, IbcEndpoint, + IbcPacket, IbcTimeout, IbcTimeoutBlock, MessageInfo, OwnedDeps, Storage, SubMsgResponse, + Timestamp, TransactionInfo, +}; + +use cw_xcall_ibc_connection::{ + state::{CwIbcConnection, IbcConfig}, + types::{ + channel_config::ChannelConfig, config::Config, connection_config::ConnectionConfig, + network_fees::NetworkFees, + }, }; pub struct MockEnvBuilder { @@ -83,3 +96,214 @@ fn test() { assert_ne!(mock, mock_env_builder) } + +pub fn get_dummy_sub_msg_res() -> SubMsgResponse { + SubMsgResponse { + events: vec![Event::new("empty")], + data: Some(to_binary("data").unwrap()), + } +} + +pub fn get_dummy_endpoints() -> (IbcEndpoint, IbcEndpoint) { + let endpoint = IbcEndpoint { + port_id: "port_src".to_owned(), + channel_id: "channel_src".to_owned(), + }; + + let counterparty_endpoint = IbcEndpoint { + port_id: "port_dst".to_owned(), + channel_id: "channel_dst".to_owned(), + }; + + (endpoint, counterparty_endpoint) +} + +pub fn get_dummy_channel() -> IbcChannel { + let (endpoint, counterparty_endpoint) = get_dummy_endpoints(); + + IbcChannel::new( + endpoint, + counterparty_endpoint, + cosmwasm_std::IbcOrder::Unordered, + "ics20-1".to_owned(), + "connection_0".to_owned(), + ) +} + +pub fn get_dummy_channel_config() -> ChannelConfig { + ChannelConfig { + client_id: "default_0".to_owned(), + timeout_height: 100, + counterparty_nid: NetId::from_str("nid").unwrap(), + } +} + +pub fn get_dummy_connection_config() -> ConnectionConfig { + ConnectionConfig { + client_id: "default_0".to_owned(), + timeout_height: 100, + } +} + +pub fn get_dummy_ibc_config() -> IbcConfig { + let (src, dst) = get_dummy_endpoints(); + IbcConfig::new(src, dst) +} + +pub fn get_dummy_network_fees() -> NetworkFees { + NetworkFees { + ack_fee: 0, + send_packet_fee: 0, + } +} + +pub fn get_dummy_ibc_packet() -> IbcPacket { + let (src, dst) = get_dummy_endpoints(); + let timeout = IbcTimeout::with_block(IbcTimeoutBlock { + revision: 0, + height: 0, + }); + IbcPacket::new(to_binary(&vec![0]).unwrap(), src, dst, 0, timeout) +} + +pub struct TestContext { + pub network_id: NetId, + pub client_id: String, + pub connection_id: String, + pub info: MessageInfo, + pub channel: IbcChannel, + pub env: Env, + pub packet: Option, +} + +impl TestContext { + pub fn default() -> Self { + Self { + network_id: NetId::from_str("nid").unwrap(), + client_id: "default_0".to_owned(), + connection_id: "connection_0".to_owned(), + info: mock_info("owner", &[]), + channel: get_dummy_channel(), + env: mock_env(), + packet: None, + } + } + + pub fn for_packet_ack(packet: &IbcPacket) -> Self { + let mut ctx = TestContext::default(); + ctx.packet = Some(packet.clone()); + + ctx + } + + pub fn for_packet_timeout(packet: &IbcPacket) -> Self { + let mut ctx = TestContext::default(); + ctx.packet = Some(packet.clone()); + + ctx + } + + pub fn init_context(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + self.add_owner(storage, contract); + self.update_admin(storage, contract); + self.store_ibc_host(storage, contract); + self.store_xcall_host(storage, contract); + self.store_config(storage, contract); + self.store_connection_config(storage, contract); + self.store_channel_config(storage, contract); + self.store_network_fees(storage, contract); + self.store_ibc_config(storage, contract); + } + + pub fn init_channel_open(&self, deps: DepsMut, contract: &CwIbcConnection) { + self.init_context(deps.storage, &contract); + + self.store_counterparty_nid(deps.storage, contract); + self.configure_connection(deps, &contract); + } + + pub fn init_channel_connect(&self, deps: DepsMut, contract: &CwIbcConnection) { + self.init_context(deps.storage, &contract); + + self.store_counterparty_nid(deps.storage, contract); + self.configure_connection(deps, &contract); + } + + pub fn add_owner(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + let _res = contract + .add_owner(storage, self.info.sender.clone()) + .unwrap(); + } + + pub fn update_admin(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + let _res = contract + .update_admin(storage, self.info.sender.clone()) + .unwrap(); + } + + pub fn store_ibc_host(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + contract + .set_ibc_host(storage, Addr::unchecked("ibc_host")) + .unwrap() + } + + pub fn store_xcall_host(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + contract + .set_xcall_host(storage, Addr::unchecked("xcall_host")) + .unwrap() + } + + pub fn store_config(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + let config = Config { + port_id: "port_src".to_owned(), + denom: "arch".to_owned(), + }; + contract.store_config(storage, &config).unwrap() + } + + pub fn store_channel_config(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + contract + .store_channel_config(storage, "channel_src", &get_dummy_channel_config()) + .unwrap() + } + + pub fn store_connection_config(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + contract + .store_connection_config(storage, &self.connection_id, &get_dummy_connection_config()) + .unwrap() + } + + pub fn store_ibc_config(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + let ibc_config = get_dummy_ibc_config(); + contract + .store_ibc_config(storage, &self.network_id, &ibc_config) + .unwrap(); + } + + pub fn store_network_fees(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + contract + .store_network_fees(storage, self.network_id.clone(), &get_dummy_network_fees()) + .unwrap() + } + + pub fn store_counterparty_nid(&self, storage: &mut dyn Storage, contract: &CwIbcConnection) { + contract + .store_counterparty_nid(storage, &self.connection_id, "port_dst", &self.network_id) + .unwrap() + } + + pub fn configure_connection(&self, deps: DepsMut, contract: &CwIbcConnection) { + let config = get_dummy_connection_config(); + + contract + .configure_connection( + deps, + self.connection_id.clone(), + "port_dst".to_string(), + self.network_id.clone(), + config.client_id, + config.timeout_height, + ) + .unwrap() + } +} diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_admin.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_admin.rs index 752b429e6..6d5264d55 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_admin.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_admin.rs @@ -9,69 +9,38 @@ use setup::*; #[test] #[should_panic(expected = "OnlyAdmin")] fn update_admin_unauthorzied() { - let mut mock_deps = deps(); - - let mock_info = create_mock_info(&alice().to_string(), "umlg", 2000); - + let ctx = TestContext::default(); + let mut deps = deps(); let contract = CwIbcConnection::default(); - contract - .add_owner(mock_deps.as_mut().storage, mock_info.sender) - .unwrap(); - - contract - .update_admin( - mock_deps.as_mut().storage, - Addr::unchecked(Addr::unchecked(admin_one().to_string())), - ) - .unwrap(); - - let result = contract.query_admin(mock_deps.as_ref().storage).unwrap(); + ctx.init_context(deps.as_mut().storage, &contract); - assert_eq!(result, Addr::unchecked(admin_one().to_string())); + let result = contract.query_admin(deps.as_ref().storage).unwrap(); + assert_eq!(result, ctx.info.sender); - let mock_info = create_mock_info(&bob().to_string(), "umlg", 2000); + let info = create_mock_info(&bob().to_string(), "umlg", 2000); let execute_msg = ExecuteMsg::SetAdmin { address: admin_one().to_string(), }; - execute(mock_deps.as_mut(), mock_env(), mock_info, execute_msg).unwrap(); + execute(deps.as_mut(), mock_env(), info, execute_msg).unwrap(); } #[test] fn update_admin() { - let mut mock_deps = deps(); - - let mock_info = create_mock_info(&admin_one().to_string(), "umlg", 2000); - + let ctx = TestContext::default(); + let mut deps = deps(); let contract = CwIbcConnection::default(); - contract - .add_owner(mock_deps.as_mut().storage, mock_info.sender) - .unwrap(); - - contract - .update_admin( - mock_deps.as_mut().storage, - Addr::unchecked(admin_one().to_string()), - ) - .unwrap(); - - let result = contract.query_admin(mock_deps.as_ref().storage).unwrap(); - - assert_eq!(result, Addr::unchecked(admin_one().to_string())); - - let mock_info = create_mock_info(&admin_one().to_string(), "umlg", 2000); + ctx.init_context(deps.as_mut().storage, &contract); let execute_msg = ExecuteMsg::SetAdmin { address: admin_two().to_string(), }; + execute(deps.as_mut(), mock_env(), ctx.info, execute_msg).unwrap(); - execute(mock_deps.as_mut(), mock_env(), mock_info, execute_msg).unwrap(); - - let result = contract.query_admin(mock_deps.as_ref().storage).unwrap(); - + let result = contract.query_admin(deps.as_ref().storage).unwrap(); assert_eq!(result, admin_two().to_string()); } @@ -91,22 +60,17 @@ fn query_admin() { #[test] #[should_panic(expected = "InvalidAddress { address: \"*************\"")] fn add_invalid_char_as_admin() { - let mut mock_deps = deps(); - - let mock_info = create_mock_info(&alice().to_string(), "umlg", 2000); - let mock_env = mock_env(); - + let ctx = TestContext::default(); + let mut deps = deps(); let mut contract = CwIbcConnection::default(); - contract - .update_admin(mock_deps.as_mut().storage, mock_info.clone().sender) - .unwrap(); + ctx.init_context(deps.as_mut().storage, &contract); contract .execute( - mock_deps.as_mut(), - mock_env, - mock_info, + deps.as_mut(), + ctx.env, + ctx.info, cw_common::xcall_connection_msg::ExecuteMsg::SetAdmin { address: "*************".into(), }, @@ -119,22 +83,17 @@ fn add_invalid_char_as_admin() { expected = "Std(GenericErr { msg: \"Invalid input: human address too short for this mock implementation (must be >= 3).\" })" )] fn validate_address_add_admin_size_lessthan_3() { - let mut mock_deps = deps(); - - let mock_info = create_mock_info(&alice().to_string(), "umlg", 2000); - let mock_env = mock_env(); - + let ctx = TestContext::default(); + let mut deps = deps(); let mut contract = CwIbcConnection::default(); - contract - .update_admin(mock_deps.as_mut().storage, mock_info.clone().sender) - .unwrap(); + ctx.init_context(deps.as_mut().storage, &contract); contract .execute( - mock_deps.as_mut(), - mock_env, - mock_info, + deps.as_mut(), + ctx.env, + ctx.info, cw_common::xcall_connection_msg::ExecuteMsg::SetAdmin { address: "sm".into(), }, @@ -147,22 +106,17 @@ fn validate_address_add_admin_size_lessthan_3() { expected = "Std(GenericErr { msg: \"Invalid input: human address too long for this mock implementation (must be <= 90).\" })" )] fn validate_address_add_admin_size_more_than_45() { - let mut mock_deps = deps(); - - let mock_info = create_mock_info(&alice().to_string(), "umlg", 2000); - let mock_env = mock_env(); - + let ctx = TestContext::default(); + let mut deps = deps(); let mut contract = CwIbcConnection::default(); - contract - .update_admin(mock_deps.as_mut().storage, mock_info.clone().sender) - .unwrap(); + ctx.init_context(deps.as_mut().storage, &contract); contract .execute( - mock_deps.as_mut(), - mock_env, - mock_info, + deps.as_mut(), + ctx.env, + ctx.info, cw_common::xcall_connection_msg::ExecuteMsg::SetAdmin { address: "eddiuo6lbp05golmz3rb5n7hbi4c5hhyh0rb1w6cslyjt5mhwd0chn3x254lyorpx4dzvrvsc9h2em44be2rj193dwe".into(), }, @@ -173,30 +127,17 @@ fn validate_address_add_admin_size_more_than_45() { #[test] #[should_panic(expected = "InvalidAddress { address: \"new_addmin!@234\" }")] fn update_admin_fails() { - let mut mock_deps = deps(); - - let mock_info = create_mock_info(&admin_one().to_string(), "umlg", 2000); - + let ctx = TestContext::default(); + let mut deps = deps(); let contract = CwIbcConnection::default(); - contract - .update_admin( - mock_deps.as_mut().storage, - Addr::unchecked(admin_one().to_string()), - ) - .unwrap(); - - let result = contract.query_admin(mock_deps.as_ref().storage).unwrap(); - - assert_eq!(result, Addr::unchecked(admin_one().to_string())); + ctx.init_context(deps.as_mut().storage, &contract); let execute_msg = ExecuteMsg::SetAdmin { address: "new_addmin!@234".into(), }; + execute(deps.as_mut(), mock_env(), ctx.info, execute_msg).unwrap(); - execute(mock_deps.as_mut(), mock_env(), mock_info, execute_msg).unwrap(); - - let result = contract.query_admin(mock_deps.as_ref().storage).unwrap(); - + let result = contract.query_admin(deps.as_ref().storage).unwrap(); assert_eq!(result, admin_two().to_string()); } diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_call_service.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_call_service.rs index 2a72ef4ed..fe520ccb1 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_call_service.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_call_service.rs @@ -2,14 +2,19 @@ mod account; mod setup; use cosmwasm_std::{ testing::{mock_env, MOCK_CONTRACT_ADDR}, - Addr, + Addr, Reply, SubMsgResult, }; -use cw_xcall_ibc_connection::{instantiate, msg::InstantiateMsg, state::CwIbcConnection}; +use cw_xcall_ibc_connection::{ + instantiate, migrate, + msg::InstantiateMsg, + reply, + state::{CwIbcConnection, XCALL_HANDLE_ERROR_REPLY_ID}, + MigrateMsg, +}; use setup::*; #[test] - fn proper_instantiate() { let mut mock_deps = deps(); let mock_info = create_mock_info(MOCK_CONTRACT_ADDR, "umlg", 2000); @@ -35,3 +40,27 @@ fn proper_instantiate() { assert_eq!(MOCK_CONTRACT_ADDR, owner) } + +#[test] +fn test_reply() { + let ctx = TestContext::default(); + let mut deps = deps(); + + let sub_msg_res = get_dummy_sub_msg_res(); + let msg = Reply { + id: XCALL_HANDLE_ERROR_REPLY_ID, + result: SubMsgResult::Ok(sub_msg_res), + }; + + let res = reply(deps.as_mut(), ctx.env, msg); + assert!(res.is_ok()) +} + +#[test] +fn test_migrate() { + let ctx = TestContext::default(); + let mut deps = deps(); + + let res = migrate(deps.as_mut(), ctx.env, MigrateMsg {}).unwrap(); + assert_eq!(res.attributes[0].value, "successful") +} diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc.rs new file mode 100644 index 000000000..748e4101f --- /dev/null +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc.rs @@ -0,0 +1,84 @@ +pub mod setup; + +use cosmwasm_std::{ + to_binary, Addr, Binary, Ibc3ChannelOpenResponse, IbcAcknowledgement, IbcChannelCloseMsg, + IbcChannelConnectMsg, IbcChannelOpenMsg, IbcPacketAckMsg, +}; + +use cw_common::types::Ack; +use cw_xcall_ibc_connection::ibc::*; +use cw_xcall_ibc_connection::state::CwIbcConnection; + +use setup::*; + +#[test] +fn test_ibc_channel_open() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::default(); + + ctx.init_channel_open(deps.as_mut(), &contract); + + let msg = IbcChannelOpenMsg::OpenInit { + channel: ctx.channel, + }; + let res = ibc_channel_open(deps.as_mut(), ctx.env, msg).unwrap(); + let expected_res = Some(Ibc3ChannelOpenResponse { + version: IBC_VERSION.to_string(), + }); + + assert_eq!(res, expected_res); +} + +#[test] +fn test_ibc_channel_connect() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::default(); + + ctx.init_channel_connect(deps.as_mut(), &contract); + + let msg = IbcChannelConnectMsg::OpenAck { + channel: ctx.channel, + counterparty_version: IBC_VERSION.to_string(), + }; + let res = ibc_channel_connect(deps.as_mut(), ctx.env, msg).unwrap(); + assert_eq!(res.attributes[0].value, "on_channel_connect"); +} + +#[test] +fn test_channel_close_confirm() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::default(); + + ctx.init_context(deps.as_mut().storage, &contract); + + let msg = IbcChannelCloseMsg::CloseConfirm { + channel: ctx.channel, + }; + let res = ibc_channel_close(deps.as_mut(), ctx.env, msg).unwrap(); + assert_eq!(res.attributes[0].value, "ibc_channel_close") +} + +#[test] +fn test_ibc_packet_ack() { + let packet = get_dummy_ibc_packet(); + let ctx = TestContext::for_packet_ack(&packet); + + let mut deps = deps(); + let contract = CwIbcConnection::default(); + + ctx.init_context(deps.as_mut().storage, &contract); + + let ack = IbcAcknowledgement::new( + to_binary(&Ack::Result( + Binary::from_base64("aGVsbG8gd29ybGQ=").unwrap(), + )) + .unwrap(), + ); + + let msg = IbcPacketAckMsg::new(ack, packet, Addr::unchecked("relayer")); + let res = ibc_packet_ack(deps.as_mut(), ctx.env, msg); + assert!(res.is_ok()); +} diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc_functions.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc_functions.rs index 7f6ac411e..6737d275e 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc_functions.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_ibc_functions.rs @@ -10,7 +10,7 @@ use cosmwasm_std::{ use cw_common::from_binary_response; use cw_common::types::Ack; -use cw_xcall_ibc_connection::ack::{on_ack_failure, on_ack_success}; +use cw_xcall_ibc_connection::ack::{make_ack_success, on_ack_failure, on_ack_success}; use cw_xcall_ibc_connection::types::config::Config; use cw_xcall_lib::network_address::{NetId, NetworkAddress}; @@ -24,192 +24,196 @@ pub mod account; use account::admin_one; use account::alice; -use cosmwasm_std::from_binary; +use cosmwasm_std::{from_binary, IbcChannelCloseMsg, IbcPacketTimeoutMsg, Reply, SubMsgResult}; use cw_common::xcall_connection_msg::{ExecuteMsg, QueryMsg}; use cw_xcall::types::message::CSMessage; use cw_xcall::types::request::CSMessageRequest; -use cw_xcall_ibc_connection::state::CwIbcConnection; +use cw_xcall_ibc_connection::state::{ + CwIbcConnection, ACK_FAILURE_ID, HOST_SEND_MESSAGE_REPLY_ID, + HOST_WRITE_ACKNOWLEDGEMENT_REPLY_ID, XCALL_HANDLE_ERROR_REPLY_ID, + XCALL_HANDLE_MESSAGE_REPLY_ID, +}; + +use cosmwasm_std::IbcOrder; #[test] #[cfg(not(feature = "native_ibc"))] #[should_panic(expected = "OrderedChannel")] fn fails_on_open_channel_open_init_ordered_channel() { + let ctx = TestContext::default(); let mut deps = deps(); - - let mock_env = mock_env(); - let mock_info = create_mock_info("alice", "umlg", 2000); - let mut contract = CwIbcConnection::default(); + let info = create_mock_info("ibc_host", "umlg", 2000); - let src = IbcEndpoint { - port_id: "our-port".to_string(), - channel_id: "channel-1".to_string(), - }; - let dst = IbcEndpoint { - port_id: "their-port".to_string(), - channel_id: "channel-3".to_string(), - }; + ctx.init_context(deps.as_mut().storage, &contract); + + let mut channel = get_dummy_channel(); + channel.order = IbcOrder::Ordered; let execute_msg = ExecuteMsg::IbcChannelOpen { - msg: OpenInit { - channel: IbcChannel::new( - src, - dst, - cosmwasm_std::IbcOrder::Ordered, - "xcall-1", - "newconnection", - ), - }, + msg: OpenInit { channel }, }; contract - .set_ibc_host(deps.as_mut().storage, Addr::unchecked(alice().as_str())) - .unwrap(); - - contract - .execute(deps.as_mut(), mock_env, mock_info, execute_msg) + .execute(deps.as_mut(), ctx.env, info, execute_msg) .unwrap(); } #[test] #[cfg(not(feature = "native_ibc"))] fn success_on_open_channel_open_init_unordered_channel() { - use cw_xcall_ibc_connection::{state::CwIbcConnection, types::config::Config}; - + let ctx = TestContext::default(); let mut deps = deps(); - - let mock_env = mock_env(); - let mock_info = create_mock_info("alice", "umlg", 2000); - let mut contract = CwIbcConnection::default(); + let info = create_mock_info("ibc_host", "umlg", 2000); - let src = IbcEndpoint { - port_id: "our-port".to_string(), - channel_id: "channel-1".to_string(), - }; - let dst = IbcEndpoint { - port_id: "their-port".to_string(), - channel_id: "channel-3".to_string(), - }; - - contract - .store_config( - deps.as_mut().storage, - &Config { - port_id: "our-port".to_string(), - denom: "arch".to_string(), - }, - ) - .unwrap(); - - let connection_id = "newconnection".to_string(); + ctx.init_channel_open(deps.as_mut(), &contract); let execute_msg = ExecuteMsg::IbcChannelOpen { msg: OpenInit { - channel: IbcChannel::new( - src, - dst.clone(), - cosmwasm_std::IbcOrder::Unordered, - "ics20-1", - &connection_id, - ), + channel: ctx.channel, }, }; - - contract - .configure_connection( - deps.as_mut(), - connection_id, - dst.port_id, - NetId::from("nid".to_string()), - "client-id".to_string(), - 100, - ) - .unwrap(); - contract - .set_ibc_host(deps.as_mut().storage, Addr::unchecked(alice().as_str())) - .unwrap(); - - let result = contract.execute(deps.as_mut(), mock_env, mock_info, execute_msg); - println!("{:?}", result); - + let result = contract.execute(deps.as_mut(), ctx.env, info, execute_msg); assert!(result.is_ok()) } #[test] #[cfg(not(feature = "native_ibc"))] -fn get_ibc_config_after_setup() { - use cw_common::xcall_connection_msg::ConfigResponse; - use cw_xcall_ibc_connection::{state::CwIbcConnection, types::config::Config}; +fn test_query_get_ibc_config() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::default(); + + ctx.init_context(deps.as_mut().storage, &contract); + + let query = QueryMsg::GetIbcConfig { + nid: ctx.network_id.clone(), + }; + let response = contract.query(deps.as_ref(), ctx.env, query); + assert!(response.is_ok()); + let ibc_config = contract + .get_ibc_config(deps.as_ref().storage, &ctx.network_id) + .unwrap(); + assert_eq!(ibc_config.sequence(), 0); + assert_eq!(ibc_config.next_sequence(), Some(1)) +} + +#[test] +fn test_execute_set_xcall_host() { + let ctx = TestContext::default(); let mut deps = deps(); + let contract = CwIbcConnection::default(); - let mock_env = mock_env(); - let mock_info = create_mock_info("alice", "umlg", 2000); + ctx.init_context(deps.as_mut().storage, &contract); + + let address = "xcall".to_string(); + let msg = ExecuteMsg::SetXCallHost { + address: address.clone(), + }; + let res = execute(deps.as_mut(), ctx.env, ctx.info, msg); + assert!(res.is_ok()); + let xcall_host = contract.get_xcall_host(deps.as_ref().storage).unwrap(); + assert_eq!(xcall_host.to_string(), address) +} + +#[test] +fn test_execute_configure_connection() { + let ctx = TestContext::default(); + let mut deps = deps(); let mut contract = CwIbcConnection::default(); - let src = IbcEndpoint { - port_id: "our-port".to_string(), - channel_id: "channel-1".to_string(), + ctx.init_context(deps.as_mut().storage, &contract); + + let msg = ExecuteMsg::ConfigureConnection { + connection_id: ctx.connection_id, + counterparty_port_id: "port_dst".to_owned(), + counterparty_nid: ctx.network_id, + client_id: ctx.client_id, + timeout_height: 100, }; - let dst = IbcEndpoint { - port_id: "their-port".to_string(), - channel_id: "channel-3".to_string(), + let res = contract.execute(deps.as_mut(), ctx.env, ctx.info, msg); + assert!(res.is_ok()) +} + +#[test] +fn test_execute_override_connection() { + let ctx = TestContext::default(); + let mut deps = deps(); + let mut contract = CwIbcConnection::default(); + + ctx.init_channel_open(deps.as_mut(), &contract); + + let msg = ExecuteMsg::OverrideConnection { + connection_id: ctx.connection_id.clone(), + counterparty_port_id: "counterparty_port".to_owned(), + counterparty_nid: NetId::from_str("new_nid").unwrap(), + client_id: ctx.client_id, + timeout_height: 200, }; + let res = contract.execute(deps.as_mut(), ctx.env, ctx.info, msg); + assert!(res.is_ok()); - contract - .store_config( - deps.as_mut().storage, - &Config { - port_id: "our-port".to_string(), - denom: "arch".to_string(), - }, + let counterparty_nid = contract + .get_counterparty_nid( + deps.as_ref().storage, + &ctx.connection_id, + "counterparty_port", ) .unwrap(); + assert_eq!(counterparty_nid.as_str(), "new_nid") +} - let connection_id = "newconnection".to_string(); +#[test] +fn test_execute_set_fee() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::default(); - let execute_msg = ExecuteMsg::IbcChannelOpen { - msg: OpenInit { - channel: IbcChannel::new( - src.clone(), - dst.clone(), - cosmwasm_std::IbcOrder::Unordered, - "ics20-1", - &connection_id, - ), - }, + ctx.init_channel_open(deps.as_mut(), &contract); + + let msg = ExecuteMsg::SetFees { + nid: ctx.network_id, + packet_fee: 10, + ack_fee: 10, }; + let res = execute(deps.as_mut(), ctx.env, ctx.info, msg); + assert!(res.is_ok()) +} - contract - .configure_connection( - deps.as_mut(), - connection_id, - dst.port_id.clone(), - NetId::from("nid".to_string()), - "client-id".to_string(), - 100, - ) - .unwrap(); - contract - .set_ibc_host(deps.as_mut().storage, Addr::unchecked(alice().as_str())) - .unwrap(); +#[test] +fn test_query_get_fee() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::default(); - let result = contract.execute(deps.as_mut(), mock_env.clone(), mock_info, execute_msg); + ctx.init_channel_open(deps.as_mut(), &contract); - assert!(result.is_ok()); + let msg = QueryMsg::GetFee { + nid: ctx.network_id, + response: true, + }; + let res = query(deps.as_ref(), ctx.env, msg).unwrap(); + let fee: u128 = from_binary(&res).unwrap(); + assert_eq!(fee, 0) +} - let query = QueryMsg::GetIbcConfig { - nid: NetId::from("nid".to_string()), - }; - let response = contract.query(deps.as_ref(), mock_env, query); - let config: ConfigResponse = from_binary(&response.unwrap()).unwrap(); - assert_eq!(config.channel_id, src.channel_id); - assert_eq!(config.port, src.port_id); - assert_eq!(config.destination_channel_id, dst.channel_id); - assert_eq!(config.destination_port_id, dst.port_id); - assert_eq!(config.light_client_id, "client-id"); - assert_eq!(config.timeout_height, 100); +#[test] +fn test_query_get_unclaimed_fee() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::default(); + + ctx.init_channel_open(deps.as_mut(), &contract); + + let msg = QueryMsg::GetUnclaimedFee { + nid: ctx.network_id, + relayer: "crly".to_owned(), + }; + let res = query(deps.as_ref(), ctx.env, msg).unwrap(); + let fee: u128 = from_binary(&res).unwrap(); + assert_eq!(fee, 0) } #[test] @@ -282,71 +286,47 @@ fn success_on_open_channel_open_try_valid_version() { #[test] #[cfg(not(feature = "native_ibc"))] fn success_on_ibc_channel_connect() { - use std::str::FromStr; - - use cw_xcall_lib::network_address::NetId; - + let ctx = TestContext::default(); let mut deps = deps(); + let mut contract = CwIbcConnection::default(); + let info = create_mock_info("ibc_host", "umlg", 2000); - let mock_env = mock_env(); - let mock_info = create_mock_info("alice", "umlg", 2000); + ctx.init_channel_connect(deps.as_mut(), &contract); - let mut contract = CwIbcConnection::default(); - let src = IbcEndpoint { - port_id: "our-port".to_string(), - channel_id: "channel-1".to_string(), - }; - let dst = IbcEndpoint { - port_id: "their-port".to_string(), - channel_id: "channel-3".to_string(), - }; - let connection_id = "newconnection"; - let execute_message = ExecuteMsg::IbcChannelConnect { + let msg = ExecuteMsg::IbcChannelConnect { msg: OpenAck { - channel: IbcChannel::new( - src.clone(), - dst.clone(), - cosmwasm_std::IbcOrder::Unordered, - "ics20-1", - connection_id, - ), + channel: ctx.channel.clone(), counterparty_version: "ics20-1".to_owned(), }, }; - contract - .set_ibc_host(deps.as_mut().storage, Addr::unchecked(alice().as_str())) - .unwrap(); - contract - .store_config( - deps.as_mut().storage, - &Config { - port_id: "our-port".to_string(), - denom: "arch".to_string(), - }, - ) - .unwrap(); - contract - .configure_connection( - deps.as_mut(), - "newconnection".to_string(), - dst.port_id, - NetId::from("btp".to_string()), - "client-id".to_string(), - 100, - ) - .unwrap(); - - let result = contract - .execute(deps.as_mut(), mock_env, mock_info, execute_message) - .unwrap(); - assert_eq!("on_channel_connect", result.attributes[0].value); + let res = contract.execute(deps.as_mut(), ctx.env, info, msg).unwrap(); + assert_eq!("on_channel_connect", res.attributes[0].value); let ibc_config = contract - .get_ibc_config(deps.as_ref().storage, &NetId::from_str("btp").unwrap()) + .get_ibc_config(deps.as_ref().storage, &ctx.network_id) .unwrap(); + assert_eq!( + ibc_config.src_endpoint().port_id, + ctx.channel.endpoint.port_id.as_str() + ) +} - assert_eq!(ibc_config.src_endpoint().port_id, src.port_id.as_str()) +#[test] +fn test_execute_channel_close_init() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::default(); + + ctx.init_context(deps.as_mut().storage, &contract); + + let msg = ExecuteMsg::IbcChannelClose { + msg: IbcChannelCloseMsg::CloseInit { + channel: ctx.channel, + }, + }; + let res = execute(deps.as_mut(), ctx.env, ctx.info, msg).unwrap(); + assert_eq!(res.attributes[0].value, "ibc_channel_close") } #[test] @@ -691,14 +671,16 @@ fn success_receive_packet_for_call_message_request() { #[test] #[cfg(not(feature = "native_ibc"))] -fn _on_ack_packet() { - use cw_xcall_lib::network_address::{NetId, NetworkAddress}; - - let mut mock_deps = deps(); - let mock_info = create_mock_info("alice", "umlg", 2000); - let mock_env = mock_env(); +fn on_ack_packet() { + let packet = get_dummy_ibc_packet(); + let ctx = TestContext::for_packet_ack(&packet); + let mut deps = deps(); + let info = create_mock_info("ibc_host", "umlg", 2000); let mut contract = CwIbcConnection::default(); + + ctx.init_context(deps.as_mut().storage, &contract); + let ack = IbcAcknowledgement::new( to_binary(&Ack::Result( Binary::from_base64("aGVsbG8gd29ybGQ=").unwrap(), @@ -706,57 +688,10 @@ fn _on_ack_packet() { .unwrap(), ); - let timeout_block = IbcTimeoutBlock { - revision: 0, - height: 0, - }; - let timeout = IbcTimeout::with_block(timeout_block); - let src = IbcEndpoint { - port_id: "our-port".to_string(), - channel_id: "channel-1".to_string(), - }; - - let dst = IbcEndpoint { - port_id: "their-port".to_string(), - channel_id: "channel-3".to_string(), - }; - - let data = CSMessageRequest::new( - NetworkAddress::new("nid", mock_info.sender.as_str()), - Addr::unchecked("alice"), - 1, - false, - vec![1, 2, 3], - vec![], - ); - contract - .set_ibc_host( - mock_deps.as_mut().storage, - Addr::unchecked(alice().as_str()), - ) - .unwrap(); - let channel = src.channel_id.clone(); - contract - .set_xcall_host(mock_deps.as_mut().storage, Addr::unchecked("xcall-host")) - .unwrap(); - - let channel_config = ChannelConfig { - client_id: "client_id".to_string(), - timeout_height: 100, - counterparty_nid: NetId::from("nid".to_string()), - }; - contract - .store_channel_config(mock_deps.as_mut().storage, &channel, &channel_config) - .unwrap(); - let message: CSMessage = data.try_into().unwrap(); - - let packet = IbcPacket::new(to_binary(&message).unwrap(), src, dst, 0, timeout); - let ack_packet = IbcPacketAckMsg::new(ack, packet, Addr::unchecked("relayer")); - let execute_message = ExecuteMsg::IbcPacketAck { msg: ack_packet }; - - let result = contract.execute(mock_deps.as_mut(), mock_env, mock_info, execute_message); + let msg = ExecuteMsg::IbcPacketAck { msg: ack_packet }; + let result = contract.execute(deps.as_mut(), ctx.env, info, msg); assert!(result.is_ok()); } @@ -1263,3 +1198,171 @@ fn test_call_message_from_raw_message() { ); assert_eq!(expected_data, cs_message_request) } + +#[test] +fn test_make_ack_success() { + let res = make_ack_success(); + + let res_bytes: Vec = res.into(); + let res_str = String::from_utf8(res_bytes).unwrap(); + + assert_eq!(res_str, "{\"result\":\"MQ==\"}") +} + +#[test] +#[should_panic(expected = "ReplyError { code: 1, msg: \"Unknown\" }")] +fn test_xcall_handle_message_reply_fail() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let msg = Reply { + id: XCALL_HANDLE_MESSAGE_REPLY_ID, + result: SubMsgResult::Err("Unknown".to_string()), + }; + + contract.reply(deps.as_mut(), ctx.env, msg).unwrap(); +} + +#[test] +fn test_xcall_handle_error_reply() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let sub_msg_reply = get_dummy_sub_msg_res(); + let msg = Reply { + id: XCALL_HANDLE_ERROR_REPLY_ID, + result: SubMsgResult::Ok(sub_msg_reply), + }; + + let res = contract.reply(deps.as_mut(), ctx.env, msg).unwrap(); + assert_eq!(res.attributes[0].value, "call_message"); + assert_eq!(res.attributes[1].value, "xcall_handle_error_reply") +} + +#[test] +#[should_panic(expected = "ReplyError { code: 2, msg: \"Unknown\" }")] +fn test_xcall_handle_error_reply_fail() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let msg = Reply { + id: XCALL_HANDLE_ERROR_REPLY_ID, + result: SubMsgResult::Err("Unknown".to_string()), + }; + + contract.reply(deps.as_mut(), ctx.env, msg).unwrap(); +} + +#[test] +fn test_host_send_message_reply() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let sub_msg_reply = get_dummy_sub_msg_res(); + let msg = Reply { + id: HOST_SEND_MESSAGE_REPLY_ID, + result: SubMsgResult::Ok(sub_msg_reply), + }; + + let res = contract.reply(deps.as_mut(), ctx.env, msg).unwrap(); + assert_eq!(res.attributes[0].value, "call_message"); + assert_eq!(res.attributes[1].value, "reply_forward_host") +} + +#[test] +#[should_panic(expected = "ReplyError { code: 4, msg: \"Unknown\" }")] +fn test_host_send_message_reply_fail() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let msg = Reply { + id: HOST_SEND_MESSAGE_REPLY_ID, + result: SubMsgResult::Err("Unknown".to_string()), + }; + + contract.reply(deps.as_mut(), ctx.env, msg).unwrap(); +} + +#[test] +fn test_host_write_acknowledgement_reply() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let sub_msg_reply = get_dummy_sub_msg_res(); + let msg = Reply { + id: HOST_WRITE_ACKNOWLEDGEMENT_REPLY_ID, + result: SubMsgResult::Ok(sub_msg_reply), + }; + + let res = contract.reply(deps.as_mut(), ctx.env, msg).unwrap(); + assert_eq!(res.attributes[0].value, "call_message"); + assert_eq!(res.attributes[1].value, "reply_write_acknowledgement") +} + +#[test] +#[should_panic(expected = "ReplyError { code: 3, msg: \"Unknown\" }")] +fn test_host_write_acknowledgement_reply_fail() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let msg = Reply { + id: HOST_WRITE_ACKNOWLEDGEMENT_REPLY_ID, + result: SubMsgResult::Err("Unknown".to_string()), + }; + + contract.reply(deps.as_mut(), ctx.env, msg).unwrap(); +} + +#[test] +fn test_reply_ack_on_error() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let sub_msg_reply = get_dummy_sub_msg_res(); + let msg = Reply { + id: ACK_FAILURE_ID, + result: SubMsgResult::Ok(sub_msg_reply), + }; + + let res = contract.reply(deps.as_mut(), ctx.env, msg); + assert!(res.is_ok()) +} + +#[test] +fn test_reply_ack_on_error_fail() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let msg = Reply { + id: ACK_FAILURE_ID, + result: SubMsgResult::Err("Unknown".to_string()), + }; + + let res = contract.reply(deps.as_mut(), ctx.env, msg); + assert!(res.is_ok()) +} + +#[test] +#[should_panic(expected = "ReplyError { code: 9, msg: \"Unknown\" }")] +fn test_reply_fail_for_invalid_id() { + let ctx = TestContext::default(); + let mut deps = deps(); + let contract = CwIbcConnection::new(); + + let invalid_reply_id = 9; + let msg = Reply { + id: invalid_reply_id, + result: SubMsgResult::Err("Unknown".to_string()), + }; + + contract.reply(deps.as_mut(), ctx.env, msg).unwrap(); +} diff --git a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_owner.rs b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_owner.rs index 2d4bb0257..005ad0b03 100644 --- a/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_owner.rs +++ b/contracts/cosmwasm-vm/cw-xcall-ibc-connection/tests/test_owner.rs @@ -2,14 +2,13 @@ mod account; mod setup; use account::*; +use cosmwasm_std::Addr; use cw_xcall_ibc_connection::state::CwIbcConnection; use setup::*; #[test] fn add_owner() { let mut mock_deps = deps(); - let mock_info = create_mock_info(&alice().to_string(), "umlg", 2000); - let contract = CwIbcConnection::default(); contract @@ -17,17 +16,31 @@ fn add_owner() { .unwrap(); let result = contract.query_owner(mock_deps.as_ref().storage).unwrap(); - assert_eq!(result, mock_info.sender.to_string()) } +#[test] +fn test_add_owner() { + let mut deps = deps(); + let contract = CwIbcConnection::default(); + + contract + .add_owner(deps.as_mut().storage, Addr::unchecked("owner")) + .unwrap(); + + let owner = Addr::unchecked("new_owner"); + let res = contract.add_owner(deps.as_mut().storage, owner.clone()); + assert!(res.is_ok()); + + let expected_owner = contract.query_owner(deps.as_ref().storage).unwrap(); + assert_eq!(owner, expected_owner) +} + #[test] #[should_panic(expected = "OwnerAlreadyExist")] fn add_existing_owner() { let mut mock_deps = deps(); - let mock_info = create_mock_info(&alice().to_string(), "umlg", 2000); - let contract = CwIbcConnection::default(); contract @@ -35,7 +48,6 @@ fn add_existing_owner() { .unwrap(); let result = contract.query_owner(mock_deps.as_ref().storage).unwrap(); - assert_eq!(result, mock_info.sender.to_string()); contract From 32c11d034721f382527023db1a91ac376724f727 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 9 May 2024 13:29:38 +0545 Subject: [PATCH 62/64] fix: fix test --- contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs index 13473739c..d12b8c7d9 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs @@ -540,7 +540,7 @@ mod tests { contract.insert_config(&config).unwrap(); contract - .ensure_ibc_host(Addr::unchecked("regular_host")) + .ensure_ibc_host(&Addr::unchecked("regular_host")) .unwrap() } From 5db2ee94f9404215a5c5845d17aa0fbb10814e6d Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 9 May 2024 14:19:29 +0545 Subject: [PATCH 63/64] fix: resolve test issues --- .../cw-icon-light-client/src/context.rs | 3 + .../cw-icon-light-client/src/contract.rs | 2 +- .../src/light_client.rs | 61 ------------------- .../tests/test_instantiate.rs | 2 +- 4 files changed, 5 insertions(+), 63 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs index d12b8c7d9..d1fa463c2 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs @@ -189,6 +189,7 @@ mod tests { use cw_common::raw_types::Any; use hex_literal::hex; use prost::Message; + use test_utils::get_test_headers; use test_utils::get_test_signed_headers; @@ -633,4 +634,6 @@ mod tests { .get_processed_block_at_height(client_id, 3) .unwrap(); } + + } diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs index 87422f324..845d87a21 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/contract.rs @@ -952,7 +952,7 @@ mod tests { } #[test] - #[should_panic(expected = "Std(NotFound { kind: \"alloc::vec::Vec")] + #[should_panic(expected = "ClientStateNotFound(\"another_client\")")] fn test_query_latest_consensus_state_fail() { let start_header = &get_test_headers()[0]; let client_id = "test_client".to_string(); diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index 8e780c030..43ae4d250 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -237,64 +237,3 @@ impl ILightClient for IconClient { } } -#[cfg(test)] -mod test { - use super::*; - use cosmwasm_std::testing::{mock_dependencies, mock_env}; - use test_utils::get_test_headers; - - #[test] - fn test_validate_delay_args() { - let mut deps = mock_dependencies(); - let ctx = CwContext::new(deps.as_mut(), mock_env()); - let mut icon_client = IconClient::new(ctx); - - let height = 12_345; - let client_id = "icon_client"; - - icon_client - .context - .insert_blocknumber_at_height(client_id, height) - .unwrap(); - - icon_client - .context - .insert_timestamp_at_height(client_id, height) - .unwrap(); - - let res = icon_client - .validate_delay_args(client_id, height, 0, 0) - .unwrap(); - assert_eq!(res, ()); - - let err = icon_client - .validate_delay_args(client_id, height, 1, 0) - .unwrap_err(); - assert_eq!(err, ContractError::NotEnoughtTimeElapsed); - - let err = icon_client - .validate_delay_args(client_id, height, 0, 1) - .unwrap_err(); - assert_eq!(err, ContractError::NotEnoughtBlocksElapsed) - } - - #[test] - #[should_panic(expected = "InSuffcientQuorum")] - fn check_block_proof_with_empty_validators() { - let header = &get_test_headers()[0]; - let mut deps = mock_dependencies(); - let ctx = CwContext::new(deps.as_mut(), mock_env()); - let mut icon_client = IconClient::new(ctx); - - let client_id = "icon_client"; - let client_state = ClientState::default(); - icon_client - .context - .insert_client_state(client_id, client_state) - .unwrap(); - - icon_client - .check_block_proof(client_id, header, &Vec::new(), &Vec::new()) - .unwrap(); - } -} diff --git a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs index de38a9626..8c2db05c2 100644 --- a/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs +++ b/contracts/cosmwasm-vm/cw-wasm-light-client/tests/test_instantiate.rs @@ -24,7 +24,7 @@ pub fn instantiate_success() { } #[test] -#[should_panic(expected = "ClientStateNotFound(\"08-wasm-0\")")] +#[should_panic(expected = " ClientStateNotFound(\"08-iconwasm-0\")")] pub fn instantiate_fails_on_uninitialized_storage() { let mut deps = mock_dependencies(); let env = mock_env(); From 25ee4a98b81ad2707d46e12a2c29be371e24e223 Mon Sep 17 00:00:00 2001 From: ibrizsabin Date: Thu, 9 May 2024 15:04:34 +0545 Subject: [PATCH 64/64] fix: cargo fmt --- contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs | 2 -- .../cosmwasm-vm/cw-light-client-common/src/light_client.rs | 1 - 2 files changed, 3 deletions(-) diff --git a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs index d1fa463c2..a6100b4e9 100644 --- a/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs +++ b/contracts/cosmwasm-vm/cw-icon-light-client/src/context.rs @@ -634,6 +634,4 @@ mod tests { .get_processed_block_at_height(client_id, 3) .unwrap(); } - - } diff --git a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs index 43ae4d250..12b6ae694 100644 --- a/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs +++ b/contracts/cosmwasm-vm/cw-light-client-common/src/light_client.rs @@ -236,4 +236,3 @@ impl ILightClient for IconClient { Ok(()) } } -