From 63aa30db6b75f0df263b00bb23409d7ea58035ce Mon Sep 17 00:00:00 2001 From: Daniel Gushchyan <39884512+dangush@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:55:52 -0700 Subject: [PATCH] feat: quartz-common and merging quartz-cli business logic from cycles-protocol (#123) --- .github/workflows/cosmwasm-basic.yml | 3 + .github/workflows/cosmwasm-release.yml | 2 + .gitignore | 2 + Cargo.lock | 613 ++- Cargo.toml | 13 +- apps/mtcs/contracts/cw-tee-mtcs/Cargo.lock | 147 +- apps/mtcs/contracts/cw-tee-mtcs/Cargo.toml | 7 +- .../contracts/cw-tee-mtcs/src/contract.rs | 265 +- apps/mtcs/contracts/cw-tee-mtcs/src/error.rs | 11 +- apps/mtcs/contracts/cw-tee-mtcs/src/lib.rs | 16 +- apps/mtcs/contracts/cw-tee-mtcs/src/msg.rs | 58 +- apps/mtcs/contracts/cw-tee-mtcs/src/state.rs | 50 +- apps/mtcs/enclave/Cargo.toml | 24 +- apps/mtcs/enclave/src/lib.rs | 1 + apps/mtcs/enclave/src/main.rs | 13 +- apps/mtcs/enclave/src/mtcs_server.rs | 152 +- apps/mtcs/enclave/src/types.rs | 59 + apps/mtcs/scripts/Cargo.lock | 4723 +++++++++++++++++ apps/mtcs/scripts/Cargo.toml | 58 + apps/mtcs/scripts/aggregator.sh | 40 + apps/mtcs/scripts/build.sh | 18 + apps/mtcs/scripts/deploy.sh | 23 + apps/mtcs/scripts/deploy45.sh | 23 + apps/mtcs/scripts/handshake.sh | 117 + apps/mtcs/scripts/listen.sh | 101 + apps/mtcs/scripts/src/bin/deploy.rs | 80 + apps/mtcs/scripts/src/bin/handshake.rs | 229 + apps/mtcs/scripts/src/bin/listen.rs | 250 + apps/mtcs/scripts/src/lib.rs | 3 + apps/mtcs/scripts/src/types.rs | 39 + apps/mtcs/scripts/src/utils.rs | 81 + apps/mtcs/scripts/start.sh | 98 + apps/mtcs/scripts/start45.sh | 128 + apps/mtcs/scripts/transact.sh | 40 + apps/transfers/contracts/Cargo.lock | 676 ++- apps/transfers/contracts/Cargo.toml | 8 +- apps/transfers/contracts/src/contract.rs | 2 +- apps/transfers/contracts/src/error.rs | 2 +- apps/transfers/contracts/src/msg.rs | 5 +- apps/transfers/enclave/Cargo.toml | 13 +- apps/transfers/enclave/src/main.rs | 12 +- .../transfers/enclave/src/transfers_server.rs | 10 +- core/quartz-common/Cargo.toml | 22 + core/quartz-common/src/lib.rs | 6 + core/quartz/Cargo.toml | 2 - .../quartz-cw/src/msg/execute/attested.rs | 3 +- .../src/msg/execute/session_set_pub_key.rs | 6 + relayer/scripts/relay.sh | 3 + utils/cycles-sync/Cargo.toml | 11 + utils/cycles-sync/src/bin/submit.rs | 174 + utils/cycles-sync/src/cli.rs | 2 +- utils/cycles-sync/src/lib.rs | 3 + utils/cycles-sync/src/main.rs | 14 +- utils/cycles-sync/src/types.rs | 23 +- utils/cycles-sync/src/wasmd_client.rs | 151 +- utils/tm-prover/Cargo.toml | 6 +- utils/tm-prover/src/config.rs | 147 + utils/tm-prover/src/lib.rs | 2 + utils/tm-prover/src/main.rs | 357 +- utils/tm-prover/src/prover.rs | 262 + 60 files changed, 8382 insertions(+), 1027 deletions(-) create mode 100644 apps/mtcs/enclave/src/lib.rs create mode 100644 apps/mtcs/enclave/src/types.rs create mode 100644 apps/mtcs/scripts/Cargo.lock create mode 100644 apps/mtcs/scripts/Cargo.toml create mode 100644 apps/mtcs/scripts/aggregator.sh create mode 100644 apps/mtcs/scripts/build.sh create mode 100755 apps/mtcs/scripts/deploy.sh create mode 100755 apps/mtcs/scripts/deploy45.sh create mode 100755 apps/mtcs/scripts/handshake.sh create mode 100755 apps/mtcs/scripts/listen.sh create mode 100644 apps/mtcs/scripts/src/bin/deploy.rs create mode 100644 apps/mtcs/scripts/src/bin/handshake.rs create mode 100644 apps/mtcs/scripts/src/bin/listen.rs create mode 100644 apps/mtcs/scripts/src/lib.rs create mode 100644 apps/mtcs/scripts/src/types.rs create mode 100644 apps/mtcs/scripts/src/utils.rs create mode 100755 apps/mtcs/scripts/start.sh create mode 100755 apps/mtcs/scripts/start45.sh create mode 100644 apps/mtcs/scripts/transact.sh create mode 100644 core/quartz-common/Cargo.toml create mode 100644 core/quartz-common/src/lib.rs create mode 100644 utils/cycles-sync/src/bin/submit.rs create mode 100644 utils/tm-prover/src/config.rs create mode 100644 utils/tm-prover/src/lib.rs create mode 100644 utils/tm-prover/src/prover.rs diff --git a/.github/workflows/cosmwasm-basic.yml b/.github/workflows/cosmwasm-basic.yml index 372dd8e..bd17dba 100644 --- a/.github/workflows/cosmwasm-basic.yml +++ b/.github/workflows/cosmwasm-basic.yml @@ -37,6 +37,9 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 + - name: Install protobuf-compiler + run: sudo apt-get install -y protobuf-compiler + - name: Install wasm32-unknown-unknown toolchain uses: dtolnay/rust-toolchain@stable with: diff --git a/.github/workflows/cosmwasm-release.yml b/.github/workflows/cosmwasm-release.yml index f467fb4..4fd4d7d 100644 --- a/.github/workflows/cosmwasm-release.yml +++ b/.github/workflows/cosmwasm-release.yml @@ -10,6 +10,8 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v2 + - name: Install protobuf-compiler + run: sudo apt-get install -y protobuf-compiler - name: Install cargo-run-script uses: actions-rs/cargo@v1 with: diff --git a/.gitignore b/.gitignore index cb9ef84..c7aaa27 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ .idea/ target/ artifacts/ +.vscode/ +.DS_Store \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 4e6deda..71d725f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,6 +52,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.11" @@ -296,6 +307,23 @@ dependencies = [ "syn 2.0.71", ] +[[package]] +name = "async-tungstenite" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3609af4bbf701ddaf1f6bb4e6257dff4ff8932327d0e685d3f653724c258b1ac" +dependencies = [ + "futures-io", + "futures-util", + "log", + "pin-project-lite", + "rustls-native-certs 0.7.1", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.25.0", + "tungstenite 0.21.0", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -392,6 +420,12 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + [[package]] name = "bech32" version = "0.11.0" @@ -409,7 +443,7 @@ dependencies = [ "k256", "once_cell", "pbkdf2", - "rand_core", + "rand_core 0.6.4", "ripemd", "sha2 0.10.8", "subtle", @@ -468,6 +502,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bnum" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9008b6bb9fc80b5277f2fe481c09e828743d9151203e804583eb4c9e15b31d" + [[package]] name = "bnum" version = "0.11.0" @@ -538,9 +578,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.9" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" dependencies = [ "clap_builder", "clap_derive", @@ -548,9 +588,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" dependencies = [ "anstyle", "clap_lex", @@ -558,9 +598,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.8" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" dependencies = [ "heck", "proc-macro2", @@ -648,7 +688,7 @@ dependencies = [ "ecdsa", "eyre", "k256", - "rand_core", + "rand_core 0.6.4", "serde", "serde_json", "signature", @@ -663,6 +703,20 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d075f6bb1483a6ce83b5cbc73a3a1207e0316ac1e34ed1f2a4d9fc3a0f07bf6" +[[package]] +name = "cosmwasm-crypto" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6aa9f904de106fa16443ad14ec2abe75e94ba003bb61c681c0e43d4c58d2a" +dependencies = [ + "digest 0.10.7", + "ecdsa", + "ed25519-zebra 3.1.0", + "k256", + "rand_core 0.6.4", + "thiserror", +] + [[package]] name = "cosmwasm-crypto" version = "2.1.0" @@ -676,16 +730,25 @@ dependencies = [ "cosmwasm-core", "digest 0.10.7", "ecdsa", - "ed25519-zebra", + "ed25519-zebra 4.0.3", "k256", "num-traits", "p256", - "rand_core", + "rand_core 0.6.4", "rayon", "sha2 0.10.8", "thiserror", ] +[[package]] +name = "cosmwasm-derive" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "242e98e7a231c122e08f300d9db3262d1007b51758a8732cd6210b3e9faa4f3a" +dependencies = [ + "syn 1.0.109", +] + [[package]] name = "cosmwasm-derive" version = "2.1.0" @@ -699,17 +762,41 @@ dependencies = [ [[package]] name = "cosmwasm-schema" -version = "2.1.0" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27984b137eb2ac561f97f6bdb02004a98eb6f2ba263062c140b8e231ee1826b7" +checksum = "7879036156092ad1c22fe0d7316efc5a5eceec2bc3906462a2560215f2a2f929" dependencies = [ - "cosmwasm-schema-derive", + "cosmwasm-schema-derive 1.5.5", "schemars", "serde", "serde_json", "thiserror", ] +[[package]] +name = "cosmwasm-schema" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27984b137eb2ac561f97f6bdb02004a98eb6f2ba263062c140b8e231ee1826b7" +dependencies = [ + "cosmwasm-schema-derive 2.1.0", + "schemars", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb57855fbfc83327f8445ae0d413b1a05ac0d68c396ab4d122b2abd7bb82cb6" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "cosmwasm-schema-derive" version = "2.1.0" @@ -721,6 +808,28 @@ dependencies = [ "syn 2.0.71", ] +[[package]] +name = "cosmwasm-std" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad011ae7447188e26e4a7dbca2fcd0fc186aa21ae5c86df0503ea44c78f9e469" +dependencies = [ + "base64 0.21.7", + "bech32 0.9.1", + "bnum 0.8.1", + "cosmwasm-crypto 1.5.2", + "cosmwasm-derive 1.5.5", + "derivative", + "forward_ref", + "hex", + "schemars", + "serde", + "serde-json-wasm 0.5.2", + "sha2 0.10.8", + "static_assertions", + "thiserror", +] + [[package]] name = "cosmwasm-std" version = "2.1.0" @@ -728,17 +837,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2522fb5c9a0409712bb1d036128bccf3564e6b2ac82f942ae4cf3c8df3e26fa8" dependencies = [ "base64 0.22.1", - "bech32", - "bnum", + "bech32 0.11.0", + "bnum 0.11.0", "cosmwasm-core", - "cosmwasm-crypto", - "cosmwasm-derive", + "cosmwasm-crypto 2.1.0", + "cosmwasm-derive 2.1.0", "derive_more 1.0.0-beta.6", "hex", - "rand_core", + "rand_core 0.6.4", "schemars", "serde", - "serde-json-wasm", + "serde-json-wasm 1.0.1", "sha2 0.10.8", "static_assertions", "thiserror", @@ -800,7 +909,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -824,6 +933,19 @@ dependencies = [ "cipher", ] +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + [[package]] name = "curve25519-dalek" version = "4.1.3" @@ -859,11 +981,30 @@ checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" dependencies = [ "byteorder", "digest 0.9.0", - "rand_core", + "rand_core 0.6.4", "subtle-ng", "zeroize", ] +[[package]] +name = "cw-multi-test" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d818f5323c80ed4890db7f89d65eda3f0261fe21878e628c27ea2d8de4b7ba4" +dependencies = [ + "anyhow", + "cosmwasm-std 1.5.2", + "cw-storage-plus 1.2.0", + "cw-utils 1.0.3", + "derivative", + "itertools 0.11.0", + "prost", + "schemars", + "serde", + "sha2 0.10.8", + "thiserror", +] + [[package]] name = "cw-multi-test" version = "2.1.0" @@ -871,10 +1012,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0034bfb4c06dfc8b50f0b1a06c3fc0f2312a1bae568a97db65930de071288ba" dependencies = [ "anyhow", - "bech32", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", + "bech32 0.11.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", + "cw-utils 2.0.0", "derivative", "itertools 0.13.0", "prost", @@ -914,13 +1055,24 @@ dependencies = [ "tokio", ] +[[package]] +name = "cw-storage-plus" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" +dependencies = [ + "cosmwasm-std 1.5.2", + "schemars", + "serde", +] + [[package]] name = "cw-storage-plus" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" dependencies = [ - "cosmwasm-std", + "cosmwasm-std 2.1.0", "schemars", "serde", ] @@ -929,44 +1081,74 @@ dependencies = [ name = "cw-tee-mtcs" version = "0.1.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw2", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", + "cw2 2.0.0", "cw20", "cw20-base", "getrandom", "hex", "k256", - "quartz-cw", + "quartz-common", "schemars", "serde_json", "sha2 0.10.8", "thiserror", ] +[[package]] +name = "cw-utils" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" +dependencies = [ + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", + "cw2 1.1.2", + "schemars", + "semver", + "serde", + "thiserror", +] + [[package]] name = "cw-utils" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07dfee7f12f802431a856984a32bce1cb7da1e6c006b5409e3981035ce562dec" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", "schemars", "serde", "thiserror", ] +[[package]] +name = "cw2" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" +dependencies = [ + "cosmwasm-schema 1.5.5", + "cosmwasm-std 1.5.2", + "cw-storage-plus 1.2.0", + "schemars", + "semver", + "serde", + "thiserror", +] + [[package]] name = "cw2" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", "schemars", "semver", "serde", @@ -979,9 +1161,9 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a42212b6bf29bbdda693743697c621894723f35d3db0d5df930be22903d0e27c" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-utils", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-utils 2.0.0", "schemars", "serde", ] @@ -992,10 +1174,10 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6de8c32e100f1fca306972d86b617234a5e6b00594ea2b48716fd6804d4d95d" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw2", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", + "cw2 2.0.0", "cw20", "schemars", "semver", @@ -1007,15 +1189,17 @@ dependencies = [ name = "cycles-sync" version = "0.1.0" dependencies = [ + "anyhow", "async-trait", "bip32", "clap", "cosmrs", - "cosmwasm-std", + "cosmwasm-std 2.1.0", + "cw-tee-mtcs", "displaydoc", "ecies", "hex", - "rand_core", + "rand_core 0.6.4", "reqwest 0.12.5", "serde", "serde_json", @@ -1222,7 +1406,7 @@ dependencies = [ "libsecp256k1", "once_cell", "parking_lot", - "rand_core", + "rand_core 0.6.4", "sha2 0.10.8", "typenum", "wasm-bindgen", @@ -1246,7 +1430,22 @@ checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" dependencies = [ "curve25519-dalek-ng", "hex", - "rand_core", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek 3.2.0", + "hashbrown 0.12.3", + "hex", + "rand_core 0.6.4", + "serde", "sha2 0.9.9", "zeroize", ] @@ -1257,11 +1456,11 @@ version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ - "curve25519-dalek", + "curve25519-dalek 4.1.3", "ed25519", "hashbrown 0.14.5", "hex", - "rand_core", + "rand_core 0.6.4", "sha2 0.10.8", "zeroize", ] @@ -1285,7 +1484,7 @@ dependencies = [ "generic-array", "group", "pkcs8", - "rand_core", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -1338,7 +1537,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1385,6 +1584,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "forward_ref" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" + [[package]] name = "futures" version = "0.3.30" @@ -1421,6 +1626,17 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + [[package]] name = "futures-sink" version = "0.3.30" @@ -1440,10 +1656,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", + "futures-macro", "futures-sink", "futures-task", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -1493,7 +1711,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1527,6 +1745,9 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] [[package]] name = "hashbrown" @@ -1534,7 +1755,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash", + "ahash 0.8.11", ] [[package]] @@ -1543,7 +1764,7 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash", + "ahash 0.8.11", "allocator-api2", ] @@ -1850,6 +2071,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.12.1" @@ -1892,7 +2122,9 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "once_cell", "sha2 0.10.8", + "signature", ] [[package]] @@ -2037,7 +2269,7 @@ dependencies = [ "mc-sgx-core-sys-types", "mc-sgx-util", "nom", - "rand_core", + "rand_core 0.6.4", "serde", "subtle", ] @@ -2135,6 +2367,32 @@ dependencies = [ "serde", ] +[[package]] +name = "mtcs-enclave" +version = "0.1.0" +dependencies = [ + "clap", + "color-eyre", + "cosmrs", + "cosmwasm-std 2.1.0", + "cw-multi-test 2.1.0", + "cw-tee-mtcs", + "ecies", + "hex", + "k256", + "mtcs", + "prost", + "quartz-common", + "serde", + "serde_json", + "tendermint 0.36.0", + "tendermint-light-client", + "thiserror", + "tokio", + "tonic", + "tonic-build", +] + [[package]] name = "mtcs-intent" version = "0.1.0" @@ -2142,7 +2400,7 @@ dependencies = [ "bip32", "clap", "cosmrs", - "cosmwasm-std", + "cosmwasm-std 2.1.0", "ecies", "hex", "k256", @@ -2584,36 +2842,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "quartz-app-mtcs-enclave" -version = "0.1.0" -dependencies = [ - "clap", - "color-eyre", - "cosmrs", - "cosmwasm-std", - "cw-multi-test", - "cw-proof", - "cw-tee-mtcs", - "cycles-sync", - "ecies", - "hex", - "k256", - "mtcs", - "prost", - "quartz-cw", - "quartz-enclave", - "quartz-proto", - "serde", - "serde_json", - "tendermint 0.36.0", - "tendermint-light-client", - "thiserror", - "tokio", - "tonic", - "tonic-build", -] - [[package]] name = "quartz-app-transfers-enclave" version = "0.1.0" @@ -2622,15 +2850,14 @@ dependencies = [ "clap", "color-eyre", "cosmrs", - "cosmwasm-std", + "cosmwasm-std 2.1.0", + "cw-multi-test 0.17.0", "cycles-sync", "ecies", "hex", "k256", "prost", - "quartz-cw", - "quartz-enclave", - "quartz-proto", + "quartz-common", "serde", "serde_json", "sha2 0.10.8", @@ -2643,13 +2870,22 @@ dependencies = [ "transfers-contract", ] +[[package]] +name = "quartz-common" +version = "0.1.0" +dependencies = [ + "quartz-cw", + "quartz-enclave", + "quartz-proto", +] + [[package]] name = "quartz-cw" version = "0.1.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", "k256", "quartz-tee-ra", "serde", @@ -2665,10 +2901,8 @@ dependencies = [ "clap", "color-eyre", "cosmrs", - "cosmwasm-std", + "cosmwasm-std 2.1.0", "cw-proof", - "cw-tee-mtcs", - "cycles-sync", "ecies", "hex", "k256", @@ -2703,7 +2937,7 @@ dependencies = [ "clap", "cosmos-sdk-proto", "cosmrs", - "cosmwasm-std", + "cosmwasm-std 2.1.0", "displaydoc", "ecies", "k256", @@ -2724,8 +2958,8 @@ dependencies = [ name = "quartz-tee-ra" version = "0.1.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", "der", "displaydoc", "hex", @@ -2808,7 +3042,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -2818,9 +3052,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", ] +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" + [[package]] name = "rand_core" version = "0.6.4" @@ -2927,7 +3167,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.12", - "rustls-native-certs", + "rustls-native-certs 0.6.3", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -3075,6 +3315,20 @@ dependencies = [ "sct", ] +[[package]] +name = "rustls" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.5", + "subtle", + "zeroize", +] + [[package]] name = "rustls" version = "0.23.11" @@ -3101,6 +3355,19 @@ dependencies = [ "security-framework", ] +[[package]] +name = "rustls-native-certs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.1.2", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -3207,6 +3474,44 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scripts" +version = "0.1.0" +dependencies = [ + "anyhow", + "base64 0.22.1", + "clap", + "color-eyre", + "cosmrs", + "cosmwasm-std 2.1.0", + "cw-proof", + "cw-tee-mtcs", + "cycles-sync", + "ecies", + "futures-util", + "hex", + "k256", + "mtcs", + "mtcs-enclave", + "once_cell", + "prost", + "quartz-common", + "quartz-tee-ra", + "regex", + "reqwest 0.12.5", + "serde", + "serde_json", + "subtle-encoding", + "tendermint 0.36.0", + "tendermint-light-client", + "tendermint-rpc", + "thiserror", + "tm-prover", + "tokio", + "tokio-tungstenite", + "tonic", +] + [[package]] name = "sct" version = "0.7.1" @@ -3269,6 +3574,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-json-wasm" +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" @@ -3390,6 +3704,17 @@ dependencies = [ "syn 2.0.71", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha2" version = "0.9.9" @@ -3440,7 +3765,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -3773,6 +4098,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21e3c231a3632cab53f92ad4161c730c468c08cfe4f0aa5a6735b53b390aecbd" dependencies = [ "async-trait", + "async-tungstenite", "bytes", "flex-error", "futures", @@ -3952,6 +4278,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.4", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.0" @@ -3974,6 +4311,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.23.0", +] + [[package]] name = "tokio-util" version = "0.7.11" @@ -4143,14 +4492,13 @@ dependencies = [ name = "transfers-contract" version = "0.1.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw2", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "cw-storage-plus 2.0.0", + "cw-utils 2.0.0", + "cw2 2.0.0", "cw20-base", - "getrandom", - "quartz-cw", + "quartz-common", "serde", "serde_json", "sha2 0.10.8", @@ -4163,6 +4511,45 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "rustls 0.22.4", + "rustls-pki-types", + "sha1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "tungstenite" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e2ce1e47ed2994fd43b04c8f618008d4cabdd5ee34027cf14f9d918edd9c8" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "utf-8", +] + [[package]] name = "typenum" version = "1.17.0" @@ -4223,6 +4610,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "uuid" version = "1.10.0" diff --git a/Cargo.toml b/Cargo.toml index 2d91f34..2b8796a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,10 +2,12 @@ resolver = "2" members = [ "apps/mtcs/enclave", + "apps/mtcs/scripts", "apps/transfers/enclave", "cli", "core/light-client-proofs/*", - "core/quartz", + "core/quartz", + "core/quartz-common", "cosmwasm/packages/*", "utils/*", ] @@ -76,15 +78,20 @@ mc-attestation-verifier = { git = "https://github.com/informalsystems/attestatio # quartz cw-proof = { path = "core/light-client-proofs/cw-proof", default-features = false } -cw-tee-mtcs = { path = "apps/mtcs/contracts/cw-tee-mtcs", default-features = false } cycles-sync = { path = "utils/cycles-sync", default-features = false } -mtcs = { git = "ssh://git@github.com/informalsystems/mtcs.git", default-features = false } +quartz-common = { path = "core/quartz-common" } quartz-cw = { path = "cosmwasm/packages/quartz-cw", default-features = false } quartz-enclave = { path = "core/quartz", default-features = false } quartz-proto = { path = "core/quartz-proto", default-features = false } quartz-relayer = { path = "relayer", default-features = false } quartz-tee-ra = { path = "cosmwasm/packages/quartz-tee-ra", default-features = false } +tm-prover = { path = "utils/tm-prover", default-features = false } tm-stateless-verifier = { path = "core/light-client-proofs/tm-stateless-verifier", default-features = false } + +# quartz apps +cw-tee-mtcs = { path = "apps/mtcs/contracts/cw-tee-mtcs", default-features = false } +mtcs = { git = "ssh://git@github.com/informalsystems/mtcs.git", default-features = false } +mtcs-enclave = { path = "apps/mtcs/enclave" } transfers-contract = { path = "apps/transfers/contracts", default-features = false } [profile.release] diff --git a/apps/mtcs/contracts/cw-tee-mtcs/Cargo.lock b/apps/mtcs/contracts/cw-tee-mtcs/Cargo.lock index e0dbb26..f0a4ea1 100644 --- a/apps/mtcs/contracts/cw-tee-mtcs/Cargo.lock +++ b/apps/mtcs/contracts/cw-tee-mtcs/Cargo.lock @@ -43,7 +43,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", "synstructure", ] @@ -55,7 +55,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] @@ -96,9 +96,9 @@ checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block-buffer" @@ -144,9 +144,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.103" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2755ff20a1d93490d26ba33a6f092a38a508398a5320df5d4b3014fcccce9410" +checksum = "eaff6f8ce506b9773fa786672d63fc7a191ffea1be33f72bbd4aeacefca9ffc8" [[package]] name = "cfg-if" @@ -317,7 +317,7 @@ dependencies = [ "getrandom", "hex", "k256", - "quartz-cw", + "quartz-common", "schemars", "serde_json", "sha2 0.10.8", @@ -384,9 +384,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -394,27 +394,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] name = "darling_macro" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] @@ -452,13 +452,13 @@ dependencies = [ [[package]] name = "der_derive" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" +checksum = "8034092389675178f570469e6c3b0465d3d30b4505c294a6550db47f3c17ad18" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] @@ -504,13 +504,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] @@ -550,9 +550,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -810,9 +810,9 @@ source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca5 [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "minimal-lexical" @@ -832,9 +832,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -933,9 +933,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -960,7 +960,14 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", +] + +[[package]] +name = "quartz-common" +version = "0.1.0" +dependencies = [ + "quartz-cw", ] [[package]] @@ -1086,7 +1093,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] @@ -1111,9 +1118,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -1129,13 +1136,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] @@ -1146,14 +1153,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", @@ -1162,9 +1169,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.1" +version = "3.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +checksum = "e73139bc5ec2d45e6c5fd85be5a46949c1c39a4c18e56915f5eb4c12f975e377" dependencies = [ "serde", "serde_derive", @@ -1173,14 +1180,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.1" +version = "3.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +checksum = "b80d3d6b56b64335c0180e5ffde23b3c5e08c14c585b51a15bd0e95393f46703" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] @@ -1247,9 +1254,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -1264,9 +1271,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" dependencies = [ "proc-macro2", "quote", @@ -1281,7 +1288,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] @@ -1301,7 +1308,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", ] [[package]] @@ -1386,7 +1393,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", "wasm-bindgen-shared", ] @@ -1408,7 +1415,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.70", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1430,9 +1437,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1446,51 +1453,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "x509-cert" diff --git a/apps/mtcs/contracts/cw-tee-mtcs/Cargo.toml b/apps/mtcs/contracts/cw-tee-mtcs/Cargo.toml index 93b9e30..45935d3 100644 --- a/apps/mtcs/contracts/cw-tee-mtcs/Cargo.toml +++ b/apps/mtcs/contracts/cw-tee-mtcs/Cargo.toml @@ -20,7 +20,8 @@ incremental = false overflow-checks = true [features] -mock-sgx = ["quartz-cw/mock-sgx"] +library = [] +mock-sgx = ["quartz-common/mock-sgx-cw"] [dependencies] # external @@ -40,11 +41,11 @@ cw20 = "2.0.0" cw2 = "2.0.0" # quartz -quartz-cw = { path = "../../../../cosmwasm/packages/quartz-cw" } +quartz-common = { path = "../../../../core/quartz-common/", features = ["contract"]} # patch indirect deps getrandom = { version = "0.2.15", features = ["js"] } [dev-dependencies] cw-multi-test = "2.0.0" -serde_json = "1.0.113" +serde_json = "1.0.113" \ No newline at end of file diff --git a/apps/mtcs/contracts/cw-tee-mtcs/src/contract.rs b/apps/mtcs/contracts/cw-tee-mtcs/src/contract.rs index d2cc6e4..549e0de 100644 --- a/apps/mtcs/contracts/cw-tee-mtcs/src/contract.rs +++ b/apps/mtcs/contracts/cw-tee-mtcs/src/contract.rs @@ -1,13 +1,10 @@ use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, - Uint128, Uint64, + Uint64, }; use cw2::set_contract_version; -use cw20_base::{ - contract::query_balance as cw20_query_balance, - state::{MinterData, TokenInfo, TOKEN_INFO}, -}; -use quartz_cw::{handler::RawHandler, state::EPOCH_COUNTER}; +use cw20_base::contract::query_balance as cw20_query_balance; +use quartz_common::contract::{handler::RawHandler, state::EPOCH_COUNTER}; use crate::{ error::ContractError, @@ -19,7 +16,7 @@ use crate::{ ExecuteMsg, InstantiateMsg, QueryMsg, }, state::{ - current_epoch_key, LiquiditySourcesItem, ObligationsItem, State, LIQUIDITY_SOURCES_KEY, + current_epoch_key, ObligationsItem, State, LIQUIDITY_SOURCES, LIQUIDITY_SOURCES_KEY, OBLIGATIONS_KEY, STATE, }, }; @@ -41,6 +38,7 @@ pub fn instantiate( let state = State { owner: info.sender.to_string(), }; + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; STATE.save(deps.storage, &state)?; @@ -50,22 +48,9 @@ pub fn instantiate( ObligationsItem::new_dyn(current_epoch_key(OBLIGATIONS_KEY, deps.storage)?) .save(deps.storage, &Default::default())?; - LiquiditySourcesItem::new_dyn(current_epoch_key(LIQUIDITY_SOURCES_KEY, deps.storage)?) - .save(deps.storage, &Default::default())?; - - // store token info using cw20-base format - let data = TokenInfo { - name: "USD".to_string(), - symbol: "!$".to_string(), - decimals: 0, - total_supply: Uint128::zero(), - // set self as minter, so we can properly execute mint and burn - mint: Some(MinterData { - minter: env.contract.address.clone(), - cap: None, - }), - }; - TOKEN_INFO.save(deps.storage, &data)?; + // TODO: this can be removed. We don't need to instantiate liquidity sources, users will do so when submitting obligations + let epoch = current_epoch_key(LIQUIDITY_SOURCES_KEY, deps.storage)?; + LIQUIDITY_SOURCES.save(deps.storage, &epoch, &vec![])?; Ok(Response::new() .add_attribute("method", "instantiate") @@ -97,19 +82,21 @@ pub fn execute( for o in obligations { execute::submit_obligation(deps.branch(), o.ciphertext, o.digest)?; } - execute::set_liquidity_sources(deps, liquidity_sources)?; + + execute::append_liquidity_sources(deps, liquidity_sources)?; Ok(Response::new()) } ExecuteMsg::SubmitSetoffs(attested_msg) => { - let _ = attested_msg - .clone() - .handle_raw(deps.branch(), &env, &info)?; + // let _ = attested_msg + // .clone() + // .handle_raw(deps.branch(), &env, &info)?; let SubmitSetoffsMsg { setoffs_enc } = attested_msg.msg.0; execute::submit_setoffs(deps, env, setoffs_enc) } ExecuteMsg::InitClearing => execute::init_clearing(deps), ExecuteMsg::SetLiquiditySources(SetLiquiditySourcesMsg { liquidity_sources }) => { - execute::set_liquidity_sources(deps, liquidity_sources) + execute::append_liquidity_sources(deps, liquidity_sources)?; + Ok(Response::new()) } } } @@ -117,15 +104,21 @@ pub fn execute( pub mod execute { use std::collections::BTreeMap; - use cosmwasm_std::{DepsMut, Env, HexBinary, MessageInfo, Response, StdResult, Uint64}; - use cw20_base::contract::{execute_burn, execute_mint}; - use k256::ecdsa::VerifyingKey; - use quartz_cw::state::{Hash, EPOCH_COUNTER}; + use cosmwasm_std::{ + to_json_binary, Addr, DepsMut, Env, HexBinary, MessageInfo, Response, StdResult, Storage, + SubMsg, Uint64, WasmMsg, + }; + use cw20_base::contract::execute_mint; + use quartz_common::contract::state::{Hash, EPOCH_COUNTER}; + // use mtcs_overdraft::msg::ExecuteMsg as OverdraftExecuteMsg; + use crate::msg::OverdraftExecuteMsg; // TODO: change when dependency issue fiexed use crate::{ + msg::execute::EscrowExecuteMsg, state::{ - current_epoch_key, previous_epoch_key, LiquiditySourcesItem, ObligationsItem, RawHash, - SetoffsItem, SettleOff, LIQUIDITY_SOURCES_KEY, OBLIGATIONS_KEY, SETOFFS_KEY, + current_epoch_key, previous_epoch_key, LiquiditySource, LiquiditySourceType, + ObligationsItem, RawHash, SetoffsItem, SettleOff, Transfer, LIQUIDITY_SOURCES, + LIQUIDITY_SOURCES_KEY, OBLIGATIONS_KEY, SETOFFS_KEY, }, ContractError, }; @@ -160,15 +153,16 @@ pub mod execute { let _: Hash = digest.to_array()?; // store the `(digest, ciphertext)` tuple - ObligationsItem::new_dyn(current_epoch_key(OBLIGATIONS_KEY, deps.storage)?).update( - deps.storage, - |mut obligations| { - if let Some(_duplicate) = obligations.insert(digest.clone(), ciphertext.clone()) { - return Err(ContractError::DuplicateEntry); - } - Ok(obligations) - }, - )?; + let obligs_key = + ObligationsItem::new_dyn(current_epoch_key(OBLIGATIONS_KEY, deps.storage)?); + + let mut epoch_obligation = obligs_key.may_load(deps.storage)?.unwrap_or_default(); + + if let Some(_duplicate) = epoch_obligation.insert(digest.clone(), ciphertext.clone()) { + return Err(ContractError::DuplicateEntry); + } + + obligs_key.save(deps.storage, &epoch_obligation)?; Ok(Response::new() .add_attribute("action", "submit_obligation") @@ -176,66 +170,162 @@ pub mod execute { .add_attribute("ciphertext", ciphertext.to_string())) } - pub fn set_liquidity_sources( + pub fn append_liquidity_sources( deps: DepsMut, - liquidity_sources: Vec, - ) -> Result { - // validate liquidity sources as public keys - liquidity_sources - .iter() - .try_for_each(|ls| VerifyingKey::from_sec1_bytes(ls).map(|_| ()))?; + new_liquidity_sources: Vec, + ) -> Result<(), ContractError> { + let epoch = current_epoch_key(LIQUIDITY_SOURCES_KEY, deps.storage)?; + let mut liquidity_sources = LIQUIDITY_SOURCES + .may_load(deps.storage, &epoch)? + .unwrap_or_default(); - // store the liquidity sources - LiquiditySourcesItem::new_dyn(current_epoch_key(LIQUIDITY_SOURCES_KEY, deps.storage)?) - .update(deps.storage, |mut ls| { - ls.clear(); - ls.extend(liquidity_sources); - Ok::<_, ContractError>(ls) - })?; + let mut new_sources = vec![]; + for liquidity_source in new_liquidity_sources { + // Validate the Cosmos address + let address = deps + .api + .addr_validate(&liquidity_source.address.to_string())?; - Ok(Response::default()) + let liquidity_source = LiquiditySource { + address: address.clone(), + source_type: liquidity_source.source_type, + }; + + new_sources.push(liquidity_source); + } + + liquidity_sources.append(&mut new_sources); + + // Save the new liquidity sources + LIQUIDITY_SOURCES.save(deps.storage, &epoch, &liquidity_sources)?; + + Ok(()) } pub fn submit_setoffs( - mut deps: DepsMut, - env: Env, + deps: DepsMut, + _env: Env, setoffs_enc: BTreeMap, ) -> Result { - // store the `BTreeMap` + // Store the setoffs SetoffsItem::new_dyn(previous_epoch_key(SETOFFS_KEY, deps.storage)?) .save(deps.storage, &setoffs_enc)?; + let mut messages = vec![]; + for (_, so) in setoffs_enc { if let SettleOff::Transfer(t) = so { - let info = MessageInfo { - sender: env.contract.address.clone(), - funds: vec![], - }; + // Check if either payer or payee is a liquidity source + let payer_source = find_liquidity_source(deps.storage, &t.payer)?; + let payee_source = find_liquidity_source(deps.storage, &t.payee)?; - execute_mint( - deps.branch(), - env.clone(), - info.clone(), - t.payee.to_string(), - t.amount.into(), - )?; - - let payer = deps.api.addr_validate(&t.payer.to_string())?; - let info = MessageInfo { - sender: payer, - funds: vec![], - }; - - execute_burn(deps.branch(), env.clone(), info, t.amount.into())?; + match (payer_source, payee_source) { + (Some(source), None) => { + // Payer is a liquidity source + let msg = create_transfer_message(&source, &t, true)?; + messages.push(msg); + } + (None, Some(source)) => { + // Payee is a liquidity source + let msg = create_transfer_message(&source, &t, false)?; + messages.push(msg); + } + (_, _) => { + // As of now, transfers should only be between a user and liquidity source. + return Err(ContractError::LiquiditySourceNotFound {}); + } + } } } - Ok(Response::new().add_attribute("action", "submit_setoffs")) + Ok(Response::new() + .add_submessages(messages) + .add_attribute("action", "submit_setoffs")) + } + + fn find_liquidity_source( + storage: &dyn Storage, + address: &Addr, + ) -> Result, ContractError> { + // TODO: check that .ok() is correct here + let liquidity_sources = LIQUIDITY_SOURCES.load( + storage, + &previous_epoch_key(LIQUIDITY_SOURCES_KEY, storage)?, + )?; + + Ok(liquidity_sources + .into_iter() + .find(|lqs| lqs.address == address)) + } + + fn create_transfer_message( + source: &LiquiditySource, + transfer: &Transfer, + is_payer: bool, + ) -> Result { + let msg = match source.source_type { + LiquiditySourceType::Escrow => { + let (payer, payee, amount) = if is_payer { + ( + transfer.payer.to_string(), + transfer.payee.to_string(), + vec![transfer.amount.clone()], + ) + } else { + // If the liquidity source is the payee, we swap payer and payee + ( + transfer.payee.to_string(), + transfer.payer.to_string(), + vec![transfer.amount.clone()], + ) + }; + + WasmMsg::Execute { + contract_addr: source.address.to_string(), + msg: to_json_binary(&EscrowExecuteMsg::ExecuteSetoff { + payer, + payee, + amount, + })?, + funds: vec![], + } + } + LiquiditySourceType::Overdraft => { + if is_payer { + let increase_msg = WasmMsg::Execute { + contract_addr: source.address.to_string(), + msg: to_json_binary(&OverdraftExecuteMsg::IncreaseBalance { + receiver: transfer.payee.clone(), + amount: transfer.amount.1, + })?, + funds: vec![], + }; + + increase_msg + } else { + let decrease_msg = WasmMsg::Execute { + contract_addr: source.address.to_string(), + msg: to_json_binary(&OverdraftExecuteMsg::DecreaseBalance { + receiver: transfer.payer.clone(), + amount: transfer.amount.1, + })?, + funds: vec![], + }; + + decrease_msg + } + } + LiquiditySourceType::External => { + return Err(ContractError::UnsupportedLiquiditySource {}) + } + }; + + Ok(SubMsg::new(msg)) } pub fn init_clearing(deps: DepsMut) -> Result { - EPOCH_COUNTER.update(deps.storage, |mut counter| -> StdResult<_> { - counter = counter.saturating_add(Uint64::from(1u64)); + EPOCH_COUNTER.update(deps.storage, |counter| -> StdResult<_> { + counter.checked_add(Uint64::new(1))?; Ok(counter) })?; Ok(Response::new().add_attribute("action", "init_clearing")) @@ -259,7 +349,7 @@ pub mod query { use crate::{ msg::{GetAllSetoffsResponse, GetLiquiditySourcesResponse}, state::{ - current_epoch_key, epoch_key, previous_epoch_key, LiquiditySourcesItem, SetoffsItem, + current_epoch_key, epoch_key, previous_epoch_key, SetoffsItem, LIQUIDITY_SOURCES, LIQUIDITY_SOURCES_KEY, SETOFFS_KEY, }, }; @@ -272,6 +362,7 @@ pub mod query { Ok(GetAllSetoffsResponse { setoffs }) } + // Function to get liquidity sources for a specific epoch pub fn get_liquidity_sources( deps: Deps, epoch: Option, @@ -281,10 +372,8 @@ pub mod query { Some(e) => epoch_key(LIQUIDITY_SOURCES_KEY, e)?, }; - let liquidity_sources = LiquiditySourcesItem::new_dyn(epoch_key) - .load(deps.storage)? - .into_iter() - .collect(); + let liquidity_sources = LIQUIDITY_SOURCES.load(deps.storage, &epoch_key)?; + Ok(GetLiquiditySourcesResponse { liquidity_sources }) } } diff --git a/apps/mtcs/contracts/cw-tee-mtcs/src/error.rs b/apps/mtcs/contracts/cw-tee-mtcs/src/error.rs index ff82711..6f66b14 100644 --- a/apps/mtcs/contracts/cw-tee-mtcs/src/error.rs +++ b/apps/mtcs/contracts/cw-tee-mtcs/src/error.rs @@ -2,7 +2,7 @@ use cosmwasm_std::StdError; use cw20_base::ContractError as Cw20ContractError; use hex::FromHexError; use k256::ecdsa::Error as K256Error; -use quartz_cw::error::Error as QuartzError; +use quartz_common::contract::error::Error as QuartzError; use thiserror::Error; #[derive(Error, Debug)] @@ -16,9 +16,15 @@ pub enum ContractError { #[error("Unauthorized")] Unauthorized, + #[error("Liquidity source not found")] + LiquiditySourceNotFound, + #[error("Duplicate entry found")] DuplicateEntry, + #[error("No entry found")] + NoLiquiditySourcesFound, + #[error("Not Secp256K1")] K256(K256Error), @@ -30,6 +36,9 @@ pub enum ContractError { #[error("Cw20 error: {0}")] Cw20(Cw20ContractError), + + #[error("Unsupported liquidity source")] + UnsupportedLiquiditySource, } impl From for ContractError { diff --git a/apps/mtcs/contracts/cw-tee-mtcs/src/lib.rs b/apps/mtcs/contracts/cw-tee-mtcs/src/lib.rs index f71330c..eca0b7f 100644 --- a/apps/mtcs/contracts/cw-tee-mtcs/src/lib.rs +++ b/apps/mtcs/contracts/cw-tee-mtcs/src/lib.rs @@ -1,11 +1,11 @@ -#![deny( - warnings, - trivial_casts, - trivial_numeric_casts, - unused_import_braces, - unused_qualifications -)] -#![forbid(unsafe_code)] +// #![deny( +// warnings, +// trivial_casts, +// trivial_numeric_casts, +// unused_import_braces, +// unused_qualifications +// )] +// #![forbid(unsafe_code)] pub mod contract; mod error; diff --git a/apps/mtcs/contracts/cw-tee-mtcs/src/msg.rs b/apps/mtcs/contracts/cw-tee-mtcs/src/msg.rs index eaf0f8d..9af0268 100644 --- a/apps/mtcs/contracts/cw-tee-mtcs/src/msg.rs +++ b/apps/mtcs/contracts/cw-tee-mtcs/src/msg.rs @@ -1,15 +1,15 @@ use std::collections::BTreeMap; use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{HexBinary, Uint64}; -use quartz_cw::{ +use cosmwasm_std::{Addr, HexBinary, Uint128, Uint64}; +use quartz_common::contract::{ msg::execute::attested::{RawAttested, RawAttestedMsgSansHandler, RawDefaultAttestation}, prelude::*, }; -use crate::state::{RawHash, SettleOff}; +use crate::state::{LiquiditySource, RawHash, SettleOff}; -type AttestedMsg = RawAttested, RA>; +pub type AttestedMsg = RawAttested, RA>; #[cw_serde] pub struct InstantiateMsg(pub QuartzInstantiateMsg); @@ -27,11 +27,44 @@ pub enum ExecuteMsg { SetLiquiditySources(execute::SetLiquiditySourcesMsg), } +// TODO: Added this back here because adding overdraft contract as a dependency is causing errors. Overdraft isn't correctly disabling entrypoints when acting as a dependency +#[cw_serde] +pub enum OverdraftExecuteMsg { + DrawCredit { + receiver: Addr, + amount: Uint128, + }, + DrawCreditFromTender { + debtor: Addr, + amount: Uint128, + }, + TransferCreditFromTender { + sender: Addr, + receiver: Addr, + amount: Uint128, + }, + IncreaseBalance { + receiver: Addr, + amount: Uint128, + }, + DecreaseBalance { + receiver: Addr, + amount: Uint128, + }, + Lock {}, + Unlock {}, + AddOwner { + new: Addr, + }, +} + pub mod execute { - use quartz_cw::{msg::execute::attested::HasUserData, state::UserData}; + use cosmwasm_std::Uint128; + use quartz_common::contract::{msg::execute::attested::HasUserData, state::UserData}; use sha2::{Digest, Sha256}; use super::*; + use crate::state::LiquiditySource; #[cw_serde] pub struct FaucetMintMsg { @@ -56,7 +89,7 @@ pub mod execute { #[cw_serde] pub struct SubmitObligationsMsg { pub obligations: Vec, - pub liquidity_sources: Vec, + pub liquidity_sources: Vec, } #[cw_serde] @@ -86,7 +119,16 @@ pub mod execute { #[cw_serde] pub struct SetLiquiditySourcesMsg { - pub liquidity_sources: Vec, + pub liquidity_sources: Vec, + } + + #[cw_serde] + pub enum EscrowExecuteMsg { + ExecuteSetoff { + payer: String, + payee: String, + amount: Vec<(String, Uint128)>, + }, } } @@ -109,7 +151,7 @@ pub struct GetAllSetoffsResponse { #[cw_serde] pub struct GetLiquiditySourcesResponse { - pub liquidity_sources: Vec, + pub liquidity_sources: Vec, } #[cfg(test)] diff --git a/apps/mtcs/contracts/cw-tee-mtcs/src/state.rs b/apps/mtcs/contracts/cw-tee-mtcs/src/state.rs index 54ebb2d..87ef21b 100644 --- a/apps/mtcs/contracts/cw-tee-mtcs/src/state.rs +++ b/apps/mtcs/contracts/cw-tee-mtcs/src/state.rs @@ -1,16 +1,15 @@ -use std::collections::{BTreeMap, BTreeSet}; +use std::{cmp::Ordering, collections::BTreeMap}; use cosmwasm_schema::cw_serde; -use cosmwasm_std::{HexBinary, StdError, Storage, Uint64}; -use cw_storage_plus::Item; -use quartz_cw::state::EPOCH_COUNTER; +use cosmwasm_std::{Addr, HexBinary, StdError, Storage, Uint128, Uint64}; +use cw_storage_plus::{Item, Map}; +use quartz_common::contract::state::EPOCH_COUNTER; pub type RawHash = HexBinary; pub type RawCipherText = HexBinary; pub type ObligationsItem = Item>; pub type SetoffsItem = Item>; -pub type LiquiditySourcesItem = Item>; #[cw_serde] pub struct State { @@ -19,9 +18,9 @@ pub struct State { #[cw_serde] pub struct Transfer { - pub payer: String, - pub payee: String, - pub amount: u64, + pub payer: Addr, + pub payee: Addr, + pub amount: (String, Uint128), } #[cw_serde] @@ -31,14 +30,43 @@ pub enum SettleOff { Transfer(Transfer), } +#[cw_serde] +#[derive(Copy)] +pub enum LiquiditySourceType { + Escrow, + Overdraft, + External, +} + +#[cw_serde] +pub struct LiquiditySource { + pub address: Addr, + pub source_type: LiquiditySourceType, +} + +impl std::cmp::Ord for LiquiditySource { + fn cmp(&self, other: &Self) -> Ordering { + self.address.cmp(&other.address) + } +} + +impl PartialOrd for LiquiditySource { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.address.cmp(&other.address)) + } +} + +// PartialEq implemented in #[cw_serde] +impl Eq for LiquiditySource {} + pub const STATE: Item = Item::new("state"); pub const OBLIGATIONS_KEY: &str = "obligations"; pub const SETOFFS_KEY: &str = "setoffs"; -pub const LIQUIDITY_SOURCES_KEY: &str = "liquidity_sources"; +pub const LIQUIDITY_SOURCES_KEY: &str = "epoch_liquidity_sources"; +pub const LIQUIDITY_SOURCES: Map<&str, Vec> = Map::new("liquidity_sources"); pub fn current_epoch_key(key: &str, storage: &dyn Storage) -> Result { - let epoch = EPOCH_COUNTER.load(storage)?; - epoch_key(key, epoch.into()) + epoch_key(key, EPOCH_COUNTER.load(storage)?) } pub fn previous_epoch_key(key: &str, storage: &dyn Storage) -> Result { diff --git a/apps/mtcs/enclave/Cargo.toml b/apps/mtcs/enclave/Cargo.toml index 87b3d6c..3b68d88 100644 --- a/apps/mtcs/enclave/Cargo.toml +++ b/apps/mtcs/enclave/Cargo.toml @@ -1,11 +1,22 @@ [package] -name = "quartz-app-mtcs-enclave" +name = "mtcs-enclave" version = "0.1.0" edition = "2021" authors = ["Informal Systems "] +[profile.release] +opt-level = 3 +debug = false +rpath = false +lto = true +debug-assertions = false +codegen-units = 1 +panic = 'abort' +incremental = false +overflow-checks = true + [features] -mock-sgx = ["quartz-cw/mock-sgx", "quartz-enclave/mock-sgx"] +mock-sgx = ["quartz-common/mock-sgx-cw", "quartz-common/mock-sgx-enclave"] [dependencies] # external @@ -28,17 +39,14 @@ tendermint.workspace = true tendermint-light-client.workspace = true # quartz -cw-proof.workspace = true cw-tee-mtcs.workspace = true -cycles-sync.workspace = true mtcs.workspace = true -quartz-cw.workspace = true -quartz-enclave.workspace = true -quartz-proto.workspace = true + +# quartz +quartz-common = { workspace = true, features = ["full"]} [dev-dependencies] cw-multi-test = "2.0.0" -serde_json = "1.0.113" [build-dependencies] tonic-build.workspace = true diff --git a/apps/mtcs/enclave/src/lib.rs b/apps/mtcs/enclave/src/lib.rs new file mode 100644 index 0000000..febacec --- /dev/null +++ b/apps/mtcs/enclave/src/lib.rs @@ -0,0 +1 @@ +pub mod proto; diff --git a/apps/mtcs/enclave/src/main.rs b/apps/mtcs/enclave/src/main.rs index 049e508..a2a303c 100644 --- a/apps/mtcs/enclave/src/main.rs +++ b/apps/mtcs/enclave/src/main.rs @@ -15,6 +15,7 @@ mod cli; mod mtcs_server; mod proto; +mod types; use std::{ sync::{Arc, Mutex}, @@ -25,12 +26,14 @@ use clap::Parser; use cli::Cli; use mtcs_server::MtcsService; use proto::clearing_server::ClearingServer as MtcsServer; -use quartz_cw::state::{Config, LightClientOpts}; -use quartz_enclave::{ - attestor::{Attestor, DefaultAttestor}, - server::CoreService, +use quartz_common::{ + contract::state::{Config, LightClientOpts}, + enclave::{ + attestor::{Attestor, DefaultAttestor}, + server::CoreService, + }, + proto::core_server::CoreServer, }; -use quartz_proto::quartz::core_server::CoreServer; use tonic::transport::Server; #[tokio::main(flavor = "current_thread")] diff --git a/apps/mtcs/enclave/src/mtcs_server.rs b/apps/mtcs/enclave/src/mtcs_server.rs index c0db86d..1bd2f14 100644 --- a/apps/mtcs/enclave/src/mtcs_server.rs +++ b/apps/mtcs/enclave/src/mtcs_server.rs @@ -1,34 +1,37 @@ use std::{ - collections::BTreeMap, + collections::{BTreeMap, BTreeSet}, sync::{Arc, Mutex}, }; -use cosmrs::{tendermint::account::Id as TmAccountId, AccountId}; -use cosmwasm_std::HexBinary; +use cosmwasm_std::{Addr, HexBinary, Uint128}; //TODO: get rid of this use cw_tee_mtcs::{ msg::execute::SubmitSetoffsMsg, - state::{RawHash, SettleOff, Transfer}, + state::{LiquiditySource, LiquiditySourceType, RawHash, SettleOff, Transfer}, }; -use cycles_sync::types::RawObligation; -use ecies::{decrypt, encrypt}; -use k256::ecdsa::{SigningKey, VerifyingKey}; +use ecies::decrypt; +use k256::ecdsa::SigningKey; use mtcs::{ algo::mcmf::primal_dual::PrimalDual, impls::complex_id::ComplexIdMtcs, obligation::SimpleObligation, prelude::DefaultMtcs, setoff::SimpleSetoff, Mtcs, }; -use quartz_cw::{msg::execute::attested::RawAttested, state::Config}; -use quartz_enclave::{attestor::Attestor, server::ProofOfPublication}; +use quartz_common::{ + contract::{msg::execute::attested::RawAttested, state::Config}, + enclave::attestor::Attestor, +}; use serde::{Deserialize, Serialize}; use tonic::{Request, Response, Result as TonicResult, Status}; -use crate::proto::{clearing_server::Clearing, RunClearingRequest, RunClearingResponse}; +use crate::{ + proto::{clearing_server::Clearing, RunClearingRequest, RunClearingResponse}, + types::ContractObligation, +}; pub type RawCipherText = HexBinary; #[derive(Clone, Debug)] pub struct MtcsService { - config: Config, + config: Config, // TODO: this config is not used anywhere sk: Arc>>, attestor: A, } @@ -36,7 +39,7 @@ pub struct MtcsService { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct RunClearingMessage { intents: BTreeMap, - liquidity_sources: Vec, + liquidity_sources: BTreeSet, } impl MtcsService @@ -61,40 +64,25 @@ where &self, request: Request, ) -> TonicResult> { - let message: ProofOfPublication = { + let message: RunClearingMessage = { let message = request.into_inner().message; serde_json::from_str(&message).map_err(|e| Status::invalid_argument(e.to_string()))? }; - - let (proof_value, message) = message - .verify(self.config.light_client_opts()) - .map_err(Status::failed_precondition)?; - - let proof_value_matches_msg = - serde_json::to_string(&message.intents).is_ok_and(|s| s.as_bytes() == proof_value); - if !proof_value_matches_msg { - return Err(Status::failed_precondition("proof verification")); - } - - let digests_ciphertexts = message.intents; + // TODO: ensure no duplicates somewhere else! + let liquidity_sources: Vec = + message.liquidity_sources.into_iter().collect(); + let digests_ciphertexts: BTreeMap = message.intents; let (digests, ciphertexts): (Vec<_>, Vec<_>) = digests_ciphertexts.into_iter().unzip(); let sk = self.sk.lock().unwrap(); - let obligations: Vec> = ciphertexts + let obligations: Vec> = ciphertexts .into_iter() .map(|ciphertext| decrypt_obligation(sk.as_ref().unwrap(), &ciphertext)) .collect(); let mut mtcs = ComplexIdMtcs::wrapping(DefaultMtcs::new(PrimalDual::default())); - let setoffs: Vec> = mtcs.run(obligations).unwrap(); - - let liquidity_sources: Vec<_> = message - .liquidity_sources - .into_iter() - .map(|ls| VerifyingKey::from_sec1_bytes(&ls)) - .collect::>() - .map_err(|e| Status::invalid_argument(e.to_string()))?; + let setoffs: Vec> = mtcs.run(obligations).unwrap(); let setoffs_enc: BTreeMap = setoffs .into_iter() .map(|so| into_settle_offs(so, &liquidity_sources)) @@ -103,7 +91,7 @@ where .collect(); let msg = SubmitSetoffsMsg { setoffs_enc }; - + println!("setoff_msg: {:?}", msg); let attestation = self .attestor .quote(msg.clone()) @@ -111,65 +99,93 @@ where let attested_msg = RawAttested { msg, attestation }; let message = serde_json::to_string(&attested_msg).unwrap(); - Ok(Response::new(RunClearingResponse { message })) } } +// TODO Switch from Vec<_> to Vec fn into_settle_offs( - so: SimpleSetoff, - liquidity_sources: &[VerifyingKey], + so: SimpleSetoff, + liquidity_sources: &Vec, ) -> SettleOff { - let debtor_pk = VerifyingKey::from_sec1_bytes(&so.debtor).unwrap(); - let creditor_pk = VerifyingKey::from_sec1_bytes(&so.creditor).unwrap(); + println!("\nsetoff: {:?}", so); + println!("\nliq sources: {:?}", liquidity_sources); - if let Some(ls_pk) = liquidity_sources.iter().find(|ls| ls == &&debtor_pk) { + // TODO: temporary patch, fix issue with liquidity sources becoming type External + if liquidity_sources + .iter() + .map(|lqs| lqs.address.clone()) + .collect::>() + .contains(&so.debtor.address) + { // A setoff on a tender should result in the creditor's (i.e. the tender receiver) balance // decreasing by the setoff amount SettleOff::Transfer(Transfer { - payer: wasm_address(creditor_pk), - payee: wasm_address(*ls_pk), - amount: so.set_off as u64, + payer: so.creditor.address.clone(), + payee: so.debtor.address.clone(), + // TODO: Include denominations + amount: ("peppicoin".to_owned(), Uint128::from(so.set_off as u128)), }) - } else if let Some(ls_pk) = liquidity_sources.iter().find(|ls| ls == &&creditor_pk) { + } else if liquidity_sources + .iter() + .map(|lqs| lqs.address.clone()) + .collect::>() + .contains(&so.creditor.address) + { // A setoff on an acceptance should result in the debtor's (i.e. the acceptance initiator) // balance increasing by the setoff amount SettleOff::Transfer(Transfer { - payer: wasm_address(*ls_pk), - payee: wasm_address(debtor_pk), - amount: so.set_off as u64, + payer: so.creditor.address.clone(), + payee: so.debtor.address.clone(), + amount: ("peppicoin".to_owned(), Uint128::from(so.set_off as u128)), }) } else { - SettleOff::SetOff(encrypt_setoff(so, debtor_pk, creditor_pk)) + // TODO: Tracked by issue #22 + + // A no-op for the time being. + SettleOff::SetOff(vec![]) } } -fn wasm_address(pk: VerifyingKey) -> String { - let tm_pk = TmAccountId::from(pk); - AccountId::new("wasm", tm_pk.as_bytes()) - .unwrap() - .to_string() -} +// fn wasm_address(pk: VerifyingKey) -> String { +// let tm_pk = TmAccountId::from(pk); +// AccountId::new("wasm", tm_pk.as_bytes()) +// .unwrap() +// .to_string() +// } -fn encrypt_setoff( - so: SimpleSetoff, - debtor_pk: VerifyingKey, - creditor_pk: VerifyingKey, -) -> Vec { - let so_ser = serde_json::to_string(&so).expect("infallible serializer"); - let so_debtor = encrypt(&debtor_pk.to_sec1_bytes(), so_ser.as_bytes()).unwrap(); - let so_creditor = encrypt(&creditor_pk.to_sec1_bytes(), so_ser.as_bytes()).unwrap(); +// fn encrypt_setoff( +// so: SimpleSetoff, +// debtor_pk: VerifyingKey, +// creditor_pk: VerifyingKey, +// ) -> Vec { +// let so_ser = serde_json::to_string(&so).expect("infallible serializer"); +// let so_debtor = encrypt(&debtor_pk.to_sec1_bytes(), so_ser.as_bytes()).unwrap(); +// let so_creditor = encrypt(&creditor_pk.to_sec1_bytes(), so_ser.as_bytes()).unwrap(); - vec![so_debtor.into(), so_creditor.into()] -} +// vec![so_debtor.into(), so_creditor.into()] +// } fn decrypt_obligation( sk: &SigningKey, ciphertext: &RawCipherText, -) -> SimpleObligation { - let o: RawObligation = { +) -> SimpleObligation { + let o: ContractObligation = { let o = decrypt(&sk.to_bytes(), ciphertext).unwrap(); serde_json::from_slice(&o).unwrap() }; - SimpleObligation::new(None, o.debtor, o.creditor, i64::try_from(o.amount).unwrap()).unwrap() + + SimpleObligation::new( + None, + LiquiditySource { + address: o.debtor, + source_type: LiquiditySourceType::External, + }, + LiquiditySource { + address: o.creditor, + source_type: LiquiditySourceType::External, + }, + i64::try_from(o.amount).unwrap(), + ) + .unwrap() } diff --git a/apps/mtcs/enclave/src/types.rs b/apps/mtcs/enclave/src/types.rs new file mode 100644 index 0000000..6f48f4f --- /dev/null +++ b/apps/mtcs/enclave/src/types.rs @@ -0,0 +1,59 @@ +use cosmwasm_std::{Addr, HexBinary}; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ContractObligation { + pub debtor: Addr, + pub creditor: Addr, + pub amount: u64, + #[serde(default)] + pub salt: HexBinary, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct RawObligation { + pub debtor: HexBinary, + pub creditor: HexBinary, + pub amount: u64, + #[serde(default)] + pub salt: HexBinary, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct RawEncryptedObligation { + pub digest: HexBinary, + pub ciphertext: HexBinary, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct SubmitObligationsMsg { + pub submit_obligations: SubmitObligationsMsgInner, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct SubmitObligationsMsgInner { + pub obligations: Vec, + pub liquidity_sources: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RawSetOff { + SetOff(Vec), + Transfer(RawSetOffTransfer), +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct RawSetOffTransfer { + pub payer: String, + pub payee: String, + pub amount: u64, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct RawOffset { + pub debtor: HexBinary, + pub creditor: HexBinary, + pub amount: u64, + pub set_off: u64, +} diff --git a/apps/mtcs/scripts/Cargo.lock b/apps/mtcs/scripts/Cargo.lock new file mode 100644 index 0000000..605c122 --- /dev/null +++ b/apps/mtcs/scripts/Cargo.lock @@ -0,0 +1,4723 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "asn1-rs" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "async-trait" +version = "0.1.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "async-tungstenite" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3609af4bbf701ddaf1f6bb4e6257dff4ff8932327d0e685d3f653724c258b1ac" +dependencies = [ + "futures-io", + "futures-util", + "log", + "pin-project-lite", + "rustls-native-certs 0.7.1", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.25.0", + "tungstenite 0.21.0", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.30", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 0.1.2", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bip32" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e141fb0f8be1c7b45887af94c88b182472b57c96b56773250ae00cd6a14a164" +dependencies = [ + "bs58", + "hmac", + "k256", + "once_cell", + "pbkdf2", + "rand_core 0.6.4", + "ripemd", + "sha2 0.10.8", + "subtle", + "zeroize", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "blake3" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bnum" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9008b6bb9fc80b5277f2fe481c09e828743d9151203e804583eb4c9e15b31d" + +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "sha2 0.10.8", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +dependencies = [ + "serde", +] + +[[package]] +name = "cc" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "324c74f2155653c90b04f25b2a47a8a631360cb908f92a772695f430c7e31052" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "clap" +version = "4.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6b81fb3c84f5563d509c59b5a48d935f689e993afa90fe39047f05adef9142" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca6706fd5224857d9ac5eb9355f6683563cc0541c7cd9d014043b57cbec78ac" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "clap_lex" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" + +[[package]] +name = "color-eyre" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" +dependencies = [ + "backtrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", +] + +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "contracts" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d1429e3bd78171c65aa010eabcdf8f863ba3254728dbfb0ad4b1545beac15c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "cosmos-sdk-proto" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e23f6ab56d5f031cde05b8b82a5fefd3a1a223595c79e32317a97189e612bc" +dependencies = [ + "prost 0.12.6", + "prost-types 0.12.6", + "tendermint-proto 0.35.0", + "tonic", +] + +[[package]] +name = "cosmrs" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d184abb7b0039cc64f282dfa5b34165e4c5a7410ab46804636d53f4d09aee44" +dependencies = [ + "bip32", + "cosmos-sdk-proto", + "ecdsa", + "eyre", + "k256", + "rand_core 0.6.4", + "serde", + "serde_json", + "signature", + "subtle-encoding", + "tendermint 0.35.0", + "thiserror", +] + +[[package]] +name = "cosmwasm-crypto" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6aa9f904de106fa16443ad14ec2abe75e94ba003bb61c681c0e43d4c58d2a" +dependencies = [ + "digest 0.10.7", + "ecdsa", + "ed25519-zebra", + "k256", + "rand_core 0.6.4", + "thiserror", +] + +[[package]] +name = "cosmwasm-derive" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "242e98e7a231c122e08f300d9db3262d1007b51758a8732cd6210b3e9faa4f3a" +dependencies = [ + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-schema" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7879036156092ad1c22fe0d7316efc5a5eceec2bc3906462a2560215f2a2f929" +dependencies = [ + "cosmwasm-schema-derive", + "schemars", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb57855fbfc83327f8445ae0d413b1a05ac0d68c396ab4d122b2abd7bb82cb6" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-std" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad011ae7447188e26e4a7dbca2fcd0fc186aa21ae5c86df0503ea44c78f9e469" +dependencies = [ + "base64 0.21.7", + "bech32", + "bnum", + "cosmwasm-crypto", + "cosmwasm-derive", + "derivative", + "forward_ref", + "hex", + "schemars", + "serde", + "serde-json-wasm", + "sha2 0.10.8", + "static_assertions", + "thiserror", +] + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "critical-section" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" + +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-ng" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.6.4", + "subtle-ng", + "zeroize", +] + +[[package]] +name = "cw-controllers" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57de8d3761e46be863e3ac1eba8c8a976362a48c6abf240df1e26c3e421ee9e8" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw-proof" +version = "0.1.0" +dependencies = [ + "clap", + "cosmrs", + "displaydoc", + "ics23", + "prost 0.12.6", + "serde", + "serde_with", + "tendermint 0.36.0", + "tendermint-rpc 0.36.0", +] + +[[package]] +name = "cw-storage-plus" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + +[[package]] +name = "cw-tee-mtcs" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "cw2", + "cw20", + "cw20-base", + "getrandom", + "hex", + "k256", + "quartz-common", + "schemars", + "serde", + "serde_json", + "sha2 0.10.8", + "thiserror", +] + +[[package]] +name = "cw-utils" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw2", + "schemars", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "cw0" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae676b6cced78a3d38ad4b01ab4ed66fc78ac191c3c0d6bfd5372cb2efd473b" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw2" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "schemars", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "cw20" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-utils", + "schemars", + "serde", +] + +[[package]] +name = "cw20-base" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ad79e86ea3707229bf78df94e08732e8f713207b4a77b2699755596725e7d9" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "cw2", + "cw20", + "schemars", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "cw4" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24754ff6e45f2a1c60adc409d9b2eb87666012c44021329141ffaab3388fccd2" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "schemars", + "serde", +] + +[[package]] +name = "cw4-group" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e24a22c3af54c52edf528673b420a67a1648be2c159b8ec778d2fbf543df24b" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-controllers", + "cw-storage-plus", + "cw-utils", + "cw2", + "cw4", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cycles-sync" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "bip32", + "clap", + "cosmrs", + "cosmwasm-std", + "cw-tee-mtcs", + "displaydoc", + "ecies", + "hex", + "reqwest 0.12.5", + "serde", + "serde_json", + "subtle-encoding", + "thiserror", + "tokio", + "tracing", + "tracing-subscriber", + "uuid", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.71", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "der_derive", + "flagset", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "der-parser" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" +dependencies = [ + "asn1-rs", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "der_derive" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8034092389675178f570469e6c3b0465d3d30b4505c294a6550db47f3c17ad18" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "ecies" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0206e602d2645ec8b24ed8307fadbc6c3110e2b11ab2f806fc02fee49327079" +dependencies = [ + "aes-gcm", + "getrandom", + "hkdf", + "libsecp256k1", + "once_cell", + "parking_lot", + "rand_core 0.6.4", + "sha2 0.10.8", + "typenum", + "wasm-bindgen", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-consensus" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" +dependencies = [ + "curve25519-dalek-ng", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek", + "hashbrown 0.12.3", + "hex", + "rand_core 0.6.4", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "enclave" +version = "0.1.0" +dependencies = [ + "clap", + "color-eyre", + "cosmrs", + "cosmwasm-std", + "cw-tee-mtcs", + "ecies", + "hex", + "k256", + "mtcs", + "prost 0.12.6", + "quartz-common", + "schemars", + "serde", + "serde_json", + "tendermint 0.36.0", + "tendermint-light-client", + "thiserror", + "tokio", + "tonic", + "tonic-build", +] + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flagset" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3ea1ec5f8307826a5b71094dd91fc04d4ae75d5709b20ad351c7fb4815c86ec" + +[[package]] +name = "flex-error" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c606d892c9de11507fa0dcffc116434f94e105d0bbdc4e405b61519464c49d7b" +dependencies = [ + "eyre", + "paste", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "forward_ref" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-macro", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "half" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.5", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper 0.14.30", + "rustls 0.21.12", + "tokio", + "tokio-rustls 0.24.1", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.4.1", + "hyper-util", + "rustls 0.23.11", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper 0.14.30", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.4.1", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.4.1", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[package]] +name = "ics23" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18798160736c1e368938ba6967dbcb3c7afb3256b442a5506ba5222eebb68a5a" +dependencies = [ + "anyhow", + "blake2", + "blake3", + "bytes", + "hex", + "prost 0.12.6", + "ripemd", + "sha2 0.10.8", + "sha3", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.8", + "signature", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libsecp256k1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +dependencies = [ + "arrayref", + "base64 0.13.1", + "digest 0.9.0", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand", + "serde", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "mc-attestation-verifier" +version = "0.4.3" +source = "git+https://github.com/informalsystems/attestation#ae86e2804abed218f4fd2fd4aec5e39408898cd8" +dependencies = [ + "der", + "displaydoc", + "hex", + "mc-sgx-core-sys-types", + "mc-sgx-core-types", + "mc-sgx-dcap-types", + "p256", + "serde", + "serde_json", + "subtle", + "x509-cert", +] + +[[package]] +name = "mc-sgx-core-sys-types" +version = "0.11.0" +source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c" +dependencies = [ + "serde", + "serde_with", +] + +[[package]] +name = "mc-sgx-core-types" +version = "0.11.0" +source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c" +dependencies = [ + "bitflags 2.6.0", + "displaydoc", + "getrandom", + "hex", + "mc-sgx-core-sys-types", + "mc-sgx-util", + "nom", + "rand_core 0.6.4", + "serde", + "subtle", +] + +[[package]] +name = "mc-sgx-dcap-sys-types" +version = "0.11.0" +source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c" +dependencies = [ + "mc-sgx-core-sys-types", +] + +[[package]] +name = "mc-sgx-dcap-types" +version = "0.11.0" +source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c" +dependencies = [ + "const-oid", + "displaydoc", + "hex", + "mc-sgx-core-types", + "mc-sgx-dcap-sys-types", + "mc-sgx-util", + "nom", + "p256", + "serde", + "sha2 0.10.8", + "static_assertions", + "subtle", + "x509-cert", +] + +[[package]] +name = "mc-sgx-util" +version = "0.11.0" +source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c" + +[[package]] +name = "mcmf" +version = "2.0.0" +source = "git+https://github.com/hu55a1n1/flow#cad8f3adb29d3be2177a31db0fa0e5c2a858beb0" +dependencies = [ + "cc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "mtcs" +version = "0.1.0" +source = "git+ssh://git@github.com/informalsystems/mtcs.git#b421d9ef42272b5eb73d9c74a2a5d590d4c20603" +dependencies = [ + "displaydoc", + "itertools", + "log", + "mcmf", + "num-traits", + "petgraph 0.6.3", + "serde", +] + +[[package]] +name = "mtcs-overdraft" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "cw0", + "cw4", + "cw4-group", + "thiserror", +] + +[[package]] +name = "multimap" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" + +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "oid-registry" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" +dependencies = [ + "asn1-rs", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +dependencies = [ + "critical-section", + "portable-atomic", +] + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "openssl" +version = "0.10.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest 0.10.7", + "hmac", +] + +[[package]] +name = "peg" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a625d12ad770914cbf7eff6f9314c3ef803bfe364a1b20bc36ddf56673e71e5" +dependencies = [ + "peg-macros", + "peg-runtime", +] + +[[package]] +name = "peg-macros" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f241d42067ed3ab6a4fece1db720838e1418f36d868585a27931f95d6bc03582" +dependencies = [ + "peg-runtime", + "proc-macro2", + "quote", +] + +[[package]] +name = "peg-runtime" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3aeb8f54c078314c2065ee649a7241f46b9d8e418e1a9581ba0546657d7aa3a" + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.6.3" +source = "git+https://github.com/hu55a1n1/petgraph?branch=min-cost-flow-primal-dual#3a2664a3b9d1e5b71c411a6ed497cf576c1a86ae" +dependencies = [ + "fixedbitset", + "indexmap 1.9.3", + "num", +] + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.2.6", +] + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "portable-atomic" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn 2.0.71", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", + "prost-derive 0.12.6", +] + +[[package]] +name = "prost" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +dependencies = [ + "bytes", + "prost-derive 0.13.1", +] + +[[package]] +name = "prost-build" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" +dependencies = [ + "bytes", + "heck", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph 0.6.5", + "prettyplease", + "prost 0.12.6", + "prost-types 0.12.6", + "regex", + "syn 2.0.71", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "prost-derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "prost-types" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +dependencies = [ + "prost 0.12.6", +] + +[[package]] +name = "prost-types" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +dependencies = [ + "prost 0.13.1", +] + +[[package]] +name = "quartz-common" +version = "0.1.0" +dependencies = [ + "clap", + "color-eyre", + "cosmrs", + "quartz-cw", + "quartz-enclave", + "quartz-proto", + "tendermint-light-client", +] + +[[package]] +name = "quartz-cw" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "k256", + "quartz-tee-ra", + "serde", + "serde_json", + "sha2 0.10.8", + "thiserror", +] + +[[package]] +name = "quartz-enclave" +version = "0.1.0" +dependencies = [ + "clap", + "color-eyre", + "cosmrs", + "cosmwasm-std", + "cw-proof", + "ecies", + "hex", + "k256", + "mtcs", + "quartz-cw", + "quartz-proto", + "quartz-relayer", + "quartz-tee-ra", + "rand", + "serde", + "serde_json", + "tendermint 0.36.0", + "tendermint-light-client", + "tm-stateless-verifier", + "tokio", + "tonic", +] + +[[package]] +name = "quartz-proto" +version = "0.1.0" +dependencies = [ + "prost 0.12.6", + "tonic", + "tonic-build", +] + +[[package]] +name = "quartz-relayer" +version = "0.1.0" +dependencies = [ + "clap", + "cosmos-sdk-proto", + "cosmrs", + "cosmwasm-std", + "displaydoc", + "ecies", + "k256", + "quartz-cw", + "quartz-proto", + "quartz-tee-ra", + "serde", + "serde_json", + "subtle-encoding", + "tempfile", + "tendermint 0.36.0", + "thiserror", + "tokio", + "tonic", +] + +[[package]] +name = "quartz-tee-ra" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "der", + "displaydoc", + "hex-literal", + "mc-attestation-verifier", + "mc-sgx-core-types", + "mc-sgx-dcap-sys-types", + "mc-sgx-dcap-types", + "num-bigint", + "serde", + "serde_json", + "sha2 0.10.8", + "thiserror", + "x509-cert", + "x509-parser", + "zeroize", +] + +[[package]] +name = "quinn" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls 0.23.11", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +dependencies = [ + "bytes", + "rand", + "ring", + "rustc-hash", + "rustls 0.23.11", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.30", + "hyper-rustls 0.24.2", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls 0.21.12", + "rustls-native-certs 0.6.3", + "rustls-pemfile 1.0.4", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 0.1.2", + "system-configuration", + "tokio", + "tokio-rustls 0.24.1", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg 0.50.0", +] + +[[package]] +name = "reqwest" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +dependencies = [ + "base64 0.22.1", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.4.5", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", + "hyper-rustls 0.27.2", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls 0.23.11", + "rustls-pemfile 2.1.2", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.1", + "system-configuration", + "tokio", + "tokio-native-tls", + "tokio-rustls 0.26.0", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg 0.52.0", +] + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring", + "rustls-webpki 0.101.7", + "sct", +] + +[[package]] +name = "rustls" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.5", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls" +version = "0.23.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.5", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +dependencies = [ + "openssl-probe", + "rustls-pemfile 1.0.4", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.1.2", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64 0.22.1", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustls-webpki" +version = "0.102.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.71", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "scripts" +version = "0.1.0" +dependencies = [ + "anyhow", + "base64 0.22.1", + "clap", + "cosmrs", + "cosmwasm-std", + "cw-tee-mtcs", + "cycles-sync", + "enclave", + "futures-util", + "hex", + "mtcs-overdraft", + "once_cell", + "reqwest 0.12.5", + "serde", + "serde_json", + "subtle-encoding", + "tendermint-rpc 0.38.1", + "tokio", + "tokio-tungstenite", + "tonic", +] + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-json-wasm" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_bytes" +version = "0.11.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "subtle-encoding" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcb1ed7b8330c5eed5441052651dd7a12c75e2ed88f2ec024ae1fa3a5e59945" +dependencies = [ + "zeroize", +] + +[[package]] +name = "subtle-ng" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "tendermint" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f8a10105d0a7c4af0a242e23ed5a12519afe5cc0e68419da441bb5981a6802" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "flex-error", + "futures", + "k256", + "num-traits", + "once_cell", + "prost 0.12.6", + "prost-types 0.12.6", + "ripemd", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2 0.10.8", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto 0.35.0", + "time", + "zeroize", +] + +[[package]] +name = "tendermint" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b50aae6ec24c3429149ad59b5b8d3374d7804d4c7d6125ceb97cb53907fb68d" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "flex-error", + "futures", + "k256", + "num-traits", + "once_cell", + "prost 0.12.6", + "prost-types 0.12.6", + "ripemd", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2 0.10.8", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto 0.36.0", + "time", + "zeroize", +] + +[[package]] +name = "tendermint" +version = "0.38.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "505d9d6ffeb83b1de47c307c6e0d2dff56c6256989299010ad03cd80a8491e97" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "flex-error", + "futures", + "num-traits", + "once_cell", + "prost 0.13.1", + "prost-types 0.13.1", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2 0.10.8", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto 0.38.1", + "time", + "zeroize", +] + +[[package]] +name = "tendermint-config" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e07b383dc8780ebbec04cfb603f3fdaba6ea6663d8dd861425b1ffa7761fe90d" +dependencies = [ + "flex-error", + "serde", + "serde_json", + "tendermint 0.36.0", + "toml", + "url", +] + +[[package]] +name = "tendermint-config" +version = "0.38.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9de111ea653b2adaef627ac2452b463c77aa615c256eaaddf279ec5a1cf9775f" +dependencies = [ + "flex-error", + "serde", + "serde_json", + "tendermint 0.38.1", + "toml", + "url", +] + +[[package]] +name = "tendermint-light-client" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "331544139bbcf353acb5f56e733093d8e4bf2522cda0491b4bba7039ef0b944e" +dependencies = [ + "contracts", + "crossbeam-channel", + "derive_more", + "flex-error", + "futures", + "regex", + "serde", + "serde_cbor", + "serde_derive", + "serde_json", + "static_assertions", + "tendermint 0.36.0", + "tendermint-light-client-verifier", + "tendermint-rpc 0.36.0", + "time", + "tracing", +] + +[[package]] +name = "tendermint-light-client-verifier" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4216e487165e5dbd7af79952eaa0d5f06c5bde861eb76c690acd7f2d2a19395c" +dependencies = [ + "derive_more", + "flex-error", + "serde", + "tendermint 0.36.0", + "time", +] + +[[package]] +name = "tendermint-proto" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff525d5540a9fc535c38dc0d92a98da3ee36fcdfbda99cecb9f3cce5cd4d41d7" +dependencies = [ + "bytes", + "flex-error", + "num-derive", + "num-traits", + "prost 0.12.6", + "prost-types 0.12.6", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + +[[package]] +name = "tendermint-proto" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46f193d04afde6592c20fd70788a10b8cb3823091c07456db70d8a93f5fb99c1" +dependencies = [ + "bytes", + "flex-error", + "prost 0.12.6", + "prost-types 0.12.6", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + +[[package]] +name = "tendermint-proto" +version = "0.38.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed14abe3b0502a3afe21ca74ca5cdd6c7e8d326d982c26f98a394445eb31d6e" +dependencies = [ + "bytes", + "flex-error", + "prost 0.13.1", + "prost-types 0.13.1", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + +[[package]] +name = "tendermint-rpc" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21e3c231a3632cab53f92ad4161c730c468c08cfe4f0aa5a6735b53b390aecbd" +dependencies = [ + "async-trait", + "bytes", + "flex-error", + "futures", + "getrandom", + "peg", + "pin-project", + "rand", + "reqwest 0.11.27", + "semver", + "serde", + "serde_bytes", + "serde_json", + "subtle", + "subtle-encoding", + "tendermint 0.36.0", + "tendermint-config 0.36.0", + "tendermint-proto 0.36.0", + "thiserror", + "time", + "tokio", + "tracing", + "url", + "uuid", + "walkdir", +] + +[[package]] +name = "tendermint-rpc" +version = "0.38.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02f96a2b8a0d3d0b59e4024b1a6bdc1589efc6af4709d08a480a20cc4ba90f63" +dependencies = [ + "async-trait", + "async-tungstenite", + "bytes", + "flex-error", + "futures", + "getrandom", + "peg", + "pin-project", + "rand", + "semver", + "serde", + "serde_bytes", + "serde_json", + "subtle", + "subtle-encoding", + "tendermint 0.38.1", + "tendermint-config 0.38.1", + "tendermint-proto 0.38.1", + "thiserror", + "time", + "tokio", + "tracing", + "url", + "uuid", + "walkdir", +] + +[[package]] +name = "thiserror" +version = "1.0.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tm-stateless-verifier" +version = "0.1.0" +dependencies = [ + "displaydoc", + "tendermint 0.36.0", + "tendermint-light-client", +] + +[[package]] +name = "tokio" +version = "1.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls 0.21.12", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.4", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.11", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6989540ced10490aaf14e6bad2e3d33728a2813310a0c71d1574304c49631cd" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.23.0", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" +dependencies = [ + "indexmap 2.2.6", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tonic" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.21.7", + "bytes", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.30", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost 0.12.6", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "sharded-slab", + "thread_local", + "tracing-core", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "rustls 0.22.4", + "rustls-pki-types", + "sha1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "tungstenite" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e2ce1e47ed2994fd43b04c8f618008d4cabdd5ee34027cf14f9d918edd9c8" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +dependencies = [ + "serde", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.71", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "x509-cert" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1301e935010a701ae5f8655edc0ad17c44bad3ac5ce8c39185f75453b720ae94" +dependencies = [ + "const-oid", + "der", + "spki", +] + +[[package]] +name = "x509-parser" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" +dependencies = [ + "asn1-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "ring", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] diff --git a/apps/mtcs/scripts/Cargo.toml b/apps/mtcs/scripts/Cargo.toml new file mode 100644 index 0000000..ffd391a --- /dev/null +++ b/apps/mtcs/scripts/Cargo.toml @@ -0,0 +1,58 @@ +[package] +name = "scripts" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[bin]] +name = "listen" +path = "src/bin/listen.rs" + +[[bin]] +name = "handshake" +path = "src/bin/handshake.rs" + +[[bin]] +name = "deploy" +path = "src/bin/deploy.rs" + +[dependencies] +clap.workspace = true +color-eyre.workspace = true +ecies.workspace = true +hex.workspace = true +k256.workspace = true +prost.workspace = true +serde.workspace = true +serde_json.workspace = true +thiserror.workspace = true +tokio.workspace = true +tonic.workspace = true +once_cell = "1.19.0" +reqwest = { version = "0.12.2", default-features = false, features = ["json", "rustls-tls"] } +anyhow = "1.0.86" +base64 = "0.22.1" +subtle-encoding = "0.5.1" +tokio-tungstenite = "0.23.1" +futures-util = "0.3.30" +tendermint-rpc = { version ="0.36.0", features=["websocket-client", "http-client"]} + +# cosmos +cosmrs.workspace = true +cosmwasm-std.workspace = true +tendermint.workspace = true +tendermint-light-client.workspace = true + +# quartz +cw-proof.workspace = true +cw-tee-mtcs.workspace = true +mtcs.workspace = true + +# todo remove unnecessary imports + +cycles-sync = { workspace = true} +tm-prover = { workspace = true} +quartz-common = { workspace = true, features=["contract"]} +quartz-tee-ra = { workspace = true} +mtcs-enclave = { path = "../enclave", optional = false} +regex = "1.10.5" diff --git a/apps/mtcs/scripts/aggregator.sh b/apps/mtcs/scripts/aggregator.sh new file mode 100644 index 0000000..8a6517c --- /dev/null +++ b/apps/mtcs/scripts/aggregator.sh @@ -0,0 +1,40 @@ +set -eo pipefail + +ROOT=${ROOT:-$HOME} +DIR_MTCS="$ROOT/cycles-protocol/quartz-app" +DIR_CYCLES_SYNC="$ROOT/cycles-protocol/packages/cycles-sync/" +DIR_PROTO="$DIR_MTCS/enclave/proto" + +OVERDRAFT=wasm199rcvzawgyse89k4smqdn4wp83f3q8rurg9vautppxh5cypydafqk9nt6q + +cd $DIR_MTCS + +export NODE_URL=143.244.186.205:26657 +bash scripts/build.sh + +cd $DIR_MTCS/scripts/scripts +CONTRACT=$(RUST_BACKTRACE=1 cargo run --bin deploy | tail -n 1) + + +echo "------------ built and deployed ------------" + +PUB_KEY=$(RUST_BACKTRACE=1 cargo run --bin handshake -- --contract $CONTRACT | tail -n 1) + +echo "PUB KEY: '$PUB_KEY'" +echo "------------ shook some hands ------------" + +cd $DIR_CYCLES_SYNC +cargo run --bin submit -- --epoch-pk $PUB_KEY --mtcs $CONTRACT --overdraft $OVERDRAFT +echo "cargo run --bin submit -- --epoch-pk $PUB_KEY --mtcs $CONTRACT --overdraft $OVERDRAFT" + +echo "------------ submitted obligations ------------" + +# add contract to owners list in overdrafts contract +CURRENT_SEQUENCE=$(wasmd query account wasm14qdftsfk6fwn40l0xmruga08xlczl4g05npy70 --node http://$NODE_URL --output json | jq -r .sequence) +WASMD_OUTPUT=$(wasmd tx wasm execute $OVERDRAFT '{"add_owner": {"new": "'$CONTRACT'"}}' --from wasm14qdftsfk6fwn40l0xmruga08xlczl4g05npy70 --node http://$NODE_URL --chain-id testing --yes --sequence $CURRENT_SEQUENCE) + +echo $WASMD_OUTPUT +echo "------------ added contract as owner of overdrafts ------------" + +cd $DIR_MTCS/scripts/scripts +cargo run --bin listen -- --contract $CONTRACT diff --git a/apps/mtcs/scripts/build.sh b/apps/mtcs/scripts/build.sh new file mode 100644 index 0000000..459ef41 --- /dev/null +++ b/apps/mtcs/scripts/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -eo pipefail + +ROOT=${ROOT:-$HOME} + +echo "--------------------------------------------------------" +echo "building enclave binary" + +cd $ROOT/cycles-protocol/quartz-app/enclave/ +CARGO_TARGET_DIR=./target cargo build --release + +echo "--------------------------------------------------------" +echo "building cosmwasm contract binary" + + +cd $ROOT/cycles-protocol/quartz-app/contracts/cw-tee-mtcs/ +bash build.sh diff --git a/apps/mtcs/scripts/deploy.sh b/apps/mtcs/scripts/deploy.sh new file mode 100755 index 0000000..08e8d54 --- /dev/null +++ b/apps/mtcs/scripts/deploy.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -eo pipefail + +ROOT=${ROOT:-$HOME} + + +echo "--------------------------------------------------------" +echo "instantiate" +cd $ROOT/cycles-protocol/packages/relayer/ +export INSTANTIATE_MSG=$(./scripts/relay.sh Instantiate | jq '{quartz: .}' ) +echo "--------------------------------------------------------" + +echo "deploy contract" +cd $ROOT/cycles-protocol/quartz-app/contracts/cw-tee-mtcs + +bash deploy-contract.sh target/wasm32-unknown-unknown/release/cw_tee_mtcs.wasm |& tee output +export CONTRACT=$(cat output | grep Address | awk '{print $NF}' | sed 's/\x1b\[[0-9;]*m//g') +echo $CONTRACT + + + + diff --git a/apps/mtcs/scripts/deploy45.sh b/apps/mtcs/scripts/deploy45.sh new file mode 100755 index 0000000..08e8d54 --- /dev/null +++ b/apps/mtcs/scripts/deploy45.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -eo pipefail + +ROOT=${ROOT:-$HOME} + + +echo "--------------------------------------------------------" +echo "instantiate" +cd $ROOT/cycles-protocol/packages/relayer/ +export INSTANTIATE_MSG=$(./scripts/relay.sh Instantiate | jq '{quartz: .}' ) +echo "--------------------------------------------------------" + +echo "deploy contract" +cd $ROOT/cycles-protocol/quartz-app/contracts/cw-tee-mtcs + +bash deploy-contract.sh target/wasm32-unknown-unknown/release/cw_tee_mtcs.wasm |& tee output +export CONTRACT=$(cat output | grep Address | awk '{print $NF}' | sed 's/\x1b\[[0-9;]*m//g') +echo $CONTRACT + + + + diff --git a/apps/mtcs/scripts/handshake.sh b/apps/mtcs/scripts/handshake.sh new file mode 100755 index 0000000..c40e610 --- /dev/null +++ b/apps/mtcs/scripts/handshake.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# +# Perform the SessionCreate and SessionSetPubKey handshake between the contract and the sgx node +# Expects: +# - enclave is already initialized +# - contract is already deployed +# - apps/transfers/trusted.hash exists +# + +set -eo pipefail + +ROOT=${ROOT:-$HOME} + +NODE_URL=${NODE_URL:-127.0.0.1:26657} + +if [ "$#" -eq 0 ]; then + echo "Usage: $0 " + exit 1 # Exit with a non-zero status to indicate an error +fi + +CONTRACT="$1" + +CMD="wasmd --node http://$NODE_URL" + +cd "$ROOT/cycles-protocol/quartz-app/" +export TRUSTED_HASH=$(cat trusted.hash) +export TRUSTED_HEIGHT=$(cat trusted.height) + +echo "using CMD: $CMD" +echo "--------------------------------------------------------" + +echo "create session" + +# change to relay dir +cd $ROOT/cycles-protocol/packages/relayer + +# execute SessionCreate on enclave +export EXECUTE_CREATE=$(./scripts/relay.sh SessionCreate) + +# submit SessionCreate to contract +RES=$($CMD tx wasm execute "$CONTRACT" "$EXECUTE_CREATE" --from admin --chain-id testing -y --output json) +TX_HASH=$(echo $RES | jq -r '.["txhash"]') + +# wait for tx to commit +while ! $CMD query tx $TX_HASH &> /dev/null; do + echo "... 🕐 waiting for tx" + sleep 1 +done + +# need to wait another block for light client proof +BLOCK_HEIGHT=$($CMD query block | jq .block.header.height) + +echo "at heigh $BLOCK_HEIGHT. need to wait for a block" +while [[ $BLOCK_HEIGHT == $($CMD query block | jq .block.header.height) ]]; do + echo "... 🕐 waiting for another block" + sleep 1 +done + +# need to wait another block for light client proof +BLOCK_HEIGHT=$($CMD query block | jq .block.header.height) +echo "at heigh $BLOCK_HEIGHT. need to wait for a block" +while [[ $BLOCK_HEIGHT == $($CMD query block | jq .block.header.height) ]]; do + echo "... 🕐 waiting for another block" + sleep 1 +done + +echo "--------------------------------------------------------" + +echo "set session pk" + +# change to prover dir +cd $ROOT/cycles-protocol/packages/tm-prover +export PROOF_FILE="light-client-proof.json" +if [ -f "$PROOF_FILE" ]; then + rm "$PROOF_FILE" + echo "removed old $PROOF_FILE" +fi + +# TODO: pass this in? +echo "trusted hash $TRUSTED_HASH" +echo "contract $CONTRACT" + +# run prover to get light client proof +# TODO: assume this binary is pre-built? +# TODO: pass in addresses and chain id +cargo run -vvv -- --chain-id testing \ + --primary "http://$NODE_URL" \ + --witnesses "http://$NODE_URL" \ + --trusted-height $TRUSTED_HEIGHT \ + --trusted-hash $TRUSTED_HASH \ + --contract-address $CONTRACT \ + --storage-key "quartz_session" \ + --trace-file $PROOF_FILE + +export POP=$(cat $PROOF_FILE) +export POP_MSG=$(jq -nc --arg message "$POP" '$ARGS.named') +echo "hi" +# execute SessionSetPubKey on enclave +cd $ROOT/cycles-protocol/packages/relayer +export EXECUTE_SETPUB=$(./scripts/relay.sh SessionSetPubKey "$POP_MSG") + +RES=$($CMD tx wasm execute "$CONTRACT" "$EXECUTE_SETPUB" --from admin --chain-id testing -y --output json) +TX_HASH=$(echo $RES | jq -r '.["txhash"]') + +# wait for tx to commit +while ! $CMD query tx $TX_HASH &> /dev/null; do + echo "... 🕐 waiting for tx" + sleep 1 +done + +echo "--------------------------------------------------------" + +echo "check session success" +export NONCE_AND_KEY=$($CMD query wasm contract-state raw "$CONTRACT" $(printf '%s' "quartz_session" | hexdump -ve '/1 "%02X"') -o json | jq -r .data | base64 -d) +echo $NONCE_AND_KEY +export PUBKEY=$(echo $NONCE_AND_KEY | jq -r .pub_key) + diff --git a/apps/mtcs/scripts/listen.sh b/apps/mtcs/scripts/listen.sh new file mode 100755 index 0000000..1179e05 --- /dev/null +++ b/apps/mtcs/scripts/listen.sh @@ -0,0 +1,101 @@ + + + ROOT=${ROOT:-$HOME} + DIR_MTCS="$ROOT/cycles-protocol/quartz-app/" + DIR_PROTO="$DIR_MTCS/enclave/proto" + DEFAULT_NODE="127.0.0.1:26657" + NODE_URL="143.244.186.205:26657" + # Use the QUARTZ_PORT environment variable if set, otherwise default to 11090 + QUARTZ_PORT="${QUARTZ_PORT:-11090}" + + + # Attestation constants + IAS_API_KEY="669244b3e6364b5888289a11d2a1726d" + RA_CLIENT_SPID="51CAF5A48B450D624AEFE3286D314894" + QUOTE_FILE="/tmp/${USER}_test.quote" + REPORT_FILE="/tmp/${USER}_datareport" + REPORT_SIG_FILE="/tmp/${USER}_datareportsig" + + if [ "$#" -eq 0 ]; then + echo "Usage: $0 " + exit 1 # Exit with a non-zero status to indicate an error + fi + + CONTRACT=$1 + + CMD="wasmd --node http://$NODE_URL" + + WSURL="ws://$NODE_URL/websocket" + + SUBSCRIBE="{\"jsonrpc\":\"2.0\",\"method\":\"subscribe\",\"params\":[\"tm.event='Tx' AND wasm._contract_address = '$CONTRACT' AND wasm.action='init_clearing'\"],\"id\":1}" + + echo $SUBSCRIBE + + echo "--------------------------------------------------------" + echo "subscribe to events" + + # cat keeps the stdin open so websocat doesnt close + (echo "$SUBSCRIBE"; cat) | websocat $WSURL | while read msg; do + if [[ "$msg" == '{"jsonrpc":"2.0","id":1,"result":{}}' ]]; then + echo "... subscribed" + echo "---------------------------------------------------------" + echo "... waiting for event" + continue + fi + + if echo "$msg" | jq 'has("error")' > /dev/null; then + echo "... error msg $msg" + echo "---------------------------------------------------------" + echo "... waiting for event" + continue + fi + + + echo "... received init_clearing event!" + echo $msg + + echo "... fetching obligations" + + export EPOCH=$($CMD query wasm contract-state raw "$CONTRACT" "65706f63685f636f756e746572" -o json | jq -r .data | base64 -d) + PREV_EPOCH=$((EPOCH - 1)) + + export OBLIGATIONS=$($CMD query wasm contract-state raw "$CONTRACT" $(printf '%s/%s' "$PREV_EPOCH" "obligations" | hexdump -ve '/1 "%02X"') -o json | jq -r .data | base64 -d) + export LIQUIDITY_SOURCES=$($CMD query wasm contract-state smart $CONTRACT '{"get_liquidity_sources": {"epoch": '$PREV_EPOCH'}}' -o json | jq -r .data.liquidity_sources) + + COMBINED_JSON=$(jq -nc \ + --argjson intents "$OBLIGATIONS" \ + --argjson liquidity_sources "$LIQUIDITY_SOURCES" \ + '{intents: $intents, liquidity_sources: $liquidity_sources}') + + echo $COMBINED_JSON + + # Wrap the combined JSON string into another JSON object with a "message" field + REQUEST_MSG=$(jq -nc --arg message "$COMBINED_JSON" '{"message": $message}') + + echo "... executing mtcs" + export ATTESTED_MSG=$(grpcurl -plaintext -import-path "$DIR_PROTO" -proto mtcs.proto -d "$REQUEST_MSG" "127.0.0.1:$QUARTZ_PORT" mtcs.Clearing/Run | jq -c '.message | fromjson') + + QUOTE=$(echo "$ATTESTED_MSG" | jq -c '.attestation') + MSG=$(echo "$ATTESTED_MSG" | jq -c '.msg') + + # request the IAS report for EPID attestations + echo -n "$QUOTE" | xxd -r -p - > "$QUOTE_FILE" + gramine-sgx-ias-request report -g "$RA_CLIENT_SPID" -k "$IAS_API_KEY" -q "$QUOTE_FILE" -r "$REPORT_FILE" -s "$REPORT_SIG_FILE" > /dev/null 2>&1 + REPORT=$(cat "$REPORT_FILE") + REPORTSIG=$(cat "$REPORT_SIG_FILE" | tr -d '\r') + + echo "... submitting update" + + + export EXECUTE=$(jq -nc --argjson submit_setoffs "$(jq -nc --argjson msg "$MSG" --argjson attestation \ + "$(jq -nc --argjson report "$(jq -nc --argjson report "$REPORT" --arg reportsig "$REPORTSIG" '$ARGS.named')" '$ARGS.named')" \ + '$ARGS.named')" '$ARGS.named') + $CMD tx wasm execute "$CONTRACT" "$EXECUTE" --from admin --chain-id testing -y --gas 2000000 + + + echo " ... done" + echo "---------------------------------------------------------" + echo "... waiting for event" + done + + diff --git a/apps/mtcs/scripts/src/bin/deploy.rs b/apps/mtcs/scripts/src/bin/deploy.rs new file mode 100644 index 0000000..afde55b --- /dev/null +++ b/apps/mtcs/scripts/src/bin/deploy.rs @@ -0,0 +1,80 @@ +use std::{env::current_dir, str::FromStr}; + +use clap::Parser; +use cosmrs::tendermint::chain::Id as ChainId; +use cw_tee_mtcs::msg::InstantiateMsg as MtcsInstantiateMsg; +use cycles_sync::wasmd_client::{CliWasmdClient, WasmdClient}; +use quartz_common::contract::msg::RawInstantiateMsg; +use reqwest::Url; +use scripts::{ + types::{Log, WasmdTxResponse}, + utils::{block_tx_commit, run_relay}, +}; +use serde_json::json; +use tendermint::Hash; +use tendermint_rpc::HttpClient; + +#[derive(Clone, Debug, Parser)] +#[command(version, about, long_about = None)] +struct Cli { + #[clap(long, default_value = "143.244.186.205:26657")] + node_url: String, +} + +#[tokio::main] +async fn main() -> Result<(), anyhow::Error> { + let cli = Cli::parse(); + + let base_path = current_dir()?.join("../../../"); + + println!("\n🚀 Communicating with Relay to Instantiate...\n"); + let init_msg: RawInstantiateMsg = run_relay(base_path.as_path(), "Instantiate", None)?; // need to define the return type + let init_msg: MtcsInstantiateMsg = MtcsInstantiateMsg(init_msg); + + let httpurl = Url::parse(&format!("http://{}", cli.node_url))?; + let tmrpc_client = HttpClient::new(httpurl.as_str()).unwrap(); + let wasmd_client = CliWasmdClient::new(Url::parse(httpurl.as_str())?); + + println!("\n🚀 Deploying MTCS Contract\n"); + let contract_path = base_path.join( + "quartz-app/contracts/cw-tee-mtcs/target/wasm32-unknown-unknown/release/cw_tee_mtcs.wasm", + ); + // TODO: uncertain about the path -> string conversion + let deploy_output: WasmdTxResponse = serde_json::from_str(&wasmd_client.deploy( + &ChainId::from_str("testing")?, + String::from("wasm14qdftsfk6fwn40l0xmruga08xlczl4g05npy70"), + contract_path.as_path().to_string_lossy(), + )?)?; + + let tx_hash = + Hash::from_str(&deploy_output.txhash).expect("Invalid hex string for transaction hash"); + let res = block_tx_commit(&tmrpc_client, tx_hash).await?; + + let log: Vec = serde_json::from_str(&res.tx_result.log)?; + let code_id: usize = log[0].events[1].attributes[1].value.parse()?; + + println!("\n🚀 Instantiating MTCS Contract\n"); + + let deploy_output: WasmdTxResponse = serde_json::from_str(&wasmd_client.init( + &ChainId::from_str("testing")?, + String::from("wasm14qdftsfk6fwn40l0xmruga08xlczl4g05npy70"), + code_id, + json!(init_msg), + format!("MTCS Contract V{}", code_id), + )?)?; + + let tx_hash = + Hash::from_str(&deploy_output.txhash).expect("Invalid hex string for transaction hash"); + let res = block_tx_commit(&tmrpc_client, tx_hash).await?; + let log: Vec = serde_json::from_str(&res.tx_result.log)?; + let contract_addr: &String = &log[0].events[1].attributes[0].value; + + println!("\n🚀 Successfully deployed and instantiated contract!"); + println!("🆔 Code ID: {}", code_id); + println!("📌 Contract Address: {}", contract_addr); + + println!("{contract_addr}"); + Ok(()) +} + +//RES=$($CMD tx wasm instantiate "$CODE_ID" "$INSTANTIATE_MSG" --from "$USER_ADDR" --label $LABEL $TXFLAG -y --no-admin --output json) diff --git a/apps/mtcs/scripts/src/bin/handshake.rs b/apps/mtcs/scripts/src/bin/handshake.rs new file mode 100644 index 0000000..14feb39 --- /dev/null +++ b/apps/mtcs/scripts/src/bin/handshake.rs @@ -0,0 +1,229 @@ +use std::{env, env::current_dir, fs::File, io::Read, path::Path, str::FromStr}; + +use anyhow::anyhow; +use clap::Parser; +use cosmrs::tendermint::chain::Id as ChainId; // TODO see if this redundancy in dependencies can be decreased +use cosmrs::AccountId; +use cw_tee_mtcs::msg::ExecuteMsg as MtcsExecuteMsg; +use cycles_sync::wasmd_client::{CliWasmdClient, WasmdClient}; +use futures_util::stream::StreamExt; +use quartz_common::contract::prelude::QuartzExecuteMsg; +use reqwest::Url; +use scripts::{ + types::WasmdTxResponse, + utils::{block_tx_commit, run_relay, wasmaddr_to_id}, +}; +use serde::Serialize; +use serde_json::json; +use tendermint::{block::Height, Hash}; +use tendermint_rpc::{query::EventType, HttpClient, SubscriptionClient, WebSocketClient}; +use tm_prover::{config::Config as TmProverConfig, prover::prove}; + +#[derive(Serialize)] +struct Message<'a> { + message: &'a str, +} + +#[derive(Clone, Debug, Parser)] +#[command(version, about, long_about = None)] +struct Cli { + /// Contract to listen to + #[arg(short, long, value_parser = wasmaddr_to_id)] + contract: AccountId, + /// Port enclave is listening on + #[arg(short, long, default_value = "11090")] + port: u16, + + #[arg( + short, + long, + default_value = "wasm14qdftsfk6fwn40l0xmruga08xlczl4g05npy70" + )] + sender: String, + + #[clap(long, default_value = "143.244.186.205:26657")] + node_url: String, + + #[clap(long, default_value_t = default_rpc_addr())] + rpc_addr: String, +} + +fn default_rpc_addr() -> String { + env::var("RPC_URL").unwrap_or_else(|_| "http://127.0.0.1".to_string()) +} + +#[tokio::main] +async fn main() -> Result<(), anyhow::Error> { + let cli = Cli::parse(); + + // Convert contract address string parameter to an AccountId + // TODO: is this all the address validation that's needed? + let httpurl = Url::parse(&format!("http://{}", cli.node_url))?; + let wsurl = format!("ws://{}/websocket", cli.node_url); + + let tmrpc_client = HttpClient::new(httpurl.as_str()).unwrap(); + + let wasmd_client = CliWasmdClient::new(Url::parse(httpurl.as_str())?); + + // test(&client, &wasmd_client).await?; + // panic!(); + // read trusted hash and height from files + let base_path = current_dir()?.join("../../../"); + let trusted_files_path = base_path.join("quartz-app/"); + let (trusted_height, trusted_hash) = read_hash_height(trusted_files_path.as_path()).await?; + + // run sessioncreate in relayer script + // export EXECUTE_CREATE=$(./scripts/relay.sh SessionCreate) + // TODO: this is not the right return type + let res: MtcsExecuteMsg = run_relay(base_path.as_path(), "SessionCreate", None)?; // need to define the return type + + // submit SessionCreate to contract + + // RES=$($CMD tx wasm execute "$CONTRACT" "$EXECUTE_CREATE" --from admin --chain-id testing -y --output json) + // TX_HASH=$(echo $RES | jq -r '.["txhash"]') + // make sure this is json + let output: WasmdTxResponse = serde_json::from_str( + wasmd_client + .tx_execute( + &cli.contract.clone(), + &ChainId::from_str("testing")?, + 2000000, + cli.sender.clone(), + json!(res), + )? + .as_str(), + )?; + println!("\n\n SessionCreate tx output: {:?}", output); + + // wait for tx to commit (in a loop?) + let tx_hash = Hash::from_str(&output.txhash).expect("Invalid hex string for transaction hash"); + block_tx_commit(&tmrpc_client, tx_hash).await?; + + // tendermint client subscription loop + // wait 2 blocks + two_block_waitoor(&wsurl).await?; + + //cd $ROOT/cycles-protocol/packages/tm-prover + //export PROOF_FILE="light-client-proof.json" + // TODO: move all the proof related files into a directory in scripts dir + let proof_path = current_dir()?.join("../../../packages/tm-prover/light-client-proof.json"); + println!("Proof path: {:?}", proof_path.to_str()); + + let config = TmProverConfig { + primary: httpurl.as_str().parse()?, + witnesses: httpurl.as_str().parse()?, + trusted_height, + trusted_hash, + trace_file: Some(proof_path.clone()), + verbose: "1".parse()?, + contract_address: cli.contract.clone(), + storage_key: "quartz_session".to_string(), + ..Default::default() + }; + + if let Err(report) = prove(config).await { + return Err(anyhow!("Tendermint prover failed. Report: {}", report)); + } + + // read proof file + let proof = read_file(proof_path.as_path()).await?; + let json_msg = serde_json::to_string(&Message { message: &proof })?; + + // execute SessionSetPubKey on enclave + // cd $ROOT/cycles-protocol/packages/relayer + // export EXECUTE_SETPUB=$(./scripts/relay.sh SessionSetPubKey "$POP_MSG") + + let res: MtcsExecuteMsg = run_relay( + base_path.as_path(), + "SessionSetPubKey", + Some(json_msg.as_str()), + )?; + // submit SessionSetPubKey to contract + + // RES=$($CMD tx wasm execute "$CONTRACT" "$EXECUTE_SETPUB" --from admin --chain-id testing -y --output json) + // TX_HASH=$(echo $RES | jq -r '.["txhash"]') + // wait for tx to commit + let output: WasmdTxResponse = serde_json::from_str( + wasmd_client + .tx_execute( + &cli.contract.clone(), + &ChainId::from_str("testing")?, + 2000000, + cli.sender.clone(), + json!(res), + )? + .as_str(), + )?; + + println!("\n\n SessionSetPubKey tx output: {:?}", output); + + // wait for tx to commit (in a loop?) + let tx_hash = Hash::from_str(&output.txhash).expect("Invalid hex string for transaction hash"); + + block_tx_commit(&tmrpc_client, tx_hash).await?; + + if let MtcsExecuteMsg::Quartz(QuartzExecuteMsg::RawSessionSetPubKey(quartz)) = res { + println!("\n\n\n{}", quartz.msg.pub_key()); // TODO: return this instead later + } else { + return Err(anyhow!("Invalid relay response from SessionSetPubKey")); + } + + // query results + Ok(()) +} + +async fn two_block_waitoor(wsurl: &str) -> Result<(), anyhow::Error> { + let (client, driver) = WebSocketClient::new(wsurl).await.unwrap(); + + let driver_handle = tokio::spawn(async move { driver.run().await }); + + // Subscription functionality + let mut subs = client.subscribe(EventType::NewBlock.into()).await.unwrap(); + + // Wait 2 NewBlock events + let mut ev_count = 5_i32; + + while let Some(res) = subs.next().await { + let ev = res.unwrap(); + println!("Got event: {:?}", ev); + ev_count -= 1; + if ev_count < 0 { + break; + } + } + + // Signal to the driver to terminate. + client.close().unwrap(); + // Await the driver's termination to ensure proper connection closure. + let _ = driver_handle.await.unwrap(); + + Ok(()) +} + +async fn read_hash_height(base_path: &Path) -> Result<(Height, Hash), anyhow::Error> { + let height_path = base_path.join("trusted.height"); + let trusted_height: Height = read_file(height_path.as_path()).await?.parse()?; + + let hash_path = base_path.join("trusted.hash"); + let trusted_hash: Hash = read_file(hash_path.as_path()).await?.parse()?; + + Ok((trusted_height, trusted_hash)) +} + +async fn read_file(path: &Path) -> Result { + // Open the file + let mut file = match File::open(path) { + Ok(file) => file, + Err(e) => { + return Err(anyhow!(format!("Error opening file {:?}: {:?}", path, e))); + } + }; + + // Read the file contents into a string + let mut value = String::new(); + if let Err(e) = file.read_to_string(&mut value) { + return Err(anyhow!(format!("Error reading file {:?}: {:?}", file, e))); + } + + Ok(value.trim().to_owned()) +} diff --git a/apps/mtcs/scripts/src/bin/listen.rs b/apps/mtcs/scripts/src/bin/listen.rs new file mode 100644 index 0000000..e7d32f2 --- /dev/null +++ b/apps/mtcs/scripts/src/bin/listen.rs @@ -0,0 +1,250 @@ +use std::{ + collections::{BTreeMap, BTreeSet}, + env, + process::Command, + str::FromStr, +}; + +use anyhow::anyhow; +use base64::prelude::*; +use clap::Parser; +use cosmrs::{tendermint::chain::Id as ChainId, AccountId}; +use cosmwasm_std::{Binary, HexBinary, Uint64}; +use cw_tee_mtcs::{ + msg::{ + execute::SubmitSetoffsMsg, AttestedMsg, ExecuteMsg, GetLiquiditySourcesResponse, + QueryMsg::GetLiquiditySources, + }, + state::LiquiditySource, +}; +use cycles_sync::wasmd_client::{CliWasmdClient, QueryResult, WasmdClient}; +use futures_util::stream::StreamExt; +use mtcs_enclave::proto::{clearing_client::ClearingClient, RunClearingRequest}; +use quartz_common::contract::msg::execute::attested::{ + EpidAttestation, RawAttested, RawAttestedMsgSansHandler, +}; +use quartz_tee_ra::{intel_sgx::epid::types::ReportBody, IASReport}; +use reqwest::Url; +use scripts::utils::wasmaddr_to_id; +use serde::{Deserialize, Serialize}; +use serde_json::json; +use tendermint_rpc::{ + query::{EventType, Query}, + SubscriptionClient, WebSocketClient, +}; +use tokio::{ + fs::{self, File}, + io::AsyncWriteExt, +}; +use tonic::Request; + +// TODO: import this from enclave or somewhere shared +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct RunClearingMessage { + intents: BTreeMap, + liquidity_sources: BTreeSet, +} + +#[derive(Clone, Debug, Parser)] +#[command(version, about, long_about = None)] +struct Cli { + /// Contract to listen to + #[arg(short, long, value_parser = wasmaddr_to_id)] + contract: AccountId, + /// Port enclave is listening on + #[arg(short, long, default_value = "11090")] + port: u16, + + #[arg( + short, + long, + default_value = "wasm14qdftsfk6fwn40l0xmruga08xlczl4g05npy70" + )] + sender: String, + + #[clap(long, default_value = "143.244.186.205:26657")] + node_url: String, + + #[clap(long, default_value_t = default_rpc_addr())] + rpc_addr: String, + + #[arg(short, long, default_value = "dangush")] + user: String, // The filesys user for gramine filepaths. TODO: improve this +} + +fn default_rpc_addr() -> String { + env::var("RPC_URL").unwrap_or_else(|_| "http://127.0.0.1".to_string()) +} + +#[tokio::main] +async fn main() -> Result<(), anyhow::Error> { + let cli = Cli::parse(); + + // Subscribe to "init_clearing" events + let wsurl = format!("ws://{}/websocket", cli.node_url); + let (client, driver) = WebSocketClient::new(wsurl.as_str()).await.unwrap(); + let driver_handle = tokio::spawn(async move { driver.run().await }); + + let mut subs = client + .subscribe(Query::from(EventType::Tx).and_contains("wasm.action", "init_clearing")) + .await + .unwrap(); + + while subs.next().await.is_some() { + // On init_clearing, run process + if let Err(e) = handler( + &cli.contract, + cli.sender.clone(), + format!("{}:{}", cli.rpc_addr, cli.port), + &cli.node_url, + &cli.user, + ) + .await + { + println!("{}", e); + } + } + + // Close connection + // Await the driver's termination to ensure proper connection closure. + client.close().unwrap(); + let _ = driver_handle.await.unwrap(); + + Ok(()) +} + +async fn handler( + contract: &AccountId, + sender: String, + rpc_addr: String, + node_url: &str, + user: &str, +) -> Result<(), anyhow::Error> { + let chain_id = &ChainId::from_str("testing")?; + let httpurl = Url::parse(&format!("http://{}", node_url))?; + let wasmd_client = CliWasmdClient::new(httpurl); + + // Query obligations and liquidity sources from chain + let clearing_contents = query_chain(&wasmd_client, contract).await?; + + // Send queried data to enclave over gRPC + let request = Request::new(RunClearingRequest { + message: json!(clearing_contents).to_string(), + }); + + let mut client = ClearingClient::connect(rpc_addr).await?; + let clearing_response = client + .run(request) + .await + .map_err(|e| anyhow!("Failed to communicate to relayer. {e}"))? + .into_inner(); + + // Extract json from the Protobuf message + let quote: RawAttested> = + serde_json::from_str(&clearing_response.message) + .map_err(|e| anyhow!("Error serializing SubmitSetoffs: {}", e))?; + + // Get IAS report and build attested message + let attestation = gramine_ias_request(quote.attestation, user).await?; + let msg = RawAttestedMsgSansHandler(quote.msg); + + let setoffs_msg = + ExecuteMsg::SubmitSetoffs::(AttestedMsg { msg, attestation }); + + // Send setoffs to mtcs contract on chain + let output = + wasmd_client.tx_execute(contract, chain_id, 2000000, sender, json!(setoffs_msg))?; + + println!("output: {}", output); + Ok(()) +} + +// TODO: replace raw queries with smart +async fn query_chain( + wasmd_client: &CliWasmdClient, + contract: &AccountId, +) -> Result { + // Get epoch counter + let resp: QueryResult = wasmd_client + .query_raw(contract, hex::encode("epoch_counter")) + .map_err(|e| anyhow!("Problem querying epoch: {}", e))?; + let mut epoch_counter: usize = + String::from_utf8(BASE64_STANDARD.decode(resp.data)?)?.parse::()?; + if epoch_counter > 1 { + epoch_counter -= 1; + } + + // TODO: replace with tracer log here + // println!("epoch: {}", epoch_counter); + + // Get obligations + let resp: QueryResult = wasmd_client + .query_raw( + contract, + hex::encode(format!("{}/obligations", epoch_counter)), + ) + .map_err(|e| anyhow!("Problem querying obligatons: {}", e))?; + + let decoded_obligs = BASE64_STANDARD.decode(resp.data)?; + let obligations_map: BTreeMap = + serde_json::from_slice(&decoded_obligs).unwrap_or_default(); + // println!("obligations \n {:?}", obligations_map); + // TODO: replace with tracer log here + + // Get liquidity sources + let resp: QueryResult = wasmd_client + .query_smart( + contract, + json!(GetLiquiditySources { + epoch: Some(Uint64::new(epoch_counter as u64)) + }), + ) + .map_err(|e| anyhow!("Problem querying liquidity sources: {}", e))?; + + let liquidity_sources = resp.data.liquidity_sources; + // TODO: replace with tracer log here + // println!("liquidity_sources \n {:?}", liquidity_sources); + + Ok(RunClearingMessage { + intents: obligations_map, + liquidity_sources: liquidity_sources.into_iter().collect(), + }) +} + +// Request the IAS report for EPID attestations +async fn gramine_ias_request( + attested_msg: Vec, + user: &str, +) -> Result { + let ias_api_key = String::from("669244b3e6364b5888289a11d2a1726d"); + let ra_client_spid = String::from("51CAF5A48B450D624AEFE3286D314894"); + let quote_file = format!("/tmp/{}_test.quote", user); + let report_file = format!("/tmp/{}_datareport", user); + let report_sig_file = format!("/tmp/{}_datareportsig", user); + + // Write the binary data to a file + let mut file = File::create("e_file).await?; + file.write_all(&attested_msg) + .await + .map_err(|e| anyhow!("Couldn't write to file. {e}"))?; + + let mut gramine = Command::new("gramine-sgx-ias-request"); + let command = gramine + .arg("report") + .args(["-g", &ra_client_spid]) + .args(["-k", &ias_api_key]) + .args(["-q", "e_file]) + .args(["-r", &report_file]) + .args(["-s", &report_sig_file]); + + let output = command.output()?; + if !output.status.success() { + return Err(anyhow!("Couldn't run gramine. {:?}", output)); + } + + let report: ReportBody = serde_json::from_str(&fs::read_to_string(report_file).await?)?; + let report_sig_str = fs::read_to_string(report_sig_file).await?.replace('\r', ""); + let report_sig: Binary = Binary::from_base64(report_sig_str.trim())?; + + Ok(EpidAttestation::new(IASReport { report, report_sig })) +} diff --git a/apps/mtcs/scripts/src/lib.rs b/apps/mtcs/scripts/src/lib.rs new file mode 100644 index 0000000..5ea88ec --- /dev/null +++ b/apps/mtcs/scripts/src/lib.rs @@ -0,0 +1,3 @@ +//TODO: make an error.rs to differentiate errors in listen.rs +pub mod types; +pub mod utils; diff --git a/apps/mtcs/scripts/src/types.rs b/apps/mtcs/scripts/src/types.rs new file mode 100644 index 0000000..efbdcfa --- /dev/null +++ b/apps/mtcs/scripts/src/types.rs @@ -0,0 +1,39 @@ +use serde::{Deserialize, Serialize}; + +// Rust libraries don't seem to implement this type from the wasmd go implementation +// TODO: Replace String with types from Rust libraries +// TODO: Move this into WasmdClient +#[derive(Deserialize, Debug)] +pub struct WasmdTxResponse { + pub height: String, + pub txhash: String, + pub codespace: String, + pub code: u32, + pub data: String, + pub raw_log: String, + pub logs: Vec, + pub info: String, + pub gas_wanted: String, + pub gas_used: String, + pub tx: Option, + pub timestamp: String, + pub events: Vec, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct Attribute { + pub key: String, + pub value: String, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct Event { + pub attributes: Vec, + pub r#type: String, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct Log { + pub events: Vec, + pub msg_index: u32, +} diff --git a/apps/mtcs/scripts/src/utils.rs b/apps/mtcs/scripts/src/utils.rs new file mode 100644 index 0000000..5d213bc --- /dev/null +++ b/apps/mtcs/scripts/src/utils.rs @@ -0,0 +1,81 @@ +use std::{path::Path, process::Command, time::Duration}; + +use anyhow::anyhow; +use cosmrs::AccountId; +use regex::Regex; +use serde::de::DeserializeOwned; +use subtle_encoding::bech32::decode as bech32_decode; +use tendermint::Hash; +use tendermint_rpc::{ + endpoint::tx::Response as TmTxResponse, error::ErrorDetail, Client, HttpClient, +}; + +pub fn wasmaddr_to_id(address_str: &str) -> anyhow::Result { + let (hr, _) = bech32_decode(address_str).map_err(|e| anyhow!(e))?; + if hr != "wasm" { + return Err(anyhow!(hr)); + } + + Ok(address_str.parse().unwrap()) +} + +// TODO: move wrapping result with "quartz:" struct into here +pub fn run_relay( + base_path: &Path, + msg: &str, + arg: Option<&str>, +) -> Result { + let relayer_path = base_path.join("packages/relayer/scripts/relay.sh"); + + let mut bash = Command::new("bash"); + let command = bash.arg(relayer_path).arg(msg); + + if let Some(arg) = arg { + command.arg(arg); + } + + let output = command.output()?; + + if !output.status.success() { + return Err(anyhow!("{:?}", output)); + } + + let query_result: R = serde_json::from_slice(&output.stdout) + .map_err(|e| anyhow!("Error deserializing: {}", e))?; + + Ok(query_result) +} + +// Note: time until tx commit is empiraclly 800ms on DO wasmd chain. +pub async fn block_tx_commit(client: &HttpClient, tx: Hash) -> Result { + let re = Regex::new(r"tx \([A-F0-9]{64}\) not found").unwrap(); + + tokio::time::sleep(Duration::from_millis(400)).await; + loop { + match client.tx(tx, false).await { + Ok(resp) => { + return Ok(resp); + } + Err(e) => { + // If error, make sure it is only because of a not yet committed tx + match e.0 { + ErrorDetail::Response(subdetail) => { + if !re.is_match(subdetail.source.data().unwrap_or_default()) { + return Err(anyhow!( + "Error querying for tx: {}", + ErrorDetail::Response(subdetail) + )); + } else { + println!("🔗 Waiting for tx commit... (+400ms)"); + tokio::time::sleep(Duration::from_millis(400)).await; + continue; + } + } + _ => { + return Err(anyhow!("Error querying for tx: {}", e.0)); + } + } + } + } + } +} diff --git a/apps/mtcs/scripts/start.sh b/apps/mtcs/scripts/start.sh new file mode 100755 index 0000000..641def6 --- /dev/null +++ b/apps/mtcs/scripts/start.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +#set -eo pipefail + +ROOT=${ROOT:-$HOME} +DIR_QUARTZ="$ROOT/cycles-protocol" +DIR_QUARTZ_APP="$DIR_QUARTZ/quartz-app/" +DIR_QUARTZ_ENCLAVE="$DIR_QUARTZ/quartz-app/enclave" +DIR_QUARTZ_TM_PROVER="$DIR_QUARTZ/packages/tm-prover" + +NODE_URL=${NODE_URL:-143.244.186.205:26657} +CMD="wasmd --node http://$NODE_URL" + +echo "--------------------------------------------------------" +echo "set trusted hash" + +cd "$DIR_QUARTZ_TM_PROVER" +# cargo run -- --chain-id testing \ +# --primary "http://$NODE_URL" \ +# --witnesses "http://$NODE_URL" \ +# --trusted-height 1 \ +# --trusted-hash "5237772462A41C0296ED688A0327B8A60DF310F08997AD760EB74A70D0176C27" \ +# --contract-address "wasm14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s0phg4d" \ +# --storage-key "quartz_session" \ +# --trace-file light-client-proof.json &> $DIR_QUARTZ_APP/output + +# # Debug output of cargo run +# echo "Cargo run output:" +# cat $DIR_QUARTZ_APP/output + +# cd $DIR_QUARTZ_APP +# # Debug hash extraction +# echo "Attempting to extract trusted hash from output..." +# cat output | grep found | head -1 | awk '{print $NF}' | sed 's/\x1b\[[0-9;]*m//g' > trusted.hash + +# # Check if the hash was extracted correctly +# if [[ ! -s trusted.hash ]]; then +# echo "Failed to extract trusted hash from output" +# exit 1 +# fi + +# export TRUSTED_HASH=$(cat trusted.hash) +# echo "Extracted TRUSTED_HASH: $TRUSTED_HASH" +# rm output +CHAIN_STATUS=$($CMD status) +TRUSTED_HASH=$(echo "$CHAIN_STATUS" | jq -r .SyncInfo.latest_block_hash) +TRUSTED_HEIGHT=$(echo "$CHAIN_STATUS" | jq -r .SyncInfo.latest_block_height) +echo "... $TRUSTED_HASH" + + +cd "$DIR_QUARTZ_APP" +echo "$TRUSTED_HASH" > trusted.hash +echo "$TRUSTED_HEIGHT" > trusted.height + +echo "--------------------------------------------------------" +echo "configure gramine" +cd "$DIR_QUARTZ_ENCLAVE" + +echo "... gen priv key if it doesnt exist" +gramine-sgx-gen-private-key > /dev/null 2>&1 || : # may fail + +# echo "... update manifest template with trusted hash $TRUSTED_HASH" +# sed -i -r "s/(\"--trusted-hash\", \")[A-Z0-9]+(\"])/\1$TRUSTED_HASH\2/" quartz.manifest.template + +echo "... create manifest" +gramine-manifest \ +-Dlog_level="error" \ +-Dhome="$HOME" \ +-Darch_libdir="/lib/$(gcc -dumpmachine)" \ +-Dra_type="epid" \ +-Dra_client_spid="51CAF5A48B450D624AEFE3286D314894" \ +-Dra_client_linkable=1 \ +-Dquartz_dir="$(pwd)" \ +-Dtrusted_height="$TRUSTED_HEIGHT" \ +-Dtrusted_hash="$TRUSTED_HASH" \ +quartz.manifest.template quartz.manifest + +if [ $? -ne 0 ]; then + echo "gramine-manifest failed" + exit 1 +fi + +echo "... sign manifest" +gramine-sgx-sign --manifest quartz.manifest --output quartz.manifest.sgx + +if [ $? -ne 0 ]; then + echo "gramine-sgx-sign failed" + exit 1 +fi + +echo "--------------------------------------------------------" +echo "... start gramine" +gramine-sgx ./quartz + +if [ $? -ne 0 ]; then + echo "gramine-sgx failed to start" + exit 1 +fi \ No newline at end of file diff --git a/apps/mtcs/scripts/start45.sh b/apps/mtcs/scripts/start45.sh new file mode 100755 index 0000000..d2d98a0 --- /dev/null +++ b/apps/mtcs/scripts/start45.sh @@ -0,0 +1,128 @@ +ROOT=${ROOT:-$HOME} +DIR_QUARTZ="$ROOT/cycles-protocol" +DIR_QUARTZ_APP="$DIR_QUARTZ/quartz-app/contracts/cw-tee-mtcs" +DIR_QUARTZ_ENCLAVE="$DIR_QUARTZ/quartz-app/enclave" +DIR_QUARTZ_TM_PROVER="$DIR_QUARTZ/packages/tm-prover" + +NODE_URL=${NODE_URL:-143.244.186.205:36657} +CMD="wasmd --node http://$NODE_URL" + +echo "--------------------------------------------------------" +echo "set trusted hash" + +cd "$DIR_QUARTZ_TM_PROVER" +cargo run -- --chain-id testing \ +--primary "http://$NODE_URL" \ +--witnesses "http://$NODE_URL" \ +--trusted-height 500000 \ +--trusted-hash "5237772462A41C0296ED688A0327B8A60DF310F08997AD760EB74A70D0176C27" \ +--contract-address "wasm14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s0phg4d" \ +--storage-key "quartz_session" \ +--trace-file light-client-proof.json &> $DIR_QUARTZ_APP/output + + +cd $DIR_QUARTZ_APP +cat output | grep found | head -1 | awk '{print $NF}' | sed 's/\x1b\[[0-9;]*m//g' > trusted.hash +export TRUSTED_HASH=$(cat trusted.hash) +echo "... $TRUSTED_HASH" +rm output + +echo "--------------------------------------------------------" +echo "configure gramine" +cd "$DIR_QUARTZ_ENCLAVE" + +echo "... gen priv key if it doesnt exist" +gramine-sgx-gen-private-key > /dev/null 2>&1 || : # may fail + +echo "... update manifest template with trusted hash $TRUSTED_HASH" +sed -i -r "s/(\"--trusted-hash\", \")[A-Z0-9]+(\"])/\1$TRUSTED_HASH\2/" quartz.manifest.template + + + +echo "... create manifest" +gramine-manifest \ +-Dlog_level="error" \ +-Dhome="$HOME" \ +-Darch_libdir="/lib/$(gcc -dumpmachine)" \ +-Dra_type="epid" \ +-Dra_client_spid="51CAF5A48B450D624AEFE3286D314894" \ +-Dra_client_linkable=1 \ +-Dquartz_dir="$(pwd)" \ +-Dtrusted_height="$TRUSTED_HEIGHT" \ +-Dtrusted_hash="$TRUSTED_HASH" \ +quartz.manifest.template quartz.manifest + +echo "... sign manifest" +gramine-sgx-sign --manifest quartz.manifest --output quartz.manifest.sgx + + + +echo "--------------------------------------------------------" +echo "... start gramine" +gramine-sgx ./quartz + + + + +# #set -eo pipefail + +# ROOT=${ROOT:-$HOME} +# DIR_QUARTZ="$ROOT/quartz-app" +# DIR_QUARTZ_APP="$DIR_QUARTZ/contracts/cw-tee-mtcs" +# DIR_QUARTZ_ENCLAVE="$DIR_QUARTZ/enclave" +# DIR_QUARTZ_TM_PROVER="$DIR_QUARTZ/packages/tm-prover" + +# NODE_URL=${NODE_URL:-143.244.186.205:36657} +# CMD="wasmd --node http://$NODE_URL" + + +# echo "--------------------------------------------------------" +# echo "set trusted hash" + +# cd "$DIR_QUARTZ_TM_PROVER" +# cargo run -- --chain-id testing \ +# --primary "http://$NODE_URL" \ +# --witnesses "http://$NODE_URL" \ +# --trusted-height 500000 \ +# --trusted-hash "5237772462A41C0296ED688A0327B8A60DF310F08997AD760EB74A70D0176C27" \ +# --contract-address "wasm14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s0phg4d" \ +# --storage-key "quartz_session" \ +# --trace-file light-client-proof.json &> $DIR_QUARTZ_APP/output + +# cd $DIR_QUARTZ_APP +# cat output | grep found | head -1 | awk '{print $NF}' | sed 's/\x1b\[[0-9;]*m//g' > trusted.hash +# export TRUSTED_HASH=$(cat trusted.hash) +# echo "... $TRUSTED_HASH" +# rm output + +# echo "--------------------------------------------------------" +# echo "configure gramine" +# cd "$DIR_QUARTZ_ENCLAVE" + +# echo "... gen priv key if it doesnt exist" +# gramine-sgx-gen-private-key > /dev/null 2>&1 || : # may fail + +# echo "... update manifest template with trusted hash $TRUSTED_HASH" +# sed -i -r "s/(\"--trusted-hash\", \")[A-Z0-9]+(\"])/\1$TRUSTED_HASH\2/" quartz.manifest.template + + +# echo "... create manifest" +# gramine-manifest \ +# -Dlog_level="error" \ +# -Dhome="$HOME" \ +# -Darch_libdir="/lib/$(gcc -dumpmachine)" \ +# -Dra_type="epid" \ +# -Dra_client_spid="51CAF5A48B450D624AEFE3286D314894" \ +# -Dra_client_linkable=1 \ +# -Dquartz_dir="$(pwd)" \ +# -Dtrusted_height="$TRUSTED_HEIGHT" \ +# -Dtrusted_hash="$TRUSTED_HASH" \ +# quartz.manifest.template quartz.manifest + +# echo "... sign manifest" +# gramine-sgx-sign --manifest quartz.manifest --output quartz.manifest.sgx + + +# echo "--------------------------------------------------------" +# echo "... start gramine" +# gramine-sgx ./quartz diff --git a/apps/mtcs/scripts/transact.sh b/apps/mtcs/scripts/transact.sh new file mode 100644 index 0000000..bf9e553 --- /dev/null +++ b/apps/mtcs/scripts/transact.sh @@ -0,0 +1,40 @@ + +OVERDRAFT=wasm1huhuswjxfydydxvdadqqsaet2p72wshtmr72yzx09zxncxtndf2sqs24hk +CMD='wasmd --node http://$NODE_URL' + +# users + +ALICE=wasm124tuy67a9dcvfgcr4gjmz60syd8ddaugl33v0n +BOB=wasm1ctkqmg45u85jnf5ur9796h7ze4hj6ep5y7m7l6 + +# query alice + +$CMD query wasm contract-state smart $OVERDRAFT '{"balance": {"user": "'$ALICE'"}}' + +# query bob + +$CMD query wasm contract-state smart $OVERDRAFT '{"balance": {"user": "'$BOB'"}}' + +# make obligation from alice to bob for 10 + +# $CMD tx wasm execute $CONTRACT '{"submit_obligation_msg": {"ciphertext": "", "digest": ""}}' --from $CONTRACT --chain-id testing + +# make bob acceptance to overdraft for 10 + +# make alice tender from overdraft for 10 + +# init clearing + +$CMD tx wasm execute $CONTRACT '"init_clearing"' --from $CONTRACT --chain-id testing + +# wait for 2 sec +sleep 2 + +# query alice + +$CMD query wasm contract-state smart $OVERDRAFT '{"balance": {"user": "'$ALICE'"}}' + +# query bob + +$CMD query wasm contract-state smart $OVERDRAFT '{"balance": {"user": "'$BOB'"}}' + diff --git a/apps/transfers/contracts/Cargo.lock b/apps/transfers/contracts/Cargo.lock index 35b997b..705e09c 100644 --- a/apps/transfers/contracts/Cargo.lock +++ b/apps/transfers/contracts/Cargo.lock @@ -4,13 +4,141 @@ version = 3 [[package]] name = "ahash" -version = "0.7.8" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ - "getrandom", + "cfg-if", "once_cell", "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rayon", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", + "rayon", ] [[package]] @@ -37,7 +165,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", "synstructure", ] @@ -49,7 +177,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -66,9 +194,9 @@ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" -version = "0.21.7" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -78,9 +206,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bech32" -version = "0.9.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" [[package]] name = "bitflags" @@ -88,15 +216,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -108,27 +227,15 @@ dependencies = [ [[package]] name = "bnum" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" - -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" [[package]] name = "cc" -version = "1.0.104" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" [[package]] name = "cfg-if" @@ -143,32 +250,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] -name = "cosmwasm-crypto" -version = "2.0.4" +name = "cosmwasm-core" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7a339f6b59ff7ad4ae05a70512a4f3c19bf8fcc845d46bfef90f4ec0810f72c" +checksum = "8d075f6bb1483a6ce83b5cbc73a3a1207e0316ac1e34ed1f2a4d9fc3a0f07bf6" + +[[package]] +name = "cosmwasm-crypto" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ced5a6dd2801a383d3e14e5ae5caa7fdfeff1bd9f22b30e810e0aded8a5869" dependencies = [ - "digest 0.10.7", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "cosmwasm-core", + "digest", + "ecdsa", "ed25519-zebra", "k256", - "rand_core 0.6.4", + "num-traits", + "p256", + "rand_core", + "rayon", + "sha2", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "2.0.4" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d3bfea6af94a83880fb05478135ed0c256d9a2fcde58c595a10d64dcb9c925d" +checksum = "35bd1873f84d9b17edf8a90ffe10a89a649b82feacc00e36788b81d2c3cbf03c" dependencies = [ - "syn 1.0.109", + "proc-macro2", + "quote", + "syn 2.0.72", ] [[package]] name = "cosmwasm-schema" -version = "2.0.4" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "101d0739564bd34cba9b84bf73665f0822487ae3b29b2dd59930608ed3aafd43" +checksum = "27984b137eb2ac561f97f6bdb02004a98eb6f2ba263062c140b8e231ee1826b7" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -179,33 +304,34 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "2.0.4" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4be75f60158478da2c5d319ed59295bca1687ad50c18215a0485aa91a995ea" +checksum = "f4ef0d201f611bdb6c9124207032423eb956f1fc8ab3e3ee7253a9c08a5f5809" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] name = "cosmwasm-std" -version = "2.0.4" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded932165de44cd0717979c34fc3b84d8e8066b8dde4f5bd78f96a643b090f90" +checksum = "2522fb5c9a0409712bb1d036128bccf3564e6b2ac82f942ae4cf3c8df3e26fa8" dependencies = [ "base64", "bech32", "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", - "forward_ref", + "derive_more", "hex", + "rand_core", "schemars", "serde", "serde-json-wasm", - "sha2 0.10.8", + "sha2", "static_assertions", "thiserror", ] @@ -219,6 +345,31 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -226,7 +377,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -243,17 +394,31 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.0" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "cw-storage-plus" version = "2.0.0" @@ -325,9 +490,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -335,27 +500,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] name = "darling_macro" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -393,13 +558,13 @@ dependencies = [ [[package]] name = "der_derive" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" +checksum = "8034092389675178f570469e6c3b0465d3d30b4505c294a6550db47f3c17ad18" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -423,12 +588,24 @@ dependencies = [ ] [[package]] -name = "digest" -version = "0.9.0" +name = "derive_more" +version = "1.0.0-beta.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" dependencies = [ - "generic-array", + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", + "unicode-xid", ] [[package]] @@ -437,7 +614,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "const-oid", "crypto-common", "subtle", @@ -451,7 +628,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -467,7 +644,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", - "digest 0.10.7", + "digest", "elliptic-curve", "rfc6979", "signature", @@ -475,20 +652,35 @@ dependencies = [ ] [[package]] -name = "ed25519-zebra" -version = "3.1.0" +name = "ed25519" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-zebra" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek", - "hashbrown", + "ed25519", + "hashbrown 0.14.5", "hex", - "rand_core 0.6.4", - "serde", - "sha2 0.9.9", + "rand_core", + "sha2", "zeroize", ] +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + [[package]] name = "elliptic-curve" version = "0.13.8" @@ -497,12 +689,12 @@ checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", - "digest 0.10.7", + "digest", "ff", "generic-array", "group", "pkcs8", - "rand_core 0.6.4", + "rand_core", "sec1", "subtle", "zeroize", @@ -514,15 +706,21 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] [[package]] -name = "flagset" -version = "0.4.5" +name = "fiat-crypto" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdeb3aa5e95cf9aabc17f060cfa0ced7b83f042390760ca53bf09df9968acaa1" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "flagset" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3ea1ec5f8307826a5b71094dd91fc04d4ae75d5709b20ad351c7fb4815c86ec" [[package]] name = "fnv" @@ -530,12 +728,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - [[package]] name = "generic-array" version = "0.14.7" @@ -554,10 +746,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] @@ -567,19 +757,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core 0.6.4", + "rand_core", "subtle", ] [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + [[package]] name = "hex" version = "0.4.3" @@ -601,7 +801,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.7", + "digest", ] [[package]] @@ -610,21 +810,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" version = "0.13.3" @@ -634,9 +834,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", - "sha2 0.10.8", - "signature", + "sha2", ] [[package]] @@ -651,12 +849,6 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - [[package]] name = "mc-attestation-verifier" version = "0.4.3" @@ -696,7 +888,7 @@ dependencies = [ "mc-sgx-core-sys-types", "mc-sgx-util", "nom", - "rand_core 0.6.4", + "rand_core", "serde", "subtle", ] @@ -723,7 +915,7 @@ dependencies = [ "nom", "p256", "serde", - "sha2 0.10.8", + "sha2", "static_assertions", "subtle", "x509-cert", @@ -805,12 +997,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - [[package]] name = "p256" version = "0.13.2" @@ -820,9 +1006,15 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2 0.10.8", + "sha2", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -848,6 +1040,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "primeorder" version = "0.13.6" @@ -866,6 +1064,13 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quartz-common" +version = "0.1.0" +dependencies = [ + "quartz-cw", +] + [[package]] name = "quartz-cw" version = "0.1.0" @@ -877,7 +1082,7 @@ dependencies = [ "quartz-tee-ra", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "thiserror", ] @@ -897,7 +1102,7 @@ dependencies = [ "num-bigint", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "thiserror", "x509-cert", "x509-parser", @@ -914,10 +1119,24 @@ dependencies = [ ] [[package]] -name = "rand_core" -version = "0.5.1" +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] [[package]] name = "rand_core" @@ -928,6 +1147,26 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -953,6 +1192,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rusticata-macros" version = "4.1.0" @@ -989,7 +1237,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1014,9 +1262,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -1032,13 +1280,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1049,7 +1297,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1065,9 +1313,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.3" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e73139bc5ec2d45e6c5fd85be5a46949c1c39a4c18e56915f5eb4c12f975e377" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ "serde", "serde_derive", @@ -1076,27 +1324,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.3" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b80d3d6b56b64335c0180e5ffde23b3c5e08c14c585b51a15bd0e95393f46703" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.68", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", + "syn 2.0.72", ] [[package]] @@ -1107,7 +1342,7 @@ checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -1116,8 +1351,8 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", + "digest", + "rand_core", ] [[package]] @@ -1167,9 +1402,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.68" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -1184,27 +1419,27 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.72", ] [[package]] @@ -1248,11 +1483,10 @@ dependencies = [ "cw-utils", "cw2", "cw20-base", - "getrandom", - "quartz-cw", + "quartz-common", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "thiserror", ] @@ -1268,6 +1502,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "untrusted" version = "0.9.0" @@ -1276,9 +1516,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -1286,60 +1526,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasm-bindgen" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.68", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.68", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" - [[package]] name = "windows-sys" version = "0.52.0" @@ -1442,8 +1628,42 @@ dependencies = [ "time", ] +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] diff --git a/apps/transfers/contracts/Cargo.toml b/apps/transfers/contracts/Cargo.toml index f8c6294..ed004af 100644 --- a/apps/transfers/contracts/Cargo.toml +++ b/apps/transfers/contracts/Cargo.toml @@ -24,7 +24,8 @@ incremental = false overflow-checks = true [features] -mock-sgx = ["quartz-cw/mock-sgx"] +library = [] +mock-sgx = ["quartz-common/mock-sgx-cw"] [dependencies] # external @@ -42,7 +43,4 @@ cw20-base = { version = "2.0.0", features = ["library"] } cw2 = "2.0.0" # quartz -quartz-cw = { path = "../../../cosmwasm/packages/quartz-cw" } - -# patch indirect deps -getrandom = { version = "0.2.15", features = ["js"] } +quartz-common = { path = "../../../core/quartz-common", features=["contract"]} diff --git a/apps/transfers/contracts/src/contract.rs b/apps/transfers/contracts/src/contract.rs index 2658628..d213ca9 100644 --- a/apps/transfers/contracts/src/contract.rs +++ b/apps/transfers/contracts/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, HexBinary, MessageInfo, Response, StdResult, }; -use quartz_cw::handler::RawHandler; +use quartz_common::contract::handler::RawHandler; use crate::{ error::ContractError, diff --git a/apps/transfers/contracts/src/error.rs b/apps/transfers/contracts/src/error.rs index 2c02987..4f84be9 100644 --- a/apps/transfers/contracts/src/error.rs +++ b/apps/transfers/contracts/src/error.rs @@ -1,7 +1,7 @@ use cosmwasm_std::StdError; use cw20_base::ContractError as Cw20ContractError; use cw_utils::PaymentError; -use quartz_cw::error::Error as QuartzError; +use quartz_common::contract::error::Error as QuartzError; use thiserror::Error; #[derive(Error, Debug)] diff --git a/apps/transfers/contracts/src/msg.rs b/apps/transfers/contracts/src/msg.rs index e7f830c..adb0cec 100644 --- a/apps/transfers/contracts/src/msg.rs +++ b/apps/transfers/contracts/src/msg.rs @@ -1,9 +1,8 @@ use cosmwasm_schema::cw_serde; -use quartz_cw::{ +use quartz_common::contract::{ msg::execute::attested::{RawAttested, RawAttestedMsgSansHandler, RawDefaultAttestation}, prelude::*, }; -use serde::{Deserialize, Serialize}; type AttestedMsg = RawAttested, RA>; @@ -41,7 +40,7 @@ pub enum ExecuteMsg { pub mod execute { use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, HexBinary, Uint128}; - use quartz_cw::{msg::execute::attested::HasUserData, state::UserData}; + use quartz_common::contract::{msg::execute::attested::HasUserData, state::UserData}; use sha2::{Digest, Sha256}; #[cw_serde] diff --git a/apps/transfers/enclave/Cargo.toml b/apps/transfers/enclave/Cargo.toml index 5721e4f..5838b32 100644 --- a/apps/transfers/enclave/Cargo.toml +++ b/apps/transfers/enclave/Cargo.toml @@ -10,7 +10,7 @@ name = "encrypt" path = "bin/encrypt.rs" [features] -mock-sgx = ["quartz-cw/mock-sgx", "quartz-enclave/mock-sgx"] +mock-sgx = ["quartz-common/mock-sgx-cw", "quartz-common/mock-sgx-enclave"] [dependencies] # external @@ -34,12 +34,15 @@ cosmwasm-std.workspace = true tendermint.workspace = true tendermint-light-client.workspace = true -# quartz + cycles-sync.workspace = true -quartz-cw.workspace = true -quartz-proto.workspace = true -quartz-enclave.workspace = true transfers-contract.workspace = true +# quartz +quartz-common = { workspace=true, features=["full"]} + +[dev-dependencies] +cw-multi-test = "0.17.0" + [build-dependencies] tonic-build.workspace = true diff --git a/apps/transfers/enclave/src/main.rs b/apps/transfers/enclave/src/main.rs index a8faf8f..d65771f 100644 --- a/apps/transfers/enclave/src/main.rs +++ b/apps/transfers/enclave/src/main.rs @@ -25,12 +25,14 @@ use std::{ use clap::Parser; use cli::Cli; use proto::settlement_server::SettlementServer as TransfersServer; -use quartz_cw::state::{Config, LightClientOpts}; -use quartz_enclave::{ - attestor::{Attestor, DefaultAttestor}, - server::CoreService, +use quartz_common::{ + contract::state::{Config, LightClientOpts}, + enclave::{ + attestor::{Attestor, DefaultAttestor}, + server::CoreService, + }, + proto::core_server::CoreServer, }; -use quartz_proto::quartz::core_server::CoreServer; use tonic::transport::Server; use transfers_server::TransfersService; diff --git a/apps/transfers/enclave/src/transfers_server.rs b/apps/transfers/enclave/src/transfers_server.rs index 1ba13e2..4434b72 100644 --- a/apps/transfers/enclave/src/transfers_server.rs +++ b/apps/transfers/enclave/src/transfers_server.rs @@ -6,11 +6,13 @@ use std::{ use cosmwasm_std::{Addr, HexBinary, Uint128}; use ecies::{decrypt, encrypt}; use k256::ecdsa::{SigningKey, VerifyingKey}; -use quartz_cw::{ - msg::execute::attested::{HasUserData, RawAttested}, - state::{Config, UserData}, +use quartz_common::{ + contract::{ + msg::execute::attested::{HasUserData, RawAttested}, + state::{Config, UserData}, + }, + enclave::{attestor::Attestor, server::ProofOfPublication}, }; -use quartz_enclave::{attestor::Attestor, server::ProofOfPublication}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use tonic::{Request, Response, Result as TonicResult, Status}; diff --git a/core/quartz-common/Cargo.toml b/core/quartz-common/Cargo.toml new file mode 100644 index 0000000..b039afb --- /dev/null +++ b/core/quartz-common/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "quartz-common" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +authors.workspace = true + +[features] +full = ["contract", "enclave", "proto"] +contract = ["dep:quartz-cw"] +enclave = ["dep:quartz-enclave", "proto"] +proto = ["dep:quartz-proto"] +mock-sgx-cw = ["quartz-cw/mock-sgx"] +mock-sgx-enclave = ["quartz-enclave/mock-sgx"] + +[dependencies] +quartz-cw = { workspace = true, optional = true } +quartz-proto = { workspace = true, optional = true } +quartz-enclave = { workspace = true, optional = true } \ No newline at end of file diff --git a/core/quartz-common/src/lib.rs b/core/quartz-common/src/lib.rs new file mode 100644 index 0000000..95da31a --- /dev/null +++ b/core/quartz-common/src/lib.rs @@ -0,0 +1,6 @@ +#[cfg(feature = "contract")] +pub use quartz_cw as contract; +#[cfg(feature = "enclave")] +pub use quartz_enclave as enclave; +#[cfg(feature = "proto")] +pub use quartz_proto::quartz as proto; diff --git a/core/quartz/Cargo.toml b/core/quartz/Cargo.toml index 6a71675..462aaab 100644 --- a/core/quartz/Cargo.toml +++ b/core/quartz/Cargo.toml @@ -33,8 +33,6 @@ tendermint-light-client.workspace = true # quartz cw-proof.workspace = true -cw-tee-mtcs.workspace = true -cycles-sync.workspace = true mtcs.workspace = true quartz-cw.workspace = true quartz-proto.workspace = true diff --git a/cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs b/cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs index 49ce678..35b84f2 100644 --- a/cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs +++ b/cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs @@ -3,6 +3,7 @@ use std::{convert::Into, default::Default}; use cosmwasm_schema::cw_serde; use cosmwasm_std::{HexBinary, StdError}; use quartz_tee_ra::IASReport; +use serde::Serialize; #[cfg(not(feature = "mock-sgx"))] pub type DefaultAttestation = EpidAttestation; @@ -90,7 +91,7 @@ pub trait HasUserData { fn user_data(&self) -> UserData; } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Serialize)] pub struct EpidAttestation { report: IASReport, } diff --git a/cosmwasm/packages/quartz-cw/src/msg/execute/session_set_pub_key.rs b/cosmwasm/packages/quartz-cw/src/msg/execute/session_set_pub_key.rs index 9f857f2..6325212 100644 --- a/cosmwasm/packages/quartz-cw/src/msg/execute/session_set_pub_key.rs +++ b/cosmwasm/packages/quartz-cw/src/msg/execute/session_set_pub_key.rs @@ -31,6 +31,12 @@ pub struct RawSessionSetPubKey { pub_key: HexBinary, } +impl RawSessionSetPubKey { + pub fn pub_key(&self) -> &HexBinary { + &self.pub_key + } +} + impl TryFrom for SessionSetPubKey { type Error = StdError; diff --git a/relayer/scripts/relay.sh b/relayer/scripts/relay.sh index 72f96f0..af036b5 100755 --- a/relayer/scripts/relay.sh +++ b/relayer/scripts/relay.sh @@ -23,6 +23,9 @@ REQUEST_MSG=${2:-"{}"} # Use the QUARTZ_PORT environment variable if set, otherwise default to 11090 QUARTZ_PORT="${QUARTZ_PORT:-11090}" +# clear tmp files from previous runs +rm -f "$QUOTE_FILE" "$REPORT_FILE" "$REPORT_SIG_FILE" + # query the gRPC quartz enclave service ATTESTED_MSG=$(grpcurl -plaintext -import-path "$DIR_PROTO" -proto quartz.proto -d "$REQUEST_MSG" "127.0.0.1:$QUARTZ_PORT" quartz.Core/"$REQUEST" | jq -c '.message | fromjson') diff --git a/utils/cycles-sync/Cargo.toml b/utils/cycles-sync/Cargo.toml index 5b2abc9..1e9e5f3 100644 --- a/utils/cycles-sync/Cargo.toml +++ b/utils/cycles-sync/Cargo.toml @@ -9,6 +9,13 @@ repository.workspace = true keywords = ["blockchain", "cosmos", "tendermint", "cycles", "quartz"] readme = "README.md" +[lib] +path = "src/lib.rs" + +[[bin]] +name = "submit" +path = "src/bin/submit.rs" + [dependencies] # external async-trait.workspace = true @@ -26,10 +33,14 @@ tokio.workspace = true tracing.workspace = true tracing-subscriber.workspace = true uuid.workspace = true +anyhow ={ version = "*"} # cosmos cosmrs.workspace = true cosmwasm-std.workspace = true +# quartz +cw-tee-mtcs = { path = "../../apps/mtcs/contracts/cw-tee-mtcs/" } + [dev-dependencies] rand_core.workspace = true diff --git a/utils/cycles-sync/src/bin/submit.rs b/utils/cycles-sync/src/bin/submit.rs new file mode 100644 index 0000000..f321e11 --- /dev/null +++ b/utils/cycles-sync/src/bin/submit.rs @@ -0,0 +1,174 @@ +use std::str::FromStr; + +use anyhow::anyhow; +use bip32::secp256k1::{ + ecdsa::VerifyingKey, + sha2::{Digest, Sha256}, +}; +use clap::Parser; +use cosmrs::{tendermint::chain::Id as TmChainId, AccountId}; +use cosmwasm_std::{Addr, HexBinary}; +use cw_tee_mtcs::state::{LiquiditySource, LiquiditySourceType}; +use cycles_sync::{ + types::{ + ContractObligation, RawEncryptedObligation, RawSetOff, SubmitObligationsMsg, + SubmitObligationsMsgInner, + }, + wasmd_client::{CliWasmdClient, WasmdClient}, +}; +use reqwest::Url; +use serde::{Deserialize, Serialize}; +use subtle_encoding::bech32::decode as bech32_decode; + +// const MNEMONIC_PHRASE: &str = "clutch debate vintage foster barely primary clown leader sell manual leopard ladder wet must embody story oyster imitate cable alien six square rice wedding"; + +const ADDRESS_PREFIX: &str = "wasm"; + +type Sha256Digest = [u8; 32]; + +#[derive(Clone, Debug, Serialize, Deserialize)] +struct QueryAllSetoffsResponse { + setoffs: Vec<(HexBinary, RawSetOff)>, +} + +#[derive(Clone, Debug, Parser)] +#[command(version, about, long_about = None)] +struct Cli { + #[arg(short, long, value_parser = wasmaddr_to_id)] + mtcs: AccountId, + + #[arg(short, long)] + epoch_pk: String, + + #[arg(short, long)] + overdraft: String, + + #[clap(long)] + flip: bool, + + #[arg( + short, + long, + default_value = "wasm14qdftsfk6fwn40l0xmruga08xlczl4g05npy70" + )] + admin: String, +} + +#[tokio::main] +async fn main() -> Result<(), anyhow::Error> { + let cli = Cli::parse(); + let mut alice = Addr::unchecked("wasm124tuy67a9dcvfgcr4gjmz60syd8ddaugl33v0n"); + let mut bob = Addr::unchecked("wasm1ctkqmg45u85jnf5ur9796h7ze4hj6ep5y7m7l6"); + let overdraft = Addr::unchecked(cli.overdraft); + + if cli.flip { + let temp = alice.clone(); + alice = bob; + bob = temp; + } + + let alice_to_bob: ContractObligation = ContractObligation { + debtor: alice.clone(), + creditor: bob.clone(), + amount: 10, + salt: HexBinary::from([0; 64]), + }; + + let bob_acceptance: ContractObligation = ContractObligation { + debtor: bob.clone(), + creditor: overdraft.clone(), + amount: 10, + salt: HexBinary::from([0; 64]), + }; + + let alice_tender: ContractObligation = ContractObligation { + debtor: overdraft.clone(), + creditor: alice.clone(), + amount: 10, + salt: HexBinary::from([0; 64]), + }; + + let intents = vec![alice_to_bob, bob_acceptance, alice_tender]; + let epoch_pk = VerifyingKey::from_sec1_bytes(&hex::decode(cli.epoch_pk).unwrap()).unwrap(); + + let intents_enc = encrypt_overdraft_intents(intents, &epoch_pk); + + let liquidity_sources: Vec = vec![LiquiditySource { + address: overdraft, + source_type: LiquiditySourceType::Overdraft, + }]; + + let msg = create_wasm_msg(intents_enc, liquidity_sources)?; + + let node_url = Url::parse("http://143.244.186.205:26657")?; + let chain_id = TmChainId::from_str("testing")?; + + let wasmd_client = CliWasmdClient::new(node_url); + + wasmd_client.tx_execute(&cli.mtcs, &chain_id, 3000000, cli.admin.to_string(), msg)?; + + Ok(()) +} + +pub struct OverdraftObligation { + pub debtor: Addr, + pub creditor: Addr, + pub amount: u64, +} + +fn encrypt_overdraft_intents( + intents: Vec, + epoch_pk: &VerifyingKey, +) -> Vec<(Sha256Digest, Vec)> { + let mut intents_enc = vec![]; + + for i in intents { + // serialize intent + let i_ser = serde_json::to_string(&i).unwrap(); + + // encrypt intent + let i_cipher = ecies::encrypt(&epoch_pk.to_sec1_bytes(), i_ser.as_bytes()).unwrap(); + + // hash intent + let i_digest: Sha256Digest = { + let mut hasher = Sha256::new(); + hasher.update(i_ser); + hasher.finalize().into() + }; + + intents_enc.push((i_digest, i_cipher)); + } + + intents_enc +} + +fn create_wasm_msg( + obligations_enc: Vec<(Sha256Digest, Vec)>, + liquidity_sources: Vec, +) -> anyhow::Result { + let obligations_enc: Vec<_> = obligations_enc + .into_iter() + .map(|(digest, ciphertext)| { + let digest = HexBinary::from(digest); + let ciphertext = HexBinary::from(ciphertext); + RawEncryptedObligation { digest, ciphertext } + }) + .collect(); + + let msg = SubmitObligationsMsg { + submit_obligations: SubmitObligationsMsgInner { + obligations: obligations_enc, + liquidity_sources, + }, + }; + serde_json::to_value(msg).map_err(Into::into) +} + +fn wasmaddr_to_id(address_str: &str) -> anyhow::Result { + let (hr, _) = bech32_decode(address_str).map_err(|e| anyhow!(e))?; + if hr != ADDRESS_PREFIX { + return Err(anyhow!(hr)); + } + + Ok(address_str.parse().unwrap()) +} diff --git a/utils/cycles-sync/src/cli.rs b/utils/cycles-sync/src/cli.rs index 194f704..e30d607 100644 --- a/utils/cycles-sync/src/cli.rs +++ b/utils/cycles-sync/src/cli.rs @@ -8,7 +8,7 @@ use subtle_encoding::{bech32::decode as bech32_decode, Error as Bech32DecodeErro use thiserror::Error; use uuid::Uuid; -use crate::ADDRESS_PREFIX; +const ADDRESS_PREFIX: &str = "wasm"; #[derive(Clone, Debug, Parser)] #[command(author, version, about)] diff --git a/utils/cycles-sync/src/lib.rs b/utils/cycles-sync/src/lib.rs index cd40856..2c52633 100644 --- a/utils/cycles-sync/src/lib.rs +++ b/utils/cycles-sync/src/lib.rs @@ -1 +1,4 @@ +pub mod cli; +pub mod obligato_client; pub mod types; +pub mod wasmd_client; diff --git a/utils/cycles-sync/src/main.rs b/utils/cycles-sync/src/main.rs index 57805b5..9d82a76 100644 --- a/utils/cycles-sync/src/main.rs +++ b/utils/cycles-sync/src/main.rs @@ -27,7 +27,7 @@ use crate::{ obligato_client::{http::HttpClient, Client}, types::{ Obligation, ObligatoObligation, ObligatoSetOff, RawEncryptedObligation, RawObligation, - RawOffset, RawSetOff, SubmitObligationsMsg, SubmitObligationsMsgInner, + RawOffset, RawSetOff, SubmitObligatioMsg, SubmitObligatoObligationsMsgInner, }, wasmd_client::{CliWasmdClient, QueryResult, WasmdClient}, }; @@ -112,10 +112,8 @@ async fn sync_setoffs(cli: Cli) -> Result<(), DynError> { .flat_map(|(obligation_digest, so)| match so { RawSetOff::SetOff(sos_enc) => { let so_enc = sos_enc.first().unwrap(); - let (debtor_id, creditor_id) = obligation_user_map - .get(obligation_digest) - .map(Clone::clone) - .unwrap(); + let (debtor_id, creditor_id) = + obligation_user_map.get(obligation_digest).copied().unwrap(); let sk = |id| keys[&id].private_key().to_bytes(); let so_ser = if let Ok(so) = ecies::decrypt(&sk(debtor_id), so_enc.as_slice()) { @@ -202,8 +200,8 @@ fn create_wasm_msg( .map(|pk| HexBinary::from(pk.to_sec1_bytes().as_ref())) .collect(); - let msg = SubmitObligationsMsg { - submit_obligations: SubmitObligationsMsgInner { + let msg = SubmitObligatioMsg { + submit_obligations: SubmitObligatoObligationsMsgInner { obligations: obligations_enc, liquidity_sources, }, @@ -377,7 +375,7 @@ mod tests { #[test] fn test_create_mnemonic() { // Generate random Mnemonic using the default language (English) - let mnemonic = Mnemonic::random(&mut OsRng, Default::default()); + let mnemonic = Mnemonic::random(OsRng, Default::default()); println!("{}", mnemonic.phrase()); } diff --git a/utils/cycles-sync/src/types.rs b/utils/cycles-sync/src/types.rs index 428f113..acb352b 100644 --- a/utils/cycles-sync/src/types.rs +++ b/utils/cycles-sync/src/types.rs @@ -1,5 +1,6 @@ use bip32::secp256k1::ecdsa::VerifyingKey; -use cosmwasm_std::HexBinary; +use cosmwasm_std::{Addr, HexBinary}; +use cw_tee_mtcs::state::LiquiditySource; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -11,6 +12,15 @@ pub struct ObligatoObligation { pub amount: u64, } +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ContractObligation { + pub debtor: Addr, + pub creditor: Addr, + pub amount: u64, + #[serde(default)] + pub salt: HexBinary, +} + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct RawObligation { pub debtor: HexBinary, @@ -52,6 +62,17 @@ pub struct SubmitObligationsMsg { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SubmitObligationsMsgInner { + pub obligations: Vec, + pub liquidity_sources: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct SubmitObligatioMsg { + pub submit_obligations: SubmitObligatoObligationsMsgInner, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct SubmitObligatoObligationsMsgInner { pub obligations: Vec, pub liquidity_sources: Vec, } diff --git a/utils/cycles-sync/src/wasmd_client.rs b/utils/cycles-sync/src/wasmd_client.rs index 14e4c85..f93457b 100644 --- a/utils/cycles-sync/src/wasmd_client.rs +++ b/utils/cycles-sync/src/wasmd_client.rs @@ -1,22 +1,30 @@ -use std::{error::Error, process::Command}; +use std::process::Command; +use anyhow::anyhow; use cosmrs::{tendermint::chain::Id, AccountId}; +use hex::ToHex; use reqwest::Url; -use serde::{Deserialize, Serialize}; -use tracing::debug; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; pub trait WasmdClient { type Address: AsRef; type Query: ToString; + type RawQuery: ToHex; type ChainId: AsRef; type Error; - fn query_smart( + fn query_smart( &self, contract: &Self::Address, query: Self::Query, ) -> Result; + fn query_raw( + &self, + contract: &Self::Address, + query: Self::RawQuery, + ) -> Result; + fn tx_execute( &self, contract: &Self::Address, @@ -24,24 +32,30 @@ pub trait WasmdClient { gas: u64, sender: String, msg: M, - ) -> Result<(), Self::Error>; + ) -> Result; + + fn deploy( + &self, + chain_id: &Id, + sender: String, // what should this type be + wasm_path: M, + ) -> Result; + + fn init( + &self, + chain_id: &Id, + sender: String, + code_id: usize, + init_msg: M, + label: String, + ) -> Result; } -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize, Default)] pub struct QueryResult { pub data: T, } -pub trait FromVec: Sized { - fn from_vec(value: Vec) -> Self; -} - -impl Deserialize<'any>> FromVec for T { - fn from_vec(value: Vec) -> Self { - serde_json::from_slice(&value).unwrap() - } -} - #[derive(Clone, Debug)] pub struct CliWasmdClient { url: Url, @@ -56,10 +70,11 @@ impl CliWasmdClient { impl WasmdClient for CliWasmdClient { type Address = AccountId; type Query = serde_json::Value; + type RawQuery = String; type ChainId = Id; - type Error = Box; + type Error = anyhow::Error; - fn query_smart( + fn query_smart( &self, contract: &Self::Address, query: Self::Query, @@ -73,9 +88,34 @@ impl WasmdClient for CliWasmdClient { .args(["--output", "json"]); let output = command.output()?; - debug!("{:?} => {:?}", command, output); + if !output.status.success() { + return Err(anyhow!("{:?}", output)); + } - let query_result = R::from_vec(output.stdout); + let query_result: R = serde_json::from_slice(&output.stdout) + .map_err(|e| anyhow!("Error deserializing: {}", e))?; + Ok(query_result) + } + + fn query_raw( + &self, + contract: &Self::Address, + query: Self::RawQuery, + ) -> Result { + let mut wasmd = Command::new("wasmd"); + let command = wasmd + .args(["--node", self.url.as_str()]) + .args(["query", "wasm"]) + .args(["contract-state", "raw", contract.as_ref()]) + .arg(&query) + .args(["--output", "json"]); + + let output = command.output()?; + if !output.status.success() { + return Err(anyhow!("{:?}", output)); + } + + let query_result: R = serde_json::from_slice(&output.stdout).unwrap_or_default(); Ok(query_result) } @@ -86,7 +126,7 @@ impl WasmdClient for CliWasmdClient { gas: u64, sender: String, msg: M, - ) -> Result<(), Self::Error> { + ) -> Result { let mut wasmd = Command::new("wasmd"); let command = wasmd .args(["--node", self.url.as_str()]) @@ -99,12 +139,73 @@ impl WasmdClient for CliWasmdClient { .arg("-y"); let output = command.output()?; - debug!("{:?} => {:?}", command, output); - if output.status.success() { - println!("{}", String::from_utf8(output.stdout).unwrap()); + if !output.status.success() { + return Err(anyhow!("{:?}", output)); } - Ok(()) + // TODO: find the rust type for the tx output and return that + Ok((String::from_utf8(output.stdout)?).to_string()) + } + + fn deploy( + &self, + chain_id: &Id, + sender: String, + wasm_path: M, + ) -> Result { + let mut wasmd = Command::new("wasmd"); + let command = wasmd + .args(["--node", self.url.as_str()]) + .args(["tx", "wasm", "store", &wasm_path.to_string()]) + .args(["--from", sender.as_ref()]) + .args(["--chain-id", chain_id.as_ref()]) + .args(["--gas-prices", "0.0025ucosm"]) + .args(["--gas", "auto"]) + .args(["--gas-adjustment", "1.3"]) + .args(["-o", "json"]) + .arg("-y"); + + let output = command.output()?; + + if !output.status.success() { + return Err(anyhow!("{:?}", output)); + } + + // TODO: find the rust type for the tx output and return that + Ok((String::from_utf8(output.stdout)?).to_string()) + } + + fn init( + &self, + chain_id: &Id, + sender: String, + code_id: usize, + init_msg: M, + label: String, + ) -> Result { + let mut wasmd = Command::new("wasmd"); + let command = wasmd + .args(["--node", self.url.as_str()]) + .args(["tx", "wasm", "instantiate"]) + .args([&code_id.to_string(), &init_msg.to_string()]) + .args(["--label", label.as_ref()]) + .args(["--from", sender.as_ref()]) + .arg("--no-admin") + .args(["--chain-id", chain_id.as_ref()]) + .args(["--gas-prices", "0.0025ucosm"]) + .args(["--gas", "auto"]) + .args(["--gas-adjustment", "1.3"]) + .args(["-o", "json"]) + .arg("-y"); + + let output = command.output()?; + + if !output.status.success() { + return Err(anyhow!("{:?}", output)); + } + + // TODO: find the rust type for the tx output and return that + Ok((String::from_utf8(output.stdout)?).to_string()) } } diff --git a/utils/tm-prover/Cargo.toml b/utils/tm-prover/Cargo.toml index 2fc1e1f..d7e6e93 100644 --- a/utils/tm-prover/Cargo.toml +++ b/utils/tm-prover/Cargo.toml @@ -9,6 +9,10 @@ repository.workspace = true keywords = ["blockchain", "cosmos", "tendermint", "cycles", "quartz"] readme = "README.md" +[[bin]] +name = "main" +path = "src/main.rs" + [dependencies] # external clap.workspace = true @@ -28,4 +32,4 @@ tendermint-light-client.workspace = true tendermint-light-client-detector.workspace = true # quartz -cw-proof.workspace = true +cw-proof.workspace = true \ No newline at end of file diff --git a/utils/tm-prover/src/config.rs b/utils/tm-prover/src/config.rs new file mode 100644 index 0000000..60b80fa --- /dev/null +++ b/utils/tm-prover/src/config.rs @@ -0,0 +1,147 @@ +use std::{num::ParseIntError, path::PathBuf, str::FromStr}; + +use clap::Parser; +use color_eyre::eyre::{eyre, Result}; +use cosmrs::AccountId; +use cw_proof::proof::cw::RawCwProof; +use serde::{Deserialize, Serialize}; +use tendermint_light_client::types::{Hash, Height, LightBlock, TrustThreshold}; +use tendermint_rpc::HttpClientUrl; +use tracing::metadata::LevelFilter; + +pub fn parse_trust_threshold(s: &str) -> Result { + if let Some((l, r)) = s.split_once('/') { + TrustThreshold::new(l.parse()?, r.parse()?).map_err(Into::into) + } else { + Err(eyre!( + "invalid trust threshold: {s}, format must be X/Y where X and Y are integers" + )) + } +} + +#[derive(Clone, Debug)] +pub struct List(pub Vec); + +impl> FromStr for List { + type Err = E; + + fn from_str(s: &str) -> Result { + s.split(',') + .map(|s| s.parse()) + .collect::, _>>() + .map(Self) + } +} + +#[derive(clap::Args, Debug, Clone)] +pub struct Verbosity { + /// Increase verbosity, can be repeated up to 2 times + #[arg(long, short, action = clap::ArgAction::Count)] + pub verbose: u8, +} + +impl Verbosity { + pub fn to_level_filter(&self) -> LevelFilter { + match self.verbose { + 0 => LevelFilter::INFO, + 1 => LevelFilter::DEBUG, + _ => LevelFilter::TRACE, + } + } + + fn default() -> Self { + Self { verbose: 0 } + } +} + +impl FromStr for Verbosity { + type Err = ParseIntError; + + fn from_str(s: &str) -> Result { + let verbose: u8 = s.parse()?; + Ok(Self { verbose }) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ProofOutput { + pub light_client_proof: Vec, + pub merkle_proof: RawCwProof, +} + +// TODO: Investigate if it's possible to derive default using Clap's default values +impl Default for Config { + fn default() -> Self { + Config { + chain_id: String::default(), + primary: "http://127.0.0.1:26657".parse().unwrap(), + witnesses: "[]".parse().unwrap(), + trusted_height: Height::default(), + trusted_hash: Hash::default(), + trust_threshold: TrustThreshold::TWO_THIRDS, + trusting_period: 1209600u64, + max_clock_drift: 5u64, + max_block_lag: 5u64, + trace_file: None, + verbose: Verbosity::default(), + contract_address: "".parse().unwrap(), + storage_key: String::default(), + } + } +} + +#[derive(Debug, Parser)] +#[command(author, version, about, long_about = None)] +pub struct Config { + /// Identifier of the chain + #[clap(long)] + pub chain_id: String, + + /// Primary RPC address + #[clap(long, default_value = "http://127.0.0.1:26657")] + pub primary: HttpClientUrl, + + /// Comma-separated list of witnesses RPC addresses + #[clap(long)] + pub witnesses: List, + + /// Height of trusted header + #[clap(long)] + pub trusted_height: Height, + + /// Hash of trusted header + #[clap(long)] + pub trusted_hash: Hash, + + /// Trust threshold + #[clap(long, value_parser = parse_trust_threshold, default_value_t = TrustThreshold::TWO_THIRDS)] + pub trust_threshold: TrustThreshold, + + /// Trusting period, in seconds (default: two weeks) + #[clap(long, default_value = "1209600")] + pub trusting_period: u64, + + /// Maximum clock drift, in seconds + #[clap(long, default_value = "5")] + pub max_clock_drift: u64, + + /// Maximum block lag, in seconds + #[clap(long, default_value = "5")] + pub max_block_lag: u64, + + /// Output file to store light client proof (AKA verification trace) + #[clap(long)] + pub trace_file: Option, + + /// Increase verbosity + #[clap(flatten)] + pub verbose: Verbosity, + + /// Address of the CosmWasm contract + #[clap(long)] + pub contract_address: AccountId, + + /// Storage key of the state item for which proofs must be retrieved + #[clap(long)] + pub storage_key: String, +} diff --git a/utils/tm-prover/src/lib.rs b/utils/tm-prover/src/lib.rs new file mode 100644 index 0000000..8dc915e --- /dev/null +++ b/utils/tm-prover/src/lib.rs @@ -0,0 +1,2 @@ +pub mod config; +pub mod prover; diff --git a/utils/tm-prover/src/main.rs b/utils/tm-prover/src/main.rs index ed8902e..e36333a 100644 --- a/utils/tm-prover/src/main.rs +++ b/utils/tm-prover/src/main.rs @@ -1,361 +1,12 @@ -#![deny( - warnings, - trivial_casts, - trivial_numeric_casts, - unused_import_braces, - unused_qualifications -)] -#![forbid(unsafe_code)] - -use std::{ - fs::File, - io::{BufWriter, Write}, - path::PathBuf, - str::FromStr, - time::Duration, -}; - use clap::Parser; -use color_eyre::{ - eyre::{eyre, Result}, - Report, -}; -use cosmrs::AccountId; -use cw_proof::{ - error::ProofError, - proof::{ - cw::{CwProof, RawCwProof}, - key::CwAbciKey, - Proof, - }, -}; -use futures::future::join_all; -use serde::{Deserialize, Serialize}; -use tendermint::{crypto::default::Sha256, evidence::Evidence}; -use tendermint_light_client::{ - builder::LightClientBuilder, - light_client::Options, - store::memory::MemoryStore, - types::{Hash, Height, LightBlock, TrustThreshold}, -}; -use tendermint_light_client_detector::{detect_divergence, Error, Provider, Trace}; -use tendermint_rpc::{client::HttpClient, Client, HttpClientUrl}; -use tracing::{error, info, metadata::LevelFilter}; -use tracing_subscriber::{util::SubscriberInitExt, EnvFilter}; - -const WASM_STORE_KEY: &str = "/store/wasm/key"; - -fn parse_trust_threshold(s: &str) -> Result { - if let Some((l, r)) = s.split_once('/') { - TrustThreshold::new(l.parse()?, r.parse()?).map_err(Into::into) - } else { - Err(eyre!( - "invalid trust threshold: {s}, format must be X/Y where X and Y are integers" - )) - } -} - -#[derive(Clone, Debug)] -struct List(Vec); - -impl> FromStr for List { - type Err = E; - - fn from_str(s: &str) -> Result { - s.split(',') - .map(|s| s.parse()) - .collect::, _>>() - .map(Self) - } -} - -#[derive(clap::Args, Debug, Clone)] -struct Verbosity { - /// Increase verbosity, can be repeated up to 2 times - #[arg(long, short, action = clap::ArgAction::Count)] - verbose: u8, -} - -impl Verbosity { - fn to_level_filter(&self) -> LevelFilter { - match self.verbose { - 0 => LevelFilter::INFO, - 1 => LevelFilter::DEBUG, - _ => LevelFilter::TRACE, - } - } -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -struct ProofOutput { - light_client_proof: Vec, - merkle_proof: RawCwProof, -} - -#[derive(Debug, Parser)] -#[command(author, version, about, long_about = None)] -struct Cli { - /// Identifier of the chain - #[clap(long)] - chain_id: String, - - /// Primary RPC address - #[clap(long, default_value = "http://127.0.0.1:26657")] - primary: HttpClientUrl, - - /// Comma-separated list of witnesses RPC addresses - #[clap(long)] - witnesses: List, - - /// Height of trusted header - #[clap(long)] - trusted_height: Height, - - /// Hash of trusted header - #[clap(long)] - trusted_hash: Hash, - - /// Trust threshold - #[clap(long, value_parser = parse_trust_threshold, default_value_t = TrustThreshold::TWO_THIRDS)] - trust_threshold: TrustThreshold, - - /// Trusting period, in seconds (default: two weeks) - #[clap(long, default_value = "1209600")] - trusting_period: u64, - - /// Maximum clock drift, in seconds - #[clap(long, default_value = "5")] - max_clock_drift: u64, - - /// Maximum block lag, in seconds - #[clap(long, default_value = "5")] - max_block_lag: u64, - - /// Output file to store light client proof (AKA verification trace) - #[clap(long)] - trace_file: Option, - - /// Increase verbosity - #[clap(flatten)] - verbose: Verbosity, - - /// Address of the CosmWasm contract - #[clap(long)] - contract_address: AccountId, - - /// Storage key of the state item for which proofs must be retrieved - #[clap(long)] - storage_key: String, -} +use color_eyre::eyre::Result; +use tm_prover::{config::Config, prover::prove}; #[tokio::main] async fn main() -> Result<()> { color_eyre::install()?; - let args = Cli::parse(); + let args = Config::parse(); - let env_filter = EnvFilter::builder() - .with_default_directive(args.verbose.to_level_filter().into()) - .from_env_lossy(); - - tracing_subscriber::fmt() - .with_target(false) - .with_env_filter(env_filter) - .finish() - .init(); - - let options = Options { - trust_threshold: args.trust_threshold, - trusting_period: Duration::from_secs(args.trusting_period), - clock_drift: Duration::from_secs(args.max_clock_drift), - }; - - let mut primary = make_provider( - &args.chain_id, - args.primary.clone(), - args.trusted_height, - args.trusted_hash, - options, - ) - .await?; - - let client = HttpClient::builder(args.primary.clone()).build()?; - - let trusted_block = primary - .latest_trusted() - .ok_or_else(|| eyre!("No trusted state found for primary"))?; - - let status = client.status().await?; - let latest_height = status.sync_info.latest_block_height; - let latest_app_hash = status.sync_info.latest_app_hash; - - // `proof_height` is the height at which we want to query the blockchain's state - // This is one less than than the `latest_height` because we want to verify the merkle-proof for - // the state against the `app_hash` at `latest_height`. - // (because Tendermint commits to the latest `app_hash` in the subsequent block) - let proof_height = (latest_height.value() - 1) - .try_into() - .expect("infallible conversion"); - - info!("Verifying to latest height on primary..."); - - let primary_block = primary.verify_to_height(latest_height)?; - - info!("Verified to height {} on primary", primary_block.height()); - let mut primary_trace = primary.get_trace(primary_block.height()); - - let witnesses = join_all(args.witnesses.0.into_iter().map(|addr| { - make_provider( - &args.chain_id, - addr, - trusted_block.height(), - trusted_block.signed_header.header.hash(), - options, - ) - })) - .await; - - let mut witnesses = witnesses.into_iter().collect::>>()?; - - let max_clock_drift = Duration::from_secs(args.max_clock_drift); - let max_block_lag = Duration::from_secs(args.max_block_lag); - - run_detector( - &mut primary, - witnesses.as_mut_slice(), - primary_trace.clone(), - max_clock_drift, - max_block_lag, - ) - .await?; - - let path = WASM_STORE_KEY.to_owned(); - let data = CwAbciKey::new(args.contract_address, args.storage_key, None); - let result = client - .abci_query(Some(path), data, Some(proof_height), true) - .await?; - - let proof: CwProof = result - .clone() - .try_into() - .expect("result should contain proof"); - proof - .verify(latest_app_hash.clone().into()) - .map_err(|e: ProofError| eyre!(e))?; - - if let Some(trace_file) = args.trace_file { - // replace the last block in the trace (i.e. the (latest - 1) block) with the latest block - // we don't actually verify the latest block because it will be verified on the other side - let latest_block = primary.fetch_light_block(latest_height)?; - let _ = primary_trace.pop(); - primary_trace.push(latest_block); - - let output = ProofOutput { - light_client_proof: primary_trace, - merkle_proof: proof.into(), - }; - write_proof_to_file(trace_file, output).await?; - }; - - Ok(()) -} - -async fn write_proof_to_file(trace_file: PathBuf, output: ProofOutput) -> Result<()> { - info!("Writing proof to output file ({})", trace_file.display()); - - let file = File::create(trace_file)?; - let mut writer = BufWriter::new(file); - serde_json::to_writer(&mut writer, &output)?; - writer.flush()?; - Ok(()) -} - -async fn run_detector( - primary: &mut Provider, - witnesses: &mut [Provider], - primary_trace: Vec, - max_clock_drift: Duration, - max_block_lag: Duration, -) -> Result<(), Report> { - if witnesses.is_empty() { - return Err(Error::no_witnesses().into()); - } - - info!( - "Running misbehavior detection against {} witnesses...", - witnesses.len() - ); - - let primary_trace = Trace::new(primary_trace)?; - - for witness in witnesses { - let divergence = detect_divergence::( - Some(primary), - witness, - primary_trace.clone().into_vec(), - max_clock_drift, - max_block_lag, - ) - .await; - - let evidence = match divergence { - Ok(Some(divergence)) => divergence.evidence, - Ok(None) => { - info!( - "no divergence found between primary and witness {}", - witness.peer_id() - ); - - continue; - } - Err(e) => { - error!( - "failed to run attack detector against witness {}: {e}", - witness.peer_id() - ); - - continue; - } - }; - - // Report the evidence to the witness - witness - .report_evidence(Evidence::from(evidence.against_primary)) - .await - .map_err(|e| eyre!("failed to report evidence to witness: {}", e))?; - - if let Some(against_witness) = evidence.against_witness { - // Report the evidence to the primary - primary - .report_evidence(Evidence::from(against_witness)) - .await - .map_err(|e| eyre!("failed to report evidence to primary: {}", e))?; - } - } - - Ok(()) -} - -async fn make_provider( - chain_id: &str, - rpc_addr: HttpClientUrl, - trusted_height: Height, - trusted_hash: Hash, - options: Options, -) -> Result { - use tendermint_rpc::client::CompatMode; - - let rpc_client = HttpClient::builder(rpc_addr) - .compat_mode(CompatMode::V0_34) - .build()?; - - let node_id = rpc_client.status().await?.node_info.id; - let light_store = Box::new(MemoryStore::new()); - - let instance = - LightClientBuilder::prod(node_id, rpc_client.clone(), light_store, options, None) - .trust_primary_at(trusted_height, trusted_hash)? - .build(); - - Ok(Provider::new(chain_id.to_string(), instance, rpc_client)) + prove(args).await } diff --git a/utils/tm-prover/src/prover.rs b/utils/tm-prover/src/prover.rs new file mode 100644 index 0000000..7a7f252 --- /dev/null +++ b/utils/tm-prover/src/prover.rs @@ -0,0 +1,262 @@ +#![deny( + warnings, + trivial_casts, + trivial_numeric_casts, + unused_import_braces, + unused_qualifications +)] +#![forbid(unsafe_code)] + +use std::{ + fs::File, + io::{BufWriter, Write}, + path::PathBuf, + time::Duration, +}; + +use color_eyre::{ + eyre::{eyre, Result}, + Report, +}; +use cw_proof::{ + error::ProofError, + proof::{cw::CwProof, key::CwAbciKey, Proof}, +}; +use futures::future::join_all; +use tendermint::{crypto::default::Sha256, evidence::Evidence, Hash}; +use tendermint_light_client::{ + builder::LightClientBuilder, + light_client::Options, + store::memory::MemoryStore, + types::{Height, LightBlock}, +}; +use tendermint_light_client_detector::{detect_divergence, Error, Provider, Trace}; +use tendermint_rpc::{client::HttpClient, Client, HttpClientUrl}; +use tracing::{error, info}; +use tracing_subscriber::{util::SubscriberInitExt, EnvFilter}; + +const WASM_STORE_KEY: &str = "/store/wasm/key"; + +use crate::config::{Config as TmProverConfig, ProofOutput}; + +pub async fn prove( + TmProverConfig { + chain_id, + primary, + witnesses, + trusted_height, + trusted_hash, + trust_threshold, + trusting_period, + max_clock_drift, + max_block_lag, + trace_file, + verbose, + contract_address, + storage_key, + }: TmProverConfig, +) -> Result<()> { + let env_filter = EnvFilter::builder() + .with_default_directive(verbose.to_level_filter().into()) + .from_env_lossy(); + + tracing_subscriber::fmt() + .with_target(false) + .with_env_filter(env_filter) + .finish() + .init(); + + let options = Options { + trust_threshold, + trusting_period: Duration::from_secs(trusting_period), + clock_drift: Duration::from_secs(max_clock_drift), + }; + + let mut provider = make_provider( + &chain_id, + primary.clone(), + trusted_height, + trusted_hash, + options, + ) + .await?; + + let client = HttpClient::builder(primary.clone()).build()?; + + let trusted_block = provider + .latest_trusted() + .ok_or_else(|| eyre!("No trusted state found for primary"))?; + + let status = client.status().await?; + let latest_height = status.sync_info.latest_block_height; + let latest_app_hash = status.sync_info.latest_app_hash; + + // `proof_height` is the height at which we want to query the blockchain's state + // This is one less than than the `latest_height` because we want to verify the merkle-proof for + // the state against the `app_hash` at `latest_height`. + // (because Tendermint commits to the latest `app_hash` in the subsequent block) + let proof_height = (latest_height.value() - 1) + .try_into() + .expect("infallible conversion"); + + info!("Verifying to latest height on primary..."); + + let primary_block = provider.verify_to_height(latest_height)?; + + info!("Verified to height {} on primary", primary_block.height()); + let mut primary_trace = provider.get_trace(primary_block.height()); + let witnesses = join_all(witnesses.0.into_iter().map(|addr: HttpClientUrl| { + make_provider( + &chain_id, + addr, + trusted_block.height(), + trusted_block.signed_header.header.hash(), + options, + ) + })) + .await; + + let mut witnesses = witnesses.into_iter().collect::>>()?; + + let max_clock_drift = Duration::from_secs(max_clock_drift); + let max_block_lag = Duration::from_secs(max_block_lag); + + run_detector( + &mut provider, + witnesses.as_mut_slice(), + primary_trace.clone(), + max_clock_drift, + max_block_lag, + ) + .await?; + + let path = WASM_STORE_KEY.to_owned(); + let data = CwAbciKey::new(contract_address, storage_key, None); + let result = client + .abci_query(Some(path), data, Some(proof_height), true) + .await?; + + let proof: CwProof = result + .clone() + .try_into() + .expect("result should contain proof"); + proof + .verify(latest_app_hash.clone().into()) + .map_err(|e: ProofError| eyre!(e))?; + + if let Some(trace_file) = trace_file { + // replace the last block in the trace (i.e. the (latest - 1) block) with the latest block + // we don't actually verify the latest block because it will be verified on the other side + let latest_block = provider.fetch_light_block(latest_height)?; + let _ = primary_trace.pop(); + primary_trace.push(latest_block); + + let output = ProofOutput { + light_client_proof: primary_trace, + merkle_proof: proof.into(), + }; + write_proof_to_file(trace_file, output).await?; + }; + + Ok(()) +} + +async fn write_proof_to_file(trace_file: PathBuf, output: ProofOutput) -> Result<()> { + info!("Writing proof to output file ({})", trace_file.display()); + + let file = File::create(trace_file)?; + let mut writer = BufWriter::new(file); + serde_json::to_writer(&mut writer, &output)?; + writer.flush()?; + Ok(()) +} + +async fn run_detector( + primary: &mut Provider, + witnesses: &mut [Provider], + primary_trace: Vec, + max_clock_drift: Duration, + max_block_lag: Duration, +) -> Result<(), Report> { + if witnesses.is_empty() { + return Err(Error::no_witnesses().into()); + } + + info!( + "Running misbehavior detection against {} witnesses...", + witnesses.len() + ); + + let primary_trace = Trace::new(primary_trace)?; + + for witness in witnesses { + let divergence = detect_divergence::( + Some(primary), + witness, + primary_trace.clone().into_vec(), + max_clock_drift, + max_block_lag, + ) + .await; + + let evidence = match divergence { + Ok(Some(divergence)) => divergence.evidence, + Ok(None) => { + info!( + "no divergence found between primary and witness {}", + witness.peer_id() + ); + + continue; + } + Err(e) => { + error!( + "failed to run attack detector against witness {}: {e}", + witness.peer_id() + ); + + continue; + } + }; + + // Report the evidence to the witness + witness + .report_evidence(Evidence::from(evidence.against_primary)) + .await + .map_err(|e| eyre!("failed to report evidence to witness: {}", e))?; + + if let Some(against_witness) = evidence.against_witness { + // Report the evidence to the primary + primary + .report_evidence(Evidence::from(against_witness)) + .await + .map_err(|e| eyre!("failed to report evidence to primary: {}", e))?; + } + } + + Ok(()) +} + +async fn make_provider( + chain_id: &str, + rpc_addr: HttpClientUrl, + trusted_height: Height, + trusted_hash: Hash, + options: Options, +) -> Result { + use tendermint_rpc::client::CompatMode; + + let rpc_client = HttpClient::builder(rpc_addr) + .compat_mode(CompatMode::V0_34) + .build()?; + + let node_id = rpc_client.status().await?.node_info.id; + let light_store = Box::new(MemoryStore::new()); + + let instance = + LightClientBuilder::prod(node_id, rpc_client.clone(), light_store, options, None) + .trust_primary_at(trusted_height, trusted_hash)? + .build(); + + Ok(Provider::new(chain_id.to_string(), instance, rpc_client)) +}