diff --git a/.github/workflows/autogenerate-types-chains.yml b/.github/workflows/autogenerate-types-chains.yml new file mode 100644 index 000000000..3f88fb5c4 --- /dev/null +++ b/.github/workflows/autogenerate-types-chains.yml @@ -0,0 +1,50 @@ +name: "Autogenerate types after chain upgrades" + +on: + workflow_dispatch: + inputs: + chain: + description: "Chain to run the action for" + required: true + type: choice + options: + - composable + - picasso_kusama + +jobs: + generate-types-and-open-pr: + runs-on: ubuntu-latest + + if: github.event_name == 'workflow_dispatch' + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Set Git Identity + run: | + git config --global user.email "${GITHUB_ACTOR_EMAIL}" + git config --global user.name "${GITHUB_ACTOR}" + + - name: Set Environment Variables + run: | + echo "CHAIN=${{ github.event.inputs.chain }}" >> $GITHUB_ENV + if [[ "${{ github.event.inputs.chain }}" == "composable" ]]; then + echo "RELAY_URL=wss://rpc-pruned7200-0.polkadot-mainnet.sre-scratchpad-349209.composablenodes.tech" >> $GITHUB_ENV + echo "PARA_URL=wss://rpc-pruned3600-0.composable-mainnet.sre-scratchpad-349209.composablenodes.tech" >> $GITHUB_ENV + fi + echo "RELAY_URL=wss://rpc-pruned7200-0.kusama-mainnet.sre-scratchpad-349209.composablenodes.tech:443" >> $GITHUB_ENV + echo "PARA_URL=wss://rpc-pruned3600-0.picasso-mainnet.sre-scratchpad-349209.composablenodes.tech:443" >> $GITHUB_ENV + + - name: Generate Types + run: | + cargo run -p codegen --bin codegen -- --path ./utils/subxt/generated/src/$CHAIN --relay-url $RELAY_URL --para-url $PARA_URL + + - name: Create pull request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Auto-generate types for $CHAIN" + branch: ${{ github.actor }}-branch + base: master + title: "Autogen: types update" \ No newline at end of file diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 67efcc0e4..02d9c74a0 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -20,7 +20,7 @@ jobs: cancel-in-progress: true container: - image: paritytech/ci-unified:bullseye-1.71.0-v20230727 + image: paritytech/ci-unified:bullseye-1.74.0-v20240109 runs-on: - self-hosted diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 013a8a92b..df6559590 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,12 +3,12 @@ name: Lint on: pull_request: branches: - - 'main' + - 'master' - 'develop' - 'release*' push: branches: - - 'main' + - 'master' - 'develop' - 'release*' @@ -19,7 +19,7 @@ jobs: group: check-${{ github.ref }} cancel-in-progress: true container: - image: paritytech/ci-unified:bullseye-1.74.0-2023-11-01-v20231214 + image: paritytech/ci-unified:bullseye-1.74.0-v20240109 runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/Cargo.lock b/Cargo.lock index b1571f499..67eb577f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -179,6 +179,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "always-assert" version = "0.1.2" @@ -339,6 +348,12 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +[[package]] +name = "ascii" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" + [[package]] name = "asn1-rs" version = "0.3.1" @@ -559,7 +574,7 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http", + "http 0.2.9", "http-body", "hyper", "itoa", @@ -586,7 +601,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", + "http 0.2.9", "http-body", "mime", "rustversion", @@ -641,9 +656,15 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.0" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" [[package]] name = "base64ct" @@ -799,7 +820,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand_core 0.6.4", "ripemd", - "sha2 0.10.6", + "sha2 0.10.8", "subtle", "zeroize", ] @@ -849,7 +870,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -895,7 +916,7 @@ dependencies = [ "cc", "cfg-if 1.0.0", "constant_time_eq 0.2.4", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -953,6 +974,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +[[package]] +name = "bnum" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" + [[package]] name = "borsh" version = "0.10.3" @@ -1067,9 +1094,23 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.32", +] [[package]] name = "byteorder" @@ -1158,11 +1199,52 @@ dependencies = [ "nom", ] +[[package]] +name = "cf-guest" +version = "0.0.0" +source = "git+https://github.com/ComposableFi/emulated-light-client/#bad65fcb9e20f7716d79d70476fef991d60fda52" +dependencies = [ + "borsh", + "bytemuck", + "derive_more", + "guestchain", + "ibc-core-client-context", + "ibc-core-commitment-types", + "ibc-core-host", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "lib", + "prost 0.12.3", + "prost-build 0.12.3", + "sealable-trie", + "stdx", + "trie-ids", +] + +[[package]] +name = "cf-guest-cw" +version = "0.0.0" +dependencies = [ + "base64 0.22.0", + "borsh", + "cf-guest", + "cosmwasm-schema", + "cosmwasm-std", + "derive_more", + "ed25519-dalek 2.1.1", + "guestchain", + "ibc 0.50.0", + "prost 0.12.3", + "schemars", + "serde", + "sha2 0.10.8", +] + [[package]] name = "cfg-expr" -version = "0.15.1" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8790cf1286da485c72cf5fc7aeba308438800036ec67d89425924c4807268c9" +checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" dependencies = [ "smallvec", ] @@ -1314,23 +1396,23 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.11" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ "clap_builder", - "clap_derive 4.4.7", + "clap_derive 4.4.2", ] [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" dependencies = [ "anstream", "anstyle", - "clap_lex 0.6.0", + "clap_lex 0.5.1", "strsim", ] @@ -1358,9 +1440,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", "proc-macro2", @@ -1379,9 +1461,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "coarsetime" @@ -1400,10 +1482,10 @@ name = "codegen" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.4.11", + "clap 3.2.23", "frame-metadata 15.1.0", "hex", - "http", + "http 0.2.9", "jsonrpsee", "parity-scale-codec", "serde_json", @@ -1436,8 +1518,8 @@ version = "6.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e7b787b0dc42e8111badfdbe4c3059158ccb2db8780352fa1b01e8ccf45cc4d" dependencies = [ - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "unicode-width", ] @@ -1540,31 +1622,32 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.2.3" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22add0f9b2a5416df98c1d0248a8d8eedb882c38fbf0c5052b64eebe865df6d" +checksum = "9934c79e58d9676edfd592557dee765d2a6ef54c09d5aa2edb06156b00148966" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", + "ecdsa 0.16.7", "ed25519-zebra", - "k256 0.11.6", + "k256 0.13.1", "rand_core 0.6.4", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "1.2.3" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e64f710a18ef90d0a632cf27842e98ffc2d005a38a6f76c12fd0bc03bc1a2d" +checksum = "bc5e72e330bd3bdab11c52b5ecbdeb6a8697a004c57964caeb5d876f0b088b3c" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.2.3" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe5ad2e23a971b9e4cd57b20cee3e2e79c33799bed4b128e473aca3702bfe5dd" +checksum = "ac3e3a2136e2a60e8b6582f5dffca5d1a683ed77bf38537d330bc1dfccd69010" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -1575,9 +1658,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.3" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2926d159a9bb1a716a592b40280f1663f2491a9de3b6da77c0933cee2a2655b8" +checksum = "f5d803bea6bd9ed61bd1ee0b4a2eb09ee20dbb539cc6e0b8795614d20952ebb1" dependencies = [ "proc-macro2", "quote", @@ -1586,11 +1669,13 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.3" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76fee88ff5bf7bef55bd37ac0619974701b99bf6bd4b16cf56ee8810718abd71" +checksum = "ef8666e572a3a2519010dde88c04d16e9339ae751b56b2bb35081fe3f7d6be74" dependencies = [ - "base64 0.13.1", + "base64 0.21.7", + "bech32", + "bnum", "cosmwasm-crypto", "cosmwasm-derive", "derivative", @@ -1598,10 +1683,10 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", - "sha2 0.10.6", + "serde-json-wasm 0.5.2", + "sha2 0.10.8", + "static_assertions", "thiserror", - "uint", ] [[package]] @@ -1931,7 +2016,7 @@ name = "cumulus-client-cli" version = "0.1.0" source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.43#b8999fce0f61fb757f9e57e326cda48e70137019" dependencies = [ - "clap 4.4.11", + "clap 4.4.6", "parity-scale-codec", "sc-chain-spec", "sc-cli", @@ -2479,7 +2564,7 @@ dependencies = [ "cfg-if 1.0.0", "cpufeatures", "curve25519-dalek-derive", - "digest 0.10.6", + "digest 0.10.7", "fiat-crypto", "platforms 3.0.2", "rustc_version", @@ -2850,9 +2935,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.3", "const-oid", @@ -2976,7 +3061,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" dependencies = [ "der 0.7.8", - "digest 0.10.6", + "digest 0.10.7", "elliptic-curve 0.13.6", "rfc6979 0.4.0", "signature 2.1.0", @@ -2994,9 +3079,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "2.2.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8 0.10.2", "signature 2.1.0", @@ -3030,15 +3115,16 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek 4.1.1", - "ed25519 2.2.2", + "ed25519 2.2.3", "rand_core 0.6.4", "serde", - "sha2 0.10.6", + "sha2 0.10.8", + "subtle", "zeroize", ] @@ -3072,7 +3158,7 @@ dependencies = [ "base16ct 0.1.1", "crypto-bigint 0.4.9", "der 0.6.1", - "digest 0.10.6", + "digest 0.10.7", "ff 0.12.1", "generic-array 0.14.6", "group 0.12.1", @@ -3093,7 +3179,7 @@ checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" dependencies = [ "base16ct 0.2.0", "crypto-bigint 0.5.3", - "digest 0.10.6", + "digest 0.10.7", "ff 0.13.0", "generic-array 0.14.6", "group 0.13.0", @@ -3533,7 +3619,7 @@ dependencies = [ "Inflector", "array-bytes 4.2.0", "chrono", - "clap 4.4.11", + "clap 4.4.6", "comfy-table", "frame-benchmarking", "frame-support", @@ -4081,7 +4167,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.20", "bstr", "fnv", "log", @@ -4192,6 +4278,28 @@ dependencies = [ "subtle", ] +[[package]] +name = "guestchain" +version = "0.0.0" +source = "git+https://github.com/ComposableFi/emulated-light-client/#bad65fcb9e20f7716d79d70476fef991d60fda52" +dependencies = [ + "borsh", + "bytemuck", + "derive_more", + "ibc-core-client-context", + "ibc-core-commitment-types", + "ibc-core-host", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "lib", + "prost 0.12.3", + "prost-build 0.12.3", + "sealable-trie", + "stdx", + "strum 0.25.0", + "trie-ids", +] + [[package]] name = "gumdrop" version = "0.8.1" @@ -4223,7 +4331,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.9", "indexmap 1.9.2", "slab", "tokio", @@ -4300,7 +4408,7 @@ dependencies = [ "bitflags 1.3.2", "bytes", "headers-core", - "http", + "http 0.2.9", "httpdate", "mime", "sha1", @@ -4312,7 +4420,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http", + "http 0.2.9", ] [[package]] @@ -4398,7 +4506,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -4434,6 +4542,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.5" @@ -4441,7 +4560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.9", "pin-project-lite 0.2.13", ] @@ -4480,7 +4599,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.9", "http-body", "httparse", "httpdate", @@ -4502,7 +4621,7 @@ dependencies = [ "bytes", "futures", "headers", - "http", + "http 0.2.9", "hyper", "hyper-rustls 0.22.1", "rustls-native-certs 0.5.0", @@ -4536,7 +4655,7 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" dependencies = [ - "http", + "http 0.2.9", "hyper", "log", "rustls 0.20.8", @@ -4552,7 +4671,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ "futures-util", - "http", + "http 0.2.9", "hyper", "log", "rustls 0.21.7", @@ -4579,7 +4698,7 @@ name = "hyperspace" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.4.11", + "clap 3.2.23", "hyperspace-core", "tokio", "toml 0.7.6", @@ -4591,7 +4710,7 @@ version = "0.1.0" dependencies = [ "anyhow", "async-trait", - "clap 4.4.11", + "clap 3.2.23", "codegen", "derive_more", "env_logger 0.9.3", @@ -4600,11 +4719,10 @@ dependencies = [ "futures", "hex", "hyperspace-cosmos", - "hyperspace-macros", "hyperspace-metrics", "hyperspace-parachain", "hyperspace-primitives", - "ibc", + "ibc 0.15.0", "ibc-proto 0.18.0", "ibc-rpc", "ics08-wasm", @@ -4647,12 +4765,12 @@ dependencies = [ "bech32", "bip32", "derive_more", - "digest 0.10.6", + "digest 0.10.7", "ed25519-zebra", "futures", "hex", "hyperspace-primitives", - "ibc", + "ibc 0.15.0", "ibc-primitives 0.1.0", "ibc-proto 0.18.0", "ibc-rpc", @@ -4670,10 +4788,10 @@ dependencies = [ "rs_merkle", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "tendermint 0.28.0", "tendermint-light-client", - "tendermint-light-client-verifier", + "tendermint-light-client-verifier 0.28.0", "tendermint-proto 0.28.0", "tendermint-rpc", "thiserror", @@ -4684,15 +4802,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "hyperspace-macros" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "hyperspace-metrics" version = "0.1.0" @@ -4700,7 +4809,7 @@ dependencies = [ "anyhow", "futures-util", "hyper", - "ibc", + "ibc 0.15.0", "ibc-proto 0.18.0", "log", "prometheus", @@ -4718,7 +4827,7 @@ dependencies = [ "beefy-light-client", "beefy-light-client-primitives", "beefy-prover", - "clap 4.4.11", + "clap 3.2.23", "derive_more", "finality-grandpa", "frame-support", @@ -4729,7 +4838,7 @@ dependencies = [ "hex", "hex-literal 0.3.4", "hyperspace-primitives", - "ibc", + "ibc 0.15.0", "ibc-primitives 0.1.0", "ibc-proto 0.18.0", "ibc-rpc", @@ -4784,7 +4893,7 @@ dependencies = [ "async-trait", "futures", "hex", - "ibc", + "ibc 0.15.0", "ibc-proto 0.18.0", "ibc-rpc", "ics08-wasm", @@ -4813,7 +4922,7 @@ dependencies = [ "hyperspace-cosmos", "hyperspace-parachain", "hyperspace-primitives", - "ibc", + "ibc 0.15.0", "ibc-proto 0.18.0", "ics10-grandpa", "light-client-common", @@ -4870,8 +4979,8 @@ dependencies = [ "env_logger 0.9.3", "flex-error", "hex", - "ibc-core-host-types", - "ibc-derive", + "ibc-core-host-types 0.48.1", + "ibc-derive 0.1.0", "ibc-proto 0.18.0", "ics23 0.10.0", "log", @@ -4885,7 +4994,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "sp-core 7.0.0", "sp-std 5.0.0", @@ -4900,6 +5009,376 @@ dependencies = [ "uint", ] +[[package]] +name = "ibc" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-apps", + "ibc-clients", + "ibc-core", + "ibc-core-host-cosmos", + "ibc-derive 0.6.0", + "ibc-primitives 0.50.0", +] + +[[package]] +name = "ibc-app-nft-transfer" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-app-nft-transfer-types", + "ibc-core", + "serde-json-wasm 1.0.1", +] + +[[package]] +name = "ibc-app-nft-transfer-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "base64 0.21.7", + "borsh", + "derive_more", + "displaydoc", + "http 1.0.0", + "ibc-core", + "ibc-proto 0.41.0", + "mime", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", + "serde-json-wasm 1.0.1", +] + +[[package]] +name = "ibc-app-transfer" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-app-transfer-types", + "ibc-core", + "serde-json-wasm 1.0.1", +] + +[[package]] +name = "ibc-app-transfer-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-core", + "ibc-proto 0.41.0", + "primitive-types", + "serde", + "uint", +] + +[[package]] +name = "ibc-apps" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-app-nft-transfer", + "ibc-app-transfer", +] + +[[package]] +name = "ibc-client-tendermint" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "derive_more", + "ibc-client-tendermint-types", + "ibc-core-client", + "ibc-core-commitment-types", + "ibc-core-handler-types", + "ibc-core-host", + "ibc-primitives 0.50.0", + "serde", + "tendermint 0.34.0", + "tendermint-light-client-verifier 0.34.0", +] + +[[package]] +name = "ibc-client-tendermint-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "displaydoc", + "ibc-core-client-types", + "ibc-core-commitment-types", + "ibc-core-host-types 0.50.0", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "serde", + "tendermint 0.34.0", + "tendermint-light-client-verifier 0.34.0", + "tendermint-proto 0.34.0", +] + +[[package]] +name = "ibc-client-wasm-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "base64 0.21.7", + "displaydoc", + "ibc-core-client", + "ibc-core-host-types 0.50.0", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "serde", +] + +[[package]] +name = "ibc-clients" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-client-tendermint", + "ibc-client-wasm-types", +] + +[[package]] +name = "ibc-core" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-core-channel", + "ibc-core-client", + "ibc-core-commitment-types", + "ibc-core-connection", + "ibc-core-handler", + "ibc-core-host", + "ibc-core-router", + "ibc-derive 0.6.0", + "ibc-primitives 0.50.0", +] + +[[package]] +name = "ibc-core-channel" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-core-channel-types", + "ibc-core-client", + "ibc-core-commitment-types", + "ibc-core-connection", + "ibc-core-handler-types", + "ibc-core-host", + "ibc-core-router", + "ibc-primitives 0.50.0", +] + +[[package]] +name = "ibc-core-channel-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-core-client-types", + "ibc-core-commitment-types", + "ibc-core-connection-types", + "ibc-core-host-types 0.50.0", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", + "sha2 0.10.8", + "subtle-encoding", + "tendermint 0.34.0", +] + +[[package]] +name = "ibc-core-client" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-core-client-context", + "ibc-core-client-types", + "ibc-core-commitment-types", + "ibc-core-handler-types", + "ibc-core-host", + "ibc-primitives 0.50.0", +] + +[[package]] +name = "ibc-core-client-context" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "derive_more", + "displaydoc", + "ibc-core-client-types", + "ibc-core-commitment-types", + "ibc-core-handler-types", + "ibc-core-host-types 0.50.0", + "ibc-primitives 0.50.0", + "subtle-encoding", + "tendermint 0.34.0", +] + +[[package]] +name = "ibc-core-client-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-core-commitment-types", + "ibc-core-host-types 0.50.0", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", + "subtle-encoding", + "tendermint 0.34.0", +] + +[[package]] +name = "ibc-core-commitment-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "ics23 0.11.0", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", + "subtle-encoding", +] + +[[package]] +name = "ibc-core-connection" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-core-client", + "ibc-core-connection-types", + "ibc-core-handler-types", + "ibc-core-host", + "ibc-primitives 0.50.0", +] + +[[package]] +name = "ibc-core-connection-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-core-client-types", + "ibc-core-commitment-types", + "ibc-core-host-types 0.50.0", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", + "subtle-encoding", + "tendermint 0.34.0", +] + +[[package]] +name = "ibc-core-handler" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "ibc-core-channel", + "ibc-core-client", + "ibc-core-commitment-types", + "ibc-core-connection", + "ibc-core-handler-types", + "ibc-core-host", + "ibc-core-router", + "ibc-primitives 0.50.0", +] + +[[package]] +name = "ibc-core-handler-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-core-channel-types", + "ibc-core-client-types", + "ibc-core-commitment-types", + "ibc-core-connection-types", + "ibc-core-host-types 0.50.0", + "ibc-core-router-types", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", + "subtle-encoding", + "tendermint 0.34.0", +] + +[[package]] +name = "ibc-core-host" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "derive_more", + "displaydoc", + "ibc-core-channel-types", + "ibc-core-client-context", + "ibc-core-client-types", + "ibc-core-commitment-types", + "ibc-core-connection-types", + "ibc-core-handler-types", + "ibc-core-host-types 0.50.0", + "ibc-primitives 0.50.0", + "subtle-encoding", +] + +[[package]] +name = "ibc-core-host-cosmos" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-app-transfer-types", + "ibc-client-tendermint", + "ibc-core-client-context", + "ibc-core-client-types", + "ibc-core-commitment-types", + "ibc-core-connection-types", + "ibc-core-handler-types", + "ibc-core-host-types 0.50.0", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "serde", + "sha2 0.10.8", + "subtle-encoding", + "tendermint 0.34.0", +] + [[package]] name = "ibc-core-host-types" version = "0.48.1" @@ -4911,6 +5390,54 @@ dependencies = [ "ibc-primitives 0.48.1", ] +[[package]] +name = "ibc-core-host-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-primitives 0.50.0", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", +] + +[[package]] +name = "ibc-core-router" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "derive_more", + "displaydoc", + "ibc-core-channel-types", + "ibc-core-host-types 0.50.0", + "ibc-core-router-types", + "ibc-primitives 0.50.0", + "subtle-encoding", +] + +[[package]] +name = "ibc-core-router-types" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-core-host-types 0.50.0", + "ibc-primitives 0.50.0", + "ibc-proto 0.41.0", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", + "subtle-encoding", + "tendermint 0.34.0", +] + [[package]] name = "ibc-derive" version = "0.1.0" @@ -4922,6 +5449,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ibc-derive" +version = "0.6.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.32", +] + [[package]] name = "ibc-primitives" version = "0.1.0" @@ -4930,12 +5467,12 @@ dependencies = [ "blake2", "frame-support", "hex", - "ibc", + "ibc 0.15.0", "parity-scale-codec", "ripemd", "scale-info", "serde", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "sp-core 7.0.0", "sp-io 7.0.0", @@ -4959,6 +5496,24 @@ dependencies = [ "time 0.3.17", ] +[[package]] +name = "ibc-primitives" +version = "0.50.0" +source = "git+https://github.com/cosmos/ibc-rs?rev=6dd3c6465e594d4c177f21724dd896a15e8f3634#6dd3c6465e594d4c177f21724dd896a15e8f3634" +dependencies = [ + "borsh", + "derive_more", + "displaydoc", + "ibc-proto 0.41.0", + "parity-scale-codec", + "prost 0.12.3", + "scale-info", + "schemars", + "serde", + "tendermint 0.34.0", + "time 0.3.17", +] + [[package]] name = "ibc-proto" version = "0.18.0" @@ -4978,11 +5533,32 @@ version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93cbf4cbe9e5113cc7c70f3208a7029b2205c629502cbb2ae7ea0a09a97d3005" dependencies = [ - "base64 0.21.0", + "base64 0.21.7", + "bytes", + "flex-error", + "ics23 0.11.0", + "prost 0.12.3", + "subtle-encoding", + "tendermint-proto 0.34.0", +] + +[[package]] +name = "ibc-proto" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4ee32b22d3b06f31529b956f4928e5c9a068d71e46cf6abfa19c31ca550553" +dependencies = [ + "base64 0.21.7", + "borsh", "bytes", "flex-error", "ics23 0.11.0", + "informalsystems-pbjson 0.7.0", + "parity-scale-codec", "prost 0.12.3", + "scale-info", + "schemars", + "serde", "subtle-encoding", "tendermint-proto 0.34.0", ] @@ -4993,7 +5569,7 @@ version = "0.2.0" dependencies = [ "argh", "git2", - "prost-build", + "prost-build 0.11.6", "tempdir", "tonic-build", "walkdir", @@ -5004,9 +5580,8 @@ name = "ibc-rpc" version = "0.1.0" dependencies = [ "frame-system", - "hex", - "ibc", - "ibc-derive", + "ibc 0.15.0", + "ibc-derive 0.1.0", "ibc-primitives 0.1.0", "ibc-proto 0.18.0", "ibc-runtime-api", @@ -5044,8 +5619,8 @@ dependencies = [ "env_logger 0.9.3", "flex-error", "hex", - "ibc", - "ibc-derive", + "ibc 0.15.0", + "ibc-derive 0.1.0", "ibc-proto 0.18.0", "ics23 0.10.0", "log", @@ -5053,10 +5628,10 @@ dependencies = [ "prost 0.11.6", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "subtle-encoding", "tendermint 0.28.0", - "tendermint-light-client-verifier", + "tendermint-light-client-verifier 0.28.0", "tendermint-proto 0.28.0", "tendermint-rpc", "tendermint-testgen", @@ -5075,14 +5650,14 @@ dependencies = [ "cosmwasm-std", "cw-multi-test", "derive_more", - "digest 0.10.6", + "digest 0.10.7", "ed25519 1.5.3", "ed25519-consensus", "ed25519-zebra", "hex", "hyperspace-primitives", - "ibc", - "ibc-derive", + "ibc 0.15.0", + "ibc-derive 0.1.0", "ibc-proto 0.18.0", "ics07-tendermint", "ics08-wasm", @@ -5091,12 +5666,12 @@ dependencies = [ "prost 0.11.6", "schemars", "serde", - "serde-json-wasm", + "serde-json-wasm 0.5.2", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "tendermint 0.28.0", - "tendermint-light-client-verifier", + "tendermint-light-client-verifier 0.28.0", "tendermint-proto 0.28.0", "thiserror", ] @@ -5107,7 +5682,7 @@ version = "0.1.0" dependencies = [ "cosmwasm-schema", "hex", - "ibc", + "ibc 0.15.0", "ibc-proto 0.18.0", "prost 0.11.6", "serde", @@ -5130,15 +5705,15 @@ dependencies = [ "grandpa-prover", "hex", "hyperspace-core", - "ibc", - "ibc-derive", + "ibc 0.15.0", + "ibc-derive 0.1.0", "ibc-proto 0.18.0", "jsonrpsee-ws-client", "light-client-common", "log", "parity-scale-codec", "prost 0.11.6", - "prost-build", + "prost-build 0.11.6", "prost-types 0.11.6", "sc-consensus-grandpa-rpc", "serde", @@ -5165,14 +5740,14 @@ dependencies = [ "cw-multi-test", "cw-storage-plus", "derive_more", - "digest 0.10.6", + "digest 0.10.7", "ed25519-zebra", "finality-grandpa", "grandpa-light-client-primitives", "hex", "hyperspace-primitives", - "ibc", - "ibc-derive", + "ibc 0.15.0", + "ibc-derive 0.1.0", "ibc-proto 0.18.0", "ics08-wasm", "ics10-grandpa", @@ -5182,9 +5757,9 @@ dependencies = [ "prost 0.11.6", "schemars", "serde", - "serde-json-wasm", + "serde-json-wasm 0.5.2", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "sp-core 7.0.0", "sp-io 7.0.0", @@ -5210,13 +5785,13 @@ dependencies = [ "frame-support", "futures", "hyperspace-core", - "ibc", - "ibc-derive", + "ibc 0.15.0", + "ibc-derive 0.1.0", "ibc-proto 0.18.0", "light-client-common", "parity-scale-codec", "prost 0.11.6", - "prost-build", + "prost-build 0.11.6", "prost-types 0.11.6", "serde", "serde_json", @@ -5242,8 +5817,8 @@ dependencies = [ "derive_more", "env_logger 0.9.3", "flex-error", - "ibc", - "ibc-derive", + "ibc 0.15.0", + "ibc-derive 0.1.0", "ibc-proto 0.18.0", "ics23 0.10.0", "modelator", @@ -5255,7 +5830,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "sp-core 7.0.0", "subtle-encoding", @@ -5281,7 +5856,7 @@ dependencies = [ "hex", "prost 0.11.6", "ripemd", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", ] @@ -5294,7 +5869,12 @@ dependencies = [ "anyhow", "bytes", "hex", + "informalsystems-pbjson 0.6.0", "prost 0.12.3", + "ripemd", + "serde", + "sha2 0.10.8", + "sha3", ] [[package]] @@ -5431,6 +6011,26 @@ dependencies = [ "unicode-width", ] +[[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 = "informalsystems-pbjson" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa4a0980c8379295100d70854354e78df2ee1c6ca0f96ffe89afeb3140e3a3d" +dependencies = [ + "base64 0.21.7", + "serde", +] + [[package]] name = "inout" version = "0.1.3" @@ -5585,7 +6185,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8b3815d9f5d5de348e5f162b316dc9cdf4548305ebb15b4eb9328e66cf27d7a" dependencies = [ "futures-util", - "http", + "http 0.2.9", "jsonrpsee-core", "jsonrpsee-types", "pin-project", @@ -5667,7 +6267,7 @@ checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" dependencies = [ "futures-channel", "futures-util", - "http", + "http 0.2.9", "hyper", "jsonrpsee-core", "jsonrpsee-types", @@ -5701,7 +6301,7 @@ version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e1b3975ed5d73f456478681a417128597acd6a2487855fdb7b4a3d4d195bf5e" dependencies = [ - "http", + "http 0.2.9", "jsonrpsee-client-transport", "jsonrpsee-core", "jsonrpsee-types", @@ -5716,7 +6316,7 @@ dependencies = [ "cfg-if 1.0.0", "ecdsa 0.14.8", "elliptic-curve 0.12.3", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", ] @@ -5730,7 +6330,8 @@ dependencies = [ "ecdsa 0.16.7", "elliptic-curve 0.13.6", "once_cell", - "sha2 0.10.6", + "sha2 0.10.8", + "signature 2.1.0", ] [[package]] @@ -5900,6 +6501,19 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "lib" +version = "0.0.0" +source = "git+https://github.com/ComposableFi/emulated-light-client/#bad65fcb9e20f7716d79d70476fef991d60fda52" +dependencies = [ + "base64 0.21.7", + "borsh", + "bytemuck", + "derive_more", + "sha2 0.10.8", + "stdx", +] + [[package]] name = "libc" version = "0.2.148" @@ -6065,13 +6679,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58", - "ed25519-dalek 2.0.0", + "ed25519-dalek 2.1.1", "log", "multiaddr", "multihash 0.17.0", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.8", "thiserror", "zeroize", ] @@ -6096,7 +6710,7 @@ dependencies = [ "log", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.8", "smallvec", "thiserror", "uint", @@ -6154,7 +6768,7 @@ dependencies = [ "once_cell", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.8", "snow", "static_assertions", "thiserror", @@ -6458,7 +7072,7 @@ dependencies = [ "async-trait", "derive_more", "hash-db", - "ibc", + "ibc 0.15.0", "ibc-proto 0.18.0", "parity-scale-codec", "serde", @@ -6617,7 +7231,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -6626,7 +7240,7 @@ 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]] @@ -6662,7 +7276,7 @@ version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -6716,6 +7330,14 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memory" +version = "0.0.0" +source = "git+https://github.com/ComposableFi/emulated-light-client/#bad65fcb9e20f7716d79d70476fef991d60fda52" +dependencies = [ + "derive_more", +] + [[package]] name = "memory-db" version = "0.32.0" @@ -6762,9 +7384,9 @@ checksum = "39617bc909d64b068dcffd0e3e31679195b5576d0c83fadc52690268cc2b2b55" [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minimal-lexical" @@ -6871,7 +7493,7 @@ dependencies = [ "regex", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "tempfile", "thiserror", "tracing", @@ -6919,9 +7541,9 @@ dependencies = [ "blake2s_simd", "blake3", "core2", - "digest 0.10.6", + "digest 0.10.7", "multihash-derive", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "unsigned-varint", ] @@ -6933,9 +7555,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" dependencies = [ "core2", - "digest 0.10.6", + "digest 0.10.7", "multihash-derive", - "sha2 0.10.6", + "sha2 0.10.8", "unsigned-varint", ] @@ -7426,7 +8048,7 @@ checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ "ecdsa 0.14.8", "elliptic-curve 0.12.3", - "sha2 0.10.6", + "sha2 0.10.8", ] [[package]] @@ -7437,7 +8059,7 @@ checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ "ecdsa 0.14.8", "elliptic-curve 0.12.3", - "sha2 0.10.6", + "sha2 0.10.8", ] [[package]] @@ -7731,7 +8353,7 @@ dependencies = [ "sp-npos-elections", "sp-runtime 7.0.0", "sp-std 5.0.0", - "strum", + "strum 0.24.1", ] [[package]] @@ -7822,8 +8444,8 @@ dependencies = [ "grandpa-light-client-primitives", "hex", "hex-literal 0.3.4", - "ibc", - "ibc-derive", + "ibc 0.15.0", + "ibc-derive 0.1.0", "ibc-primitives 0.1.0", "ibc-proto 0.18.0", "ics07-tendermint", @@ -7847,7 +8469,7 @@ dependencies = [ "scale-info", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "simple-iavl", "sp-consensus-aura", "sp-consensus-grandpa", @@ -7860,7 +8482,7 @@ dependencies = [ "sp-std 5.0.0", "sp-trie 7.0.0", "tendermint 0.28.0", - "tendermint-light-client-verifier", + "tendermint-light-client-verifier 0.28.0", "tendermint-proto 0.28.0", ] @@ -7870,7 +8492,7 @@ version = "0.0.1" dependencies = [ "frame-support", "frame-system", - "ibc", + "ibc 0.15.0", "ibc-primitives 0.1.0", "log", "parity-scale-codec", @@ -8544,7 +9166,7 @@ dependencies = [ name = "parachain-node" version = "0.1.0" dependencies = [ - "clap 4.4.11", + "clap 4.4.6", "cumulus-client-cli", "cumulus-client-collator", "cumulus-client-consensus-aura", @@ -8633,7 +9255,7 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal 0.3.4", - "ibc", + "ibc 0.15.0", "ibc-primitives 0.1.0", "ibc-runtime-api", "log", @@ -8819,7 +9441,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -8920,7 +9542,7 @@ checksum = "9f02b677c1859756359fc9983c2e56a0237f18624a3789528804406b7e915e5d" dependencies = [ "once_cell", "pest", - "sha2 0.10.6", + "sha2 0.10.8", ] [[package]] @@ -9088,7 +9710,7 @@ name = "polkadot-cli" version = "0.9.43" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" dependencies = [ - "clap 4.4.11", + "clap 4.4.6", "frame-benchmarking-cli", "futures", "log", @@ -9620,7 +10242,7 @@ dependencies = [ "rand 0.8.5", "sc-authority-discovery", "sc-network", - "strum", + "strum 0.24.1", "thiserror", "tracing-gum", ] @@ -10294,9 +10916,9 @@ dependencies = [ [[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", @@ -10436,7 +11058,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift", - "regex-syntax", + "regex-syntax 0.6.28", "rusty-fork", "tempfile", "unarray", @@ -10494,6 +11116,26 @@ dependencies = [ "which", ] +[[package]] +name = "prost-build" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" +dependencies = [ + "bytes", + "heck", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prost 0.12.3", + "prost-types 0.12.3", + "regex", + "tempfile", + "which", +] + [[package]] name = "prost-derive" version = "0.9.0" @@ -10896,13 +11538,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" dependencies = [ - "aho-corasick", + "aho-corasick 1.1.2", "memchr", - "regex-syntax", + "regex-automata 0.3.7", + "regex-syntax 0.7.5", ] [[package]] @@ -10911,7 +11554,18 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.28", +] + +[[package]] +name = "regex-automata" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +dependencies = [ + "aho-corasick 1.1.2", + "memchr", + "regex-syntax 0.7.5", ] [[package]] @@ -10920,6 +11574,12 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -10981,7 +11641,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -11113,7 +11773,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a632a43487c1332be8e183588079f89b6820fab24e04db49521eacd536837372" dependencies = [ "micromath", - "sha2 0.10.6", + "sha2 0.10.8", ] [[package]] @@ -11296,7 +11956,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64 0.21.0", + "base64 0.21.7", ] [[package]] @@ -11444,7 +12104,7 @@ dependencies = [ "multihash 0.17.0", "parity-scale-codec", "prost 0.11.6", - "prost-build", + "prost-build 0.11.6", "rand 0.8.5", "sc-client-api", "sc-network", @@ -11534,7 +12194,7 @@ source = "git+https://github.com/paritytech//substrate.git?branch=polkadot-v0.9. dependencies = [ "array-bytes 4.2.0", "chrono", - "clap 4.4.11", + "clap 4.4.6", "fdlimit", "futures", "libp2p-identity", @@ -12021,7 +12681,7 @@ dependencies = [ "libp2p-identity", "log", "prost 0.11.6", - "prost-build", + "prost-build 0.11.6", "sc-client-api", "sc-network", "sc-network-common", @@ -12044,7 +12704,7 @@ dependencies = [ "futures-timer", "libp2p-identity", "parity-scale-codec", - "prost-build", + "prost-build 0.11.6", "sc-consensus", "sc-peerset", "sc-utils", @@ -12090,7 +12750,7 @@ dependencies = [ "log", "parity-scale-codec", "prost 0.11.6", - "prost-build", + "prost-build 0.11.6", "sc-client-api", "sc-network", "sc-network-common", @@ -12118,7 +12778,7 @@ dependencies = [ "mockall", "parity-scale-codec", "prost 0.11.6", - "prost-build", + "prost-build 0.11.6", "sc-client-api", "sc-consensus", "sc-network", @@ -12267,7 +12927,7 @@ name = "sc-rpc-server" version = "4.0.0-dev" source = "git+https://github.com/paritytech//substrate.git?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "http", + "http 0.2.9", "jsonrpsee", "log", "serde_json", @@ -12385,7 +13045,7 @@ name = "sc-storage-monitor" version = "0.1.0" source = "git+https://github.com/paritytech//substrate.git?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ - "clap 4.4.11", + "clap 4.4.6", "fs4", "futures", "log", @@ -12647,9 +13307,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 1.0.0", @@ -12661,9 +13321,9 @@ 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 1.3.1", "proc-macro2", @@ -12702,9 +13362,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.11" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -12714,9 +13374,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.11" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -12797,6 +13457,23 @@ dependencies = [ "url", ] +[[package]] +name = "sealable-trie" +version = "0.0.0" +source = "git+https://github.com/ComposableFi/emulated-light-client/#bad65fcb9e20f7716d79d70476fef991d60fda52" +dependencies = [ + "ascii", + "base64 0.21.7", + "borsh", + "bytemuck", + "derive_more", + "lib", + "memory", + "sha2 0.10.8", + "stdx", + "strum 0.25.0", +] + [[package]] name = "sec1" version = "0.3.0" @@ -12910,9 +13587,18 @@ dependencies = [ [[package]] name = "serde-json-wasm" -version = "0.5.1" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" +dependencies = [ + "serde", +] + +[[package]] +name = "serde-json-wasm" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" +checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" dependencies = [ "serde", ] @@ -13010,7 +13696,7 @@ checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -13021,7 +13707,7 @@ checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -13051,13 +13737,13 @@ 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 1.0.0", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -13066,7 +13752,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "keccak", ] @@ -13100,7 +13786,7 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "rand_core 0.6.4", ] @@ -13110,7 +13796,7 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "rand_core 0.6.4", ] @@ -13151,7 +13837,7 @@ dependencies = [ "ics23 0.10.0", "proptest", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.8", "tendermint 0.28.0", ] @@ -13222,7 +13908,7 @@ dependencies = [ "rand_core 0.6.4", "ring", "rustc_version", - "sha2 0.10.6", + "sha2 0.10.8", "subtle", ] @@ -13256,7 +13942,7 @@ dependencies = [ "bytes", "flate2", "futures", - "http", + "http 0.2.9", "httparse", "log", "rand 0.8.5", @@ -13466,7 +14152,7 @@ dependencies = [ "sp-mmr-primitives", "sp-runtime 7.0.0", "sp-std 5.0.0", - "strum", + "strum 0.24.1", ] [[package]] @@ -13595,8 +14281,8 @@ source = "git+https://github.com/paritytech//substrate.git?branch=polkadot-v0.9. dependencies = [ "blake2b_simd", "byteorder", - "digest 0.10.6", - "sha2 0.10.6", + "digest 0.10.7", + "sha2 0.10.8", "sha3", "sp-std 5.0.0", "twox-hash", @@ -13610,8 +14296,8 @@ checksum = "2ee599a8399448e65197f9a6cee338ad192e9023e35e31f22382964c3c174c68" dependencies = [ "blake2b_simd", "byteorder", - "digest 0.10.6", - "sha2 0.10.6", + "digest 0.10.7", + "sha2 0.10.8", "sha3", "sp-std 8.0.0", "twox-hash", @@ -13768,7 +14454,7 @@ dependencies = [ "lazy_static", "sp-core 7.0.0", "sp-runtime 7.0.0", - "strum", + "strum 0.24.1", ] [[package]] @@ -14356,7 +15042,7 @@ checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ "lazy_static", "maplit", - "strum", + "strum 0.24.1", ] [[package]] @@ -14459,6 +15145,11 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "stdx" +version = "0.0.0" +source = "git+https://github.com/ComposableFi/emulated-light-client/#bad65fcb9e20f7716d79d70476fef991d60fda52" + [[package]] name = "strsim" version = "0.10.0" @@ -14471,7 +15162,16 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", +] + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros 0.25.3", ] [[package]] @@ -14487,6 +15187,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.32", +] + [[package]] name = "stun" version = "0.4.4" @@ -14627,7 +15340,7 @@ dependencies = [ "cargo_metadata", "filetime", "sp-maybe-compressed-blob", - "strum", + "strum 0.24.1", "tempfile", "toml 0.7.6", "walkdir", @@ -14850,7 +15563,7 @@ version = "0.28.0" source = "git+https://github.com/informalsystems/tendermint-rs?rev=e81f7bf23d63ffbcd242381d1ce5e35da3515ff1#e81f7bf23d63ffbcd242381d1ce5e35da3515ff1" dependencies = [ "bytes", - "digest 0.10.6", + "digest 0.10.7", "ed25519 1.5.3", "ed25519-consensus", "flex-error", @@ -14865,7 +15578,7 @@ dependencies = [ "serde_bytes", "serde_json", "serde_repr", - "sha2 0.10.6", + "sha2 0.10.8", "signature 1.6.4", "subtle", "subtle-encoding", @@ -14881,8 +15594,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc2294fa667c8b548ee27a9ba59115472d0a09c2ba255771092a7f1dcf03a789" dependencies = [ "bytes", - "digest 0.10.6", - "ed25519 2.2.2", + "digest 0.10.7", + "ed25519 2.2.3", + "ed25519-consensus", "flex-error", "futures", "num-traits", @@ -14893,6 +15607,7 @@ dependencies = [ "serde_bytes", "serde_json", "serde_repr", + "sha2 0.10.8", "signature 2.1.0", "subtle", "subtle-encoding", @@ -14929,7 +15644,7 @@ dependencies = [ "serde_derive", "static_assertions", "tendermint 0.28.0", - "tendermint-light-client-verifier", + "tendermint-light-client-verifier 0.28.0", "tendermint-rpc", "time 0.3.17", "tokio", @@ -14947,6 +15662,19 @@ dependencies = [ "time 0.3.17", ] +[[package]] +name = "tendermint-light-client-verifier" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74994da9de4b1144837a367ca2c60c650f5526a7c1a54760a3020959b522e474" +dependencies = [ + "derive_more", + "flex-error", + "serde", + "tendermint 0.34.0", + "time 0.3.17", +] + [[package]] name = "tendermint-proto" version = "0.28.0" @@ -14993,7 +15721,7 @@ dependencies = [ "flex-error", "futures", "getrandom 0.2.8", - "http", + "http 0.2.9", "hyper", "hyper-proxy", "hyper-rustls 0.22.1", @@ -15190,7 +15918,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.6", + "sha2 0.10.8", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -15389,7 +16117,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.9", "http-body", "hyper", "hyper-timeout", @@ -15418,7 +16146,7 @@ checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4" dependencies = [ "prettyplease 0.1.23", "proc-macro2", - "prost-build", + "prost-build 0.11.6", "quote", "syn 1.0.109", ] @@ -15453,7 +16181,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", + "http 0.2.9", "http-body", "http-range-header", "pin-project-lite 0.2.13", @@ -15472,7 +16200,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", + "http 0.2.9", "http-body", "http-range-header", "pin-project-lite 0.2.13", @@ -15637,6 +16365,22 @@ dependencies = [ "smallvec", ] +[[package]] +name = "trie-ids" +version = "0.0.0" +source = "git+https://github.com/ComposableFi/emulated-light-client/#bad65fcb9e20f7716d79d70476fef991d60fda52" +dependencies = [ + "ascii", + "base64 0.21.7", + "bytemuck", + "derive_more", + "ibc-core-channel-types", + "ibc-core-client-types", + "ibc-core-connection-types", + "ibc-core-host-types 0.50.0", + "strum 0.25.0", +] + [[package]] name = "trie-root" version = "0.18.0" @@ -15704,7 +16448,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech//substrate.git?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "async-trait", - "clap 4.4.11", + "clap 4.4.6", "frame-remote-externalities", "hex", "log", @@ -15749,7 +16493,7 @@ dependencies = [ "base64 0.13.1", "byteorder", "bytes", - "http", + "http 0.2.9", "httparse", "log", "rand 0.8.5", @@ -15770,7 +16514,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 0.2.9", "httparse", "log", "rand 0.8.5", @@ -15807,8 +16551,8 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", - "digest 0.10.6", + "cfg-if 0.1.10", + "digest 0.10.7", "rand 0.8.5", "static_assertions", ] @@ -16165,8 +16909,8 @@ checksum = "87fef6d0d508f08334e0ab0e6877feb4c0ecb3956bcf2cb950699b22fedf3e9c" dependencies = [ "anyhow", "libc", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "tempfile", "thiserror", "wasm-opt-cxx-sys", @@ -16322,14 +17066,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.21.0", + "base64 0.21.7", "bincode", "directories-next", "file-per-thread-logger", "log", "rustix 0.36.8", "serde", - "sha2 0.10.6", + "sha2 0.10.8", "toml 0.5.11", "windows-sys 0.45.0", "zstd 0.11.2+zstd.1.5.2", @@ -16559,7 +17303,7 @@ dependencies = [ "sdp", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "stun", "thiserror", "time 0.3.17", @@ -16622,7 +17366,7 @@ dependencies = [ "sec1 0.3.0", "serde", "sha1", - "sha2 0.10.6", + "sha2 0.10.8", "signature 1.6.4", "subtle", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index e11faa40c..d2892ca32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ members = [ # ibc light clients "light-clients/common", + "light-clients/cf-guest-cw", "light-clients/ics07-tendermint", "light-clients/ics07-tendermint-cw", "light-clients/ics08-wasm", @@ -228,4 +229,4 @@ substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech//sub substrate-wasm-builder = { git = "https://github.com/paritytech//substrate.git", branch = "polkadot-v0.9.43" } [profile.release] -overflow-checks = true \ No newline at end of file +overflow-checks = true diff --git a/algorithms/grandpa/primitives/src/justification.rs b/algorithms/grandpa/primitives/src/justification.rs index c3e0a1b16..8cb369675 100644 --- a/algorithms/grandpa/primitives/src/justification.rs +++ b/algorithms/grandpa/primitives/src/justification.rs @@ -77,14 +77,7 @@ where let ancestry_chain = AncestryChain::::new(&self.votes_ancestries); match finality_grandpa::validate_commit(&self.commit, voters, &ancestry_chain) { - Ok(ref result) if result.is_valid() => { - if result.num_duplicated_precommits() > 0 || - result.num_invalid_voters() > 0 || - result.num_equivocations() > 0 - { - Err(anyhow!("Invalid commit, found one of `duplicate precommits`, `invalid voters`, or `equivocations` {result:?}"))? - } - }, + Ok(ref result) if result.is_valid() => (), // no additional checks required err => { let result = err.map_err(|_| { anyhow!("[verify_with_voter_set] Invalid ancestry while validating commit!") diff --git a/contracts/pallet-ibc/primitives/src/lib.rs b/contracts/pallet-ibc/primitives/src/lib.rs index fd28311f9..9fb353496 100644 --- a/contracts/pallet-ibc/primitives/src/lib.rs +++ b/contracts/pallet-ibc/primitives/src/lib.rs @@ -140,10 +140,10 @@ impl From for PacketInfo { fn from(packet: Packet) -> Self { Self { sequence: packet.sequence.into(), - source_port: packet.source_port.to_string().as_bytes().to_vec(), - source_channel: packet.source_channel.to_string().as_bytes().to_vec(), - destination_port: packet.destination_port.to_string().as_bytes().to_vec(), - destination_channel: packet.destination_channel.to_string().as_bytes().to_vec(), + source_port: packet.source_port.to_string().into_bytes(), + source_channel: packet.source_channel.to_string().into_bytes(), + destination_port: packet.destination_port.to_string().into_bytes(), + destination_channel: packet.destination_channel.to_string().into_bytes(), data: packet.data, timeout_height: ( packet.timeout_height.revision_number, diff --git a/contracts/pallet-ibc/rpc/src/events.rs b/contracts/pallet-ibc/rpc/src/events.rs index 53644a5b2..4878056d9 100644 --- a/contracts/pallet-ibc/rpc/src/events.rs +++ b/contracts/pallet-ibc/rpc/src/events.rs @@ -27,7 +27,7 @@ where let packets: Vec = api .query_send_packet_info( at, - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), port_id.as_bytes().to_vec(), vec![sequence], ) @@ -45,7 +45,7 @@ where let packets: Vec = api .query_recv_packet_info( at, - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), port_id.as_bytes().to_vec(), vec![sequence], ) @@ -63,7 +63,7 @@ where let packets: Vec = api .query_recv_packet_info( at, - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), port_id.as_bytes().to_vec(), vec![sequence], ) @@ -81,7 +81,7 @@ where let packets: Vec = api .query_send_packet_info( at, - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), port_id.as_bytes().to_vec(), vec![sequence], ) @@ -99,7 +99,7 @@ where let packets: Vec = api .query_send_packet_info( at, - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), port_id.as_bytes().to_vec(), vec![sequence], ) @@ -117,7 +117,7 @@ where let packets: Vec = api .query_send_packet_info( at, - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), port_id.as_bytes().to_vec(), vec![sequence], ) diff --git a/contracts/pallet-ibc/src/benchmarks/benchmarking.rs b/contracts/pallet-ibc/src/benchmarks/benchmarking.rs index 1df24f1cd..e276ced45 100644 --- a/contracts/pallet-ibc/src/benchmarks/benchmarking.rs +++ b/contracts/pallet-ibc/src/benchmarks/benchmarking.rs @@ -915,7 +915,7 @@ benchmarks! { let timeout = Timeout::Offset { timestamp: Some(1690894363), height: Some(2000) }; let transfer_params = TransferParams { - to: MultiAddress::Raw("bob".to_string().as_bytes().to_vec()), + to: MultiAddress::Raw("bob".to_string().into_bytes()), source_channel: channel_id.sequence(), timeout, }; @@ -988,7 +988,7 @@ benchmarks! { let mut output = HandlerOutputBuilder::new(); let port_id = PortId::transfer(); let channel_id = ChannelId::new(0); - let channel_ids = vec![channel_id.to_string().as_bytes().to_vec()]; + let channel_ids = vec![channel_id.to_string().into_bytes()]; ChannelIds::::put(channel_ids); let mut handler = IbcModule::::default(); }:{ @@ -1003,7 +1003,7 @@ benchmarks! { let mut output = HandlerOutputBuilder::new(); let port_id = PortId::transfer(); let channel_id = ChannelId::new(0); - let channel_ids = vec![channel_id.to_string().as_bytes().to_vec()]; + let channel_ids = vec![channel_id.to_string().into_bytes()]; ChannelIds::::put(channel_ids); let mut handler = IbcModule::::default(); }:{ @@ -1351,7 +1351,7 @@ benchmarks! { } } - let channel_id_bytes = channel_id.to_string().as_bytes().to_vec(); + let channel_id_bytes = channel_id.to_string().into_bytes(); let port_id_bytes = port_id.as_bytes().to_vec(); let (send_seq_set, _) = diff --git a/contracts/pallet-ibc/src/channel.rs b/contracts/pallet-ibc/src/channel.rs index 3a80d9325..136893082 100644 --- a/contracts/pallet-ibc/src/channel.rs +++ b/contracts/pallet-ibc/src/channel.rs @@ -285,7 +285,7 @@ where packet: ibc::core::ics04_channel::packet::Packet, ) -> Result<(), ICS04Error> { // store packet offchain - let channel_id = key.1.to_string().as_bytes().to_vec(); + let channel_id = key.1.to_string().into_bytes(); let port_id = key.0.as_bytes().to_vec(); let seq = u64::from(key.2); let channel_end = ChannelReader::channel_end(self, &(key.0, key.1))?; @@ -306,7 +306,7 @@ where packet: ibc::core::ics04_channel::packet::Packet, ) -> Result<(), ICS04Error> { // Store packet offchain - let channel_id = key.1.to_string().as_bytes().to_vec(); + let channel_id = key.1.to_string().into_bytes(); let port_id = key.0.as_bytes().to_vec(); let seq = u64::from(key.2); let channel_end = ChannelReader::channel_end(self, &(key.0, key.1))?; @@ -396,10 +396,8 @@ where ) -> Result<(), ICS04Error> { let conn_id = conn_id.as_bytes().to_vec(); - let port_channel_id = ( - port_channel_id.0.as_bytes().to_vec(), - port_channel_id.1.to_string().as_bytes().to_vec(), - ); + let port_channel_id = + (port_channel_id.0.as_bytes().to_vec(), port_channel_id.1.to_string().into_bytes()); if >::contains_key(conn_id.clone()) { log::trace!(target: "pallet_ibc", "in channel: [store_connection_channels] >> insert port_channel_id"); diff --git a/contracts/pallet-ibc/src/events.rs b/contracts/pallet-ibc/src/events.rs index 8071b78dd..55948aca6 100644 --- a/contracts/pallet-ibc/src/events.rs +++ b/contracts/pallet-ibc/src/events.rs @@ -311,124 +311,114 @@ impl From for IbcEvent { RawIbcEvent::OpenInitChannel(ev) => IbcEvent::OpenInitChannel { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev - .channel_id() - .map(|channel_id| channel_id.to_string().as_bytes().to_vec()), + channel_id: ev.channel_id().map(|channel_id| channel_id.to_string().into_bytes()), port_id: ev.port_id().as_bytes().to_vec(), connection_id: ev.connection_id.as_bytes().to_vec(), counterparty_port_id: ev.counterparty_port_id.as_bytes().to_vec(), counterparty_channel_id: ev .counterparty_channel_id - .map(|val| val.to_string().as_bytes().to_vec()), + .map(|val| val.to_string().into_bytes()), }, RawIbcEvent::OpenTryChannel(ev) => IbcEvent::OpenTryChannel { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev - .channel_id() - .map(|channel_id| channel_id.to_string().as_bytes().to_vec()), + channel_id: ev.channel_id().map(|channel_id| channel_id.to_string().into_bytes()), port_id: ev.port_id().as_bytes().to_vec(), connection_id: ev.connection_id.as_bytes().to_vec(), counterparty_port_id: ev.counterparty_port_id.as_bytes().to_vec(), counterparty_channel_id: ev .counterparty_channel_id - .map(|val| val.to_string().as_bytes().to_vec()), + .map(|val| val.to_string().into_bytes()), }, RawIbcEvent::OpenAckChannel(ev) => IbcEvent::OpenAckChannel { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev - .channel_id() - .map(|channel_id| channel_id.to_string().as_bytes().to_vec()), + channel_id: ev.channel_id().map(|channel_id| channel_id.to_string().into_bytes()), port_id: ev.port_id().as_bytes().to_vec(), connection_id: ev.connection_id.as_bytes().to_vec(), counterparty_port_id: ev.counterparty_port_id.as_bytes().to_vec(), counterparty_channel_id: ev .counterparty_channel_id - .map(|val| val.to_string().as_bytes().to_vec()), + .map(|val| val.to_string().into_bytes()), }, RawIbcEvent::OpenConfirmChannel(ev) => IbcEvent::OpenConfirmChannel { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev - .channel_id() - .map(|channel_id| channel_id.to_string().as_bytes().to_vec()), + channel_id: ev.channel_id().map(|channel_id| channel_id.to_string().into_bytes()), port_id: ev.port_id().as_bytes().to_vec(), connection_id: ev.connection_id.as_bytes().to_vec(), counterparty_port_id: ev.counterparty_port_id.as_bytes().to_vec(), counterparty_channel_id: ev .counterparty_channel_id - .map(|val| val.to_string().as_bytes().to_vec()), + .map(|val| val.to_string().into_bytes()), }, RawIbcEvent::CloseInitChannel(ev) => IbcEvent::CloseInitChannel { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev.channel_id().to_string().as_bytes().to_vec(), + channel_id: ev.channel_id().to_string().into_bytes(), port_id: ev.port_id().as_bytes().to_vec(), connection_id: ev.connection_id.as_bytes().to_vec(), counterparty_port_id: ev.counterparty_port_id.as_bytes().to_vec(), counterparty_channel_id: ev .counterparty_channel_id - .map(|val| val.to_string().as_bytes().to_vec()), + .map(|val| val.to_string().into_bytes()), }, RawIbcEvent::CloseConfirmChannel(ev) => IbcEvent::CloseConfirmChannel { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, port_id: ev.port_id.as_bytes().to_vec(), - channel_id: ev - .channel_id() - .map(|channel_id| channel_id.to_string().as_bytes().to_vec()), + channel_id: ev.channel_id().map(|channel_id| channel_id.to_string().into_bytes()), connection_id: ev.connection_id.as_bytes().to_vec(), counterparty_port_id: ev.counterparty_port_id.as_bytes().to_vec(), counterparty_channel_id: ev .counterparty_channel_id - .map(|val| val.to_string().as_bytes().to_vec()), + .map(|val| val.to_string().into_bytes()), }, RawIbcEvent::SendPacket(ev) => IbcEvent::SendPacket { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev.src_channel_id().to_string().as_bytes().to_vec(), + channel_id: ev.src_channel_id().to_string().into_bytes(), port_id: ev.src_port_id().as_bytes().to_vec(), dest_port: ev.dst_port_id().as_bytes().to_vec(), - dest_channel: ev.dst_channel_id().to_string().as_bytes().to_vec(), + dest_channel: ev.dst_channel_id().to_string().into_bytes(), sequence: ev.packet.sequence.into(), }, RawIbcEvent::ReceivePacket(ev) => IbcEvent::ReceivePacket { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev.src_channel_id().to_string().as_bytes().to_vec(), + channel_id: ev.src_channel_id().to_string().into_bytes(), port_id: ev.src_port_id().as_bytes().to_vec(), dest_port: ev.dst_port_id().as_bytes().to_vec(), - dest_channel: ev.dst_channel_id().to_string().as_bytes().to_vec(), + dest_channel: ev.dst_channel_id().to_string().into_bytes(), sequence: ev.packet.sequence.into(), }, RawIbcEvent::WriteAcknowledgement(ev) => IbcEvent::WriteAcknowledgement { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev.src_channel_id().to_string().as_bytes().to_vec(), + channel_id: ev.src_channel_id().to_string().into_bytes(), port_id: ev.src_port_id().as_bytes().to_vec(), dest_port: ev.dst_port_id().as_bytes().to_vec(), - dest_channel: ev.dst_channel_id().to_string().as_bytes().to_vec(), + dest_channel: ev.dst_channel_id().to_string().into_bytes(), sequence: ev.packet.sequence.into(), }, RawIbcEvent::AcknowledgePacket(ev) => IbcEvent::AcknowledgePacket { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev.src_channel_id().to_string().as_bytes().to_vec(), + channel_id: ev.src_channel_id().to_string().into_bytes(), port_id: ev.src_port_id().as_bytes().to_vec(), sequence: ev.packet.sequence.into(), }, RawIbcEvent::TimeoutPacket(ev) => IbcEvent::TimeoutPacket { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev.src_channel_id().to_string().as_bytes().to_vec(), + channel_id: ev.src_channel_id().to_string().into_bytes(), port_id: ev.src_port_id().as_bytes().to_vec(), sequence: ev.packet.sequence.into(), }, RawIbcEvent::TimeoutOnClosePacket(ev) => IbcEvent::TimeoutOnClosePacket { revision_height: ev.height().revision_height, revision_number: ev.height().revision_number, - channel_id: ev.src_channel_id().to_string().as_bytes().to_vec(), + channel_id: ev.src_channel_id().to_string().into_bytes(), port_id: ev.src_port_id().as_bytes().to_vec(), sequence: ev.packet.sequence.into(), }, @@ -436,7 +426,7 @@ impl From for IbcEvent { RawIbcEvent::ChainError(_) => IbcEvent::ChainError, RawIbcEvent::AppModule(ev) => IbcEvent::AppModule { kind: ev.kind.as_bytes().to_vec(), - module_id: ev.module_name.to_string().as_bytes().to_vec(), + module_id: ev.module_name.to_string().into_bytes(), }, RawIbcEvent::PushWasmCode(ev) => { let wasm_checksum = ev.0; diff --git a/contracts/pallet-ibc/src/ics20/mod.rs b/contracts/pallet-ibc/src/ics20/mod.rs index c46a0d4f2..89a407e51 100644 --- a/contracts/pallet-ibc/src/ics20/mod.rs +++ b/contracts/pallet-ibc/src/ics20/mod.rs @@ -127,7 +127,7 @@ where _relayer: &Signer, ) -> Result<(), Ics04Error> { let _ = ChannelIds::::try_mutate::<_, (), _>(|channels| { - channels.push(channel_id.to_string().as_bytes().to_vec()); + channels.push(channel_id.to_string().into_bytes()); Ok(()) }); let mut ctx = Context::::default(); @@ -144,7 +144,7 @@ where _relayer: &Signer, ) -> Result<(), Ics04Error> { let _ = ChannelIds::::try_mutate::<_, (), _>(|channels| { - channels.push(channel_id.to_string().as_bytes().to_vec()); + channels.push(channel_id.to_string().into_bytes()); Ok(()) }); let mut ctx = Context::::default(); @@ -161,11 +161,8 @@ where _relayer: &Signer, ) -> Result<(), Ics04Error> { let _ = ChannelIds::::try_mutate::<_, (), _>(|channels| { - let rem = channels - .iter() - .filter(|chan| chan.as_slice() != channel_id.to_string().as_bytes()) - .cloned() - .collect(); + let channel_id = channel_id.to_string().into_bytes(); + let rem = channels.iter().filter(|chan| **chan != channel_id).cloned().collect(); *channels = rem; Ok(()) }); @@ -185,11 +182,8 @@ where _relayer: &Signer, ) -> Result<(), Ics04Error> { let _ = ChannelIds::::try_mutate::<_, (), _>(|channels| { - let rem = channels - .iter() - .filter(|chan| chan.as_slice() != channel_id.to_string().as_bytes()) - .cloned() - .collect(); + let channel_id = channel_id.to_string().into_bytes(); + let rem = channels.iter().filter(|chan| **chan != channel_id).cloned().collect(); *channels = rem; Ok(()) }); @@ -270,8 +264,8 @@ where packet.source_channel, &prefixed_denom, ), - source_channel: packet.source_channel.to_string().as_bytes().to_vec(), - destination_channel: packet.destination_channel.to_string().as_bytes().to_vec(), + source_channel: packet.source_channel.to_string().into_bytes(), + destination_channel: packet.destination_channel.to_string().into_bytes(), }); let packet = packet.clone(); Pallet::::handle_message(HandlerMessage::WriteAck { @@ -318,7 +312,7 @@ where Pallet::::deposit_event(Event::::TokenTransferCompleted { from: packet_data.sender, to: packet_data.receiver, - ibc_denom: packet_data.token.denom.to_string().as_bytes().to_vec(), + ibc_denom: packet_data.token.denom.to_string().into_bytes(), local_asset_id: T::IbcDenomToAssetIdConversion::from_denom_to_asset_id( &packet_data.token.denom.to_string(), ) @@ -329,8 +323,8 @@ where packet.source_channel, &packet_data.token.denom, ), - source_channel: packet.source_channel.to_string().as_bytes().to_vec(), - destination_channel: packet.destination_channel.to_string().as_bytes().to_vec(), + source_channel: packet.source_channel.to_string().into_bytes(), + destination_channel: packet.destination_channel.to_string().into_bytes(), }) }, Err(e) => { @@ -346,7 +340,7 @@ where Pallet::::deposit_event(Event::::TokenTransferFailed { from: packet_data.sender, to: packet_data.receiver, - ibc_denom: packet_data.token.denom.to_string().as_bytes().to_vec(), + ibc_denom: packet_data.token.denom.to_string().into_bytes(), local_asset_id: T::IbcDenomToAssetIdConversion::from_denom_to_asset_id( &packet_data.token.denom.to_string(), ) @@ -357,8 +351,8 @@ where packet.source_channel, &packet_data.token.denom, ), - source_channel: packet.source_channel.to_string().as_bytes().to_vec(), - destination_channel: packet.destination_channel.to_string().as_bytes().to_vec(), + source_channel: packet.source_channel.to_string().into_bytes(), + destination_channel: packet.destination_channel.to_string().into_bytes(), }) }, } @@ -385,7 +379,7 @@ where Pallet::::deposit_event(Event::::TokenTransferTimeout { from: packet_data.sender, to: packet_data.receiver, - ibc_denom: packet_data.token.denom.to_string().as_bytes().to_vec(), + ibc_denom: packet_data.token.denom.to_string().into_bytes(), local_asset_id: T::IbcDenomToAssetIdConversion::from_denom_to_asset_id( &packet_data.token.denom.to_string(), ) @@ -396,8 +390,8 @@ where packet.source_channel, &packet_data.token.denom, ), - source_channel: packet.source_channel.to_string().as_bytes().to_vec(), - destination_channel: packet.destination_channel.to_string().as_bytes().to_vec(), + source_channel: packet.source_channel.to_string().into_bytes(), + destination_channel: packet.destination_channel.to_string().into_bytes(), }); Ok(()) } diff --git a/contracts/pallet-ibc/src/ics23/channels.rs b/contracts/pallet-ibc/src/ics23/channels.rs index fc0e56c6a..b457aa17a 100644 --- a/contracts/pallet-ibc/src/ics23/channels.rs +++ b/contracts/pallet-ibc/src/ics23/channels.rs @@ -48,7 +48,7 @@ impl Channels { { return Some(( port_id.as_bytes().to_vec(), - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), value, )) } diff --git a/contracts/pallet-ibc/src/impls.rs b/contracts/pallet-ibc/src/impls.rs index 5106b40a6..2e5eb4f25 100644 --- a/contracts/pallet-ibc/src/impls.rs +++ b/contracts/pallet-ibc/src/impls.rs @@ -507,7 +507,7 @@ where key: (PortId, ChannelId, Sequence), ack: Vec, ) -> Result<(), Error> { - let channel_id = key.1.to_string().as_bytes().to_vec(); + let channel_id = key.1.to_string().into_bytes(); let port_id = key.0.as_bytes().to_vec(); let seq = u64::from(key.2); diff --git a/contracts/pallet-ibc/src/lib.rs b/contracts/pallet-ibc/src/lib.rs index 25562ae9f..028b6b95d 100644 --- a/contracts/pallet-ibc/src/lib.rs +++ b/contracts/pallet-ibc/src/lib.rs @@ -961,9 +961,9 @@ pub mod pallet { &coin.denom.to_string(), ) .ok(), - ibc_denom: coin.denom.to_string().as_bytes().to_vec(), - source_channel: source_channel.to_string().as_bytes().to_vec(), - destination_channel: destination_channel.to_string().as_bytes().to_vec(), + ibc_denom: coin.denom.to_string().into_bytes(), + source_channel: source_channel.to_string().into_bytes(), + destination_channel: destination_channel.to_string().into_bytes(), }); }; @@ -1047,10 +1047,10 @@ pub mod pallet { &coin.denom.to_string(), ) .ok(), - ibc_denom: coin.denom.to_string().as_bytes().to_vec(), + ibc_denom: coin.denom.to_string().into_bytes(), is_sender_source, - source_channel: source_channel.to_string().as_bytes().to_vec(), - destination_channel: destination_channel.to_string().as_bytes().to_vec(), + source_channel: source_channel.to_string().into_bytes(), + destination_channel: destination_channel.to_string().into_bytes(), }); Ok(()) } diff --git a/contracts/pallet-ibc/src/tests.rs b/contracts/pallet-ibc/src/tests.rs index 06e5db256..fcc25439f 100644 --- a/contracts/pallet-ibc/src/tests.rs +++ b/contracts/pallet-ibc/src/tests.rs @@ -254,7 +254,7 @@ fn send_transfer() { let channel_id = ChannelId::new(0); let port_id = PortId::transfer(); let packet_info = Pallet::::get_send_packet_info( - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), port_id.as_bytes().to_vec(), vec![1], ) @@ -384,7 +384,7 @@ fn send_transfer_no_fee_feeless_channels() { let channel_id = ChannelId::new(0); let port_id = PortId::transfer(); let packet_info = Pallet::::get_send_packet_info( - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), port_id.as_bytes().to_vec(), vec![1], ) @@ -782,7 +782,7 @@ fn on_ack_transfer_with_custom_success_result() { )); let packet_info = Ibc::get_send_packet_info( - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), PortId::transfer().as_bytes().to_vec(), vec![1], ) @@ -1087,7 +1087,7 @@ fn should_fetch_recv_packet_with_acknowledgement() { let channel_id = ChannelId::new(0); let port_id = PortId::transfer(); let packet_info = Pallet::::get_recv_packet_info( - channel_id.to_string().as_bytes().to_vec(), + channel_id.to_string().into_bytes(), port_id.as_bytes().to_vec(), vec![1], ) @@ -1174,7 +1174,7 @@ fn should_cleanup_offchain_packets_correctly() { }); ext.execute_with(|| { - let channel_id_bytes = channel_id.to_string().as_bytes().to_vec(); + let channel_id_bytes = channel_id.to_string().into_bytes(); let port_id_bytes = port_id.as_bytes().to_vec(); let (send_seq_set, _) = @@ -1193,7 +1193,7 @@ fn should_cleanup_offchain_packets_correctly() { }); ext.execute_with(|| { - let channel_id_bytes = channel_id.to_string().as_bytes().to_vec(); + let channel_id_bytes = channel_id.to_string().into_bytes(); let port_id_bytes = port_id.as_bytes().to_vec(); let (send_seq_set, last_removed_send) = @@ -1225,7 +1225,7 @@ fn should_cleanup_offchain_packets_correctly() { }); ext.execute_with(|| { - let channel_id_bytes = channel_id.to_string().as_bytes().to_vec(); + let channel_id_bytes = channel_id.to_string().into_bytes(); let port_id_bytes = port_id.as_bytes().to_vec(); let (send_seq_set, last_removed_send) = diff --git a/hyperspace/README.md b/hyperspace/README.md index e846a776c..36a17aff2 100644 --- a/hyperspace/README.md +++ b/hyperspace/README.md @@ -154,7 +154,26 @@ these chunks are then submitted as individual transactions. ### How to build Hyperspace +In order to deploy a relayer, there are some things to install first: + +1. Install [go](https://go.dev/doc/install) + +2. Install [rust](https://rustup.rs/) + +3. Install Protobuf --> + +``` +curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v24.2/protoc-24.2-linux-x86_64.zip && \ +unzip protoc-24.2-linux-x86_64.zip -d /usr/local/protoc && \ +export PATH=$PATH:/usr/local/protoc/bin +``` + +4. Install clang, solc, rocksdb (this can be installed through apt) + +Then, run: + ``` +cd hyperspace/ make build-release-hyperspace ``` @@ -185,6 +204,118 @@ A template configuration file (which is needed to run the CLI) can be found between both chains. The config file must have a valid client and connection id. +### Configuration + +1. Compile the WASM file using `cargo +nightly-2023-02-07 build -p ics10-grandpa-cw --release --target wasm32-unknown-unknown --lib --no-default-features` (install the toolchain if needed). + +2. How to create a [`gov`](https://www.youtube.com/watch?v=leFIbW9e2zY) proposal + +- Generate draft gov proposal +``` +centaurid tx gov draft-proposal +``` + +- submit gov proposal +``` +# centaurid tx gov submit-proposal /home/ubuntu/draft_proposal.json --from validator --fees=300ppica +``` + +- list governance proposals +``` +# centaurid q gov proposals +``` + +- vote "yes" for gov proposal (`id=3`) + +``` +# centaurid tx gov vote 3 yes --from validator --fees=300ppica +``` + +- check votes for gov proposal (`id=3`) +``` +# centaurid q gov votes 3 +``` + +3. You will need two config files in order to start the relayer. In the following example you will have a config file for `centauri` and for `picasso`: + +The following is a template for banksy-testnet-5 +``` +type = "cosmos" +name = "banksy" +rpc_url = "https://rpc-testnet5.composable-cosmos.composablenodes.tech/" +grpc_url = "https://api-testnet5.composable-cosmos.composablenodes.tech" +websocket_url = "ws://rpc-testnet5.composable-cosmos.composablenodes.tech/websocket" +chain_id = "banksy-testnet-5" +client_id = "07-tendermint-0" +connection_id = "connection-2" +account_prefix = "centauri" +fee_denom = "ppica" +fee_amount = "4000" +gas_limit = 9223372036854775806 +store_prefix = "ibc" +max_tx_size = 200000 +wasm_code_id = "here_goes_the_wasm_code_id" +channel_whitelist = [["channel-2", "transfer"]] +mnemonic = "mnemonic phrase example ....." +skip_optional_client_updates = true +max_packets_to_process = 200 +``` + +The following is a template of composable-mainnet + +``` +type = "cosmos" +name = "composable" +rpc_url = "wss://rpc.composable.finance" +grpc_url = "wss://polkadot-rpc.dwellir.com" +websocket_url = "ws://rpc.composable.finance/websocket" +chain_id = "centauri-1" +client_id = "07-tendermint-32" +connection_id = "connection-5" +account_prefix = "centauri" +fee_denom = "ppica" +fee_amount = "1500000" +gas_limit = 10000000000 +store_prefix = "ibc" +max_tx_size = 20000000 +wasm_code_id = "HERE IS THE WASM CODE" +channel_whitelist = [["channel-2", "transfer"]] +mnemonic = "mnemonic phrase example" +skip_optional_client_updates = true +skip_tokens_list = [] +``` + +The following is a template of picasso mainnet + +``` +chain_id = "picasso_kusama" +type = "picasso_kusama" +name = "picasso" +para_id = 2087 +parachain_rpc_url = "wss://rpc.composablenodes.tech" +relay_chain_rpc_url = "wss://kusama-rpc.dwellir.com" +client_id = "10-grandpa-28" +connection_id = "connection-23" +channel_whitelist = [["channel-15", "transfer"]] +commitment_prefix = "0x6962632f" +private_key = "here goes the private key" +ss58_version = 49 +key_type = "sr25519" +finality_protocol = "Grandpa" +``` + +4. Upload the contract +``` +hyperspace upload-wasm --config picasso-local.toml --wasm-path ics10-grandpa-cw +``` + +or + +``` +centaurid tx 08-wasm push-wasm ics10-grandpa-cw --keyring-backend test --gas auto --fees 1000016pica -y --from mykey +``` + +5. Build the [`connection`](./contract.toml) ### Metrics diff --git a/light-clients/cf-guest-cw/Cargo.toml b/light-clients/cf-guest-cw/Cargo.toml new file mode 100644 index 000000000..17cf12c2e --- /dev/null +++ b/light-clients/cf-guest-cw/Cargo.toml @@ -0,0 +1,57 @@ +[package] +name = "cf-guest-cw" +version = "0.0.0" +authors = ["Michal Nazarewicz "] +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", +] + +[lib] +crate-type = ["cdylib", "rlib"] + +[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.6 +""" + +[dependencies] +cf-guest = { git = "https://github.com/ComposableFi/emulated-light-client/", default-features = false } +guestchain = { git = "https://github.com/ComposableFi/emulated-light-client/", default-features = false } + +base64 = { version = "0.22", default-features = false, features = ["alloc"] } +borsh = { version = "0.10.3", default-features = false } +cosmwasm-schema = "1.5.3" +cosmwasm-std = "1.5.3" +derive_more = "0.99.17" +ed25519-dalek = { version = "2.1.1", default-features = false, features = ["pkcs8"] } + +# Same version emulated-light-client uses +ibc = { git = "https://github.com/cosmos/ibc-rs", rev = "6dd3c6465e594d4c177f21724dd896a15e8f3634", default-features = false, features = ["borsh", "serde"] } + +prost = { version = "0.12.3", default-features = false } +schemars = "0.8.10" +serde = { version = "1.0.145", default-features = false, features = ["derive"] } +sha2 = "0.10" + +[features] +# for more explicit tests, cargo test --features=backtraces +backtraces = ["cosmwasm-std/backtraces"] +# use library feature to disable all instantiate/execute/query exports +library = [] +default = [] +std = [ + "base64/std", + "ed25519-dalek/std", + "ibc/std", + "prost/std", + "serde/std", + "sha2/std", +] diff --git a/light-clients/cf-guest-cw/src/bin/schema.rs b/light-clients/cf-guest-cw/src/bin/schema.rs new file mode 100644 index 000000000..fa9bda8c3 --- /dev/null +++ b/light-clients/cf-guest-cw/src/bin/schema.rs @@ -0,0 +1,25 @@ +// 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 cf_guest_cw::msg; +use cosmwasm_schema::write_api; + +fn main() { + write_api! { + instantiate: msg::InstantiateMsg, + sudo: msg::SudoMsg, + query: msg::QueryMsg, + } +} diff --git a/light-clients/cf-guest-cw/src/context.rs b/light-clients/cf-guest-cw/src/context.rs new file mode 100644 index 000000000..c979eafc6 --- /dev/null +++ b/light-clients/cf-guest-cw/src/context.rs @@ -0,0 +1,182 @@ +// 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 core::str::FromStr; + +use cosmwasm_std::{Api, Deps, DepsMut, Env, Storage}; + +use crate::{ibc, state}; + +type Result = core::result::Result; + +/// Base context for handling CosmWasm operations. +/// +/// It wraps together access to CosmWasm API and information about the request +/// such as block height, current time and IBC client id corresponding to this +/// contract. +/// +/// The object dereferences into [`state::Metadata`] such that metadata fields +/// are directly accessible through this object. +#[derive(derive_more::Deref)] +pub(crate) struct ContextBase<'a> { + #[deref] + pub metadata: state::Metadata, + pub client_id: ibc::ClientId, + pub api: &'a dyn Api, +} + +/// Mutable execution context for handling CosmWasm operations. +/// +/// It wraps together access to CosmWasm APIs, storage and information about the +/// request. To construct a new context object use [`new`] function. +#[derive(derive_more::Deref)] +pub(crate) struct ContextMut<'a> { + #[deref] + base: ContextBase<'a>, + storage: &'a mut dyn Storage, +} + +/// Constructs a new mutable execution context. +pub(crate) fn new<'a>(deps: DepsMut<'a>, env: Env) -> ContextMut<'a> { + ContextMut { base: ContextBase::new(env, deps.api), storage: deps.storage } +} + +/// Read-only execution context for handling CosmWasm operations. +/// +/// It wraps together access to CosmWasm APIs, storage and information about the +/// request. To construct a new context object use [`new_ro`] function. +/// +/// The object dereferences into [`ContextBase`] which holds data common between +/// read-only and mutable execution contexts. +#[derive(derive_more::Deref)] +pub(crate) struct Context<'a> { + #[deref] + base: ContextBase<'a>, + storage: &'a dyn Storage, +} + +/// Constructs a new read-only execution context. +pub(crate) fn new_ro<'a>(deps: Deps<'a>, env: Env) -> Context<'a> { + Context { base: ContextBase::new(env, deps.api), storage: deps.storage } +} + +impl<'a> ContextBase<'a> { + fn new(env: Env, api: &'a dyn Api) -> Self { + let metadata = state::Metadata { + host_timestamp_ns: env.block.time.nanos(), + host_height: env.block.height, + }; + let address = env.contract.address.as_str(); + let client_id = ibc::ClientId::from_str(address).unwrap(); + Self { client_id, metadata, api } + } + + pub fn log(&self, msg: impl alloc::string::ToString) { + self.api.debug(&msg.to_string()) + } +} + +/// Logs formatted text using CosmWasm API. +/// +/// To log string literals prefer [`ContextBase::log`] method. +macro_rules! log { + ($self:expr, $($tt:tt)*) => { + $self.log(format_args!($($tt)*)) + }; +} + +pub(crate) use log; + +impl<'a> Context<'a> { + /// Reads this light client’s client state from storage. + pub fn client_state(&self) -> Result { + req_client_state(&self.client_id, self.client_states().get()) + } + + /// Returns object providing access to read client state from the + /// storage. + pub fn client_states(&self) -> &'a state::ClientStates { + state::ClientStates::new_ro(self.storage) + } + + /// Reads this light client’s consensus state at given height from + /// storage. + pub fn consensus_state(&self, height: ibc::Height) -> Result { + req_consensus_state(&self.client_id, height, self.consensus_states().get(height)) + } + + /// Returns object providing access to read consensus states from the + /// storage. + pub fn consensus_states(&self) -> &'a state::ConsensusStates { + state::ConsensusStates::new_ro(self.storage) + } +} + +impl<'a> ContextMut<'a> { + /// Reads this light client’s client state from storage. + pub fn client_state(&self) -> Result { + req_client_state(&self.client_id, self.client_states().get()) + } + + /// Returns object providing access to read client state from the + /// storage. + pub fn client_states(&self) -> &state::ClientStates { + state::ClientStates::new_ro(self.storage) + } + + /// Returns object providing access to read or write client state + /// from/to the storage. + pub fn client_states_mut(&mut self) -> &mut state::ClientStates { + state::ClientStates::new(self.storage) + } + + /// Reads this light client’s consensus state at given height from + /// storage. + pub fn consensus_state(&self, height: ibc::Height) -> Result { + req_consensus_state(&self.client_id, height, self.consensus_states().get(height)) + } + + /// Returns object providing access to read consensus states from the + /// storage. + pub fn consensus_states(&self) -> &state::ConsensusStates { + state::ConsensusStates::new_ro(self.storage) + } + + /// Returns object providing access to read or write consensus states + /// from/to the storage. + pub fn consensus_states_mut(&mut self) -> &mut state::ConsensusStates { + state::ConsensusStates::new(self.storage) + } +} + +/// Returns an error if client state is not present. +fn req_client_state( + client_id: &ibc::ClientId, + state: Result>, +) -> Result { + let make_err = || ibc::ClientError::ClientStateNotFound { client_id: client_id.clone() }.into(); + state.and_then(|state| state.ok_or_else(make_err)) +} + +/// Returns an error if consensus state is not present. +fn req_consensus_state( + client_id: &ibc::ClientId, + height: ibc::Height, + state: Result>, +) -> Result { + let make_err = + || ibc::ClientError::ConsensusStateNotFound { client_id: client_id.clone(), height }.into(); + state.and_then(|state| state.map(|(state, _metadata)| state).ok_or_else(make_err)) +} diff --git a/light-clients/cf-guest-cw/src/contract.rs b/light-clients/cf-guest-cw/src/contract.rs new file mode 100644 index 000000000..d68a1c57f --- /dev/null +++ b/light-clients/cf-guest-cw/src/contract.rs @@ -0,0 +1,149 @@ +// 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 cosmwasm_std::{ + to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, Uint64, +}; +use prost::Message; + +use crate::{context, context::log, crypto::Verifier, ibc, msg, state}; + +type Result = core::result::Result; + +#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)] +fn instantiate( + deps: DepsMut, + env: Env, + _info: MessageInfo, + msg: msg::InstantiateMsg, +) -> Result { + let mut ctx = context::new(deps, env); + log!(ctx, "instantiate: {msg:?}"); + + ctx.client_states_mut().set(&msg.client_state); + + let height = ibc::Height::new(0, msg.client_state.latest_height.into()).unwrap(); + let metadata = ctx.metadata; + ctx.consensus_states_mut().set(height, &msg.consensus_state, metadata); + + Ok(Response::default()) +} + +#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)] +fn sudo(deps: DepsMut, env: Env, msg: msg::SudoMsg) -> Result { + let mut ctx = context::new(deps, env); + log!(ctx, "sudo({msg:?})"); + match msg { + msg::SudoMsg::UpdateStateOnMisbehaviour(_msg) => { + let client_state = ctx.client_state()?.frozen(); + ctx.client_states_mut().set(client_state); + }, + msg::SudoMsg::UpdateState(msg) => process_update_state_msg(ctx, msg)?, + } + Ok(Response::default()) +} + +fn process_update_state_msg(mut ctx: context::ContextMut, msg: msg::UpdateStateMsg) -> Result { + let client_state = ctx.client_state()?; + let now_ns = ctx.host_timestamp_ns; + + ctx.consensus_states_mut().prune_oldest_consensus_state(&client_state, now_ns)?; + + let new_consensus_state = state::ConsensusState::from(&msg.header); + let new_client_state = client_state.with_header(&msg.header); + + let metadata = ctx.metadata; + let height = ibc::Height::new(0, msg.header.block_header.block_height.into())?; + ctx.client_states_mut().set(&new_client_state); + ctx.consensus_states_mut().set(height, &new_consensus_state, metadata); + Ok(()) +} + +#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)] +fn query(deps: Deps, env: Env, msg: msg::QueryMsg) -> StdResult { + let ctx = context::new_ro(deps, env); + match msg { + msg::QueryMsg::VerifyClientMessage(msg) => { + query_verify_client_msg(ctx, msg)?; + to_json_binary(&()) + }, + msg::QueryMsg::CheckForMisbehaviour(msg) => { + let res = query_check_for_misbehaviour_msg(ctx, msg)?; + to_json_binary(&res) + }, + msg::QueryMsg::VerifyStateProof(msg) => { + query_verify_state_proof(ctx, msg)?; + to_json_binary(&()) + }, + msg::QueryMsg::Status(msg::StatusMsg {}) => to_json_binary(&query_status(ctx)?), + msg::QueryMsg::TimestampAtHeight(msg) => { + let state = ctx.consensus_state(msg.height)?; + to_json_binary(&Uint64::from(state.timestamp_ns.get())) + }, + msg::QueryMsg::ExportMetadata(msg::ExportMetadataMsg {}) => { + let meta = ctx.consensus_states().get_all_metadata()?; + to_json_binary(&meta) + }, + } +} + +fn query_verify_state_proof(ctx: context::Context, msg: msg::VerifyStateProofMsg) -> StdResult<()> { + let consensus_state = ctx.consensus_state(msg.height)?; + cf_guest::proof::verify( + &ibc::CommitmentPrefix::default(), + &msg.proof, + &consensus_state.block_hash, + msg.path, + msg.value.as_deref(), + ) + .map_err(|err| StdError::GenericErr { msg: err.to_string() }) +} + +fn query_verify_client_msg(ctx: context::Context, msg: msg::VerifyClientMessageMsg) -> Result { + let client_message = + ibc::proto::Any::decode(msg.client_message.as_slice()).map_err(crate::Error::from)?; + ctx.client_state()? + .verify_client_message(&Verifier, &ctx.client_id, client_message) + .map_err(crate::Error::from) +} + +fn query_check_for_misbehaviour_msg( + ctx: context::Context, + msg: msg::CheckForMisbehaviourMsg, +) -> Result { + let client_message = + ibc::proto::Any::decode(msg.client_message.as_slice()).map_err(crate::Error::from)?; + ctx.client_state()? + .check_for_misbehaviour(&Verifier, &ctx.client_id, client_message) + .map_err(crate::Error::from) +} + +fn query_status(ctx: context::Context) -> StdResult { + let client_state = ctx.client_state()?; + if client_state.is_frozen { + return Ok(msg::StatusResponse::Frozen) + } + + let height = client_state.latest_height; + let height = ibc::Height::new(0, height.into()).unwrap(); + let consensus_state = ctx.consensus_state(height)?; + + let age = ctx.host_timestamp_ns.saturating_sub(consensus_state.timestamp_ns.get()); + Ok(if age >= client_state.trusting_period_ns { + msg::StatusResponse::Expired + } else { + msg::StatusResponse::Active + }) +} diff --git a/light-clients/cf-guest-cw/src/crypto.rs b/light-clients/cf-guest-cw/src/crypto.rs new file mode 100644 index 000000000..c4ff05a2e --- /dev/null +++ b/light-clients/cf-guest-cw/src/crypto.rs @@ -0,0 +1,107 @@ +use borsh::maybestd::io; + +/// Ed25519 public key (a.k.a. verifying key). +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +#[repr(transparent)] +pub struct PubKey(ed25519_dalek::VerifyingKey); + +impl guestchain::PubKey for PubKey { + type Signature = Signature; + + fn to_vec(&self) -> Vec { + self.0.as_bytes().to_vec() + } + fn from_bytes(bytes: &[u8]) -> Result { + bytes.try_into().map(Self).map_err(|_| guestchain::BadFormat) + } +} + +impl borsh::BorshSerialize for PubKey { + fn serialize(&self, wr: &mut W) -> io::Result<()> { + wr.write_all(self.0.as_bytes()) + } +} + +impl borsh::BorshDeserialize for PubKey { + fn deserialize_reader(rd: &mut R) -> io::Result { + let mut bytes = ed25519_dalek::pkcs8::PublicKeyBytes([0; 32]); + rd.read_exact(&mut bytes.0[..])?; + ed25519_dalek::VerifyingKey::try_from(bytes) + .map(Self) + .map_err(|_| io::Error::new(io::ErrorKind::Other, "malformed Ed25519 public key")) + } +} + +impl PartialOrd for PubKey { + fn partial_cmp(&self, rhs: &Self) -> Option { + Some(self.cmp(rhs)) + } +} + +impl Ord for PubKey { + fn cmp(&self, rhs: &Self) -> core::cmp::Ordering { + self.0.as_bytes().cmp(rhs.0.as_bytes()) + } +} + +/// Ed25519 signature. +#[derive(Clone, PartialEq, Eq, Debug)] +#[repr(transparent)] +pub struct Signature(ed25519_dalek::Signature); + +impl guestchain::Signature for Signature { + fn to_vec(&self) -> Vec { + self.0.to_vec() + } + fn from_bytes(bytes: &[u8]) -> Result { + ed25519_dalek::Signature::from_slice(bytes) + .map(Self) + .map_err(|_| guestchain::BadFormat) + } +} + +impl borsh::BorshSerialize for Signature { + fn serialize(&self, wr: &mut W) -> io::Result<()> { + wr.write_all(self.0.r_bytes())?; + wr.write_all(self.0.s_bytes())?; + Ok(()) + } +} + +impl borsh::BorshDeserialize for Signature { + fn deserialize_reader(rd: &mut R) -> io::Result { + let mut buf = [0; 64]; + rd.read_exact(&mut buf[..])?; + Ok(Self(ed25519_dalek::Signature::from_bytes(&buf))) + } +} + +impl core::hash::Hash for Signature { + fn hash(&self, hasher: &mut H) { + hasher.write(self.0.r_bytes()); + hasher.write(self.0.s_bytes()); + } +} + +impl PartialOrd for Signature { + fn partial_cmp(&self, rhs: &Self) -> Option { + Some(self.cmp(rhs)) + } +} + +impl Ord for Signature { + fn cmp(&self, rhs: &Self) -> core::cmp::Ordering { + let lhs = (self.0.r_bytes(), self.0.s_bytes()); + let rhs = (rhs.0.r_bytes(), rhs.0.s_bytes()); + lhs.cmp(&rhs) + } +} + +/// Verifier for Ed25519 signatures using ed25519-dalek implementation. +pub(crate) struct Verifier; + +impl guestchain::Verifier for Verifier { + fn verify(&self, message: &[u8], pubkey: &PubKey, signature: &Signature) -> bool { + pubkey.0.verify_strict(message, &signature.0).is_ok() + } +} diff --git a/light-clients/cf-guest-cw/src/error.rs b/light-clients/cf-guest-cw/src/error.rs new file mode 100644 index 000000000..a5e812f76 --- /dev/null +++ b/light-clients/cf-guest-cw/src/error.rs @@ -0,0 +1,56 @@ +// 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 cosmwasm_std::StdError; + +#[derive(Debug, derive_more::From, derive_more::Display)] +pub enum Error { + Std(StdError), + Client(crate::ibc::ClientError), + Wasm(crate::ibc::wasm::Error), + BadProto(prost::DecodeError), + #[from(ignore)] + BadMessage, + #[from(ignore)] + BadType, +} + +#[cfg(feature = "std")] +impl std::error::Error for Error {} + +impl From for Error { + fn from(err: alloc::string::FromUtf8Error) -> Self { + Self::Std(StdError::InvalidUtf8 { msg: err.to_string() }) + } +} + +impl From for Error { + fn from(err: cf_guest::DecodeError) -> Self { + match err { + cf_guest::DecodeError::BadMessage => Self::BadMessage, + cf_guest::DecodeError::BadType => Self::BadType, + cf_guest::DecodeError::BadProto(err) => err.into(), + } + } +} + +impl From for StdError { + fn from(err: Error) -> Self { + match err { + Error::Std(err) => err, + _ => StdError::GenericErr { msg: err.to_string() }, + } + } +} diff --git a/light-clients/cf-guest-cw/src/ibc.rs b/light-clients/cf-guest-cw/src/ibc.rs new file mode 100644 index 000000000..3a7170bf5 --- /dev/null +++ b/light-clients/cf-guest-cw/src/ibc.rs @@ -0,0 +1,16 @@ +//! A helper module which collects IBC types we’re using in a flatter namespace. + +pub mod wasm { + pub use ibc::clients::wasm_types::{ + client_state::ClientState, consensus_state::ConsensusState, error::Error, + }; +} + +pub use ibc::{ + core::{ + client::{context::types::error::ClientError, types::Height}, + commitment_types::commitment::{CommitmentPrefix, CommitmentProofBytes}, + host::types::{identifiers::ClientId, path}, + }, + primitives::{proto, Timestamp}, +}; diff --git a/light-clients/cf-guest-cw/src/lib.rs b/light-clients/cf-guest-cw/src/lib.rs new file mode 100644 index 000000000..61a97abcf --- /dev/null +++ b/light-clients/cf-guest-cw/src/lib.rs @@ -0,0 +1,30 @@ +// 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. + +#![allow(dead_code)] + +extern crate alloc; +extern crate core; + +mod context; +mod contract; +mod crypto; +mod error; +mod ibc; +pub mod msg; +mod serialisation; +pub mod state; + +use crate::{crypto::PubKey, error::Error}; diff --git a/light-clients/cf-guest-cw/src/msg.rs b/light-clients/cf-guest-cw/src/msg.rs new file mode 100644 index 000000000..ce84d4ba6 --- /dev/null +++ b/light-clients/cf-guest-cw/src/msg.rs @@ -0,0 +1,150 @@ +// 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 cosmwasm_schema::{cw_serde, QueryResponses}; +use cosmwasm_std::Uint64; + +use crate::{ibc, serialisation, state}; + +#[cw_serde] +pub struct InstantiateMsg { + #[serde(with = "serialisation::Base64")] + pub client_state: state::ClientState, + #[serde(with = "serialisation::Base64")] + pub consensus_state: state::ConsensusState, +} + +#[cw_serde] +pub enum SudoMsg { + //MigrateClientStore(MigrateClientStoreMsg), + UpdateState(UpdateStateMsg), + UpdateStateOnMisbehaviour(UpdateStateOnMisbehaviourMsg), + // VerifyUpgradeAndUpdateState(VerifyUpgradeAndUpdateStateMsg), +} + +// #[cw_serde] +// pub struct MigrateClientStoreMsg {} + +#[cw_serde] +pub struct UpdateStateMsg { + #[serde(with = "serialisation::Base64")] + pub header: state::Header, +} + +#[cw_serde] +pub struct UpdateStateOnMisbehaviourMsg { + #[serde(with = "serialisation::Base64")] + pub misbehaviour_message: state::Misbehaviour, +} + +// #[cw_serde] +// pub struct VerifyUpgradeAndUpdateStateMsg { +// #[serde(with = "serialisation::Base64")] +// pub upgrade_client_state: state::ClientState, +// #[serde(with = "serialisation::Base64")] +// pub upgrade_consensus_state: state::ConsensusState, +// #[serde(with = "serialisation::Base64")] +// pub proof_upgrade_client: ibc::CommitmentProofBytes, +// #[serde(with = "serialisation::Base64")] +// pub proof_upgrade_consensus_state: ibc::CommitmentProofBytes, +// } + +#[cw_serde] +#[derive(QueryResponses)] +pub enum QueryMsg { + /// Verifies client message. + #[returns(())] + VerifyClientMessage(VerifyClientMessageMsg), + + /// Checks client message for misbehaviour. + #[returns(bool)] + CheckForMisbehaviour(CheckForMisbehaviourMsg), + + /// Checks whether provided membership or non-membership proof is valid. + /// + /// The proof is a membership proof is `self.0.value` field is `Some`. + /// Otherwise, if `self.0.value` is `None`, the proof is non-membership + /// proof. + #[returns(())] + VerifyStateProof(VerifyStateProofMsg), + + /// Checks status of the client. + #[returns(StatusResponse)] + Status(StatusMsg), + + /// Returns timestamp for consensus at given height. + /// + /// The timestamp is represented as nanoseconds since Unix epoch. + #[returns(Uint64)] + TimestampAtHeight(TimestampAtHeightMsg), + + /// Gets metadata of all consensus states. + #[returns(Vec)] + ExportMetadata(ExportMetadataMsg), +} + +#[cw_serde] +pub struct VerifyClientMessageMsg { + #[serde(with = "serialisation::Base64")] + pub client_message: Vec, +} + +#[cw_serde] +pub struct CheckForMisbehaviourMsg { + #[serde(with = "serialisation::Base64")] + pub client_message: Vec, +} + +#[cw_serde] +pub struct VerifyStateProofMsg { + #[serde(with = "serialisation::Base64")] + pub proof: ibc::CommitmentProofBytes, + #[serde(with = "serialisation::AsStr")] + pub path: ibc::path::Path, + #[serde(with = "serialisation::OptBase64", default, skip_serializing_if = "Option::is_none")] + pub value: Option>, + #[serde(with = "serialisation::Height")] + pub height: ibc::Height, +} + +#[cw_serde] +pub struct StatusMsg {} + +#[cw_serde] +pub enum StatusResponse { + Active, + Expired, + Frozen, +} + +#[cw_serde] +pub struct GetLatestHeightsMsg {} + +#[cw_serde] +pub struct TimestampAtHeightMsg { + #[serde(with = "serialisation::Height")] + pub height: ibc::Height, +} + +#[cw_serde] +pub struct ExportMetadataMsg {} + +#[cw_serde] +pub struct ConsensusStateMetadata { + #[serde(with = "serialisation::Height")] + pub height: ibc::Height, + pub host_timestamp_ns: Uint64, + pub host_height: Uint64, +} diff --git a/light-clients/cf-guest-cw/src/serialisation.rs b/light-clients/cf-guest-cw/src/serialisation.rs new file mode 100644 index 000000000..881b7acd1 --- /dev/null +++ b/light-clients/cf-guest-cw/src/serialisation.rs @@ -0,0 +1,268 @@ +use core::{fmt, marker::PhantomData, str::FromStr}; + +use cosmwasm_std::Binary; +use prost::Message; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +use crate::{ibc, state}; + +/// A Serde serialisation implementation which encodes binary data as +/// base64-string (when serialising to human-readable form). +pub struct Base64; + +/// A Serde serialisation implementation handling `Option` values where `T` +/// can be serialised using [`Base64`]. +pub struct OptBase64; + +/// A Serde serialisation implementation which encodes object using +/// `Display` and deserialises using `FromStr`. +pub struct AsStr; + +/// A Serde serialisation implementation for [`ibc::Height`]. +/// +/// We need it because we need this to implement `JsonSchema`. ibc-rs does +/// support schema with a `schema` feature however that brings in `std` and we +/// don’t want that. As a result, we need to define our own serialisation for +/// IBC height. +pub struct Height; + +// ==================== Base64 ================================================= + +impl Base64 { + pub fn serialize(obj: &T, ser: S) -> Result { + Base64Bytes(obj.to_bytes()?.as_ref()).serialize(ser) + } + + pub fn deserialize<'de, T: BytesConv, D: Deserializer<'de>>(de: D) -> Result { + T::from_bytes(Binary::deserialize(de)?.into()) + } +} + +impl OptBase64 { + pub fn serialize( + obj: &Option, + ser: S, + ) -> Result { + if let Some(ref obj) = obj { + let bytes = obj.to_bytes()?; + ser.serialize_some(&Base64Bytes(bytes.as_ref())) + } else { + ser.serialize_none() + } + } + + pub fn deserialize<'de, T: BytesConv, D: Deserializer<'de>>( + de: D, + ) -> Result, D::Error> { + match Option::::deserialize(de)? { + None => Ok(None), + Some(bin) => T::from_bytes(bin.into()).map(Some), + } + } +} + +/// Wrapper which serialised bytes slice using base64 encoding. +struct Base64Bytes<'a>(&'a [u8]); + +impl Serialize for Base64Bytes<'_> { + fn serialize(&self, ser: S) -> Result { + use base64::engine::{general_purpose::STANDARD, Engine}; + ser.serialize_str(&STANDARD.encode(self.0)) + } +} + +/// Trait implementing conversion to and from bytes used by [`Base64`] and +/// [`OptBase64`]. +pub trait BytesConv: Sized { + type Bytes<'a>: AsRef<[u8]> + where + Self: 'a; + + fn to_bytes<'a, E: serde::ser::Error>(&'a self) -> Result, E>; + fn from_bytes(bytes: Vec) -> Result; +} + +impl BytesConv for Vec { + type Bytes<'a> = &'a [u8]; + fn to_bytes<'a, E: serde::ser::Error>(&'a self) -> Result<&'a [u8], E> { + Ok(self.as_slice()) + } + + fn from_bytes(bytes: Vec) -> Result { + Ok(bytes) + } +} + +impl BytesConv for ibc::CommitmentProofBytes { + type Bytes<'a> = &'a [u8]; + fn to_bytes<'a, E: serde::ser::Error>(&'a self) -> Result<&'a [u8], E> { + Ok(self.as_ref()) + } + + fn from_bytes(bytes: Vec) -> Result { + Self::try_from(bytes).map_err(E::custom) + } +} + +macro_rules! conv_via_any { + ($msg:ty) => { + impl BytesConv for $msg { + type Bytes<'a> = Vec; + + fn to_bytes<'a, E: serde::ser::Error>(&'a self) -> Result, E> { + Ok(ibc::proto::Any::from(self).encode_to_vec()) + } + + fn from_bytes(bytes: Vec) -> Result { + let any = ibc::proto::Any::decode(bytes.as_slice()).map_err(E::custom)?; + <$msg>::try_from(any).map_err(E::custom) + } + } + }; +} + +conv_via_any!(state::ClientState); +conv_via_any!(state::ConsensusState); +conv_via_any!(state::Header); +conv_via_any!(state::Misbehaviour); + +impl schemars::JsonSchema for Base64 { + fn schema_name() -> alloc::string::String { + "Base64".into() + } + fn schema_id() -> alloc::borrow::Cow<'static, str> { + alloc::borrow::Cow::Borrowed("cf_guest::Base64") + } + fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(gen) + } +} + +impl schemars::JsonSchema for OptBase64 { + fn schema_name() -> alloc::string::String { + "Nullable_Base64".into() + } + fn schema_id() -> alloc::borrow::Cow<'static, str> { + alloc::borrow::Cow::Borrowed("Option") + } + fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + >::json_schema(gen) + } +} + +// ==================== As String ============================================== + +impl AsStr { + pub fn serialize(obj: &T, ser: S) -> Result { + ser.serialize_str(&obj.to_string()) + } + + pub fn deserialize<'de, T, E, D>(de: D) -> Result + where + T: FromStr, + E: fmt::Display, + D: Deserializer<'de>, + { + de.deserialize_str(AsStrVisitor::::default()) + } +} + +struct AsStrVisitor(PhantomData); + +impl Default for AsStrVisitor { + fn default() -> Self { + Self(PhantomData) + } +} + +impl<'de, T, Err> serde::de::Visitor<'de> for AsStrVisitor +where + T: FromStr, + Err: fmt::Display, +{ + type Value = T; + + fn expecting(&self, fmtr: &mut fmt::Formatter) -> fmt::Result { + write!(fmtr, "object formatted to string") + } + + fn visit_str(self, value: &str) -> Result { + T::from_str(value).map_err(E::custom) + } +} + +impl schemars::JsonSchema for AsStr { + fn schema_name() -> alloc::string::String { + String::schema_name() + } + fn schema_id() -> alloc::borrow::Cow<'static, str> { + String::schema_id() + } + fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(gen) + } +} + +// ==================== IBC Height ============================================= + +impl Height { + pub fn serialize(height: &ibc::Height, ser: S) -> Result { + RawHeight::from(*height).serialize(ser) + } + + pub fn deserialize<'de, D: Deserializer<'de>>(de: D) -> Result { + use serde::de::Error; + let height = ::deserialize(de)?; + ibc::Height::try_from(height).map_err(|_| { + D::Error::invalid_value( + serde::de::Unexpected::Unsigned(0), + &"height with non-zero revision_height", + ) + }) + } +} + +/// The core IBC height type, which represents the height of a chain, which +/// typically is the number of blocks since genesis (or more generally, since +/// the last revision/hard upgrade). +#[derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)] +pub struct RawHeight { + /// Previously known as "epoch" + #[serde(default, skip_serializing_if = "is_zero")] + pub revision_number: cosmwasm_std::Uint64, + + /// The height of a block + pub revision_height: cosmwasm_std::Uint64, +} + +impl TryFrom for ibc::Height { + type Error = ibc::ClientError; + fn try_from(height: RawHeight) -> Result { + Self::new(height.revision_number.into(), height.revision_height.into()) + } +} + +impl From for RawHeight { + fn from(height: ibc::Height) -> Self { + Self { + revision_number: height.revision_number().into(), + revision_height: height.revision_height().into(), + } + } +} + +impl schemars::JsonSchema for Height { + fn schema_name() -> alloc::string::String { + "Height".into() + } + fn schema_id() -> alloc::borrow::Cow<'static, str> { + alloc::borrow::Cow::Borrowed("cf_guest::IbcHeight") + } + fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + ::json_schema(gen) + } +} + +fn is_zero(num: &cosmwasm_std::Uint64) -> bool { + num.u64() == 0 +} diff --git a/light-clients/cf-guest-cw/src/state.rs b/light-clients/cf-guest-cw/src/state.rs new file mode 100644 index 000000000..4dcf0a0f5 --- /dev/null +++ b/light-clients/cf-guest-cw/src/state.rs @@ -0,0 +1,250 @@ +// 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 cosmwasm_std::Storage; +use prost::Message; + +use crate::{ibc, ibc::proto::Any}; + +type Result = core::result::Result; + +pub type ClientMessage = cf_guest::ClientMessage; +pub type ClientState = cf_guest::ClientState; +pub type ConsensusState = cf_guest::ConsensusState; +pub type Header = cf_guest::Header; +pub type Misbehaviour = cf_guest::Misbehaviour; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct Metadata { + pub host_timestamp_ns: u64, + pub host_height: u64, +} + +/// Wrapper for accessing client state saved in the storage. +#[repr(transparent)] +pub(crate) struct ClientStates(dyn Storage); + +impl ClientStates { + pub fn new<'a>(storage: &'a mut dyn Storage) -> &'a mut Self { + // SAFETY: Self is repr(transparent) over dyn Storage so the + // transmutation is sound. + unsafe { wrap_mut(storage) } + } + + pub fn new_ro<'a>(storage: &'a dyn Storage) -> &'a Self { + // SAFETY: Self is repr(transparent) over dyn Storage so the + // transmutation is sound. + unsafe { wrap_ref(storage) } + } + + pub fn get(&self) -> Result, E> + where + T: TryFrom, + E: From + From, + { + self.get_impl(Self::KEY) + } + + pub fn set(&mut self, state: impl Into) { + self.set_impl(Self::KEY, state) + } + + const KEY: &'static [u8] = b"clientState/"; + + fn get_impl(&self, key: &[u8]) -> Result, E> + where + T: TryFrom, + E: From + From, + { + self.0 + .get(&key) + .map(|value| { + let any = Any::decode(value.as_slice())?; + T::try_from(any).map_err(|err| err.into()) + }) + .transpose() + } + + fn set_impl(&mut self, key: &[u8], state: impl Into) { + self.0.set(&key, state.into().encode_to_vec().as_slice()) + } +} + +/// Wrapper for accessing consensus state saved in the storage. +#[repr(transparent)] +pub(crate) struct ConsensusStates(dyn Storage); + +impl ConsensusStates { + pub fn new<'a>(storage: &'a mut dyn Storage) -> &'a mut Self { + // SAFETY: Self is repr(transparent) over dyn Storage so the + // transmutation is sound. + unsafe { wrap_mut(storage) } + } + + pub fn new_ro<'a>(storage: &'a dyn Storage) -> &'a Self { + // SAFETY: Self is repr(transparent) over dyn Storage so the + // transmutation is sound. + unsafe { wrap_ref(storage) } + } + + pub fn get(&self, height: ibc::Height) -> Result, E> + where + T: TryFrom, + E: From + From, + { + self.get_impl(&Self::key(height)) + } + + pub fn set(&mut self, height: ibc::Height, state: impl Into, metadata: Metadata) { + self.set_impl(Self::key(height), state, metadata) + } + + fn all<'a>( + &'a self, + ) -> impl Iterator, Any, Metadata), prost::DecodeError>> + 'a { + self.0 + .range( + Some(Self::key_impl(0, 0).as_slice()), + Some(Self::key_impl(u64::MAX, u64::MAX).as_slice()), + cosmwasm_std::Order::Ascending, + ) + .map(|(key, value)| { + let (any, metadata) = ConsensusWithMetadata::decode(value.as_slice())?.into_parts(); + Ok((key, any, metadata)) + }) + } + + pub fn prune_oldest_consensus_state( + &mut self, + client_state: &ClientState, + now_ns: u64, + ) -> Result<()> { + let (key, any) = match self.all().next() { + None => return Ok(()), + Some(Err(err)) => return Err(err.into()), + Some(Ok((key, any, _metadata))) => (key, any), + }; + let state = ConsensusState::try_from(any)?; + let elapsed = now_ns.saturating_sub(state.timestamp_ns.get()); + if elapsed >= client_state.trusting_period_ns { + self.0.remove(key.as_slice()); + } + Ok(()) + } + + pub fn get_all_metadata(&self) -> Result> { + let mut records = Vec::new(); + for record in self.all() { + let (key, _state, metadata) = record?; + let key = &key[key.len() - 16..]; + let revision_number = u64::from_be_bytes(key[..8].try_into().unwrap()); + let revision_height = u64::from_be_bytes(key[8..].try_into().unwrap()); + records.push(crate::msg::ConsensusStateMetadata { + height: ibc::Height::new(revision_number, revision_height).unwrap(), + host_timestamp_ns: metadata.host_timestamp_ns.into(), + host_height: metadata.host_height.into(), + }) + } + Ok(records) + } + + pub fn del(&mut self, height: ibc::Height) { + self.0.remove(&Self::key(height)) + } + + fn key(height: ibc::Height) -> Vec { + Self::key_impl(height.revision_number(), height.revision_height()) + } + + fn key_impl(rev_number: u64, rev_height: u64) -> Vec { + let rev_number = rev_number.to_be_bytes(); + let rev_height = rev_height.to_be_bytes(); + [b"consensusState/", &rev_number[..], &rev_height[..]].concat() + } + + fn get_impl(&self, key: &[u8]) -> Result, E> + where + T: TryFrom, + E: From + From, + { + let value = match self.0.get(&key) { + None => return Ok(None), + Some(value) => value, + }; + let (any, metadata) = ConsensusWithMetadata::decode(value.as_slice())?.into_parts(); + Ok(Some((T::try_from(any)?, metadata))) + } + + fn set_impl(&mut self, key: Vec, state: impl Into, metadata: Metadata) { + let state = ConsensusWithMetadata::new(state, metadata); + self.0.set(&key, state.encode_to_vec().as_slice()) + } +} + +/// Extension of protobuf’s Any type to include host height and host timestamp. +#[derive(Clone, PartialEq, prost::Message)] +struct ConsensusWithMetadata { + #[prost(string, tag = "1")] + pub type_url: ::prost::alloc::string::String, + #[prost(bytes = "vec", tag = "2")] + pub value: ::prost::alloc::vec::Vec, + #[prost(uint64, tag = "3")] + pub host_timestamp_ns: u64, + #[prost(uint64, tag = "4")] + pub host_height: u64, +} + +impl ConsensusWithMetadata { + fn new(state: impl Into, metadata: Metadata) -> Self { + let Any { type_url, value } = state.into(); + let Metadata { host_timestamp_ns, host_height } = metadata; + Self { type_url, value, host_timestamp_ns, host_height } + } + + fn into_parts(self) -> (Any, Metadata) { + ( + Any { type_url: self.type_url, value: self.value }, + Metadata { host_timestamp_ns: self.host_timestamp_ns, host_height: self.host_height }, + ) + } +} + +unsafe fn wrap_ref(from: &F) -> &T { + assert!(core::mem::size_of::<*const F>() == core::mem::size_of::<*const T>()); + let inner_ptr = core::mem::ManuallyDrop::new(from as *const F); + // SAFETY: Caller guarantees soundness. + unsafe { + // A pointer cast doesn't work here because rustc can't tell + // that the vtables match (because of the `?Sized` restriction + // relaxation). A `transmute` doesn't work because the sizes + // are unspecified. + let outer_ptr: *const T = core::mem::transmute_copy(&inner_ptr); + &*outer_ptr + } +} + +unsafe fn wrap_mut(from: &mut F) -> &mut T { + assert!(core::mem::size_of::<*mut F>() == core::mem::size_of::<*mut T>()); + let inner_ptr = core::mem::ManuallyDrop::new(from as *mut F); + // SAFETY: Caller guarantees soundness. + unsafe { + // A pointer cast doesn't work here because rustc can't tell + // that the vtables match (because of the `?Sized` restriction + // relaxation). A `transmute` doesn't work because the sizes + // are unspecified. + let outer_ptr: *mut T = core::mem::transmute_copy(&inner_ptr); + &mut *outer_ptr + } +} diff --git a/light-clients/ics07-tendermint-cw/src/client.rs b/light-clients/ics07-tendermint-cw/src/client.rs index c5d192107..4dde0d591 100644 --- a/light-clients/ics07-tendermint-cw/src/client.rs +++ b/light-clients/ics07-tendermint-cw/src/client.rs @@ -239,7 +239,7 @@ impl<'a, H: HostFunctionsProvider + 'static> ClientKeeper for Context<'a, H> { timestamp: Timestamp, ) -> Result<(), Error> { let mut processed_state = ProcessedStates::new(self.storage_mut()); - processed_state.set_processed_time(height, timestamp.nanoseconds(), &mut Vec::new()); + processed_state.set_processed_time(height, timestamp.nanoseconds(), ""); Ok(()) } @@ -251,8 +251,8 @@ impl<'a, H: HostFunctionsProvider + 'static> ClientKeeper for Context<'a, H> { host_height: Height, ) -> Result<(), Error> { let mut processed_state = ProcessedStates::new(self.storage_mut()); - processed_state.set_processed_height(height, host_height.revision_height, &mut Vec::new()); - processed_state.set_iteration_key(height, &mut Vec::new()); + processed_state.set_processed_height(height, host_height.revision_height, ""); + processed_state.set_iteration_key(height, ""); Ok(()) } diff --git a/light-clients/ics07-tendermint-cw/src/context.rs b/light-clients/ics07-tendermint-cw/src/context.rs index 7fecd9ba1..4e53bfb56 100644 --- a/light-clients/ics07-tendermint-cw/src/context.rs +++ b/light-clients/ics07-tendermint-cw/src/context.rs @@ -103,7 +103,7 @@ where { pub fn processed_timestamp(&self, height: Height) -> Result { let processed_state = ReadonlyProcessedStates::new(self.storage()); - match processed_state.get_processed_time(height, &mut Vec::new()) { + match processed_state.get_processed_time(height, "") { Some(time) => Ok(time), None => Err(Error::implementation_specific( "problem getting processed timestamp".to_string(), @@ -113,7 +113,7 @@ where pub fn processed_height(&self, height: Height) -> Result { let processed_state = ReadonlyProcessedStates::new(self.storage()); - match processed_state.get_processed_height(height, &mut Vec::new()) { + match processed_state.get_processed_height(height, "") { Some(p_height) => Ok(p_height), None => Err(Error::implementation_specific("problem getting processed height".to_string())), diff --git a/light-clients/ics07-tendermint-cw/src/contract.rs b/light-clients/ics07-tendermint-cw/src/contract.rs index c57cef78e..0a3beda82 100644 --- a/light-clients/ics07-tendermint-cw/src/contract.rs +++ b/light-clients/ics07-tendermint-cw/src/contract.rs @@ -238,8 +238,8 @@ fn process_message( .map_err(|e| ContractError::Tendermint(e.to_string())) .and_then(|(cs, cu)| { let height = cs.latest_height(); - ctx.store_consensus_state_prefixed(height, cu, SUBJECT_PREFIX); - ctx.store_client_state_prefixed(cs, SUBJECT_PREFIX, client_id) + ctx.store_consensus_state_prefixed(height, cu, SUBJECT_PREFIX.as_bytes()); + ctx.store_client_state_prefixed(cs, SUBJECT_PREFIX.as_bytes(), client_id) .map_err(|e| ContractError::Tendermint(e.to_string()))?; Ok(to_binary(&ContractResult::success())) }), diff --git a/light-clients/ics07-tendermint-cw/src/helpers.rs b/light-clients/ics07-tendermint-cw/src/helpers.rs index ae353146a..377d9c413 100644 --- a/light-clients/ics07-tendermint-cw/src/helpers.rs +++ b/light-clients/ics07-tendermint-cw/src/helpers.rs @@ -171,12 +171,14 @@ pub fn verify_upgrade_and_update_state( pub fn check_substitute_and_update_state( ctx: &mut Context, ) -> Result<(ClientState, ConsensusState), Ics02Error> { - let mut subject_client_state = ctx.client_state_prefixed(SUBJECT_PREFIX).map_err(|_| { - Ics02Error::implementation_specific("subject client state not found".to_string()) - })?; - let substitute_client_state = ctx.client_state_prefixed(SUBSTITUTE_PREFIX).map_err(|_| { - Ics02Error::implementation_specific("substitute client state not found".to_string()) - })?; + let mut subject_client_state = + ctx.client_state_prefixed(SUBJECT_PREFIX.as_bytes()).map_err(|_| { + Ics02Error::implementation_specific("subject client state not found".to_string()) + })?; + let substitute_client_state = + ctx.client_state_prefixed(SUBSTITUTE_PREFIX.as_bytes()).map_err(|_| { + Ics02Error::implementation_specific("substitute client state not found".to_string()) + })?; if subject_client_state.trust_level != substitute_client_state.trust_level || subject_client_state.unbonding_period != substitute_client_state.unbonding_period || @@ -188,32 +190,22 @@ pub fn check_substitute_and_update_state( } let height = substitute_client_state.latest_height(); - let substitute_consensus_state = - ctx.consensus_state_prefixed(height, SUBSTITUTE_PREFIX).map_err(|_| { + let substitute_consensus_state = ctx + .consensus_state_prefixed(height, SUBSTITUTE_PREFIX.as_bytes()) + .map_err(|_| { Ics02Error::implementation_specific("substitute consensus state not found".to_string()) })?; let mut process_states = ProcessedStates::new(ctx.storage_mut()); - let substitute_processed_time = process_states - .get_processed_time(height, &mut SUBSTITUTE_PREFIX.to_vec()) - .unwrap(); - let substitute_processed_height = process_states - .get_processed_height(height, &mut SUBSTITUTE_PREFIX.to_vec()) - .unwrap(); - let substitute_iteration_key = process_states - .get_iteration_key(height, &mut SUBSTITUTE_PREFIX.to_vec()) - .unwrap(); - process_states.set_processed_time( - height, - substitute_processed_time, - &mut SUBJECT_PREFIX.to_vec(), - ); - process_states.set_processed_height( - height, - substitute_processed_height, - &mut SUBJECT_PREFIX.to_vec(), - ); - process_states.set_iteration_key(substitute_iteration_key, &mut SUBJECT_PREFIX.to_vec()); + let substitute_processed_time = + process_states.get_processed_time(height, SUBSTITUTE_PREFIX).unwrap(); + let substitute_processed_height = + process_states.get_processed_height(height, SUBSTITUTE_PREFIX).unwrap(); + let substitute_iteration_key = + process_states.get_iteration_key(height, SUBSTITUTE_PREFIX).unwrap(); + process_states.set_processed_time(height, substitute_processed_time, SUBJECT_PREFIX); + process_states.set_processed_height(height, substitute_processed_height, SUBJECT_PREFIX); + process_states.set_iteration_key(substitute_iteration_key, SUBJECT_PREFIX); subject_client_state.latest_height = substitute_client_state.latest_height; subject_client_state.chain_id = substitute_client_state.chain_id; @@ -231,8 +223,7 @@ pub fn prune_oldest_consensus_state( let mut processed_states = ProcessedStates::new(ctx.storage_mut()); if let Some(earliest_height) = processed_states.get_earliest_height(client_state.latest_height) { - let processed_time = - processed_states.get_processed_time(earliest_height, &mut Vec::new()).unwrap(); + let processed_time = processed_states.get_processed_time(earliest_height, "").unwrap(); let elapsed = Duration::from_nanos(current_time - processed_time); if client_state.expired(elapsed) { processed_states.remove_states_at_height(earliest_height); diff --git a/light-clients/ics07-tendermint-cw/src/ics23/consensus_states.rs b/light-clients/ics07-tendermint-cw/src/ics23/consensus_states.rs index fa2f0a78c..8137f0db3 100644 --- a/light-clients/ics07-tendermint-cw/src/ics23/consensus_states.rs +++ b/light-clients/ics07-tendermint-cw/src/ics23/consensus_states.rs @@ -50,7 +50,7 @@ impl<'a> ConsensusStates<'a> { } pub fn consensus_state_client_key() -> Vec { - "consensusStates/".to_string().into_bytes() + b"consensusStates/".to_vec() } pub fn consensus_state_height_key(height: Height) -> Vec { diff --git a/light-clients/ics07-tendermint-cw/src/ics23/processed_states.rs b/light-clients/ics07-tendermint-cw/src/ics23/processed_states.rs index 0474c4925..9a5b47409 100644 --- a/light-clients/ics07-tendermint-cw/src/ics23/processed_states.rs +++ b/light-clients/ics07-tendermint-cw/src/ics23/processed_states.rs @@ -25,59 +25,51 @@ impl<'a> ProcessedStates<'a> { ProcessedStates(storage) } - 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_time_key(height: Height, prefix: &str) -> Vec { + format!("{prefix}consensusStates/{height}/processedTime").into_bytes() } - 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 processed_height_key(height: Height, prefix: &str) -> Vec { + format!("{prefix}consensusStates/{height}/processedHeight").into_bytes() } - pub fn iteration_key(height: Height, prefix: &mut Vec) -> Vec { - prefix.append(&mut "iterateConsensusStates".to_string().into_bytes()); - prefix.append(&mut height.revision_number.to_be_bytes().to_vec()); - prefix.append(&mut height.revision_height.to_be_bytes().to_vec()); - prefix.clone() + pub fn iteration_key(height: Height, prefix: &str) -> Vec { + [ + prefix.as_bytes(), + &b"iterateConsensusStates"[..], + &height.revision_number.to_be_bytes()[..], + &height.revision_height.to_be_bytes()[..], + ] + .concat() } - pub fn get_processed_time(&self, height: Height, prefix: &mut Vec) -> Option { + pub fn get_processed_time(&self, height: Height, prefix: &str) -> Option { let full_key = Self::processed_time_key(height, prefix); self.0 .get(&full_key) .map(|timestamp| u64::from_be_bytes(timestamp.try_into().unwrap())) } - pub fn set_processed_time(&mut self, height: Height, timestamp: u64, prefix: &mut Vec) { + pub fn set_processed_time(&mut self, height: Height, timestamp: u64, prefix: &str) { let full_key = Self::processed_time_key(height, prefix); let time_vec: [u8; 8] = timestamp.to_be_bytes(); self.0.set(&full_key, &time_vec); } - pub fn get_processed_height(&self, height: Height, prefix: &mut Vec) -> Option { + pub fn get_processed_height(&self, height: Height, prefix: &str) -> Option { let full_key = Self::processed_height_key(height, prefix); self.0 .get(&full_key) .map(|height| u64::from_be_bytes(height.try_into().unwrap())) } - pub fn set_processed_height( - &mut self, - height: Height, - processed_height: u64, - prefix: &mut Vec, - ) { + pub fn set_processed_height(&mut self, height: Height, processed_height: u64, prefix: &str) { let full_key = Self::processed_height_key(height, prefix); let height_vec: [u8; 8] = processed_height.to_be_bytes(); self.0.set(&full_key, &height_vec); } - pub fn get_iteration_key(&self, height: Height, prefix: &mut Vec) -> Option { + pub fn get_iteration_key(&self, height: Height, prefix: &str) -> Option { let full_key = Self::iteration_key(height, prefix); match self.0.get(&full_key) { Some(height) => match std::str::from_utf8(height.as_slice()) { @@ -88,16 +80,16 @@ impl<'a> ProcessedStates<'a> { } } - pub fn set_iteration_key(&mut self, height: Height, prefix: &mut Vec) { + pub fn set_iteration_key(&mut self, height: Height, prefix: &str) { let full_key = Self::iteration_key(height, prefix); let height_vec = format!("{height}").into_bytes(); self.0.set(&full_key, &height_vec); } pub fn get_earliest_height(&mut self, current_height: Height) -> Option { - let full_key = Self::iteration_key(current_height, &mut Vec::new()); - let start_key = "iterateConsensusStates".to_string().into_bytes(); - let mut iterator = self.0.range(Some(&start_key), Some(&full_key), Order::Ascending); + let full_key = Self::iteration_key(current_height, ""); + let start_key = &b"iterateConsensusStates"[..]; + let mut iterator = self.0.range(Some(start_key), Some(&full_key), Order::Ascending); match iterator.next() { Some((_, height)) => match std::str::from_utf8(height.as_slice()) { Ok(height_str) => Some(Height::try_from(height_str).unwrap()), @@ -108,9 +100,9 @@ impl<'a> ProcessedStates<'a> { } pub fn remove_states_at_height(&mut self, height: Height) { - let processed_time_key = Self::processed_time_key(height, &mut Vec::new()); - let processed_height_key = Self::processed_height_key(height, &mut Vec::new()); - let iteration_key = Self::iteration_key(height, &mut Vec::new()); + let processed_time_key = Self::processed_time_key(height, ""); + let processed_height_key = Self::processed_height_key(height, ""); + let iteration_key = Self::iteration_key(height, ""); self.0.remove(&processed_time_key); self.0.remove(&processed_height_key); @@ -125,21 +117,21 @@ impl<'a> ReadonlyProcessedStates<'a> { ReadonlyProcessedStates(storage) } - pub fn get_processed_time(&self, height: Height, prefix: &mut Vec) -> Option { + pub fn get_processed_time(&self, height: Height, prefix: &str) -> Option { let full_key = ProcessedStates::processed_time_key(height, prefix); self.0 .get(&full_key) .map(|timestamp| u64::from_be_bytes(timestamp.try_into().unwrap())) } - pub fn get_processed_height(&self, height: Height, prefix: &mut Vec) -> Option { + pub fn get_processed_height(&self, height: Height, prefix: &str) -> Option { let full_key = ProcessedStates::processed_height_key(height, prefix); self.0 .get(&full_key) .map(|height| u64::from_be_bytes(height.try_into().unwrap())) } - pub fn get_iteration_key(&self, height: Height, prefix: &mut Vec) -> Option { + pub fn get_iteration_key(&self, height: Height, prefix: &str) -> Option { let full_key = ProcessedStates::iteration_key(height, prefix); match self.0.get(&full_key) { Some(height) => match std::str::from_utf8(height.as_slice()) { @@ -151,7 +143,7 @@ impl<'a> ReadonlyProcessedStates<'a> { } pub fn get_next_height(&self, height: Height) -> Option { - let full_key = ProcessedStates::iteration_key(height, &mut Vec::new()); + let full_key = ProcessedStates::iteration_key(height, ""); let mut iterator = self.0.range(Some(&full_key), None, Order::Ascending); match iterator.next() { Some((_, height)) => match std::str::from_utf8(height.as_slice()) { @@ -163,7 +155,7 @@ impl<'a> ReadonlyProcessedStates<'a> { } pub fn get_prev_height(&self, height: Height) -> Option { - let full_key = ProcessedStates::iteration_key(height, &mut Vec::new()); + let full_key = ProcessedStates::iteration_key(height, ""); let mut iterator = self.0.range(None, Some(&full_key), Order::Descending); match iterator.next() { Some((_, height)) => match std::str::from_utf8(height.as_slice()) { @@ -177,20 +169,18 @@ impl<'a> ReadonlyProcessedStates<'a> { pub fn get_metadata(&self) -> Option> { let mut gm: Vec = Vec::::new(); - let start_key = "iterateConsensusStates".to_string().into_bytes(); - let iterator = self.0.range(Some(&start_key), None, Order::Ascending); + let start_key = &b"iterateConsensusStates"[..]; + let iterator = self.0.range(Some(start_key), None, Order::Ascending); for (_, height) in iterator { match std::str::from_utf8(height.as_slice()) { Ok(height_str) => { let height = Height::try_from(height_str).unwrap(); - let processed_height_key = - ProcessedStates::processed_height_key(height, &mut Vec::new()); + let processed_height_key = ProcessedStates::processed_height_key(height, ""); gm.push(GenesisMetadata { key: processed_height_key.clone(), value: self.0.get(&processed_height_key).unwrap(), }); - let processed_time_key = - ProcessedStates::processed_time_key(height, &mut Vec::new()); + let processed_time_key = ProcessedStates::processed_time_key(height, ""); gm.push(GenesisMetadata { key: processed_time_key.clone(), value: self.0.get(&processed_time_key).unwrap(), @@ -200,7 +190,7 @@ impl<'a> ReadonlyProcessedStates<'a> { } } - let iterator = self.0.range(Some(&start_key), None, Order::Ascending); + let iterator = self.0.range(Some(start_key), None, Order::Ascending); for (key, height) in iterator { gm.push(GenesisMetadata { key, value: height }); } diff --git a/light-clients/ics07-tendermint-cw/src/state.rs b/light-clients/ics07-tendermint-cw/src/state.rs index 057892a82..a9ebea116 100644 --- a/light-clients/ics07-tendermint-cw/src/state.rs +++ b/light-clients/ics07-tendermint-cw/src/state.rs @@ -30,7 +30,7 @@ pub fn get_client_state( client_id: ClientId, ) -> Result, Error> { deps.storage - .get(&"clientState".to_string().into_bytes()) + .get(b"clientState") .ok_or_else(|| Error::unknown_client_state_type(client_id.to_string())) .and_then(|client_state| deserialize_client_state(client_state, deps)) } @@ -84,5 +84,5 @@ fn deserialize_consensus_state(consensus_state: Vec) -> Result Vec { - ["consensusStates/".to_string().into_bytes(), format!("{height}").into_bytes()].concat() + format!("consensusStates/{height}").into_bytes() } diff --git a/light-clients/ics08-wasm/src/lib.rs b/light-clients/ics08-wasm/src/lib.rs index 9cc2b5a1d..35b6a127a 100644 --- a/light-clients/ics08-wasm/src/lib.rs +++ b/light-clients/ics08-wasm/src/lib.rs @@ -28,5 +28,5 @@ pub mod instantiate; pub mod msg; pub type Bytes = Vec; -pub static SUBJECT_PREFIX: &[u8] = "subject/".as_bytes(); -pub static SUBSTITUTE_PREFIX: &[u8] = "substitute/".as_bytes(); +pub static SUBJECT_PREFIX: &str = "subject/"; +pub static SUBSTITUTE_PREFIX: &str = "substitute/"; diff --git a/light-clients/ics10-grandpa-cw/src/contract.rs b/light-clients/ics10-grandpa-cw/src/contract.rs index 7864941f9..0d5f9cb5f 100644 --- a/light-clients/ics10-grandpa-cw/src/contract.rs +++ b/light-clients/ics10-grandpa-cw/src/contract.rs @@ -208,7 +208,7 @@ fn process_message( // load the substitute client state from the combined storage using the appropriate // prefix let substitute_client_state = ctx - .client_state_prefixed(SUBSTITUTE_PREFIX) + .client_state_prefixed(SUBSTITUTE_PREFIX.as_bytes()) .map_err(|e| ContractError::Grandpa(e.to_string()))?; // No items for the grandpa client state are required to be the same @@ -216,10 +216,18 @@ fn process_message( let height = substitute_client_state.latest_height(); // consensus state should be replaced as well let substitute_consensus_state = - ctx.consensus_state_prefixed(height, SUBSTITUTE_PREFIX)?; - ctx.store_consensus_state_prefixed(height, substitute_consensus_state, SUBJECT_PREFIX); - ctx.store_client_state_prefixed(substitute_client_state, SUBJECT_PREFIX, client_id) - .map_err(|e| ContractError::Grandpa(e.to_string()))?; + ctx.consensus_state_prefixed(height, SUBSTITUTE_PREFIX.as_bytes())?; + ctx.store_consensus_state_prefixed( + height, + substitute_consensus_state, + SUBJECT_PREFIX.as_bytes(), + ); + ctx.store_client_state_prefixed( + substitute_client_state, + SUBJECT_PREFIX.as_bytes(), + client_id, + ) + .map_err(|e| ContractError::Grandpa(e.to_string()))?; Ok(()).map(|_| to_binary(&ContractResult::success())) }, diff --git a/light-clients/ics10-grandpa-cw/src/ics23/consensus_states.rs b/light-clients/ics10-grandpa-cw/src/ics23/consensus_states.rs index f443129af..98fd0b471 100644 --- a/light-clients/ics10-grandpa-cw/src/ics23/consensus_states.rs +++ b/light-clients/ics10-grandpa-cw/src/ics23/consensus_states.rs @@ -51,7 +51,7 @@ impl<'a> ConsensusStates<'a> { } pub fn consensus_state_client_key() -> Vec { - "consensusStates/".to_string().into_bytes() + b"consensusStates/".to_vec() } pub fn consensus_state_height_key(height: Height) -> Vec { diff --git a/light-clients/ics10-grandpa-cw/src/state.rs b/light-clients/ics10-grandpa-cw/src/state.rs index 23b9813f4..6647e98f6 100644 --- a/light-clients/ics10-grandpa-cw/src/state.rs +++ b/light-clients/ics10-grandpa-cw/src/state.rs @@ -30,7 +30,7 @@ pub fn get_client_state( client_id: ClientId, ) -> Result, Error> { deps.storage - .get(&"clientState".to_string().into_bytes()) + .get(b"clientState") .ok_or_else(|| Error::unknown_client_state_type(client_id.to_string())) .and_then(deserialize_client_state) } @@ -63,5 +63,5 @@ pub fn get_consensus_state( } pub fn get_consensus_state_key(height: Height) -> Vec { - ["consensusStates/".to_string().into_bytes(), format!("{height}").into_bytes()].concat() + format!("consensusStates/{height}").into_bytes() } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 654d4cf37..fda60ffb2 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,8 @@ [toolchain] -channel = "nightly-2023-08-24" +# Note: ahash 0.7.7 and 0.8.6 don’t work with newer nightly versions. +# For the time being sticking to version that works. Setting this to +# never version will likely require `cargo update -p ahash@0.8.3 && +# cargo update -p ahash@0.7.6`. +channel = "nightly-2024-02-05" targets = [ "wasm32-unknown-unknown"] -profile = "minimal" \ No newline at end of file +profile = "minimal"