diff --git a/.changelog/unreleased/improvements/850-fix-wasm-compilation-error-with-floats.md b/.changelog/unreleased/improvements/850-fix-wasm-compilation-error-with-floats.md new file mode 100644 index 000000000..ca866767a --- /dev/null +++ b/.changelog/unreleased/improvements/850-fix-wasm-compilation-error-with-floats.md @@ -0,0 +1,4 @@ +- Fix compilation issue with Wasm envs because of floats + - Use `serde-json-wasm` dependency instead of `serde-json` for no-floats support + - Add CI test to include CosmWasm compilation check +([/#850](https://github.com/cosmos/ibc-rs/issues/850)) diff --git a/.github/workflows/cw-check.yaml b/.github/workflows/cw-check.yaml new file mode 100644 index 000000000..e06e19251 --- /dev/null +++ b/.github/workflows/cw-check.yaml @@ -0,0 +1,38 @@ +name: CosmWasm Compilation Check +on: + pull_request: + paths: + - .github/workflows/cw-check.yml + - ci/cw-check/** + +on: + push: + tags: + - v[0-9]+.* + branches: + - 'release/*' + - main + paths: + - .github/workflows/cw-check.yml + - Cargo.toml + - Cargo.lock + - ci/cw-check/** + - crates/** + +jobs: + cw-check: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + experimental-features = nix-command flakes + + - name: Run cw-check + run: | + cd ci/cw-check + nix-shell --run "cw-check" \ No newline at end of file diff --git a/.github/workflows/no-std.yaml b/.github/workflows/no-std.yaml index f2e0c3407..47a2005a3 100644 --- a/.github/workflows/no-std.yaml +++ b/.github/workflows/no-std.yaml @@ -5,7 +5,7 @@ on: - .github/workflows/no-std.yml - Cargo.toml - Cargo.lock - - ci/** + - ci/no-std-check/** - crates/** push: branches: main @@ -13,7 +13,7 @@ on: - .github/workflows/no-std.yml - Cargo.toml - Cargo.lock - - ci/** + - ci/no-std-check/** - crates/** jobs: diff --git a/Cargo.toml b/Cargo.toml index d1fa2ad83..5d7413065 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,5 +9,6 @@ members = [ ] exclude = [ + "ci/cw-check", "ci/no-std-check", ] diff --git a/ci/cw-check/Cargo.lock b/ci/cw-check/Cargo.lock new file mode 100644 index 000000000..b72af99c7 --- /dev/null +++ b/ci/cw-check/Cargo.lock @@ -0,0 +1,1456 @@ +# 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 = "anyhow" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" + +[[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 = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[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.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "845141a4fade3f790628b7daaaa298a25b204fb28907eb54febe5142db6ce653" + +[[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.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +dependencies = [ + "serde", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" + +[[package]] +name = "cosmwasm-crypto" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e272708a9745dad8b591ef8a718571512130f2b39b33e3d7a27c558e3069394" +dependencies = [ + "digest 0.10.7", + "ed25519-zebra", + "k256", + "rand_core 0.6.4", + "thiserror", +] + +[[package]] +name = "cosmwasm-derive" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "296db6a3caca5283425ae0cf347f4e46999ba3f6620dbea8939a0e00347831ce" +dependencies = [ + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-schema" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63c337e097a089e5b52b5d914a7ff6613332777f38ea6d9d36e1887cd0baa72e" +dependencies = [ + "cosmwasm-schema-derive", + "schemars", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "766cc9e7c1762d8fc9c0265808910fcad755200cd0e624195a491dd885a61169" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-std" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb5e05a95fd2a420cca50f4e94eb7e70648dac64db45e90403997ebefeb143bd" +dependencies = [ + "base64 0.13.1", + "bnum", + "cosmwasm-crypto", + "cosmwasm-derive", + "derivative", + "forward_ref", + "hex", + "schemars", + "serde", + "serde-json-wasm 0.5.1", + "sha2 0.10.7", + "thiserror", +] + +[[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-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-check" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "ibc", + "serde-json-wasm 1.0.0", + "thiserror", +] + +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.28", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.28", +] + +[[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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" +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", + "quote", + "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 = [ + "proc-macro2", + "quote", + "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", + "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", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "dyn-clone" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" + +[[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", + "rfc6979", + "signature 1.6.4", +] + +[[package]] +name = "ed25519" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fb04eee5d9d907f29e80ee6b0e78f7e2c82342c63e3580d8c4f69d9d5aad963" +dependencies = [ + "pkcs8 0.10.2", + "signature 2.1.0", +] + +[[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", + "crypto-bigint", + "der 0.6.1", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "pkcs8 0.9.0", + "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 = "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 = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "static_assertions", +] + +[[package]] +name = "flex-error" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c606d892c9de11507fa0dcffc116434f94e105d0bbdc4e405b61519464c49d7b" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" + +[[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", +] + +[[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", + "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", +] + +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[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 = "ibc" +version = "0.45.0" +dependencies = [ + "bytes", + "derive_more", + "displaydoc", + "ibc-derive", + "ibc-proto", + "ics23", + "num-traits", + "parity-scale-codec", + "primitive-types", + "prost", + "scale-info", + "serde", + "serde-json-wasm 1.0.0", + "serde_derive", + "sha2 0.10.7", + "subtle-encoding", + "tendermint", + "tendermint-light-client-verifier", + "tendermint-proto", + "time", + "tracing", + "uint", +] + +[[package]] +name = "ibc-derive" +version = "0.3.0" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "ibc-proto" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "459ccbab879b749bf500ae13244593fa16fc64c1b3159f6b0753c169625a1e23" +dependencies = [ + "base64 0.21.2", + "bytes", + "flex-error", + "ics23", + "parity-scale-codec", + "prost", + "scale-info", + "serde", + "subtle-encoding", + "tendermint-proto", +] + +[[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", + "ripemd", + "serde", + "sha2 0.10.7", + "sha3", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[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", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + +[[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 = "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", + "elliptic-curve", + "sha2 0.10.7", +] + +[[package]] +name = "keccak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-traits" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +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 = "parity-scale-codec" +version = "3.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" +dependencies = [ + "arrayvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "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 = "pin-project-lite" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" + +[[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.7", + "spki 0.7.2", +] + +[[package]] +name = "primitive-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +dependencies = [ + "fixed-hash", + "impl-serde", + "uint", +] + +[[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 = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[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", + "quote", + "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", +] + +[[package]] +name = "quote" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +dependencies = [ + "proc-macro2", +] + +[[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 = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[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 = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "scale-info" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +dependencies = [ + "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", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "schemars" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "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", + "der 0.6.1", + "generic-array", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + +[[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.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" +dependencies = [ + "serde", +] + +[[package]] +name = "serde-json-wasm" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83c37d03f3b0f6b5f77c11af1e7c772de1c9af83e50bef7bb6069601900ba67b" +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", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "serde_derive_internals" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "serde_json" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +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", + "quote", + "syn 2.0.28", +] + +[[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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +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 = "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" + +[[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.7", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[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 = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tendermint" +version = "0.33.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c35fe4fd24a7715571814c22416dbc40ec0f2a6e3cce75d73e19699faecd246" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "flex-error", + "futures", + "num-traits", + "once_cell", + "prost", + "prost-types", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2 0.10.7", + "signature 2.1.0", + "subtle", + "subtle-encoding", + "tendermint-proto", + "time", + "zeroize", +] + +[[package]] +name = "tendermint-light-client-verifier" +version = "0.33.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680639f67d51eceb700bff18b45b584373ec94ee0d7ffe61f4ca6c54ed7787ff" +dependencies = [ + "derive_more", + "flex-error", + "serde", + "tendermint", + "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", + "prost-types", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + +[[package]] +name = "thiserror" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "time" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +dependencies = [ + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "time-macros" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +dependencies = [ + "time-core", +] + +[[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.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +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" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[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.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" + +[[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 = "winnow" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bd122eb777186e60c3fdf765a58ac76e41c582f1f535fbf3314434c6b58f3f7" +dependencies = [ + "memchr", +] + +[[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", + "quote", + "syn 2.0.28", +] diff --git a/ci/cw-check/Cargo.toml b/ci/cw-check/Cargo.toml new file mode 100644 index 000000000..6d57e8947 --- /dev/null +++ b/ci/cw-check/Cargo.toml @@ -0,0 +1,24 @@ +[package] +edition = "2021" +name = "cw-check" +version = "0.1.0" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +ibc = { path = "../../crates/ibc", default_features = false, features = ["serde", "parity-scale-codec"]} +cosmwasm-std = { version = "1.2.5", default-features = false} +cosmwasm-schema = { version = "1.2.5", default-features = false} +serde_json = {package = "serde-json-wasm", version = "1.0.0", default-features = false } +thiserror = { version = "*", default-features = false} + +[profile.release] +lto = true +codegen-units = 1 +debug = false +debug-assertions = false +opt-level = "s" +overflow-checks = true +panic = "abort" +rpath = false \ No newline at end of file diff --git a/ci/cw-check/rust-toolchain.toml b/ci/cw-check/rust-toolchain.toml new file mode 100644 index 000000000..0ce1c5cca --- /dev/null +++ b/ci/cw-check/rust-toolchain.toml @@ -0,0 +1,5 @@ +[toolchain] +channel = "nightly-2023-03-09" +targets = [ + "wasm32-unknown-unknown", +] diff --git a/ci/cw-check/shell.nix b/ci/cw-check/shell.nix new file mode 100644 index 000000000..3482d1228 --- /dev/null +++ b/ci/cw-check/shell.nix @@ -0,0 +1,16 @@ +# install nix and `nix-shell` in this directory, run `cw-check` command +{ pkgs ? import { overlays = [ (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/refs/heads/stable.zip")) ]; } }: +let + rust-as-on-ci = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + cw-check = pkgs.writeShellApplication rec { + name = "cw-check"; + runtimeInputs = [ rust-as-on-ci ]; + text = '' + cargo build --target wasm32-unknown-unknown --no-default-features --release + nix run github:informalsystems/cosmos.nix#cosmwasm-check ./target/wasm32-unknown-unknown/release/cw_check.wasm + ''; + }; +in +pkgs.mkShell { + nativeBuildInputs = [ rust-as-on-ci cw-check]; +} \ No newline at end of file diff --git a/ci/cw-check/src/lib.rs b/ci/cw-check/src/lib.rs new file mode 100644 index 000000000..e13da8cd5 --- /dev/null +++ b/ci/cw-check/src/lib.rs @@ -0,0 +1,64 @@ +extern crate alloc; +use std::str::FromStr; + +use cosmwasm_schema::cw_serde; +use cosmwasm_std::{DepsMut, Env, MessageInfo, Response}; +use ibc::{ + applications::transfer::{msgs::transfer::MsgTransfer, packet::PacketData, *}, + core::ics24_host::identifier::*, +}; +use thiserror::Error; + +#[cw_serde] +pub struct Msg { + pub test: String, +} + +#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)] +pub fn instantiate( + _deps: DepsMut, + _env: Env, + _info: MessageInfo, + msg: Msg, +) -> Result { + let _serde: ( + PrefixedCoin, + Amount, + ChannelId, + ChainId, + ConnectionId, + MsgTransfer, + PacketData, + ) = serde_json::from_str(&msg.test).expect("test"); + let a = serde_json::to_string(&ChannelId::from_str(msg.test.as_str()).unwrap()).expect("test"); + let b = serde_json::to_string(&PortId::from_str(msg.test.as_str()).unwrap()).expect("test"); + let c = serde_json::to_string(&ClientId::from_str(msg.test.as_str()).unwrap()).expect("test"); + let d = + serde_json::to_string(&ConnectionId::from_str(msg.test.as_str()).unwrap()).expect("test"); + let e = serde_json::to_string(&PrefixedDenom { + trace_path: TracePath::default(), + base_denom: BaseDenom::from_str(msg.test.as_str()).unwrap(), + }) + .expect("test"); + let f = serde_json::to_string(&ConnectionId::from_str(msg.test.as_str()).expect("test")) + .expect("test"); + Ok(Response::new() + .add_attribute(a, b) + .add_attribute(c, d) + .add_attribute(e, f) + .add_attribute(msg.test.clone(), msg.test.clone())) +} + +#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)] +pub fn execute( + _deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: Msg, +) -> Result { + Ok(Response::default()) +} + +#[cw_serde] +#[derive(Error)] +pub enum ContractError {} diff --git a/ci/no-std-check/Cargo.lock b/ci/no-std-check/Cargo.lock index 1ccfd78d4..ab6f65baf 100644 --- a/ci/no-std-check/Cargo.lock +++ b/ci/no-std-check/Cargo.lock @@ -1064,7 +1064,7 @@ dependencies = [ [[package]] name = "ibc" -version = "0.45.0" +version = "0.46.0" dependencies = [ "bytes", "derive_more", @@ -1076,8 +1076,8 @@ dependencies = [ "primitive-types", "prost", "serde", + "serde-json-wasm", "serde_derive", - "serde_json", "sha2 0.10.8", "subtle-encoding", "tendermint", @@ -1381,7 +1381,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.18", + "rustix 0.38.19", ] [[package]] @@ -1844,7 +1844,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata 0.4.1", - "regex-syntax 0.8.0", + "regex-syntax 0.8.1", ] [[package]] @@ -1864,7 +1864,7 @@ checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.0", + "regex-syntax 0.8.1", ] [[package]] @@ -1875,9 +1875,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" +checksum = "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33" [[package]] name = "ripemd" @@ -1917,9 +1917,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.15" +version = "0.36.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" +checksum = "6da3636faa25820d8648e0e31c5d519bbb01f72fdf57131f0f5f7da5fed36eab" dependencies = [ "bitflags 1.3.2", "errno", @@ -1931,9 +1931,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", @@ -2050,13 +2050,22 @@ 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", ] +[[package]] +name = "serde-json-wasm" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83c37d03f3b0f6b5f77c11af1e7c772de1c9af83e50bef7bb6069601900ba67b" +dependencies = [ + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.12" @@ -2068,9 +2077,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", "quote", @@ -3154,7 +3163,7 @@ dependencies = [ "memoffset", "paste", "rand 0.8.5", - "rustix 0.36.15", + "rustix 0.36.16", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", diff --git a/crates/ibc/Cargo.toml b/crates/ibc/Cargo.toml index 24d57a030..0a7a66025 100644 --- a/crates/ibc/Cargo.toml +++ b/crates/ibc/Cargo.toml @@ -21,12 +21,12 @@ default = ["std"] std = [ "ibc-proto/std", "ics23/std", - "serde/std", - "serde_json/std", + "serde/std", "tracing/std", "prost/std", "bytes/std", "subtle-encoding/std", + "serde_json/std", "sha2/std", "displaydoc/std", "num-traits/std", @@ -39,7 +39,7 @@ parity-scale-codec = ["dep:parity-scale-codec", "dep:scale-info", "ibc-proto/par borsh = ["dep:borsh", "ibc-proto/borsh"] # This feature is required for token transfer (ICS-20) -serde = ["dep:serde", "dep:serde_derive", "serde_json", "ics23/serde"] +serde = ["dep:serde", "dep:serde_derive", "serde_json", "ibc-proto/serde", "ics23/serde"] # CosmWasm message API generator compatible, should not be inside on chain code schema = ["dep:schemars", "serde", "std"] @@ -55,7 +55,7 @@ ics23 = { version = "0.11", default-features = false, features = ["host-function time = { version = ">=0.3.0, <0.3.30", default-features = false } serde_derive = { version = "1.0.104", default-features = false, optional = true } serde = { version = "1.0", default-features = false, optional = true } -serde_json = { version = "1", default-features = false, optional = true } +serde_json = { package = "serde-json-wasm", version = "1.0.0" , default-features = false, optional = true} tracing = { version = "0.1.36", default-features = false } prost = { version = "0.12", default-features = false } bytes = { version = "1.2.1", default-features = false } diff --git a/crates/ibc/clippy.toml b/crates/ibc/clippy.toml new file mode 100644 index 000000000..af3114623 --- /dev/null +++ b/crates/ibc/clippy.toml @@ -0,0 +1,10 @@ +disallowed-types = [ + # { path = "usize", reason = "variable size" }, # cannot on now, because mocks use it and serde, even if there is no usize in type + { path = "f64", reason = "not supported in CosmWasm" }, + { path = "f32", reason = "not supported in CosmWasm" }, + { path = "num_traits::float::*", reason = "harware dependant" }, +] + +disallowed-methods = [ + "std::time::Duration::as_secs_f64", +] diff --git a/crates/ibc/src/applications/transfer/amount.rs b/crates/ibc/src/applications/transfer/amount.rs index fe21574fa..b14a1797a 100644 --- a/crates/ibc/src/applications/transfer/amount.rs +++ b/crates/ibc/src/applications/transfer/amount.rs @@ -131,7 +131,8 @@ where D: serde::Deserializer<'de>, { use serde::Deserialize; - U256::from_dec_str(<&str>::deserialize(deserializer)?).map_err(serde::de::Error::custom) + U256::from_dec_str(::deserialize(deserializer)?.as_str()) + .map_err(serde::de::Error::custom) } #[cfg(test)] diff --git a/crates/ibc/src/applications/transfer/denom.rs b/crates/ibc/src/applications/transfer/denom.rs index 73d46745d..855b542ae 100644 --- a/crates/ibc/src/applications/transfer/denom.rs +++ b/crates/ibc/src/applications/transfer/denom.rs @@ -142,7 +142,9 @@ impl<'a> TryFrom> for TracePath { fn try_from(v: Vec<&'a str>) -> Result { if v.len() % 2 != 0 { - return Err(TokenTransferError::InvalidTraceLength { len: v.len() }); + return Err(TokenTransferError::InvalidTraceLength { + len: v.len() as u64, + }); } let mut trace = vec![]; @@ -150,12 +152,12 @@ impl<'a> TryFrom> for TracePath { for (pos, (port_id, channel_id)) in id_pairs.rev().enumerate() { let port_id = PortId::from_str(port_id).map_err(|e| TokenTransferError::InvalidTracePortId { - pos, + pos: pos as u64, validation_error: e, })?; let channel_id = ChannelId::from_str(channel_id).map_err(|e| { TokenTransferError::InvalidTraceChannelId { - pos, + pos: pos as u64, validation_error: e, } })?; diff --git a/crates/ibc/src/applications/transfer/error.rs b/crates/ibc/src/applications/transfer/error.rs index 0c25654ce..72fb7ce2f 100644 --- a/crates/ibc/src/applications/transfer/error.rs +++ b/crates/ibc/src/applications/transfer/error.rs @@ -28,16 +28,16 @@ pub enum TokenTransferError { EmptyBaseDenom, /// invalid prot id n trace at position: `{pos}`, validation error: `{validation_error}` InvalidTracePortId { - pos: usize, + pos: u64, validation_error: IdentifierError, }, /// invalid channel id in trace at position: `{pos}`, validation error: `{validation_error}` InvalidTraceChannelId { - pos: usize, + pos: u64, validation_error: IdentifierError, }, /// trace length must be even but got: `{len}` - InvalidTraceLength { len: usize }, + InvalidTraceLength { len: u64 }, /// invalid amount error: `{0}` InvalidAmount(FromDecStrErr), /// invalid token diff --git a/crates/ibc/src/clients/ics07_tendermint/client_state.rs b/crates/ibc/src/clients/ics07_tendermint/client_state.rs index a0f85d226..cc7c1f66a 100644 --- a/crates/ibc/src/clients/ics07_tendermint/client_state.rs +++ b/crates/ibc/src/clients/ics07_tendermint/client_state.rs @@ -146,7 +146,7 @@ impl ClientState { } pub fn validate(&self) -> Result<(), Error> { - self.chain_id.validate_length(3, MaxChainIdLen)?; + self.chain_id.validate_length(3, MaxChainIdLen as u64)?; // `TrustThreshold` is guaranteed to be in the range `[0, 1)`, but a `TrustThreshold::ZERO` // value is invalid in this context diff --git a/crates/ibc/src/core/ics03_connection/handler/conn_open_try.rs b/crates/ibc/src/core/ics03_connection/handler/conn_open_try.rs index 4c0004790..93f3f6612 100644 --- a/crates/ibc/src/core/ics03_connection/handler/conn_open_try.rs +++ b/crates/ibc/src/core/ics03_connection/handler/conn_open_try.rs @@ -234,7 +234,7 @@ mod tests { let client_cons_state_height = 10; let host_chain_height = Height::new(0, 35).unwrap(); let pruned_height = host_chain_height - .sub(max_history_size as u64 + 1) + .sub(max_history_size + 1) .unwrap() .revision_height(); diff --git a/crates/ibc/src/core/ics04_channel/channel.rs b/crates/ibc/src/core/ics04_channel/channel.rs index 56bdaed6a..4fd2d9237 100644 --- a/crates/ibc/src/core/ics04_channel/channel.rs +++ b/crates/ibc/src/core/ics04_channel/channel.rs @@ -314,12 +314,12 @@ impl ChannelEnd { /// Checks if the `connection_hops` has a length of `expected`. pub(crate) fn verify_connection_hops_length( connection_hops: &Vec, - expected: usize, + expected: u64, ) -> Result<(), ChannelError> { - if connection_hops.len() != expected { + if connection_hops.len() as u64 != expected { return Err(ChannelError::InvalidConnectionHopsLength { expected, - actual: connection_hops.len(), + actual: connection_hops.len() as u64, }); } Ok(()) diff --git a/crates/ibc/src/core/ics04_channel/context.rs b/crates/ibc/src/core/ics04_channel/context.rs index 5d6f2aba0..40c51d3fc 100644 --- a/crates/ibc/src/core/ics04_channel/context.rs +++ b/crates/ibc/src/core/ics04_channel/context.rs @@ -2,8 +2,6 @@ use core::time::Duration; -use num_traits::float::FloatCore; - use super::packet::Sequence; use crate::core::events::IbcEvent; use crate::core::ics02_client::client_state::ClientState; @@ -142,10 +140,42 @@ pub(crate) fn calculate_block_delay( delay_period_time: &Duration, max_expected_time_per_block: &Duration, ) -> u64 { - if max_expected_time_per_block.is_zero() { + let delay_period_time = delay_period_time.as_secs(); + let max_expected_time_per_block = max_expected_time_per_block.as_secs(); + if max_expected_time_per_block == 0 { return 0; } + if delay_period_time % max_expected_time_per_block == 0 { + return delay_period_time / max_expected_time_per_block; + } + (delay_period_time / max_expected_time_per_block) + 1 +} - FloatCore::ceil(delay_period_time.as_secs_f64() / max_expected_time_per_block.as_secs_f64()) - as u64 +#[cfg(test)] +mod tests { + + use rstest::rstest; + + use super::*; + + #[rstest] + #[case::remainder_zero(10, 2, 5)] + #[case::remainder_not_zero(10, 3, 4)] + #[case::max_expected_zero(10, 0, 0)] + #[case::delay_period_zero(0, 2, 0)] + #[case::both_zero(0, 0, 0)] + #[case::delay_less_than_max(10, 11, 1)] + fn test_calculate_block_delay_zero( + #[case] delay_period_time: u64, + #[case] max_expected_time_per_block: u64, + #[case] expected: u64, + ) { + assert_eq!( + calculate_block_delay( + &Duration::from_secs(delay_period_time), + &Duration::from_secs(max_expected_time_per_block) + ), + expected + ); + } } diff --git a/crates/ibc/src/core/ics04_channel/error.rs b/crates/ibc/src/core/ics04_channel/error.rs index 61e5a14b1..88a8abcb0 100644 --- a/crates/ibc/src/core/ics04_channel/error.rs +++ b/crates/ibc/src/core/ics04_channel/error.rs @@ -25,7 +25,7 @@ pub enum ChannelError { /// invalid channel order type: expected `{expected}`, actual `{actual}` InvalidOrderType { expected: String, actual: String }, /// invalid connection hops length: expected `{expected}`; actual `{actual}` - InvalidConnectionHopsLength { expected: usize, actual: usize }, + InvalidConnectionHopsLength { expected: u64, actual: u64 }, /// invalid signer error: `{reason}` InvalidSigner { reason: String }, /// invalid proof: missing height diff --git a/crates/ibc/src/core/ics23_commitment/merkle.rs b/crates/ibc/src/core/ics23_commitment/merkle.rs index 3f5bfb437..3ffb37b8b 100644 --- a/crates/ibc/src/core/ics23_commitment/merkle.rs +++ b/crates/ibc/src/core/ics23_commitment/merkle.rs @@ -57,7 +57,7 @@ impl MerkleProof { root: MerkleRoot, keys: MerklePath, value: Vec, - start_index: usize, + start_index: u64, ) -> Result<(), CommitmentError> { // validate arguments if self.proofs.is_empty() { @@ -86,7 +86,11 @@ impl MerkleProof { .iter() .zip(ics23_specs.iter()) .zip(keys.key_path.iter().rev()) - .skip(start_index) + .skip( + start_index + .try_into() + .expect("safe because if u64 is more than usize it will skip all anyway"), + ) { match &proof.proof { Some(Proof::Exist(existence_proof)) => { diff --git a/crates/ibc/src/core/ics24_host/identifier.rs b/crates/ibc/src/core/ics24_host/identifier.rs index ae5a4fbb2..4d28f65c1 100644 --- a/crates/ibc/src/core/ics24_host/identifier.rs +++ b/crates/ibc/src/core/ics24_host/identifier.rs @@ -39,6 +39,7 @@ const TRANSFER_PORT_ID: &str = "transfer"; derive(borsh::BorshSerialize, borsh::BorshDeserialize) )] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ChainId { id: String, @@ -107,11 +108,7 @@ impl ChainId { /// A convenient method to check if the `ChainId` forms a valid identifier /// with the desired min/max length. However, ICS-24 does not specify a /// certain min or max lengths for chain identifiers. - pub fn validate_length( - &self, - min_length: usize, - max_length: usize, - ) -> Result<(), IdentifierError> { + pub fn validate_length(&self, min_length: u64, max_length: u64) -> Result<(), IdentifierError> { validate_prefix_length(self.chain_name(), min_length, max_length) } } @@ -504,9 +501,9 @@ pub enum IdentifierError { /// identifier `{id}` has invalid length `{length}` must be between `{min}`-`{max}` characters InvalidLength { id: String, - length: usize, - min: usize, - max: usize, + length: u64, + min: u64, + max: u64, }, /// identifier `{id}` must only contain alphanumeric characters or `.`, `_`, `+`, `-`, `#`, - `[`, `]`, `<`, `>` InvalidCharacter { id: String }, diff --git a/crates/ibc/src/core/ics24_host/identifier/validate.rs b/crates/ibc/src/core/ics24_host/identifier/validate.rs index ddf8c98b8..8123aeb3e 100644 --- a/crates/ibc/src/core/ics24_host/identifier/validate.rs +++ b/crates/ibc/src/core/ics24_host/identifier/validate.rs @@ -37,14 +37,14 @@ pub fn validate_identifier_chars(id: &str) -> Result<(), Error> { /// Checks if the identifier forms a valid identifier with the given min/max length as specified in the /// [`ICS-24`](https://github.com/cosmos/ibc/tree/main/spec/core/ics-024-host-requirements#paths-identifiers-separators)] /// spec. -pub fn validate_identifier_length(id: &str, min: usize, max: usize) -> Result<(), Error> { +pub fn validate_identifier_length(id: &str, min: u64, max: u64) -> Result<(), Error> { assert!(max >= min); // Check identifier length is between given min/max - if id.len() < min || id.len() > max { + if (id.len() as u64) < min || id.len() as u64 > max { return Err(Error::InvalidLength { id: id.into(), - length: id.len(), + length: id.len() as u64, min, max, }); @@ -58,8 +58,8 @@ pub fn validate_identifier_length(id: &str, min: usize, max: usize) -> Result<() /// and `max_id_length - 21` characters, considering `u64::MAX` (20 chars) and "-". pub fn validate_prefix_length( prefix: &str, - min_id_length: usize, - max_id_length: usize, + min_id_length: u64, + max_id_length: u64, ) -> Result<(), Error> { // Checks if the prefix forms a valid identifier length when constructed with `u64::MIN` validate_identifier_length( diff --git a/crates/ibc/src/lib.rs b/crates/ibc/src/lib.rs index de0256681..528693a9b 100644 --- a/crates/ibc/src/lib.rs +++ b/crates/ibc/src/lib.rs @@ -8,6 +8,7 @@ unused_qualifications, rust_2018_idioms )] +#![cfg_attr(not(test), deny(clippy::disallowed_methods, clippy::disallowed_types,))] #![forbid(unsafe_code)] // https://github.com/cosmos/ibc-rs/issues/342 #![allow(clippy::result_large_err)] diff --git a/crates/ibc/src/mock/context.rs b/crates/ibc/src/mock/context.rs index 8bc84d1d0..f31e23a6d 100644 --- a/crates/ibc/src/mock/context.rs +++ b/crates/ibc/src/mock/context.rs @@ -200,7 +200,7 @@ pub struct MockContext { host_chain_id: ChainId, /// Maximum size for the history of the host chain. Any block older than this is pruned. - max_history_size: usize, + max_history_size: u64, /// The chain of blocks underlying this context. A vector of size up to `max_history_size` /// blocks, ascending order by their height (latest block is on the last position). @@ -263,7 +263,7 @@ impl MockContext { pub fn new( host_id: ChainId, host_type: HostType, - max_history_size: usize, + max_history_size: u64, latest_height: Height, ) -> Self { assert_ne!( @@ -278,7 +278,7 @@ impl MockContext { ); // Compute the number of blocks to store. - let n = min(max_history_size as u64, latest_height.revision_height()); + let n = min(max_history_size, latest_height.revision_height()); assert_eq!( host_id.revision_number(), @@ -377,7 +377,7 @@ impl MockContext { MockContext { host_chain_type: host_type, host_chain_id: host_id.clone(), - max_history_size, + max_history_size: max_history_size as u64, history, block_time, ibc_store: Arc::new(Mutex::new(MockIbcStore::default())), @@ -638,7 +638,7 @@ impl MockContext { panic!("Cannot rewind history of the chain to a smaller revision height!") } else if target_height.revision_height() > latest_height.revision_height() { // Repeatedly advance the host chain height till we hit the desired height - let mut ctx = MockContext { ..self }; + let mut ctx = self; while ctx.latest_height().revision_height() < target_height.revision_height() { ctx.advance_host_chain_height() } @@ -670,14 +670,14 @@ impl MockContext { /// Accessor for a block of the local (host) chain from this context. /// Returns `None` if the block at the requested height does not exist. pub fn host_block(&self, target_height: &Height) -> Option<&HostBlock> { - let target = target_height.revision_height() as usize; - let latest = self.latest_height().revision_height() as usize; + let target = target_height.revision_height(); + let latest = self.latest_height().revision_height(); // Check that the block is not too advanced, nor has it been pruned. - if (target > latest) || (target <= latest - self.history.len()) { + if (target > latest) || (target <= latest - self.history.len() as u64) { None // Block for requested height does not exist in history. } else { - Some(&self.history[self.history.len() + target - latest - 1]) + Some(&self.history[self.history.len() + target as usize - latest as usize - 1]) } } @@ -695,10 +695,10 @@ impl MockContext { ); // Append the new header at the tip of the history. - if self.history.len() >= self.max_history_size { + if self.history.len() as u64 >= self.max_history_size { // History is full, we rotate and replace the tip with the new header. self.history.rotate_left(1); - self.history[self.max_history_size - 1] = new_block; + self.history[self.max_history_size as usize - 1] = new_block; } else { // History is not full yet. self.history.push(new_block); @@ -722,7 +722,7 @@ impl MockContext { /// Validates this context. Should be called after the context is mutated by a test. pub fn validate(&self) -> Result<(), String> { // Check that the number of entries is not higher than window size. - if self.history.len() > self.max_history_size { + if self.history.len() as u64 > self.max_history_size { return Err("too many entries".to_string()); } @@ -1507,7 +1507,7 @@ mod tests { fn test_router() { #[derive(Debug, Default)] struct FooModule { - counter: usize, + counter: u64, } impl Module for FooModule { diff --git a/crates/ibc/src/serializers.rs b/crates/ibc/src/serializers.rs index 5e0a49281..a4b56473b 100644 --- a/crates/ibc/src/serializers.rs +++ b/crates/ibc/src/serializers.rs @@ -18,12 +18,17 @@ pub mod serde_string { use serde::{de, Deserialize, Deserializer, Serializer}; + use crate::prelude::*; + + // Note: used String version (slower + heap) instead of str, + // because both str ser/de hit some kind of f64/f32 case when compiled into wasm + // and fails to be validated f32/f64 wasm runtimes pub fn serialize(value: &T, serializer: S) -> Result where T: Display, S: Serializer, { - serializer.collect_str(value) + serializer.serialize_str(value.to_string().as_ref()) } pub fn deserialize<'de, T, D>(deserializer: D) -> Result @@ -32,9 +37,7 @@ pub mod serde_string { T::Err: Display, D: Deserializer<'de>, { - <&str>::deserialize(deserializer)? - .parse() - .map_err(de::Error::custom) + T::from_str(::deserialize(deserializer)?.as_str()).map_err(de::Error::custom) } }