diff --git a/.github/workflows/benchmarking.yml b/.github/workflows/benchmarking.yml index 7231dfce4..19a517c4f 100644 --- a/.github/workflows/benchmarking.yml +++ b/.github/workflows/benchmarking.yml @@ -28,7 +28,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.50.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -36,7 +36,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-benchmarking-rust:1.57.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-benchmarking-rust:1.50.0-{{ checksum "Cargo.lock" }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Run vm benchmarks (Singlepass) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17b3e664b..43cf6ca90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 615b87e7a..454d36b5a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: types: [closed] env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: release: runs-on: ubuntu-latest @@ -20,10 +20,10 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal - override: true + override: true - name: Get version id: get_version run: | @@ -37,6 +37,7 @@ jobs: with: version: ${{ steps.get_version.outputs.version }} git_tag_prefix: v + - name: Create new tag run: | if [ -z "${{ steps.get_version.outputs.version }}" ]; then @@ -56,12 +57,12 @@ jobs: - name: Build development contracts run: | echo "Building all contracts under ./contracts" - docker run --volumes-from with_code cosmwasm/rust-optimizer:0.12.1 ./contracts/*/ + docker run --volumes-from with_code cosmwasm/rust-optimizer:0.11.0 ./contracts/*/ - name: Check development contracts working-directory: ./ run: | echo "Checking all contracts under ./artifacts" - docker run --volumes-from with_code rust:1.54.0 /bin/bash -e -c 'cd ./code/packages/vm; ./examples/check_contract.sh ../../artifacts/*.wasm' + docker run --volumes-from with_code rust:1.51.0 /bin/bash -e -c 'cd ./code/packages/vm; ./examples/check_contract.sh ../../artifacts/*.wasm' docker cp with_code:/code/artifacts . - name: Create Release diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5080fdc80..79cfd6c58 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,7 +19,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -27,7 +27,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-package_crypto-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-package_crypto-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Build @@ -48,7 +48,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -56,7 +56,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-package_schema-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-package_schema-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Build @@ -77,7 +77,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -85,7 +85,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-package_std-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-package_std-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add wasm32 target @@ -130,7 +130,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -138,7 +138,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-package_storage-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-package_storage-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Build library for native target @@ -162,7 +162,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -170,7 +170,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-package_vm-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-package_vm-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Build @@ -197,7 +197,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -205,7 +205,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-contract_burner-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-contract_burner-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add wasm32 target @@ -243,7 +243,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -251,7 +251,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-contract_crypto_verify-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-contract_crypto_verify-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add wasm32 target @@ -289,7 +289,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -297,7 +297,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-hackatom_verify-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-hackatom_verify-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add wasm32 target @@ -335,7 +335,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -343,7 +343,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-contract_ibc_reflect-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-contract_ibc_reflect-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add wasm32 target @@ -381,7 +381,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -389,7 +389,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-contract_ibc_reflect_send-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-contract_ibc_reflect_send-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add wasm32 target @@ -427,7 +427,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -435,7 +435,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-contract_queue-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-contract_queue-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add wasm32 target @@ -473,7 +473,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -481,7 +481,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-contract_reflect-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-contract_reflect-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add wasm32 target @@ -519,7 +519,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -527,7 +527,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-contract_staking-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-contract_staking-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add wasm32 target @@ -565,7 +565,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -573,7 +573,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-fmt-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-fmt-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add rustfmt component @@ -611,7 +611,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.57.0 + toolchain: 1.51.0 target: wasm32-unknown-unknown profile: minimal override: true @@ -619,7 +619,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cargo - key: cargocache-v2-clippy-rust:1.57.0-${{ hashFiles('Cargo.lock') }} + key: cargocache-v2-clippy-rust:1.51.0-${{ hashFiles('Cargo.lock') }} - name: Version information run: rustc --version; cargo --version; rustup --version; rustup target list --installed - name: Add clippy component diff --git a/.mergify.yml b/.mergify.yml index 44a711384..77ccf0ca9 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -19,7 +19,6 @@ pull_request_rules: - "status-success=ci/circleci: contract_hackatom" - "status-success=ci/circleci: contract_ibc_reflect" - "status-success=ci/circleci: contract_ibc_reflect_send" - - "status-success=ci/circleci: contract_floaty" - "status-success=ci/circleci: contract_queue" - "status-success=ci/circleci: contract_reflect" - "status-success=ci/circleci: contract_staking" diff --git a/.prettierrc.json b/.prettierrc.json index 6a82f4e8f..5b5bd9933 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,10 +1,3 @@ { - "overrides": [ - { - "files": "*.md", - "options": { - "proseWrap": "always" - } - } - ] + "proseWrap": "always" } diff --git a/Cargo.lock b/Cargo.lock index a46d4ff16..d3e25dc0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -62,10 +51,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -75,12 +64,32 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" +dependencies = [ + "funty", + "radium", + "wyz", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -108,27 +117,6 @@ version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" -[[package]] -name = "bytecheck" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" -dependencies = [ - "bytecheck_derive", - "ptr_meta", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "byteorder" version = "1.4.3" @@ -150,6 +138,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -192,9 +186,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -248,7 +242,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -271,7 +264,6 @@ dependencies = [ "criterion", "hex", "hex-literal", - "loupe", "parity-wasm", "schemars", "serde", @@ -295,35 +287,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -331,21 +325,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -355,11 +352,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -404,7 +401,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -414,7 +411,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -425,7 +422,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -438,33 +435,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -507,9 +486,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -517,9 +496,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -531,9 +510,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -542,9 +521,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -587,16 +566,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -624,16 +602,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -673,11 +653,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -687,6 +668,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -703,7 +690,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -714,16 +701,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -738,12 +725,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -758,9 +745,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -785,9 +769,9 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -812,9 +796,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.3" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" dependencies = [ "either", ] @@ -836,11 +820,11 @@ dependencies = [ [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -860,17 +844,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -880,28 +864,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -919,6 +882,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -930,9 +902,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -984,20 +956,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "oorandom" @@ -1025,12 +999,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -1093,33 +1066,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quote" version = "1.0.10" @@ -1129,6 +1082,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1246,9 +1205,9 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1265,40 +1224,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1320,17 +1245,11 @@ dependencies = [ "semver", ] -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "same-file" @@ -1371,12 +1290,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "semver" version = "1.0.4" @@ -1385,9 +1298,9 @@ checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "serde" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1422,9 +1335,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1460,7 +1373,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1473,7 +1386,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1481,12 +1394,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1495,27 +1408,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[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.8.0" @@ -1547,9 +1445,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1557,7 +1455,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1620,8 +1518,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1653,18 +1550,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-width" version = "0.1.9" @@ -1728,7 +1613,7 @@ version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] @@ -1778,39 +1663,35 @@ checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1823,19 +1704,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1844,17 +1723,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1863,9 +1742,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1875,15 +1754,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1896,54 +1774,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1951,11 +1825,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1963,33 +1837,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1998,9 +1868,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" [[package]] name = "wast" @@ -2072,6 +1942,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/MIGRATING.md b/MIGRATING.md deleted file mode 100644 index e49f415d7..000000000 --- a/MIGRATING.md +++ /dev/null @@ -1,1327 +0,0 @@ -# Migrating Contracts - -This guide explains what is needed to upgrade contracts when migrating over -major releases of `cosmwasm`. Note that you can also view the -[complete CHANGELOG](./CHANGELOG.md) to understand the differences. - -## 0.15 -> 0.16 - -- Update CosmWasm dependencies in Cargo.toml (skip the ones you don't use): - - ``` - [dependencies] - cosmwasm-std = "0.16.0" - cosmwasm-storage = "0.16.0" - # ... - - [dev-dependencies] - cosmwasm-schema = "0.16.0" - cosmwasm-vm = "0.16.0" - # ... - ``` - -- The `attr` function now accepts arguments that implement `Into` rather - than `ToString`. This means that "stringly" types like `&str` are still - accepted, but others (like numbers or booleans) have to be explicitly - converted to strings; you can use the `to_string` method (from the - `std::string::ToString` trait) for that. - - ```diff - let steal_funds = true; - - attr("steal_funds", steal_funds), - + attr("steal_funds", steal_funds.to_string()), - ``` - - It also means that `&&str` is no longer accepted. - -- The `iterator` feature in `cosmwasm-std`, `cosmwasm-vm` and `cosmwasm-storage` - is now enabled by default. If you want to use it, you don't have to explicitly - enable it anymore. - - If you don't want to use it, you **have to** disable default features when - depending on `cosmwasm-std`. Example: - - ```diff - - cosmwasm-std = { version = "0.15.0" } - + cosmwasm-std = { version = "0.16.0", default-features = false } - ``` - -- The `Event::attr` setter has been renamed to `Event::add_attribute` - this is - for consistency with other types, like `Response`. - - ```diff - - let event = Event::new("ibc").attr("channel", "connect"); - + let event = Event::new("ibc").add_attribute("channel", "connect"); - ``` - -- `Response` can no longer be built using a struct literal. Please use - `Response::new` as well as relevant - [builder-style setters](https://github.com/CosmWasm/cosmwasm/blob/402e3281ff5bc1cd7b4b3e36c2bb9914f07eaaf6/packages/std/src/results/response.rs#L103-L167) - to set the data. - - This is a step toward better API stability. - - ```diff - #[entry_point] - pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> StdResult { - // ... - - let send = BankMsg::Send { - to_address: msg.payout.clone(), - amount: balance, - }; - let data_msg = format!("burnt {} keys", count).into_bytes(); - - - Ok(Response { - - messages: vec![SubMsg::new(send)], - - attributes: vec![attr("action", "burn"), attr("payout", msg.payout)], - - events: vec![], - - data: Some(data_msg.into()), - - }) - + Ok(Response::new() - + .add_message(send) - + .add_attribute("action", "burn") - + .add_attribute("payout", msg.payout) - + .set_data(data_msg)) - } - ``` - - ```diff - - Ok(Response { - - data: Some((old_size as u32).to_be_bytes().into()), - - ..Response::default() - - }) - + Ok(Response::new().set_data((old_size as u32).to_be_bytes())) - ``` - - ```diff - - let res = Response { - - messages: msgs, - - attributes: vec![attr("action", "reflect_subcall")], - - events: vec![], - - data: None, - - }; - - Ok(res) - + Ok(Response::new() - + .add_attribute("action", "reflect_subcall") - + .add_submessages(msgs)) - ``` - -- For IBC-enabled contracts only: constructing `IbcReceiveResponse` and - `IbcBasicResponse` follows the same principles now as `Response` above. - - ```diff - pub fn ibc_packet_receive( - deps: DepsMut, - env: Env, - msg: IbcPacketReceiveMsg, - ) -> StdResult { - // ... - - - Ok(IbcReceiveResponse { - - acknowledgement, - - messages: vec![], - - attributes: vec![], - - events: vec![Event::new("ibc").attr("packet", "receive")], - - }) - + Ok(IbcReceiveResponse::new() - + .set_ack(acknowledgement) - + .add_event(Event::new("ibc").add_attribute("packet", "receive"))) - } - ``` - -- For IBC-enabled contracts only: IBC entry points have different signatures. - Instead of accepting bare packets, channels and acknowledgements, all of those - are wrapped in a `Msg` type specific to the given entry point. Channels, - packets and acknowledgements have to be unpacked from those. - - ```diff - #[entry_point] - - pub fn ibc_channel_open(_deps: DepsMut, _env: Env, channel: IbcChannel) -> StdResult<()> { - + pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> StdResult<()> { - + let channel = msg.channel(); - - // do things - } - ``` - - ```diff - #[entry_point] - pub fn ibc_channel_connect( - deps: DepsMut, - env: Env, - - channel: IbcChannel, - + msg: IbcChannelConnectMsg, - ) -> StdResult { - + let channel = msg.channel(); - - // do things - } - ``` - - ```diff - #[entry_point] - pub fn ibc_channel_close( - deps: DepsMut, - env: Env, - - channel: IbcChannel, - + msg: IbcChannelCloseMsg, - ) -> StdResult { - + let channel = msg.channel(); - - // do things - } - ``` - - ```diff - #[entry_point] - pub fn ibc_packet_receive( - deps: DepsMut, - env: Env, - - packet: IbcPacket, - + msg: IbcPacketReceiveMsg, - ) -> StdResult { - + let packet = msg.packet; - - // do things - } - ``` - - ```diff - #[entry_point] - pub fn ibc_packet_receive( - deps: DepsMut, - env: Env, - - ack: IbcAcknowledgementWithPacket, - + msg: IbcPacketReceiveMsg, - ) -> StdResult { - // They are the same struct just a different name - let ack = msg; - - // do things - } - ``` - - ```diff - #[entry_point] - pub fn ibc_packet_timeout( - deps: DepsMut, - env: Env, - - packet: IbcPacket, - + msg: IbcPacketTimeoutMsg, - ) -> StdResult { - + let packet = msg.packet; - - // do things - } - ``` - -## 0.14 -> 0.15 - -- Update CosmWasm dependencies in Cargo.toml (skip the ones you don't use): - - ``` - [dependencies] - cosmwasm-std = "0.15.0" - cosmwasm-storage = "0.15.0" - # ... - - [dev-dependencies] - cosmwasm-schema = "0.15.0" - cosmwasm-vm = "0.15.0" - # ... - ``` - -- Combine `messages` and `submessages` on the `Response` object. The new format - uses `messages: Vec>`, so copy `submessages` content, and wrap old - messages using `SubMsg::new`. Here is how to change messages: - - ```rust - let send = BankMsg::Send { to_address, amount }; - - // before - let res = Response { - messages: vec![send.into()], - ..Response::default() - } - - // after - let res = Response { - messages: vec![SubMsg::new(send)], - ..Response::default() - } - - // alternate approach - let mut res = Response::new(); - res.add_message(send); - ``` - - And here is how to change submessages: - - ```rust - // before - let sub_msg = SubMsg { - id: INIT_CALLBACK_ID, - msg: msg.into(), - gas_limit: None, - reply_on: ReplyOn::Success, - }; - let res = Response { - submessages: vec![sub_msg], - ..Response::default() - }; - - // after - let msg = SubMsg::reply_on_success(msg, INIT_CALLBACK_ID); - let res = Response { - messages: vec![msg], - ..Response::default() - }; - - // alternate approach - let msg = SubMsg::reply_on_success(msg, INIT_CALLBACK_ID); - let mut res = Response::new(); - res.add_submessage(msg); - ``` - - Note that this means you can mix "messages" and "submessages" in any execution - order. You are no more restricted to doing "submessages" first. - -- Rename the `send` field to `funds` whenever constructing a `WasmMsg::Execute` - or `WasmMsg::Instantiate` value. - - ```diff - let exec = WasmMsg::Execute { - contract_addr: coin.address.into(), - msg: to_binary(&msg)?, - - send: vec![], - + funds: vec![], - }; - ``` - -- `Uint128` field can no longer be constructed using a struct literal. Call - `Uint128::new` (or `Uint128::zero`) instead. - - ```diff - - const TOKENS_PER_WEIGHT: Uint128 = Uint128(1_000); - - const MIN_BOND: Uint128 = Uint128(5_000); - + const TOKENS_PER_WEIGHT: Uint128 = Uint128::new(1_000); - + const MIN_BOND: Uint128 = Uint128::new(5_000); - ``` - - ```diff - - assert_eq!(escrow_balance, Uint128(0)); - + assert_eq!(escrow_balance, Uint128::zero()); - ``` - -- If constructing a `Response` using struct literal syntax, add the `events` - field. - - ```diff - Ok(Response { - messages: vec![], - attributes, - + events: vec![], - data: None, - }) - ``` - -- For IBC-enabled contracts only: You need to adapt to the new - `IbcAcknowledgementWithPacket` structure and use the embedded `data` field: - - ```rust - // before - pub fn ibc_packet_ack( - deps: DepsMut, - env: Env, - ack: IbcAcknowledgement, - ) -> StdResult { - let res: AcknowledgementMsg = from_slice(&ack.acknowledgement)?; - // ... - } - - // after - pub fn ibc_packet_ack( - deps: DepsMut, - env: Env, - ack: IbcAcknowledgementWithPacket, - ) -> StdResult { - let res: AcknowledgementMsg = from_slice(&ack.acknowledgement.data)?; - // ... - } - ``` - - You also need to update the constructors in test code. Below we show how to do - so both for JSON data as well as any custom binary format: - - ```rust - // before (JSON) - let ack = IbcAcknowledgement { - acknowledgement: to_binary(&AcknowledgementMsg::Ok(())).unwrap() - original_packet: packet, - }; - - // after (JSON) - let ack = IbcAcknowledgementWithPacket { - acknowledgement: IbcAcknowledgement::encode_json(&AcknowledgementMsg::Ok(())).unwrap(), - original_packet: packet, - }; - - // before (Custom binary data) - let acknowledgement = vec![12, 56, 78]; - let ack = IbcAcknowledgement { - acknowledgement: Binary(acknowledgement), - original_packet: packet, - }; - - // after (Custom binary data) - let acknowledgement = vec![12, 56, 78]; - let ack = IbcAcknowledgement { - acknowledgement: IbcAcknowledgement::new(acknowledgement), - original_packet: packet, - }; - ``` - -## 0.13 -> 0.14 - -- The minimum Rust supported version for 0.14 is 1.51.0. Verify your Rust - version is >= 1.51.0 with: `rustc --version` - -- Update CosmWasm and schemars dependencies in Cargo.toml (skip the ones you - don't use): - - ``` - [dependencies] - cosmwasm-std = "0.14.0" - cosmwasm-storage = "0.14.0" - schemars = "0.8.1" - # ... - - [dev-dependencies] - cosmwasm-schema = "0.14.0" - cosmwasm-vm = "0.14.0" - # ... - ``` - -- Rename the `init` entry point to `instantiate`. Also, rename `InitMsg` to - `InstantiateMsg`. - -- Rename the `handle` entry point to `execute`. Also, rename `HandleMsg` to - `ExecuteMsg`. - -- Rename `InitResponse`, `HandleResponse` and `MigrateResponse` to `Response`. - The old names are still supported (with a deprecation warning), and will be - removed in the next version. Also, you'll need to add the `submessages` field - to `Response`. - -- Remove `from_address` from `BankMsg::Send`, which is now automatically filled - with the contract address: - - ```rust - // before - ctx.add_message(BankMsg::Send { - from_address: env.contract.address, - to_address: to_addr, - amount: balance, - }); - - // after - ctx.add_message(BankMsg::Send { - to_address: to_addr, - amount: balance, - }); - ``` - -- Use the new entry point system. From `lib.rs` remove - - ```rust - #[cfg(target_arch = "wasm32")] - cosmwasm_std::create_entry_points!(contract); - - // or - - #[cfg(target_arch = "wasm32")] - cosmwasm_std::create_entry_points_with_migration!(contract); - ``` - - Then add the macro attribute `#[entry_point]` to your `contract.rs` as - follows: - - ```rust - use cosmwasm_std::{entry_point, … }; - - // … - - #[entry_point] - pub fn init( - _deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: InitMsg, - ) -> StdResult { - // … - } - - #[entry_point] - pub fn execute( - _deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: ExecuteMsg, - ) -> StdResult { - // … - } - - // only if you have migrate - #[entry_point] - pub fn migrate( - deps: DepsMut, - env: Env, - _info: MessageInfo, - msg: MigrateMsg, - ) -> StdResult { - // … - } - - #[entry_point] - pub fn query(_deps: Deps, _env: Env, _msg: QueryMsg) -> StdResult { - // … - } - ``` - -- Since `Response` contains a `data` field, converting `Context` into `Response` - always succeeds. - - ```rust - // before - pub fn init(deps: DepsMut, env: Env, info: MessageInfo, msg: InitMsg) -> Result { - // … - let mut ctx = Context::new(); - ctx.add_attribute("Let the", "hacking begin"); - Ok(ctx.try_into()?) - } - - // after - pub fn init(deps: DepsMut, env: Env, info: MessageInfo, msg: InitMsg) -> Result { - // … - let mut ctx = Context::new(); - ctx.add_attribute("Let the", "hacking begin"); - Ok(ctx.into()) - } - ``` - -- Remove the `info: MessageInfo` field from the `migrate` entry point: - - ```rust - // Before - pub fn migrate( - deps: DepsMut, - env: Env, - _info: MessageInfo, - msg: MigrateMsg, - ) -> StdResult { - // ... - } - - // After - pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> StdResult { - // ... - } - ``` - - `MessageInfo::funds` was always empty since [MsgMigrateContract] does not have - a funds field. `MessageInfo::sender` should not be needed for authentication - because the chain checks permissions before calling `migrate`. If the sender's - address is needed for anything else, this should be expressed as part of the - migrate message. - - [msgmigratecontract]: - https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L86-L96 - -- Add mutating helper methods to `Response` that can be used instead of creating - a `Context` that is later converted to a response: - - ```rust - // before - pub fn handle_impl(deps: DepsMut, env: Env, info: MessageInfo) -> Result { - // ... - - // release counter_offer to creator - let mut ctx = Context::new(); - ctx.add_message(BankMsg::Send { - to_address: state.creator, - amount: state.counter_offer, - }); - - // release collateral to sender - ctx.add_message(BankMsg::Send { - to_address: state.owner, - amount: state.collateral, - }); - - // .. - - ctx.add_attribute("action", "execute"); - Ok(ctx.into()) - } - - - // after - pub fn execute_impl(deps: DepsMut, env: Env, info: MessageInfo) -> Result { - // ... - - // release counter_offer to creator - let mut resp = Response::new(); - resp.add_message(BankMsg::Send { - to_address: state.creator, - amount: state.counter_offer, - }); - - // release collateral to sender - resp.add_message(BankMsg::Send { - to_address: state.owner, - amount: state.collateral, - }); - - // .. - - resp.add_attribute("action", "execute"); - Ok(resp) - } - ``` - -- Use type `Pair` instead of `KV` - - ```rust - // before - use cosmwasm_std::KV; - - // after - use cosmwasm_std::Pair; - ``` - -- If necessary, add a wildcard arm to the `match` of now non-exhaustive message - types `BankMsg`, `BankQuery`, `WasmMsg` and `WasmQuery`. - -- `HumanAddr` has been deprecated in favour of simply `String`. It never added - any significant safety bonus over `String` and was just a marker type. The new - type `Addr` was created to hold validated addresses. Those can be created via - `Addr::unchecked`, `Api::addr_validate`, `Api::addr_humanize` and JSON - deserialization. In order to maintain type safety, deserialization into `Addr` - must only be done from trusted sources like a contract's state or a query - response. User inputs must be deserialized into `String`. This new `Addr` type - makes it easy to use human readable addresses in state: - - With pre-validated `Addr` from `MessageInfo`: - - ```rust - // before - pub struct State { - pub owner: CanonicalAddr, - } - - let state = State { - owner: deps.api.canonical_address(&info.sender /* of type HumanAddr */)?, - }; - - - // after - pub struct State { - pub owner: Addr, - } - let state = State { - owner: info.sender.clone() /* of type Addr */, - }; - ``` - - With user input in `msg`: - - ```rust - // before - pub struct State { - pub verifier: CanonicalAddr, - pub beneficiary: CanonicalAddr, - pub funder: CanonicalAddr, - } - - deps.storage.set( - CONFIG_KEY, - &to_vec(&State { - verifier: deps.api.canonical_address(&msg.verifier /* of type HumanAddr */)?, - beneficiary: deps.api.canonical_address(&msg.beneficiary /* of type HumanAddr */)?, - funder: deps.api.canonical_address(&info.sender /* of type HumanAddr */)?, - })?, - ); - - // after - pub struct State { - pub verifier: Addr, - pub beneficiary: Addr, - pub funder: Addr, - } - - deps.storage.set( - CONFIG_KEY, - &to_vec(&State { - verifier: deps.api.addr_validate(&msg.verifier /* of type String */)?, - beneficiary: deps.api.addr_validate(&msg.beneficiary /* of type String */)?, - funder: info.sender /* of type Addr */, - })?, - ); - ``` - - The existing `CanonicalAddr` remains unchanged and can be used in cases in - which a compact binary representation is desired. For JSON state this does not - save much data (e.g. the bech32 address - cosmos1pfq05em6sfkls66ut4m2257p7qwlk448h8mysz takes 45 bytes as direct ASCII - and 28 bytes when its canonical representation is base64 encoded). For fixed - length database keys `CanonicalAddr` remains handy though. - -- Replace `StakingMsg::Withdraw` with `DistributionMsg::SetWithdrawAddress` and - `DistributionMsg::WithdrawDelegatorReward`. `StakingMsg::Withdraw` was a - shorthand for the two distribution messages. However, it was unintuitive - because it did not set the address for one withdraw only but for all following - withdrawls. Since withdrawls are [triggered by different - events][distribution docs] such as validators changing their commission rate, - an address that was set for a one-time withdrawl would be used for future - withdrawls not considered by the contract author. - - If the contract never set a withdraw address other than the contract itself - (`env.contract.address`), you can simply replace `StakingMsg::Withdraw` with - `DistributionMsg::WithdrawDelegatorReward`. It is then never changed from the - default. Otherwise you need to carefully track what the current withdraw - address is. A one-time change can be implemented by emitted 3 messages: - - 1. `SetWithdrawAddress { address: recipient }` to temporarily change the - recipient - 2. `WithdrawDelegatorReward { validator }` to do a manual withdrawl from the - given validator - 3. `SetWithdrawAddress { address: env.contract.address.into() }` to change it - back for all future withdrawls - - [distribution docs]: https://docs.cosmos.network/v0.42/modules/distribution/ - -- The block time in `env.block.time` is now a `Timestamp` which stores - nanosecond precision. `env.block.time_nanos` was removed. If you need the - compnents as before, use - ```rust - let seconds = env.block.time.nanos() / 1_000_000_000; - let nsecs = env.block.time.nanos() % 1_000_000_000; - ``` - -## 0.12 -> 0.13 - -- The minimum Rust supported version for 0.13 is 1.47.0. Verify your Rust - version is >= 1.47.0 with: `rustc --version` - -- Update CosmWasm dependencies in Cargo.toml (skip the ones you don't use): - - ``` - [dependencies] - cosmwasm-std = "0.13.0" - cosmwasm-storage = "0.13.0" - # ... - - [dev-dependencies] - cosmwasm-schema = "0.13.0" - cosmwasm-vm = "0.13.0" - # ... - ``` - -## 0.11 -> 0.12 - -- Update CosmWasm dependencies in Cargo.toml (skip the ones you don't use): - - ``` - [dependencies] - cosmwasm-std = "0.12.0" - cosmwasm-storage = "0.12.0" - # ... - - [dev-dependencies] - cosmwasm-schema = "0.12.0" - cosmwasm-vm = "0.12.0" - # ... - ``` - -- In your contract's `.cargo/config` remove `--features backtraces`, which is - now available in Rust nightly only: - - ```diff - @@ -1,6 +1,6 @@ - [alias] - wasm = "build --release --target wasm32-unknown-unknown" - wasm-debug = "build --target wasm32-unknown-unknown" - -unit-test = "test --lib --features backtraces" - +unit-test = "test --lib" - integration-test = "test --test integration" - schema = "run --example schema" - ``` - - In order to use backtraces for debugging, run - `RUST_BACKTRACE=1 cargo +nightly unit-test --features backtraces`. - -- Rename the type `Extern` to `Deps`, and radically simplify the - `init`/`handle`/`migrate`/`query` entrypoints. Rather than - `&mut Extern`, use `DepsMut`. And instead of `&Extern`, use - `Deps`. If you ever pass eg. `foo(api: A)` around, you must now use - dynamic trait pointers: `foo(api: &dyn Api)`. Here is the quick search-replace - guide on how to fix `contract.rs`: - - _In production (non-test) code:_ - - - `` => `` - - `&mut Extern` => `DepsMut` - - `&Extern` => `Deps` - - `&mut deps.storage` => `deps.storage` where passing into `state.rs` helpers - - `&deps.storage` => `deps.storage` where passing into `state.rs` helpers - - On the top, remove `use cosmwasm_std::{Api, Extern, Querier, Storage}`. Add - `use cosmwasm_std::{Deps, DepsMut}`. - - _In test code only:_ - - - `&mut deps,` => `deps.as_mut(),` - - `&deps,` => `deps.as_ref(),` - - You may have to add `use cosmwasm_std::{Storage}` if the compile complains - about the trait - - _If you use cosmwasm-storage, in `state.rs`:_ - - - `` => `` - - `` => `` - - ` `<` - - `&mut S` => `&mut dyn Storage` - - `&S` => `&dyn Storage` - -- If you have any references to `ReadonlyStorage` left after the above, please - replace them with `Storage` - -## 0.10 -> 0.11 - -- Update CosmWasm dependencies in Cargo.toml (skip the ones you don't use): - - ``` - [dependencies] - cosmwasm-std = "0.11.0" - cosmwasm-storage = "0.11.0" - # ... - - [dev-dependencies] - cosmwasm-schema = "0.11.0" - cosmwasm-vm = "0.11.0" - # ... - ``` - -- Contracts now support any custom error type `E: ToString + From`. - Previously this has been `StdError`, which you can still use. However, you can - now create a much more structured error experience for your unit tests that - handels exactly the error cases of your contract. In order to get a convenient - implementation for `ToString` and `From`, we use the crate - [thiserror](https://crates.io/crates/thiserror), which needs to be added to - the contracts dependencies in `Cargo.toml`. To create the custom error, create - an error module `src/errors.rs` as follows: - - ```rust - use cosmwasm_std::{CanonicalAddr, StdError}; - use thiserror::Error; - - // thiserror implements Display and ToString if you - // set the `#[error("…")]` attribute for all cases - #[derive(Error, Debug)] - pub enum MyCustomError { - #[error("{0}")] - // let thiserror implement From for you - Std(#[from] StdError), - // this is whatever we want - #[error("Permission denied: the sender is not the current owner")] - NotCurrentOwner { - expected: CanonicalAddr, - actual: CanonicalAddr, - }, - #[error("Messages empty. Must reflect at least one message")] - MessagesEmpty, - } - ``` - - Then add `mod errors;` to `src/lib.rs` and `use crate::errors::MyCustomError;` - to `src/contract.rs`. Now adapt the return types as follows: - - - `fn init`: `Result`, - - `fn migrate` (if you have it): `Result`, - - `fn handle`: `Result`, - - `fn query`: `Result`. - - If one of your funtions does not use the custom error, you can continue to use - `StdError` as before. I.e. you can have `handle` returning - `Result` and `query` returning - `StdResult`. - - You can have a top-hevel `init`/`migrate`/`handle`/`query` that returns a - custom error but some of its implementations only return errors from the - standard library (`StdResult` aka. - `Result`). Then use `Ok(std_result?)` to convert - between the result types. E.g. - - ```rust - pub fn handle( - deps: &mut Extern, - env: Env, - msg: HandleMsg, - ) -> Result { - match msg { - // conversion to Result - HandleMsg::Bond {} => Ok(bond(deps, env)?), - // this already returns Result - HandleMsg::_BondAllTokens {} => _bond_all_tokens(deps, env), - } - } - ``` - - or - - ```rust - pub fn init( - deps: &mut Extern, - env: Env, - msg: InitMsg, - ) -> Result { - // … - - let mut ctx = Context::new(); - ctx.add_attribute("Let the", "hacking begin"); - Ok(ctx.try_into()?) - } - ``` - - Once you got familiar with the concept, you can create different error types - for each of the contract's functions. - - You can also try a different error library than - [thiserror](https://crates.io/crates/thiserror). The - [staking development contract](https://github.com/CosmWasm/cosmwasm/tree/main/contracts/staking) - shows how this would look like using [snafu](https://crates.io/crates/snafu). - -- Change order of arguments such that `storage` is always first followed by - namespace in `Bucket::new`, `Bucket::multilevel`, `ReadonlyBucket::new`, - `ReadonlyBucket::multilevel`, `PrefixedStorage::new`, - `PrefixedStorage::multilevel`, `ReadonlyPrefixedStorage::new`, - `ReadonlyPrefixedStorage::multilevel`, `bucket`, `bucket_read`, `prefixed` and - `prefixed_read`. - - ```rust - // before - let mut bucket = bucket::<_, Data>(b"data", &mut store); - - // after - let mut bucket = bucket::<_, Data>(&mut store, b"data"); - ``` - -- Rename `InitResponse::log`, `MigrateResponse::log` and `HandleResponse::log` - to `InitResponse::attributes`, `MigrateResponse::attributes` and - `HandleResponse::attributes`. Replace calls to `log` with `attr`: - - ```rust - // before - Ok(HandleResponse { - log: vec![log("action", "change_owner"), log("owner", owner)], - ..HandleResponse::default() - }) - - // after - Ok(HandleResponse { - attributes: vec![attr("action", "change_owner"), attr("owner", owner)], - ..HandleResponse::default() - }) - ``` - -- Rename `Context::add_log` to `Context::add_attribute`: - - ```rust - // before - let mut ctx = Context::new(); - ctx.add_log("action", "release"); - ctx.add_log("destination", &to_addr); - - // after - let mut ctx = Context::new(); - ctx.add_attribute("action", "release"); - ctx.add_attribute("destination", &to_addr); - ``` - -- Add result type to `Bucket::update` and `Singleton::update`: - - ```rust - // before - bucket.update(b"maria", |mayd: Option| { - let mut d = mayd.ok_or(StdError::not_found("Data"))?; - old_age = d.age; - d.age += 1; - Ok(d) - }) - - // after - bucket.update(b"maria", |mayd: Option| -> StdResult<_> { - let mut d = mayd.ok_or(StdError::not_found("Data"))?; - old_age = d.age; - d.age += 1; - Ok(d) - }) - ``` - -- Remove all `canonical_length` arguments from mock APIs in tests: - - ```rust - // before - let mut deps = mock_dependencies(20, &[]); - let mut deps = mock_dependencies(20, &coins(123456, "gold")); - let deps = mock_dependencies_with_balances(20, &[(&rich_addr, &rich_balance)]); - let api = MockApi::new(20); - - // after - let mut deps = mock_dependencies(&[]); - let mut deps = mock_dependencies(&coins(123456, "gold")); - let deps = mock_dependencies_with_balances(&[(&rich_addr, &rich_balance)]); - let api = MockApi::default(); - ``` - -- Add `MessageInfo` as separate arg after `Env` for `init`, `handle`, `migrate`. - Add `Env` arg to `query`. Use `info.sender` instead of `env.message.sender` - and `info.sent_funds` rather than `env.message.sent_funds`. Just changing the - function signatures of the 3-4 export functions should be enough, then the - compiler will warn you anywhere you use `env.message` - - ```rust - // before - pub fn init( - deps: &mut Extern, - env: Env, - msg: InitMsg, - ) { - deps.storage.set( - CONFIG_KEY, - &to_vec(&State { - verifier: deps.api.canonical_address(&msg.verifier)?, - beneficiary: deps.api.canonical_address(&msg.beneficiary)?, - funder: deps.api.canonical_address(&env.message.sender)?, - })?, - ); - } - - // after - pub fn init( - deps: &mut Extern, - _env: Env, - info: MessageInfo, - msg: InitMsg, - ) { - deps.storage.set( - CONFIG_KEY, - &to_vec(&State { - verifier: deps.api.canonical_address(&msg.verifier)?, - beneficiary: deps.api.canonical_address(&msg.beneficiary)?, - funder: deps.api.canonical_address(&info.sender)?, - })?, - ); - } - ``` - -- Test code now has `mock_info` which takes the same args `mock_env` used to. - You can just pass `mock_env()` directly into the function calls unless you - need to change height/time. -- One more object to pass in for both unit and integration tests. To do this - quickly, I just highlight all copies of `env` and replace them with `info` - (using Ctrl+D in VSCode or Alt+J in IntelliJ). Then I select all `deps, info` - sections and replace that with `deps, mock_env(), info`. This fixes up all - `init` and `handle` calls, then just add an extra `mock_env()` to the query - calls. - - ```rust - // before: unit test - let env = mock_env(creator.as_str(), &[]); - let res = init(&mut deps, env, msg).unwrap(); - - let query_response = query(&deps, QueryMsg::Verifier {}).unwrap(); - - // after: unit test - let info = mock_info(creator.as_str(), &[]); - let res = init(&mut deps, mock_env(), info, msg).unwrap(); - - let query_response = query(&deps, mock_env(), QueryMsg::Verifier {}).unwrap(); - - // before: integration test - let env = mock_env("creator", &coins(1000, "earth")); - let res: InitResponse = init(&mut deps, env, msg).unwrap(); - - let query_response = query(&mut deps, QueryMsg::Verifier {}).unwrap(); - - // after: integration test - let info = mock_info("creator", &coins(1000, "earth")); - let res: InitResponse = init(&mut deps, mock_env(), info, msg).unwrap(); - - let query_response = query(&mut deps, mock_env(), QueryMsg::Verifier {}).unwrap(); - ``` - -## 0.9 -> 0.10 - -- Update CosmWasm dependencies in Cargo.toml (skip the ones you don't use): - - ``` - [dependencies] - cosmwasm-std = "0.10.0" - cosmwasm-storage = "0.10.0" - # ... - - [dev-dependencies] - cosmwasm-schema = "0.10.0" - cosmwasm-vm = "0.10.0" - # ... - ``` - -Integration tests: - -- Calls to `Api::human_address` and `Api::canonical_address` now return a pair - of result and gas information. Change - - ```rust - // before - verifier: deps.api.canonical_address(&verifier).unwrap(), - - // after - verifier: deps.api.canonical_address(&verifier).0.unwrap(), - ``` - - The same applies for all calls of `Querier` and `Storage`. - -All Tests: - -All usages of `mock_env` will have to remove the first argument (no need of -API). - -```rust -// before -let env = mock_env(&deps.api, "creator", &coins(1000, "earth")); - -// after -let env = mock_env("creator", &coins(1000, "earth")); -``` - -Contracts: - -- All code that uses `message.sender` or `contract.address` should deal with - `HumanAddr` not `CanonicalAddr`. Many times this means you can remove a - conversion step. - -## 0.8 -> 0.9 - -- Update CosmWasm dependencies in Cargo.toml (skip the ones you don't use): - - ``` - [dependencies] - cosmwasm-std = "0.9.0" - cosmwasm-storage = "0.9.0" - # ... - - [dev-dependencies] - cosmwasm-schema = "0.9.0" - cosmwasm-vm = "0.9.0" - # ... - ``` - -`lib.rs`: - -- The C export boilerplate can now be reduced to the following code (see e.g. in - [hackatom/src/lib.rs](https://github.com/CosmWasm/cosmwasm/blob/0a5b3e8121/contracts/hackatom/src/lib.rs)): - - ```rust - mod contract; // contains init, handle, query - // maybe additional modules here - - #[cfg(target_arch = "wasm32")] - cosmwasm_std::create_entry_points!(contract); - ``` - -Contract code and uni tests: - -- `cosmwasm_storage::get_with_prefix`, `cosmwasm_storage::set_with_prefix`, - `cosmwasm_storage::RepLog::commit`, `cosmwasm_std::ReadonlyStorage::get`, - `cosmwasm_std::ReadonlyStorage::range`, `cosmwasm_std::Storage::set` and - `cosmwasm_std::Storage::remove` now return the value directly that was wrapped - in a result before. -- Error creator functions are now in type itself, e.g. - `StdError::invalid_base64` instead of `invalid_base64`. The free functions are - deprecated and will be removed before 1.0. -- Remove `InitResponse.data` in `init`. Before 0.9 this was not stored to chain - but ignored. -- Use `cosmwasm_storage::transactional` instead of the removed - `cosmwasm_storage::transactional_deps`. -- Replace `cosmwasm_std::Never` with `cosmwasm_std::Empty`. - -Integration tests: - -- Replace `cosmwasm_vm::ReadonlyStorage` with `cosmwasm_vm::Storage`, which now - contains all backend storage methods. -- Storage getters (and iterators) now return a result of - `(Option>, u64)`, where the first component is the element and the - second one is the gas cost. Thus in a few places `.0` must be added to access - the element. - -## 0.7.2 -> 0.8 - -### Update wasm code - -`Cargo.toml` dependencies: - -- Update to `schemars = "0.7"` -- Replace `cosmwasm = "0.7"` with `cosmwasm-std = "0.8"` -- Replace `cosmwasm-vm = "0.7"` with `cosmwasm-vm = "0.8"` -- Replace `cw-storage = "0.2"` with `cosmwasm-storage = "0.8"` -- Remove explicit `snafu` dependency. `cosmwasm_std` still uses it internally - but doesn't expose snafu specifics anymore. See more details on errors below. - -(Note: until release of `0.8`, you need to use git references for all -`cosmwasm_*` packages) - -`Cargo.toml` features: - -- Replace `"cosmwasm/backtraces"` with `"cosmwasm-std/backtraces"` - -Imports: - -- Replace all `use cosmwasm::X::Y` with `use cosmwasm_std::Y`, except for mock -- Replace all `use cosmwasm::mock::Y` with `use cosmwasm_std::testing::Y`. This - should only be used in test code. -- Replace `cw_storage:X` with `cosmwasm_storage::X` -- Replace `cosmwasm_std::Response` with `cosmwasm_std::HandleResponse` and - `cosmwasm_std::InitResponse` (different type for each call) - -`src/lib.rs`: - -This has been re-written, but is generic boilerplate and should be (almost) the -same in all contracts: - -- copy the new version from - [`contracts/queue`](https://github.com/CosmWasm/cosmwasm/blob/main/contracts/queue/src/lib.rs) -- Add `pub mod XYZ` directives for any modules you use besides `contract` - -Contract Code: - -- Add query to extern: - - Before: `my_func(deps: &Extern, ...` - - After: `my_func(deps: &Extern, ...` - - Remember to add `use cosmwasm_std::Querier;` -- `query` now returns `StdResult` instead of `Result>` - - You can also replace `to_vec(...)` with `to_binary(...)` -- No `.context(...)` is required after `from_slice` and `to_vec`, they return - proper `cosmwasm_std::Error` variants on errors. -- `env.message.signer` becomes `env.message.sender`. -- If you used `env.contract.balance`, you must now use the querier. The - following code block should work: - - ```rust - // before (in env) - let foo = env.contract.balance; - - // after (query my balance) - let contract_addr = deps.api.human_address(&env.contract.address)?; - let balance = deps.querier.query_all_balances(&contract_addr)?; - let foo = balance.amount; - ``` - -- Update the `CosmosMsg` enums used: - - - `CosmosMsg::Send{}` => `CosmosMsg::Bank(BankMsg::Send{})` - - `CosmosMsg::Opaque{ data }` => `CosmosMsg::Native{ msg }` - - `CosmosMsg::Contract` => `CosmosMsg::Wasm(WasmMsg::Execute{})` - -- Complete overhaul of `cosmwasm::Error` into `cosmwasm_std::StdError`: - - Auto generated snafu error constructor structs like `NotFound`/`ParseErr`/… - have been privatized in favour of error generation helpers like - `not_found`/`parse_err`/… - - All error generator functions now return errors instead of results, such - that e.g. `return unauthorized();` becomes `return Err(unauthorized());` - - Error cases don't contain `source` fields anymore. Instead source errors are - converted to standard types like `String`. For this reason, both - `snafu::ResultExt` and `snafu::OptionExt` cannot be used anymore. An error - wrapper now looks like `.map_err(invalid_base64)` and an `Option::None` to - error mapping looks like `.ok_or_else(|| not_found("State"))`. - - Backtraces became optional. Use `RUST_BACKTRACE=1` to enable them for unit - tests. - - `Utf8Err`/`Utf8StringErr` merged into `StdError::InvalidUtf8` - - `Base64Err` renamed into `StdError::InvalidBase64` - - `ContractErr`/`DynContractErr` merged into `StdError::GenericErr`, thus both - `contract_err` and `dyn_contract_err` must be replaced with `generic_err`. - - The unused `ValidationErr` was removed - -At this point `cargo wasm` should pass. - -### Update test code - -Both: - -- Update all imports from `cosmwasm::mock::*` to `cosmwasm_std::testing::*` -- Use `from_binary` not `from_slice` on all query responses (update imports) - - `from_slice(res.as_slice())` -> `from_binary(&res)` -- Replace `coin("123", "FOO")` with `coins(123, "FOO")`. We renamed it to coins - to be more explicit that it returns `Vec`, and now accept a `u128` as - the first argument for better type-safety. `coin` is now an alias to - `Coin::new` and returns one `Coin`. -- Remove the 4th argument (contract balance) from all calls to `mock_env`, this - is no longer stored in the environment. -- `dependencies` was renamed to `mock_dependencies`. `mock_dependencies` and - `mock_instance` take a 2nd argument to set the contract balance (visible for - the querier). If you need to set more balances, use `mock_XX_with_balances`. - The follow code block explains: - - ```rust - // before: balance as last arg in mock_env - let mut deps = dependencies(20); - let env = mock_env(&deps.api, "creator", &coins(15, "earth"), &coins(1015, "earth")); - - // after: balance as last arg in mock_dependencies - let mut deps = mock_dependencies(20, &coins(1015, "earth")); - let env = mock_env(&deps.api, "creator", &coins(15, "earth")); - ``` - -Unit Tests: - -- Replace `dependencies` with `mock_dependencies` - -Integration Tests: - -- We no longer check errors as strings but have rich types: - - Before: - `match err { ContractResult::Err(msg) => assert_eq!(msg, "Unauthorized"), ... }` - - After: `match err { Err(StdError::Unauthorized{ .. }) => {}, ... }` -- Remove all imports / use of `ContractResult` -- You must specify `CosmosMsg::Native` type when calling - `cosmwasm_vm::testing::{handle, init}`. You will want to - `use cosmwasm_std::{HandleResult, InitResult}` or - `use cosmwasm_std::{HandleResponse, InitResponse}`. If you don't use custom - native types, simply update calls as follows: - - `let res = init(...)` => `let res: InitResult = init(...)` - - `let res = init(...).unwrap()` => - `let res: InitResponse = init(...).unwrap()` - - `let res = handle(...)` => `let res: HandleResult = handle(...)` - - `let res = handle(...).unwrap()` => - `let res: HandleResponse = handle(...).unwrap()` - -### Update schema code - -All helper functions have been moved into a new `cosmwasm-schema` package. - -- Add `cosmwasm-schema = "0.8"` to `[dev-dependencies]` in `Cargo.toml` -- Remove `serde_json` `[dev-dependency]` if there, as cosmwasm-schema will - handle JSON output internally. -- Update `examples/schema.rs` to look - [more like queue](https://github.com/CosmWasm/cosmwasm/blob/main/contracts/queue/examples/schema.rs), - but replacing all the imports and type names with those you currently have. -- Regenerate schemas with `cargo schema` - -### Polishing - -After so many changes, remember to let the linters do their jobs. - -- `cargo fmt` -- `cargo clippy` diff --git a/contracts/README.md b/contracts/README.md index f868e0268..4184d4efb 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -17,47 +17,42 @@ reason, use the following commands: docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_burner",target=/code/contracts/burner/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/burner + cosmwasm/rust-optimizer:0.11.0 ./contracts/burner docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_burner",target=/code/contracts/crypto-verify/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/crypto-verify - -docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_floaty",target=/code/contracts/floaty/target \ - --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/floaty + cosmwasm/rust-optimizer:0.11.0 ./contracts/crypto-verify docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_hackatom",target=/code/contracts/hackatom/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/hackatom + cosmwasm/rust-optimizer:0.11.0 ./contracts/hackatom docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_ibc_reflect",target=/code/contracts/ibc-reflect/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/ibc-reflect + cosmwasm/rust-optimizer:0.11.0 ./contracts/ibc-reflect docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_ibc_reflect_send",target=/code/contracts/ibc-reflect-send/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/ibc-reflect-send + cosmwasm/rust-optimizer:0.11.0 ./contracts/ibc-reflect-send docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_queue",target=/code/contracts/queue/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/queue + cosmwasm/rust-optimizer:0.11.0 ./contracts/queue docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_reflect",target=/code/contracts/reflect/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/reflect + cosmwasm/rust-optimizer:0.11.0 ./contracts/reflect docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_staking",target=/code/contracts/staking/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/staking + cosmwasm/rust-optimizer:0.11.0 ./contracts/staking ``` ## Entry points diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index c2623b918..a4be9efa8 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -42,10 +31,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -55,12 +44,32 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" +dependencies = [ + "funty", + "radium", + "wyz", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -70,12 +79,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bumpalo" -version = "3.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" - [[package]] name = "burner" version = "0.0.0" @@ -87,27 +90,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bytecheck" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" -dependencies = [ - "bytecheck_derive", - "ptr_meta", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "byteorder" version = "1.4.3" @@ -120,6 +102,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -134,9 +122,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -176,7 +164,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -188,7 +175,6 @@ dependencies = [ "cosmwasm-crypto", "cosmwasm-std", "hex", - "loupe", "parity-wasm", "schemars", "serde", @@ -210,35 +196,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -246,21 +234,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -270,11 +261,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -283,7 +274,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -293,7 +284,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -304,7 +295,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -317,33 +308,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -364,9 +337,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -374,9 +347,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -388,9 +361,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -399,9 +372,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -444,16 +417,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -481,16 +453,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -524,11 +498,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -538,6 +513,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -554,7 +535,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -565,16 +546,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -589,12 +570,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -603,9 +584,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -624,9 +602,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -655,22 +633,13 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -690,17 +659,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -710,28 +679,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -749,6 +697,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -760,9 +717,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -795,20 +752,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "opaque-debug" @@ -830,12 +789,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -870,33 +828,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quote" version = "1.0.10" @@ -906,6 +844,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1002,9 +946,9 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1021,40 +965,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1067,17 +977,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "schemars" @@ -1109,17 +1013,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "serde" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1144,9 +1042,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1182,7 +1080,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1195,7 +1093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1203,12 +1101,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1217,27 +1115,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -1263,9 +1146,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1273,7 +1156,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1307,8 +1190,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1340,18 +1222,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1386,95 +1256,37 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1487,19 +1299,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1508,17 +1318,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1527,9 +1337,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1539,15 +1349,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1560,54 +1369,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1615,11 +1420,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1627,33 +1432,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1662,9 +1463,27 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wast" +version = "38.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +dependencies = [ + "wast", +] [[package]] name = "which" @@ -1699,6 +1518,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/contracts/burner/src/contract.rs b/contracts/burner/src/contract.rs index b80594cf5..93a15620b 100644 --- a/contracts/burner/src/contract.rs +++ b/contracts/burner/src/contract.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{ - entry_point, BankMsg, DepsMut, Env, MessageInfo, Order, Response, StdError, StdResult, + attr, entry_point, BankMsg, DepsMut, Env, MessageInfo, Order, Response, StdError, StdResult, }; use crate::msg::{InstantiateMsg, MigrateMsg}; @@ -38,18 +38,19 @@ pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> StdResult let data_msg = format!("burnt {} keys", count).into_bytes(); - Ok(Response::new() - .add_message(send) - .add_attribute("action", "burn") - .add_attribute("payout", msg.payout) - .set_data(data_msg)) + Ok(Response { + submessages: vec![], + messages: vec![send.into()], + attributes: vec![attr("action", "burn"), attr("payout", msg.payout)], + data: Some(data_msg.into()), + }) } #[cfg(test)] mod tests { use super::*; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{coins, StdError, Storage, SubMsg}; + use cosmwasm_std::{coins, StdError, Storage}; #[test] fn instantiate_fails() { @@ -89,10 +90,11 @@ mod tests { let msg = res.messages.get(0).expect("no message"); assert_eq!( msg, - &SubMsg::new(BankMsg::Send { + &BankMsg::Send { to_address: payout, amount: coins(123456, "gold"), - }) + } + .into(), ); // check there is no data in storage diff --git a/contracts/burner/tests/integration.rs b/contracts/burner/tests/integration.rs index 8f30c2cca..fdd437e07 100644 --- a/contracts/burner/tests/integration.rs +++ b/contracts/burner/tests/integration.rs @@ -17,7 +17,7 @@ //! }); //! 4. Anywhere you see query(&deps, ...) you must replace it with query(&mut deps, ...) -use cosmwasm_std::{coins, BankMsg, ContractResult, Order, Response, SubMsg}; +use cosmwasm_std::{coins, BankMsg, ContractResult, Order, Response}; use cosmwasm_vm::testing::{instantiate, migrate, mock_env, mock_info, mock_instance}; use burner::msg::{InstantiateMsg, MigrateMsg}; @@ -70,10 +70,11 @@ fn migrate_cleans_up_data() { let msg = res.messages.get(0).expect("no message"); assert_eq!( msg, - &SubMsg::new(BankMsg::Send { + &BankMsg::Send { to_address: payout, amount: coins(123456, "gold"), - }), + } + .into(), ); // check there is no data in storage diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index faf2d84c6..a21e3269f 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -42,10 +31,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -55,12 +44,32 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" +dependencies = [ + "funty", + "radium", + "wyz", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -77,33 +86,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" -[[package]] -name = "bumpalo" -version = "3.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" - -[[package]] -name = "bytecheck" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" -dependencies = [ - "bytecheck_derive", - "ptr_meta", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "byteorder" version = "1.4.3" @@ -122,6 +104,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -136,9 +124,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -178,7 +166,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -198,7 +185,6 @@ dependencies = [ "cosmwasm-crypto", "cosmwasm-std", "hex", - "loupe", "parity-wasm", "schemars", "serde", @@ -220,35 +206,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -256,21 +244,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -280,11 +271,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -293,7 +284,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -303,7 +294,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -314,7 +305,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -327,33 +318,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -391,9 +364,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -401,9 +374,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -415,9 +388,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -426,9 +399,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -471,16 +444,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -508,16 +480,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -551,11 +525,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -565,6 +540,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -581,7 +562,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -592,16 +573,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -616,12 +597,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -630,9 +611,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -657,9 +635,9 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -688,22 +666,13 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -729,17 +698,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -749,28 +718,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -788,6 +736,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -799,9 +756,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -834,20 +791,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "opaque-debug" @@ -869,12 +828,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -909,33 +867,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quote" version = "1.0.10" @@ -945,6 +883,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1041,9 +985,9 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1060,40 +1004,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rlp" version = "0.5.1" @@ -1122,17 +1032,11 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "schemars" @@ -1164,17 +1068,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "serde" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1199,9 +1097,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1237,7 +1135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1250,7 +1148,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1270,12 +1168,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1284,27 +1182,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -1330,9 +1213,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1340,7 +1223,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1374,8 +1257,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1407,18 +1289,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1453,95 +1323,37 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1554,19 +1366,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1575,17 +1385,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1594,9 +1404,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1606,15 +1416,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1627,54 +1436,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1682,11 +1487,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1694,33 +1499,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1729,9 +1530,27 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wast" +version = "38.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +dependencies = [ + "wast", +] [[package]] name = "which" @@ -1766,6 +1585,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/contracts/crypto-verify/src/contract.rs b/contracts/crypto-verify/src/contract.rs index ef5f86bcc..3a37d0281 100644 --- a/contracts/crypto-verify/src/contract.rs +++ b/contracts/crypto-verify/src/contract.rs @@ -425,9 +425,9 @@ mod tests { let chain_id = 4; // Rinkeby, see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids let from = "0x0a65766695a712af41b5cfecaad217b1a11cb22a"; let to = "0xe137f5264b6b528244e1643a2d570b37660b7f14"; - let gas_limit = Uint128::new(0x226c8); - let gas_price = Uint128::new(0x3b9aca00); - let value = Uint128::new(0x53177c); + let gas_limit = Uint128(0x226c8); + let gas_price = Uint128(0x3b9aca00); + let value = Uint128(0x53177c); let data = hex!("536561726368207478207465737420302e36353930383639313733393634333335"); let r = hex!("b9299dab50b3cddcaecd64b29bfbd5cd30fac1a1adea1b359a13c4e5171492a6"); let s = hex!("573059c66d894684488f92e7ce1f91b158ca57b0235485625b576a3b98c480ac"); diff --git a/contracts/crypto-verify/src/ethereum.rs b/contracts/crypto-verify/src/ethereum.rs index 5ee78ea57..242b6dbdb 100644 --- a/contracts/crypto-verify/src/ethereum.rs +++ b/contracts/crypto-verify/src/ethereum.rs @@ -167,7 +167,7 @@ mod tests { &api, from, to, nonce, gas_limit, gas_price, value, &data, chain_id, &r, &s, v, ) .unwrap(); - assert!(valid); + assert_eq!(valid, true); } #[test] diff --git a/contracts/crypto-verify/tests/integration.rs b/contracts/crypto-verify/tests/integration.rs index 4cdf2f374..41b6c984d 100644 --- a/contracts/crypto-verify/tests/integration.rs +++ b/contracts/crypto-verify/tests/integration.rs @@ -54,8 +54,6 @@ const ED25519_SIGNATURE2_HEX: &str = "92a009a9f0d4cab8720e820b5f642540a2b27b5416 const ED25519_PUBLIC_KEY2_HEX: &str = "3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c"; -const DESERIALIZATION_LIMIT: usize = 20_000; - fn setup() -> Instance { let mut deps = mock_instance(WASM, &[]); let msg = InstantiateMsg {}; @@ -85,7 +83,7 @@ fn cosmos_signature_verify_works() { }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: true }); } @@ -107,7 +105,7 @@ fn cosmos_signature_verify_fails() { }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: false }); } @@ -146,7 +144,7 @@ fn ethereum_signature_verify_works() { signer_address: signer_address.into(), }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: true }); } @@ -166,7 +164,7 @@ fn ethereum_signature_verify_fails_for_corrupted_message() { signer_address: signer_address.into(), }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: false }); } @@ -187,7 +185,7 @@ fn ethereum_signature_verify_fails_for_corrupted_signature() { signer_address: signer_address.into(), }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: false }); // Broken signature @@ -227,9 +225,9 @@ fn verify_ethereum_transaction_works() { let chain_id = 4; // Rinkeby, see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids let from = "0x0a65766695a712af41b5cfecaad217b1a11cb22a"; let to = "0xe137f5264b6b528244e1643a2d570b37660b7f14"; - let gas_limit = Uint128::new(0x226c8); - let gas_price = Uint128::new(0x3b9aca00); - let value = Uint128::new(0x53177c); + let gas_limit = Uint128(0x226c8); + let gas_price = Uint128(0x3b9aca00); + let value = Uint128(0x53177c); let data = hex!("536561726368207478207465737420302e36353930383639313733393634333335"); let r = hex!("b9299dab50b3cddcaecd64b29bfbd5cd30fac1a1adea1b359a13c4e5171492a6"); let s = hex!("573059c66d894684488f92e7ce1f91b158ca57b0235485625b576a3b98c480ac"); @@ -249,7 +247,7 @@ fn verify_ethereum_transaction_works() { v, }; let raw = query(&mut deps, mock_env(), msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: true }); } @@ -268,7 +266,7 @@ fn tendermint_signature_verify_works() { }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: true }); } @@ -290,7 +288,7 @@ fn tendermint_signature_verify_fails() { }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: false }); } @@ -339,7 +337,7 @@ fn tendermint_signatures_batch_verify_works() { }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: true }); } @@ -372,7 +370,7 @@ fn tendermint_signatures_batch_verify_message_multisig_works() { }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: true }); } @@ -405,7 +403,7 @@ fn tendermint_signatures_batch_verify_single_public_key_works() { }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: true }); } @@ -436,7 +434,7 @@ fn tendermint_signatures_batch_verify_fails() { }; let raw = query(&mut deps, mock_env(), verify_msg).unwrap(); - let res: VerifyResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: VerifyResponse = from_slice(&raw).unwrap(); assert_eq!(res, VerifyResponse { verifies: false }); } @@ -478,7 +476,7 @@ fn query_works() { let query_msg = QueryMsg::ListVerificationSchemes {}; let raw = query(&mut deps, mock_env(), query_msg).unwrap(); - let res: ListVerificationsResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: ListVerificationsResponse = from_slice(&raw).unwrap(); assert_eq!( res, diff --git a/contracts/floaty/.cargo/config b/contracts/floaty/.cargo/config deleted file mode 100644 index 8d4bc738b..000000000 --- a/contracts/floaty/.cargo/config +++ /dev/null @@ -1,6 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration" -schema = "run --example schema" diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock deleted file mode 100644 index 3bb27a05d..000000000 --- a/contracts/floaty/Cargo.lock +++ /dev/null @@ -1,1717 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli 0.26.1", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "backtrace" -version = "0.3.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[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 = "bumpalo" -version = "3.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" - -[[package]] -name = "bytecheck" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" -dependencies = [ - "bytecheck_derive", - "ptr_meta", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "cc" -version = "1.0.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clru" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" - -[[package]] -name = "const-oid" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" - -[[package]] -name = "cosmwasm-crypto" -version = "0.14.0-0.4.0" -dependencies = [ - "digest", - "ed25519-zebra", - "k256", - "rand_core 0.5.1", - "sha-1", - "thiserror", -] - -[[package]] -name = "cosmwasm-derive" -version = "0.14.0-0.4.0" -dependencies = [ - "syn", -] - -[[package]] -name = "cosmwasm-schema" -version = "0.14.0-0.4.0" -dependencies = [ - "schemars", - "serde_json", -] - -[[package]] -name = "cosmwasm-std" -version = "0.14.0-0.4.0" -dependencies = [ - "base64", - "cosmwasm-crypto", - "cosmwasm-derive", - "schemars", - "serde", - "serde-json-wasm", - "thiserror", - "uint", - "uuid", -] - -[[package]] -name = "cosmwasm-storage" -version = "0.14.0-0.4.0" -dependencies = [ - "cosmwasm-std", - "serde", -] - -[[package]] -name = "cosmwasm-vm" -version = "0.14.0-0.4.0" -dependencies = [ - "clru", - "cosmwasm-crypto", - "cosmwasm-std", - "hex", - "loupe", - "parity-wasm", - "schemars", - "serde", - "serde_json", - "sha2", - "thiserror", - "wasmer", - "wasmer-middlewares", -] - -[[package]] -name = "cpufeatures" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" -dependencies = [ - "libc", -] - -[[package]] -name = "cranelift-bforest" -version = "0.76.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.76.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" -dependencies = [ - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli 0.25.0", - "log", - "regalloc", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.76.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" -dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.76.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" - -[[package]] -name = "cranelift-entity" -version = "0.76.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" - -[[package]] -name = "cranelift-frontend" -version = "0.76.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "crc32fast" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "lazy_static", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" -dependencies = [ - "cfg-if", - "lazy_static", -] - -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-mac" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - -[[package]] -name = "darling" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" -dependencies = [ - "darling_core", - "quote", - "syn", -] - -[[package]] -name = "der" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" -dependencies = [ - "const-oid", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "dyn-clone" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" - -[[package]] -name = "dynasm" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab1096ebdaa974cd6a41a743e94dfa00cce9bfbf4690bcc73fdec6a903938ccc" -dependencies = [ - "bitflags", - "byteorder", - "lazy_static", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "dynasmrt" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" -dependencies = [ - "byteorder", - "dynasm", - "memmap2", -] - -[[package]] -name = "ecdsa" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" -dependencies = [ - "der", - "elliptic-curve", - "hmac", - "signature", -] - -[[package]] -name = "ed25519-zebra" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a128b76af6dd4b427e34a6fd43dc78dbfe73672ec41ff615a2414c1a0ad0409" -dependencies = [ - "curve25519-dalek", - "hex", - "rand_core 0.5.1", - "serde", - "sha2", - "thiserror", -] - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "elliptic-curve" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" -dependencies = [ - "crypto-bigint", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - -[[package]] -name = "enumset" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6216d2c19a6fb5f29d1ada1dc7bc4367a8cbf0fa4af5cf12e07b5bbdde6b5b2c" -dependencies = [ - "enumset_derive", -] - -[[package]] -name = "enumset_derive" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6451128aa6655d880755345d085494cf7561a6bee7c8dc821e5d77e6d267ecd4" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "ff" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" -dependencies = [ - "rand_core 0.6.3", - "subtle", -] - -[[package]] -name = "floaty" -version = "0.0.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cosmwasm-vm", - "schemars", - "serde", - "sha2", - "thiserror", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "generic-array" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.10.2+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - -[[package]] -name = "gimli" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" - -[[package]] -name = "group" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" -dependencies = [ - "ff", - "rand_core 0.6.3", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac", - "digest", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "indexmap" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" -dependencies = [ - "autocfg", - "hashbrown", - "serde", -] - -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "k256" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "leb128" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" - -[[package]] -name = "libc" -version = "0.2.111" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" - -[[package]] -name = "libloading" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "log" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - -[[package]] -name = "memchr" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" - -[[package]] -name = "memmap2" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4647a11b578fead29cdbb34d4adef8dd3dc35b876c9c6d5240d83f205abfe96e" -dependencies = [ - "libc", -] - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - -[[package]] -name = "more-asserts" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" -dependencies = [ - "crc32fast", - "indexmap", - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "parity-wasm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" - -[[package]] -name = "pin-project-lite" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" - -[[package]] -name = "pkcs8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro2" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "quote" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" -dependencies = [ - "libc", - "rand_chacha", - "rand_core 0.6.3", - "rand_hc", -] - -[[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.3", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom 0.2.3", -] - -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core 0.6.3", -] - -[[package]] -name = "rayon" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" -dependencies = [ - "autocfg", - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "lazy_static", - "num_cpus", -] - -[[package]] -name = "redox_syscall" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regalloc" -version = "0.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" -dependencies = [ - "log", - "rustc-hash", - "smallvec", -] - -[[package]] -name = "region" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - -[[package]] -name = "ryu" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" - -[[package]] -name = "schemars" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b5a3c80cea1ab61f4260238409510e814e38b4b563c06044edf91e7dc070e3" -dependencies = [ - "dyn-clone", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ae4dce13e8614c46ac3c38ef1c0d668b101df6ac39817aebdaa26642ddae9b" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - -[[package]] -name = "serde" -version = "1.0.131" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-json-wasm" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50eef3672ec8fa45f3457fd423ba131117786784a895548021976117c1ded449" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_bytes" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.131" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_derive_internals" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dbab34ca63057a1f15280bdf3c39f2b1eb1b54c17e98360e511637aef7418c6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha-1" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" -dependencies = [ - "block-buffer", - "cfg-if", - "cpufeatures", - "digest", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" -dependencies = [ - "block-buffer", - "cfg-if", - "cpufeatures", - "digest", - "opaque-debug", -] - -[[package]] -name = "signature" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" -dependencies = [ - "digest", - "rand_core 0.6.3", -] - -[[package]] -name = "smallvec" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" - -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "syn" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "target-lexicon" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" - -[[package]] -name = "tempfile" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" -dependencies = [ - "cfg-if", - "libc", - "rand", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "thiserror" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" -dependencies = [ - "cfg-if", - "log", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "typenum" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" - -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - -[[package]] -name = "uuid" -version = "1.0.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb3ab47baa004111b323696c6eaa2752e7356f7f77cf6b6dc7a2087368ce1ca4" -dependencies = [ - "serde", - "sha-1", -] - -[[package]] -name = "version_check" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - -[[package]] -name = "wasmer" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" -dependencies = [ - "cfg-if", - "indexmap", - "js-sys", - "loupe", - "more-asserts", - "target-lexicon", - "thiserror", - "wasm-bindgen", - "wasmer-compiler", - "wasmer-compiler-cranelift", - "wasmer-compiler-singlepass", - "wasmer-derive", - "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-compiler" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" -dependencies = [ - "enumset", - "loupe", - "rkyv", - "serde", - "serde_bytes", - "smallvec", - "target-lexicon", - "thiserror", - "wasmer-types", - "wasmer-vm", - "wasmparser", -] - -[[package]] -name = "wasmer-compiler-cranelift" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "gimli 0.25.0", - "loupe", - "more-asserts", - "rayon", - "smallvec", - "target-lexicon", - "tracing", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-compiler-singlepass" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" -dependencies = [ - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "loupe", - "more-asserts", - "rayon", - "smallvec", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-derive" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "wasmer-engine" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" -dependencies = [ - "backtrace", - "enumset", - "lazy_static", - "loupe", - "memmap2", - "more-asserts", - "rustc-demangle", - "serde", - "serde_bytes", - "target-lexicon", - "thiserror", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" -dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", - "serde", - "tempfile", - "tracing", - "wasmer-compiler", - "wasmer-engine", - "wasmer-object", - "wasmer-types", - "wasmer-vm", - "which", -] - -[[package]] -name = "wasmer-engine-universal" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" -dependencies = [ - "cfg-if", - "enumset", - "leb128", - "loupe", - "region", - "rkyv", - "wasmer-compiler", - "wasmer-engine", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-middlewares" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" -dependencies = [ - "loupe", - "wasmer", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-object" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" -dependencies = [ - "object", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-types" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" -dependencies = [ - "indexmap", - "loupe", - "rkyv", - "serde", - "thiserror", -] - -[[package]] -name = "wasmer-vm" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" -dependencies = [ - "backtrace", - "cc", - "cfg-if", - "indexmap", - "libc", - "loupe", - "memoffset", - "more-asserts", - "region", - "rkyv", - "serde", - "thiserror", - "wasmer-types", - "winapi", -] - -[[package]] -name = "wasmparser" -version = "0.78.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" - -[[package]] -name = "which" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9" -dependencies = [ - "either", - "lazy_static", - "libc", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "zeroize" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" diff --git a/contracts/floaty/Cargo.toml b/contracts/floaty/Cargo.toml deleted file mode 100644 index 0ef1a58be..000000000 --- a/contracts/floaty/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "floaty" -version = "0.0.0" -authors = ["Ethan Frey "] -edition = "2018" -publish = false - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib", "rlib"] - -[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] -# Change this to [] if you don't need Windows support and want faster integration tests. -default = ["cranelift"] -# Use cranelift backend instead of singlepass. This is required for development on Windows. -cranelift = ["cosmwasm-vm/cranelift"] -# For quicker tests, cargo test --lib. for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] - -[dependencies] -cosmwasm-std = { path = "../../packages/std" } -schemars = "0.8.1" -serde = { version = "1.0.103", default-features = false, features = ["derive"] } -sha2 = "0.9.1" -thiserror = "1.0" - -[dev-dependencies] -cosmwasm-schema = { path = "../../packages/schema" } -cosmwasm-storage = { path = "../../packages/storage" } -cosmwasm-vm = { path = "../../packages/vm", default-features = false } diff --git a/contracts/floaty/examples/schema.rs b/contracts/floaty/examples/schema.rs deleted file mode 100644 index 928cbd6a2..000000000 --- a/contracts/floaty/examples/schema.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use cosmwasm_std::BalanceResponse; - -use floaty::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, VerifierResponse}; -use floaty::state::State; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - // messages - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); - export_schema(&schema_for!(VerifierResponse), &out_dir); - export_schema(&schema_for!(BalanceResponse), &out_dir); - - // state - export_schema(&schema_for!(State), &out_dir); -} diff --git a/contracts/floaty/schema/balance_response.json b/contracts/floaty/schema/balance_response.json deleted file mode 100644 index 4e3b16aa4..000000000 --- a/contracts/floaty/schema/balance_response.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BalanceResponse", - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "description": "Always returns a Coin with the requested denom. This may be of 0 amount if no such funds.", - "allOf": [ - { - "$ref": "#/definitions/Coin" - } - ] - } - }, - "definitions": { - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/floaty/schema/execute_msg.json b/contracts/floaty/schema/execute_msg.json deleted file mode 100644 index 0cb9f7b07..000000000 --- a/contracts/floaty/schema/execute_msg.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "anyOf": [ - { - "description": "Releasing all funds in the contract to the beneficiary. This is the only \"proper\" action of this demo contract.", - "type": "object", - "required": [ - "release" - ], - "properties": { - "release": { - "type": "object" - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/floaty/schema/instantiate_msg.json b/contracts/floaty/schema/instantiate_msg.json deleted file mode 100644 index 7f844a506..000000000 --- a/contracts/floaty/schema/instantiate_msg.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "beneficiary", - "verifier" - ], - "properties": { - "beneficiary": { - "type": "string" - }, - "verifier": { - "type": "string" - } - } -} diff --git a/contracts/floaty/schema/query_msg.json b/contracts/floaty/schema/query_msg.json deleted file mode 100644 index a0b5791ac..000000000 --- a/contracts/floaty/schema/query_msg.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "anyOf": [ - { - "description": "returns a human-readable representation of the verifier use to ensure query path works in integration tests", - "type": "object", - "required": [ - "verifier" - ], - "properties": { - "verifier": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "This returns cosmwasm_std::AllBalanceResponse to demo use of the querier", - "type": "object", - "required": [ - "other_balance" - ], - "properties": { - "other_balance": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Recurse will execute a query into itself up to depth-times and return Each step of the recursion may perform some extra work to test gas metering (`work` rounds of sha256 on contract). Now that we have Env, we can auto-calculate the address to recurse into", - "type": "object", - "required": [ - "recurse" - ], - "properties": { - "recurse": { - "type": "object", - "required": [ - "depth", - "work" - ], - "properties": { - "depth": { - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "work": { - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/floaty/schema/state.json b/contracts/floaty/schema/state.json deleted file mode 100644 index 8462e9fb3..000000000 --- a/contracts/floaty/schema/state.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "State", - "type": "object", - "required": [ - "beneficiary", - "funder", - "verifier" - ], - "properties": { - "beneficiary": { - "$ref": "#/definitions/Addr" - }, - "funder": { - "$ref": "#/definitions/Addr" - }, - "verifier": { - "$ref": "#/definitions/Addr" - } - }, - "definitions": { - "Addr": { - "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", - "type": "string" - } - } -} diff --git a/contracts/floaty/schema/verifier_response.json b/contracts/floaty/schema/verifier_response.json deleted file mode 100644 index 8af8ef368..000000000 --- a/contracts/floaty/schema/verifier_response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "VerifierResponse", - "type": "object", - "required": [ - "verifier" - ], - "properties": { - "verifier": { - "type": "string" - } - } -} diff --git a/contracts/floaty/src/contract.rs b/contracts/floaty/src/contract.rs deleted file mode 100644 index 477e3822c..000000000 --- a/contracts/floaty/src/contract.rs +++ /dev/null @@ -1,312 +0,0 @@ -use sha2::{Digest, Sha256}; - -use cosmwasm_std::{ - entry_point, from_slice, to_binary, to_vec, Addr, AllBalanceResponse, BankMsg, Deps, DepsMut, - Env, Event, MessageInfo, QueryRequest, QueryResponse, Response, StdError, StdResult, WasmQuery, -}; - -use crate::errors::HackError; -use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, RecurseResponse, VerifierResponse}; -use crate::state::{State, CONFIG_KEY}; - -#[entry_point] -pub fn instantiate( - deps: DepsMut, - _env: Env, - info: MessageInfo, - msg: InstantiateMsg, -) -> Result { - deps.api.debug("here we go 🚀"); - - deps.storage.set( - CONFIG_KEY, - &to_vec(&State { - verifier: deps.api.addr_validate(&msg.verifier)?, - beneficiary: deps.api.addr_validate(&msg.beneficiary)?, - funder: info.sender, - })?, - ); - - // This adds some unrelated event attribute for testing purposes - Ok(Response::new().add_attribute("Let the", "hacking begin")) -} - -#[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - _msg: ExecuteMsg, -) -> Result { - let data = deps - .storage - .get(CONFIG_KEY) - .ok_or_else(|| StdError::not_found("State"))?; - let state: State = from_slice(&data)?; - - if info.sender == state.verifier { - let to_addr = state.beneficiary; - let balance = deps.querier.query_all_balances(env.contract.address)?; - - let mut fl = balance[0].amount.u128() as f64; - fl *= 0.3; - - let resp = Response::new() - .add_attribute("action", "release") - .add_attribute("destination", to_addr.clone()) - .add_attribute("foo", fl.to_string()) - .add_event(Event::new("hackatom").add_attribute("action", "release")) - .add_message(BankMsg::Send { - to_address: to_addr.into(), - amount: balance, - }) - .set_data(&[0xF0, 0x0B, 0xAA]); - Ok(resp) - } else { - Err(HackError::Unauthorized {}) - } -} - -pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::Verifier {} => to_binary(&query_verifier(deps)?), - QueryMsg::OtherBalance { address } => to_binary(&query_other_balance(deps, address)?), - QueryMsg::Recurse { depth, work } => { - to_binary(&query_recurse(deps, depth, work, env.contract.address)?) - } - } -} - -fn query_verifier(deps: Deps) -> StdResult { - let data = deps - .storage - .get(CONFIG_KEY) - .ok_or_else(|| StdError::not_found("State"))?; - let state: State = from_slice(&data)?; - Ok(VerifierResponse { - verifier: state.verifier.into(), - }) -} - -fn query_other_balance(deps: Deps, address: String) -> StdResult { - let amount = deps.querier.query_all_balances(address)?; - Ok(AllBalanceResponse { amount }) -} - -fn query_recurse(deps: Deps, depth: u32, work: u32, contract: Addr) -> StdResult { - // perform all hashes as requested - let mut hashed: Vec = contract.as_str().into(); - for _ in 0..work { - hashed = Sha256::digest(&hashed).to_vec() - } - - // the last contract should return the response - if depth == 0 { - Ok(RecurseResponse { - hashed: hashed.into(), - }) - } else { - // otherwise, we go one level deeper and return the response of the next level - let req = QueryMsg::Recurse { - depth: depth - 1, - work, - }; - let query = QueryRequest::Wasm(WasmQuery::Smart { - contract_addr: contract.into(), - msg: to_binary(&req)?, - }); - deps.querier.query(&query) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use cosmwasm_std::testing::{ - mock_dependencies, mock_dependencies_with_balances, mock_env, mock_info, MOCK_CONTRACT_ADDR, - }; - use cosmwasm_std::Api as _; - // import trait Storage to get access to read - use cosmwasm_std::{attr, coins, Binary, Storage, SubMsg}; - - #[test] - fn proper_initialization() { - let mut deps = mock_dependencies(&[]); - - let verifier = String::from("verifies"); - let beneficiary = String::from("benefits"); - let creator = String::from("creator"); - let expected_state = State { - verifier: deps.api.addr_validate(&verifier).unwrap(), - beneficiary: deps.api.addr_validate(&beneficiary).unwrap(), - funder: deps.api.addr_validate(&creator).unwrap(), - }; - - let msg = InstantiateMsg { - verifier, - beneficiary, - }; - let info = mock_info(creator.as_str(), &[]); - let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(res.messages.len(), 0); - assert_eq!(res.attributes.len(), 1); - assert_eq!(res.attributes[0].key, "Let the"); - assert_eq!(res.attributes[0].value, "hacking begin"); - - // it worked, let's check the state - let data = deps.storage.get(CONFIG_KEY).expect("no data stored"); - let state: State = from_slice(&data).unwrap(); - assert_eq!(state, expected_state); - } - - #[test] - fn instantiate_and_query() { - let mut deps = mock_dependencies(&[]); - - let verifier = String::from("verifies"); - let beneficiary = String::from("benefits"); - let creator = String::from("creator"); - let msg = InstantiateMsg { - verifier: verifier.clone(), - beneficiary, - }; - let info = mock_info(&creator, &[]); - let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - - // now let's query - let query_response = query_verifier(deps.as_ref()).unwrap(); - assert_eq!(query_response.verifier, verifier); - } - - #[test] - fn querier_callbacks_work() { - let rich_addr = String::from("foobar"); - let rich_balance = coins(10000, "gold"); - let deps = mock_dependencies_with_balances(&[(&rich_addr, &rich_balance)]); - - // querying with balance gets the balance - let bal = query_other_balance(deps.as_ref(), rich_addr).unwrap(); - assert_eq!(bal.amount, rich_balance); - - // querying other accounts gets none - let bal = query_other_balance(deps.as_ref(), String::from("someone else")).unwrap(); - assert_eq!(bal.amount, vec![]); - } - - #[test] - fn execute_release_works() { - let mut deps = mock_dependencies(&[]); - - // initialize the store - let creator = String::from("creator"); - let verifier = String::from("verifies"); - let beneficiary = String::from("benefits"); - - let instantiate_msg = InstantiateMsg { - verifier: verifier.clone(), - beneficiary: beneficiary.clone(), - }; - let init_amount = coins(1000, "earth"); - let init_info = mock_info(&creator, &init_amount); - let init_res = instantiate(deps.as_mut(), mock_env(), init_info, instantiate_msg).unwrap(); - assert_eq!(init_res.messages.len(), 0); - - // balance changed in init - deps.querier.update_balance(MOCK_CONTRACT_ADDR, init_amount); - - // beneficiary can release it - let execute_info = mock_info(verifier.as_str(), &[]); - let execute_res = execute( - deps.as_mut(), - mock_env(), - execute_info, - ExecuteMsg::Release {}, - ) - .unwrap(); - assert_eq!(execute_res.messages.len(), 1); - let msg = execute_res.messages.get(0).expect("no message"); - assert_eq!( - msg, - &SubMsg::new(BankMsg::Send { - to_address: beneficiary, - amount: coins(1000, "earth"), - }), - ); - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "release"), - attr("destination", "benefits"), - attr("foo", "300") - ], - ); - assert_eq!(execute_res.data, Some(vec![0xF0, 0x0B, 0xAA].into())); - } - - #[test] - fn execute_release_fails_for_wrong_sender() { - let mut deps = mock_dependencies(&[]); - - // initialize the store - let creator = String::from("creator"); - let verifier = String::from("verifies"); - let beneficiary = String::from("benefits"); - - let instantiate_msg = InstantiateMsg { - verifier: verifier.clone(), - beneficiary: beneficiary.clone(), - }; - let init_amount = coins(1000, "earth"); - let init_info = mock_info(&creator, &init_amount); - let init_res = instantiate(deps.as_mut(), mock_env(), init_info, instantiate_msg).unwrap(); - assert_eq!(init_res.messages.len(), 0); - - // balance changed in init - deps.querier.update_balance(MOCK_CONTRACT_ADDR, init_amount); - - // beneficiary cannot release it - let execute_info = mock_info(beneficiary.as_str(), &[]); - let execute_res = execute( - deps.as_mut(), - mock_env(), - execute_info, - ExecuteMsg::Release {}, - ); - assert_eq!(execute_res.unwrap_err(), HackError::Unauthorized {}); - - // state should not change - let data = deps.storage.get(CONFIG_KEY).expect("no data stored"); - let state: State = from_slice(&data).unwrap(); - assert_eq!( - state, - State { - verifier: Addr::unchecked(verifier), - beneficiary: Addr::unchecked(beneficiary), - funder: Addr::unchecked(creator), - } - ); - } - - #[test] - fn query_recursive() { - // the test framework doesn't handle contracts querying contracts yet, - // let's just make sure the last step looks right - - let deps = mock_dependencies(&[]); - let contract = Addr::unchecked("my-contract"); - let bin_contract: &[u8] = b"my-contract"; - - // return the unhashed value here - let no_work_query = query_recurse(deps.as_ref(), 0, 0, contract.clone()).unwrap(); - assert_eq!(no_work_query.hashed, Binary::from(bin_contract)); - - // let's see if 5 hashes are done right - let mut expected_hash = Sha256::digest(bin_contract); - for _ in 0..4 { - expected_hash = Sha256::digest(&expected_hash); - } - let work_query = query_recurse(deps.as_ref(), 0, 5, contract).unwrap(); - assert_eq!(work_query.hashed, expected_hash.to_vec()); - } -} diff --git a/contracts/floaty/src/errors.rs b/contracts/floaty/src/errors.rs deleted file mode 100644 index 7b46b00b6..000000000 --- a/contracts/floaty/src/errors.rs +++ /dev/null @@ -1,12 +0,0 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - -#[derive(Error, Debug, PartialEq)] -pub enum HackError { - #[error("{0}")] - /// this is needed so we can use `bucket.load(...)?` and have it auto-converted to the custom error - Std(#[from] StdError), - // this is whatever we want - #[error("Unauthorized")] - Unauthorized {}, -} diff --git a/contracts/floaty/src/lib.rs b/contracts/floaty/src/lib.rs deleted file mode 100644 index 0573cc96c..000000000 --- a/contracts/floaty/src/lib.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod contract; -mod errors; -pub mod msg; -pub mod state; diff --git a/contracts/floaty/src/msg.rs b/contracts/floaty/src/msg.rs deleted file mode 100644 index c3297aa7a..000000000 --- a/contracts/floaty/src/msg.rs +++ /dev/null @@ -1,45 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::Binary; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct InstantiateMsg { - pub verifier: String, - pub beneficiary: String, -} - -// failure modes to help test wasmd, based on this comment -// https://github.com/cosmwasm/wasmd/issues/8#issuecomment-576146751 -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { - /// Releasing all funds in the contract to the beneficiary. This is the only "proper" action of this demo contract. - Release {}, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum QueryMsg { - /// returns a human-readable representation of the verifier - /// use to ensure query path works in integration tests - Verifier {}, - /// This returns cosmwasm_std::AllBalanceResponse to demo use of the querier - OtherBalance { address: String }, - /// Recurse will execute a query into itself up to depth-times and return - /// Each step of the recursion may perform some extra work to test gas metering - /// (`work` rounds of sha256 on contract). - /// Now that we have Env, we can auto-calculate the address to recurse into - Recurse { depth: u32, work: u32 }, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct VerifierResponse { - pub verifier: String, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct RecurseResponse { - /// hashed is the result of running sha256 "work+1" times on the contract's human address - pub hashed: Binary, -} diff --git a/contracts/floaty/src/state.rs b/contracts/floaty/src/state.rs deleted file mode 100644 index b1e8196be..000000000 --- a/contracts/floaty/src/state.rs +++ /dev/null @@ -1,13 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::Addr; - -pub const CONFIG_KEY: &[u8] = b"config"; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct State { - pub verifier: Addr, - pub beneficiary: Addr, - pub funder: Addr, -} diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 9a6464c1f..175170120 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -42,10 +31,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -56,45 +45,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bincode" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "generic-array", + "serde", ] [[package]] -name = "bumpalo" -version = "3.8.0" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bytecheck" -version = "0.6.7" +name = "bitvec" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" dependencies = [ - "bytecheck_derive", - "ptr_meta", + "funty", + "radium", + "wyz", ] [[package]] -name = "bytecheck_derive" -version = "0.6.7" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "proc-macro2", - "quote", - "syn", + "generic-array", ] [[package]] @@ -109,6 +91,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -123,9 +111,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -165,7 +153,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -185,7 +172,6 @@ dependencies = [ "cosmwasm-crypto", "cosmwasm-std", "hex", - "loupe", "parity-wasm", "schemars", "serde", @@ -207,35 +193,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -243,21 +231,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -267,11 +258,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -280,7 +271,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -290,7 +281,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -301,7 +292,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -314,33 +305,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -361,9 +334,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -371,9 +344,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -385,9 +358,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -396,9 +369,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -441,16 +414,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -478,16 +450,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -521,11 +495,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -535,6 +510,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -551,7 +532,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -562,16 +543,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -586,12 +567,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -614,9 +595,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -635,9 +613,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -666,22 +644,13 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -701,17 +670,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -721,28 +690,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -760,6 +708,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -771,9 +728,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -806,20 +763,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "opaque-debug" @@ -841,12 +800,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -881,33 +839,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quote" version = "1.0.10" @@ -917,6 +855,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1013,9 +957,9 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1032,40 +976,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1078,17 +988,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "schemars" @@ -1120,17 +1024,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "serde" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1155,9 +1053,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1193,7 +1091,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1206,7 +1104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1214,12 +1112,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1228,27 +1126,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -1274,9 +1157,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1284,7 +1167,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1318,8 +1201,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1351,18 +1233,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1397,95 +1267,37 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1498,19 +1310,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1519,17 +1329,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1538,9 +1348,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1550,15 +1360,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1571,54 +1380,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1626,11 +1431,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1638,33 +1443,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1673,9 +1474,27 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wast" +version = "38.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +dependencies = [ + "wast", +] [[package]] name = "which" @@ -1710,6 +1529,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/contracts/hackatom/Cargo.toml b/contracts/hackatom/Cargo.toml index d6541333b..cc4911e9c 100644 --- a/contracts/hackatom/Cargo.toml +++ b/contracts/hackatom/Cargo.toml @@ -30,7 +30,7 @@ cranelift = ["cosmwasm-vm/cranelift"] backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] -cosmwasm-std = { path = "../../packages/std", default-features = false } +cosmwasm-std = { path = "../../packages/std" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } sha2 = "0.9.1" @@ -38,5 +38,5 @@ thiserror = "1.0" [dev-dependencies] cosmwasm-schema = { path = "../../packages/schema" } -cosmwasm-storage = { path = "../../packages/storage", default-features = false } +cosmwasm-storage = { path = "../../packages/storage" } cosmwasm-vm = { path = "../../packages/vm", default-features = false } diff --git a/contracts/hackatom/src/contract.rs b/contracts/hackatom/src/contract.rs index 9155f5899..e4421b58e 100644 --- a/contracts/hackatom/src/contract.rs +++ b/contracts/hackatom/src/contract.rs @@ -2,7 +2,7 @@ use sha2::{Digest, Sha256}; use cosmwasm_std::{ entry_point, from_slice, to_binary, to_vec, Addr, AllBalanceResponse, Api, BankMsg, - CanonicalAddr, Deps, DepsMut, Env, Event, MessageInfo, QueryRequest, QueryResponse, Response, + CanonicalAddr, Deps, DepsMut, Env, MessageInfo, QueryRequest, QueryResponse, Response, StdError, StdResult, WasmQuery, }; @@ -30,7 +30,9 @@ pub fn instantiate( ); // This adds some unrelated event attribute for testing purposes - Ok(Response::new().add_attribute("Let the", "hacking begin")) + let mut resp = Response::new(); + resp.add_attribute("Let the", "hacking begin"); + Ok(resp) } pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result { @@ -53,7 +55,9 @@ pub fn sudo(_deps: DepsMut, _env: Env, msg: SudoMsg) -> Result Result Result { if old_size == usize::max_value() { return Err(StdError::generic_err("memory.grow failed").into()); } - Ok(Response::new().set_data((old_size as u32).to_be_bytes())) + Ok(Response { + data: Some((old_size as u32).to_be_bytes().into()), + ..Response::default() + }) } #[cfg(not(target_arch = "wasm32"))] @@ -167,8 +173,7 @@ fn do_user_errors_in_api_calls(api: &dyn Api) -> Result { } } - let invalid_bech32 = - "bn9hhssomeltvhzgvuqkwjkpwxojfuigltwedayzxljucefikuieillowaticksoistqoynmgcnj219a"; + let invalid_bech32 = "bn93hg934hg08q340g8u4jcau3"; match api.addr_canonicalize(invalid_bech32).unwrap_err() { StdError::GenericErr { .. } => {} err => { @@ -280,7 +285,7 @@ mod tests { mock_dependencies, mock_dependencies_with_balances, mock_env, mock_info, MOCK_CONTRACT_ADDR, }; // import trait Storage to get access to read - use cosmwasm_std::{coins, Binary, Storage, SubMsg}; + use cosmwasm_std::{attr, coins, Binary, Storage}; #[test] fn proper_initialization() { @@ -302,7 +307,9 @@ mod tests { let info = mock_info(creator.as_str(), &[]); let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); assert_eq!(res.messages.len(), 0); - assert_eq!(res.attributes, [("Let the", "hacking begin")]); + assert_eq!(res.attributes.len(), 1); + assert_eq!(res.attributes[0].key, "Let the"); + assert_eq!(res.attributes[0].value, "hacking begin"); // it worked, let's check the state let data = deps.storage.get(CONFIG_KEY).expect("no data stored"); @@ -387,7 +394,7 @@ mod tests { let res = sudo(deps.as_mut(), mock_env(), sys_msg).unwrap(); assert_eq!(1, res.messages.len()); let msg = res.messages.get(0).expect("no message"); - assert_eq!(msg, &SubMsg::new(BankMsg::Send { to_address, amount })); + assert_eq!(msg, &BankMsg::Send { to_address, amount }.into(),); } #[test] @@ -439,14 +446,15 @@ mod tests { let msg = execute_res.messages.get(0).expect("no message"); assert_eq!( msg, - &SubMsg::new(BankMsg::Send { + &BankMsg::Send { to_address: beneficiary, amount: coins(1000, "earth"), - }), + } + .into(), ); assert_eq!( execute_res.attributes, - vec![("action", "release"), ("destination", "benefits")], + vec![attr("action", "release"), attr("destination", "benefits")], ); assert_eq!(execute_res.data, Some(vec![0xF0, 0x0B, 0xAA].into())); } diff --git a/contracts/hackatom/tests/integration.rs b/contracts/hackatom/tests/integration.rs index 7f13e484e..64a353a42 100644 --- a/contracts/hackatom/tests/integration.rs +++ b/contracts/hackatom/tests/integration.rs @@ -18,8 +18,8 @@ //! 4. Anywhere you see query(&deps, ...) you must replace it with query(&mut deps, ...) use cosmwasm_std::{ - coins, from_binary, to_vec, Addr, AllBalanceResponse, BankMsg, Binary, ContractResult, Empty, - Response, SubMsg, + attr, coins, from_binary, to_vec, Addr, AllBalanceResponse, BankMsg, Binary, ContractResult, + Empty, Response, }; use cosmwasm_vm::{ call_execute, from_slice, @@ -35,8 +35,6 @@ use hackatom::state::{State, CONFIG_KEY}; static WASM: &[u8] = include_bytes!("../target/wasm32-unknown-unknown/release/hackatom.wasm"); -const DESERIALIZATION_LIMIT: usize = 20_000; - fn make_init_msg() -> (InstantiateMsg, String) { let verifier = String::from("verifies"); let beneficiary = String::from("benefits"); @@ -53,7 +51,7 @@ fn make_init_msg() -> (InstantiateMsg, String) { #[test] fn proper_initialization() { let mut deps = mock_instance(WASM, &[]); - assert_eq!(deps.required_features().len(), 0); + assert_eq!(deps.required_features.len(), 0); let verifier = String::from("verifies"); let beneficiary = String::from("benefits"); @@ -71,7 +69,9 @@ fn proper_initialization() { let info = mock_info(&creator, &coins(1000, "earth")); let res: Response = instantiate(&mut deps, mock_env(), info, msg).unwrap(); assert_eq!(res.messages.len(), 0); - assert_eq!(res.attributes, [("Let the", "hacking begin")]); + assert_eq!(res.attributes.len(), 1); + assert_eq!(res.attributes[0].key, "Let the"); + assert_eq!(res.attributes[0].value, "hacking begin"); // it worked, let's check the state let state: State = deps @@ -81,7 +81,7 @@ fn proper_initialization() { .0 .expect("error reading db") .expect("no data stored"); - from_slice(&data, DESERIALIZATION_LIMIT) + from_slice(&data) }) .unwrap(); assert_eq!(state, expected_state); @@ -171,7 +171,7 @@ fn sudo_can_steal_tokens() { let res: Response = sudo(&mut deps, mock_env(), sys_msg).unwrap(); assert_eq!(1, res.messages.len()); let msg = res.messages.get(0).expect("no message"); - assert_eq!(msg, &SubMsg::new(BankMsg::Send { to_address, amount })); + assert_eq!(msg, &BankMsg::Send { to_address, amount }.into(),); } #[test] @@ -240,14 +240,15 @@ fn execute_release_works() { let msg = execute_res.messages.get(0).expect("no message"); assert_eq!( msg, - &SubMsg::new(BankMsg::Send { + &BankMsg::Send { to_address: beneficiary, amount: coins(1000, "earth"), - }), + } + .into(), ); assert_eq!( execute_res.attributes, - vec![("action", "release"), ("destination", "benefits")], + vec![attr("action", "release"), attr("destination", "benefits")], ); assert_eq!(execute_res.data, Some(vec![0xF0, 0x0B, 0xAA].into())); } @@ -295,7 +296,7 @@ fn execute_release_fails_for_wrong_sender() { .expect("no data stored")) }) .unwrap(); - let state: State = from_slice(&data, DESERIALIZATION_LIMIT).unwrap(); + let state: State = from_slice(&data).unwrap(); assert_eq!( state, State { diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 3bf9c5c72..838b2faa4 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -42,10 +31,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -56,45 +45,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bincode" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "generic-array", + "serde", ] [[package]] -name = "bumpalo" -version = "3.8.0" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bytecheck" -version = "0.6.7" +name = "bitvec" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" dependencies = [ - "bytecheck_derive", - "ptr_meta", + "funty", + "radium", + "wyz", ] [[package]] -name = "bytecheck_derive" -version = "0.6.7" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "proc-macro2", - "quote", - "syn", + "generic-array", ] [[package]] @@ -109,6 +91,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -123,9 +111,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -165,7 +153,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -185,7 +172,6 @@ dependencies = [ "cosmwasm-crypto", "cosmwasm-std", "hex", - "loupe", "parity-wasm", "schemars", "serde", @@ -207,35 +193,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -243,21 +231,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -267,11 +258,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -280,7 +271,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -290,7 +281,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -301,7 +292,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -314,33 +305,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -361,9 +334,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -371,9 +344,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -385,9 +358,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -396,9 +369,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -441,16 +414,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -478,16 +450,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -521,11 +495,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -535,6 +510,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -551,7 +532,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -562,16 +543,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -586,12 +567,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -600,9 +581,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -621,9 +599,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -664,22 +642,13 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -699,17 +668,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -719,28 +688,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -758,6 +706,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -769,9 +726,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -804,20 +761,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "opaque-debug" @@ -839,12 +798,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -879,33 +837,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quote" version = "1.0.10" @@ -915,6 +853,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1011,9 +955,9 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1030,40 +974,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1076,17 +986,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "schemars" @@ -1118,17 +1022,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "serde" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1153,9 +1051,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1191,7 +1089,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1204,7 +1102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1212,12 +1110,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1226,27 +1124,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -1272,9 +1155,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1282,7 +1165,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1316,8 +1199,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1349,18 +1231,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1395,95 +1265,37 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1496,19 +1308,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1517,17 +1327,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1536,9 +1346,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1548,15 +1358,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1569,54 +1378,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1624,11 +1429,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1636,33 +1441,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1671,9 +1472,27 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wast" +version = "38.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +dependencies = [ + "wast", +] [[package]] name = "which" @@ -1708,6 +1527,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/contracts/ibc-reflect-send/schema/account_response.json b/contracts/ibc-reflect-send/schema/account_response.json index d6e05cc5e..8e57ee5ac 100644 --- a/contracts/ibc-reflect-send/schema/account_response.json +++ b/contracts/ibc-reflect-send/schema/account_response.json @@ -46,7 +46,7 @@ } }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", "allOf": [ { "$ref": "#/definitions/Uint64" diff --git a/contracts/ibc-reflect-send/schema/execute_msg.json b/contracts/ibc-reflect-send/schema/execute_msg.json index a2b2f1b5c..3a104320f 100644 --- a/contracts/ibc-reflect-send/schema/execute_msg.json +++ b/contracts/ibc-reflect-send/schema/execute_msg.json @@ -273,18 +273,6 @@ } }, "additionalProperties": false - }, - { - "type": "object", - "required": [ - "gov" - ], - "properties": { - "gov": { - "$ref": "#/definitions/GovMsg" - } - }, - "additionalProperties": false } ] }, @@ -341,37 +329,6 @@ "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", "type": "object" }, - "GovMsg": { - "oneOf": [ - { - "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "vote" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "vote": { - "$ref": "#/definitions/VoteOption" - } - } - } - }, - "additionalProperties": false - } - ] - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -610,7 +567,7 @@ ] }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", "allOf": [ { "$ref": "#/definitions/Uint64" @@ -625,15 +582,6 @@ "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, - "VoteOption": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "no_with_veto" - ] - }, "WasmMsg": { "description": "The message types of the wasm module.\n\nSee https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/types/tx.proto.", "oneOf": [ @@ -648,19 +596,13 @@ "type": "object", "required": [ "contract_addr", - "funds", - "msg" + "msg", + "send" ], "properties": { "contract_addr": { "type": "string" }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -668,6 +610,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } @@ -685,9 +633,9 @@ "type": "object", "required": [ "code_id", - "funds", "label", - "msg" + "msg", + "send" ], "properties": { "admin": { @@ -701,12 +649,6 @@ "format": "uint64", "minimum": 0.0 }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -718,6 +660,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } diff --git a/contracts/ibc-reflect-send/schema/list_accounts_response.json b/contracts/ibc-reflect-send/schema/list_accounts_response.json index 7c63981f8..b648789fb 100644 --- a/contracts/ibc-reflect-send/schema/list_accounts_response.json +++ b/contracts/ibc-reflect-send/schema/list_accounts_response.json @@ -64,7 +64,7 @@ } }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", "allOf": [ { "$ref": "#/definitions/Uint64" diff --git a/contracts/ibc-reflect-send/schema/packet_msg.json b/contracts/ibc-reflect-send/schema/packet_msg.json index 177e5cd5f..51a01bd40 100644 --- a/contracts/ibc-reflect-send/schema/packet_msg.json +++ b/contracts/ibc-reflect-send/schema/packet_msg.json @@ -226,18 +226,6 @@ } }, "additionalProperties": false - }, - { - "type": "object", - "required": [ - "gov" - ], - "properties": { - "gov": { - "$ref": "#/definitions/GovMsg" - } - }, - "additionalProperties": false } ] }, @@ -294,37 +282,6 @@ "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", "type": "object" }, - "GovMsg": { - "oneOf": [ - { - "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "vote" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "vote": { - "$ref": "#/definitions/VoteOption" - } - } - } - }, - "additionalProperties": false - } - ] - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -563,7 +520,7 @@ ] }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", "allOf": [ { "$ref": "#/definitions/Uint64" @@ -578,15 +535,6 @@ "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, - "VoteOption": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "no_with_veto" - ] - }, "WasmMsg": { "description": "The message types of the wasm module.\n\nSee https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/types/tx.proto.", "oneOf": [ @@ -601,19 +549,13 @@ "type": "object", "required": [ "contract_addr", - "funds", - "msg" + "msg", + "send" ], "properties": { "contract_addr": { "type": "string" }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -621,6 +563,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } @@ -638,9 +586,9 @@ "type": "object", "required": [ "code_id", - "funds", "label", - "msg" + "msg", + "send" ], "properties": { "admin": { @@ -654,12 +602,6 @@ "format": "uint64", "minimum": 0.0 }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -671,6 +613,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } diff --git a/contracts/ibc-reflect-send/src/contract.rs b/contracts/ibc-reflect-send/src/contract.rs index 87b34c435..266ee6b49 100644 --- a/contracts/ibc-reflect-send/src/contract.rs +++ b/contracts/ibc-reflect-send/src/contract.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{ - entry_point, to_binary, CosmosMsg, Deps, DepsMut, Env, IbcMsg, MessageInfo, Order, + attr, entry_point, to_binary, CosmosMsg, Deps, DepsMut, Env, IbcMsg, MessageInfo, Order, QueryResponse, Response, StdError, StdResult, }; @@ -22,7 +22,12 @@ pub fn instantiate( let cfg = Config { admin: info.sender }; config(deps.storage).save(&cfg)?; - Ok(Response::new().add_attribute("action", "instantiate")) + Ok(Response { + data: None, + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "instantiate")], + }) } #[entry_point] @@ -55,9 +60,15 @@ pub fn handle_update_admin( cfg.admin = deps.api.addr_validate(&new_admin)?; config(deps.storage).save(&cfg)?; - Ok(Response::new() - .add_attribute("action", "handle_update_admin") - .add_attribute("new_admin", cfg.admin)) + Ok(Response { + submessages: vec![], + messages: vec![], + attributes: vec![ + attr("action", "handle_update_admin"), + attr("new_admin", cfg.admin), + ], + data: None, + }) } pub fn handle_send_msgs( @@ -83,10 +94,12 @@ pub fn handle_send_msgs( timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(), }; - let res = Response::new() - .add_message(msg) - .add_attribute("action", "handle_send_msgs"); - Ok(res) + Ok(Response { + submessages: vec![], + messages: vec![msg.into()], + attributes: vec![attr("action", "handle_send_msgs")], + data: None, + }) } pub fn handle_check_remote_balance( @@ -111,10 +124,12 @@ pub fn handle_check_remote_balance( timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(), }; - let res = Response::new() - .add_message(msg) - .add_attribute("action", "handle_check_remote_balance"); - Ok(res) + Ok(Response { + submessages: vec![], + messages: vec![msg.into()], + attributes: vec![attr("action", "handle_check_remote_balance")], + data: None, + }) } pub fn handle_send_funds( @@ -159,10 +174,12 @@ pub fn handle_send_funds( timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(), }; - let res = Response::new() - .add_message(msg) - .add_attribute("action", "handle_send_funds"); - Ok(res) + Ok(Response { + submessages: vec![], + messages: vec![msg.into()], + attributes: vec![attr("action", "handle_send_funds")], + data: None, + }) } #[entry_point] diff --git a/contracts/ibc-reflect-send/src/ibc.rs b/contracts/ibc-reflect-send/src/ibc.rs index b62d98583..2a6d8f270 100644 --- a/contracts/ibc-reflect-send/src/ibc.rs +++ b/contracts/ibc-reflect-send/src/ibc.rs @@ -1,7 +1,6 @@ use cosmwasm_std::{ - entry_point, from_slice, to_binary, DepsMut, Env, IbcBasicResponse, IbcChannelCloseMsg, - IbcChannelConnectMsg, IbcChannelOpenMsg, IbcMsg, IbcOrder, IbcPacketAckMsg, - IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, StdError, StdResult, + attr, entry_point, from_slice, to_binary, DepsMut, Env, IbcAcknowledgement, IbcBasicResponse, + IbcChannel, IbcMsg, IbcOrder, IbcPacket, IbcReceiveResponse, StdError, StdResult, }; use crate::ibc_msg::{ @@ -17,9 +16,7 @@ pub const PACKET_LIFETIME: u64 = 60 * 60; #[entry_point] /// enforces ordering and versioing constraints -pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> StdResult<()> { - let channel = msg.channel(); - +pub fn ibc_channel_open(_deps: DepsMut, _env: Env, channel: IbcChannel) -> StdResult<()> { if channel.order != IbcOrder::Ordered { return Err(StdError::generic_err("Only supports ordered channels")); } @@ -29,9 +26,10 @@ pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> St IBC_VERSION ))); } - - if let Some(counter_version) = msg.counterparty_version() { - if counter_version != IBC_VERSION { + // TODO: do we need to check counterparty version as well? + // This flow needs to be well documented + if let Some(counter_version) = channel.counterparty_version { + if counter_version.as_str() != IBC_VERSION { return Err(StdError::generic_err(format!( "Counterparty version must be `{}`", IBC_VERSION @@ -47,11 +45,9 @@ pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> St pub fn ibc_channel_connect( deps: DepsMut, env: Env, - msg: IbcChannelConnectMsg, + channel: IbcChannel, ) -> StdResult { - let channel = msg.channel(); - - let channel_id = &channel.endpoint.channel_id; + let channel_id = channel.endpoint.channel_id; // create an account holder the channel exists (not found if not registered) let data = AccountData::default(); @@ -65,10 +61,14 @@ pub fn ibc_channel_connect( timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(), }; - Ok(IbcBasicResponse::new() - .add_message(msg) - .add_attribute("action", "ibc_connect") - .add_attribute("channel_id", channel_id)) + Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![msg.into()], + attributes: vec![ + attr("action", "ibc_connect"), + attr("channel_id", channel_id), + ], + }) } #[entry_point] @@ -76,17 +76,17 @@ pub fn ibc_channel_connect( pub fn ibc_channel_close( deps: DepsMut, _env: Env, - msg: IbcChannelCloseMsg, + channel: IbcChannel, ) -> StdResult { - let channel = msg.channel(); - // remove the channel - let channel_id = &channel.endpoint.channel_id; + let channel_id = channel.endpoint.channel_id; accounts(deps.storage).remove(channel_id.as_bytes()); - Ok(IbcBasicResponse::new() - .add_attribute("action", "ibc_close") - .add_attribute("channel_id", channel_id)) + Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "ibc_close"), attr("channel_id", channel_id)], + }) } #[entry_point] @@ -94,34 +94,37 @@ pub fn ibc_channel_close( pub fn ibc_packet_receive( _deps: DepsMut, _env: Env, - _packet: IbcPacketReceiveMsg, + _packet: IbcPacket, ) -> StdResult { - Ok(IbcReceiveResponse::new() - .set_ack(b"{}") - .add_attribute("action", "ibc_packet_ack")) + Ok(IbcReceiveResponse { + acknowledgement: b"{}".into(), + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "ibc_packet_ack")], + }) } #[entry_point] pub fn ibc_packet_ack( deps: DepsMut, env: Env, - msg: IbcPacketAckMsg, + ack: IbcAcknowledgement, ) -> StdResult { // which local channel was this packet send from - let caller = msg.original_packet.src.channel_id; + let caller = ack.original_packet.src.channel_id; // we need to parse the ack based on our request - let packet: PacketMsg = from_slice(&msg.original_packet.data)?; - match packet { + let msg: PacketMsg = from_slice(&ack.original_packet.data)?; + match msg { PacketMsg::Dispatch { .. } => { - let res: AcknowledgementMsg = from_slice(&msg.acknowledgement.data)?; + let res: AcknowledgementMsg = from_slice(&ack.acknowledgement)?; acknowledge_dispatch(deps, caller, res) } PacketMsg::WhoAmI {} => { - let res: AcknowledgementMsg = from_slice(&msg.acknowledgement.data)?; + let res: AcknowledgementMsg = from_slice(&ack.acknowledgement)?; acknowledge_who_am_i(deps, caller, res) } PacketMsg::Balances {} => { - let res: AcknowledgementMsg = from_slice(&msg.acknowledgement.data)?; + let res: AcknowledgementMsg = from_slice(&ack.acknowledgement)?; acknowledge_balances(deps, env, caller, res) } } @@ -135,7 +138,11 @@ fn acknowledge_dispatch( _ack: AcknowledgementMsg, ) -> StdResult { // TODO: actually handle success/error? - Ok(IbcBasicResponse::new().add_attribute("action", "acknowledge_dispatch")) + Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "acknowledge_dispatch")], + }) } // receive PacketMsg::WhoAmI response @@ -149,9 +156,11 @@ fn acknowledge_who_am_i( let WhoAmIResponse { account } = match ack { AcknowledgementMsg::Ok(res) => res, AcknowledgementMsg::Err(e) => { - return Ok(IbcBasicResponse::new() - .add_attribute("action", "acknowledge_who_am_i") - .add_attribute("error", e)) + return Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "acknowledge_who_am_i"), attr("error", e)], + }) } }; @@ -168,7 +177,11 @@ fn acknowledge_who_am_i( } })?; - Ok(IbcBasicResponse::new().add_attribute("action", "acknowledge_who_am_i")) + Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "acknowledge_who_am_i")], + }) } // receive PacketMsg::Balances response @@ -182,9 +195,11 @@ fn acknowledge_balances( let BalancesResponse { account, balances } = match ack { AcknowledgementMsg::Ok(res) => res, AcknowledgementMsg::Err(e) => { - return Ok(IbcBasicResponse::new() - .add_attribute("action", "acknowledge_balances") - .add_attribute("error", e)) + return Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "acknowledge_balances"), attr("error", e)], + }) } }; @@ -209,7 +224,11 @@ fn acknowledge_balances( } })?; - Ok(IbcBasicResponse::new().add_attribute("action", "acknowledge_balances")) + Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "acknowledge_balances")], + }) } #[entry_point] @@ -217,9 +236,13 @@ fn acknowledge_balances( pub fn ibc_packet_timeout( _deps: DepsMut, _env: Env, - _msg: IbcPacketTimeoutMsg, + _packet: IbcPacket, ) -> StdResult { - Ok(IbcBasicResponse::new().add_attribute("action", "ibc_packet_timeout")) + Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "ibc_packet_timeout")], + }) } #[cfg(test)] @@ -229,11 +252,10 @@ mod tests { use crate::msg::{AccountResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; use cosmwasm_std::testing::{ - mock_dependencies, mock_env, mock_ibc_channel_connect_ack, mock_ibc_channel_open_init, - mock_ibc_channel_open_try, mock_ibc_packet_ack, mock_info, MockApi, MockQuerier, - MockStorage, + mock_dependencies, mock_env, mock_ibc_channel, mock_ibc_packet_ack, mock_info, MockApi, + MockQuerier, MockStorage, }; - use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, IbcAcknowledgement, OwnedDeps}; + use cosmwasm_std::{coin, coins, BankMsg, CosmosMsg, OwnedDeps}; const CREATOR: &str = "creator"; @@ -249,18 +271,19 @@ mod tests { // connect will run through the entire handshake to set up a proper connect and // save the account (tested in detail in `proper_handshake_flow`) fn connect(mut deps: DepsMut, channel_id: &str) { - let handshake_open = mock_ibc_channel_open_init(channel_id, IbcOrder::Ordered, IBC_VERSION); + // open packet has no counterparty version, connect does + let mut handshake_open = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); + handshake_open.counterparty_version = None; // first we try to open with a valid handshake ibc_channel_open(deps.branch(), mock_env(), handshake_open).unwrap(); // then we connect (with counter-party version set) - let handshake_connect = - mock_ibc_channel_connect_ack(channel_id, IbcOrder::Ordered, IBC_VERSION); + let handshake_connect = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); let res = ibc_channel_connect(deps.branch(), mock_env(), handshake_connect).unwrap(); // this should send a WhoAmI request, which is received some blocks later assert_eq!(1, res.messages.len()); - match &res.messages[0].msg { + match &res.messages[0] { CosmosMsg::Ibc(IbcMsg::SendPacket { channel_id: packet_channel, .. @@ -269,14 +292,16 @@ mod tests { }; } - fn who_am_i_response(deps: DepsMut, channel_id: &str, account: impl Into) { + fn who_am_i_response>(deps: DepsMut, channel_id: &str, account: T) { let packet = PacketMsg::WhoAmI {}; let response = AcknowledgementMsg::Ok(WhoAmIResponse { account: account.into(), }); - let ack = IbcAcknowledgement::encode_json(&response).unwrap(); - let msg = mock_ibc_packet_ack(channel_id, &packet, ack).unwrap(); - let res = ibc_packet_ack(deps, mock_env(), msg).unwrap(); + let ack = IbcAcknowledgement { + acknowledgement: to_binary(&response).unwrap(), + original_packet: mock_ibc_packet_ack(channel_id, &packet).unwrap(), + }; + let res = ibc_packet_ack(deps, mock_env(), ack).unwrap(); assert_eq!(0, res.messages.len()); } @@ -284,14 +309,13 @@ mod tests { fn enforce_version_in_handshake() { let mut deps = setup(); - let wrong_order = mock_ibc_channel_open_try("channel-12", IbcOrder::Unordered, IBC_VERSION); + let wrong_order = mock_ibc_channel("channel-12", IbcOrder::Unordered, IBC_VERSION); ibc_channel_open(deps.as_mut(), mock_env(), wrong_order).unwrap_err(); - let wrong_version = mock_ibc_channel_open_try("channel-12", IbcOrder::Ordered, "reflect"); + let wrong_version = mock_ibc_channel("channel-12", IbcOrder::Ordered, "reflect"); ibc_channel_open(deps.as_mut(), mock_env(), wrong_version).unwrap_err(); - let valid_handshake = - mock_ibc_channel_open_try("channel-12", IbcOrder::Ordered, IBC_VERSION); + let valid_handshake = mock_ibc_channel("channel-12", IbcOrder::Ordered, IBC_VERSION); ibc_channel_open(deps.as_mut(), mock_env(), valid_handshake).unwrap(); } @@ -352,21 +376,26 @@ mod tests { let info = mock_info(CREATOR, &[]); let mut res = execute(deps.as_mut(), mock_env(), info, handle_msg).unwrap(); assert_eq!(1, res.messages.len()); - let msg = match res.messages.swap_remove(0).msg { + let packet = match res.messages.swap_remove(0) { CosmosMsg::Ibc(IbcMsg::SendPacket { channel_id, data, .. }) => { - let ack = IbcAcknowledgement::encode_json(&AcknowledgementMsg::Ok(())).unwrap(); - let mut msg = mock_ibc_packet_ack(&channel_id, &1, ack).unwrap(); - msg.original_packet.data = data; - msg + let mut packet = mock_ibc_packet_ack(&channel_id, &1).unwrap(); + packet.data = data; + packet } o => panic!("Unexpected message: {:?}", o), }; - let res = ibc_packet_ack(deps.as_mut(), mock_env(), msg).unwrap(); + + // and handle the ack + let ack = IbcAcknowledgement { + acknowledgement: to_binary(&AcknowledgementMsg::Ok(())).unwrap(), + original_packet: packet, + }; + let res = ibc_packet_ack(deps.as_mut(), mock_env(), ack).unwrap(); // no actions expected, but let's check the events to see it was dispatched properly assert_eq!(0, res.messages.len()); - assert_eq!(vec![("action", "acknowledge_dispatch")], res.attributes) + assert_eq!(vec![attr("action", "acknowledge_dispatch")], res.attributes) } #[test] @@ -406,7 +435,7 @@ mod tests { let info = mock_info(CREATOR, &coins(12344, "utrgd")); let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); assert_eq!(1, res.messages.len()); - match &res.messages[0].msg { + match &res.messages[0] { CosmosMsg::Ibc(IbcMsg::Transfer { channel_id, to_address, diff --git a/contracts/ibc-reflect-send/tests/integration.rs b/contracts/ibc-reflect-send/tests/integration.rs index 79d986011..60267c994 100644 --- a/contracts/ibc-reflect-send/tests/integration.rs +++ b/contracts/ibc-reflect-send/tests/integration.rs @@ -17,13 +17,10 @@ //! }); //! 4. Anywhere you see query(&deps, ...) you must replace it with query(&mut deps, ...) -use cosmwasm_std::testing::{ - mock_ibc_channel_connect_ack, mock_ibc_channel_open_init, mock_ibc_channel_open_try, - mock_ibc_packet_ack, -}; +use cosmwasm_std::testing::{mock_ibc_channel, mock_ibc_packet_ack}; use cosmwasm_std::{ - attr, coin, coins, BankMsg, CosmosMsg, Empty, IbcAcknowledgement, IbcBasicResponse, IbcMsg, - IbcOrder, Response, + attr, coin, coins, to_binary, BankMsg, CosmosMsg, Empty, IbcAcknowledgement, IbcBasicResponse, + IbcMsg, IbcOrder, Response, }; use cosmwasm_vm::testing::{ execute, ibc_channel_connect, ibc_channel_open, ibc_packet_ack, instantiate, mock_env, @@ -41,8 +38,6 @@ static WASM: &[u8] = const CREATOR: &str = "creator"; -const DESERIALIZATION_LIMIT: usize = 20_000; - fn setup() -> Instance { let mut deps = mock_instance(WASM, &[]); let msg = InstantiateMsg {}; @@ -56,18 +51,18 @@ fn setup() -> Instance { // save the account (tested in detail in `proper_handshake_flow`) fn connect(deps: &mut Instance, channel_id: &str) { // open packet has no counterparty version, connect does - let handshake_open = mock_ibc_channel_open_init(channel_id, IbcOrder::Ordered, IBC_VERSION); + let mut handshake_open = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); + handshake_open.counterparty_version = None; // first we try to open with a valid handshake ibc_channel_open(deps, mock_env(), handshake_open).unwrap(); // then we connect (with counter-party version set) - let handshake_connect = - mock_ibc_channel_connect_ack(channel_id, IbcOrder::Ordered, IBC_VERSION); + let handshake_connect = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); let res: IbcBasicResponse = ibc_channel_connect(deps, mock_env(), handshake_connect).unwrap(); // this should send a WhoAmI request, which is received some blocks later assert_eq!(1, res.messages.len()); - match &res.messages[0].msg { + match &res.messages[0] { CosmosMsg::Ibc(IbcMsg::SendPacket { channel_id: packet_channel, .. @@ -76,18 +71,20 @@ fn connect(deps: &mut Instance, channel_id: & }; } -fn who_am_i_response( +fn who_am_i_response>( deps: &mut Instance, channel_id: &str, - account: impl Into, + account: T, ) { let packet = PacketMsg::WhoAmI {}; let response = AcknowledgementMsg::Ok(WhoAmIResponse { account: account.into(), }); - let ack = IbcAcknowledgement::encode_json(&response).unwrap(); - let msg = mock_ibc_packet_ack(channel_id, &packet, ack).unwrap(); - let res: IbcBasicResponse = ibc_packet_ack(deps, mock_env(), msg).unwrap(); + let ack = IbcAcknowledgement { + acknowledgement: to_binary(&response).unwrap(), + original_packet: mock_ibc_packet_ack(channel_id, &packet).unwrap(), + }; + let res: IbcBasicResponse = ibc_packet_ack(deps, mock_env(), ack).unwrap(); assert_eq!(0, res.messages.len()); } @@ -95,7 +92,7 @@ fn who_am_i_response( fn instantiate_works() { let mut deps = setup(); let r = query(&mut deps, mock_env(), QueryMsg::Admin {}).unwrap(); - let admin: AdminResponse = from_slice(&r, DESERIALIZATION_LIMIT).unwrap(); + let admin: AdminResponse = from_slice(&r).unwrap(); assert_eq!(CREATOR, admin.admin.as_str()); } @@ -103,13 +100,13 @@ fn instantiate_works() { fn enforce_version_in_handshake() { let mut deps = setup(); - let wrong_order = mock_ibc_channel_open_try("channel-12", IbcOrder::Unordered, IBC_VERSION); + let wrong_order = mock_ibc_channel("channel-12", IbcOrder::Unordered, IBC_VERSION); ibc_channel_open(&mut deps, mock_env(), wrong_order).unwrap_err(); - let wrong_version = mock_ibc_channel_open_try("channel-12", IbcOrder::Ordered, "reflect"); + let wrong_version = mock_ibc_channel("channel-12", IbcOrder::Ordered, "reflect"); ibc_channel_open(&mut deps, mock_env(), wrong_version).unwrap_err(); - let valid_handshake = mock_ibc_channel_open_try("channel-12", IbcOrder::Ordered, IBC_VERSION); + let valid_handshake = mock_ibc_channel("channel-12", IbcOrder::Ordered, IBC_VERSION); ibc_channel_open(&mut deps, mock_env(), valid_handshake).unwrap(); } @@ -121,7 +118,7 @@ fn get_account( channel_id: channel_id.into(), }; let r = query(deps, mock_env(), msg).unwrap(); - from_slice(&r, DESERIALIZATION_LIMIT).unwrap() + from_slice(&r).unwrap() } #[test] @@ -173,18 +170,23 @@ fn dispatch_message_send_and_ack() { let info = mock_info(CREATOR, &[]); let mut res: Response = execute(&mut deps, mock_env(), info, execute_msg).unwrap(); assert_eq!(1, res.messages.len()); - let msg = match res.messages.swap_remove(0).msg { + let packet = match res.messages.swap_remove(0) { CosmosMsg::Ibc(IbcMsg::SendPacket { channel_id, data, .. }) => { - let ack = IbcAcknowledgement::encode_json(&AcknowledgementMsg::Ok(())).unwrap(); - let mut msg = mock_ibc_packet_ack(&channel_id, &1, ack).unwrap(); - msg.original_packet.data = data; - msg + let mut packet = mock_ibc_packet_ack(&channel_id, &1).unwrap(); + packet.data = data; + packet } o => panic!("Unexpected message: {:?}", o), }; - let res: IbcBasicResponse = ibc_packet_ack(&mut deps, mock_env(), msg).unwrap(); + + // and handle the ack + let ack = IbcAcknowledgement { + acknowledgement: to_binary(&AcknowledgementMsg::Ok(())).unwrap(), + original_packet: packet, + }; + let res: IbcBasicResponse = ibc_packet_ack(&mut deps, mock_env(), ack).unwrap(); // no actions expected, but let's check the events to see it was dispatched properly assert_eq!(0, res.messages.len()); assert_eq!(vec![attr("action", "acknowledge_dispatch")], res.attributes) @@ -227,7 +229,7 @@ fn send_remote_funds() { let info = mock_info(CREATOR, &coins(12344, "utrgd")); let res: Response = execute(&mut deps, mock_env(), info, msg).unwrap(); assert_eq!(1, res.messages.len()); - match &res.messages[0].msg { + match &res.messages[0] { CosmosMsg::Ibc(IbcMsg::Transfer { channel_id, to_address, diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index 850c91232..102d9f9dc 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -42,10 +31,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -56,45 +45,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bincode" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "generic-array", + "serde", ] [[package]] -name = "bumpalo" -version = "3.8.0" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bytecheck" -version = "0.6.7" +name = "bitvec" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" dependencies = [ - "bytecheck_derive", - "ptr_meta", + "funty", + "radium", + "wyz", ] [[package]] -name = "bytecheck_derive" -version = "0.6.7" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "proc-macro2", - "quote", - "syn", + "generic-array", ] [[package]] @@ -109,6 +91,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -123,9 +111,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -165,7 +153,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -185,7 +172,6 @@ dependencies = [ "cosmwasm-crypto", "cosmwasm-std", "hex", - "loupe", "parity-wasm", "schemars", "serde", @@ -207,35 +193,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -243,21 +231,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -267,11 +258,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -280,7 +271,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -290,7 +281,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -301,7 +292,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -314,33 +305,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -361,9 +334,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -371,9 +344,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -385,9 +358,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -396,9 +369,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -441,16 +414,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -478,16 +450,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -521,11 +495,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -535,6 +510,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -551,7 +532,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -562,16 +543,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -586,12 +567,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -600,9 +581,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -621,9 +599,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -664,22 +642,13 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -699,17 +668,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -719,28 +688,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -758,6 +706,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -769,9 +726,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -804,20 +761,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "opaque-debug" @@ -839,12 +798,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -879,33 +837,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quote" version = "1.0.10" @@ -915,6 +853,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1011,9 +955,9 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1030,40 +974,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1076,17 +986,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "schemars" @@ -1118,17 +1022,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "serde" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1153,9 +1051,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1191,7 +1089,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1204,7 +1102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1212,12 +1110,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1226,27 +1124,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -1272,9 +1155,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1282,7 +1165,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1316,8 +1199,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1349,18 +1231,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1395,95 +1265,37 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1496,19 +1308,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1517,17 +1327,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1536,9 +1346,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1548,15 +1358,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1569,54 +1378,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1624,11 +1429,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1636,33 +1441,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1671,9 +1472,27 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wast" +version = "38.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +dependencies = [ + "wast", +] [[package]] name = "which" @@ -1708,6 +1527,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/contracts/ibc-reflect/schema/acknowledgement_msg_balances.json b/contracts/ibc-reflect/schema/acknowledgement_msg_balances.json index 6f1c3aa6e..d57b5b06c 100644 --- a/contracts/ibc-reflect/schema/acknowledgement_msg_balances.json +++ b/contracts/ibc-reflect/schema/acknowledgement_msg_balances.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "AcknowledgementMsgBalances", - "description": "This is the final result type that is created and serialized in a contract for every init/execute/migrate call. The VM then deserializes this type to distinguish between successful and failed executions.\n\nWe use a custom type here instead of Rust's Result because we want to be able to define the serialization, which is a public interface. Every language that compiles to Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\n# Examples\n\nSuccess:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let response: Response = Response::default(); let result: ContractResult = ContractResult::Ok(response); assert_eq!(to_vec(&result).unwrap(), br#\"{\"ok\":{\"messages\":[],\"attributes\":[],\"events\":[],\"data\":null}}\"#.to_vec()); ```\n\nFailure:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let error_msg = String::from(\"Something went wrong\"); let result: ContractResult = ContractResult::Err(error_msg); assert_eq!(to_vec(&result).unwrap(), br#\"{\"error\":\"Something went wrong\"}\"#.to_vec()); ```", + "description": "This is the final result type that is created and serialized in a contract for every init/execute/migrate call. The VM then deserializes this type to distinguish between successful and failed executions.\n\nWe use a custom type here instead of Rust's Result because we want to be able to define the serialization, which is a public interface. Every language that compiles to Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\n# Examples\n\nSuccess:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let response: Response = Response::default(); let result: ContractResult = ContractResult::Ok(response); assert_eq!(to_vec(&result).unwrap(), br#\"{\"ok\":{\"submessages\":[],\"messages\":[],\"attributes\":[],\"data\":null}}\"#.to_vec()); ```\n\nFailure:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let error_msg = String::from(\"Something went wrong\"); let result: ContractResult = ContractResult::Err(error_msg); assert_eq!(to_vec(&result).unwrap(), br#\"{\"error\":\"Something went wrong\"}\"#.to_vec()); ```", "oneOf": [ { "type": "object", diff --git a/contracts/ibc-reflect/schema/acknowledgement_msg_dispatch.json b/contracts/ibc-reflect/schema/acknowledgement_msg_dispatch.json index 675ef12ee..464698c36 100644 --- a/contracts/ibc-reflect/schema/acknowledgement_msg_dispatch.json +++ b/contracts/ibc-reflect/schema/acknowledgement_msg_dispatch.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "AcknowledgementMsgDispatch", - "description": "This is the final result type that is created and serialized in a contract for every init/execute/migrate call. The VM then deserializes this type to distinguish between successful and failed executions.\n\nWe use a custom type here instead of Rust's Result because we want to be able to define the serialization, which is a public interface. Every language that compiles to Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\n# Examples\n\nSuccess:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let response: Response = Response::default(); let result: ContractResult = ContractResult::Ok(response); assert_eq!(to_vec(&result).unwrap(), br#\"{\"ok\":{\"messages\":[],\"attributes\":[],\"events\":[],\"data\":null}}\"#.to_vec()); ```\n\nFailure:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let error_msg = String::from(\"Something went wrong\"); let result: ContractResult = ContractResult::Err(error_msg); assert_eq!(to_vec(&result).unwrap(), br#\"{\"error\":\"Something went wrong\"}\"#.to_vec()); ```", + "description": "This is the final result type that is created and serialized in a contract for every init/execute/migrate call. The VM then deserializes this type to distinguish between successful and failed executions.\n\nWe use a custom type here instead of Rust's Result because we want to be able to define the serialization, which is a public interface. Every language that compiles to Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\n# Examples\n\nSuccess:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let response: Response = Response::default(); let result: ContractResult = ContractResult::Ok(response); assert_eq!(to_vec(&result).unwrap(), br#\"{\"ok\":{\"submessages\":[],\"messages\":[],\"attributes\":[],\"data\":null}}\"#.to_vec()); ```\n\nFailure:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let error_msg = String::from(\"Something went wrong\"); let result: ContractResult = ContractResult::Err(error_msg); assert_eq!(to_vec(&result).unwrap(), br#\"{\"error\":\"Something went wrong\"}\"#.to_vec()); ```", "oneOf": [ { "type": "object", diff --git a/contracts/ibc-reflect/schema/acknowledgement_msg_who_am_i.json b/contracts/ibc-reflect/schema/acknowledgement_msg_who_am_i.json index 16a1f0239..0e35afdb9 100644 --- a/contracts/ibc-reflect/schema/acknowledgement_msg_who_am_i.json +++ b/contracts/ibc-reflect/schema/acknowledgement_msg_who_am_i.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "AcknowledgementMsgWhoAmI", - "description": "This is the final result type that is created and serialized in a contract for every init/execute/migrate call. The VM then deserializes this type to distinguish between successful and failed executions.\n\nWe use a custom type here instead of Rust's Result because we want to be able to define the serialization, which is a public interface. Every language that compiles to Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\n# Examples\n\nSuccess:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let response: Response = Response::default(); let result: ContractResult = ContractResult::Ok(response); assert_eq!(to_vec(&result).unwrap(), br#\"{\"ok\":{\"messages\":[],\"attributes\":[],\"events\":[],\"data\":null}}\"#.to_vec()); ```\n\nFailure:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let error_msg = String::from(\"Something went wrong\"); let result: ContractResult = ContractResult::Err(error_msg); assert_eq!(to_vec(&result).unwrap(), br#\"{\"error\":\"Something went wrong\"}\"#.to_vec()); ```", + "description": "This is the final result type that is created and serialized in a contract for every init/execute/migrate call. The VM then deserializes this type to distinguish between successful and failed executions.\n\nWe use a custom type here instead of Rust's Result because we want to be able to define the serialization, which is a public interface. Every language that compiles to Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\n# Examples\n\nSuccess:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let response: Response = Response::default(); let result: ContractResult = ContractResult::Ok(response); assert_eq!(to_vec(&result).unwrap(), br#\"{\"ok\":{\"submessages\":[],\"messages\":[],\"attributes\":[],\"data\":null}}\"#.to_vec()); ```\n\nFailure:\n\n``` # use cosmwasm_std::{to_vec, ContractResult, Response}; let error_msg = String::from(\"Something went wrong\"); let result: ContractResult = ContractResult::Err(error_msg); assert_eq!(to_vec(&result).unwrap(), br#\"{\"error\":\"Something went wrong\"}\"#.to_vec()); ```", "oneOf": [ { "type": "object", diff --git a/contracts/ibc-reflect/schema/packet_msg.json b/contracts/ibc-reflect/schema/packet_msg.json index 88e5141c8..3024e1c0a 100644 --- a/contracts/ibc-reflect/schema/packet_msg.json +++ b/contracts/ibc-reflect/schema/packet_msg.json @@ -225,18 +225,6 @@ } }, "additionalProperties": false - }, - { - "type": "object", - "required": [ - "gov" - ], - "properties": { - "gov": { - "$ref": "#/definitions/GovMsg" - } - }, - "additionalProperties": false } ] }, @@ -293,37 +281,6 @@ "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", "type": "object" }, - "GovMsg": { - "oneOf": [ - { - "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "vote" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "vote": { - "$ref": "#/definitions/VoteOption" - } - } - } - }, - "additionalProperties": false - } - ] - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -562,7 +519,7 @@ ] }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", "allOf": [ { "$ref": "#/definitions/Uint64" @@ -577,15 +534,6 @@ "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, - "VoteOption": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "no_with_veto" - ] - }, "WasmMsg": { "description": "The message types of the wasm module.\n\nSee https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/types/tx.proto.", "oneOf": [ @@ -600,19 +548,13 @@ "type": "object", "required": [ "contract_addr", - "funds", - "msg" + "msg", + "send" ], "properties": { "contract_addr": { "type": "string" }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -620,6 +562,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } @@ -637,9 +585,9 @@ "type": "object", "required": [ "code_id", - "funds", "label", - "msg" + "msg", + "send" ], "properties": { "admin": { @@ -653,12 +601,6 @@ "format": "uint64", "minimum": 0.0 }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -670,6 +612,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } diff --git a/contracts/ibc-reflect/src/contract.rs b/contracts/ibc-reflect/src/contract.rs index 9de3d45d3..379770730 100644 --- a/contracts/ibc-reflect/src/contract.rs +++ b/contracts/ibc-reflect/src/contract.rs @@ -1,9 +1,8 @@ use cosmwasm_std::{ - entry_point, from_slice, to_binary, wasm_execute, BankMsg, Binary, ContractResult, CosmosMsg, - Deps, DepsMut, Empty, Env, Event, IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, - IbcChannelOpenMsg, IbcOrder, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, - IbcReceiveResponse, MessageInfo, Order, QueryResponse, Reply, Response, StdError, StdResult, - SubMsg, SubMsgExecutionResponse, WasmMsg, + attr, entry_point, from_slice, to_binary, wasm_execute, BankMsg, Binary, ContractResult, + CosmosMsg, Deps, DepsMut, Empty, Env, Event, IbcAcknowledgement, IbcBasicResponse, IbcChannel, + IbcOrder, IbcPacket, IbcReceiveResponse, MessageInfo, Order, QueryResponse, Reply, ReplyOn, + Response, StdError, StdResult, SubMsg, SubcallResponse, WasmMsg, }; use crate::msg::{ @@ -29,37 +28,40 @@ pub fn instantiate( }; config(deps.storage).save(&cfg)?; - Ok(Response::new().add_attribute("action", "instantiate")) + Ok(Response { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "instantiate")], + data: None, + }) } #[entry_point] pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> StdResult { match (reply.id, reply.result) { - (RECEIVE_DISPATCH_ID, ContractResult::Err(err)) => { - Ok(Response::new().set_data(encode_ibc_error(err))) - } + (RECEIVE_DISPATCH_ID, ContractResult::Err(err)) => Ok(Response { + data: Some(encode_ibc_error(err)), + ..Response::default() + }), (INIT_CALLBACK_ID, ContractResult::Ok(response)) => handle_init_callback(deps, response), _ => Err(StdError::generic_err("invalid reply id or result")), } } -// updated with https://github.com/CosmWasm/wasmd/pull/586 (emitted in keeper.Instantiate) +// see https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/msg_server.go fn parse_contract_from_event(events: Vec) -> Option { events .into_iter() - .find(|e| e.ty == "instantiate") + .find(|e| e.kind == "message") .and_then(|ev| { ev.attributes .into_iter() - .find(|a| a.key == "_contract_address") + .find(|a| a.key == "contract_address") }) .map(|a| a.value) } -pub fn handle_init_callback( - deps: DepsMut, - response: SubMsgExecutionResponse, -) -> StdResult { +pub fn handle_init_callback(deps: DepsMut, response: SubcallResponse) -> StdResult { // we use storage to pass info from the caller to the reply let id = pending_channel(deps.storage).load()?; pending_channel(deps.storage).remove(); @@ -68,7 +70,7 @@ pub fn handle_init_callback( let contract_addr = match parse_contract_from_event(response.events) { Some(addr) => deps.api.addr_validate(&addr), None => Err(StdError::generic_err( - "No _contract_address found in callback events", + "No contract_address found in callback events", )), }?; @@ -83,7 +85,12 @@ pub fn handle_init_callback( } })?; - Ok(Response::new().add_attribute("action", "execute_init_callback")) + Ok(Response { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "execute_init_callback")], + data: None, + }) } #[entry_point] @@ -119,9 +126,7 @@ pub fn query_list_accounts(deps: Deps) -> StdResult { #[entry_point] /// enforces ordering and versioing constraints -pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> StdResult<()> { - let channel = msg.channel(); - +pub fn ibc_channel_open(_deps: DepsMut, _env: Env, channel: IbcChannel) -> StdResult<()> { if channel.order != IbcOrder::Ordered { return Err(StdError::generic_err("Only supports ordered channels")); } @@ -131,9 +136,10 @@ pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> St IBC_VERSION ))); } - - if let Some(counter_version) = msg.counterparty_version() { - if counter_version != IBC_VERSION { + // TODO: do we need to check counterparty version as well? + // This flow needs to be well documented + if let Some(counter_version) = channel.counterparty_version { + if counter_version.as_str() != IBC_VERSION { return Err(StdError::generic_err(format!( "Counterparty version must be `{}`", IBC_VERSION @@ -149,29 +155,33 @@ pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> St pub fn ibc_channel_connect( deps: DepsMut, _env: Env, - msg: IbcChannelConnectMsg, + channel: IbcChannel, ) -> StdResult { - let channel = msg.channel(); let cfg = config(deps.storage).load()?; - let chan_id = &channel.endpoint.channel_id; + let chan_id = channel.endpoint.channel_id; let msg = WasmMsg::Instantiate { admin: None, code_id: cfg.reflect_code_id, msg: b"{}".into(), - funds: vec![], - label: format!("ibc-reflect-{}", chan_id), + send: vec![], + label: format!("ibc-reflect-{}", &chan_id), + }; + let sub_msg = SubMsg { + id: INIT_CALLBACK_ID, + msg: msg.into(), + gas_limit: None, + reply_on: ReplyOn::Success, }; - let msg = SubMsg::reply_on_success(msg, INIT_CALLBACK_ID); // store the channel id for the reply handler - pending_channel(deps.storage).save(chan_id)?; + pending_channel(deps.storage).save(&chan_id)?; - Ok(IbcBasicResponse::new() - .add_submessage(msg) - .add_attribute("action", "ibc_connect") - .add_attribute("channel_id", chan_id) - .add_event(Event::new("ibc").add_attribute("channel", "connect"))) + Ok(IbcBasicResponse { + messages: vec![], + submessages: vec![sub_msg], + attributes: vec![attr("action", "ibc_connect"), attr("channel_id", chan_id)], + }) } #[entry_point] @@ -180,9 +190,8 @@ pub fn ibc_channel_connect( pub fn ibc_channel_close( deps: DepsMut, env: Env, - msg: IbcChannelCloseMsg, + channel: IbcChannel, ) -> StdResult { - let channel = msg.channel(); // get contract address and remove lookup let channel_id = channel.endpoint.channel_id.as_str(); let reflect_addr = accounts(deps.storage).load(channel_id.as_bytes())?; @@ -190,7 +199,7 @@ pub fn ibc_channel_close( // transfer current balance if any (steal the money) let amount = deps.querier.query_all_balances(&reflect_addr)?; - let messages: Vec> = if !amount.is_empty() { + let messages: Vec> = if !amount.is_empty() { let bank_msg = BankMsg::Send { to_address: env.contract.address.into(), amount, @@ -199,17 +208,21 @@ pub fn ibc_channel_close( msgs: vec![bank_msg.into()], }; let wasm_msg = wasm_execute(reflect_addr, &reflect_msg, vec![])?; - vec![SubMsg::new(wasm_msg)] + vec![wasm_msg.into()] } else { vec![] }; let steal_funds = !messages.is_empty(); - Ok(IbcBasicResponse::new() - .add_submessages(messages) - .add_attribute("action", "ibc_close") - .add_attribute("channel_id", channel_id) - .add_attribute("steal_funds", steal_funds.to_string())) + Ok(IbcBasicResponse { + submessages: vec![], + messages, + attributes: vec![ + attr("action", "ibc_close"), + attr("channel_id", channel_id), + attr("steal_funds", steal_funds), + ], + }) } /// this is a no-op just to test how this integrates with wasmd @@ -219,7 +232,7 @@ pub fn migrate(_deps: DepsMut, _env: Env, _msg: Empty) -> StdResult { } // this encode an error or error message into a proper acknowledgement to the recevier -fn encode_ibc_error(msg: impl Into) -> Binary { +fn encode_ibc_error>(msg: T) -> Binary { // this cannot error, unwrap to keep the interface simple to_binary(&AcknowledgementMsg::<()>::Err(msg.into())).unwrap() } @@ -231,11 +244,10 @@ fn encode_ibc_error(msg: impl Into) -> Binary { pub fn ibc_packet_receive( deps: DepsMut, _env: Env, - msg: IbcPacketReceiveMsg, + packet: IbcPacket, ) -> StdResult { // put this in a closure so we can convert all error responses into acknowledgements (|| { - let packet = msg.packet; // which local channel did this packet come on let caller = packet.dest.channel_id; let msg: PacketMsg = from_slice(&packet.data)?; @@ -249,9 +261,12 @@ pub fn ibc_packet_receive( // we try to capture all app-level errors and convert them into // acknowledgement packets that contain an error code. let acknowledgement = encode_ibc_error(format!("invalid packet: {}", e)); - Ok(IbcReceiveResponse::new() - .set_ack(acknowledgement) - .add_event(Event::new("ibc").add_attribute("packet", "receive"))) + Ok(IbcReceiveResponse { + acknowledgement, + submessages: vec![], + messages: vec![], + attributes: vec![], + }) }) } @@ -263,9 +278,12 @@ fn receive_who_am_i(deps: DepsMut, caller: String) -> StdResult StdResult StdResult { - Ok(IbcBasicResponse::new().add_attribute("action", "ibc_packet_ack")) + Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "ibc_packet_ack")], + }) } #[entry_point] @@ -322,20 +354,23 @@ pub fn ibc_packet_ack( pub fn ibc_packet_timeout( _deps: DepsMut, _env: Env, - _msg: IbcPacketTimeoutMsg, + _packet: IbcPacket, ) -> StdResult { - Ok(IbcBasicResponse::new().add_attribute("action", "ibc_packet_timeout")) + Ok(IbcBasicResponse { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "ibc_packet_timeout")], + }) } #[cfg(test)] mod tests { use super::*; use cosmwasm_std::testing::{ - mock_dependencies, mock_env, mock_ibc_channel_close_init, mock_ibc_channel_connect_ack, - mock_ibc_channel_open_init, mock_ibc_channel_open_try, mock_ibc_packet_recv, mock_info, - mock_wasmd_attr, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR, + mock_dependencies, mock_env, mock_ibc_channel, mock_ibc_packet_recv, mock_info, MockApi, + MockQuerier, MockStorage, MOCK_CONTRACT_ADDR, }; - use cosmwasm_std::{attr, coin, coins, from_slice, BankMsg, OwnedDeps, WasmMsg}; + use cosmwasm_std::{coin, coins, from_slice, BankMsg, OwnedDeps, WasmMsg}; const CREATOR: &str = "creator"; // code id of the reflect contract @@ -355,39 +390,40 @@ mod tests { } fn fake_events(reflect_addr: &str) -> Vec { - let event = Event::new("instantiate").add_attributes(vec![ - attr("code_id", "17"), - // We have to force this one to avoid the debug assertion against _ - mock_wasmd_attr("_contract_address", reflect_addr), - ]); + let event = Event { + kind: "message".into(), + attributes: vec![ + attr("module", "wasm"), + attr("signer", MOCK_CONTRACT_ADDR), + attr("code_id", "17"), + attr("contract_address", reflect_addr), + ], + }; vec![event] } // connect will run through the entire handshake to set up a proper connect and // save the account (tested in detail in `proper_handshake_flow`) - fn connect(mut deps: DepsMut, channel_id: &str, account: impl Into) { + fn connect>(mut deps: DepsMut, channel_id: &str, account: T) { let account: String = account.into(); - let handshake_open = mock_ibc_channel_open_init(channel_id, IbcOrder::Ordered, IBC_VERSION); + // open packet has no counterparty versin, connect does + // TODO: validate this with alpe + let mut handshake_open = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); + handshake_open.counterparty_version = None; // first we try to open with a valid handshake ibc_channel_open(deps.branch(), mock_env(), handshake_open).unwrap(); // then we connect (with counter-party version set) - let handshake_connect = - mock_ibc_channel_connect_ack(channel_id, IbcOrder::Ordered, IBC_VERSION); + let handshake_connect = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); let res = ibc_channel_connect(deps.branch(), mock_env(), handshake_connect).unwrap(); - assert_eq!(1, res.messages.len()); - assert_eq!(1, res.events.len()); - assert_eq!( - Event::new("ibc").add_attribute("channel", "connect"), - res.events[0] - ); - let id = res.messages[0].id; + assert_eq!(1, res.submessages.len()); + let id = res.submessages[0].id; // fake a reply and ensure this works let response = Reply { id, - result: ContractResult::Ok(SubMsgExecutionResponse { + result: ContractResult::Ok(SubcallResponse { events: fake_events(&account), data: None, }), @@ -411,14 +447,13 @@ mod tests { fn enforce_version_in_handshake() { let mut deps = setup(); - let wrong_order = mock_ibc_channel_open_try("channel-12", IbcOrder::Unordered, IBC_VERSION); + let wrong_order = mock_ibc_channel("channel-12", IbcOrder::Unordered, IBC_VERSION); ibc_channel_open(deps.as_mut(), mock_env(), wrong_order).unwrap_err(); - let wrong_version = mock_ibc_channel_open_try("channel-12", IbcOrder::Ordered, "reflect"); + let wrong_version = mock_ibc_channel("channel-12", IbcOrder::Ordered, "reflect"); ibc_channel_open(deps.as_mut(), mock_env(), wrong_version).unwrap_err(); - let valid_handshake = - mock_ibc_channel_open_try("channel-12", IbcOrder::Ordered, IBC_VERSION); + let valid_handshake = mock_ibc_channel("channel-12", IbcOrder::Ordered, IBC_VERSION); ibc_channel_open(deps.as_mut(), mock_env(), valid_handshake).unwrap(); } @@ -428,27 +463,27 @@ mod tests { let channel_id = "channel-1234"; // first we try to open with a valid handshake - let handshake_open = mock_ibc_channel_open_init(channel_id, IbcOrder::Ordered, IBC_VERSION); + let mut handshake_open = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); + handshake_open.counterparty_version = None; ibc_channel_open(deps.as_mut(), mock_env(), handshake_open).unwrap(); // then we connect (with counter-party version set) - let handshake_connect = - mock_ibc_channel_connect_ack(channel_id, IbcOrder::Ordered, IBC_VERSION); + let handshake_connect = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); let res = ibc_channel_connect(deps.as_mut(), mock_env(), handshake_connect).unwrap(); // and set up a reflect account - assert_eq!(1, res.messages.len()); - let id = res.messages[0].id; + assert_eq!(1, res.submessages.len()); + let id = res.submessages[0].id; if let CosmosMsg::Wasm(WasmMsg::Instantiate { admin, code_id, msg: _, - funds, + send, label, - }) = &res.messages[0].msg + }) = &res.submessages[0].msg { assert_eq!(*admin, None); assert_eq!(*code_id, REFLECT_ID); - assert_eq!(funds.len(), 0); + assert_eq!(send.len(), 0); assert!(label.contains(channel_id)); } else { panic!("invalid return message: {:?}", res.messages[0]); @@ -462,8 +497,8 @@ mod tests { // fake a reply and ensure this works let response = Reply { id, - result: ContractResult::Ok(SubMsgExecutionResponse { - events: fake_events(REFLECT_ADDR), + result: ContractResult::Ok(SubcallResponse { + events: fake_events(&REFLECT_ADDR), data: None, }), }; @@ -510,15 +545,10 @@ mod tests { let ibc_msg = PacketMsg::Dispatch { msgs: msgs_to_dispatch.clone(), }; - let msg = mock_ibc_packet_recv(channel_id, &ibc_msg).unwrap(); - let res = ibc_packet_receive(deps.as_mut(), mock_env(), msg).unwrap(); + let packet = mock_ibc_packet_recv(channel_id, &ibc_msg).unwrap(); + let res = ibc_packet_receive(deps.as_mut(), mock_env(), packet).unwrap(); // we didn't dispatch anything assert_eq!(0, res.messages.len()); - assert_eq!(1, res.events.len()); - assert_eq!( - Event::new("ibc").add_attribute("packet", "receive"), - res.events[0] - ); // acknowledgement is an error let ack: AcknowledgementMsg = from_slice(&res.acknowledgement).unwrap(); assert_eq!( @@ -530,28 +560,29 @@ mod tests { connect(deps.as_mut(), channel_id, account); // receive a packet for an unregistered channel returns app-level error (not Result::Err) - let msg = mock_ibc_packet_recv(channel_id, &ibc_msg).unwrap(); - let res = ibc_packet_receive(deps.as_mut(), mock_env(), msg).unwrap(); + let packet = mock_ibc_packet_recv(channel_id, &ibc_msg).unwrap(); + let res = ibc_packet_receive(deps.as_mut(), mock_env(), packet).unwrap(); // assert app-level success let ack: AcknowledgementMsg<()> = from_slice(&res.acknowledgement).unwrap(); ack.unwrap(); // and we dispatch the BankMsg via submessage - assert_eq!(1, res.messages.len()); - assert_eq!(RECEIVE_DISPATCH_ID, res.messages[0].id); + assert_eq!(0, res.messages.len()); + assert_eq!(1, res.submessages.len()); + assert_eq!(RECEIVE_DISPATCH_ID, res.submessages[0].id); // parse the output, ensuring it matches if let CosmosMsg::Wasm(WasmMsg::Execute { contract_addr, msg, - funds, - }) = &res.messages[0].msg + send, + }) = &res.submessages[0].msg { assert_eq!(account, contract_addr.as_str()); - assert_eq!(0, funds.len()); + assert_eq!(0, send.len()); // parse the message - should callback with proper channel_id - let rmsg: ReflectExecuteMsg = from_slice(msg).unwrap(); + let rmsg: ReflectExecuteMsg = from_slice(&msg).unwrap(); assert_eq!( rmsg, ReflectExecuteMsg::ReflectMsg { @@ -566,10 +597,10 @@ mod tests { let bad_data = InstantiateMsg { reflect_code_id: 12345, }; - let msg = mock_ibc_packet_recv(channel_id, &bad_data).unwrap(); - let res = ibc_packet_receive(deps.as_mut(), mock_env(), msg).unwrap(); + let packet = mock_ibc_packet_recv(channel_id, &bad_data).unwrap(); + let res = ibc_packet_receive(deps.as_mut(), mock_env(), packet).unwrap(); // we didn't dispatch anything - assert_eq!(0, res.messages.len()); + assert_eq!(0, res.submessages.len()); // acknowledgement is an error let ack: AcknowledgementMsg = from_slice(&res.acknowledgement).unwrap(); assert_eq!(ack.unwrap_err(), "invalid packet: Error parsing into type ibc_reflect::msg::PacketMsg: unknown variant `reflect_code_id`, expected one of `dispatch`, `who_am_i`, `balances`"); @@ -596,14 +627,14 @@ mod tests { assert_eq!(funds, balance); // close the channel - let channel = mock_ibc_channel_close_init(channel_id, IbcOrder::Ordered, IBC_VERSION); + let channel = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); let res = ibc_channel_close(deps.as_mut(), mock_env(), channel).unwrap(); // it pulls out all money from the reflect contract assert_eq!(1, res.messages.len()); if let CosmosMsg::Wasm(WasmMsg::Execute { contract_addr, msg, .. - }) = &res.messages[0].msg + }) = &res.messages[0] { assert_eq!(contract_addr.as_str(), account); let reflect: ReflectExecuteMsg = from_slice(msg).unwrap(); diff --git a/contracts/ibc-reflect/tests/integration.rs b/contracts/ibc-reflect/tests/integration.rs index 62a86eb2b..f01b1eaf9 100644 --- a/contracts/ibc-reflect/tests/integration.rs +++ b/contracts/ibc-reflect/tests/integration.rs @@ -17,17 +17,14 @@ //! }); //! 4. Anywhere you see query(&deps, ...) you must replace it with query(&mut deps, ...) -use cosmwasm_std::testing::{ - mock_ibc_channel_connect_ack, mock_ibc_channel_open_init, mock_ibc_channel_open_try, - mock_ibc_packet_recv, mock_wasmd_attr, -}; +use cosmwasm_std::testing::{mock_ibc_channel, mock_ibc_packet_recv}; use cosmwasm_std::{ attr, coins, BankMsg, ContractResult, CosmosMsg, Event, IbcBasicResponse, IbcOrder, - IbcReceiveResponse, Reply, Response, SubMsgExecutionResponse, WasmMsg, + IbcReceiveResponse, Reply, Response, SubcallResponse, WasmMsg, }; use cosmwasm_vm::testing::{ ibc_channel_connect, ibc_channel_open, ibc_packet_receive, instantiate, mock_env, mock_info, - mock_instance, query, reply, MockApi, MockQuerier, MockStorage, + mock_instance, query, reply, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR, }; use cosmwasm_vm::{from_slice, Instance}; @@ -46,8 +43,6 @@ const REFLECT_ID: u64 = 101; // address of first reflect contract instance that we created const REFLECT_ADDR: &str = "reflect-acct-1"; -const DESERIALIZATION_LIMIT: usize = 20_000; - fn setup() -> Instance { let mut deps = mock_instance(WASM, &[]); let msg = InstantiateMsg { @@ -60,42 +55,41 @@ fn setup() -> Instance { } fn fake_events(reflect_addr: &str) -> Vec { - let event = Event::new("instantiate").add_attributes(vec![ - attr("code_id", "17"), - // We have to force this one to avoid the debug assertion against _ - mock_wasmd_attr("_contract_address", reflect_addr), - ]); + let event = Event { + kind: "message".into(), + attributes: vec![ + attr("module", "wasm"), + attr("signer", MOCK_CONTRACT_ADDR), + attr("code_id", "17"), + attr("contract_address", reflect_addr), + ], + }; vec![event] } // connect will run through the entire handshake to set up a proper connect and // save the account (tested in detail in `proper_handshake_flow`) -fn connect( +fn connect>( deps: &mut Instance, channel_id: &str, - account: impl Into, + account: T, ) { let account: String = account.into(); // first we try to open with a valid handshake - let handshake_open = mock_ibc_channel_open_init(channel_id, IbcOrder::Ordered, IBC_VERSION); + let mut handshake_open = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); + handshake_open.counterparty_version = None; ibc_channel_open(deps, mock_env(), handshake_open).unwrap(); // then we connect (with counter-party version set) - let handshake_connect = - mock_ibc_channel_connect_ack(channel_id, IbcOrder::Ordered, IBC_VERSION); + let handshake_connect = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); let res: IbcBasicResponse = ibc_channel_connect(deps, mock_env(), handshake_connect).unwrap(); - assert_eq!(1, res.messages.len()); - assert_eq!(1, res.events.len()); - assert_eq!( - Event::new("ibc").add_attribute("channel", "connect"), - res.events[0] - ); - let id = res.messages[0].id; + assert_eq!(1, res.submessages.len()); + let id = res.submessages[0].id; // fake a reply and ensure this works let response = Reply { id, - result: ContractResult::Ok(SubMsgExecutionResponse { + result: ContractResult::Ok(SubcallResponse { events: fake_events(&account), data: None, }), @@ -120,13 +114,13 @@ fn instantiate_works() { fn enforce_version_in_handshake() { let mut deps = setup(); - let wrong_order = mock_ibc_channel_open_try("channel-1234", IbcOrder::Unordered, IBC_VERSION); + let wrong_order = mock_ibc_channel("channel-1234", IbcOrder::Unordered, IBC_VERSION); ibc_channel_open(&mut deps, mock_env(), wrong_order).unwrap_err(); - let wrong_version = mock_ibc_channel_open_try("channel-1234", IbcOrder::Ordered, "reflect"); + let wrong_version = mock_ibc_channel("channel-1234", IbcOrder::Ordered, "reflect"); ibc_channel_open(&mut deps, mock_env(), wrong_version).unwrap_err(); - let valid_handshake = mock_ibc_channel_open_try("channel-1234", IbcOrder::Ordered, IBC_VERSION); + let valid_handshake = mock_ibc_channel("channel-1234", IbcOrder::Ordered, IBC_VERSION); ibc_channel_open(&mut deps, mock_env(), valid_handshake).unwrap(); } @@ -136,28 +130,28 @@ fn proper_handshake_flow() { let channel_id = "channel-432"; // first we try to open with a valid handshake - let handshake_open = mock_ibc_channel_open_init(channel_id, IbcOrder::Ordered, IBC_VERSION); + let mut handshake_open = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); + handshake_open.counterparty_version = None; ibc_channel_open(&mut deps, mock_env(), handshake_open).unwrap(); // then we connect (with counter-party version set) - let handshake_connect = - mock_ibc_channel_connect_ack(channel_id, IbcOrder::Ordered, IBC_VERSION); + let handshake_connect = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); let res: IbcBasicResponse = ibc_channel_connect(&mut deps, mock_env(), handshake_connect).unwrap(); // and set up a reflect account - assert_eq!(1, res.messages.len()); - let id = res.messages[0].id; + assert_eq!(1, res.submessages.len()); + let id = res.submessages[0].id; if let CosmosMsg::Wasm(WasmMsg::Instantiate { admin, code_id, msg: _, - funds, + send, label, - }) = &res.messages[0].msg + }) = &res.submessages[0].msg { assert_eq!(*admin, None); assert_eq!(*code_id, REFLECT_ID); - assert_eq!(funds.len(), 0); + assert_eq!(send.len(), 0); assert!(label.contains(channel_id)); } else { panic!("invalid return message: {:?}", res.messages[0]); @@ -165,14 +159,14 @@ fn proper_handshake_flow() { // no accounts set yet let raw = query(&mut deps, mock_env(), QueryMsg::ListAccounts {}).unwrap(); - let res: ListAccountsResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: ListAccountsResponse = from_slice(&raw).unwrap(); assert_eq!(0, res.accounts.len()); // we get the callback from reflect let response = Reply { id, - result: ContractResult::Ok(SubMsgExecutionResponse { - events: fake_events(REFLECT_ADDR), + result: ContractResult::Ok(SubcallResponse { + events: fake_events(&REFLECT_ADDR), data: None, }), }; @@ -181,7 +175,7 @@ fn proper_handshake_flow() { // ensure this is now registered let raw = query(&mut deps, mock_env(), QueryMsg::ListAccounts {}).unwrap(); - let res: ListAccountsResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: ListAccountsResponse = from_slice(&raw).unwrap(); assert_eq!(1, res.accounts.len()); assert_eq!( &res.accounts[0], @@ -200,7 +194,7 @@ fn proper_handshake_flow() { }, ) .unwrap(); - let res: AccountResponse = from_slice(&raw, DESERIALIZATION_LIMIT).unwrap(); + let res: AccountResponse = from_slice(&raw).unwrap(); assert_eq!(res.account.unwrap(), REFLECT_ADDR); } @@ -220,18 +214,12 @@ fn handle_dispatch_packet() { let ibc_msg = PacketMsg::Dispatch { msgs: msgs_to_dispatch.clone(), }; - let msg = mock_ibc_packet_recv(channel_id, &ibc_msg).unwrap(); - let res: IbcReceiveResponse = ibc_packet_receive(&mut deps, mock_env(), msg).unwrap(); + let packet = mock_ibc_packet_recv(channel_id, &ibc_msg).unwrap(); + let res: IbcReceiveResponse = ibc_packet_receive(&mut deps, mock_env(), packet).unwrap(); // we didn't dispatch anything assert_eq!(0, res.messages.len()); - assert_eq!(1, res.events.len()); - assert_eq!( - Event::new("ibc").add_attribute("packet", "receive"), - res.events[0] - ); // acknowledgement is an error - let ack: AcknowledgementMsg = - from_slice(&res.acknowledgement, DESERIALIZATION_LIMIT).unwrap(); + let ack: AcknowledgementMsg = from_slice(&res.acknowledgement).unwrap(); assert_eq!( ack.unwrap_err(), "invalid packet: cosmwasm_std::addresses::Addr not found" @@ -241,29 +229,33 @@ fn handle_dispatch_packet() { connect(&mut deps, channel_id, account); // receive a packet for an unregistered channel returns app-level error (not Result::Err) - let msg = mock_ibc_packet_recv(channel_id, &ibc_msg).unwrap(); - let res: IbcReceiveResponse = ibc_packet_receive(&mut deps, mock_env(), msg).unwrap(); + let packet = mock_ibc_packet_recv(channel_id, &ibc_msg).unwrap(); + let res: IbcReceiveResponse = ibc_packet_receive(&mut deps, mock_env(), packet).unwrap(); + println!( + "{}", + String::from_utf8(res.acknowledgement.0.clone()).unwrap() + ); // assert app-level success - let ack: AcknowledgementMsg = - from_slice(&res.acknowledgement, DESERIALIZATION_LIMIT).unwrap(); + let ack: AcknowledgementMsg = from_slice(&res.acknowledgement).unwrap(); ack.unwrap(); // and we dispatch the BankMsg - assert_eq!(1, res.messages.len()); - assert_eq!(RECEIVE_DISPATCH_ID, res.messages[0].id); + assert_eq!(0, res.messages.len()); + assert_eq!(1, res.submessages.len()); + assert_eq!(RECEIVE_DISPATCH_ID, res.submessages[0].id); // parse the output, ensuring it matches if let CosmosMsg::Wasm(WasmMsg::Execute { contract_addr, msg, - funds, - }) = &res.messages[0].msg + send, + }) = &res.submessages[0].msg { assert_eq!(account, contract_addr.as_str()); - assert_eq!(0, funds.len()); + assert_eq!(0, send.len()); // parse the message - should callback with proper channel_id - let rmsg: ReflectExecuteMsg = from_slice(msg, DESERIALIZATION_LIMIT).unwrap(); + let rmsg: ReflectExecuteMsg = from_slice(&msg).unwrap(); assert_eq!( rmsg, ReflectExecuteMsg::ReflectMsg { @@ -278,12 +270,11 @@ fn handle_dispatch_packet() { let bad_data = InstantiateMsg { reflect_code_id: 12345, }; - let msg = mock_ibc_packet_recv(channel_id, &bad_data).unwrap(); - let res: IbcReceiveResponse = ibc_packet_receive(&mut deps, mock_env(), msg).unwrap(); + let packet = mock_ibc_packet_recv(channel_id, &bad_data).unwrap(); + let res: IbcReceiveResponse = ibc_packet_receive(&mut deps, mock_env(), packet).unwrap(); // we didn't dispatch anything - assert_eq!(0, res.messages.len()); + assert_eq!(0, res.submessages.len()); // acknowledgement is an error - let ack: AcknowledgementMsg = - from_slice(&res.acknowledgement, DESERIALIZATION_LIMIT).unwrap(); + let ack: AcknowledgementMsg = from_slice(&res.acknowledgement).unwrap(); assert_eq!(ack.unwrap_err(), "invalid packet: Error parsing into type ibc_reflect::msg::PacketMsg: unknown variant `reflect_code_id`, expected one of `dispatch`, `who_am_i`, `balances`"); } diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index b123e2ee5..5169e6ec7 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -42,10 +31,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -56,45 +45,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bincode" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "generic-array", + "serde", ] [[package]] -name = "bumpalo" -version = "3.8.0" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bytecheck" -version = "0.6.7" +name = "bitvec" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" dependencies = [ - "bytecheck_derive", - "ptr_meta", + "funty", + "radium", + "wyz", ] [[package]] -name = "bytecheck_derive" -version = "0.6.7" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "proc-macro2", - "quote", - "syn", + "generic-array", ] [[package]] @@ -109,6 +91,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -123,9 +111,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -165,7 +153,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -177,7 +164,6 @@ dependencies = [ "cosmwasm-crypto", "cosmwasm-std", "hex", - "loupe", "parity-wasm", "schemars", "serde", @@ -199,35 +185,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -235,21 +223,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -259,11 +250,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -272,7 +263,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -282,7 +273,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -293,7 +284,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -306,33 +297,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -353,9 +326,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -363,9 +336,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -377,9 +350,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -388,9 +361,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -433,16 +406,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -470,16 +442,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -513,11 +487,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -527,6 +502,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -543,7 +524,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -554,16 +535,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -578,12 +559,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -592,9 +573,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -613,9 +591,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -644,22 +622,13 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -679,17 +648,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -699,28 +668,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -738,6 +686,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -749,9 +706,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -784,20 +741,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "opaque-debug" @@ -819,12 +778,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -859,33 +817,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "queue" version = "0.0.0" @@ -906,6 +844,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1002,9 +946,9 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1021,40 +965,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1067,17 +977,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "schemars" @@ -1109,17 +1013,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "serde" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1144,9 +1042,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1182,7 +1080,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1195,7 +1093,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1203,12 +1101,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1217,27 +1115,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -1263,9 +1146,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1273,7 +1156,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1307,8 +1190,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1340,18 +1222,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1386,95 +1256,37 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1487,19 +1299,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1508,17 +1318,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1527,9 +1337,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1539,15 +1349,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1560,54 +1369,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1615,11 +1420,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1627,33 +1432,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1662,9 +1463,27 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wast" +version = "38.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +dependencies = [ + "wast", +] [[package]] name = "which" @@ -1699,6 +1518,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 322c02c43..3538f5381 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -42,10 +31,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -56,45 +45,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bincode" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "generic-array", + "serde", ] [[package]] -name = "bumpalo" -version = "3.8.0" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bytecheck" -version = "0.6.7" +name = "bitvec" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" dependencies = [ - "bytecheck_derive", - "ptr_meta", + "funty", + "radium", + "wyz", ] [[package]] -name = "bytecheck_derive" -version = "0.6.7" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "proc-macro2", - "quote", - "syn", + "generic-array", ] [[package]] @@ -109,6 +91,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -123,9 +111,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -165,7 +153,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -185,7 +172,6 @@ dependencies = [ "cosmwasm-crypto", "cosmwasm-std", "hex", - "loupe", "parity-wasm", "schemars", "serde", @@ -207,35 +193,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -243,21 +231,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -267,11 +258,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -280,7 +271,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -290,7 +281,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -301,7 +292,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -314,33 +305,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -361,9 +334,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -371,9 +344,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -385,9 +358,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -396,9 +369,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -441,16 +414,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -478,16 +450,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -521,11 +495,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -535,6 +510,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -551,7 +532,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -562,16 +543,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -586,12 +567,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -600,9 +581,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -621,9 +599,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -652,22 +630,13 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -687,17 +656,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -707,28 +676,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -746,6 +694,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -757,9 +714,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -792,20 +749,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "opaque-debug" @@ -827,12 +786,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -867,33 +825,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quote" version = "1.0.10" @@ -903,6 +841,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1012,9 +956,9 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1031,40 +975,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1077,17 +987,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "schemars" @@ -1119,12 +1023,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "serde" version = "1.0.103" @@ -1192,7 +1090,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1205,7 +1103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1213,12 +1111,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1227,27 +1125,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -1273,9 +1156,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1283,7 +1166,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1317,8 +1200,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1350,18 +1232,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1396,95 +1266,37 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1497,19 +1309,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1518,17 +1328,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1537,9 +1347,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1549,15 +1359,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1570,54 +1379,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1625,11 +1430,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1637,33 +1442,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1672,9 +1473,27 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wast" +version = "38.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +dependencies = [ + "wast", +] [[package]] name = "which" @@ -1709,6 +1528,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/contracts/reflect/Cargo.toml b/contracts/reflect/Cargo.toml index e27f769e7..3025d4902 100644 --- a/contracts/reflect/Cargo.toml +++ b/contracts/reflect/Cargo.toml @@ -33,8 +33,8 @@ cranelift = ["cosmwasm-vm/cranelift"] backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] -cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["staking", "stargate"] } -cosmwasm-storage = { path = "../../packages/storage", default-features = false } +cosmwasm-std = { path = "../../packages/std", features = ["staking", "stargate"] } +cosmwasm-storage = { path = "../../packages/storage" } schemars = "0.8.1" serde = { version = "=1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0" diff --git a/contracts/reflect/schema/execute_msg.json b/contracts/reflect/schema/execute_msg.json index f3312f64f..6742ea18e 100644 --- a/contracts/reflect/schema/execute_msg.json +++ b/contracts/reflect/schema/execute_msg.json @@ -28,10 +28,10 @@ { "type": "object", "required": [ - "reflect_sub_msg" + "reflect_sub_call" ], "properties": { - "reflect_sub_msg": { + "reflect_sub_call": { "type": "object", "required": [ "msgs" @@ -244,18 +244,6 @@ } }, "additionalProperties": false - }, - { - "type": "object", - "required": [ - "gov" - ], - "properties": { - "gov": { - "$ref": "#/definitions/GovMsg" - } - }, - "additionalProperties": false } ] }, @@ -337,37 +325,6 @@ } ] }, - "GovMsg": { - "oneOf": [ - { - "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "vote" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "vote": { - "$ref": "#/definitions/VoteOption" - } - } - } - }, - "additionalProperties": false - } - ] - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -527,8 +484,7 @@ "enum": [ "always", "error", - "success", - "never" + "success" ] }, "StakingMsg": { @@ -616,7 +572,7 @@ ] }, "SubMsg_for_CustomMsg": { - "description": "A submessage that will guarantee a `reply` call on success or error, depending on the `reply_on` setting. If you do not need to process the result, use regular messages instead.\n\nNote: On error the submessage execution will revert any partial state changes due to this message, but not revert any state changes in the calling contract. If this is required, it must be done manually in the `reply` entry point.", + "description": "A sub-message that will guarantee a subcall_response callback on success or error Note on error the subcall will revert any partial state changes due to this message, but not revert any state changes in the calling contract (that must be done in the subcall_response entry point)", "type": "object", "required": [ "id", @@ -633,7 +589,6 @@ "minimum": 0.0 }, "id": { - "description": "An arbitrary ID chosen by the contract. This is typically used to match `Reply`s in the `reply` entry point to the submessage.", "type": "integer", "format": "uint64", "minimum": 0.0 @@ -647,7 +602,7 @@ } }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", "allOf": [ { "$ref": "#/definitions/Uint64" @@ -662,15 +617,6 @@ "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, - "VoteOption": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "no_with_veto" - ] - }, "WasmMsg": { "description": "The message types of the wasm module.\n\nSee https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/types/tx.proto.", "oneOf": [ @@ -685,19 +631,13 @@ "type": "object", "required": [ "contract_addr", - "funds", - "msg" + "msg", + "send" ], "properties": { "contract_addr": { "type": "string" }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -705,6 +645,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } @@ -722,9 +668,9 @@ "type": "object", "required": [ "code_id", - "funds", "label", - "msg" + "msg", + "send" ], "properties": { "admin": { @@ -738,12 +684,6 @@ "format": "uint64", "minimum": 0.0 }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -755,6 +695,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } diff --git a/contracts/reflect/schema/query_msg.json b/contracts/reflect/schema/query_msg.json index a4d08a1f0..b9d9ba3ab 100644 --- a/contracts/reflect/schema/query_msg.json +++ b/contracts/reflect/schema/query_msg.json @@ -82,13 +82,13 @@ "additionalProperties": false }, { - "description": "If there was a previous ReflectSubMsg with this ID, returns cosmwasm_std::Reply", + "description": "If there was a previous ReflectSubCall with this ID, returns cosmwasm_std::Reply", "type": "object", "required": [ - "sub_msg_result" + "sub_call_result" ], "properties": { - "sub_msg_result": { + "sub_call_result": { "type": "object", "required": [ "id" diff --git a/contracts/reflect/schema/response_for__custom_msg.json b/contracts/reflect/schema/response_for__custom_msg.json index 89586a709..f8b570490 100644 --- a/contracts/reflect/schema/response_for__custom_msg.json +++ b/contracts/reflect/schema/response_for__custom_msg.json @@ -1,23 +1,22 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Response_for_CustomMsg", - "description": "A response of a contract entry point, such as `instantiate`, `execute` or `migrate`.\n\nThis type can be constructed directly at the end of the call. Alternatively a mutable response instance can be created early in the contract's logic and incrementally be updated.\n\n## Examples\n\nDirect:\n\n``` # use cosmwasm_std::{Binary, DepsMut, Env, MessageInfo}; # type InstantiateMsg = (); # use cosmwasm_std::{attr, Response, StdResult};\n\npub fn instantiate( deps: DepsMut, _env: Env, _info: MessageInfo, msg: InstantiateMsg, ) -> StdResult { // ...\n\nOk(Response::new().add_attribute(\"action\", \"instantiate\")) } ```\n\nMutating:\n\n``` # use cosmwasm_std::{coins, BankMsg, Binary, DepsMut, Env, MessageInfo, SubMsg}; # type InstantiateMsg = (); # type MyError = (); # use cosmwasm_std::Response;\n\npub fn instantiate( deps: DepsMut, _env: Env, info: MessageInfo, msg: InstantiateMsg, ) -> Result { let mut response = Response::new() .add_attribute(\"Let the\", \"hacking begin\") .add_message(BankMsg::Send { to_address: String::from(\"recipient\"), amount: coins(128, \"uint\"), }) .add_attribute(\"foo\", \"bar\") .set_data(b\"the result data\"); Ok(response) } ```", + "description": "A response of a contract entry point, such as `instantiate`, `execute` or `migrate`.\n\nThis type can be constructed directly at the end of the call. Alternatively a mutable response instance can be created early in the contract's logic and incrementally be updated.\n\n## Examples\n\nDirect:\n\n``` # use cosmwasm_std::{Binary, DepsMut, Env, MessageInfo}; # type InstantiateMsg = (); # use cosmwasm_std::{attr, Response, StdResult};\n\npub fn instantiate( deps: DepsMut, _env: Env, _info: MessageInfo, msg: InstantiateMsg, ) -> StdResult { // ...\n\nOk(Response { submessages: vec![], messages: vec![], attributes: vec![attr(\"action\", \"instantiate\")], data: None, }) } ```\n\nMutating:\n\n``` # use cosmwasm_std::{coins, BankMsg, Binary, DepsMut, Env, MessageInfo}; # type InstantiateMsg = (); # type MyError = (); # use cosmwasm_std::Response;\n\npub fn instantiate( deps: DepsMut, _env: Env, info: MessageInfo, msg: InstantiateMsg, ) -> Result { let mut response = Response::new(); // ... response.add_attribute(\"Let the\", \"hacking begin\"); // ... response.add_message(BankMsg::Send { to_address: String::from(\"recipient\"), amount: coins(128, \"uint\"), }); response.add_attribute(\"foo\", \"bar\"); // ... response.set_data(Binary::from(b\"the result data\")); Ok(response) } ```", "type": "object", "required": [ "attributes", - "events", - "messages" + "messages", + "submessages" ], "properties": { "attributes": { - "description": "The attributes that will be emitted as part of a \"wasm\" event.\n\nMore info about events (and their attributes) can be found in [*Cosmos SDK* docs].\n\n[*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html", + "description": "The attributes that will be emitted as part of a \"wasm\" event", "type": "array", "items": { "$ref": "#/definitions/Attribute" } }, "data": { - "description": "The binary payload to include in the response.", "anyOf": [ { "$ref": "#/definitions/Binary" @@ -27,15 +26,15 @@ } ] }, - "events": { - "description": "Extra, custom events separate from the main `wasm` one. These will have `wasm-` prepended to the type.\n\nMore info about events can be found in [*Cosmos SDK* docs].\n\n[*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html", + "messages": { + "description": "After any submessages are processed, these are all dispatched in the host blockchain. If they all succeed, then the transaction is committed. If any fail, then the transaction and any local contract state changes are reverted.", "type": "array", "items": { - "$ref": "#/definitions/Event" + "$ref": "#/definitions/CosmosMsg_for_CustomMsg" } }, - "messages": { - "description": "Optional list of messages to pass. These will be executed in order. If the ReplyOn variant matches the result (Always, Success on Ok, Error on Err), the runtime will invoke this contract's `reply` entry point after execution. Otherwise, they act like \"fire and forget\". Use `SubMsg::new` to create messages with the older \"fire and forget\" semantics.", + "submessages": { + "description": "Optional list of \"subcalls\" to make. These will be executed in order (and this contract's subcall_response entry point invoked) *before* any of the \"fire and forget\" messages get executed.", "type": "array", "items": { "$ref": "#/definitions/SubMsg_for_CustomMsg" @@ -233,18 +232,6 @@ } }, "additionalProperties": false - }, - { - "type": "object", - "required": [ - "gov" - ], - "properties": { - "gov": { - "$ref": "#/definitions/GovMsg" - } - }, - "additionalProperties": false } ] }, @@ -326,58 +313,6 @@ } ] }, - "Event": { - "description": "A full [*Cosmos SDK* event].\n\nThis version uses string attributes (similar to [*Cosmos SDK* StringEvent]), which then get magically converted to bytes for Tendermint somewhere between the Rust-Go interface, JSON deserialization and the `NewEvent` call in Cosmos SDK.\n\n[*Cosmos SDK* event]: https://docs.cosmos.network/v0.42/core/events.html [*Cosmos SDK* StringEvent]: https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/base/abci/v1beta1/abci.proto#L56-L70", - "type": "object", - "required": [ - "attributes", - "type" - ], - "properties": { - "attributes": { - "description": "The attributes to be included in the event.\n\nYou can learn more about these from [*Cosmos SDK* docs].\n\n[*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html", - "type": "array", - "items": { - "$ref": "#/definitions/Attribute" - } - }, - "type": { - "description": "The event type. This is renamed to \"ty\" because \"type\" is reserved in Rust. This sucks, we know.", - "type": "string" - } - } - }, - "GovMsg": { - "oneOf": [ - { - "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "vote" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "vote": { - "$ref": "#/definitions/VoteOption" - } - } - } - }, - "additionalProperties": false - } - ] - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -537,8 +472,7 @@ "enum": [ "always", "error", - "success", - "never" + "success" ] }, "StakingMsg": { @@ -626,7 +560,7 @@ ] }, "SubMsg_for_CustomMsg": { - "description": "A submessage that will guarantee a `reply` call on success or error, depending on the `reply_on` setting. If you do not need to process the result, use regular messages instead.\n\nNote: On error the submessage execution will revert any partial state changes due to this message, but not revert any state changes in the calling contract. If this is required, it must be done manually in the `reply` entry point.", + "description": "A sub-message that will guarantee a subcall_response callback on success or error Note on error the subcall will revert any partial state changes due to this message, but not revert any state changes in the calling contract (that must be done in the subcall_response entry point)", "type": "object", "required": [ "id", @@ -643,7 +577,6 @@ "minimum": 0.0 }, "id": { - "description": "An arbitrary ID chosen by the contract. This is typically used to match `Reply`s in the `reply` entry point to the submessage.", "type": "integer", "format": "uint64", "minimum": 0.0 @@ -657,7 +590,7 @@ } }, "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", "allOf": [ { "$ref": "#/definitions/Uint64" @@ -672,15 +605,6 @@ "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, - "VoteOption": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "no_with_veto" - ] - }, "WasmMsg": { "description": "The message types of the wasm module.\n\nSee https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/types/tx.proto.", "oneOf": [ @@ -695,19 +619,13 @@ "type": "object", "required": [ "contract_addr", - "funds", - "msg" + "msg", + "send" ], "properties": { "contract_addr": { "type": "string" }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -715,6 +633,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } @@ -732,9 +656,9 @@ "type": "object", "required": [ "code_id", - "funds", "label", - "msg" + "msg", + "send" ], "properties": { "admin": { @@ -748,12 +672,6 @@ "format": "uint64", "minimum": 0.0 }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -765,6 +683,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs index 02bfa51d8..c40bbc1d3 100644 --- a/contracts/reflect/src/contract.rs +++ b/contracts/reflect/src/contract.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{ - entry_point, to_binary, to_vec, Binary, ContractResult, CosmosMsg, Deps, DepsMut, Env, + attr, entry_point, to_binary, to_vec, Binary, ContractResult, CosmosMsg, Deps, DepsMut, Env, MessageInfo, QueryRequest, QueryResponse, Reply, Response, StdError, StdResult, SubMsg, SystemResult, }; @@ -30,7 +30,7 @@ pub fn execute( ) -> Result, ReflectError> { match msg { ExecuteMsg::ReflectMsg { msgs } => try_reflect(deps, env, info, msgs), - ExecuteMsg::ReflectSubMsg { msgs } => try_reflect_subcall(deps, env, info, msgs), + ExecuteMsg::ReflectSubCall { msgs } => try_reflect_subcall(deps, env, info, msgs), ExecuteMsg::ChangeOwner { owner } => try_change_owner(deps, env, info, owner), } } @@ -53,10 +53,13 @@ pub fn try_reflect( if msgs.is_empty() { return Err(ReflectError::MessagesEmpty); } - - Ok(Response::new() - .add_attribute("action", "reflect") - .add_messages(msgs)) + let res = Response { + submessages: vec![], + messages: msgs, + attributes: vec![attr("action", "reflect")], + data: None, + }; + Ok(res) } pub fn try_reflect_subcall( @@ -76,10 +79,13 @@ pub fn try_reflect_subcall( if msgs.is_empty() { return Err(ReflectError::MessagesEmpty); } - - Ok(Response::new() - .add_attribute("action", "reflect_subcall") - .add_submessages(msgs)) + let res = Response { + submessages: msgs, + messages: vec![], + attributes: vec![attr("action", "reflect_subcall")], + data: None, + }; + Ok(res) } pub fn try_change_owner( @@ -99,9 +105,10 @@ pub fn try_change_owner( state.owner = api.addr_validate(&new_owner)?; Ok(state) })?; - Ok(Response::new() - .add_attribute("action", "change_owner") - .add_attribute("owner", new_owner)) + Ok(Response { + attributes: vec![attr("action", "change_owner"), attr("owner", new_owner)], + ..Response::default() + }) } /// This just stores the result for future query @@ -118,7 +125,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { QueryMsg::Capitalized { text } => to_binary(&query_capitalized(deps, text)?), QueryMsg::Chain { request } => to_binary(&query_chain(deps, &request)?), QueryMsg::Raw { contract, key } => to_binary(&query_raw(deps, contract, key)?), - QueryMsg::SubMsgResult { id } => to_binary(&query_subcall(deps, id)?), + QueryMsg::SubCallResult { id } => to_binary(&query_subcall(deps, id)?), } } @@ -172,7 +179,7 @@ mod tests { use cosmwasm_std::testing::{mock_env, mock_info, MOCK_CONTRACT_ADDR}; use cosmwasm_std::{ coin, coins, from_binary, AllBalanceResponse, BankMsg, BankQuery, Binary, ContractResult, - Event, StakingMsg, StdError, SubMsgExecutionResponse, + Event, ReplyOn, StakingMsg, StdError, SubcallResponse, }; #[test] @@ -210,7 +217,6 @@ mod tests { }; let info = mock_info("creator", &[]); let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - let payload: Vec<_> = payload.into_iter().map(SubMsg::new).collect(); assert_eq!(payload, res.messages); } @@ -283,7 +289,6 @@ mod tests { }; let info = mock_info("creator", &[]); let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - let payload: Vec<_> = payload.into_iter().map(SubMsg::new).collect(); assert_eq!(payload, res.messages); } @@ -399,22 +404,26 @@ mod tests { let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); let id = 123u64; - let payload = SubMsg::reply_always( - BankMsg::Send { + let payload = SubMsg { + id, + gas_limit: None, + msg: BankMsg::Send { to_address: String::from("friend"), amount: coins(1, "token"), - }, - id, - ); + } + .into(), + reply_on: ReplyOn::default(), + }; - let msg = ExecuteMsg::ReflectSubMsg { + let msg = ExecuteMsg::ReflectSubCall { msgs: vec![payload.clone()], }; let info = mock_info("creator", &[]); let mut res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(1, res.messages.len()); - let msg = res.messages.pop().expect("must have a message"); - assert_eq!(payload, msg); + assert_eq!(0, res.messages.len()); + assert_eq!(1, res.submessages.len()); + let submsg = res.submessages.pop().expect("must have a submessage"); + assert_eq!(payload, submsg); } // this mocks out what happens after reflect_subcall @@ -428,8 +437,8 @@ mod tests { let id = 123u64; let data = Binary::from(b"foobar"); - let events = vec![Event::new("message").add_attribute("signer", "caller-addr")]; - let result = ContractResult::Ok(SubMsgExecutionResponse { + let events = vec![Event::new("message", vec![attr("signer", "caller-addr")])]; + let result = ContractResult::Ok(SubcallResponse { events: events.clone(), data: Some(data.clone()), }); @@ -441,12 +450,12 @@ mod tests { let qres = query( deps.as_ref(), mock_env(), - QueryMsg::SubMsgResult { id: 65432 }, + QueryMsg::SubCallResult { id: 65432 }, ); assert!(qres.is_err()); // query for the real id - let raw = query(deps.as_ref(), mock_env(), QueryMsg::SubMsgResult { id }).unwrap(); + let raw = query(deps.as_ref(), mock_env(), QueryMsg::SubCallResult { id }).unwrap(); let qres: Reply = from_binary(&raw).unwrap(); assert_eq!(qres.id, id); let result = qres.result.unwrap(); diff --git a/contracts/reflect/src/msg.rs b/contracts/reflect/src/msg.rs index 6098e8568..f3c488822 100644 --- a/contracts/reflect/src/msg.rs +++ b/contracts/reflect/src/msg.rs @@ -10,7 +10,7 @@ pub struct InstantiateMsg {} #[serde(rename_all = "snake_case")] pub enum ExecuteMsg { ReflectMsg { msgs: Vec> }, - ReflectSubMsg { msgs: Vec> }, + ReflectSubCall { msgs: Vec> }, ChangeOwner { owner: String }, } @@ -31,8 +31,8 @@ pub enum QueryMsg { contract: String, key: Binary, }, - /// If there was a previous ReflectSubMsg with this ID, returns cosmwasm_std::Reply - SubMsgResult { + /// If there was a previous ReflectSubCall with this ID, returns cosmwasm_std::Reply + SubCallResult { id: u64, }, } diff --git a/contracts/reflect/src/testing.rs b/contracts/reflect/src/testing.rs index 8237329b1..32ccedaaf 100644 --- a/contracts/reflect/src/testing.rs +++ b/contracts/reflect/src/testing.rs @@ -10,7 +10,7 @@ pub fn mock_dependencies_with_custom_querier( ) -> OwnedDeps> { let custom_querier: MockQuerier = MockQuerier::new(&[(MOCK_CONTRACT_ADDR, contract_balance)]) - .with_custom_handler(|query| SystemResult::Ok(custom_query_execute(query))); + .with_custom_handler(|query| SystemResult::Ok(custom_query_execute(&query))); OwnedDeps { storage: MockStorage::default(), api: MockApi::default(), diff --git a/contracts/reflect/tests/integration.rs b/contracts/reflect/tests/integration.rs index 90b6d9d53..63cc8eb85 100644 --- a/contracts/reflect/tests/integration.rs +++ b/contracts/reflect/tests/integration.rs @@ -18,8 +18,8 @@ //! 4. Anywhere you see query(&deps, ...) you must replace it with query(&mut deps, ...) use cosmwasm_std::{ - coin, coins, from_binary, BankMsg, Binary, Coin, ContractResult, Event, Reply, Response, - StakingMsg, SubMsg, SubMsgExecutionResponse, SystemResult, + attr, coin, coins, from_binary, BankMsg, Binary, Coin, ContractResult, Event, Reply, Response, + StakingMsg, SubMsg, SubcallResponse, SystemResult, }; use cosmwasm_vm::{ testing::{ @@ -103,7 +103,6 @@ fn reflect() { let res: Response = execute(&mut deps, mock_env(), info, msg).unwrap(); // should return payload - let payload: Vec<_> = payload.into_iter().map(SubMsg::new).collect(); assert_eq!(payload, res.messages); } @@ -196,22 +195,26 @@ fn reflect_subcall() { let _res: Response = instantiate(&mut deps, mock_env(), info, msg).unwrap(); let id = 123u64; - let payload = SubMsg::reply_always( - BankMsg::Send { + let payload = SubMsg { + id, + gas_limit: None, + msg: BankMsg::Send { to_address: String::from("friend"), amount: coins(1, "token"), - }, - id, - ); + } + .into(), + reply_on: Default::default(), + }; - let msg = ExecuteMsg::ReflectSubMsg { + let msg = ExecuteMsg::ReflectSubCall { msgs: vec![payload.clone()], }; let info = mock_info("creator", &[]); let mut res: Response = execute(&mut deps, mock_env(), info, msg).unwrap(); - assert_eq!(1, res.messages.len()); - let msg = res.messages.pop().expect("must have a message"); - assert_eq!(payload, msg); + assert_eq!(0, res.messages.len()); + assert_eq!(1, res.submessages.len()); + let submsg = res.submessages.pop().expect("must have a submessage"); + assert_eq!(payload, submsg); } // this mocks out what happens after reflect_subcall @@ -225,8 +228,8 @@ fn reply_and_query() { let id = 123u64; let data = Binary::from(b"foobar"); - let events = vec![Event::new("message").add_attribute("signer", "caller-addr")]; - let result = ContractResult::Ok(SubMsgExecutionResponse { + let events = vec![Event::new("message", vec![attr("signer", "caller-addr")])]; + let result = ContractResult::Ok(SubcallResponse { events: events.clone(), data: Some(data.clone()), }); @@ -235,11 +238,11 @@ fn reply_and_query() { assert_eq!(0, res.messages.len()); // query for a non-existant id - let qres = query(&mut deps, mock_env(), QueryMsg::SubMsgResult { id: 65432 }); + let qres = query(&mut deps, mock_env(), QueryMsg::SubCallResult { id: 65432 }); assert!(qres.is_err()); // query for the real id - let raw = query(&mut deps, mock_env(), QueryMsg::SubMsgResult { id }).unwrap(); + let raw = query(&mut deps, mock_env(), QueryMsg::SubCallResult { id }).unwrap(); let qres: Reply = from_binary(&raw).unwrap(); assert_eq!(qres.id, id); let result = qres.result.unwrap(); diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 1dd40338e..da8a3a9c6 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -42,10 +31,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -56,45 +45,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bincode" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "generic-array", + "serde", ] [[package]] -name = "bumpalo" -version = "3.8.0" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bytecheck" -version = "0.6.7" +name = "bitvec" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" dependencies = [ - "bytecheck_derive", - "ptr_meta", + "funty", + "radium", + "wyz", ] [[package]] -name = "bytecheck_derive" -version = "0.6.7" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "proc-macro2", - "quote", - "syn", + "generic-array", ] [[package]] @@ -109,6 +91,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -123,9 +111,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -165,7 +153,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -185,7 +172,6 @@ dependencies = [ "cosmwasm-crypto", "cosmwasm-std", "hex", - "loupe", "parity-wasm", "schemars", "serde", @@ -207,35 +193,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -243,21 +231,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -267,11 +258,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -280,7 +271,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -290,7 +281,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -301,7 +292,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -314,33 +305,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -361,9 +334,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -371,9 +344,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -385,9 +358,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -396,9 +369,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -447,16 +420,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -484,16 +456,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -527,11 +501,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -541,6 +516,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -557,7 +538,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -568,16 +549,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -592,12 +573,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -606,9 +587,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -627,9 +605,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -658,22 +636,13 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -693,17 +662,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -713,28 +682,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -752,6 +700,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -763,9 +720,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -798,20 +755,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "opaque-debug" @@ -833,12 +792,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -873,33 +831,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quote" version = "1.0.10" @@ -909,6 +847,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1005,9 +949,9 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1024,40 +968,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1070,17 +980,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "schemars" @@ -1112,17 +1016,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "serde" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1147,9 +1045,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1185,7 +1083,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1198,7 +1096,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1206,12 +1104,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1241,15 +1139,6 @@ dependencies = [ "syn", ] -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -1269,12 +1158,6 @@ dependencies = [ "snafu", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -1300,9 +1183,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1310,7 +1193,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1344,8 +1227,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1377,18 +1259,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1423,95 +1293,37 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1524,19 +1336,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1545,17 +1355,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1564,9 +1374,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1576,15 +1386,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1597,54 +1406,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1652,11 +1457,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1664,33 +1469,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1699,9 +1500,27 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wast" +version = "38.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +dependencies = [ + "wast", +] [[package]] name = "which" @@ -1736,6 +1555,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/contracts/staking/Cargo.toml b/contracts/staking/Cargo.toml index ef30e1f7b..30aa8a5d5 100644 --- a/contracts/staking/Cargo.toml +++ b/contracts/staking/Cargo.toml @@ -31,8 +31,8 @@ cranelift = ["cosmwasm-vm/cranelift"] backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] -cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["staking"] } -cosmwasm-storage = { path = "../../packages/storage", default-features = false } +cosmwasm-std = { path = "../../packages/std", features = ["staking"] } +cosmwasm-storage = { path = "../../packages/storage" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } snafu = "0.6" diff --git a/contracts/staking/src/contract.rs b/contracts/staking/src/contract.rs index 99849ce1f..44224438a 100644 --- a/contracts/staking/src/contract.rs +++ b/contracts/staking/src/contract.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{ - coin, entry_point, to_binary, BankMsg, Decimal, Deps, DepsMut, DistributionMsg, Env, + attr, coin, entry_point, to_binary, BankMsg, Decimal, Deps, DepsMut, DistributionMsg, Env, MessageInfo, QuerierWrapper, QueryResponse, Response, StakingMsg, StdError, StdResult, Uint128, WasmMsg, }; @@ -93,23 +93,29 @@ pub fn transfer( Ok(balance.unwrap_or_default() + send) })?; - let res = Response::new() - .add_attribute("action", "transfer") - .add_attribute("from", info.sender) - .add_attribute("to", recipient) - .add_attribute("amount", send.to_string()); + let res = Response { + submessages: vec![], + messages: vec![], + attributes: vec![ + attr("action", "transfer"), + attr("from", info.sender), + attr("to", recipient), + attr("amount", send), + ], + data: None, + }; Ok(res) } // get_bonded returns the total amount of delegations from contract // it ensures they are all the same denom -fn get_bonded(querier: &QuerierWrapper, contract_addr: impl Into) -> StdResult { +fn get_bonded>(querier: &QuerierWrapper, contract_addr: U) -> StdResult { let bonds = querier.query_all_delegations(contract_addr)?; if bonds.is_empty() { - return Ok(Uint128::new(0)); + return Ok(Uint128(0)); } let denom = bonds[0].amount.denom.as_str(); - bonds.iter().fold(Ok(Uint128::new(0)), |racc, d| { + bonds.iter().fold(Ok(Uint128(0)), |racc, d| { let acc = racc?; if d.amount.denom.as_str() != denom { Err(StdError::generic_err(format!( @@ -168,15 +174,21 @@ pub fn bond(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult { })?; // bond them to the validator - let res = Response::new() - .add_attribute("action", "bond") - .add_attribute("from", info.sender) - .add_attribute("bonded", payment.amount) - .add_attribute("minted", to_mint) - .add_message(StakingMsg::Delegate { + let res = Response { + submessages: vec![], + messages: vec![StakingMsg::Delegate { validator: invest.validator, amount: payment.clone(), - }); + } + .into()], + attributes: vec![ + attr("action", "bond"), + attr("from", info.sender), + attr("bonded", payment.amount), + attr("minted", to_mint), + ], + data: None, + }; Ok(res) } @@ -201,7 +213,7 @@ pub fn unbond(deps: DepsMut, env: Env, info: MessageInfo, amount: Uint128) -> St accounts.update(&sender_raw, |balance| -> StdResult<_> { Ok(balance.unwrap_or_default().checked_sub(amount)?) })?; - if tax > Uint128::new(0) { + if tax > Uint128(0) { // add tax to the owner accounts.update(&owner_raw, |balance: Option| -> StdResult<_> { Ok(balance.unwrap_or_default() + tax) @@ -230,15 +242,21 @@ pub fn unbond(deps: DepsMut, env: Env, info: MessageInfo, amount: Uint128) -> St })?; // unbond them - let res = Response::new() - .add_attribute("action", "unbond") - .add_attribute("to", info.sender) - .add_attribute("unbonded", unbond) - .add_attribute("burnt", amount) - .add_message(StakingMsg::Undelegate { + let res = Response { + submessages: vec![], + messages: vec![StakingMsg::Undelegate { validator: invest.validator, amount: coin(unbond.u128(), &invest.bond_denom), - }); + } + .into()], + attributes: vec![ + attr("action", "unbond"), + attr("to", info.sender), + attr("unbonded", unbond), + attr("burnt", amount), + ], + data: None, + }; Ok(res) } @@ -271,14 +289,20 @@ pub fn claim(deps: DepsMut, env: Env, info: MessageInfo) -> StdResult // transfer tokens to the sender balance.amount = to_send; - let res = Response::new() - .add_attribute("action", "claim") - .add_attribute("from", &info.sender) - .add_attribute("amount", to_send) - .add_message(BankMsg::Send { - to_address: info.sender.into(), + let res = Response { + submessages: vec![], + messages: vec![BankMsg::Send { + to_address: info.sender.clone().into(), amount: vec![balance], - }); + } + .into()], + attributes: vec![ + attr("action", "claim"), + attr("from", info.sender), + attr("amount", to_send), + ], + data: None, + }; Ok(res) } @@ -291,15 +315,23 @@ pub fn reinvest(deps: DepsMut, env: Env, _info: MessageInfo) -> StdResult { assert_eq!(validator.as_str(), DEFAULT_VALIDATOR); @@ -576,11 +611,11 @@ mod tests { } // bob got 1000 DRV for 1000 stake at a 1.0 ratio - assert_eq!(get_balance(deps.as_ref(), &bob), Uint128::new(1000)); + assert_eq!(get_balance(deps.as_ref(), &bob), Uint128(1000)); // investment info correct (updated supply) let invest = query_investment(deps.as_ref()).unwrap(); - assert_eq!(invest.token_supply, Uint128::new(1000)); + assert_eq!(invest.token_supply, Uint128(1000)); assert_eq!(invest.staked_tokens, coin(1000, "ustake")); assert_eq!(invest.nominal_value, Decimal::one()); } @@ -620,7 +655,7 @@ mod tests { // we should now see 1000 issues and 1500 bonded (and a price of 1.5) let invest = query_investment(deps.as_ref()).unwrap(); - assert_eq!(invest.token_supply, Uint128::new(1000)); + assert_eq!(invest.token_supply, Uint128(1000)); assert_eq!(invest.staked_tokens, coin(1500, "ustake")); let ratio = Decimal::from_str("1.5").unwrap(); assert_eq!(invest.nominal_value, ratio); @@ -636,10 +671,10 @@ mod tests { set_delegation(&mut deps.querier, 3000, "ustake"); // alice should have gotten 2000 DRV for the 3000 stake, keeping the ratio at 1.5 - assert_eq!(get_balance(deps.as_ref(), &alice), Uint128::new(2000)); + assert_eq!(get_balance(deps.as_ref(), &alice), Uint128(2000)); let invest = query_investment(deps.as_ref()).unwrap(); - assert_eq!(invest.token_supply, Uint128::new(3000)); + assert_eq!(invest.token_supply, Uint128(3000)); assert_eq!(invest.staked_tokens, coin(4500, "ustake")); assert_eq!(invest.nominal_value, ratio); } @@ -709,7 +744,7 @@ mod tests { // creator now tries to unbond these tokens - this must fail let unbond_msg = ExecuteMsg::Unbond { - amount: Uint128::new(600), + amount: Uint128(600), }; let info = mock_info(&creator, &[]); let res = execute(deps.as_mut(), mock_env(), info, unbond_msg); @@ -724,15 +759,15 @@ mod tests { // 60 are taken and send to the owner // 540 are unbonded in exchange for 540 * 1.5 = 810 native tokens let unbond_msg = ExecuteMsg::Unbond { - amount: Uint128::new(600), + amount: Uint128(600), }; - let owner_cut = Uint128::new(60); - let bobs_claim = Uint128::new(810); - let bobs_balance = Uint128::new(400); + let owner_cut = Uint128(60); + let bobs_claim = Uint128(810); + let bobs_balance = Uint128(400); let info = mock_info(&bob, &[]); let res = execute(deps.as_mut(), mock_env(), info, unbond_msg).unwrap(); assert_eq!(1, res.messages.len()); - let delegate = &res.messages[0].msg; + let delegate = &res.messages[0]; match delegate { CosmosMsg::Staking(StakingMsg::Undelegate { validator, amount }) => { assert_eq!(validator.as_str(), DEFAULT_VALIDATOR); diff --git a/contracts/staking/tests/integration.rs b/contracts/staking/tests/integration.rs index c638be08f..f908d62e1 100644 --- a/contracts/staking/tests/integration.rs +++ b/contracts/staking/tests/integration.rs @@ -58,7 +58,7 @@ fn initialization_with_missing_validator() { decimals: 9, validator: String::from("my-validator"), exit_tax: Decimal::percent(2), - min_withdrawal: Uint128::new(50), + min_withdrawal: Uint128(50), }; let info = mock_info(&creator, &[]); @@ -86,8 +86,8 @@ fn proper_initialization() { ); let (instance_options, memory_limit) = mock_instance_options(); let mut deps = Instance::from_code(WASM, backend, instance_options, memory_limit).unwrap(); - assert_eq!(deps.required_features().len(), 1); - assert!(deps.required_features().contains("staking")); + assert_eq!(deps.required_features.len(), 1); + assert!(deps.required_features.contains("staking")); let creator = String::from("creator"); let msg = InstantiateMsg { @@ -96,7 +96,7 @@ fn proper_initialization() { decimals: 9, validator: String::from("my-validator"), exit_tax: Decimal::percent(2), - min_withdrawal: Uint128::new(50), + min_withdrawal: Uint128(50), }; let info = mock_info(&creator, &[]); @@ -121,7 +121,7 @@ fn proper_initialization() { ) .unwrap(); let bal: BalanceResponse = from_binary(&res).unwrap(); - assert_eq!(bal.balance, Uint128::new(0)); + assert_eq!(bal.balance, Uint128(0)); // no claims let res = query( @@ -133,7 +133,7 @@ fn proper_initialization() { ) .unwrap(); let claim: ClaimsResponse = from_binary(&res).unwrap(); - assert_eq!(claim.claims, Uint128::new(0)); + assert_eq!(claim.claims, Uint128(0)); // investment info correct let res = query(&mut deps, mock_env(), QueryMsg::Investment {}).unwrap(); @@ -143,7 +143,7 @@ fn proper_initialization() { assert_eq!(invest.exit_tax, msg.exit_tax); assert_eq!(invest.min_withdrawal, msg.min_withdrawal); - assert_eq!(invest.token_supply, Uint128::new(0)); + assert_eq!(invest.token_supply, Uint128(0)); assert_eq!(invest.staked_tokens, coin(0, "ustake")); assert_eq!(invest.nominal_value, Decimal::one()); } diff --git a/contracts/voting-with-uuid/Cargo.lock b/contracts/voting-with-uuid/Cargo.lock index 4af159c25..093146296 100644 --- a/contracts/voting-with-uuid/Cargo.lock +++ b/contracts/voting-with-uuid/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.3", - "once_cell", - "version_check", -] - [[package]] name = "autocfg" version = "1.0.1" @@ -42,10 +31,10 @@ checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.27.1", "rustc-demangle", ] @@ -56,45 +45,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bincode" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "generic-array", + "serde", ] [[package]] -name = "bumpalo" -version = "3.8.0" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bytecheck" -version = "0.6.7" +name = "bitvec" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314889ea31cda264cb7c3d6e6e5c9415a987ecb0e72c17c00d36fbb881d34abe" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" dependencies = [ - "bytecheck_derive", - "ptr_meta", + "funty", + "radium", + "wyz", ] [[package]] -name = "bytecheck_derive" -version = "0.6.7" +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a2b3b92c135dae665a6f760205b89187638e83bed17ef3e44e83c712cf30600" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "proc-macro2", - "quote", - "syn", + "generic-array", ] [[package]] @@ -109,6 +91,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -123,9 +111,9 @@ checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" [[package]] name = "const-oid" -version = "0.6.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" [[package]] name = "cosmwasm-crypto" @@ -165,7 +153,6 @@ dependencies = [ "serde", "serde-json-wasm", "thiserror", - "uint", "uuid", ] @@ -185,7 +172,6 @@ dependencies = [ "cosmwasm-crypto", "cosmwasm-std", "hex", - "loupe", "parity-wasm", "schemars", "serde", @@ -207,35 +193,37 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ + "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli 0.22.0", "log", "regalloc", "smallvec", "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -243,21 +231,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -267,11 +258,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "3825b1e8580894917dc4468cb634a1b4e9745fddc854edad72d9c04644c0319f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -280,7 +271,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -290,7 +281,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -301,7 +292,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", "memoffset", @@ -314,33 +305,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static", ] -[[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.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" -dependencies = [ - "generic-array", - "rand_core 0.6.3", - "subtle", - "zeroize", -] - [[package]] name = "crypto-mac" -version = "0.11.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" dependencies = [ "generic-array", "subtle", @@ -375,9 +348,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ "darling_core", "darling_macro", @@ -385,9 +358,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" dependencies = [ "fnv", "ident_case", @@ -399,9 +372,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ "darling_core", "quote", @@ -410,9 +383,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.5" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" dependencies = [ "const-oid", ] @@ -455,16 +428,15 @@ checksum = "c20c69d1e16ae47889b47c301c790f48615cd9bfbdf586e3f6d4fde64af3d259" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.0", ] [[package]] name = "ecdsa" -version = "0.12.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" dependencies = [ - "der", "elliptic-curve", "hmac", "signature", @@ -492,16 +464,18 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" -version = "0.10.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beca177dcb8eb540133e7680baff45e7cc4d93bf22002676cec549f82343721b" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" dependencies = [ - "crypto-bigint", + "bitvec", + "digest", "ff", + "funty", "generic-array", "group", "pkcs8", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", "zeroize", ] @@ -535,11 +509,12 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.10.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" dependencies = [ - "rand_core 0.6.3", + "bitvec", + "rand_core 0.5.1", "subtle", ] @@ -549,6 +524,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "generic-array" version = "0.14.4" @@ -565,7 +546,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -576,16 +557,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.25.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -600,12 +581,12 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "group" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" dependencies = [ "ff", - "rand_core 0.6.3", + "rand_core 0.5.1", "subtle", ] @@ -614,9 +595,6 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] [[package]] name = "hermit-abi" @@ -635,9 +613,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ "crypto-mac", "digest", @@ -666,22 +644,13 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" -[[package]] -name = "js-sys" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "k256" -version = "0.9.6" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903ae2481bcdfdb7b68e0a9baa4b7c9aff600b9ae2e8e5bb5833b8c91ab851ea" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "ecdsa", "elliptic-curve", "sha2", @@ -701,17 +670,17 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" [[package]] name = "libloading" -version = "0.7.2" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -721,28 +690,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", + "cfg-if 1.0.0", ] [[package]] @@ -760,6 +708,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memmap2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.5.0" @@ -771,9 +728,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -806,20 +763,22 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "memchr", ] [[package]] -name = "once_cell" -version = "1.8.0" +name = "object" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] [[package]] name = "opaque-debug" @@ -841,12 +800,11 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pkcs8" -version = "0.7.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" dependencies = [ "der", - "spki", ] [[package]] @@ -881,33 +839,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" dependencies = [ "unicode-xid", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "quote" version = "1.0.10" @@ -917,6 +855,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.8.4" @@ -1013,9 +957,9 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", @@ -1032,40 +976,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1033f6fe7ce48c8333e5412891b933e85d6a3a09728c4883240edf64e7a6f11a" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rkyv" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bf572c17c77322f4d858c214def56b13a3c32b8d833cd6d28a92de8325ac5f" -dependencies = [ - "bytecheck", - "hashbrown", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3eca50f172b8e59e2080810fb41b65f047960c197149564d4bd0680af1888e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1078,17 +988,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "schemars" @@ -1120,17 +1024,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "serde" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1155,9 +1053,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.131" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1193,7 +1091,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1206,7 +1104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", "opaque-debug", @@ -1214,12 +1112,12 @@ dependencies = [ [[package]] name = "signature" -version = "1.3.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" dependencies = [ "digest", - "rand_core 0.6.3", + "rand_core 0.5.1", ] [[package]] @@ -1228,27 +1126,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -1274,9 +1157,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "tempfile" @@ -1284,7 +1167,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "rand", "redox_syscall", @@ -1318,8 +1201,7 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ - "cfg-if", - "log", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1351,18 +1233,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" -[[package]] -name = "uint" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1397,95 +1267,37 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" - [[package]] name = "wasmer" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ea93a6ba209613d82b8fe128ec39be4297b0f6d9571ee0db963939ff02c25e" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "indexmap", - "js-sys", - "loupe", "more-asserts", "target-lexicon", "thiserror", - "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", + "wasmer-engine-jit", + "wasmer-engine-native", "wasmer-types", "wasmer-vm", + "wat", "winapi", ] [[package]] name = "wasmer-compiler" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0f7a9201a79b68fe6427afa7835828b23647ef75f8a7aa212ec112f1625eeb1" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "loupe", - "rkyv", "serde", "serde_bytes", "smallvec", @@ -1498,19 +1310,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d9e195af82b7c339fa946fcd13792a3ceb65264c5631e737cc8d4941b50dcd" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ "cranelift-codegen", - "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", - "loupe", + "gimli 0.22.0", "more-asserts", "rayon", + "serde", "smallvec", - "target-lexicon", "tracing", "wasmer-compiler", "wasmer-types", @@ -1519,17 +1329,17 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c57d533c1be92916bbb9c170eafa2246c57b90aef43d7c15f4162e3044ff81" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm", "dynasmrt", "lazy_static", - "loupe", "more-asserts", "rayon", + "serde", "smallvec", "wasmer-compiler", "wasmer-types", @@ -1538,9 +1348,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63990dd633cb4a8c45d2f58429aa9500385734050d0c3e434a97cd87dfecf9cc" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1550,15 +1360,14 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9202a77333cfad9a32d33862dda7c1a981c3f17139f3da44a447df6b56ae4d" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", - "enumset", + "bincode", "lazy_static", - "loupe", - "memmap2", + "memmap2 0.2.3", "more-asserts", "rustc-demangle", "serde", @@ -1571,54 +1380,50 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-dylib" -version = "2.1.0" +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d633a81aa4278720ef476f9800efafccc4616d55f6e4fb079f6f268bd2df0a5c" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ - "cfg-if", - "enumset", - "leb128", - "libloading", - "loupe", - "rkyv", + "bincode", + "cfg-if 0.1.10", + "region", "serde", - "tempfile", - "tracing", + "serde_bytes", "wasmer-compiler", "wasmer-engine", - "wasmer-object", "wasmer-types", "wasmer-vm", - "which", + "winapi", ] [[package]] -name = "wasmer-engine-universal" -version = "2.1.0" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d70c28b4a5c300b91f55dbefa947751485899bf3de6cfaf3b702d14833ddb7" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ - "cfg-if", - "enumset", + "bincode", + "cfg-if 0.1.10", "leb128", - "loupe", - "region", - "rkyv", + "libloading", + "serde", + "tempfile", + "tracing", "wasmer-compiler", "wasmer-engine", + "wasmer-object", "wasmer-types", "wasmer-vm", - "winapi", + "which", ] [[package]] name = "wasmer-middlewares" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d1ae290eddb834a2ff3c8c77c5c77ac8ee9e78f25395aa83a3f831fffdd9a6" +checksum = "547baee2c0733cf436db7d137a8d1f86737a6321fc0fe6cd74caecf6f759c3c4" dependencies = [ - "loupe", "wasmer", "wasmer-types", "wasmer-vm", @@ -1626,11 +1431,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c41ae3e6df06eec59bf781043119b85d50da3e9886c2c4bf5d2e64d3532d8" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1638,33 +1443,29 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191ca11a0b1635690bbdfa1d8b677c0717a307b57064de4c8d7b579ce960fd57" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "indexmap", - "loupe", - "rkyv", + "cranelift-entity", "serde", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f7570037d25e5215f74e44af6d644a8cee10cc3df7825d03ff4179a8f6004" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 0.1.10", "indexmap", "libc", - "loupe", "memoffset", "more-asserts", "region", - "rkyv", "serde", "thiserror", "wasmer-types", @@ -1673,9 +1474,27 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wast" +version = "38.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +dependencies = [ + "wast", +] [[package]] name = "which" @@ -1710,6 +1529,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zeroize" version = "1.4.3" diff --git a/contracts/voting-with-uuid/Cargo.toml b/contracts/voting-with-uuid/Cargo.toml index 8098339cc..b8740ec8a 100644 --- a/contracts/voting-with-uuid/Cargo.toml +++ b/contracts/voting-with-uuid/Cargo.toml @@ -32,7 +32,7 @@ backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] [dependencies] -cosmwasm-std = { path = "../../packages/std", features = ["iterator"] } +cosmwasm-std = { path = "../../packages/std" } cosmwasm-storage = { path = "../../packages/storage"} schemars = "0.8.1" serde = { version = "1.0.125", default-features = false, features = ["derive"] } @@ -41,4 +41,4 @@ thiserror = { version = "1.0.23" } [dev-dependencies] cosmwasm-schema = { path = "../../packages/schema" } -cosmwasm-vm = { path = "../../packages/vm", default-features = false, features = ["iterator"] } +cosmwasm-vm = { path = "../../packages/vm", default-features = false } diff --git a/contracts/voting-with-uuid/src/contract.rs b/contracts/voting-with-uuid/src/contract.rs index 1f14485a3..d7a0c0661 100644 --- a/contracts/voting-with-uuid/src/contract.rs +++ b/contracts/voting-with-uuid/src/contract.rs @@ -208,14 +208,19 @@ pub fn create_poll( }; poll(deps.storage).save(poll_id.as_slice(), &new_poll)?; - let r = Response::new() - .add_attribute("action", "create_poll") - .add_attribute("creator", new_poll.creator) - .add_attribute("poll_id", poll_id.to_string()) - .add_attribute("quorum_percentage", quorum_percentage.unwrap_or(0).to_string()) - .add_attribute("end_height", new_poll.end_height.to_string().to_string()) - .add_attribute("start_height", start_height.unwrap_or(0).to_string()) - .set_data(to_binary(&CreatePollResponse { poll_id })?); + let r = Response { + submessages: vec![], + messages: vec![], + attributes: vec![ + attr("action", "create_poll"), + attr("creator", new_poll.creator), + attr("poll_id", poll_id.to_string()), + attr("quorum_percentage", quorum_percentage.unwrap_or(0)), + attr("end_height", new_poll.end_height), + attr("start_height", start_height.unwrap_or(0)), + ], + data: Some(to_binary(&CreatePollResponse { poll_id })?), + }; Ok(r) } @@ -311,10 +316,16 @@ pub fn end_poll( attr("action", "end_poll"), attr("poll_id", poll_id.to_string()), attr("rejected_reason", rejected_reason), - attr("passed", &passed.to_string()), + attr("passed", &passed), ]; - Ok(Response::new().add_attributes(attributes)) + let r = Response { + submessages: vec![], + messages: vec![], + attributes, + data: None, + }; + Ok(r) } // unlock voter's tokens in a given poll @@ -390,30 +401,41 @@ pub fn cast_vote( let attributes = vec![ attr("action", "vote_casted"), attr("poll_id", poll_id.to_string()), - attr("weight", &weight.to_string()), + attr("weight", &weight), attr("voter", &info.sender), ]; - Ok(Response::new().add_attributes(attributes)) + let r = Response { + submessages: vec![], + messages: vec![], + attributes, + data: None, + }; + Ok(r) } fn send_tokens(to_address: &Addr, amount: Vec, action: &str) -> Response { let attributes = vec![attr("action", action), attr("to", to_address.clone())]; - Response::new() - .add_message( - CosmosMsg::Bank(BankMsg::Send { - to_address: to_address.to_string(), - amount, - })) - .add_attributes(attributes) + Response { + submessages: vec![], + messages: vec![CosmosMsg::Bank(BankMsg::Send { + to_address: to_address.to_string(), + amount, + })], + attributes, + data: None, + } } pub fn make_uuid(deps: DepsMut, env: Env, _info: MessageInfo) -> Result { let uuid = new_uuid(&env, deps.storage, deps.api)?; - let r = Response::new() - .add_attribute("action", "make_uuid") - .add_attribute("uuid", uuid.to_string()); + let r = Response { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "make_uuid"), attr("uuid", uuid.to_string())], + data: None, + }; Ok(r) } @@ -424,9 +446,12 @@ pub fn make_seq_id( ) -> Result { let seq_id: u64 = 0; - let r = Response::new() - .add_attribute("action", "make_seq_id") - .add_attribute("uuid", seq_id.to_string()); + let r = Response { + submessages: vec![], + messages: vec![], + attributes: vec![attr("action", "make_seq_id"), attr("uuid", seq_id)], + data: None, + }; Ok(r) } diff --git a/contracts/voting-with-uuid/src/tests.rs b/contracts/voting-with-uuid/src/tests.rs index 3de389e9a..534b1fbc7 100644 --- a/contracts/voting-with-uuid/src/tests.rs +++ b/contracts/voting-with-uuid/src/tests.rs @@ -692,8 +692,8 @@ mod tests { let msg = execute_res.messages.get(0).expect("no message"); assert_eq!( - msg.msg, - CosmosMsg::Bank(BankMsg::Send { + msg, + &CosmosMsg::Bank(BankMsg::Send { to_address: TEST_VOTER.to_string(), amount: coins(11, VOTING_TOKEN), }) @@ -750,7 +750,7 @@ mod tests { match res { Ok(_) => panic!("Must return error"), Err(ContractError::ExcessiveWithdraw { max_amount }) => { - assert_eq!(max_amount, Uint128::from(10u32)) + assert_eq!(max_amount, Uint128(10)) } Err(e) => panic!("Unexpected error: {:?}", e), } @@ -904,9 +904,9 @@ mod tests { attr("action", "create_poll"), attr("creator", creator), attr("poll_id", poll_id.to_string()), - attr("quorum_percentage", quorum.to_string()), - attr("end_height", end_height.to_string()), - attr("start_height", start_height.to_string()), + attr("quorum_percentage", quorum), + attr("end_height", end_height), + attr("start_height", start_height), ] ); @@ -942,7 +942,7 @@ mod tests { vec![ attr("action", "vote_casted"), attr("poll_id", poll_id.to_string()), - attr("weight", weight.to_string()), + attr("weight", weight), attr("voter", voter), ] ); diff --git a/devtools/format_md.sh b/devtools/format_md.sh index 6db7b36e2..3fd16120d 100755 --- a/devtools/format_md.sh +++ b/devtools/format_md.sh @@ -2,14 +2,4 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" -# Running with -c makes the script only validate instead of editing in place. -op="write" -while getopts c option; do - case "${option}" in - - c) op="check" ;; - *) ;; - esac -done - -npx prettier@2.2.1 --$op "./**/*.md" +npx prettier@2.2.1 --write "./**/*.md" diff --git a/devtools/format_sh.sh b/devtools/format_sh.sh index bfdf9d2d1..8b950a97d 100755 --- a/devtools/format_sh.sh +++ b/devtools/format_sh.sh @@ -2,13 +2,4 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" -# Running with -c makes the script only validate instead of editing in place. -op="w" -while getopts c option; do - case "${option}" in - - c) op="d" ;; - esac -done - -shfmt -$op devtools packages +shfmt -w devtools packages diff --git a/devtools/format_yml.sh b/devtools/format_yml.sh index 3423752d9..0295f76eb 100755 --- a/devtools/format_yml.sh +++ b/devtools/format_yml.sh @@ -2,13 +2,4 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" -# Running with -c makes the script only validate instead of editing in place. -op="write" -while getopts c option; do - case "${option}" in - - c) op="check" ;; - esac -done - -npx prettier@2.2.1 --$op "./**/*.yml" +npx prettier@2.2.1 --write "./**/*.yml" diff --git a/packages/crypto/Cargo.toml b/packages/crypto/Cargo.toml index 86ea006a8..b3d372d92 100644 --- a/packages/crypto/Cargo.toml +++ b/packages/crypto/Cargo.toml @@ -19,7 +19,7 @@ backtraces = [] bench = false [dependencies] -k256 = { version = "0.9.6", features = ["ecdsa"] } +k256 = { version = "0.7.2", features = ["ecdsa"] } ed25519-zebra = "2" digest = "0.9" rand_core = { version = "0.5", features = ["getrandom"] } @@ -35,7 +35,7 @@ base64 = "0.13.0" hex = "0.4" hex-literal = "0.3.1" english-numbers = "0.3" -elliptic-curve = "0.10.3" +elliptic-curve = "0.8.4" [[bench]] name = "main" diff --git a/packages/crypto/benches/main.rs b/packages/crypto/benches/main.rs index c9a704cdf..b021a5eff 100644 --- a/packages/crypto/benches/main.rs +++ b/packages/crypto/benches/main.rs @@ -13,7 +13,7 @@ use sha2::Sha256; use cosmwasm_crypto::{ ed25519_batch_verify, ed25519_verify, secp256k1_recover_pubkey, secp256k1_verify, - sha1_calculate, + sha1_calculate, INPUT_MAX_LEN, }; use std::cmp::min; @@ -74,8 +74,6 @@ fn read_decode_cosmos_sigs() -> (Vec>, Vec>, Vec>) { } fn bench_crypto(c: &mut Criterion) { - // same as vm::imports::MAX_LENGTH_SHA1_MESSAGE (=80) - const MAX_LENGTH_SHA1_MESSAGE: usize = 80; let mut group = c.benchmark_group("Crypto"); group.bench_function("secp256k1_verify", |b| { @@ -98,7 +96,7 @@ fn bench_crypto(c: &mut Criterion) { let expected = SigningKey::from_bytes(&private_key) .unwrap() - .verifying_key() + .verify_key() .to_encoded_point(false) .as_bytes() .to_vec(); @@ -110,14 +108,14 @@ fn bench_crypto(c: &mut Criterion) { }); group.bench_function("sha1_calculate_one", |b| { - let inputs: Vec<&[u8]> = vec![&[0; MAX_LENGTH_SHA1_MESSAGE]]; + let inputs: Vec<&[u8]> = vec![&[0; INPUT_MAX_LEN]]; b.iter(|| { let hash = sha1_calculate(&inputs).unwrap(); assert_eq!(hash.len(), 20); }); }); group.bench_function("sha1_calculate_two", |b| { - let inputs: Vec<&[u8]> = vec![&[0; MAX_LENGTH_SHA1_MESSAGE], &[1; MAX_LENGTH_SHA1_MESSAGE]]; + let inputs: Vec<&[u8]> = vec![&[0; INPUT_MAX_LEN], &[1; INPUT_MAX_LEN]]; b.iter(|| { let hash = sha1_calculate(&inputs).unwrap(); assert_eq!(hash.len(), 20); @@ -125,10 +123,10 @@ fn bench_crypto(c: &mut Criterion) { }); group.bench_function("sha1_calculate_four", |b| { let inputs: Vec<&[u8]> = vec![ - &[0; MAX_LENGTH_SHA1_MESSAGE], - &[1; MAX_LENGTH_SHA1_MESSAGE], - &[2; MAX_LENGTH_SHA1_MESSAGE], - &[3; MAX_LENGTH_SHA1_MESSAGE], + &[0; INPUT_MAX_LEN], + &[1; INPUT_MAX_LEN], + &[2; INPUT_MAX_LEN], + &[3; INPUT_MAX_LEN], ]; b.iter(|| { let hash = sha1_calculate(&inputs).unwrap(); diff --git a/packages/crypto/src/ed25519.rs b/packages/crypto/src/ed25519.rs index ad642c307..8974980dc 100644 --- a/packages/crypto/src/ed25519.rs +++ b/packages/crypto/src/ed25519.rs @@ -5,6 +5,16 @@ use std::convert::TryInto; use crate::errors::{CryptoError, CryptoResult}; +/// Max length of a message for ed25519 verification in bytes. +/// This is an arbitrary value, for performance / memory contraints. If you need to verify larger +/// messages, let us know. +pub const MESSAGE_MAX_LEN: usize = 128 * 1024; + +/// Max number of batch messages / signatures / public_keys. +/// This is an arbitrary value, for performance / memory contraints. If you need to batch-verify a +/// larger number of signatures, let us know. +pub const BATCH_MAX_LEN: usize = 256; + /// Length of a serialized public key pub const EDDSA_PUBKEY_LEN: usize = 32; @@ -20,12 +30,13 @@ pub const EDDSA_PUBKEY_LEN: usize = 32; /// - public key: raw ED25519 public key (32 bytes). pub fn ed25519_verify(message: &[u8], signature: &[u8], public_key: &[u8]) -> CryptoResult { // Validation + check_message_length(message)?; let signature = read_signature(signature)?; let pubkey = read_pubkey(public_key)?; // Verification match VerificationKey::try_from(pubkey) - .and_then(|vk| vk.verify(&Signature::from(signature), message)) + .and_then(|vk| vk.verify(&Signature::from(signature), &message)) { Ok(()) => Ok(true), Err(_) => Ok(false), @@ -97,6 +108,7 @@ pub fn ed25519_batch_verify( .zip(public_keys.iter()) { // Validation + check_message_length(message)?; let signature = read_signature(signature)?; let pubkey = read_pubkey(public_key)?; @@ -137,6 +149,28 @@ fn read_pubkey(data: &[u8]) -> Result<[u8; 32], InvalidEd25519PubkeyFormat> { data.try_into().map_err(|_| InvalidEd25519PubkeyFormat) } +struct MessageTooLong { + limit: usize, + actual: usize, +} + +impl From for CryptoError { + fn from(original: MessageTooLong) -> Self { + CryptoError::message_too_long(original.limit, original.actual) + } +} + +fn check_message_length(message: &[u8]) -> Result<(), MessageTooLong> { + if message.len() > MESSAGE_MAX_LEN { + Err(MessageTooLong { + limit: MESSAGE_MAX_LEN, + actual: message.len(), + }) + } else { + Ok(()) + } +} + #[cfg(test)] mod tests { use super::*; @@ -184,7 +218,7 @@ mod tests { let message = MSG.as_bytes(); // Signing let secret_key = SigningKey::new(&mut OsRng); - let signature = secret_key.sign(message); + let signature = secret_key.sign(&message); let public_key = VerificationKey::from(&secret_key); @@ -193,7 +227,7 @@ mod tests { let public_key_bytes: [u8; 32] = public_key.into(); // Verification - assert!(ed25519_verify(message, &signature_bytes, &public_key_bytes).unwrap()); + assert!(ed25519_verify(&message, &signature_bytes, &public_key_bytes).unwrap()); // Wrong message fails let bad_message = [message, b"\0"].concat(); @@ -203,7 +237,7 @@ mod tests { let other_secret_key = SigningKey::new(&mut OsRng); let other_public_key = VerificationKey::from(&other_secret_key); let other_public_key_bytes: [u8; 32] = other_public_key.into(); - assert!(!ed25519_verify(message, &signature_bytes, &other_public_key_bytes).unwrap()); + assert!(!ed25519_verify(&message, &signature_bytes, &other_public_key_bytes).unwrap()); } #[test] @@ -220,7 +254,7 @@ mod tests { .as_slice(), ) .unwrap(); - let signature = secret_key.sign(COSMOS_ED25519_MSG.as_bytes()); + let signature = secret_key.sign(&COSMOS_ED25519_MSG.as_bytes()); let signature_bytes: [u8; 64] = signature.into(); let public_key_bytes: [u8; 32] = public_key.into(); @@ -233,7 +267,7 @@ mod tests { ); assert!(ed25519_verify( - COSMOS_ED25519_MSG.as_bytes(), + &COSMOS_ED25519_MSG.as_bytes(), &signature_bytes, &public_key_bytes ) diff --git a/packages/crypto/src/errors.rs b/packages/crypto/src/errors.rs index ba699220e..821767b1e 100644 --- a/packages/crypto/src/errors.rs +++ b/packages/crypto/src/errors.rs @@ -34,6 +34,13 @@ pub enum CryptoError { #[cfg(feature = "backtraces")] backtrace: Backtrace, }, + #[error("Message is longer than supported by this implementation (Limit: {limit}, actual length: {actual})")] + MessageTooLong { + limit: usize, + actual: usize, + #[cfg(feature = "backtraces")] + backtrace: Backtrace, + }, #[error("Invalid recovery parameter. Supported values: 0 and 1.")] InvalidRecoveryParam { #[cfg(feature = "backtraces")] @@ -56,7 +63,7 @@ pub enum CryptoError { } impl CryptoError { - pub fn batch_err(msg: impl Into) -> Self { + pub fn batch_err>(msg: S) -> Self { CryptoError::BatchErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -64,7 +71,7 @@ impl CryptoError { } } - pub fn generic_err(msg: impl Into) -> Self { + pub fn generic_err>(msg: S) -> Self { CryptoError::GenericErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -93,6 +100,15 @@ impl CryptoError { } } + pub fn message_too_long(limit: usize, actual: usize) -> Self { + CryptoError::MessageTooLong { + limit, + actual, + #[cfg(feature = "backtraces")] + backtrace: Backtrace::capture(), + } + } + pub fn invalid_recovery_param() -> Self { CryptoError::InvalidRecoveryParam { #[cfg(feature = "backtraces")] @@ -120,6 +136,7 @@ impl CryptoError { /// contract VM boundary. pub fn code(&self) -> u32 { match self { + CryptoError::MessageTooLong { .. } => 2, CryptoError::InvalidHashFormat { .. } => 3, CryptoError::InvalidSignatureFormat { .. } => 4, CryptoError::InvalidPubkeyFormat { .. } => 5, @@ -177,6 +194,18 @@ mod tests { } } + #[test] + fn message_too_long_works() { + let error = CryptoError::message_too_long(5, 7); + match error { + CryptoError::MessageTooLong { limit, actual, .. } => { + assert_eq!(limit, 5); + assert_eq!(actual, 7); + } + _ => panic!("wrong error type!"), + } + } + #[test] fn invalid_pubkey_format_works() { let error = CryptoError::invalid_pubkey_format(); diff --git a/packages/crypto/src/identity_digest.rs b/packages/crypto/src/identity_digest.rs index 5503c45ef..5371360a4 100644 --- a/packages/crypto/src/identity_digest.rs +++ b/packages/crypto/src/identity_digest.rs @@ -8,11 +8,19 @@ use digest::generic_array::GenericArray; use digest::{FixedOutputDirty, Output, Reset, Update}; /// The 256-bits identity container -#[derive(Clone, Default)] +#[derive(Clone)] pub struct Identity256 { array: GenericArray, } +impl Default for Identity256 { + fn default() -> Self { + Identity256 { + array: GenericArray::default(), + } + } +} + impl Update for Identity256 { fn update(&mut self, hash: impl AsRef<[u8]>) { assert_eq!(hash.as_ref().len(), 32); diff --git a/packages/crypto/src/lib.rs b/packages/crypto/src/lib.rs index 2bf21cbfa..c86147912 100644 --- a/packages/crypto/src/lib.rs +++ b/packages/crypto/src/lib.rs @@ -10,11 +10,11 @@ mod identity_digest; mod secp256k1; mod sha1; -#[doc(hidden)] -pub use crate::ed25519::EDDSA_PUBKEY_LEN; #[doc(hidden)] pub use crate::ed25519::{ed25519_batch_verify, ed25519_verify}; #[doc(hidden)] +pub use crate::ed25519::{BATCH_MAX_LEN, EDDSA_PUBKEY_LEN, MESSAGE_MAX_LEN}; +#[doc(hidden)] pub use crate::errors::{CryptoError, CryptoResult}; #[doc(hidden)] pub use crate::secp256k1::{secp256k1_recover_pubkey, secp256k1_verify}; @@ -22,3 +22,5 @@ pub use crate::secp256k1::{secp256k1_recover_pubkey, secp256k1_verify}; pub use crate::secp256k1::{ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, MESSAGE_HASH_MAX_LEN}; #[doc(hidden)] pub use crate::sha1::sha1_calculate; +#[doc(hidden)] +pub use crate::sha1::{INPUTS_MAX_CNT, INPUT_MAX_LEN}; diff --git a/packages/crypto/src/secp256k1.rs b/packages/crypto/src/secp256k1.rs index 96e387285..1f3c9fb2a 100644 --- a/packages/crypto/src/secp256k1.rs +++ b/packages/crypto/src/secp256k1.rs @@ -155,8 +155,8 @@ fn check_pubkey(data: &[u8]) -> Result<(), InvalidSecp256k1PubkeyFormat> { mod tests { use super::*; - use elliptic_curve::rand_core::OsRng; use elliptic_curve::sec1::ToEncodedPoint; + use rand_core::OsRng; use hex_literal::hex; use k256::{ @@ -316,7 +316,7 @@ mod tests { hex!("3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1"); let expected = SigningKey::from_bytes(&private_key) .unwrap() - .verifying_key() + .verify_key() .to_encoded_point(false) .as_bytes() .to_vec(); diff --git a/packages/crypto/src/sha1.rs b/packages/crypto/src/sha1.rs index 6dc6f2d69..09365bb49 100644 --- a/packages/crypto/src/sha1.rs +++ b/packages/crypto/src/sha1.rs @@ -1,8 +1,21 @@ use sha1::{Digest, Sha1}; -use crate::errors::CryptoResult; +use crate::errors::{CryptoError, CryptoResult}; + +/// Max count of a inputs for sha1. +/// A limit is set to prevent malicious excessive input. +/// Now, we limit ourselves to only small sizes for use cases in Uuid. +pub const INPUTS_MAX_CNT: usize = 4; + +/// Max length of a input for sha1 +/// After executing the crypto bench according to INPUT_MAX_LEN, +/// the gas factor is determined based on the result. +/// If you modify this value, you need to adjust the gas factor. +pub const INPUT_MAX_LEN: usize = 80; pub fn sha1_calculate(hash_inputs: &[&[u8]]) -> CryptoResult<[u8; 20]> { + check_hash_inputs(hash_inputs)?; + let mut hasher = Sha1::new(); for &hash_input in hash_inputs.iter() { hasher.update(hash_input); @@ -11,6 +24,23 @@ pub fn sha1_calculate(hash_inputs: &[&[u8]]) -> CryptoResult<[u8; 20]> { Ok(buffer) } +fn check_hash_inputs(hash_inputs: &[&[u8]]) -> Result<(), CryptoError> { + if hash_inputs.len() > INPUTS_MAX_CNT { + return Err(CryptoError::inputs_too_larger( + INPUTS_MAX_CNT, + hash_inputs.len(), + )); + } + + for &hash_input in hash_inputs.iter() { + if hash_input.len() > INPUT_MAX_LEN { + return Err(CryptoError::input_too_long(INPUT_MAX_LEN, hash_input.len())); + } + } + + Ok(()) +} + #[cfg(test)] mod tests { use super::*; @@ -23,4 +53,31 @@ mod tests { let calc_result = sha1_calculate(inputs).unwrap(); assert_eq!(20, calc_result.len()) } + + #[test] + fn test_sha1_over_inputs_maximum_count() { + let input: &str = "malformed data"; + let inputs: [&[u8]; INPUTS_MAX_CNT + 1] = [input.as_bytes(); INPUTS_MAX_CNT + 1]; + let calc_result = sha1_calculate(&inputs).unwrap_err(); + match calc_result { + CryptoError::InputsTooLarger { limit, actual } => { + assert_eq!(limit, INPUTS_MAX_CNT); + assert_eq!(actual, INPUTS_MAX_CNT + 1); + } + _ => panic!("Wrong error message"), + } + } + + #[test] + fn test_sha1_over_input_maximum_length() { + let input: [u8; INPUT_MAX_LEN + 1] = [0; INPUT_MAX_LEN + 1]; + let calc_result = sha1_calculate(&[&input]).unwrap_err(); + match calc_result { + CryptoError::InputTooLong { limit, actual } => { + assert_eq!(limit, INPUT_MAX_LEN); + assert_eq!(actual, INPUT_MAX_LEN + 1); + } + _ => panic!("Wrong error message"), + } + } } diff --git a/packages/schema/src/export.rs b/packages/schema/src/export.rs index 2e5c7dcd1..e11ea66ce 100644 --- a/packages/schema/src/export.rs +++ b/packages/schema/src/export.rs @@ -26,14 +26,14 @@ pub fn export_schema_with_title(schema: &RootSchema, out_dir: &Path, title: &str if let Some(metadata) = &mut schema.schema.metadata { metadata.title = Some(title.to_string()); } - write_schema(&schema, out_dir, title); + write_schema(&schema, out_dir, &title); } /// Writes schema to file. Overwrites existing file. /// Panics on any error writing out the schema. fn write_schema(schema: &RootSchema, out_dir: &Path, title: &str) { // first, we set the title as we wish - let path = out_dir.join(format!("{}.json", to_snake_case(title))); + let path = out_dir.join(format!("{}.json", to_snake_case(&title))); let json = serde_json::to_string_pretty(schema).unwrap(); write(&path, json + "\n").unwrap(); println!("Created {}", path.to_str().unwrap()); diff --git a/packages/schema/src/remove.rs b/packages/schema/src/remove.rs index 2b7c2359e..19c530c9f 100644 --- a/packages/schema/src/remove.rs +++ b/packages/schema/src/remove.rs @@ -42,58 +42,58 @@ mod tests { #[test] fn is_hidden_works() { - assert!(!is_hidden(Path::new("/foo"))); - assert!(!is_hidden(Path::new("/foo/bar"))); - assert!(!is_hidden(Path::new("/foo/bar.txt"))); - assert!(!is_hidden(Path::new("~foo"))); - assert!(!is_hidden(Path::new("foo"))); + assert_eq!(is_hidden(Path::new("/foo")), false); + assert_eq!(is_hidden(Path::new("/foo/bar")), false); + assert_eq!(is_hidden(Path::new("/foo/bar.txt")), false); + assert_eq!(is_hidden(Path::new("~foo")), false); + assert_eq!(is_hidden(Path::new("foo")), false); - assert!(is_hidden(Path::new("/.foo"))); - assert!(is_hidden(Path::new("/foo/.bar"))); - assert!(is_hidden(Path::new("/foo/.bar.txt"))); - assert!(is_hidden(Path::new(".foo"))); + assert_eq!(is_hidden(Path::new("/.foo")), true); + assert_eq!(is_hidden(Path::new("/foo/.bar")), true); + assert_eq!(is_hidden(Path::new("/foo/.bar.txt")), true); + assert_eq!(is_hidden(Path::new(".foo")), true); // no filename - assert!(!is_hidden(Path::new("/"))); - assert!(!is_hidden(Path::new(""))); + assert_eq!(is_hidden(Path::new("/")), false); + assert_eq!(is_hidden(Path::new("")), false); // invalid UTF-8 #[cfg(any(unix, target_os = "redox"))] { use std::os::unix::ffi::OsStrExt; let non_hidden = OsStr::from_bytes(&[0x66, 0x6f, 0x80, 0x6f]); // fo�o - assert!(!is_hidden(Path::new(non_hidden))); + assert_eq!(is_hidden(Path::new(non_hidden)), false); let hidden = OsStr::from_bytes(&[0x2e, 0x66, 0x6f, 0x80, 0x6f]); // .fo�o - assert!(is_hidden(Path::new(hidden))); + assert_eq!(is_hidden(Path::new(hidden)), true); } } #[test] fn is_json_works() { - assert!(!is_json(Path::new("/foo"))); - assert!(!is_json(Path::new("/foo/bar"))); - assert!(!is_json(Path::new("/foo/bar.txt"))); - assert!(!is_json(Path::new("~foo"))); - assert!(!is_json(Path::new("foo"))); - assert!(!is_json(Path::new("foo.json5"))); + assert_eq!(is_json(Path::new("/foo")), false); + assert_eq!(is_json(Path::new("/foo/bar")), false); + assert_eq!(is_json(Path::new("/foo/bar.txt")), false); + assert_eq!(is_json(Path::new("~foo")), false); + assert_eq!(is_json(Path::new("foo")), false); + assert_eq!(is_json(Path::new("foo.json5")), false); - assert!(is_json(Path::new("/.json"))); - assert!(is_json(Path::new("/foo/.bar.json"))); - assert!(is_json(Path::new("/foo/bar.json"))); - assert!(is_json(Path::new("foo.json"))); + assert_eq!(is_json(Path::new("/.json")), true); + assert_eq!(is_json(Path::new("/foo/.bar.json")), true); + assert_eq!(is_json(Path::new("/foo/bar.json")), true); + assert_eq!(is_json(Path::new("foo.json")), true); // no filename - assert!(!is_json(Path::new("/"))); - assert!(!is_json(Path::new(""))); + assert_eq!(is_json(Path::new("/")), false); + assert_eq!(is_json(Path::new("")), false); // invalid UTF-8 #[cfg(any(unix, target_os = "redox"))] { use std::os::unix::ffi::OsStrExt; let non_hidden = OsStr::from_bytes(&[0x66, 0x6f, 0x80, 0x6f]); // fo�o - assert!(!is_json(Path::new(non_hidden))); + assert_eq!(is_json(Path::new(non_hidden)), false); let hidden = OsStr::from_bytes(&[0x66, 0x6f, 0x80, 0x6f, 0x2e, 0x6a, 0x73, 0x6f, 0x6e]); // fo�o.json - assert!(is_json(Path::new(hidden))); + assert_eq!(is_json(Path::new(hidden)), true); } } } diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 33941e17e..fc0d8cb7b 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -8,11 +8,8 @@ repository = "https://github.com/line/cosmwasm/tree/main/packages/std" license = "Apache-2.0" readme = "README.md" -[package.metadata.docs.rs] -features = ["stargate", "staking"] - [features] -default = ["iterator"] +default = [] # iterator allows us to iterate over all DB items in a given range # optional as some merkle stores (like tries) don't support this # given Ethereum 1.0, 2.0, Substrate, and other major projects use Tries @@ -33,10 +30,6 @@ stargate = [] [dependencies] base64 = "0.13.0" cosmwasm-derive = { path = "../derive", version = "0.14.0-0.4.0" } -# uint 0.9.2 uses edition2021 and this cannot be used from wasmvm now. -# See also https://github.com/CosmWasm/wasmvm/issues/277 -# and https://github.com/CosmWasm/cosmwasm/issues/1204 -uint = "=0.9.1" serde-json-wasm = { version = "0.3.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } diff --git a/packages/std/schema/cosmos_msg.json b/packages/std/schema/cosmos_msg.json index 18a9d4858..082c6a378 100644 --- a/packages/std/schema/cosmos_msg.json +++ b/packages/std/schema/cosmos_msg.json @@ -138,19 +138,13 @@ "type": "object", "required": [ "contract_addr", - "funds", - "msg" + "msg", + "send" ], "properties": { "contract_addr": { "type": "string" }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "msg": { "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", "allOf": [ @@ -158,6 +152,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } @@ -175,9 +175,9 @@ "type": "object", "required": [ "code_id", - "funds", "label", - "msg" + "msg", + "send" ], "properties": { "admin": { @@ -191,12 +191,6 @@ "format": "uint64", "minimum": 0.0 }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "label": { "description": "A human-readbale label for the contract", "type": "string" @@ -208,6 +202,12 @@ "$ref": "#/definitions/Binary" } ] + }, + "send": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } } } } diff --git a/packages/std/schema/timestamp.json b/packages/std/schema/timestamp.json index 6dd9971a1..889461d98 100644 --- a/packages/std/schema/timestamp.json +++ b/packages/std/schema/timestamp.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Timestamp", - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.", "allOf": [ { "$ref": "#/definitions/Uint64" diff --git a/packages/std/src/addresses.rs b/packages/std/src/addresses.rs index 4a5567b9f..80c00bba9 100644 --- a/packages/std/src/addresses.rs +++ b/packages/std/src/addresses.rs @@ -2,7 +2,6 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::borrow::Cow; use std::fmt; use std::ops::Deref; @@ -45,7 +44,7 @@ impl Addr { /// let address = Addr::unchecked("foobar"); /// assert_eq!(address, "foobar"); /// ``` - pub fn unchecked(input: impl Into) -> Addr { + pub fn unchecked>(input: T) -> Addr { Addr(input.into()) } @@ -53,20 +52,6 @@ impl Addr { pub fn as_str(&self) -> &str { self.0.as_str() } - - /// Returns the UTF-8 encoded address string as a byte array. - /// - /// This is equivalent to `address.as_str().as_bytes()`. - #[inline] - pub fn as_bytes(&self) -> &[u8] { - self.0.as_bytes() - } - - /// Utility for explicit conversion to `String`. - #[inline] - pub fn into_string(self) -> String { - self.0 - } } impl fmt::Display for Addr { @@ -137,18 +122,6 @@ impl From<&Addr> for HumanAddr { } } -impl From for Cow<'_, Addr> { - fn from(addr: Addr) -> Self { - Cow::Owned(addr) - } -} - -impl<'a> From<&'a Addr> for Cow<'a, Addr> { - fn from(addr: &'a Addr) -> Self { - Cow::Borrowed(addr) - } -} - #[deprecated( since = "0.14.0-0.4.0", note = "HumanAddr is not much more than an alias to String and it does not provide significant safety advantages. With CosmWasm 0.14, we now use String when there was HumanAddr before. There is also the new Addr, which holds a validated immutable human readable address." @@ -278,7 +251,7 @@ impl Deref for CanonicalAddr { impl CanonicalAddr { pub fn as_slice(&self) -> &[u8] { - self.0.as_slice() + &self.0.as_slice() } } @@ -314,15 +287,6 @@ mod tests { assert_eq!(addr.as_str(), "literal-string"); } - #[test] - fn addr_as_bytes_works() { - let addr = Addr::unchecked("literal-string"); - assert_eq!( - addr.as_bytes(), - [108, 105, 116, 101, 114, 97, 108, 45, 115, 116, 114, 105, 110, 103] - ); - } - #[test] fn addr_implements_display() { let addr = Addr::unchecked("cos934gh9034hg04g0h134"); @@ -499,9 +463,9 @@ mod tests { #[test] fn human_addr_is_empty() { let human_addr = HumanAddr::from("Hello, world!"); - assert!(!human_addr.is_empty()); + assert_eq!(false, human_addr.is_empty()); let empty_human_addr = HumanAddr::from(""); - assert!(empty_human_addr.is_empty()); + assert_eq!(true, empty_human_addr.is_empty()); } // Test CanonicalAddr as_slice() for each CanonicalAddr::from input type @@ -563,9 +527,9 @@ mod tests { fn canonical_addr_is_empty() { let bytes: &[u8] = &[0u8, 187, 61, 11, 250, 0]; let canonical_addr = CanonicalAddr::from(bytes); - assert!(!canonical_addr.is_empty()); + assert_eq!(false, canonical_addr.is_empty()); let empty_canonical_addr = CanonicalAddr::from(vec![]); - assert!(empty_canonical_addr.is_empty()); + assert_eq!(true, empty_canonical_addr.is_empty()); } #[test] @@ -636,21 +600,4 @@ mod tests { let set2 = HashSet::from_iter(vec![alice1, alice2, bob]); assert_eq!(set1, set2); } - - // helper to show we can handle Addr and &Addr equally - fn flexible<'a>(a: impl Into>) -> String { - a.into().into_owned().to_string() - } - - #[test] - fn addr_into_cow() { - // owned Addr - let value = "wasmeucn0ur0ncny2308ry"; - let addr = Addr::unchecked(value); - - // pass by ref - assert_eq!(value, &flexible(&addr)); - // pass by value - assert_eq!(value, &flexible(addr)); - } } diff --git a/packages/std/src/coins.rs b/packages/std/src/coins.rs index a84799b3d..b13f3fd08 100644 --- a/packages/std/src/coins.rs +++ b/packages/std/src/coins.rs @@ -11,9 +11,9 @@ pub struct Coin { } impl Coin { - pub fn new(amount: u128, denom: impl Into) -> Self { + pub fn new>(amount: u128, denom: S) -> Self { Coin { - amount: Uint128::new(amount), + amount: Uint128(amount), denom: denom.into(), } } @@ -34,19 +34,19 @@ impl fmt::Display for Coin { /// # Examples /// /// ``` -/// # use cosmwasm_std::{coins, BankMsg, CosmosMsg, Response, SubMsg}; +/// # use cosmwasm_std::{coins, BankMsg, CosmosMsg, Response}; /// # use cosmwasm_std::testing::{mock_env, mock_info}; /// # let env = mock_env(); /// # let info = mock_info("sender", &[]); /// let tip = coins(123, "ucosm"); /// /// let mut response: Response = Default::default(); -/// response.messages = vec![SubMsg::new(BankMsg::Send { +/// response.messages = vec![CosmosMsg::Bank(BankMsg::Send { /// to_address: info.sender.into(), /// amount: tip, /// })]; /// ``` -pub fn coins(amount: u128, denom: impl Into) -> Vec { +pub fn coins>(amount: u128, denom: S) -> Vec { vec![coin(amount, denom)] } @@ -55,7 +55,7 @@ pub fn coins(amount: u128, denom: impl Into) -> Vec { /// # Examples /// /// ``` -/// # use cosmwasm_std::{coin, BankMsg, CosmosMsg, Response, SubMsg}; +/// # use cosmwasm_std::{coin, BankMsg, CosmosMsg, Response}; /// # use cosmwasm_std::testing::{mock_env, mock_info}; /// # let env = mock_env(); /// # let info = mock_info("sender", &[]); @@ -65,12 +65,12 @@ pub fn coins(amount: u128, denom: impl Into) -> Vec { /// ]; /// /// let mut response: Response = Default::default(); -/// response.messages = vec![SubMsg::new(BankMsg::Send { +/// response.messages = vec![CosmosMsg::Bank(BankMsg::Send { /// to_address: info.sender.into(), /// amount: tip, /// })]; /// ``` -pub fn coin(amount: u128, denom: impl Into) -> Coin { +pub fn coin>(amount: u128, denom: S) -> Coin { Coin::new(amount, denom) } @@ -90,7 +90,7 @@ mod tests { #[test] fn coin_implements_display() { let a = Coin { - amount: Uint128::new(123), + amount: Uint128(123), denom: "ucosm".to_string(), }; @@ -105,7 +105,7 @@ mod tests { assert_eq!( a, Coin { - amount: Uint128::new(123), + amount: Uint128(123), denom: "ucosm".to_string() } ); @@ -114,7 +114,7 @@ mod tests { assert_eq!( zero, Coin { - amount: Uint128::new(0), + amount: Uint128(0), denom: "ucosm".to_string() } ); @@ -123,7 +123,7 @@ mod tests { assert_eq!( string_denom, Coin { - amount: Uint128::new(42), + amount: Uint128(42), denom: "ucosm".to_string() } ); @@ -135,7 +135,7 @@ mod tests { assert_eq!( a, vec![Coin { - amount: Uint128::new(123), + amount: Uint128(123), denom: "ucosm".to_string() }] ); @@ -144,7 +144,7 @@ mod tests { assert_eq!( zero, vec![Coin { - amount: Uint128::new(0), + amount: Uint128(0), denom: "ucosm".to_string() }] ); @@ -153,7 +153,7 @@ mod tests { assert_eq!( string_denom, vec![Coin { - amount: Uint128::new(42), + amount: Uint128(42), denom: "ucosm".to_string() }] ); diff --git a/packages/std/src/entry_points.rs b/packages/std/src/entry_points.rs index 62780e7db..a04893b3b 100644 --- a/packages/std/src/entry_points.rs +++ b/packages/std/src/entry_points.rs @@ -81,7 +81,7 @@ macro_rules! create_entry_points { $crate::create_entry_points!(@migration; $contract, $migration); - // Other C externs like interface_version_7, allocate, deallocate are available + // Other C externs like interface_version_5, allocate, deallocate are available // automatically because we `use cosmwasm_std`. } }; @@ -94,14 +94,14 @@ macro_rules! create_entry_points { /// This macro is very similar to the `create_entry_points` macro, except it also requires the `migrate` method: /// ``` /// # use cosmwasm_std::{ -/// # Storage, Api, Querier, DepsMut, Env, StdError, Response, MessageInfo, +/// # Storage, Api, Querier, DepsMut, Env, StdError, MigrateResponse, MessageInfo, /// # }; /// # type MigrateMsg = (); /// pub fn migrate( /// deps: DepsMut, /// _env: Env, /// msg: MigrateMsg, -/// ) -> Result { +/// ) -> Result { /// # Ok(Default::default()) /// } /// ``` diff --git a/packages/std/src/errors/hash_calculation_error.rs b/packages/std/src/errors/hash_calculation_error.rs index b5715aaea..7cc413651 100644 --- a/packages/std/src/errors/hash_calculation_error.rs +++ b/packages/std/src/errors/hash_calculation_error.rs @@ -60,7 +60,8 @@ impl From for HashCalculationError { match original { CryptoError::InputsTooLarger { .. } => HashCalculationError::InputsTooLarger, CryptoError::InputTooLong { .. } => HashCalculationError::InputTooLonger, - CryptoError::InvalidHashFormat { .. } + CryptoError::MessageTooLong { .. } + | CryptoError::InvalidHashFormat { .. } | CryptoError::InvalidPubkeyFormat { .. } | CryptoError::InvalidSignatureFormat { .. } | CryptoError::GenericErr { .. } diff --git a/packages/std/src/errors/mod.rs b/packages/std/src/errors/mod.rs index 1c08cf6e7..d60ca4620 100644 --- a/packages/std/src/errors/mod.rs +++ b/packages/std/src/errors/mod.rs @@ -6,9 +6,6 @@ mod verification_error; pub use hash_calculation_error::HashCalculationError; pub use recover_pubkey_error::RecoverPubkeyError; -pub use std_error::{ - ConversionOverflowError, DivideByZeroError, OverflowError, OverflowOperation, StdError, - StdResult, -}; +pub use std_error::{DivideByZeroError, OverflowError, OverflowOperation, StdError, StdResult}; pub use system_error::SystemError; pub use verification_error::VerificationError; diff --git a/packages/std/src/errors/recover_pubkey_error.rs b/packages/std/src/errors/recover_pubkey_error.rs index 4bbd060d8..d199d8faa 100644 --- a/packages/std/src/errors/recover_pubkey_error.rs +++ b/packages/std/src/errors/recover_pubkey_error.rs @@ -62,6 +62,7 @@ impl PartialEq for RecoverPubkeyError { impl From for RecoverPubkeyError { fn from(original: CryptoError) -> Self { match original { + CryptoError::MessageTooLong { .. } => panic!("Conversion not supported"), CryptoError::InvalidHashFormat { .. } => RecoverPubkeyError::InvalidHashFormat, CryptoError::InvalidPubkeyFormat { .. } => panic!("Conversion not supported"), CryptoError::InvalidSignatureFormat { .. } => { diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs index a1098db26..f800ce376 100644 --- a/packages/std/src/errors/std_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -101,13 +101,6 @@ pub enum StdError { #[cfg(feature = "backtraces")] backtrace: Backtrace, }, - #[error("Conversion error: ")] - ConversionOverflow { - #[from] - source: ConversionOverflowError, - #[cfg(feature = "backtraces")] - backtrace: Backtrace, - }, } impl StdError { @@ -134,8 +127,7 @@ impl StdError { backtrace: Backtrace::capture(), } } - - pub fn generic_err(msg: impl Into) -> Self { + pub fn generic_err>(msg: S) -> Self { StdError::GenericErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -143,7 +135,7 @@ impl StdError { } } - pub fn invalid_base64(msg: impl ToString) -> Self { + pub fn invalid_base64(msg: S) -> Self { StdError::InvalidBase64 { msg: msg.to_string(), #[cfg(feature = "backtraces")] @@ -161,7 +153,7 @@ impl StdError { } } - pub fn invalid_utf8(msg: impl ToString) -> Self { + pub fn invalid_utf8(msg: S) -> Self { StdError::InvalidUtf8 { msg: msg.to_string(), #[cfg(feature = "backtraces")] @@ -169,7 +161,7 @@ impl StdError { } } - pub fn not_found(kind: impl Into) -> Self { + pub fn not_found>(kind: S) -> Self { StdError::NotFound { kind: kind.into(), #[cfg(feature = "backtraces")] @@ -177,7 +169,7 @@ impl StdError { } } - pub fn parse_err(target: impl Into, msg: impl ToString) -> Self { + pub fn parse_err, M: ToString>(target: T, msg: M) -> Self { StdError::ParseErr { target_type: target.into(), msg: msg.to_string(), @@ -186,7 +178,7 @@ impl StdError { } } - pub fn serialize_err(source: impl Into, msg: impl ToString) -> Self { + pub fn serialize_err, M: ToString>(source: S, msg: M) -> Self { StdError::SerializeErr { source_type: source.into(), msg: msg.to_string(), @@ -413,22 +405,6 @@ impl PartialEq for StdError { false } } - StdError::ConversionOverflow { - source, - #[cfg(feature = "backtraces")] - backtrace: _, - } => { - if let StdError::ConversionOverflow { - source: rhs_source, - #[cfg(feature = "backtraces")] - backtrace: _, - } = rhs - { - source == rhs_source - } else { - false - } - } } } } @@ -488,8 +464,6 @@ pub enum OverflowOperation { Sub, Mul, Pow, - Shr, - Shl, } impl fmt::Display for OverflowOperation { @@ -507,11 +481,7 @@ pub struct OverflowError { } impl OverflowError { - pub fn new( - operation: OverflowOperation, - operand1: impl ToString, - operand2: impl ToString, - ) -> Self { + pub fn new(operation: OverflowOperation, operand1: U, operand2: U) -> Self { Self { operation, operand1: operand1.to_string(), @@ -520,34 +490,6 @@ impl OverflowError { } } -/// The error returned by [`TryFrom`] conversions that overflow, for example -/// when converting from [`Uint256`] to [`Uint128`]. -/// -/// [`TryFrom`]: std::convert::TryFrom -/// [`Uint256`]: crate::Uint256 -/// [`Uint128`]: crate::Uint128 -#[derive(Error, Debug, PartialEq, Eq)] -#[error("Error converting {source_type} to {target_type} for {value}")] -pub struct ConversionOverflowError { - pub source_type: &'static str, - pub target_type: &'static str, - pub value: String, -} - -impl ConversionOverflowError { - pub fn new( - source_type: &'static str, - target_type: &'static str, - value: impl Into, - ) -> Self { - Self { - source_type, - target_type, - value: value.into(), - } - } -} - #[derive(Error, Debug, PartialEq, Eq)] #[error("Cannot devide {operand} by zero")] pub struct DivideByZeroError { @@ -555,7 +497,7 @@ pub struct DivideByZeroError { } impl DivideByZeroError { - pub fn new(operand: impl ToString) -> Self { + pub fn new(operand: U) -> Self { Self { operand: operand.to_string(), } @@ -748,11 +690,10 @@ mod tests { fn implements_debug() { let error: StdError = StdError::from(OverflowError::new(OverflowOperation::Sub, 3, 5)); let embedded = format!("Debug: {:?}", error); - #[cfg(not(feature = "backtraces"))] - let expected = r#"Debug: Overflow { source: OverflowError { operation: Sub, operand1: "3", operand2: "5" } }"#; - #[cfg(feature = "backtraces")] - let expected = r#"Debug: Overflow { source: OverflowError { operation: Sub, operand1: "3", operand2: "5" }, backtrace: }"#; - assert_eq!(embedded, expected); + assert_eq!( + embedded, + r#"Debug: Overflow { source: OverflowError { operation: Sub, operand1: "3", operand2: "5" } }"# + ); } #[test] diff --git a/packages/std/src/errors/system_error.rs b/packages/std/src/errors/system_error.rs index e6480ae0c..e04a6bbcd 100644 --- a/packages/std/src/errors/system_error.rs +++ b/packages/std/src/errors/system_error.rs @@ -43,13 +43,13 @@ impl std::fmt::Display for SystemError { f, "Cannot parse request: {} in: {}", error, - String::from_utf8_lossy(request) + String::from_utf8_lossy(&request) ), SystemError::InvalidResponse { error, response } => write!( f, "Cannot parse response: {} in: {}", error, - String::from_utf8_lossy(response) + String::from_utf8_lossy(&response) ), SystemError::NoSuchContract { addr } => write!(f, "No such contract: {}", addr), SystemError::Unknown {} => write!(f, "Unknown system error"), diff --git a/packages/std/src/errors/verification_error.rs b/packages/std/src/errors/verification_error.rs index 90f1f265c..85505b5ac 100644 --- a/packages/std/src/errors/verification_error.rs +++ b/packages/std/src/errors/verification_error.rs @@ -12,6 +12,8 @@ pub enum VerificationError { BatchErr, #[error("Generic error")] GenericErr, + #[error("Message is longer than supported")] + MessageTooLong, #[error("Invalid hash format")] InvalidHashFormat, #[error("Invalid signature format")] @@ -43,6 +45,7 @@ impl PartialEq for VerificationError { match self { VerificationError::BatchErr => matches!(rhs, VerificationError::BatchErr), VerificationError::GenericErr => matches!(rhs, VerificationError::GenericErr), + VerificationError::MessageTooLong => matches!(rhs, VerificationError::MessageTooLong), VerificationError::InvalidHashFormat => { matches!(rhs, VerificationError::InvalidHashFormat) } @@ -74,6 +77,7 @@ impl PartialEq for VerificationError { impl From for VerificationError { fn from(original: CryptoError) -> Self { match original { + CryptoError::MessageTooLong { .. } => VerificationError::MessageTooLong, CryptoError::InvalidHashFormat { .. } => VerificationError::InvalidHashFormat, CryptoError::InvalidPubkeyFormat { .. } => VerificationError::InvalidPubkeyFormat, CryptoError::InvalidSignatureFormat { .. } => VerificationError::InvalidSignatureFormat, diff --git a/packages/std/src/exports.rs b/packages/std/src/exports.rs index 30ef40389..d47ca7d62 100644 --- a/packages/std/src/exports.rs +++ b/packages/std/src/exports.rs @@ -1,6 +1,6 @@ //! exports exposes the public wasm API //! -//! interface_version_7, allocate and deallocate turn into Wasm exports +//! interface_version_5, allocate and deallocate turn into Wasm exports //! as soon as cosmwasm_std is `use`d in the contract, even privately. //! //! `do_execute`, `do_instantiate`, `do_migrate`, `do_query`, `do_reply` @@ -33,7 +33,7 @@ extern "C" fn requires_stargate() -> () {} /// They can be checked by cosmwasm_vm. /// Update this whenever the Wasm VM interface breaks. #[no_mangle] -extern "C" fn interface_version_7() -> () {} +extern "C" fn interface_version_5() -> () {} /// allocate reserves the given number of bytes in wasm memory and returns a pointer /// to a Region defining this data. This space is managed by the calling process diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index 8ab80c840..9179cc320 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -9,9 +9,7 @@ use std::fmt; use crate::binary::Binary; use crate::coins::Coin; -use crate::errors::StdResult; -use crate::results::{Attribute, CosmosMsg, Empty, Event, SubMsg}; -use crate::serde::to_binary; +use crate::results::{Attribute, CosmosMsg, Empty, SubMsg}; use crate::timestamp::Timestamp; /// These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts @@ -115,36 +113,18 @@ impl From for IbcTimeout { /// IbcChannel defines all information on a channel. /// This is generally used in the hand-shake process, but can be queried directly. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] pub struct IbcChannel { pub endpoint: IbcEndpoint, pub counterparty_endpoint: IbcEndpoint, pub order: IbcOrder, pub version: String, + /// CounterpartyVersion can be None when not known this context, yet + pub counterparty_version: Option, /// The connection upon which this channel was created. If this is a multi-hop /// channel, we only expose the first hop. pub connection_id: String, } -impl IbcChannel { - /// Construct a new IbcChannel. - pub fn new( - endpoint: IbcEndpoint, - counterparty_endpoint: IbcEndpoint, - order: IbcOrder, - version: impl Into, - connection_id: impl Into, - ) -> Self { - Self { - endpoint, - counterparty_endpoint, - order, - version: version.into(), - connection_id: connection_id.into(), - } - } -} - /// IbcOrder defines if a channel is ORDERED or UNORDERED /// Values come from https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/core/channel/v1/channel.proto#L69-L80 /// Naming comes from the protobuf files and go translations. @@ -192,9 +172,8 @@ impl Ord for IbcTimeoutBlock { } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] pub struct IbcPacket { - /// The raw data sent from the other side in the packet + /// The raw data send from the other side in the packet pub data: Binary, /// identifies the channel and port on the sending chain. pub src: IbcEndpoint, @@ -205,231 +184,12 @@ pub struct IbcPacket { pub timeout: IbcTimeout, } -impl IbcPacket { - /// Construct a new IbcPacket. - pub fn new( - data: impl Into, - src: IbcEndpoint, - dest: IbcEndpoint, - sequence: u64, - timeout: IbcTimeout, - ) -> Self { - Self { - data: data.into(), - src, - dest, - sequence, - timeout, - } - } -} - #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] pub struct IbcAcknowledgement { - pub data: Binary, - // we may add more info here in the future (meta-data from the acknowledgement) - // there have been proposals to extend this type in core ibc for future versions -} - -impl IbcAcknowledgement { - pub fn new(data: impl Into) -> Self { - IbcAcknowledgement { data: data.into() } - } - - pub fn encode_json(data: &impl Serialize) -> StdResult { - Ok(IbcAcknowledgement { - data: to_binary(data)?, - }) - } -} - -/// The message that is passed into `ibc_channel_open` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -#[non_exhaustive] -pub enum IbcChannelOpenMsg { - /// The ChanOpenInit step from https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#channel-lifecycle-management - OpenInit { channel: IbcChannel }, - /// The ChanOpenTry step from https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#channel-lifecycle-management - OpenTry { - channel: IbcChannel, - counterparty_version: String, - }, -} - -impl IbcChannelOpenMsg { - pub fn new_init(channel: IbcChannel) -> Self { - Self::OpenInit { channel } - } - - pub fn new_try(channel: IbcChannel, counterparty_version: impl Into) -> Self { - Self::OpenTry { - channel, - counterparty_version: counterparty_version.into(), - } - } - - pub fn channel(&self) -> &IbcChannel { - match self { - Self::OpenInit { channel } => channel, - Self::OpenTry { channel, .. } => channel, - } - } - - pub fn counterparty_version(&self) -> Option<&str> { - match self { - Self::OpenTry { - counterparty_version, - .. - } => Some(counterparty_version), - _ => None, - } - } -} - -impl From for IbcChannel { - fn from(msg: IbcChannelOpenMsg) -> IbcChannel { - match msg { - IbcChannelOpenMsg::OpenInit { channel } => channel, - IbcChannelOpenMsg::OpenTry { channel, .. } => channel, - } - } -} - -/// The message that is passed into `ibc_channel_connect` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -#[non_exhaustive] -pub enum IbcChannelConnectMsg { - /// The ChanOpenAck step from https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#channel-lifecycle-management - OpenAck { - channel: IbcChannel, - counterparty_version: String, - }, - /// The ChanOpenConfirm step from https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#channel-lifecycle-management - OpenConfirm { channel: IbcChannel }, -} - -impl IbcChannelConnectMsg { - pub fn new_ack(channel: IbcChannel, counterparty_version: impl Into) -> Self { - Self::OpenAck { - channel, - counterparty_version: counterparty_version.into(), - } - } - - pub fn new_confirm(channel: IbcChannel) -> Self { - Self::OpenConfirm { channel } - } - - pub fn channel(&self) -> &IbcChannel { - match self { - Self::OpenAck { channel, .. } => channel, - Self::OpenConfirm { channel } => channel, - } - } - - pub fn counterparty_version(&self) -> Option<&str> { - match self { - Self::OpenAck { - counterparty_version, - .. - } => Some(counterparty_version), - _ => None, - } - } -} - -impl From for IbcChannel { - fn from(msg: IbcChannelConnectMsg) -> IbcChannel { - match msg { - IbcChannelConnectMsg::OpenAck { channel, .. } => channel, - IbcChannelConnectMsg::OpenConfirm { channel } => channel, - } - } -} - -/// The message that is passed into `ibc_channel_close` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -#[non_exhaustive] -pub enum IbcChannelCloseMsg { - /// The ChanCloseInit step from https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#channel-lifecycle-management - CloseInit { channel: IbcChannel }, - /// The ChanCloseConfirm step from https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#channel-lifecycle-management - CloseConfirm { channel: IbcChannel }, // pub channel: IbcChannel, -} - -impl IbcChannelCloseMsg { - pub fn new_init(channel: IbcChannel) -> Self { - Self::CloseInit { channel } - } - - pub fn new_confirm(channel: IbcChannel) -> Self { - Self::CloseConfirm { channel } - } - - pub fn channel(&self) -> &IbcChannel { - match self { - Self::CloseInit { channel } => channel, - Self::CloseConfirm { channel } => channel, - } - } -} - -impl From for IbcChannel { - fn from(msg: IbcChannelCloseMsg) -> IbcChannel { - match msg { - IbcChannelCloseMsg::CloseInit { channel } => channel, - IbcChannelCloseMsg::CloseConfirm { channel } => channel, - } - } -} - -/// The message that is passed into `ibc_packet_receive` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] -pub struct IbcPacketReceiveMsg { - pub packet: IbcPacket, -} - -impl IbcPacketReceiveMsg { - pub fn new(packet: IbcPacket) -> Self { - Self { packet } - } -} - -/// The message that is passed into `ibc_packet_ack` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] -pub struct IbcPacketAckMsg { - pub acknowledgement: IbcAcknowledgement, + pub acknowledgement: Binary, pub original_packet: IbcPacket, } -impl IbcPacketAckMsg { - pub fn new(acknowledgement: IbcAcknowledgement, original_packet: IbcPacket) -> Self { - Self { - acknowledgement, - original_packet, - } - } -} - -/// The message that is passed into `ibc_packet_timeout` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] -pub struct IbcPacketTimeoutMsg { - pub packet: IbcPacket, -} - -impl IbcPacketTimeoutMsg { - pub fn new(packet: IbcPacket) -> Self { - Self { packet } - } -} - /// This is the return value for the majority of the ibc handlers. /// That are able to dispatch messages / events on their own, /// but have no meaningful return value to the calling code. @@ -438,29 +198,20 @@ impl IbcPacketTimeoutMsg { /// or that cannot redispatch messages (like the handshake callbacks) /// will use other Response types #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] pub struct IbcBasicResponse where T: Clone + fmt::Debug + PartialEq + JsonSchema, { - /// Optional list of messages to pass. These will be executed in order. - /// If the ReplyOn member is set, they will invoke this contract's `reply` entry point - /// after execution. Otherwise, they act like "fire and forget". - /// Use `SubMsg::new` to create messages with the older "fire and forget" semantics. - pub messages: Vec>, - /// The attributes that will be emitted as part of a `wasm` event. - /// - /// More info about events (and their attributes) can be found in [*Cosmos SDK* docs]. - /// - /// [*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html + /// Optional list of "subcalls" to make. These will be executed in order + /// (and this contract's subcall_response entry point invoked) + /// *before* any of the "fire and forget" messages get executed. + pub submessages: Vec>, + /// After any submessages are processed, these are all dispatched in the host blockchain. + /// If they all succeed, then the transaction is committed. If any fail, then the transaction + /// and any local contract state changes are reverted. + pub messages: Vec>, + /// The attributes that will be emitted as part of a "wasm" event pub attributes: Vec, - /// Extra, custom events separate from the main `wasm` one. These will have - /// `wasm-` prepended to the type. - /// - /// More info about events can be found in [*Cosmos SDK* docs]. - /// - /// [*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html - pub events: Vec, } impl Default for IbcBasicResponse @@ -469,126 +220,19 @@ where { fn default() -> Self { IbcBasicResponse { + submessages: vec![], messages: vec![], attributes: vec![], - events: vec![], } } } -impl IbcBasicResponse -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - pub fn new() -> Self { - Self::default() - } - - /// Add an attribute included in the main `wasm` event. - pub fn add_attribute(mut self, key: impl Into, value: impl Into) -> Self { - self.attributes.push(Attribute::new(key, value)); - self - } - - /// This creates a "fire and forget" message, by using `SubMsg::new()` to wrap it, - /// and adds it to the list of messages to process. - pub fn add_message(mut self, msg: impl Into>) -> Self { - self.messages.push(SubMsg::new(msg)); - self - } - - /// This takes an explicit SubMsg (creates via eg. `reply_on_error`) - /// and adds it to the list of messages to process. - pub fn add_submessage(mut self, msg: SubMsg) -> Self { - self.messages.push(msg); - self - } - - /// Adds an extra event to the response, separate from the main `wasm` event - /// that is always created. - /// - /// The `wasm-` prefix will be appended by the runtime to the provided type - /// of event. - pub fn add_event(mut self, event: Event) -> Self { - self.events.push(event); - self - } - - /// Bulk add attributes included in the main `wasm` event. - /// - /// Anything that can be turned into an iterator and yields something - /// that can be converted into an `Attribute` is accepted. - /// - /// ## Examples - /// - /// ``` - /// use cosmwasm_std::{attr, IbcBasicResponse}; - /// - /// let attrs = vec![ - /// ("action", "reaction"), - /// ("answer", "42"), - /// ("another", "attribute"), - /// ]; - /// let res: IbcBasicResponse = IbcBasicResponse::new().add_attributes(attrs.clone()); - /// assert_eq!(res.attributes, attrs); - /// ``` - pub fn add_attributes>( - mut self, - attrs: impl IntoIterator, - ) -> Self { - self.attributes.extend(attrs.into_iter().map(A::into)); - self - } - - /// Bulk add "fire and forget" messages to the list of messages to process. - /// - /// ## Examples - /// - /// ``` - /// use cosmwasm_std::{CosmosMsg, IbcBasicResponse}; - /// - /// fn make_response_with_msgs(msgs: Vec) -> IbcBasicResponse { - /// IbcBasicResponse::new().add_messages(msgs) - /// } - /// ``` - pub fn add_messages>>(self, msgs: impl IntoIterator) -> Self { - self.add_submessages(msgs.into_iter().map(SubMsg::new)) - } - - /// Bulk add explicit SubMsg structs to the list of messages to process. - /// - /// ## Examples - /// - /// ``` - /// use cosmwasm_std::{SubMsg, IbcBasicResponse}; - /// - /// fn make_response_with_submsgs(msgs: Vec) -> IbcBasicResponse { - /// IbcBasicResponse::new().add_submessages(msgs) - /// } - /// ``` - pub fn add_submessages(mut self, msgs: impl IntoIterator>) -> Self { - self.messages.extend(msgs.into_iter()); - self - } - - /// Bulk add custom events to the response. These are separate from the main - /// `wasm` event. - /// - /// The `wasm-` prefix will be appended by the runtime to the provided types - /// of events. - pub fn add_events(mut self, events: impl IntoIterator) -> Self { - self.events.extend(events.into_iter()); - self - } -} - // This defines the return value on packet response processing. // This "success" case should be returned even in application-level errors, // Where the acknowledgement bytes contain an encoded error message to be returned to // the calling chain. (Returning ContractResult::Err will abort processing of this packet // and not inform the calling chain). #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] pub struct IbcReceiveResponse where T: Clone + fmt::Debug + PartialEq + JsonSchema, @@ -596,24 +240,16 @@ where /// The bytes we return to the contract that sent the packet. /// This may represent a success or error of exection pub acknowledgement: Binary, - /// Optional list of messages to pass. These will be executed in order. - /// If the ReplyOn member is set, they will invoke this contract's `reply` entry point - /// after execution. Otherwise, they act like "fire and forget". - /// Use `call` or `msg.into()` to create messages with the older "fire and forget" semantics. - pub messages: Vec>, - /// The attributes that will be emitted as part of a "wasm" event. - /// - /// More info about events (and their attributes) can be found in [*Cosmos SDK* docs]. - /// - /// [*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html + /// Optional list of "subcalls" to make. These will be executed in order + /// (and this contract's subcall_response entry point invoked) + /// *before* any of the "fire and forget" messages get executed. + pub submessages: Vec>, + /// After any submessages are processed, these are all dispatched in the host blockchain. + /// If they all succeed, then the transaction is committed. If any fail, then the transaction + /// and any local contract state changes are reverted. + pub messages: Vec>, + /// The attributes that will be emitted as part of a "wasm" event pub attributes: Vec, - /// Extra, custom events separate from the main `wasm` one. These will have - /// `wasm-` prepended to the type. - /// - /// More info about events can be found in [*Cosmos SDK* docs]. - /// - /// [*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html - pub events: Vec, } impl Default for IbcReceiveResponse @@ -623,125 +259,13 @@ where fn default() -> Self { IbcReceiveResponse { acknowledgement: Binary(vec![]), + submessages: vec![], messages: vec![], attributes: vec![], - events: vec![], } } } -impl IbcReceiveResponse -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - pub fn new() -> Self { - Self::default() - } - - /// Set the acknowledgement for this response. - pub fn set_ack(mut self, ack: impl Into) -> Self { - self.acknowledgement = ack.into(); - self - } - - /// Add an attribute included in the main `wasm` event. - pub fn add_attribute(mut self, key: impl Into, value: impl Into) -> Self { - self.attributes.push(Attribute::new(key, value)); - self - } - - /// This creates a "fire and forget" message, by using `SubMsg::new()` to wrap it, - /// and adds it to the list of messages to process. - pub fn add_message(mut self, msg: impl Into>) -> Self { - self.messages.push(SubMsg::new(msg)); - self - } - - /// This takes an explicit SubMsg (creates via eg. `reply_on_error`) - /// and adds it to the list of messages to process. - pub fn add_submessage(mut self, msg: SubMsg) -> Self { - self.messages.push(msg); - self - } - - /// Adds an extra event to the response, separate from the main `wasm` event - /// that is always created. - /// - /// The `wasm-` prefix will be appended by the runtime to the provided type - /// of event. - pub fn add_event(mut self, event: Event) -> Self { - self.events.push(event); - self - } - - /// Bulk add attributes included in the main `wasm` event. - /// - /// Anything that can be turned into an iterator and yields something - /// that can be converted into an `Attribute` is accepted. - /// - /// ## Examples - /// - /// ``` - /// use cosmwasm_std::{attr, IbcReceiveResponse}; - /// - /// let attrs = vec![ - /// ("action", "reaction"), - /// ("answer", "42"), - /// ("another", "attribute"), - /// ]; - /// let res: IbcReceiveResponse = IbcReceiveResponse::new().add_attributes(attrs.clone()); - /// assert_eq!(res.attributes, attrs); - /// ``` - pub fn add_attributes>( - mut self, - attrs: impl IntoIterator, - ) -> Self { - self.attributes.extend(attrs.into_iter().map(A::into)); - self - } - - /// Bulk add "fire and forget" messages to the list of messages to process. - /// - /// ## Examples - /// - /// ``` - /// use cosmwasm_std::{CosmosMsg, IbcReceiveResponse}; - /// - /// fn make_response_with_msgs(msgs: Vec) -> IbcReceiveResponse { - /// IbcReceiveResponse::new().add_messages(msgs) - /// } - /// ``` - pub fn add_messages>>(self, msgs: impl IntoIterator) -> Self { - self.add_submessages(msgs.into_iter().map(SubMsg::new)) - } - - /// Bulk add explicit SubMsg structs to the list of messages to process. - /// - /// ## Examples - /// - /// ``` - /// use cosmwasm_std::{SubMsg, IbcReceiveResponse}; - /// - /// fn make_response_with_submsgs(msgs: Vec) -> IbcReceiveResponse { - /// IbcReceiveResponse::new().add_submessages(msgs) - /// } - /// ``` - pub fn add_submessages(mut self, msgs: impl IntoIterator>) -> Self { - self.messages.extend(msgs.into_iter()); - self - } - - /// Bulk add custom events to the response. These are separate from the main - /// `wasm` event. - /// - /// The `wasm-` prefix will be appended by the runtime to the provided types - /// of events. - pub fn add_events(mut self, events: impl IntoIterator) -> Self { - self.events.extend(events.into_iter()); - self - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/packages/std/src/ibc_exports.rs b/packages/std/src/ibc_exports.rs index ca3762f42..611588aa6 100644 --- a/packages/std/src/ibc_exports.rs +++ b/packages/std/src/ibc_exports.rs @@ -7,14 +7,12 @@ use serde::Serialize; use crate::deps::DepsMut; use crate::exports::make_dependencies; -use crate::ibc::{ - IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcPacketAckMsg, - IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, -}; +use crate::ibc::{IbcBasicResponse, IbcChannel}; use crate::memory::{consume_region, release_buffer, Region}; use crate::results::ContractResult; use crate::serde::{from_slice, to_vec}; use crate::types::Env; +use crate::{IbcAcknowledgement, IbcPacket, IbcReceiveResponse}; // TODO: replace with https://doc.rust-lang.org/std/ops/trait.Try.html once stabilized macro_rules! r#try_into_contract_result { @@ -35,7 +33,7 @@ macro_rules! r#try_into_contract_result { /// /// contract_fn does the protocol version negotiation during channel handshake phase pub fn do_ibc_channel_open( - contract_fn: &dyn Fn(DepsMut, Env, IbcChannelOpenMsg) -> Result<(), E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcChannel) -> Result<(), E>, env_ptr: u32, msg_ptr: u32, ) -> u32 @@ -48,7 +46,7 @@ where } fn _do_ibc_channel_open( - contract_fn: &dyn Fn(DepsMut, Env, IbcChannelOpenMsg) -> Result<(), E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcChannel) -> Result<(), E>, env_ptr: *mut Region, msg_ptr: *mut Region, ) -> ContractResult<()> @@ -59,7 +57,7 @@ where let msg: Vec = unsafe { consume_region(msg_ptr) }; let env: Env = try_into_contract_result!(from_slice(&env)); - let msg: IbcChannelOpenMsg = try_into_contract_result!(from_slice(&msg)); + let msg: IbcChannel = try_into_contract_result!(from_slice(&msg)); let mut deps = make_dependencies(); contract_fn(deps.as_mut(), env, msg).into() @@ -69,7 +67,7 @@ where /// /// contract_fn is a callback when a IBC channel is established (after both sides agree in open) pub fn do_ibc_channel_connect( - contract_fn: &dyn Fn(DepsMut, Env, IbcChannelConnectMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcChannel) -> Result, E>, env_ptr: u32, msg_ptr: u32, ) -> u32 @@ -83,7 +81,7 @@ where } fn _do_ibc_channel_connect( - contract_fn: &dyn Fn(DepsMut, Env, IbcChannelConnectMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcChannel) -> Result, E>, env_ptr: *mut Region, msg_ptr: *mut Region, ) -> ContractResult> @@ -95,7 +93,7 @@ where let msg: Vec = unsafe { consume_region(msg_ptr) }; let env: Env = try_into_contract_result!(from_slice(&env)); - let msg: IbcChannelConnectMsg = try_into_contract_result!(from_slice(&msg)); + let msg: IbcChannel = try_into_contract_result!(from_slice(&msg)); let mut deps = make_dependencies(); contract_fn(deps.as_mut(), env, msg).into() @@ -105,7 +103,7 @@ where /// /// contract_fn is a callback when a IBC channel belonging to this contract is closed pub fn do_ibc_channel_close( - contract_fn: &dyn Fn(DepsMut, Env, IbcChannelCloseMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcChannel) -> Result, E>, env_ptr: u32, msg_ptr: u32, ) -> u32 @@ -119,7 +117,7 @@ where } fn _do_ibc_channel_close( - contract_fn: &dyn Fn(DepsMut, Env, IbcChannelCloseMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcChannel) -> Result, E>, env_ptr: *mut Region, msg_ptr: *mut Region, ) -> ContractResult> @@ -131,7 +129,7 @@ where let msg: Vec = unsafe { consume_region(msg_ptr) }; let env: Env = try_into_contract_result!(from_slice(&env)); - let msg: IbcChannelCloseMsg = try_into_contract_result!(from_slice(&msg)); + let msg: IbcChannel = try_into_contract_result!(from_slice(&msg)); let mut deps = make_dependencies(); contract_fn(deps.as_mut(), env, msg).into() @@ -142,7 +140,7 @@ where /// contract_fn is called when this chain receives an IBC Packet on a channel belonging /// to this contract pub fn do_ibc_packet_receive( - contract_fn: &dyn Fn(DepsMut, Env, IbcPacketReceiveMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcPacket) -> Result, E>, env_ptr: u32, msg_ptr: u32, ) -> u32 @@ -156,7 +154,7 @@ where } fn _do_ibc_packet_receive( - contract_fn: &dyn Fn(DepsMut, Env, IbcPacketReceiveMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcPacket) -> Result, E>, env_ptr: *mut Region, msg_ptr: *mut Region, ) -> ContractResult> @@ -168,7 +166,7 @@ where let msg: Vec = unsafe { consume_region(msg_ptr) }; let env: Env = try_into_contract_result!(from_slice(&env)); - let msg: IbcPacketReceiveMsg = try_into_contract_result!(from_slice(&msg)); + let msg: IbcPacket = try_into_contract_result!(from_slice(&msg)); let mut deps = make_dependencies(); contract_fn(deps.as_mut(), env, msg).into() @@ -179,7 +177,7 @@ where /// contract_fn is called when this chain receives an IBC Acknowledgement for a packet /// that this contract previously sent pub fn do_ibc_packet_ack( - contract_fn: &dyn Fn(DepsMut, Env, IbcPacketAckMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcAcknowledgement) -> Result, E>, env_ptr: u32, msg_ptr: u32, ) -> u32 @@ -193,7 +191,7 @@ where } fn _do_ibc_packet_ack( - contract_fn: &dyn Fn(DepsMut, Env, IbcPacketAckMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcAcknowledgement) -> Result, E>, env_ptr: *mut Region, msg_ptr: *mut Region, ) -> ContractResult> @@ -205,7 +203,7 @@ where let msg: Vec = unsafe { consume_region(msg_ptr) }; let env: Env = try_into_contract_result!(from_slice(&env)); - let msg: IbcPacketAckMsg = try_into_contract_result!(from_slice(&msg)); + let msg: IbcAcknowledgement = try_into_contract_result!(from_slice(&msg)); let mut deps = make_dependencies(); contract_fn(deps.as_mut(), env, msg).into() @@ -217,7 +215,7 @@ where /// timedout and will never be relayed to the calling chain. This generally behaves /// like ick_ack_fn upon an acknowledgement containing an error. pub fn do_ibc_packet_timeout( - contract_fn: &dyn Fn(DepsMut, Env, IbcPacketTimeoutMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcPacket) -> Result, E>, env_ptr: u32, msg_ptr: u32, ) -> u32 @@ -231,7 +229,7 @@ where } fn _do_ibc_packet_timeout( - contract_fn: &dyn Fn(DepsMut, Env, IbcPacketTimeoutMsg) -> Result, E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcPacket) -> Result, E>, env_ptr: *mut Region, msg_ptr: *mut Region, ) -> ContractResult> @@ -243,7 +241,7 @@ where let msg: Vec = unsafe { consume_region(msg_ptr) }; let env: Env = try_into_contract_result!(from_slice(&env)); - let msg: IbcPacketTimeoutMsg = try_into_contract_result!(from_slice(&msg)); + let msg: IbcPacket = try_into_contract_result!(from_slice(&msg)); let mut deps = make_dependencies(); contract_fn(deps.as_mut(), env, msg).into() diff --git a/packages/std/src/imports.rs b/packages/std/src/imports.rs index 9bbe15a06..69866d271 100644 --- a/packages/std/src/imports.rs +++ b/packages/std/src/imports.rs @@ -21,13 +21,13 @@ use crate::{ }; /// An upper bound for typical canonical address lengths (e.g. 20 in Cosmos SDK/Ethereum or 32 in Nano/Substrate) -const CANONICAL_ADDRESS_BUFFER_LENGTH: usize = 64; +const CANONICAL_ADDRESS_BUFFER_LENGTH: usize = 32; /// An upper bound for typical human readable address formats (e.g. 42 for Ethereum hex addresses or 90 for bech32) const HUMAN_ADDRESS_BUFFER_LENGTH: usize = 90; // This interface will compile into required Wasm imports. // A complete documentation those functions is available in the VM that provides them: -// https://github.com/line/cosmwasm/blob/0342c82d5e5c588131c28fae1fb941505838f352/packages/vm/src/instance.rs#L84-L201 +// https://github.com/line/cosmwasm/blob/main/packages/vm/src/instance.rs extern "C" { fn db_read(key: u32) -> u32; fn db_write(key: u32, value: u32); @@ -160,15 +160,8 @@ impl ExternalApi { } impl Api for ExternalApi { - fn addr_validate(&self, input: &str) -> StdResult { - let input_bytes = input.as_bytes(); - if input_bytes.len() > 90 { - // See MAX_LENGTH_HUMAN_ADDRESS in the VM. - // In this case, the VM will refuse to read the input from the contract. - // Stop here to allow handling the error in the contract. - return Err(StdError::generic_err("input too long for addr_validate")); - } - let source = build_region(input_bytes); + fn addr_validate(&self, human: &str) -> StdResult { + let source = build_region(human.as_bytes()); let source_ptr = &*source as *const Region as u32; let result = unsafe { addr_validate(source_ptr) }; @@ -180,20 +173,11 @@ impl Api for ExternalApi { ))); } - Ok(Addr::unchecked(input)) + Ok(Addr::unchecked(human)) } - fn addr_canonicalize(&self, input: &str) -> StdResult { - let input_bytes = input.as_bytes(); - if input_bytes.len() > 90 { - // See MAX_LENGTH_HUMAN_ADDRESS in the VM. - // In this case, the VM will refuse to read the input from the contract. - // Stop here to allow handling the error in the contract. - return Err(StdError::generic_err( - "input too long for addr_canonicalize", - )); - } - let send = build_region(input_bytes); + fn addr_canonicalize(&self, human: &str) -> StdResult { + let send = build_region(human.as_bytes()); let send_ptr = &*send as *const Region as u32; let canon = alloc(CANONICAL_ADDRESS_BUFFER_LENGTH); @@ -299,7 +283,7 @@ impl Api for ExternalApi { match result { 0 => Ok(true), 1 => Ok(false), - 2 => panic!("Error code 2 unused since CosmWasm 0.15. This is a bug in the VM."), + 2 => Err(VerificationError::MessageTooLong), 3 => panic!("InvalidHashFormat must not happen. This is a bug in the VM."), 4 => Err(VerificationError::InvalidSignatureFormat), 5 => Err(VerificationError::InvalidPubkeyFormat), @@ -331,7 +315,7 @@ impl Api for ExternalApi { match result { 0 => Ok(true), 1 => Ok(false), - 2 => panic!("Error code 2 unused since CosmWasm 0.15. This is a bug in the VM."), + 2 => Err(VerificationError::MessageTooLong), 3 => panic!("InvalidHashFormat must not happen. This is a bug in the VM."), 4 => Err(VerificationError::InvalidSignatureFormat), 5 => Err(VerificationError::InvalidPubkeyFormat), @@ -357,7 +341,7 @@ impl Api for ExternalApi { Ok(hash_array) } 1 => Err(HashCalculationError::InputsTooLarger), - 2 => panic!("Error code 2 unused since CosmWasm 0.15. This is a bug in the VM."), + 2 => Err(HashCalculationError::InputTooLonger), error_code => Err(HashCalculationError::unknown_err(error_code)), } } diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 15e14ea82..2c69aca28 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -30,19 +30,18 @@ pub use crate::binary::Binary; pub use crate::coins::{coin, coins, has_coins, Coin}; pub use crate::deps::{Deps, DepsMut, OwnedDeps}; pub use crate::errors::{ - ConversionOverflowError, DivideByZeroError, OverflowError, OverflowOperation, - RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError, + DivideByZeroError, OverflowError, OverflowOperation, RecoverPubkeyError, StdError, StdResult, + SystemError, VerificationError, }; #[cfg(feature = "stargate")] pub use crate::ibc::{ - IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, - IbcChannelOpenMsg, IbcEndpoint, IbcMsg, IbcOrder, IbcPacket, IbcPacketAckMsg, - IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, IbcTimeout, IbcTimeoutBlock, + IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcEndpoint, IbcMsg, IbcOrder, IbcPacket, + IbcReceiveResponse, IbcTimeout, IbcTimeoutBlock, }; #[cfg(feature = "iterator")] #[allow(deprecated)] pub use crate::iterator::{Order, Pair, KV}; -pub use crate::math::{Decimal, Decimal256, Fraction, Uint128, Uint256, Uint512, Uint64}; +pub use crate::math::{Decimal, Fraction, Uint128, Uint64}; pub use crate::query::{ AllBalanceResponse, BalanceResponse, BankQuery, CustomQuery, QueryRequest, WasmQuery, }; @@ -55,13 +54,12 @@ pub use crate::query::{ pub use crate::query::{ChannelResponse, IbcQuery, ListChannelsResponse, PortIdResponse}; pub use crate::results::{ attr, wasm_execute, wasm_instantiate, Attribute, BankMsg, ContractResult, CosmosMsg, Empty, - Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubMsgExecutionResponse, SystemResult, - WasmMsg, + Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubcallResponse, SystemResult, WasmMsg, }; +#[allow(deprecated)] +pub use crate::results::{Context, HandleResponse, InitResponse, MigrateResponse}; #[cfg(feature = "staking")] pub use crate::results::{DistributionMsg, StakingMsg}; -#[cfg(feature = "stargate")] -pub use crate::results::{GovMsg, VoteOption}; pub use crate::serde::{from_binary, from_slice, to_binary, to_vec}; pub use crate::storage::MemoryStorage; pub use crate::timestamp::Timestamp; @@ -102,16 +100,11 @@ pub mod testing { pub use crate::mock::StakingQuerier; pub use crate::mock::{ digit_sum, mock_dependencies, mock_dependencies_with_balances, mock_env, mock_info, - mock_wasmd_attr, riffle_shuffle, BankQuerier, MockApi, MockQuerier, - MockQuerierCustomHandlerResult, MockStorage, MOCK_CONTRACT_ADDR, + riffle_shuffle, BankQuerier, MockApi, MockQuerier, MockQuerierCustomHandlerResult, + MockStorage, MOCK_CONTRACT_ADDR, }; #[cfg(feature = "stargate")] - pub use crate::mock::{ - mock_ibc_channel, mock_ibc_channel_close_confirm, mock_ibc_channel_close_init, - mock_ibc_channel_connect_ack, mock_ibc_channel_connect_confirm, mock_ibc_channel_open_init, - mock_ibc_channel_open_try, mock_ibc_packet_ack, mock_ibc_packet_recv, - mock_ibc_packet_timeout, - }; + pub use crate::mock::{mock_ibc_channel, mock_ibc_packet_ack, mock_ibc_packet_recv}; } // Re-exports diff --git a/packages/std/src/math/decimal.rs b/packages/std/src/math/decimal.rs index d95a54679..a08d5ed16 100644 --- a/packages/std/src/math/decimal.rs +++ b/packages/std/src/math/decimal.rs @@ -7,117 +7,78 @@ use std::str::FromStr; use crate::errors::StdError; use super::Fraction; -use super::Isqrt; use super::Uint128; /// A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0 /// /// The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) #[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Decimal(#[schemars(with = "String")] Uint128); +pub struct Decimal(#[schemars(with = "String")] u128); -impl Decimal { - const DECIMAL_FRACTIONAL: Uint128 = Uint128::new(1_000_000_000_000_000_000u128); // 1*10**18 - const DECIMAL_FRACTIONAL_SQUARED: Uint128 = - Uint128::new(1_000_000_000_000_000_000_000_000_000_000_000_000u128); // (1*10**18)**2 = 1*10**36 - const DECIMAL_PLACES: usize = 18; // This needs to be an even number. +const DECIMAL_FRACTIONAL: u128 = 1_000_000_000_000_000_000; // 1*10**18 +const DECIMAL_FRACTIONAL_SQUARED: u128 = 1_000_000_000_000_000_000_000_000_000_000_000_000; // (1*10**18)**2 = 1*10**36 - pub const MAX: Self = Self(Uint128::MAX); +impl Decimal { + pub const MAX: Decimal = Decimal(u128::MAX); /// Create a 1.0 Decimal - pub const fn one() -> Self { - Decimal(Self::DECIMAL_FRACTIONAL) + pub const fn one() -> Decimal { + Decimal(DECIMAL_FRACTIONAL) } /// Create a 0.0 Decimal - pub const fn zero() -> Self { - Decimal(Uint128::zero()) + pub const fn zero() -> Decimal { + Decimal(0) } /// Convert x% into Decimal - pub fn percent(x: u64) -> Self { - Decimal(((x as u128) * 10_000_000_000_000_000).into()) + pub fn percent(x: u64) -> Decimal { + Decimal((x as u128) * 10_000_000_000_000_000) } /// Convert permille (x/1000) into Decimal - pub fn permille(x: u64) -> Self { - Decimal(((x as u128) * 1_000_000_000_000_000).into()) + pub fn permille(x: u64) -> Decimal { + Decimal((x as u128) * 1_000_000_000_000_000) } /// Returns the ratio (numerator / denominator) as a Decimal - pub fn from_ratio(numerator: impl Into, denominator: impl Into) -> Self { - let numerator: Uint128 = numerator.into(); - let denominator: Uint128 = denominator.into(); - if denominator.is_zero() { + pub fn from_ratio, B: Into>(numerator: A, denominator: B) -> Decimal { + let numerator: u128 = numerator.into(); + let denominator: u128 = denominator.into(); + if denominator == 0 { panic!("Denominator must not be zero"); } - - Decimal( - // numerator * DECIMAL_FRACTIONAL / denominator - numerator.multiply_ratio(Self::DECIMAL_FRACTIONAL, denominator), - ) + // TODO: better algorithm with less rounding potential? + Decimal(numerator * DECIMAL_FRACTIONAL / denominator) } pub fn is_zero(&self) -> bool { - self.0.is_zero() - } - - /// Returns the approximate square root as a Decimal. - /// - /// This should not overflow or panic. - #[must_use] - pub fn sqrt(&self) -> Self { - // Algorithm described in https://hackmd.io/@webmaster128/SJThlukj_ - // We start with the highest precision possible and lower it until - // there's no overflow. - // - // TODO: This could be made more efficient once log10 is in: - // https://github.com/rust-lang/rust/issues/70887 - // The max precision is something like `9 - log10(self.0) / 2`. - (0..=Self::DECIMAL_PLACES / 2) - .rev() - .find_map(|i| self.sqrt_with_precision(i)) - // The last step (i = 0) is guaranteed to succeed because `isqrt(u128::MAX) * 10^9` does not overflow - .unwrap() - } - - /// Lower precision means more aggressive rounding, but less risk of overflow. - /// Precision *must* be a number between 0 and 9 (inclusive). - /// - /// Returns `None` if the internal multiplication overflows. - fn sqrt_with_precision(&self, precision: usize) -> Option { - let precision = precision as u32; - - let inner_mul = 100u128.pow(precision); - self.0.checked_mul(inner_mul.into()).ok().map(|inner| { - let outer_mul = 10u128.pow(Self::DECIMAL_PLACES as u32 / 2 - precision); - Decimal(inner.isqrt().checked_mul(Uint128::from(outer_mul)).unwrap()) - }) + self.0 == 0 } } impl Fraction for Decimal { #[inline] fn numerator(&self) -> u128 { - self.0.u128() + self.0 } #[inline] fn denominator(&self) -> u128 { - Self::DECIMAL_FRACTIONAL.u128() + DECIMAL_FRACTIONAL } /// Returns the multiplicative inverse `1/d` for decimal `d`. /// /// If `d` is zero, none is returned. - fn inv(&self) -> Option { + fn inv(&self) -> Option { if self.is_zero() { None } else { // Let self be p/q with p = self.0 and q = DECIMAL_FRACTIONAL. // Now we calculate the inverse a/b = q/p such that b = DECIMAL_FRACTIONAL. Then // `a = DECIMAL_FRACTIONAL*DECIMAL_FRACTIONAL / self.0`. - Some(Decimal(Self::DECIMAL_FRACTIONAL_SQUARED / self.0)) + Some(Decimal(DECIMAL_FRACTIONAL_SQUARED / self.0)) } } } @@ -130,38 +91,30 @@ impl FromStr for Decimal { /// Disallowed: "", ".23" /// /// This never performs any kind of rounding. - /// More than DECIMAL_PLACES fractional digits, even zeros, result in an error. + /// More than 18 fractional digits, even zeros, result in an error. fn from_str(input: &str) -> Result { let mut parts_iter = input.split('.'); let whole_part = parts_iter.next().unwrap(); // split always returns at least one element let whole = whole_part - .parse::() + .parse::() .map_err(|_| StdError::generic_err("Error parsing whole"))?; let mut atomics = whole - .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| StdError::generic_err("Value too big"))?; + .checked_mul(DECIMAL_FRACTIONAL) + .ok_or_else(|| StdError::generic_err("Value too big"))?; if let Some(fractional_part) = parts_iter.next() { let fractional = fractional_part - .parse::() + .parse::() .map_err(|_| StdError::generic_err("Error parsing fractional"))?; - let exp = - (Self::DECIMAL_PLACES.checked_sub(fractional_part.len())).ok_or_else(|| { - StdError::generic_err(format!( - "Cannot parse more than {} fractional digits", - Self::DECIMAL_PLACES - )) - })?; - debug_assert!(exp <= Self::DECIMAL_PLACES); - let fractional_factor = Uint128::from(10u128.pow(exp as u32)); + let exp = (18usize.checked_sub(fractional_part.len())).ok_or_else(|| { + StdError::generic_err("Cannot parse more than 18 fractional digits") + })?; + debug_assert!(exp <= 18); + let fractional_factor = 10u128.pow(exp as u32); atomics = atomics - .checked_add( - // The inner multiplication can't overflow because - // fractional < 10^DECIMAL_PLACES && fractional_factor <= 10^DECIMAL_PLACES - fractional.checked_mul(fractional_factor).unwrap(), - ) - .map_err(|_| StdError::generic_err("Value too big"))?; + .checked_add(fractional * fractional_factor) + .ok_or_else(|| StdError::generic_err("Value too big"))?; } if parts_iter.next().is_some() { @@ -174,14 +127,13 @@ impl FromStr for Decimal { impl fmt::Display for Decimal { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let whole = (self.0) / Self::DECIMAL_FRACTIONAL; - let fractional = (self.0).checked_rem(Self::DECIMAL_FRACTIONAL).unwrap(); + let whole = (self.0) / DECIMAL_FRACTIONAL; + let fractional = (self.0) % DECIMAL_FRACTIONAL; - if fractional.is_zero() { + if fractional == 0 { write!(f, "{}", whole) } else { - let fractional_string = - format!("{:0>padding$}", fractional, padding = Self::DECIMAL_PLACES); + let fractional_string = format!("{:018}", fractional); f.write_str(&whole.to_string())?; f.write_char('.')?; f.write_str(fractional_string.trim_end_matches('0'))?; @@ -198,14 +150,6 @@ impl ops::Add for Decimal { } } -impl ops::Sub for Decimal { - type Output = Self; - - fn sub(self, other: Self) -> Self { - Decimal(self.0 - other.0) - } -} - /// Both d*u and u*d with d: Decimal and u: Uint128 returns an Uint128. There is no /// specific reason for this decision other than the initial use cases we have. If you /// need a Decimal result for the same calculation, use Decimal(d*u) or Decimal(u*d). @@ -218,7 +162,7 @@ impl ops::Mul for Uint128 { if self.is_zero() || rhs.is_zero() { return Uint128::zero(); } - self.multiply_ratio(rhs.0, Decimal::DECIMAL_FRACTIONAL) + self.multiply_ratio(rhs.0, DECIMAL_FRACTIONAL) } } @@ -230,20 +174,6 @@ impl ops::Mul for Decimal { } } -impl ops::Div for Decimal { - type Output = Self; - - fn div(self, rhs: Uint128) -> Self::Output { - Decimal(self.0 / rhs) - } -} - -impl ops::DivAssign for Decimal { - fn div_assign(&mut self, rhs: Uint128) { - self.0 /= rhs; - } -} - /// Serializes as a decimal string impl Serialize for Decimal { fn serialize(&self, serializer: S) -> Result @@ -256,7 +186,7 @@ impl Serialize for Decimal { /// Deserializes as a base64 string impl<'de> Deserialize<'de> for Decimal { - fn deserialize(deserializer: D) -> Result + fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { @@ -293,25 +223,25 @@ mod tests { #[test] fn decimal_one() { let value = Decimal::one(); - assert_eq!(value.0, Decimal::DECIMAL_FRACTIONAL); + assert_eq!(value.0, DECIMAL_FRACTIONAL); } #[test] fn decimal_zero() { let value = Decimal::zero(); - assert!(value.0.is_zero()); + assert_eq!(value.0, 0); } #[test] fn decimal_percent() { let value = Decimal::percent(50); - assert_eq!(value.0, Decimal::DECIMAL_FRACTIONAL / Uint128::from(2u8)); + assert_eq!(value.0, DECIMAL_FRACTIONAL / 2); } #[test] fn decimal_permille() { let value = Decimal::permille(125); - assert_eq!(value.0, Decimal::DECIMAL_FRACTIONAL / Uint128::from(8u8)); + assert_eq!(value.0, DECIMAL_FRACTIONAL / 8); } #[test] @@ -333,22 +263,13 @@ mod tests { // 1/3 (result floored) assert_eq!( Decimal::from_ratio(1u64, 3u64), - Decimal(Uint128::from(333_333_333_333_333_333u128)) + Decimal(333_333_333_333_333_333) ); // 2/3 (result floored) assert_eq!( Decimal::from_ratio(2u64, 3u64), - Decimal(Uint128::from(666_666_666_666_666_666u128)) - ); - - // large inputs - assert_eq!(Decimal::from_ratio(0u128, u128::MAX), Decimal::zero()); - assert_eq!(Decimal::from_ratio(u128::MAX, u128::MAX), Decimal::one()); - // 340282366920938463463 is the largest integer <= Decimal::MAX - assert_eq!( - Decimal::from_ratio(340282366920938463463u128, 1u128), - Decimal::from_str("340282366920938463463").unwrap() + Decimal(666_666_666_666_666_666) ); } @@ -361,8 +282,8 @@ mod tests { #[test] fn decimal_implements_fraction() { let fraction = Decimal::from_str("1234.567").unwrap(); - assert_eq!(fraction.numerator(), 1_234_567_000_000_000_000_000u128); - assert_eq!(fraction.denominator(), 1_000_000_000_000_000_000u128); + assert_eq!(fraction.numerator(), 1_234_567_000_000_000_000_000); + assert_eq!(fraction.denominator(), 1_000_000_000_000_000_000); } #[test] @@ -388,14 +309,14 @@ mod tests { assert_eq!(Decimal::from_str("00.40").unwrap(), Decimal::percent(40)); assert_eq!(Decimal::from_str("00.04").unwrap(), Decimal::percent(4)); - // Can handle DECIMAL_PLACES fractional digits + // Can handle 18 fractional digits assert_eq!( Decimal::from_str("7.123456789012345678").unwrap(), - Decimal(Uint128::from(7123456789012345678u128)) + Decimal(7123456789012345678) ); assert_eq!( Decimal::from_str("7.999999999999999999").unwrap(), - Decimal(Uint128::from(7999999999999999999u128)) + Decimal(7999999999999999999) ); // Works for documented max value @@ -450,7 +371,7 @@ mod tests { fn decimal_from_str_errors_for_more_than_18_fractional_digits() { match Decimal::from_str("7.1234567890123456789").unwrap_err() { StdError::GenericErr { msg, .. } => { - assert_eq!(msg, "Cannot parse more than 18 fractional digits",) + assert_eq!(msg, "Cannot parse more than 18 fractional digits") } e => panic!("Unexpected error: {:?}", e), } @@ -498,13 +419,13 @@ mod tests { #[test] fn decimal_is_zero_works() { - assert!(Decimal::zero().is_zero()); - assert!(Decimal::percent(0).is_zero()); - assert!(Decimal::permille(0).is_zero()); + assert_eq!(Decimal::zero().is_zero(), true); + assert_eq!(Decimal::percent(0).is_zero(), true); + assert_eq!(Decimal::permille(0).is_zero(), true); - assert!(!Decimal::one().is_zero()); - assert!(!Decimal::percent(123).is_zero()); - assert!(!Decimal::permille(1234).is_zero()); + assert_eq!(Decimal::one().is_zero(), false); + assert_eq!(Decimal::percent(123).is_zero(), false); + assert_eq!(Decimal::permille(1234).is_zero(), false); } #[test] @@ -565,47 +486,26 @@ mod tests { #[test] fn decimal_add() { let value = Decimal::one() + Decimal::percent(50); // 1.5 - assert_eq!( - value.0, - Decimal::DECIMAL_FRACTIONAL * Uint128::from(3u8) / Uint128::from(2u8) - ); - } - - #[test] - #[should_panic(expected = "attempt to add with overflow")] - fn decimal_add_overflow_panics() { - let _value = Decimal::MAX + Decimal::percent(50); - } - - #[test] - fn decimal_sub() { - let value = Decimal::one() - Decimal::percent(50); // 0.5 - assert_eq!(value.0, Decimal::DECIMAL_FRACTIONAL / Uint128::from(2u8)); - } - - #[test] - #[should_panic(expected = "attempt to subtract with overflow")] - fn decimal_sub_overflow_panics() { - let _value = Decimal::zero() - Decimal::percent(50); + assert_eq!(value.0, DECIMAL_FRACTIONAL * 3 / 2); } #[test] // in this test the Decimal is on the right fn uint128_decimal_multiply() { // a*b - let left = Uint128::new(300); + let left = Uint128(300); let right = Decimal::one() + Decimal::percent(50); // 1.5 - assert_eq!(left * right, Uint128::new(450)); + assert_eq!(left * right, Uint128(450)); // a*0 - let left = Uint128::new(300); + let left = Uint128(300); let right = Decimal::zero(); - assert_eq!(left * right, Uint128::new(0)); + assert_eq!(left * right, Uint128(0)); // 0*a - let left = Uint128::new(0); + let left = Uint128(0); let right = Decimal::one() + Decimal::percent(50); // 1.5 - assert_eq!(left * right, Uint128::new(0)); + assert_eq!(left * right, Uint128(0)); } #[test] @@ -613,96 +513,18 @@ mod tests { fn decimal_uint128_multiply() { // a*b let left = Decimal::one() + Decimal::percent(50); // 1.5 - let right = Uint128::new(300); - assert_eq!(left * right, Uint128::new(450)); + let right = Uint128(300); + assert_eq!(left * right, Uint128(450)); // 0*a let left = Decimal::zero(); - let right = Uint128::new(300); - assert_eq!(left * right, Uint128::new(0)); + let right = Uint128(300); + assert_eq!(left * right, Uint128(0)); // a*0 let left = Decimal::one() + Decimal::percent(50); // 1.5 - let right = Uint128::new(0); - assert_eq!(left * right, Uint128::new(0)); - } - - #[test] - fn decimal_uint128_division() { - // a/b - let left = Decimal::percent(150); // 1.5 - let right = Uint128::new(3); - assert_eq!(left / right, Decimal::percent(50)); - - // 0/a - let left = Decimal::zero(); - let right = Uint128::new(300); - assert_eq!(left / right, Decimal::zero()); - } - - #[test] - #[should_panic(expected = "attempt to divide by zero")] - fn decimal_uint128_divide_by_zero() { - let left = Decimal::percent(150); // 1.5 - let right = Uint128::new(0); - let _result = left / right; - } - - #[test] - fn decimal_uint128_div_assign() { - // a/b - let mut dec = Decimal::percent(150); // 1.5 - dec /= Uint128::new(3); - assert_eq!(dec, Decimal::percent(50)); - - // 0/a - let mut dec = Decimal::zero(); - dec /= Uint128::new(300); - assert_eq!(dec, Decimal::zero()); - } - - #[test] - #[should_panic(expected = "attempt to divide by zero")] - fn decimal_uint128_div_assign_by_zero() { - // a/0 - let mut dec = Decimal::percent(50); - dec /= Uint128::new(0); - } - - #[test] - fn decimal_uint128_sqrt() { - assert_eq!(Decimal::percent(900).sqrt(), Decimal::percent(300)); - - assert!(Decimal::percent(316) < Decimal::percent(1000).sqrt()); - assert!(Decimal::percent(1000).sqrt() < Decimal::percent(317)); - } - - /// sqrt(2) is an irrational number, i.e. all 18 decimal places should be used. - #[test] - fn decimal_uint128_sqrt_is_precise() { - assert_eq!( - Decimal::from_str("2").unwrap().sqrt(), - Decimal::from_str("1.414213562373095048").unwrap() // https://www.wolframalpha.com/input/?i=sqrt%282%29 - ); - } - - #[test] - fn decimal_uint128_sqrt_does_not_overflow() { - assert_eq!( - Decimal::from_str("400").unwrap().sqrt(), - Decimal::from_str("20").unwrap() - ); - } - - #[test] - fn decimal_uint128_sqrt_intermediate_precision_used() { - assert_eq!( - Decimal::from_str("400001").unwrap().sqrt(), - // The last two digits (27) are truncated below due to the algorithm - // we use. Larger numbers will cause less precision. - // https://www.wolframalpha.com/input/?i=sqrt%28400001%29 - Decimal::from_str("632.456322602596803200").unwrap() - ); + let right = Uint128(0); + assert_eq!(left * right, Uint128(0)); } #[test] @@ -715,77 +537,26 @@ mod tests { // Decimals assert_eq!(Decimal::percent(125).to_string(), "1.25"); assert_eq!(Decimal::percent(42638).to_string(), "426.38"); - assert_eq!(Decimal::percent(3).to_string(), "0.03"); + assert_eq!(Decimal::percent(1).to_string(), "0.01"); assert_eq!(Decimal::permille(987).to_string(), "0.987"); - assert_eq!( - Decimal(Uint128::from(1u128)).to_string(), - "0.000000000000000001" - ); - assert_eq!( - Decimal(Uint128::from(10u128)).to_string(), - "0.00000000000000001" - ); - assert_eq!( - Decimal(Uint128::from(100u128)).to_string(), - "0.0000000000000001" - ); - assert_eq!( - Decimal(Uint128::from(1000u128)).to_string(), - "0.000000000000001" - ); - assert_eq!( - Decimal(Uint128::from(10000u128)).to_string(), - "0.00000000000001" - ); - assert_eq!( - Decimal(Uint128::from(100000u128)).to_string(), - "0.0000000000001" - ); - assert_eq!( - Decimal(Uint128::from(1000000u128)).to_string(), - "0.000000000001" - ); - assert_eq!( - Decimal(Uint128::from(10000000u128)).to_string(), - "0.00000000001" - ); - assert_eq!( - Decimal(Uint128::from(100000000u128)).to_string(), - "0.0000000001" - ); - assert_eq!( - Decimal(Uint128::from(1000000000u128)).to_string(), - "0.000000001" - ); - assert_eq!( - Decimal(Uint128::from(10000000000u128)).to_string(), - "0.00000001" - ); - assert_eq!( - Decimal(Uint128::from(100000000000u128)).to_string(), - "0.0000001" - ); - assert_eq!( - Decimal(Uint128::from(10000000000000u128)).to_string(), - "0.00001" - ); - assert_eq!( - Decimal(Uint128::from(100000000000000u128)).to_string(), - "0.0001" - ); - assert_eq!( - Decimal(Uint128::from(1000000000000000u128)).to_string(), - "0.001" - ); - assert_eq!( - Decimal(Uint128::from(10000000000000000u128)).to_string(), - "0.01" - ); - assert_eq!( - Decimal(Uint128::from(100000000000000000u128)).to_string(), - "0.1" - ); + assert_eq!(Decimal(1).to_string(), "0.000000000000000001"); + assert_eq!(Decimal(10).to_string(), "0.00000000000000001"); + assert_eq!(Decimal(100).to_string(), "0.0000000000000001"); + assert_eq!(Decimal(1000).to_string(), "0.000000000000001"); + assert_eq!(Decimal(10000).to_string(), "0.00000000000001"); + assert_eq!(Decimal(100000).to_string(), "0.0000000000001"); + assert_eq!(Decimal(1000000).to_string(), "0.000000000001"); + assert_eq!(Decimal(10000000).to_string(), "0.00000000001"); + assert_eq!(Decimal(100000000).to_string(), "0.0000000001"); + assert_eq!(Decimal(1000000000).to_string(), "0.000000001"); + assert_eq!(Decimal(10000000000).to_string(), "0.00000001"); + assert_eq!(Decimal(100000000000).to_string(), "0.0000001"); + assert_eq!(Decimal(10000000000000).to_string(), "0.00001"); + assert_eq!(Decimal(100000000000000).to_string(), "0.0001"); + assert_eq!(Decimal(1000000000000000).to_string(), "0.001"); + assert_eq!(Decimal(10000000000000000).to_string(), "0.01"); + assert_eq!(Decimal(100000000000000000).to_string(), "0.1"); } #[test] diff --git a/packages/std/src/math/decimal256.rs b/packages/std/src/math/decimal256.rs deleted file mode 100644 index 9e9b662f8..000000000 --- a/packages/std/src/math/decimal256.rs +++ /dev/null @@ -1,921 +0,0 @@ -use schemars::JsonSchema; -use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use std::fmt::{self, Write}; -use std::ops; -use std::str::FromStr; - -use crate::errors::StdError; - -use super::Fraction; -use super::Isqrt; -use super::Uint256; - -/// A fixed-point decimal value with 18 fractional digits, i.e. Decimal256(1_000_000_000_000_000_000) == 1.0 -/// -/// The greatest possible value that can be represented is -/// 115792089237316195423570985008687907853269984665640564039457.584007913129639935 -/// (which is (2^256 - 1) / 10^18) -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Decimal256(#[schemars(with = "String")] Uint256); - -impl Decimal256 { - const DECIMAL_PLACES: usize = 18; - const DECIMAL_FRACTIONAL: Uint256 = // 1*10**18 - Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 224, 182, - 179, 167, 100, 0, 0, - ]); - const DECIMAL_FRACTIONAL_SQUARED: Uint256 = // 1*10**36 - Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 151, 206, 123, 201, 7, 21, 179, - 75, 159, 16, 0, 0, 0, 0, - ]); - - pub const MAX: Self = Self(Uint256::MAX); - - /// Create a 1.0 Decimal256 - pub const fn one() -> Self { - Self(Self::DECIMAL_FRACTIONAL) - } - - /// Create a 0.0 Decimal256 - pub const fn zero() -> Self { - Self(Uint256::zero()) - } - - /// Convert x% into Decimal256 - pub fn percent(x: u64) -> Self { - Self(Uint256::from(x) * Uint256::from(10_000_000_000_000_000u128)) - } - - /// Convert permille (x/1000) into Decimal256 - pub fn permille(x: u64) -> Self { - Self(Uint256::from(x) * Uint256::from(1_000_000_000_000_000u128)) - } - - /// Returns the ratio (numerator / denominator) as a Decimal256 - pub fn from_ratio(numerator: impl Into, denominator: impl Into) -> Self { - let numerator: Uint256 = numerator.into(); - let denominator: Uint256 = denominator.into(); - if denominator.is_zero() { - panic!("Denominator must not be zero"); - } - - Self( - // numerator * DECIMAL_FRACTIONAL / denominator - numerator.multiply_ratio(Self::DECIMAL_FRACTIONAL, denominator), - ) - } - - pub fn is_zero(&self) -> bool { - self.0.is_zero() - } - - /// Returns the approximate square root as a Decimal256. - /// - /// This should not overflow or panic. - #[must_use] - pub fn sqrt(&self) -> Self { - // Algorithm described in https://hackmd.io/@webmaster128/SJThlukj_ - // We start with the highest precision possible and lower it until - // there's no overflow. - // - // TODO: This could be made more efficient once log10 is in: - // https://github.com/rust-lang/rust/issues/70887 - // The max precision is something like `18 - log10(self.0) / 2`. - (0..=Self::DECIMAL_PLACES / 2) - .rev() - .find_map(|i| self.sqrt_with_precision(i)) - // The last step (i = 0) is guaranteed to succeed because `isqrt(Uint256::MAX) * 10^9` does not overflow - .unwrap() - } - - /// Lower precision means more aggressive rounding, but less risk of overflow. - /// Precision *must* be a number between 0 and 9 (inclusive). - /// - /// Returns `None` if the internal multiplication overflows. - fn sqrt_with_precision(&self, precision: usize) -> Option { - let precision = precision as u32; - - let inner_mul = Uint256::from(100u128).pow(precision); - self.0.checked_mul(inner_mul).ok().map(|inner| { - let outer_mul = Uint256::from(10u128).pow(Self::DECIMAL_PLACES as u32 / 2 - precision); - Self(inner.isqrt().checked_mul(outer_mul).unwrap()) - }) - } -} - -impl Fraction for Decimal256 { - #[inline] - fn numerator(&self) -> Uint256 { - self.0 - } - - #[inline] - fn denominator(&self) -> Uint256 { - Self::DECIMAL_FRACTIONAL - } - - /// Returns the multiplicative inverse `1/d` for decimal `d`. - /// - /// If `d` is zero, none is returned. - fn inv(&self) -> Option { - if self.is_zero() { - None - } else { - // Let self be p/q with p = self.0 and q = DECIMAL_FRACTIONAL. - // Now we calculate the inverse a/b = q/p such that b = DECIMAL_FRACTIONAL. Then - // `a = DECIMAL_FRACTIONAL*DECIMAL_FRACTIONAL / self.0`. - Some(Self(Self::DECIMAL_FRACTIONAL_SQUARED / self.0)) - } - } -} - -impl FromStr for Decimal256 { - type Err = StdError; - - /// Converts the decimal string to a Decimal256 - /// Possible inputs: "1.23", "1", "000012", "1.123000000" - /// Disallowed: "", ".23" - /// - /// This never performs any kind of rounding. - /// More than DECIMAL_PLACES fractional digits, even zeros, result in an error. - fn from_str(input: &str) -> Result { - let mut parts_iter = input.split('.'); - - let whole_part = parts_iter.next().unwrap(); // split always returns at least one element - let whole = whole_part - .parse::() - .map_err(|_| StdError::generic_err("Error parsing whole"))?; - let mut atomics = whole - .checked_mul(Self::DECIMAL_FRACTIONAL) - .map_err(|_| StdError::generic_err("Value too big"))?; - - if let Some(fractional_part) = parts_iter.next() { - let fractional = fractional_part - .parse::() - .map_err(|_| StdError::generic_err("Error parsing fractional"))?; - let exp = - (Self::DECIMAL_PLACES.checked_sub(fractional_part.len())).ok_or_else(|| { - StdError::generic_err(format!( - "Cannot parse more than {} fractional digits", - Self::DECIMAL_PLACES - )) - })?; - debug_assert!(exp <= Self::DECIMAL_PLACES); - let fractional_factor = Uint256::from(10u128).pow(exp as u32); - atomics = atomics - .checked_add( - // The inner multiplication can't overflow because - // fractional < 10^DECIMAL_PLACES && fractional_factor <= 10^DECIMAL_PLACES - fractional.checked_mul(fractional_factor).unwrap(), - ) - .map_err(|_| StdError::generic_err("Value too big"))?; - } - - if parts_iter.next().is_some() { - return Err(StdError::generic_err("Unexpected number of dots")); - } - - Ok(Self(atomics)) - } -} - -impl fmt::Display for Decimal256 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let whole = (self.0) / Self::DECIMAL_FRACTIONAL; - let fractional = (self.0).checked_rem(Self::DECIMAL_FRACTIONAL).unwrap(); - - if fractional.is_zero() { - write!(f, "{}", whole) - } else { - let fractional_string = - format!("{:0>padding$}", fractional, padding = Self::DECIMAL_PLACES); - f.write_str(&whole.to_string())?; - f.write_char('.')?; - f.write_str(fractional_string.trim_end_matches('0'))?; - Ok(()) - } - } -} - -impl ops::Add for Decimal256 { - type Output = Self; - - fn add(self, other: Self) -> Self { - Self(self.0 + other.0) - } -} - -impl ops::Sub for Decimal256 { - type Output = Self; - - fn sub(self, other: Self) -> Self { - Self(self.0 - other.0) - } -} - -/// Both d*u and u*d with d: Decimal256 and u: Uint256 returns an Uint256. There is no -/// specific reason for this decision other than the initial use cases we have. If you -/// need a Decimal256 result for the same calculation, use Decimal256(d*u) or Decimal256(u*d). -impl ops::Mul for Uint256 { - type Output = Self; - - #[allow(clippy::suspicious_arithmetic_impl)] - fn mul(self, rhs: Decimal256) -> Self::Output { - // 0*a and b*0 is always 0 - if self.is_zero() || rhs.is_zero() { - return Uint256::zero(); - } - self.multiply_ratio(rhs.0, Decimal256::DECIMAL_FRACTIONAL) - } -} - -impl ops::Mul for Decimal256 { - type Output = Uint256; - - fn mul(self, rhs: Uint256) -> Self::Output { - rhs * self - } -} - -impl ops::Div for Decimal256 { - type Output = Self; - - fn div(self, rhs: Uint256) -> Self::Output { - Self(self.0 / rhs) - } -} - -impl ops::DivAssign for Decimal256 { - fn div_assign(&mut self, rhs: Uint256) { - self.0 /= rhs; - } -} - -/// Serializes as a decimal string -impl Serialize for Decimal256 { - fn serialize(&self, serializer: S) -> Result - where - S: ser::Serializer, - { - serializer.serialize_str(&self.to_string()) - } -} - -/// Deserializes as a base64 string -impl<'de> Deserialize<'de> for Decimal256 { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - deserializer.deserialize_str(Decimal256Visitor) - } -} - -struct Decimal256Visitor; - -impl<'de> de::Visitor<'de> for Decimal256Visitor { - type Value = Decimal256; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("string-encoded decimal") - } - - fn visit_str(self, v: &str) -> Result - where - E: de::Error, - { - match Self::Value::from_str(v) { - Ok(d) => Ok(d), - Err(e) => Err(E::custom(format!("Error parsing decimal '{}': {}", v, e))), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::errors::StdError; - use crate::{from_slice, to_vec}; - - #[test] - fn decimal_one() { - let value = Decimal256::one(); - assert_eq!(value.0, Decimal256::DECIMAL_FRACTIONAL); - } - - #[test] - fn decimal_zero() { - let value = Decimal256::zero(); - assert!(value.0.is_zero()); - } - - #[test] - fn decimal_percent() { - let value = Decimal256::percent(50); - assert_eq!(value.0, Decimal256::DECIMAL_FRACTIONAL / Uint256::from(2u8)); - } - - #[test] - fn decimal_permille() { - let value = Decimal256::permille(125); - assert_eq!(value.0, Decimal256::DECIMAL_FRACTIONAL / Uint256::from(8u8)); - } - - #[test] - fn decimal_from_ratio_works() { - // 1.0 - assert_eq!(Decimal256::from_ratio(1u128, 1u128), Decimal256::one()); - assert_eq!(Decimal256::from_ratio(53u128, 53u128), Decimal256::one()); - assert_eq!(Decimal256::from_ratio(125u128, 125u128), Decimal256::one()); - - // 1.5 - assert_eq!( - Decimal256::from_ratio(3u128, 2u128), - Decimal256::percent(150) - ); - assert_eq!( - Decimal256::from_ratio(150u128, 100u128), - Decimal256::percent(150) - ); - assert_eq!( - Decimal256::from_ratio(333u128, 222u128), - Decimal256::percent(150) - ); - - // 0.125 - assert_eq!( - Decimal256::from_ratio(1u64, 8u64), - Decimal256::permille(125) - ); - assert_eq!( - Decimal256::from_ratio(125u64, 1000u64), - Decimal256::permille(125) - ); - - // 1/3 (result floored) - assert_eq!( - Decimal256::from_ratio(1u64, 3u64), - Decimal256(Uint256::from_str("333333333333333333").unwrap()) - ); - - // 2/3 (result floored) - assert_eq!( - Decimal256::from_ratio(2u64, 3u64), - Decimal256(Uint256::from_str("666666666666666666").unwrap()) - ); - - // large inputs - assert_eq!(Decimal256::from_ratio(0u128, u128::MAX), Decimal256::zero()); - assert_eq!( - Decimal256::from_ratio(u128::MAX, u128::MAX), - Decimal256::one() - ); - // 340282366920938463463 is the largest integer <= Decimal256::MAX - assert_eq!( - Decimal256::from_ratio(340282366920938463463u128, 1u128), - Decimal256::from_str("340282366920938463463").unwrap() - ); - } - - #[test] - #[should_panic(expected = "Denominator must not be zero")] - fn decimal_from_ratio_panics_for_zero_denominator() { - Decimal256::from_ratio(1u128, 0u128); - } - - #[test] - fn decimal_implements_fraction() { - let fraction = Decimal256::from_str("1234.567").unwrap(); - assert_eq!( - fraction.numerator(), - Uint256::from_str("1234567000000000000000").unwrap() - ); - assert_eq!( - fraction.denominator(), - Uint256::from_str("1000000000000000000").unwrap() - ); - } - - #[test] - fn decimal_from_str_works() { - // Integers - assert_eq!(Decimal256::from_str("0").unwrap(), Decimal256::percent(0)); - assert_eq!(Decimal256::from_str("1").unwrap(), Decimal256::percent(100)); - assert_eq!(Decimal256::from_str("5").unwrap(), Decimal256::percent(500)); - assert_eq!( - Decimal256::from_str("42").unwrap(), - Decimal256::percent(4200) - ); - assert_eq!(Decimal256::from_str("000").unwrap(), Decimal256::percent(0)); - assert_eq!( - Decimal256::from_str("001").unwrap(), - Decimal256::percent(100) - ); - assert_eq!( - Decimal256::from_str("005").unwrap(), - Decimal256::percent(500) - ); - assert_eq!( - Decimal256::from_str("0042").unwrap(), - Decimal256::percent(4200) - ); - - // Decimals - assert_eq!( - Decimal256::from_str("1.0").unwrap(), - Decimal256::percent(100) - ); - assert_eq!( - Decimal256::from_str("1.5").unwrap(), - Decimal256::percent(150) - ); - assert_eq!( - Decimal256::from_str("0.5").unwrap(), - Decimal256::percent(50) - ); - assert_eq!( - Decimal256::from_str("0.123").unwrap(), - Decimal256::permille(123) - ); - - assert_eq!( - Decimal256::from_str("40.00").unwrap(), - Decimal256::percent(4000) - ); - assert_eq!( - Decimal256::from_str("04.00").unwrap(), - Decimal256::percent(400) - ); - assert_eq!( - Decimal256::from_str("00.40").unwrap(), - Decimal256::percent(40) - ); - assert_eq!( - Decimal256::from_str("00.04").unwrap(), - Decimal256::percent(4) - ); - - // Can handle 18 fractional digits - assert_eq!( - Decimal256::from_str("7.123456789012345678").unwrap(), - Decimal256(Uint256::from(7123456789012345678u128)) - ); - assert_eq!( - Decimal256::from_str("7.999999999999999999").unwrap(), - Decimal256(Uint256::from(7999999999999999999u128)) - ); - - // Works for documented max value - assert_eq!( - Decimal256::from_str( - "115792089237316195423570985008687907853269984665640564039457.584007913129639935" - ) - .unwrap(), - Decimal256::MAX - ); - } - - #[test] - fn decimal_from_str_errors_for_broken_whole_part() { - match Decimal256::from_str("").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), - e => panic!("Unexpected error: {:?}", e), - } - - match Decimal256::from_str(" ").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), - e => panic!("Unexpected error: {:?}", e), - } - - match Decimal256::from_str("-1").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing whole"), - e => panic!("Unexpected error: {:?}", e), - } - } - - #[test] - fn decimal_from_str_errors_for_broken_fractinal_part() { - match Decimal256::from_str("1.").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), - e => panic!("Unexpected error: {:?}", e), - } - - match Decimal256::from_str("1. ").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), - e => panic!("Unexpected error: {:?}", e), - } - - match Decimal256::from_str("1.e").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), - e => panic!("Unexpected error: {:?}", e), - } - - match Decimal256::from_str("1.2e3").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Error parsing fractional"), - e => panic!("Unexpected error: {:?}", e), - } - } - - #[test] - fn decimal_from_str_errors_for_more_than_36_fractional_digits() { - match Decimal256::from_str("7.1234567890123456789").unwrap_err() { - StdError::GenericErr { msg, .. } => { - assert_eq!(msg, "Cannot parse more than 18 fractional digits") - } - e => panic!("Unexpected error: {:?}", e), - } - - // No special rules for trailing zeros. This could be changed but adds gas cost for the happy path. - match Decimal256::from_str("7.1230000000000000000").unwrap_err() { - StdError::GenericErr { msg, .. } => { - assert_eq!(msg, "Cannot parse more than 18 fractional digits") - } - e => panic!("Unexpected error: {:?}", e), - } - } - - #[test] - fn decimal_from_str_errors_for_invalid_number_of_dots() { - match Decimal256::from_str("1.2.3").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), - e => panic!("Unexpected error: {:?}", e), - } - - match Decimal256::from_str("1.2.3.4").unwrap_err() { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Unexpected number of dots"), - e => panic!("Unexpected error: {:?}", e), - } - } - - #[test] - fn decimal_from_str_errors_for_more_than_max_value() { - // Integer - match Decimal256::from_str("115792089237316195423570985008687907853269984665640564039458") - .unwrap_err() - { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), - e => panic!("Unexpected error: {:?}", e), - } - - // Decimal - match Decimal256::from_str("115792089237316195423570985008687907853269984665640564039458.0") - .unwrap_err() - { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), - e => panic!("Unexpected error: {:?}", e), - } - match Decimal256::from_str( - "115792089237316195423570985008687907853269984665640564039457.584007913129639936", - ) - .unwrap_err() - { - StdError::GenericErr { msg, .. } => assert_eq!(msg, "Value too big"), - e => panic!("Unexpected error: {:?}", e), - } - } - - #[test] - fn decimal_is_zero_works() { - assert!(Decimal256::zero().is_zero()); - assert!(Decimal256::percent(0).is_zero()); - assert!(Decimal256::permille(0).is_zero()); - - assert!(!Decimal256::one().is_zero()); - assert!(!Decimal256::percent(123).is_zero()); - assert!(!Decimal256::permille(1234).is_zero()); - } - - #[test] - fn decimal_inv_works() { - // d = 0 - assert_eq!(Decimal256::zero().inv(), None); - - // d == 1 - assert_eq!(Decimal256::one().inv(), Some(Decimal256::one())); - - // d > 1 exact - assert_eq!( - Decimal256::from_str("2").unwrap().inv(), - Some(Decimal256::from_str("0.5").unwrap()) - ); - assert_eq!( - Decimal256::from_str("20").unwrap().inv(), - Some(Decimal256::from_str("0.05").unwrap()) - ); - assert_eq!( - Decimal256::from_str("200").unwrap().inv(), - Some(Decimal256::from_str("0.005").unwrap()) - ); - assert_eq!( - Decimal256::from_str("2000").unwrap().inv(), - Some(Decimal256::from_str("0.0005").unwrap()) - ); - - // d > 1 rounded - assert_eq!( - Decimal256::from_str("3").unwrap().inv(), - Some(Decimal256::from_str("0.333333333333333333").unwrap()) - ); - assert_eq!( - Decimal256::from_str("6").unwrap().inv(), - Some(Decimal256::from_str("0.166666666666666666").unwrap()) - ); - - // d < 1 exact - assert_eq!( - Decimal256::from_str("0.5").unwrap().inv(), - Some(Decimal256::from_str("2").unwrap()) - ); - assert_eq!( - Decimal256::from_str("0.05").unwrap().inv(), - Some(Decimal256::from_str("20").unwrap()) - ); - assert_eq!( - Decimal256::from_str("0.005").unwrap().inv(), - Some(Decimal256::from_str("200").unwrap()) - ); - assert_eq!( - Decimal256::from_str("0.0005").unwrap().inv(), - Some(Decimal256::from_str("2000").unwrap()) - ); - } - - #[test] - fn decimal_add() { - let value = Decimal256::one() + Decimal256::percent(50); // 1.5 - assert_eq!( - value.0, - Decimal256::DECIMAL_FRACTIONAL * Uint256::from(3u8) / Uint256::from(2u8) - ); - } - - #[test] - #[should_panic(expected = "attempt to add with overflow")] - fn decimal_add_overflow_panics() { - let _value = Decimal256::MAX + Decimal256::percent(50); - } - - #[test] - fn decimal_sub() { - let value = Decimal256::one() - Decimal256::percent(50); // 0.5 - assert_eq!(value.0, Decimal256::DECIMAL_FRACTIONAL / Uint256::from(2u8)); - } - - #[test] - #[should_panic(expected = "attempt to subtract with overflow")] - fn decimal_sub_overflow_panics() { - let _value = Decimal256::zero() - Decimal256::percent(50); - } - - #[test] - // in this test the Decimal256 is on the right - fn uint128_decimal_multiply() { - // a*b - let left = Uint256::from(300u128); - let right = Decimal256::one() + Decimal256::percent(50); // 1.5 - assert_eq!(left * right, Uint256::from(450u32)); - - // a*0 - let left = Uint256::from(300u128); - let right = Decimal256::zero(); - assert_eq!(left * right, Uint256::from(0u128)); - - // 0*a - let left = Uint256::from(0u128); - let right = Decimal256::one() + Decimal256::percent(50); // 1.5 - assert_eq!(left * right, Uint256::from(0u128)); - } - - #[test] - // in this test the Decimal256 is on the left - fn decimal_uint128_multiply() { - // a*b - let left = Decimal256::one() + Decimal256::percent(50); // 1.5 - let right = Uint256::from(300u128); - assert_eq!(left * right, Uint256::from(450u128)); - - // 0*a - let left = Decimal256::zero(); - let right = Uint256::from(300u128); - assert_eq!(left * right, Uint256::from(0u128)); - - // a*0 - let left = Decimal256::one() + Decimal256::percent(50); // 1.5 - let right = Uint256::from(0u128); - assert_eq!(left * right, Uint256::from(0u128)); - } - - #[test] - fn decimal_uint128_division() { - // a/b - let left = Decimal256::percent(150); // 1.5 - let right = Uint256::from(3u128); - assert_eq!(left / right, Decimal256::percent(50)); - - // 0/a - let left = Decimal256::zero(); - let right = Uint256::from(300u128); - assert_eq!(left / right, Decimal256::zero()); - } - - #[test] - #[should_panic(expected = "attempt to divide by zero")] - fn decimal_uint128_divide_by_zero() { - let left = Decimal256::percent(150); // 1.5 - let right = Uint256::from(0u128); - let _result = left / right; - } - - #[test] - fn decimal_uint128_div_assign() { - // a/b - let mut dec = Decimal256::percent(150); // 1.5 - dec /= Uint256::from(3u128); - assert_eq!(dec, Decimal256::percent(50)); - - // 0/a - let mut dec = Decimal256::zero(); - dec /= Uint256::from(300u128); - assert_eq!(dec, Decimal256::zero()); - } - - #[test] - #[should_panic(expected = "attempt to divide by zero")] - fn decimal_uint128_div_assign_by_zero() { - // a/0 - let mut dec = Decimal256::percent(50); - dec /= Uint256::from(0u128); - } - - #[test] - fn decimal_uint128_sqrt() { - assert_eq!(Decimal256::percent(900).sqrt(), Decimal256::percent(300)); - - assert!(Decimal256::percent(316) < Decimal256::percent(1000).sqrt()); - assert!(Decimal256::percent(1000).sqrt() < Decimal256::percent(317)); - } - - /// sqrt(2) is an irrational number, i.e. all 36 decimal places should be used. - #[test] - fn decimal_uint128_sqrt_is_precise() { - assert_eq!( - Decimal256::from_str("2").unwrap().sqrt(), - Decimal256::from_str("1.414213562373095048").unwrap() // https://www.wolframalpha.com/input/?i=sqrt%282%29 - ); - } - - #[test] - fn decimal_uint128_sqrt_does_not_overflow() { - assert_eq!( - Decimal256::from_str("40000000000000000000000000000000000000000000000000000000000") - .unwrap() - .sqrt(), - Decimal256::from_str("200000000000000000000000000000").unwrap() - ); - } - - #[test] - fn decimal_uint128_sqrt_intermediate_precision_used() { - assert_eq!( - Decimal256::from_str("40000000000000000000000000000000000000000000000001") - .unwrap() - .sqrt(), - // The last few digits (39110) are truncated below due to the algorithm - // we use. Larger numbers will cause less precision. - // https://www.wolframalpha.com/input/?i=sqrt%2840000000000000000000000000000000000000000000000001%29 - Decimal256::from_str("6324555320336758663997787.088865437067400000").unwrap() - ); - } - - #[test] - fn decimal_to_string() { - // Integers - assert_eq!(Decimal256::zero().to_string(), "0"); - assert_eq!(Decimal256::one().to_string(), "1"); - assert_eq!(Decimal256::percent(500).to_string(), "5"); - - // Decimals - assert_eq!(Decimal256::percent(125).to_string(), "1.25"); - assert_eq!(Decimal256::percent(42638).to_string(), "426.38"); - assert_eq!(Decimal256::percent(3).to_string(), "0.03"); - assert_eq!(Decimal256::permille(987).to_string(), "0.987"); - - assert_eq!( - Decimal256(Uint256::from(1u128)).to_string(), - "0.000000000000000001" - ); - assert_eq!( - Decimal256(Uint256::from(10u128)).to_string(), - "0.00000000000000001" - ); - assert_eq!( - Decimal256(Uint256::from(100u128)).to_string(), - "0.0000000000000001" - ); - assert_eq!( - Decimal256(Uint256::from(1000u128)).to_string(), - "0.000000000000001" - ); - assert_eq!( - Decimal256(Uint256::from(10000u128)).to_string(), - "0.00000000000001" - ); - assert_eq!( - Decimal256(Uint256::from(100000u128)).to_string(), - "0.0000000000001" - ); - assert_eq!( - Decimal256(Uint256::from(1000000u128)).to_string(), - "0.000000000001" - ); - assert_eq!( - Decimal256(Uint256::from(10000000u128)).to_string(), - "0.00000000001" - ); - assert_eq!( - Decimal256(Uint256::from(100000000u128)).to_string(), - "0.0000000001" - ); - assert_eq!( - Decimal256(Uint256::from(1000000000u128)).to_string(), - "0.000000001" - ); - assert_eq!( - Decimal256(Uint256::from(10000000000u128)).to_string(), - "0.00000001" - ); - assert_eq!( - Decimal256(Uint256::from(100000000000u128)).to_string(), - "0.0000001" - ); - assert_eq!( - Decimal256(Uint256::from(10000000000000u128)).to_string(), - "0.00001" - ); - assert_eq!( - Decimal256(Uint256::from(100000000000000u128)).to_string(), - "0.0001" - ); - assert_eq!( - Decimal256(Uint256::from(1000000000000000u128)).to_string(), - "0.001" - ); - assert_eq!( - Decimal256(Uint256::from(10000000000000000u128)).to_string(), - "0.01" - ); - assert_eq!( - Decimal256(Uint256::from(100000000000000000u128)).to_string(), - "0.1" - ); - } - - #[test] - fn decimal_serialize() { - assert_eq!(to_vec(&Decimal256::zero()).unwrap(), br#""0""#); - assert_eq!(to_vec(&Decimal256::one()).unwrap(), br#""1""#); - assert_eq!(to_vec(&Decimal256::percent(8)).unwrap(), br#""0.08""#); - assert_eq!(to_vec(&Decimal256::percent(87)).unwrap(), br#""0.87""#); - assert_eq!(to_vec(&Decimal256::percent(876)).unwrap(), br#""8.76""#); - assert_eq!(to_vec(&Decimal256::percent(8765)).unwrap(), br#""87.65""#); - } - - #[test] - fn decimal_deserialize() { - assert_eq!( - from_slice::(br#""0""#).unwrap(), - Decimal256::zero() - ); - assert_eq!( - from_slice::(br#""1""#).unwrap(), - Decimal256::one() - ); - assert_eq!( - from_slice::(br#""000""#).unwrap(), - Decimal256::zero() - ); - assert_eq!( - from_slice::(br#""001""#).unwrap(), - Decimal256::one() - ); - - assert_eq!( - from_slice::(br#""0.08""#).unwrap(), - Decimal256::percent(8) - ); - assert_eq!( - from_slice::(br#""0.87""#).unwrap(), - Decimal256::percent(87) - ); - assert_eq!( - from_slice::(br#""8.76""#).unwrap(), - Decimal256::percent(876) - ); - assert_eq!( - from_slice::(br#""87.65""#).unwrap(), - Decimal256::percent(8765) - ); - } -} diff --git a/packages/std/src/math/isqrt.rs b/packages/std/src/math/isqrt.rs deleted file mode 100644 index 8716232f7..000000000 --- a/packages/std/src/math/isqrt.rs +++ /dev/null @@ -1,108 +0,0 @@ -use std::{cmp, ops}; - -use crate::{Uint128, Uint256, Uint512, Uint64}; - -/// A trait for calculating the -/// [integer square root](https://en.wikipedia.org/wiki/Integer_square_root). -pub trait Isqrt { - /// The [integer square root](https://en.wikipedia.org/wiki/Integer_square_root). - fn isqrt(self) -> Self; -} - -impl Isqrt for I -where - I: Unsigned - + ops::Add - + ops::Div - + ops::Shr - + cmp::PartialOrd - + Copy - + From, -{ - /// Algorithm adapted from - /// [Wikipedia](https://en.wikipedia.org/wiki/Integer_square_root#Example_implementation_in_C). - fn isqrt(self) -> Self { - let mut x0 = self >> 1; - - if x0 > 0.into() { - let mut x1 = (x0 + self / x0) >> 1; - - while x1 < x0 { - x0 = x1; - x1 = (x0 + self / x0) >> 1; - } - - return x0; - } - self - } -} - -/// Marker trait for types that represent unsigned integers. -pub trait Unsigned {} -impl Unsigned for u8 {} -impl Unsigned for u16 {} -impl Unsigned for u32 {} -impl Unsigned for u64 {} -impl Unsigned for u128 {} -impl Unsigned for Uint64 {} -impl Unsigned for Uint128 {} -impl Unsigned for Uint256 {} -impl Unsigned for Uint512 {} -impl Unsigned for usize {} - -#[cfg(test)] -mod tests { - use std::convert::TryFrom; - - use super::*; - - #[test] - fn isqrt_primitives() { - // Let's check correctness. - assert_eq!(0u8.isqrt(), 0); - assert_eq!(1u8.isqrt(), 1); - assert_eq!(24u8.isqrt(), 4); - assert_eq!(25u8.isqrt(), 5); - assert_eq!(26u8.isqrt(), 5); - assert_eq!(36u8.isqrt(), 6); - - // Let's also check different types. - assert_eq!(26u8.isqrt(), 5); - assert_eq!(26u16.isqrt(), 5); - assert_eq!(26u32.isqrt(), 5); - assert_eq!(26u64.isqrt(), 5); - assert_eq!(26u128.isqrt(), 5); - } - - #[test] - fn isqrt_uint64() { - assert_eq!(Uint64::new(24).isqrt(), Uint64::new(4)); - } - - #[test] - fn isqrt_uint128() { - assert_eq!(Uint128::new(24).isqrt(), Uint128::new(4)); - } - - #[test] - fn isqrt_uint256() { - assert_eq!(Uint256::from(24u32).isqrt(), Uint256::from(4u32)); - assert_eq!( - (Uint256::from(u128::MAX) * Uint256::from(u128::MAX)).isqrt(), - Uint256::try_from("340282366920938463463374607431768211455").unwrap() - ); - } - - #[test] - fn isqrt_uint512() { - assert_eq!(Uint512::from(24u32).isqrt(), Uint512::from(4u32)); - assert_eq!( - (Uint512::from(Uint256::MAX) * Uint512::from(Uint256::MAX)).isqrt(), - Uint512::try_from( - "115792089237316195423570985008687907853269984665640564039457584007913129639935" - ) - .unwrap() - ); - } -} diff --git a/packages/std/src/math/mod.rs b/packages/std/src/math/mod.rs index cc3c91bde..e9c5dbe28 100644 --- a/packages/std/src/math/mod.rs +++ b/packages/std/src/math/mod.rs @@ -1,17 +1,9 @@ mod decimal; -mod decimal256; mod fraction; -mod isqrt; mod uint128; -mod uint256; -mod uint512; mod uint64; pub use decimal::Decimal; -pub use decimal256::Decimal256; pub use fraction::Fraction; -pub use isqrt::Isqrt; pub use uint128::Uint128; -pub use uint256::Uint256; -pub use uint512::Uint512; pub use uint64::Uint64; diff --git a/packages/std/src/math/uint128.rs b/packages/std/src/math/uint128.rs index ae1eaea1a..6d9899ab0 100644 --- a/packages/std/src/math/uint128.rs +++ b/packages/std/src/math/uint128.rs @@ -1,13 +1,11 @@ use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use std::convert::{TryFrom, TryInto}; +use std::convert::TryFrom; use std::fmt::{self}; use std::iter::Sum; use std::ops; -use std::str::FromStr; use crate::errors::{DivideByZeroError, OverflowError, OverflowOperation, StdError}; -use crate::{ConversionOverflowError, Uint256, Uint64}; /// A thin wrapper around u128 that is using strings for JSON encoding/decoding, /// such that the full u128 range can be used for clients that convert JSON numbers to floats, @@ -29,11 +27,11 @@ use crate::{ConversionOverflowError, Uint256, Uint64}; /// assert_eq!(c.u128(), 70); /// ``` #[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Uint128(#[schemars(with = "String")] u128); +pub struct Uint128( + #[schemars(with = "String")] pub u128, // Simon thinks this should be private, but does not want to worry about breaking code right now +); impl Uint128 { - pub const MAX: Self = Self(u128::MAX); - /// Creates a Uint128(value). /// /// This method is less flexible than `from` but can be called in a const context. @@ -97,42 +95,34 @@ impl Uint128 { .ok_or_else(|| DivideByZeroError::new(self)) } - #[must_use] pub fn wrapping_add(self, other: Self) -> Self { Self(self.0.wrapping_add(other.0)) } - #[must_use] pub fn wrapping_sub(self, other: Self) -> Self { Self(self.0.wrapping_sub(other.0)) } - #[must_use] pub fn wrapping_mul(self, other: Self) -> Self { Self(self.0.wrapping_mul(other.0)) } - #[must_use] pub fn wrapping_pow(self, other: u32) -> Self { Self(self.0.wrapping_pow(other)) } - #[must_use] pub fn saturating_add(self, other: Self) -> Self { Self(self.0.saturating_add(other.0)) } - #[must_use] pub fn saturating_sub(self, other: Self) -> Self { Self(self.0.saturating_sub(other.0)) } - #[must_use] pub fn saturating_mul(self, other: Self) -> Self { Self(self.0.saturating_mul(other.0)) } - #[must_use] pub fn saturating_pow(self, other: u32) -> Self { Self(self.0.saturating_pow(other)) } @@ -143,12 +133,6 @@ impl Uint128 { // of the conflict with `TryFrom<&str>` as described here // https://stackoverflow.com/questions/63136970/how-do-i-work-around-the-upstream-crates-may-add-a-new-impl-of-trait-error -impl From for Uint128 { - fn from(val: Uint64) -> Self { - val.u64().into() - } -} - impl From for Uint128 { fn from(val: u128) -> Self { Uint128(val) @@ -179,29 +163,11 @@ impl From for Uint128 { } } -impl TryFrom for Uint64 { - type Error = ConversionOverflowError; - - fn try_from(value: Uint128) -> Result { - Ok(Uint64::new(value.0.try_into().map_err(|_| { - ConversionOverflowError::new("Uint128", "Uint64", value.to_string()) - })?)) - } -} - impl TryFrom<&str> for Uint128 { type Error = StdError; fn try_from(val: &str) -> Result { - Self::from_str(val) - } -} - -impl FromStr for Uint128 { - type Err = StdError; - - fn from_str(s: &str) -> Result { - match s.parse::() { + match val.parse::() { Ok(u) => Ok(Uint128(u)), Err(e) => Err(StdError::generic_err(format!("Parsing u128: {}", e))), } @@ -222,7 +188,7 @@ impl From for u128 { impl fmt::Display for Uint128 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.fmt(f) + write!(f, "{}", self.0) } } @@ -230,11 +196,7 @@ impl ops::Add for Uint128 { type Output = Self; fn add(self, rhs: Self) -> Self { - Uint128( - self.u128() - .checked_add(rhs.u128()) - .expect("attempt to add with overflow"), - ) + Uint128(self.u128().checked_add(rhs.u128()).unwrap()) } } @@ -242,153 +204,24 @@ impl<'a> ops::Add<&'a Uint128> for Uint128 { type Output = Self; fn add(self, rhs: &'a Uint128) -> Self { - self + *rhs - } -} - -impl ops::Sub for Uint128 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - Uint128( - self.u128() - .checked_sub(rhs.u128()) - .expect("attempt to subtract with overflow"), - ) - } -} - -impl<'a> ops::Sub<&'a Uint128> for Uint128 { - type Output = Self; - - fn sub(self, rhs: &'a Uint128) -> Self { - self - *rhs - } -} - -impl ops::Mul for Uint128 { - type Output = Self; - - fn mul(self, rhs: Self) -> Self::Output { - Self( - self.u128() - .checked_mul(rhs.u128()) - .expect("attempt to multiply with overflow"), - ) - } -} - -impl<'a> ops::Mul<&'a Uint128> for Uint128 { - type Output = Self; - - fn mul(self, rhs: &'a Uint128) -> Self::Output { - self.mul(*rhs) - } -} - -impl ops::Div for Uint128 { - type Output = Self; - - fn div(self, rhs: Self) -> Self::Output { - Self( - self.u128() - .checked_div(rhs.u128()) - .expect("attempt to divide by zero"), - ) - } -} - -impl<'a> ops::Div<&'a Uint128> for Uint128 { - type Output = Self; - - fn div(self, rhs: &'a Uint128) -> Self::Output { - self / *rhs - } -} - -impl ops::Shr for Uint128 { - type Output = Self; - - fn shr(self, rhs: u32) -> Self::Output { - Self( - self.u128() - .checked_shr(rhs) - .expect("attempt to shift right with overflow"), - ) - } -} - -impl<'a> ops::Shr<&'a u32> for Uint128 { - type Output = Self; - - fn shr(self, rhs: &'a u32) -> Self::Output { - self >> *rhs + Uint128(self.u128().checked_add(rhs.u128()).unwrap()) } } impl ops::AddAssign for Uint128 { fn add_assign(&mut self, rhs: Uint128) { - *self = *self + rhs; + self.0 = self.0.checked_add(rhs.u128()).unwrap(); } } impl<'a> ops::AddAssign<&'a Uint128> for Uint128 { fn add_assign(&mut self, rhs: &'a Uint128) { - *self = *self + rhs; - } -} - -impl ops::SubAssign for Uint128 { - fn sub_assign(&mut self, rhs: Uint128) { - *self = *self - rhs; - } -} - -impl<'a> ops::SubAssign<&'a Uint128> for Uint128 { - fn sub_assign(&mut self, rhs: &'a Uint128) { - *self = *self - rhs; - } -} - -impl ops::MulAssign for Uint128 { - fn mul_assign(&mut self, rhs: Self) { - *self = *self * rhs; - } -} - -impl<'a> ops::MulAssign<&'a Uint128> for Uint128 { - fn mul_assign(&mut self, rhs: &'a Uint128) { - *self = *self * rhs; - } -} - -impl ops::DivAssign for Uint128 { - fn div_assign(&mut self, rhs: Self) { - *self = *self / rhs; - } -} - -impl<'a> ops::DivAssign<&'a Uint128> for Uint128 { - fn div_assign(&mut self, rhs: &'a Uint128) { - *self = *self / rhs; - } -} - -impl ops::ShrAssign for Uint128 { - fn shr_assign(&mut self, rhs: u32) { - *self = *self >> rhs; - } -} - -impl<'a> ops::ShrAssign<&'a u32> for Uint128 { - fn shr_assign(&mut self, rhs: &'a u32) { - *self = *self >> rhs; + self.0 = self.0.checked_add(rhs.u128()).unwrap(); } } impl Uint128 { /// Returns `self * numerator / denominator` - #[must_use] pub fn multiply_ratio, B: Into>( &self, numerator: A, @@ -399,27 +232,9 @@ impl Uint128 { if denominator == 0 { panic!("Denominator must not be zero"); } - (self.full_mul(numerator) / Uint256::from(denominator)) - .try_into() - .expect("multiplication overflow") - } - - /// Multiplies two u128 values without overflow, producing an - /// [`Uint256`]. - /// - /// # Examples - /// - /// ``` - /// use cosmwasm_std::Uint128; - /// - /// let a = Uint128::MAX; - /// let result = a.full_mul(2u32); - /// assert_eq!(result.to_string(), "680564733841876926926749214863536422910"); - /// ``` - pub fn full_mul(self, rhs: impl Into) -> Uint256 { - Uint256::from(self.u128()) - .checked_mul(Uint256::from(rhs.into())) - .unwrap() + // TODO: minimize rounding that takes place (using gcd algorithm) + let val = self.u128() * numerator / denominator; + Uint128::from(val) } } @@ -526,19 +341,13 @@ mod tests { assert_eq!(a.to_string(), "0"); } - #[test] - fn uint128_display_padding_works() { - let a = Uint128::from(123u64); - assert_eq!(format!("Embedded: {:05}", a), "Embedded: 00123"); - } - #[test] fn uint128_is_zero_works() { - assert!(Uint128::zero().is_zero()); - assert!(Uint128(0).is_zero()); + assert_eq!(Uint128::zero().is_zero(), true); + assert_eq!(Uint128(0).is_zero(), true); - assert!(!Uint128(1).is_zero()); - assert!(!Uint128(123).is_zero()); + assert_eq!(Uint128(1).is_zero(), false); + assert_eq!(Uint128(123).is_zero(), false); } #[test] @@ -571,8 +380,7 @@ mod tests { assert_eq!(a + &b, Uint128(35801)); // test - with owned and reference right hand side - assert_eq!(b - a, Uint128(11111)); - assert_eq!(b - &a, Uint128(11111)); + assert_eq!((b.checked_sub(a)).unwrap(), Uint128(11111)); // test += with owned and reference right hand side let mut c = Uint128(300000); @@ -582,14 +390,6 @@ mod tests { d += &b; assert_eq!(d, Uint128(323456)); - // test -= with owned and reference right hand side - let mut c = Uint128(300000); - c -= b; - assert_eq!(c, Uint128(276544)); - let mut d = Uint128(300000); - d -= &b; - assert_eq!(d, Uint128(276544)); - // error result on underflow (- would produce negative result) let underflow_result = a.checked_sub(b); let OverflowError { @@ -600,27 +400,20 @@ mod tests { #[test] #[should_panic] - fn uint128_add_overflow_panics() { + fn uint128_math_overflow_panics() { // almost_max is 2^128 - 10 let almost_max = Uint128(340282366920938463463374607431768211446); let _ = almost_max + Uint128(12); } - #[test] - #[should_panic] - fn uint128_sub_overflow_panics() { - let _ = Uint128(1) - Uint128(2); - } - #[test] fn uint128_multiply_ratio_works() { let base = Uint128(500); // factor 1/1 - assert_eq!(base.multiply_ratio(1u128, 1u128), base); - assert_eq!(base.multiply_ratio(3u128, 3u128), base); - assert_eq!(base.multiply_ratio(654321u128, 654321u128), base); - assert_eq!(base.multiply_ratio(u128::MAX, u128::MAX), base); + assert_eq!(base.multiply_ratio(1u128, 1u128), Uint128(500)); + assert_eq!(base.multiply_ratio(3u128, 3u128), Uint128(500)); + assert_eq!(base.multiply_ratio(654321u128, 654321u128), Uint128(500)); // factor 3/2 assert_eq!(base.multiply_ratio(3u128, 2u128), Uint128(750)); @@ -635,23 +428,6 @@ mod tests { assert_eq!(base.multiply_ratio(100u128, 120u128), Uint128(416)); } - #[test] - fn uint128_multiply_ratio_does_not_overflow_when_result_fits() { - // Almost max value for Uint128. - let base = Uint128(u128::MAX - 9); - - assert_eq!(base.multiply_ratio(2u128, 2u128), base); - } - - #[test] - #[should_panic] - fn uint128_multiply_ratio_panicks_on_overflow() { - // Almost max value for Uint128. - let base = Uint128(u128::MAX - 9); - - assert_eq!(base.multiply_ratio(2u128, 1u128), base); - } - #[test] #[should_panic(expected = "Denominator must not be zero")] fn uint128_multiply_ratio_panics_for_zero_denominator() { diff --git a/packages/std/src/math/uint256.rs b/packages/std/src/math/uint256.rs deleted file mode 100644 index 3888f2dbe..000000000 --- a/packages/std/src/math/uint256.rs +++ /dev/null @@ -1,1160 +0,0 @@ -use schemars::JsonSchema; -use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use std::convert::{TryFrom, TryInto}; -use std::fmt; -use std::iter::Sum; -use std::ops::{self, Shl, Shr}; -use std::str::FromStr; - -use crate::errors::{ - ConversionOverflowError, DivideByZeroError, OverflowError, OverflowOperation, StdError, -}; -use crate::{Uint128, Uint512, Uint64}; - -/// This module is purely a workaround that lets us ignore lints for all the code -/// the `construct_uint!` macro generates. -#[allow(clippy::all)] -mod uints { - uint::construct_uint! { - pub struct U256(4); - } -} - -/// Used internally - we don't want to leak this type since we might change -/// the implementation in the future. -use uints::U256; - -/// An implementation of u256 that is using strings for JSON encoding/decoding, -/// such that the full u256 range can be used for clients that convert JSON numbers to floats, -/// like JavaScript and jq. -/// -/// # Examples -/// -/// Use `from` to create instances out of primitive uint types or `new` to provide big -/// endian bytes: -/// -/// ``` -/// # use cosmwasm_std::Uint256; -/// let a = Uint256::from(258u128); -/// let b = Uint256::new([ -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8, -/// ]); -/// assert_eq!(a, b); -/// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Uint256(#[schemars(with = "String")] U256); - -impl Uint256 { - pub const MAX: Uint256 = Uint256(U256::MAX); - - /// Creates a Uint256(value) from a big endian representation. It's just an alias for - /// [`Uint256::from_be_bytes`]. - /// - /// This method is less flexible than `from` but can be called in a const context. - pub const fn new(value: [u8; 32]) -> Self { - Self::from_be_bytes(value) - } - - /// Creates a Uint256(0) - pub const fn zero() -> Self { - Uint256(U256::zero()) - } - - pub const fn from_be_bytes(data: [u8; 32]) -> Self { - let words: [u64; 4] = [ - u64::from_le_bytes([ - data[31], data[30], data[29], data[28], data[27], data[26], data[25], data[24], - ]), - u64::from_le_bytes([ - data[23], data[22], data[21], data[20], data[19], data[18], data[17], data[16], - ]), - u64::from_le_bytes([ - data[15], data[14], data[13], data[12], data[11], data[10], data[9], data[8], - ]), - u64::from_le_bytes([ - data[7], data[6], data[5], data[4], data[3], data[2], data[1], data[0], - ]), - ]; - Uint256(U256(words)) - } - - pub const fn from_le_bytes(data: [u8; 32]) -> Self { - let words: [u64; 4] = [ - u64::from_le_bytes([ - data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], - ]), - u64::from_le_bytes([ - data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15], - ]), - u64::from_le_bytes([ - data[16], data[17], data[18], data[19], data[20], data[21], data[22], data[23], - ]), - u64::from_le_bytes([ - data[24], data[25], data[26], data[27], data[28], data[29], data[30], data[31], - ]), - ]; - Uint256(U256(words)) - } - - /// Returns a copy of the number as big endian bytes. - pub fn to_be_bytes(self) -> [u8; 32] { - let mut result = [0u8; 32]; - self.0.to_big_endian(&mut result); - result - } - - /// Returns a copy of the number as little endian bytes. - pub fn to_le_bytes(self) -> [u8; 32] { - let mut result = [0u8; 32]; - self.0.to_little_endian(&mut result); - result - } - - pub fn is_zero(&self) -> bool { - self.0.is_zero() - } - - pub fn checked_add(self, other: Self) -> Result { - self.0 - .checked_add(other.0) - .map(Self) - .ok_or_else(|| OverflowError::new(OverflowOperation::Add, self, other)) - } - - pub fn checked_sub(self, other: Self) -> Result { - self.0 - .checked_sub(other.0) - .map(Self) - .ok_or_else(|| OverflowError::new(OverflowOperation::Sub, self, other)) - } - - pub fn checked_mul(self, other: Self) -> Result { - self.0 - .checked_mul(other.0) - .map(Self) - .ok_or_else(|| OverflowError::new(OverflowOperation::Mul, self, other)) - } - - pub fn checked_div(self, other: Self) -> Result { - self.0 - .checked_div(other.0) - .map(Self) - .ok_or_else(|| DivideByZeroError::new(self)) - } - - pub fn checked_rem(self, other: Self) -> Result { - self.0 - .checked_rem(other.0) - .map(Self) - .ok_or_else(|| DivideByZeroError::new(self)) - } - - pub fn checked_pow(self, exp: u32) -> Result { - self.0 - .checked_pow(exp.into()) - .map(Self) - .ok_or_else(|| OverflowError::new(OverflowOperation::Pow, self, exp)) - } - - #[must_use] - pub fn pow(self, exp: u32) -> Self { - self.checked_pow(exp) - .expect("attempt to raise to a power with overflow") - } - - pub fn checked_shr(self, other: u32) -> Result { - if other >= 256 { - return Err(OverflowError::new(OverflowOperation::Shr, self, other)); - } - - Ok(Self(self.0.shr(other))) - } - - pub fn checked_shl(self, other: u32) -> Result { - if other >= 256 { - return Err(OverflowError::new(OverflowOperation::Shl, self, other)); - } - - Ok(Self(self.0.shl(other))) - } - - #[must_use] - pub fn saturating_add(self, other: Self) -> Self { - Self(self.0.saturating_add(other.0)) - } - - #[must_use] - pub fn saturating_sub(self, other: Self) -> Self { - Self(self.0.saturating_sub(other.0)) - } - - #[must_use] - pub fn saturating_mul(self, other: Self) -> Self { - Self(self.0.saturating_mul(other.0)) - } -} - -impl From for Uint256 { - fn from(val: Uint128) -> Self { - val.u128().into() - } -} - -impl From for Uint256 { - fn from(val: Uint64) -> Self { - val.u64().into() - } -} - -impl From for Uint256 { - fn from(val: u128) -> Self { - Uint256(val.into()) - } -} - -impl From for Uint256 { - fn from(val: u64) -> Self { - Uint256(val.into()) - } -} - -impl From for Uint256 { - fn from(val: u32) -> Self { - Uint256(val.into()) - } -} - -impl From for Uint256 { - fn from(val: u16) -> Self { - Uint256(val.into()) - } -} - -impl From for Uint256 { - fn from(val: u8) -> Self { - Uint256(val.into()) - } -} - -impl TryFrom for Uint128 { - type Error = ConversionOverflowError; - - fn try_from(value: Uint256) -> Result { - Ok(Uint128::new(value.0.try_into().map_err(|_| { - ConversionOverflowError::new("Uint256", "Uint128", value.to_string()) - })?)) - } -} - -impl TryFrom<&str> for Uint256 { - type Error = StdError; - - fn try_from(val: &str) -> Result { - Self::from_str(val) - } -} - -impl FromStr for Uint256 { - type Err = StdError; - - fn from_str(s: &str) -> Result { - if s.is_empty() { - return Err(StdError::generic_err("Parsing u256: received empty string")); - } - - match U256::from_dec_str(s) { - Ok(u) => Ok(Uint256(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing u256: {}", e))), - } - } -} - -impl From for String { - fn from(original: Uint256) -> Self { - original.to_string() - } -} - -impl fmt::Display for Uint256 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // The inner type doesn't work as expected with padding, so we - // work around that. - let unpadded = self.0.to_string(); - - f.pad_integral(true, "", &unpadded) - } -} - -impl ops::Add for Uint256 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - Self( - self.0 - .checked_add(rhs.0) - .expect("attempt to add with overflow"), - ) - } -} - -impl<'a> ops::Add<&'a Uint256> for Uint256 { - type Output = Self; - - fn add(self, rhs: &'a Uint256) -> Self { - self + *rhs - } -} - -impl ops::Sub for Uint256 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - Self( - self.0 - .checked_sub(rhs.0) - .expect("attempt to subtract with overflow"), - ) - } -} - -impl<'a> ops::Sub<&'a Uint256> for Uint256 { - type Output = Self; - - fn sub(self, rhs: &'a Uint256) -> Self { - self - *rhs - } -} - -impl ops::Div for Uint256 { - type Output = Self; - - fn div(self, rhs: Self) -> Self::Output { - Self( - self.0 - .checked_div(rhs.0) - .expect("attempt to divide by zero"), - ) - } -} - -impl<'a> ops::Div<&'a Uint256> for Uint256 { - type Output = Self; - - fn div(self, rhs: &'a Uint256) -> Self::Output { - self / *rhs - } -} - -impl ops::Mul for Uint256 { - type Output = Self; - - fn mul(self, rhs: Self) -> Self::Output { - Self( - self.0 - .checked_mul(rhs.0) - .expect("attempt to multiply with overflow"), - ) - } -} - -impl<'a> ops::Mul<&'a Uint256> for Uint256 { - type Output = Self; - - fn mul(self, rhs: &'a Uint256) -> Self::Output { - self.mul(*rhs) - } -} - -impl ops::Shr for Uint256 { - type Output = Self; - - fn shr(self, rhs: u32) -> Self::Output { - self.checked_shr(rhs).unwrap_or_else(|_| { - panic!( - "right shift error: {} is larger or equal than the number of bits in Uint256", - rhs, - ) - }) - } -} - -impl<'a> ops::Shr<&'a u32> for Uint256 { - type Output = Self; - - fn shr(self, rhs: &'a u32) -> Self::Output { - self.shr(*rhs) - } -} - -impl ops::Shl for Uint256 { - type Output = Self; - - fn shl(self, rhs: u32) -> Self::Output { - self.checked_shl(rhs).unwrap_or_else(|_| { - panic!( - "left shift error: {} is larger or equal than the number of bits in Uint256", - rhs, - ) - }) - } -} - -impl<'a> ops::Shl<&'a u32> for Uint256 { - type Output = Self; - - fn shl(self, rhs: &'a u32) -> Self::Output { - self.shl(*rhs) - } -} - -impl ops::AddAssign for Uint256 { - fn add_assign(&mut self, rhs: Uint256) { - *self = *self + rhs; - } -} - -impl<'a> ops::AddAssign<&'a Uint256> for Uint256 { - fn add_assign(&mut self, rhs: &'a Uint256) { - *self = *self + rhs; - } -} - -impl ops::SubAssign for Uint256 { - fn sub_assign(&mut self, rhs: Uint256) { - *self = *self - rhs; - } -} - -impl<'a> ops::SubAssign<&'a Uint256> for Uint256 { - fn sub_assign(&mut self, rhs: &'a Uint256) { - *self = *self - rhs; - } -} - -impl ops::MulAssign for Uint256 { - fn mul_assign(&mut self, rhs: Self) { - *self = *self * rhs; - } -} - -impl<'a> ops::MulAssign<&'a Uint256> for Uint256 { - fn mul_assign(&mut self, rhs: &'a Uint256) { - *self = *self * rhs; - } -} - -impl ops::DivAssign for Uint256 { - fn div_assign(&mut self, rhs: Self) { - *self = *self / rhs; - } -} - -impl<'a> ops::DivAssign<&'a Uint256> for Uint256 { - fn div_assign(&mut self, rhs: &'a Uint256) { - *self = *self / rhs; - } -} - -impl ops::ShrAssign for Uint256 { - fn shr_assign(&mut self, rhs: u32) { - *self = Shr::::shr(*self, rhs); - } -} - -impl<'a> ops::ShrAssign<&'a u32> for Uint256 { - fn shr_assign(&mut self, rhs: &'a u32) { - *self = Shr::::shr(*self, *rhs); - } -} - -impl Uint256 { - /// Returns `self * numerator / denominator` - #[must_use] - pub fn multiply_ratio, B: Into>( - &self, - numerator: A, - denominator: B, - ) -> Uint256 { - let numerator: Uint256 = numerator.into(); - let denominator: Uint256 = denominator.into(); - if denominator.is_zero() { - panic!("Denominator must not be zero"); - } - (self.full_mul(numerator) / Uint512::from(denominator)) - .try_into() - .expect("multiplication overflow") - } - - /// Multiplies two u256 values without overflow, producing an - /// [`Uint512`]. - /// - /// # Examples - /// - /// ``` - /// use cosmwasm_std::Uint256; - /// - /// let a = Uint256::MAX; - /// let result = a.full_mul(2u32); - /// assert_eq!( - /// result.to_string(), - /// "231584178474632390847141970017375815706539969331281128078915168015826259279870", - /// ); - /// ``` - pub fn full_mul(self, rhs: impl Into) -> Uint512 { - Uint512::from(self) - .checked_mul(Uint512::from(rhs.into())) - .unwrap() - } -} - -impl Serialize for Uint256 { - /// Serializes as an integer string using base 10 - fn serialize(&self, serializer: S) -> Result - where - S: ser::Serializer, - { - serializer.serialize_str(&self.to_string()) - } -} - -impl<'de> Deserialize<'de> for Uint256 { - /// Deserialized from an integer string using base 10 - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - deserializer.deserialize_str(Uint256Visitor) - } -} - -struct Uint256Visitor; - -impl<'de> de::Visitor<'de> for Uint256Visitor { - type Value = Uint256; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("string-encoded integer") - } - - fn visit_str(self, v: &str) -> Result - where - E: de::Error, - { - Uint256::try_from(v).map_err(|e| E::custom(format!("invalid Uint256 '{}' - {}", v, e))) - } -} - -impl Sum for Uint256 { - fn sum>(iter: I) -> Self { - iter.fold(Uint256::zero(), ops::Add::add) - } -} - -impl<'a> Sum<&'a Uint256> for Uint256 { - fn sum>(iter: I) -> Self { - iter.fold(Uint256::zero(), ops::Add::add) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{from_slice, to_vec}; - - #[test] - fn uint256_construct() { - let num = Uint256::new([1; 32]); - let a: [u8; 32] = num.to_be_bytes(); - assert_eq!(a, [1; 32]); - - let be_bytes = [ - 0u8, 222u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8, 3u8, - ]; - let num = Uint256::new(be_bytes); - let resulting_bytes: [u8; 32] = num.to_be_bytes(); - assert_eq!(be_bytes, resulting_bytes); - } - - #[test] - fn uint256_from_be_bytes() { - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(0u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 42, - ]); - assert_eq!(a, Uint256::from(42u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, - ]); - assert_eq!(a, Uint256::from(1u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, - ]); - assert_eq!(a, Uint256::from(256u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, - ]); - assert_eq!(a, Uint256::from(65536u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(16777216u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(4294967296u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1099511627776u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(281474976710656u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(72057594037927936u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(18446744073709551616u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(4722366482869645213696u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1208925819614629174706176u128)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1329227995784915872903807060280344576u128)); - - // Values > u128::MAX - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 16)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 17)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 18)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 19)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 20)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 21)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 22)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 23)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 24)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 25)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 26)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 27)); - let a = Uint256::from_be_bytes([ - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 28)); - let a = Uint256::from_be_bytes([ - 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 29)); - let a = Uint256::from_be_bytes([ - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 30)); - let a = Uint256::from_be_bytes([ - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 31)); - } - - #[test] - fn uint256_from_le_bytes() { - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(0u128)); - let a = Uint256::from_le_bytes([ - 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(42u128)); - let a = Uint256::from_le_bytes([ - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128)); - let a = Uint256::from_le_bytes([ - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(256u128)); - let a = Uint256::from_le_bytes([ - 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(65536u128)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(16777216u128)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(4294967296u128)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(72057594037927936u128)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(18446744073709551616u128)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1329227995784915872903807060280344576u128)); - - // Values > u128::MAX - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 16)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 17)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 18)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 19)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 20)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 21)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 22)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 23)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 24)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 25)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 26)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 27)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 28)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 29)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 30)); - let a = Uint256::from_le_bytes([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, - ]); - assert_eq!(a, Uint256::from(1u128) << (8 * 31)); - } - - #[test] - fn uint256_endianness() { - let be_bytes = [ - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8, 3u8, - ]; - let le_bytes = [ - 3u8, 2u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - ]; - - // These should all be the same. - let num1 = Uint256::new(be_bytes); - let num2 = Uint256::from_be_bytes(be_bytes); - let num3 = Uint256::from_le_bytes(le_bytes); - assert_eq!(num1, Uint256::from(65536u32 + 512 + 3)); - assert_eq!(num1, num2); - assert_eq!(num1, num3); - } - - #[test] - fn uint256_convert_from() { - let a = Uint256::from(5u128); - assert_eq!(a.0, U256::from(5)); - - let a = Uint256::from(5u64); - assert_eq!(a.0, U256::from(5)); - - let a = Uint256::from(5u32); - assert_eq!(a.0, U256::from(5)); - - let a = Uint256::from(5u16); - assert_eq!(a.0, U256::from(5)); - - let a = Uint256::from(5u8); - assert_eq!(a.0, U256::from(5)); - - let result = Uint256::try_from("34567"); - assert_eq!(result.unwrap().0, U256::from_dec_str("34567").unwrap()); - - let result = Uint256::try_from("1.23"); - assert!(result.is_err()); - } - - #[test] - fn uint256_convert_to_uint128() { - let source = Uint256::from(42u128); - let target = Uint128::try_from(source); - assert_eq!(target, Ok(Uint128::new(42u128))); - - let source = Uint256::MAX; - let target = Uint128::try_from(source); - assert_eq!( - target, - Err(ConversionOverflowError::new( - "Uint256", - "Uint128", - Uint256::MAX.to_string() - )) - ); - } - - #[test] - fn uint256_implements_display() { - let a = Uint256::from(12345u32); - assert_eq!(format!("Embedded: {}", a), "Embedded: 12345"); - assert_eq!(a.to_string(), "12345"); - - let a = Uint256::zero(); - assert_eq!(format!("Embedded: {}", a), "Embedded: 0"); - assert_eq!(a.to_string(), "0"); - } - - #[test] - fn uint256_display_padding_works() { - let a = Uint256::from(123u64); - assert_eq!(format!("Embedded: {:05}", a), "Embedded: 00123"); - } - - #[test] - fn uint256_is_zero_works() { - assert!(Uint256::zero().is_zero()); - assert!(Uint256(U256::from(0)).is_zero()); - - assert!(!Uint256::from(1u32).is_zero()); - assert!(!Uint256::from(123u32).is_zero()); - } - - #[test] - fn uint256_json() { - let orig = Uint256::from(1234567890987654321u128); - let serialized = to_vec(&orig).unwrap(); - assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Uint256 = from_slice(&serialized).unwrap(); - assert_eq!(parsed, orig); - } - - #[test] - fn uint256_compare() { - let a = Uint256::from(12345u32); - let b = Uint256::from(23456u32); - - assert!(a < b); - assert!(b > a); - assert_eq!(a, Uint256::from(12345u32)); - } - - #[test] - #[allow(clippy::op_ref)] - fn uint256_math() { - let a = Uint256::from(12345u32); - let b = Uint256::from(23456u32); - - // test + with owned and reference right hand side - assert_eq!(a + b, Uint256::from(35801u32)); - assert_eq!(a + &b, Uint256::from(35801u32)); - - // test - with owned and reference right hand side - assert_eq!(b - a, Uint256::from(11111u32)); - assert_eq!(b - &a, Uint256::from(11111u32)); - - // test += with owned and reference right hand side - let mut c = Uint256::from(300000u32); - c += b; - assert_eq!(c, Uint256::from(323456u32)); - let mut d = Uint256::from(300000u32); - d += &b; - assert_eq!(d, Uint256::from(323456u32)); - - // test -= with owned and reference right hand side - let mut c = Uint256::from(300000u32); - c -= b; - assert_eq!(c, Uint256::from(276544u32)); - let mut d = Uint256::from(300000u32); - d -= &b; - assert_eq!(d, Uint256::from(276544u32)); - - // error result on underflow (- would produce negative result) - let underflow_result = a.checked_sub(b); - let OverflowError { - operand1, operand2, .. - } = underflow_result.unwrap_err(); - assert_eq!((operand1, operand2), (a.to_string(), b.to_string())); - } - - #[test] - #[should_panic] - fn uint256_add_overflow_panics() { - let max = Uint256::new([255u8; 32]); - let _ = max + Uint256::from(12u32); - } - - #[test] - #[should_panic] - fn uint256_sub_overflow_panics() { - let _ = Uint256::from(1u32) - Uint256::from(2u32); - } - - #[test] - fn uint256_multiply_ratio_works() { - let base = Uint256::from(500u32); - - // factor 1/1 - assert_eq!(base.multiply_ratio(1u128, 1u128), base); - assert_eq!(base.multiply_ratio(3u128, 3u128), base); - assert_eq!(base.multiply_ratio(654321u128, 654321u128), base); - assert_eq!(base.multiply_ratio(Uint256::MAX, Uint256::MAX), base); - - // factor 3/2 - assert_eq!(base.multiply_ratio(3u128, 2u128), Uint256::from(750u32)); - assert_eq!( - base.multiply_ratio(333333u128, 222222u128), - Uint256::from(750u32) - ); - - // factor 2/3 (integer devision always floors the result) - assert_eq!(base.multiply_ratio(2u128, 3u128), Uint256::from(333u32)); - assert_eq!( - base.multiply_ratio(222222u128, 333333u128), - Uint256::from(333u32) - ); - - // factor 5/6 (integer devision always floors the result) - assert_eq!(base.multiply_ratio(5u128, 6u128), Uint256::from(416u32)); - assert_eq!(base.multiply_ratio(100u128, 120u128), Uint256::from(416u32)); - } - - #[test] - fn uint256_multiply_ratio_does_not_overflow_when_result_fits() { - // Almost max value for Uint256. - let base = Uint256::MAX - Uint256::from(9u8); - - assert_eq!(base.multiply_ratio(2u128, 2u128), base); - } - - #[test] - #[should_panic] - fn uint256_multiply_ratio_panicks_on_overflow() { - // Almost max value for Uint256. - let base = Uint256::MAX - Uint256::from(9u8); - - assert_eq!(base.multiply_ratio(2u128, 1u128), base); - } - - #[test] - #[should_panic(expected = "Denominator must not be zero")] - fn uint256_multiply_ratio_panics_for_zero_denominator() { - Uint256::from(500u32).multiply_ratio(1u128, 0u128); - } - - #[test] - fn uint256_shr_works() { - let original = Uint256::new([ - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 2u8, 0u8, 4u8, 2u8, - ]); - - let shifted = Uint256::new([ - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 128u8, 1u8, 0u8, - ]); - - assert_eq!(original >> 2u32, shifted); - } - - #[test] - #[should_panic] - fn uint256_shr_overflow_panics() { - let _ = Uint256::from(1u32) >> 256u32; - } - - #[test] - fn sum_works() { - let nums = vec![ - Uint256::from(17u32), - Uint256::from(123u32), - Uint256::from(540u32), - Uint256::from(82u32), - ]; - let expected = Uint256::from(762u32); - - let sum_as_ref = nums.iter().sum(); - assert_eq!(expected, sum_as_ref); - - let sum_as_owned = nums.into_iter().sum(); - assert_eq!(expected, sum_as_owned); - } - - #[test] - fn uint256_methods() { - // checked_* - assert!(matches!( - Uint256::MAX.checked_add(Uint256::from(1u32)), - Err(OverflowError { .. }) - )); - assert!(matches!( - Uint256::from(0u32).checked_sub(Uint256::from(1u32)), - Err(OverflowError { .. }) - )); - assert!(matches!( - Uint256::MAX.checked_mul(Uint256::from(2u32)), - Err(OverflowError { .. }) - )); - assert!(matches!( - Uint256::MAX.checked_div(Uint256::from(0u32)), - Err(DivideByZeroError { .. }) - )); - assert!(matches!( - Uint256::MAX.checked_rem(Uint256::from(0u32)), - Err(DivideByZeroError { .. }) - )); - - // saturating_* - assert_eq!( - Uint256::MAX.saturating_add(Uint256::from(1u32)), - Uint256::MAX - ); - assert_eq!( - Uint256::from(0u32).saturating_sub(Uint256::from(1u32)), - Uint256::from(0u32) - ); - assert_eq!( - Uint256::MAX.saturating_mul(Uint256::from(2u32)), - Uint256::MAX - ); - } -} diff --git a/packages/std/src/math/uint512.rs b/packages/std/src/math/uint512.rs deleted file mode 100644 index 33a10ff57..000000000 --- a/packages/std/src/math/uint512.rs +++ /dev/null @@ -1,725 +0,0 @@ -use schemars::JsonSchema; -use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use std::convert::{TryFrom, TryInto}; -use std::fmt; -use std::iter::Sum; -use std::ops::{self, Shr}; -use std::str::FromStr; - -use crate::errors::{ - ConversionOverflowError, DivideByZeroError, OverflowError, OverflowOperation, StdError, -}; -use crate::{Uint128, Uint256, Uint64}; - -/// This module is purely a workaround that lets us ignore lints for all the code -/// the `construct_uint!` macro generates. -#[allow(clippy::all)] -mod uints { - uint::construct_uint! { - pub struct U512(8); - } -} - -/// Used internally - we don't want to leak this type since we might change -/// the implementation in the future. -use uints::U512; - -/// An implementation of u512 that is using strings for JSON encoding/decoding, -/// such that the full u512 range can be used for clients that convert JSON numbers to floats, -/// like JavaScript and jq. -/// -/// # Examples -/// -/// Use `from` to create instances out of primitive uint types or `new` to provide big -/// endian bytes: -/// -/// ``` -/// # use cosmwasm_std::Uint512; -/// let a = Uint512::from(258u128); -/// let b = Uint512::new([ -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, -/// 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8, -/// ]); -/// assert_eq!(a, b); -/// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema)] -pub struct Uint512(#[schemars(with = "String")] U512); - -impl Uint512 { - pub const MAX: Uint512 = Uint512(U512::MAX); - - /// Creates a Uint512(value) from a big endian representation. It's just an alias for - /// `from_big_endian`. - pub fn new(value: [u8; 64]) -> Self { - Self::from_be_bytes(value) - } - - /// Creates a Uint512(0) - pub const fn zero() -> Self { - Uint512(U512::zero()) - } - - pub fn from_be_bytes(value: [u8; 64]) -> Self { - Uint512(U512::from_big_endian(&value)) - } - - pub fn from_le_bytes(value: [u8; 64]) -> Self { - Uint512(U512::from_little_endian(&value)) - } - - /// Returns a copy of the number as big endian bytes. - pub fn to_be_bytes(self) -> [u8; 64] { - let mut result = [0u8; 64]; - self.0.to_big_endian(&mut result); - result - } - - /// Returns a copy of the number as little endian bytes. - pub fn to_le_bytes(self) -> [u8; 64] { - let mut result = [0u8; 64]; - self.0.to_little_endian(&mut result); - result - } - - pub fn is_zero(&self) -> bool { - self.0.is_zero() - } - - pub fn checked_add(self, other: Self) -> Result { - self.0 - .checked_add(other.0) - .map(Self) - .ok_or_else(|| OverflowError::new(OverflowOperation::Add, self, other)) - } - - pub fn checked_sub(self, other: Self) -> Result { - self.0 - .checked_sub(other.0) - .map(Self) - .ok_or_else(|| OverflowError::new(OverflowOperation::Sub, self, other)) - } - - pub fn checked_mul(self, other: Self) -> Result { - self.0 - .checked_mul(other.0) - .map(Self) - .ok_or_else(|| OverflowError::new(OverflowOperation::Mul, self, other)) - } - - pub fn checked_div(self, other: Self) -> Result { - self.0 - .checked_div(other.0) - .map(Self) - .ok_or_else(|| DivideByZeroError::new(self)) - } - - pub fn checked_rem(self, other: Self) -> Result { - self.0 - .checked_rem(other.0) - .map(Self) - .ok_or_else(|| DivideByZeroError::new(self)) - } - - pub fn checked_shr(self, other: u32) -> Result { - if other >= 512 { - return Err(OverflowError::new(OverflowOperation::Shr, self, other)); - } - - Ok(Self(self.0.shr(other))) - } - - #[must_use] - pub fn saturating_add(self, other: Self) -> Self { - Self(self.0.saturating_add(other.0)) - } - - #[must_use] - pub fn saturating_sub(self, other: Self) -> Self { - Self(self.0.saturating_sub(other.0)) - } - - #[must_use] - pub fn saturating_mul(self, other: Self) -> Self { - Self(self.0.saturating_mul(other.0)) - } -} - -impl From for Uint512 { - fn from(val: Uint256) -> Self { - let bytes = [[0u8; 32], val.to_be_bytes()].concat(); - - Self::from_be_bytes(bytes.try_into().unwrap()) - } -} - -impl From for Uint512 { - fn from(val: Uint128) -> Self { - val.u128().into() - } -} - -impl From for Uint512 { - fn from(val: Uint64) -> Self { - val.u64().into() - } -} - -impl From for Uint512 { - fn from(val: u128) -> Self { - Uint512(val.into()) - } -} - -impl From for Uint512 { - fn from(val: u64) -> Self { - Uint512(val.into()) - } -} - -impl From for Uint512 { - fn from(val: u32) -> Self { - Uint512(val.into()) - } -} - -impl From for Uint512 { - fn from(val: u16) -> Self { - Uint512(val.into()) - } -} - -impl From for Uint512 { - fn from(val: u8) -> Self { - Uint512(val.into()) - } -} - -impl TryFrom for Uint256 { - type Error = ConversionOverflowError; - - fn try_from(value: Uint512) -> Result { - let bytes = value.to_be_bytes(); - let (first_bytes, last_bytes) = bytes.split_at(32); - - if first_bytes != [0u8; 32] { - return Err(ConversionOverflowError::new( - "Uint512", - "Uint256", - value.to_string(), - )); - } - - Ok(Self::from_be_bytes(last_bytes.try_into().unwrap())) - } -} - -impl TryFrom for Uint128 { - type Error = ConversionOverflowError; - - fn try_from(value: Uint512) -> Result { - Ok(Uint128::new(value.0.try_into().map_err(|_| { - ConversionOverflowError::new("Uint512", "Uint128", value.to_string()) - })?)) - } -} - -impl TryFrom<&str> for Uint512 { - type Error = StdError; - - fn try_from(val: &str) -> Result { - Self::from_str(val) - } -} - -impl FromStr for Uint512 { - type Err = StdError; - - fn from_str(s: &str) -> Result { - match U512::from_dec_str(s) { - Ok(u) => Ok(Self(u)), - Err(e) => Err(StdError::generic_err(format!("Parsing u512: {}", e))), - } - } -} - -impl From for String { - fn from(original: Uint512) -> Self { - original.to_string() - } -} - -impl fmt::Display for Uint512 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // The inner type doesn't work as expected with padding, so we - // work around that. - let unpadded = self.0.to_string(); - - f.pad_integral(true, "", &unpadded) - } -} - -impl ops::Add for Uint512 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - Uint512(self.0.checked_add(rhs.0).unwrap()) - } -} - -impl<'a> ops::Add<&'a Uint512> for Uint512 { - type Output = Self; - - fn add(self, rhs: &'a Uint512) -> Self { - Uint512(self.0.checked_add(rhs.0).unwrap()) - } -} - -impl ops::Sub for Uint512 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - Uint512(self.0.checked_sub(rhs.0).unwrap()) - } -} - -impl<'a> ops::Sub<&'a Uint512> for Uint512 { - type Output = Self; - - fn sub(self, rhs: &'a Uint512) -> Self { - Uint512(self.0.checked_sub(rhs.0).unwrap()) - } -} - -impl ops::Div for Uint512 { - type Output = Self; - - fn div(self, rhs: Self) -> Self::Output { - Self(self.0.checked_div(rhs.0).unwrap()) - } -} - -impl<'a> ops::Div<&'a Uint512> for Uint512 { - type Output = Self; - - fn div(self, rhs: &'a Uint512) -> Self::Output { - Self(self.0.checked_div(rhs.0).unwrap()) - } -} - -impl ops::Mul for Uint512 { - type Output = Self; - - fn mul(self, rhs: Self) -> Self::Output { - Self(self.0.checked_mul(rhs.0).unwrap()) - } -} - -impl<'a> ops::Mul<&'a Uint512> for Uint512 { - type Output = Self; - - fn mul(self, rhs: &'a Uint512) -> Self::Output { - Self(self.0.checked_mul(rhs.0).unwrap()) - } -} - -impl ops::Shr for Uint512 { - type Output = Self; - - fn shr(self, rhs: u32) -> Self::Output { - self.checked_shr(rhs).unwrap_or_else(|_| { - panic!( - "right shift error: {} is larger or equal than the number of bits in Uint512", - rhs, - ) - }) - } -} - -impl<'a> ops::Shr<&'a u32> for Uint512 { - type Output = Self; - - fn shr(self, rhs: &'a u32) -> Self::Output { - Shr::::shr(self, *rhs) - } -} - -impl ops::AddAssign for Uint512 { - fn add_assign(&mut self, rhs: Uint512) { - self.0 = self.0.checked_add(rhs.0).unwrap(); - } -} - -impl<'a> ops::AddAssign<&'a Uint512> for Uint512 { - fn add_assign(&mut self, rhs: &'a Uint512) { - self.0 = self.0.checked_add(rhs.0).unwrap(); - } -} - -impl ops::SubAssign for Uint512 { - fn sub_assign(&mut self, rhs: Uint512) { - self.0 = self.0.checked_sub(rhs.0).unwrap(); - } -} - -impl<'a> ops::SubAssign<&'a Uint512> for Uint512 { - fn sub_assign(&mut self, rhs: &'a Uint512) { - self.0 = self.0.checked_sub(rhs.0).unwrap(); - } -} - -impl ops::DivAssign for Uint512 { - fn div_assign(&mut self, rhs: Self) { - self.0 = self.0.checked_div(rhs.0).unwrap(); - } -} - -impl<'a> ops::DivAssign<&'a Uint512> for Uint512 { - fn div_assign(&mut self, rhs: &'a Uint512) { - self.0 = self.0.checked_div(rhs.0).unwrap(); - } -} - -impl ops::MulAssign for Uint512 { - fn mul_assign(&mut self, rhs: Self) { - self.0 = self.0.checked_mul(rhs.0).unwrap(); - } -} - -impl<'a> ops::MulAssign<&'a Uint512> for Uint512 { - fn mul_assign(&mut self, rhs: &'a Uint512) { - self.0 = self.0.checked_mul(rhs.0).unwrap(); - } -} - -impl ops::ShrAssign for Uint512 { - fn shr_assign(&mut self, rhs: u32) { - *self = Shr::::shr(*self, rhs); - } -} - -impl<'a> ops::ShrAssign<&'a u32> for Uint512 { - fn shr_assign(&mut self, rhs: &'a u32) { - *self = Shr::::shr(*self, *rhs); - } -} - -impl Serialize for Uint512 { - /// Serializes as an integer string using base 10 - fn serialize(&self, serializer: S) -> Result - where - S: ser::Serializer, - { - serializer.serialize_str(&self.to_string()) - } -} - -impl<'de> Deserialize<'de> for Uint512 { - /// Deserialized from an integer string using base 10 - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - deserializer.deserialize_str(Uint512Visitor) - } -} - -struct Uint512Visitor; - -impl<'de> de::Visitor<'de> for Uint512Visitor { - type Value = Uint512; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("string-encoded integer") - } - - fn visit_str(self, v: &str) -> Result - where - E: de::Error, - { - Uint512::try_from(v).map_err(|e| E::custom(format!("invalid Uint512 '{}' - {}", v, e))) - } -} - -impl Sum for Uint512 { - fn sum>(iter: I) -> Self { - iter.fold(Uint512::zero(), ops::Add::add) - } -} - -impl<'a> Sum<&'a Uint512> for Uint512 { - fn sum>(iter: I) -> Self { - iter.fold(Uint512::zero(), ops::Add::add) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{from_slice, to_vec}; - - #[test] - fn uint512_construct() { - let num = Uint512::new([1; 64]); - let a: [u8; 64] = num.to_be_bytes(); - assert_eq!(a, [1; 64]); - - let be_bytes = [ - 0u8, 222u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8, 3u8, - ]; - let num = Uint512::new(be_bytes); - let resulting_bytes: [u8; 64] = num.to_be_bytes(); - assert_eq!(be_bytes, resulting_bytes); - } - - #[test] - fn uint512_endianness() { - let be_bytes = [ - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8, 3u8, - ]; - let le_bytes = [ - 3u8, 2u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - ]; - - // These should all be the same. - let num1 = Uint512::new(be_bytes); - let num2 = Uint512::from_be_bytes(be_bytes); - let num3 = Uint512::from_le_bytes(le_bytes); - assert_eq!(num1, Uint512::from(65536u32 + 512 + 3)); - assert_eq!(num1, num2); - assert_eq!(num1, num3); - } - - #[test] - fn uint512_convert_from() { - let a = Uint512::from(5u128); - assert_eq!(a.0, U512::from(5)); - - let a = Uint512::from(5u64); - assert_eq!(a.0, U512::from(5)); - - let a = Uint512::from(5u32); - assert_eq!(a.0, U512::from(5)); - - let a = Uint512::from(5u16); - assert_eq!(a.0, U512::from(5)); - - let a = Uint512::from(5u8); - assert_eq!(a.0, U512::from(5)); - - let result = Uint512::try_from("34567"); - assert_eq!(result.unwrap().0, U512::from_dec_str("34567").unwrap()); - - let result = Uint512::try_from("1.23"); - assert!(result.is_err()); - } - - #[test] - fn uint512_convert_to_uint128() { - let source = Uint512::from(42u128); - let target = Uint128::try_from(source); - assert_eq!(target, Ok(Uint128::new(42u128))); - - let source = Uint512::MAX; - let target = Uint128::try_from(source); - assert_eq!( - target, - Err(ConversionOverflowError::new( - "Uint512", - "Uint128", - Uint512::MAX.to_string() - )) - ); - } - - #[test] - fn uint512_implements_display() { - let a = Uint512::from(12345u32); - assert_eq!(format!("Embedded: {}", a), "Embedded: 12345"); - assert_eq!(a.to_string(), "12345"); - - let a = Uint512::zero(); - assert_eq!(format!("Embedded: {}", a), "Embedded: 0"); - assert_eq!(a.to_string(), "0"); - } - - #[test] - fn uint512_display_padding_works() { - let a = Uint512::from(123u64); - assert_eq!(format!("Embedded: {:05}", a), "Embedded: 00123"); - } - - #[test] - fn uint512_is_zero_works() { - assert!(Uint512::zero().is_zero()); - assert!(Uint512(U512::from(0)).is_zero()); - - assert!(!Uint512::from(1u32).is_zero()); - assert!(!Uint512::from(123u32).is_zero()); - } - - #[test] - fn uint512_json() { - let orig = Uint512::from(1234567890987654321u128); - let serialized = to_vec(&orig).unwrap(); - assert_eq!(serialized.as_slice(), b"\"1234567890987654321\""); - let parsed: Uint512 = from_slice(&serialized).unwrap(); - assert_eq!(parsed, orig); - } - - #[test] - fn uint512_compare() { - let a = Uint512::from(12345u32); - let b = Uint512::from(23456u32); - - assert!(a < b); - assert!(b > a); - assert_eq!(a, Uint512::from(12345u32)); - } - - #[test] - #[allow(clippy::op_ref)] - fn uint512_math() { - let a = Uint512::from(12345u32); - let b = Uint512::from(23456u32); - - // test + with owned and reference right hand side - assert_eq!(a + b, Uint512::from(35801u32)); - assert_eq!(a + &b, Uint512::from(35801u32)); - - // test - with owned and reference right hand side - assert_eq!(b - a, Uint512::from(11111u32)); - assert_eq!(b - &a, Uint512::from(11111u32)); - - // test += with owned and reference right hand side - let mut c = Uint512::from(300000u32); - c += b; - assert_eq!(c, Uint512::from(323456u32)); - let mut d = Uint512::from(300000u32); - d += &b; - assert_eq!(d, Uint512::from(323456u32)); - - // test -= with owned and reference right hand side - let mut c = Uint512::from(300000u32); - c -= b; - assert_eq!(c, Uint512::from(276544u32)); - let mut d = Uint512::from(300000u32); - d -= &b; - assert_eq!(d, Uint512::from(276544u32)); - - // error result on underflow (- would produce negative result) - let underflow_result = a.checked_sub(b); - let OverflowError { - operand1, operand2, .. - } = underflow_result.unwrap_err(); - assert_eq!((operand1, operand2), (a.to_string(), b.to_string())); - } - - #[test] - #[should_panic] - fn uint512_add_overflow_panics() { - let max = Uint512::new([255u8; 64]); - let _ = max + Uint512::from(12u32); - } - - #[test] - #[should_panic] - fn uint512_sub_overflow_panics() { - let _ = Uint512::from(1u32) - Uint512::from(2u32); - } - - #[test] - fn uint512_shr_works() { - let original = Uint512::new([ - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 2u8, 0u8, 4u8, 2u8, - ]); - - let shifted = Uint512::new([ - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, - 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 128u8, 1u8, 0u8, - ]); - - assert_eq!(original >> 2u32, shifted); - } - - #[test] - #[should_panic] - fn uint512_shr_overflow_panics() { - let _ = Uint512::from(1u32) >> 512u32; - } - - #[test] - fn sum_works() { - let nums = vec![ - Uint512::from(17u32), - Uint512::from(123u32), - Uint512::from(540u32), - Uint512::from(82u32), - ]; - let expected = Uint512::from(762u32); - - let sum_as_ref = nums.iter().sum(); - assert_eq!(expected, sum_as_ref); - - let sum_as_owned = nums.into_iter().sum(); - assert_eq!(expected, sum_as_owned); - } - - #[test] - fn uint512_methods() { - // checked_* - assert!(matches!( - Uint512::MAX.checked_add(Uint512::from(1u32)), - Err(OverflowError { .. }) - )); - assert!(matches!( - Uint512::from(0u32).checked_sub(Uint512::from(1u32)), - Err(OverflowError { .. }) - )); - assert!(matches!( - Uint512::MAX.checked_mul(Uint512::from(2u32)), - Err(OverflowError { .. }) - )); - assert!(matches!( - Uint512::MAX.checked_div(Uint512::from(0u32)), - Err(DivideByZeroError { .. }) - )); - assert!(matches!( - Uint512::MAX.checked_rem(Uint512::from(0u32)), - Err(DivideByZeroError { .. }) - )); - - // saturating_* - assert_eq!( - Uint512::MAX.saturating_add(Uint512::from(1u32)), - Uint512::MAX - ); - assert_eq!( - Uint512::from(0u32).saturating_sub(Uint512::from(1u32)), - Uint512::from(0u32) - ); - assert_eq!( - Uint512::MAX.saturating_mul(Uint512::from(2u32)), - Uint512::MAX - ); - } -} diff --git a/packages/std/src/math/uint64.rs b/packages/std/src/math/uint64.rs index bccd60925..4d8db1065 100644 --- a/packages/std/src/math/uint64.rs +++ b/packages/std/src/math/uint64.rs @@ -1,12 +1,11 @@ use schemars::JsonSchema; use serde::{de, ser, Deserialize, Deserializer, Serialize}; -use std::convert::{TryFrom, TryInto}; +use std::convert::TryFrom; use std::fmt::{self}; use std::iter::Sum; use std::ops; use crate::errors::{DivideByZeroError, OverflowError, OverflowOperation, StdError}; -use crate::Uint128; /// A thin wrapper around u64 that is using strings for JSON encoding/decoding, /// such that the full u64 range can be used for clients that convert JSON numbers to floats, @@ -28,8 +27,6 @@ use crate::Uint128; pub struct Uint64(#[schemars(with = "String")] u64); impl Uint64 { - pub const MAX: Self = Self(u64::MAX); - /// Creates a Uint64(value). /// /// This method is less flexible than `from` but can be called in a const context. @@ -93,42 +90,34 @@ impl Uint64 { .ok_or_else(|| DivideByZeroError::new(self)) } - #[must_use] pub fn wrapping_add(self, other: Self) -> Self { Self(self.0.wrapping_add(other.0)) } - #[must_use] pub fn wrapping_sub(self, other: Self) -> Self { Self(self.0.wrapping_sub(other.0)) } - #[must_use] pub fn wrapping_mul(self, other: Self) -> Self { Self(self.0.wrapping_mul(other.0)) } - #[must_use] pub fn wrapping_pow(self, other: u32) -> Self { Self(self.0.wrapping_pow(other)) } - #[must_use] pub fn saturating_add(self, other: Self) -> Self { Self(self.0.saturating_add(other.0)) } - #[must_use] pub fn saturating_sub(self, other: Self) -> Self { Self(self.0.saturating_sub(other.0)) } - #[must_use] pub fn saturating_mul(self, other: Self) -> Self { Self(self.0.saturating_mul(other.0)) } - #[must_use] pub fn saturating_pow(self, other: u32) -> Self { Self(self.0.saturating_pow(other)) } @@ -188,7 +177,7 @@ impl From for u64 { impl fmt::Display for Uint64 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.fmt(f) + write!(f, "{}", self.0) } } @@ -208,38 +197,6 @@ impl<'a> ops::Add<&'a Uint64> for Uint64 { } } -impl ops::Div for Uint64 { - type Output = Self; - - fn div(self, rhs: Self) -> Self::Output { - Self(self.u64().checked_div(rhs.u64()).unwrap()) - } -} - -impl<'a> ops::Div<&'a Uint64> for Uint64 { - type Output = Self; - - fn div(self, rhs: &'a Uint64) -> Self::Output { - Self(self.u64().checked_div(rhs.u64()).unwrap()) - } -} - -impl ops::Shr for Uint64 { - type Output = Self; - - fn shr(self, rhs: u32) -> Self::Output { - Self(self.u64().checked_shr(rhs).unwrap()) - } -} - -impl<'a> ops::Shr<&'a u32> for Uint64 { - type Output = Self; - - fn shr(self, rhs: &'a u32) -> Self::Output { - Self(self.u64().checked_shr(*rhs).unwrap()) - } -} - impl ops::AddAssign for Uint64 { fn add_assign(&mut self, rhs: Uint64) { self.0 = self.0.checked_add(rhs.u64()).unwrap(); @@ -252,65 +209,21 @@ impl<'a> ops::AddAssign<&'a Uint64> for Uint64 { } } -impl ops::DivAssign for Uint64 { - fn div_assign(&mut self, rhs: Self) { - self.0 = self.0.checked_div(rhs.u64()).unwrap(); - } -} - -impl<'a> ops::DivAssign<&'a Uint64> for Uint64 { - fn div_assign(&mut self, rhs: &'a Uint64) { - self.0 = self.0.checked_div(rhs.u64()).unwrap(); - } -} - -impl ops::ShrAssign for Uint64 { - fn shr_assign(&mut self, rhs: u32) { - self.0 = self.0.checked_shr(rhs).unwrap(); - } -} - -impl<'a> ops::ShrAssign<&'a u32> for Uint64 { - fn shr_assign(&mut self, rhs: &'a u32) { - self.0 = self.0.checked_shr(*rhs).unwrap(); - } -} - impl Uint64 { /// Returns `self * numerator / denominator` - #[must_use] pub fn multiply_ratio, B: Into>( &self, numerator: A, denominator: B, ) -> Uint64 { - let numerator = numerator.into(); - let denominator = denominator.into(); + let numerator: u64 = numerator.into(); + let denominator: u64 = denominator.into(); if denominator == 0 { panic!("Denominator must not be zero"); } - - (self.full_mul(numerator) / Uint128::from(denominator)) - .try_into() - .expect("multiplication overflow") - } - - /// Multiplies two `Uint64`/`u64` values without overflow, producing an - /// [`Uint128`]. - /// - /// # Examples - /// - /// ``` - /// use cosmwasm_std::Uint64; - /// - /// let a = Uint64::MAX; - /// let result = a.full_mul(2u32); - /// assert_eq!(result.to_string(), "36893488147419103230"); - /// ``` - pub fn full_mul(self, rhs: impl Into) -> Uint128 { - Uint128::from(self.u64()) - .checked_mul(Uint128::from(rhs.into())) - .unwrap() + // TODO: minimize rounding that takes place (using gcd algorithm) + let val = self.u64() * numerator / denominator; + Uint64::from(val) } } @@ -414,19 +327,13 @@ mod tests { assert_eq!(a.to_string(), "0"); } - #[test] - fn uint64_display_padding_works() { - let a = Uint64::from(123u64); - assert_eq!(format!("Embedded: {:05}", a), "Embedded: 00123"); - } - #[test] fn uint64_is_zero_works() { - assert!(Uint64::zero().is_zero()); - assert!(Uint64(0).is_zero()); + assert_eq!(Uint64::zero().is_zero(), true); + assert_eq!(Uint64(0).is_zero(), true); - assert!(!Uint64(1).is_zero()); - assert!(!Uint64(123).is_zero()); + assert_eq!(Uint64(1).is_zero(), false); + assert_eq!(Uint64(123).is_zero(), false); } #[test] @@ -490,10 +397,9 @@ mod tests { let base = Uint64(500); // factor 1/1 - assert_eq!(base.multiply_ratio(1u64, 1u64), base); - assert_eq!(base.multiply_ratio(3u64, 3u64), base); - assert_eq!(base.multiply_ratio(654321u64, 654321u64), base); - assert_eq!(base.multiply_ratio(u64::MAX, u64::MAX), base); + assert_eq!(base.multiply_ratio(1u64, 1u64), Uint64(500)); + assert_eq!(base.multiply_ratio(3u64, 3u64), Uint64(500)); + assert_eq!(base.multiply_ratio(654321u64, 654321u64), Uint64(500)); // factor 3/2 assert_eq!(base.multiply_ratio(3u64, 2u64), Uint64(750)); @@ -508,23 +414,6 @@ mod tests { assert_eq!(base.multiply_ratio(100u64, 120u64), Uint64(416)); } - #[test] - fn uint64_multiply_ratio_does_not_overflow_when_result_fits() { - // Almost max value for Uint64. - let base = Uint64(u64::MAX - 9); - - assert_eq!(base.multiply_ratio(2u64, 2u64), base); - } - - #[test] - #[should_panic] - fn uint64_multiply_ratio_panicks_on_overflow() { - // Almost max value for Uint64. - let base = Uint64(u64::MAX - 9); - - assert_eq!(base.multiply_ratio(2u64, 1u64), base); - } - #[test] #[should_panic(expected = "Denominator must not be zero")] fn uint64_multiply_ratio_panics_for_zero_denominator() { diff --git a/packages/std/src/mock.rs b/packages/std/src/mock.rs index 0190e7ee5..a22e08704 100644 --- a/packages/std/src/mock.rs +++ b/packages/std/src/mock.rs @@ -11,11 +11,7 @@ use crate::errors::{ HashCalculationError, RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError, }; #[cfg(feature = "stargate")] -use crate::ibc::{ - IbcAcknowledgement, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, - IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, - IbcTimeoutBlock, -}; +use crate::ibc::{IbcChannel, IbcEndpoint, IbcOrder, IbcPacket, IbcTimeoutBlock}; use crate::query::{ AllBalanceResponse, BalanceResponse, BankQuery, CustomQuery, QueryRequest, WasmQuery, }; @@ -30,7 +26,6 @@ use crate::storage::MemoryStorage; use crate::timestamp::Timestamp; use crate::traits::{Api, Querier, QuerierResult}; use crate::types::{BlockInfo, ContractInfo, Env, MessageInfo}; -use crate::Attribute; pub const MOCK_CONTRACT_ADDR: &str = "cosmos2contract"; @@ -62,14 +57,6 @@ pub fn mock_dependencies_with_balances( // We can later make simplifications here if needed pub type MockStorage = MemoryStorage; -/// Length of canonical addresses created with this API. Contracts should not make any assumtions -/// what this value is. -/// The value here must be restorable with `SHUFFLES_ENCODE` + `SHUFFLES_DECODE` in-shuffles. -const CANONICAL_LENGTH: usize = 54; - -const SHUFFLES_ENCODE: usize = 18; -const SHUFFLES_DECODE: usize = 2; - // MockPrecompiles zero pads all human addresses to make them fit the canonical_length // it trims off zeros for the reverse operation. // not really smart, but allows us to see a difference (and consistent length for canonical adddresses) @@ -77,13 +64,13 @@ const SHUFFLES_DECODE: usize = 2; pub struct MockApi { /// Length of canonical addresses created with this API. Contracts should not make any assumtions /// what this value is. - canonical_length: usize, + pub canonical_length: usize, } impl Default for MockApi { fn default() -> Self { MockApi { - canonical_length: CANONICAL_LENGTH, + canonical_length: 24, } } } @@ -115,7 +102,7 @@ impl Api for MockApi { // the most obvious structure (https://github.com/CosmWasm/cosmwasm/issues/552) let rotate_by = digit_sum(&out) % self.canonical_length; out.rotate_left(rotate_by); - for _ in 0..SHUFFLES_ENCODE { + for _ in 0..18 { out = riffle_shuffle(&out); } Ok(out.into()) @@ -130,7 +117,7 @@ impl Api for MockApi { let mut tmp: Vec = canonical.clone().into(); // Shuffle two more times which restored the original value (24 elements are back to original after 20 rounds) - for _ in 0..SHUFFLES_DECODE { + for _ in 0..2 { tmp = riffle_shuffle(&tmp); } // Rotate back @@ -227,9 +214,9 @@ pub fn mock_info(sender: &str, funds: &[Coin]) -> MessageInfo { } } +#[cfg(feature = "stargate")] /// Creates an IbcChannel for testing. You set a few key parameters for handshaking, /// If you want to set more, use this as a default and mutate other fields -#[cfg(feature = "stargate")] pub fn mock_ibc_channel(my_channel_id: &str, order: IbcOrder, version: &str) -> IbcChannel { IbcChannel { endpoint: IbcEndpoint { @@ -242,78 +229,16 @@ pub fn mock_ibc_channel(my_channel_id: &str, order: IbcOrder, version: &str) -> }, order, version: version.to_string(), + counterparty_version: Some(version.to_string()), connection_id: "connection-2".to_string(), } } -/// Creates a IbcChannelOpenMsg::OpenInit for testing ibc_channel_open. -#[cfg(feature = "stargate")] -pub fn mock_ibc_channel_open_init( - my_channel_id: &str, - order: IbcOrder, - version: &str, -) -> IbcChannelOpenMsg { - IbcChannelOpenMsg::new_init(mock_ibc_channel(my_channel_id, order, version)) -} - -/// Creates a IbcChannelOpenMsg::OpenTry for testing ibc_channel_open. -#[cfg(feature = "stargate")] -pub fn mock_ibc_channel_open_try( - my_channel_id: &str, - order: IbcOrder, - version: &str, -) -> IbcChannelOpenMsg { - IbcChannelOpenMsg::new_try(mock_ibc_channel(my_channel_id, order, version), version) -} - -/// Creates a IbcChannelConnectMsg::ConnectAck for testing ibc_channel_connect. #[cfg(feature = "stargate")] -pub fn mock_ibc_channel_connect_ack( - my_channel_id: &str, - order: IbcOrder, - version: &str, -) -> IbcChannelConnectMsg { - IbcChannelConnectMsg::new_ack(mock_ibc_channel(my_channel_id, order, version), version) -} - -/// Creates a IbcChannelConnectMsg::ConnectConfirm for testing ibc_channel_connect. -#[cfg(feature = "stargate")] -pub fn mock_ibc_channel_connect_confirm( - my_channel_id: &str, - order: IbcOrder, - version: &str, -) -> IbcChannelConnectMsg { - IbcChannelConnectMsg::new_confirm(mock_ibc_channel(my_channel_id, order, version)) -} - -/// Creates a IbcChannelCloseMsg::CloseInit for testing ibc_channel_close. -#[cfg(feature = "stargate")] -pub fn mock_ibc_channel_close_init( - my_channel_id: &str, - order: IbcOrder, - version: &str, -) -> IbcChannelCloseMsg { - IbcChannelCloseMsg::new_init(mock_ibc_channel(my_channel_id, order, version)) -} - -/// Creates a IbcChannelCloseMsg::CloseConfirm for testing ibc_channel_close. -#[cfg(feature = "stargate")] -pub fn mock_ibc_channel_close_confirm( - my_channel_id: &str, - order: IbcOrder, - version: &str, -) -> IbcChannelCloseMsg { - IbcChannelCloseMsg::new_confirm(mock_ibc_channel(my_channel_id, order, version)) -} - -/// Creates a IbcPacketReceiveMsg for testing ibc_packet_receive. You set a few key parameters that are +/// Creates a IbcPacket for testing ibc_packet_receive. You set a few key parameters that are /// often parsed. If you want to set more, use this as a default and mutate other fields -#[cfg(feature = "stargate")] -pub fn mock_ibc_packet_recv( - my_channel_id: &str, - data: &impl Serialize, -) -> StdResult { - Ok(IbcPacketReceiveMsg::new(IbcPacket { +pub fn mock_ibc_packet_recv(my_channel_id: &str, data: &T) -> StdResult { + Ok(IbcPacket { data: to_binary(data)?, src: IbcEndpoint { port_id: "their-port".to_string(), @@ -329,14 +254,14 @@ pub fn mock_ibc_packet_recv( height: 12345678, } .into(), - })) + }) } +#[cfg(feature = "stargate")] /// Creates a IbcPacket for testing ibc_packet_{ack,timeout}. You set a few key parameters that are /// often parsed. If you want to set more, use this as a default and mutate other fields. -/// The difference from mock_ibc_packet_recv is if `my_channel_id` is src or dest. -#[cfg(feature = "stargate")] -fn mock_ibc_packet(my_channel_id: &str, data: &impl Serialize) -> StdResult { +/// The difference between mock_ibc_packet_recv is if `my_channel_id` is src or dest. +pub fn mock_ibc_packet_ack(my_channel_id: &str, data: &T) -> StdResult { Ok(IbcPacket { data: to_binary(data)?, src: IbcEndpoint { @@ -356,31 +281,6 @@ fn mock_ibc_packet(my_channel_id: &str, data: &impl Serialize) -> StdResult StdResult { - let packet = mock_ibc_packet(my_channel_id, data)?; - - Ok(IbcPacketAckMsg::new(ack, packet)) -} - -/// Creates a IbcPacketTimeoutMsg for testing ibc_packet_timeout. You set a few key parameters that are -/// often parsed. If you want to set more, use this as a default and mutate other fields. -/// The difference from mock_ibc_packet_recv is if `my_channel_id` is src or dest./ -#[cfg(feature = "stargate")] -pub fn mock_ibc_packet_timeout( - my_channel_id: &str, - data: &impl Serialize, -) -> StdResult { - mock_ibc_packet(my_channel_id, data).map(IbcPacketTimeoutMsg::new) -} - /// The same type as cosmwasm-std's QuerierResult, but easier to reuse in /// cosmwasm-vm. It might diverge from QuerierResult at some point. pub type MockQuerierCustomHandlerResult = SystemResult>; @@ -417,9 +317,9 @@ impl MockQuerier { } // set a new balance for the given address and return the old balance - pub fn update_balance( + pub fn update_balance>( &mut self, - addr: impl Into, + addr: U, balance: Vec, ) -> Option> { self.bank.balances.insert(addr.into(), balance) @@ -435,7 +335,6 @@ impl MockQuerier { self.staking = StakingQuerier::new(denom, validators, delegations); } - #[must_use] pub fn with_custom_handler(mut self, handler: CH) -> Self where CH: Fn(&C) -> MockQuerierCustomHandlerResult, @@ -615,49 +514,6 @@ impl StakingQuerier { /// /// https://en.wikipedia.org/wiki/Riffle_shuffle_permutation#Perfect_shuffles /// https://en.wikipedia.org/wiki/In_shuffle -/// -/// The number of shuffles required to restore the original order are listed in -/// https://oeis.org/A002326, e.g.: -/// -/// ```ignore -/// 2: 2 -/// 4: 4 -/// 6: 3 -/// 8: 6 -/// 10: 10 -/// 12: 12 -/// 14: 4 -/// 16: 8 -/// 18: 18 -/// 20: 6 -/// 22: 11 -/// 24: 20 -/// 26: 18 -/// 28: 28 -/// 30: 5 -/// 32: 10 -/// 34: 12 -/// 36: 36 -/// 38: 12 -/// 40: 20 -/// 42: 14 -/// 44: 12 -/// 46: 23 -/// 48: 21 -/// 50: 8 -/// 52: 52 -/// 54: 20 -/// 56: 18 -/// 58: 58 -/// 60: 60 -/// 62: 6 -/// 64: 12 -/// 66: 66 -/// 68: 22 -/// 70: 35 -/// 72: 9 -/// 74: 20 -/// ``` pub fn riffle_shuffle(input: &[T]) -> Vec { assert!( input.len() % 2 == 0, @@ -677,15 +533,6 @@ pub fn digit_sum(input: &[u8]) -> usize { input.iter().fold(0, |sum, val| sum + (*val as usize)) } -/// Only for test code. This bypasses assertions in new, allowing us to create _* -/// Attributes to simulate responses from the blockchain -pub fn mock_wasmd_attr(key: impl Into, value: impl Into) -> Attribute { - Attribute { - key: key.into(), - value: value.into(), - } -} - #[cfg(test)] mod tests { use super::*; @@ -741,8 +588,7 @@ mod tests { #[should_panic(expected = "address too long")] fn addr_canonicalize_max_input_length() { let api = MockApi::default(); - let human = - String::from("some-extremely-long-address-not-supported-by-this-api-longer-than-54"); + let human = String::from("some-extremely-long-address-not-supported-by-this-api"); let _ = api.addr_canonicalize(&human).unwrap(); } @@ -754,7 +600,7 @@ mod tests { api.addr_canonicalize(&input).unwrap(); let input = "foobar456"; - api.addr_canonicalize(input).unwrap(); + api.addr_canonicalize(&input).unwrap(); } #[test] @@ -962,8 +808,8 @@ mod tests { let signature = hex::decode(ED25519_SIG_HEX).unwrap(); let public_key: Vec = vec![0u8; 0]; - let msgs: Vec<&[u8]> = vec![msg.as_slice()]; - let signatures: Vec<&[u8]> = vec![signature.as_slice()]; + let msgs: Vec<&[u8]> = vec![&msg.as_slice()]; + let signatures: Vec<&[u8]> = vec![&signature.as_slice()]; let public_keys: Vec<&[u8]> = vec![&public_key]; let res = api.ed25519_batch_verify(&msgs, &signatures, &public_keys); @@ -1119,9 +965,9 @@ mod tests { #[cfg(feature = "staking")] // gets delegators from query or panic - fn get_all_delegators( + fn get_all_delegators>( staking: &StakingQuerier, - delegator: impl Into, + delegator: U, ) -> Vec { let raw = staking .query(&StakingQuery::AllDelegations { @@ -1135,10 +981,10 @@ mod tests { #[cfg(feature = "staking")] // gets full delegators from query or panic - fn get_delegator( + fn get_delegator, V: Into>( staking: &StakingQuerier, - delegator: impl Into, - validator: impl Into, + delegator: U, + validator: V, ) -> Option { let raw = staking .query(&StakingQuery::Delegation { diff --git a/packages/std/src/results/attribute.rs b/packages/std/src/results/attribute.rs new file mode 100644 index 000000000..619e12bba --- /dev/null +++ b/packages/std/src/results/attribute.rs @@ -0,0 +1,37 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +/// An key value pair that is used in the context of event attributes in logs +#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, JsonSchema)] +pub struct Attribute { + pub key: String, + pub value: String, +} + +/// Creates a new Attribute. +pub fn attr(key: K, value: V) -> Attribute { + Attribute { + key: key.to_string(), + value: value.to_string(), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::Uint128; + + #[test] + fn attr_works_for_different_types() { + let expeceted = Attribute { + key: "foo".to_string(), + value: "42".to_string(), + }; + + assert_eq!(attr("foo", "42"), expeceted); + assert_eq!(attr("foo".to_string(), "42"), expeceted); + assert_eq!(attr("foo", "42".to_string()), expeceted); + assert_eq!(attr("foo", Uint128(42)), expeceted); + assert_eq!(attr("foo", 42), expeceted); + } +} diff --git a/packages/std/src/results/contract_result.rs b/packages/std/src/results/contract_result.rs index afaaed2ad..eda69703f 100644 --- a/packages/std/src/results/contract_result.rs +++ b/packages/std/src/results/contract_result.rs @@ -18,7 +18,7 @@ use std::fmt; /// # use cosmwasm_std::{to_vec, ContractResult, Response}; /// let response: Response = Response::default(); /// let result: ContractResult = ContractResult::Ok(response); -/// assert_eq!(to_vec(&result).unwrap(), br#"{"ok":{"messages":[],"attributes":[],"events":[],"data":null}}"#.to_vec()); +/// assert_eq!(to_vec(&result).unwrap(), br#"{"ok":{"submessages":[],"messages":[],"attributes":[],"data":null}}"#.to_vec()); /// ``` /// /// Failure: @@ -101,7 +101,7 @@ mod tests { let result: ContractResult = ContractResult::Ok(Response::default()); assert_eq!( to_vec(&result).unwrap(), - br#"{"ok":{"messages":[],"attributes":[],"events":[],"data":null}}"#.to_vec() + br#"{"ok":{"submessages":[],"messages":[],"attributes":[],"data":null}}"#.to_vec() ); let result: ContractResult = ContractResult::Err("broken".to_string()); @@ -117,7 +117,7 @@ mod tests { assert_eq!(result, ContractResult::Ok("foo".to_string())); let result: ContractResult = - from_slice(br#"{"ok":{"messages":[],"attributes":[],"events":[],"data":null}}"#) + from_slice(br#"{"ok":{"submessages":[],"messages":[],"attributes":[],"data":null}}"#) .unwrap(); assert_eq!(result, ContractResult::Ok(Response::default())); diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index c5c795611..138f6e4e3 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -37,8 +37,6 @@ where #[cfg(feature = "stargate")] Ibc(IbcMsg), Wasm(WasmMsg), - #[cfg(feature = "stargate")] - Gov(GovMsg), } /// The message types of the bank module. @@ -122,7 +120,7 @@ pub enum WasmMsg { contract_addr: String, /// msg is the json-encoded ExecuteMsg struct (as raw Binary) msg: Binary, - funds: Vec, + send: Vec, }, /// Instantiates a new contracts from previously uploaded Wasm code. /// @@ -133,7 +131,7 @@ pub enum WasmMsg { code_id: u64, /// msg is the JSON-encoded InstantiateMsg struct (as raw Binary) msg: Binary, - funds: Vec, + send: Vec, /// A human-readbale label for the contract label: String, }, @@ -162,54 +160,39 @@ pub enum WasmMsg { ClearAdmin { contract_addr: String }, } -#[cfg(feature = "stargate")] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum GovMsg { - /// This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address. - Vote { proposal_id: u64, vote: VoteOption }, -} - -#[cfg(feature = "stargate")] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum VoteOption { - Yes, - No, - Abstain, - NoWithVeto, -} - /// Shortcut helper as the construction of WasmMsg::Instantiate can be quite verbose in contract code. /// /// When using this, `admin` is always unset. If you need more flexibility, create the message directly. -pub fn wasm_instantiate( +pub fn wasm_instantiate( code_id: u64, - msg: &impl Serialize, - funds: Vec, + msg: &T, + send: Vec, label: String, -) -> StdResult { +) -> StdResult +where + T: Serialize, +{ let payload = to_binary(msg)?; Ok(WasmMsg::Instantiate { admin: None, code_id, msg: payload, - funds, + send, label, }) } /// Shortcut helper as the construction of WasmMsg::Instantiate can be quite verbose in contract code -pub fn wasm_execute( - contract_addr: impl Into, - msg: &impl Serialize, - funds: Vec, -) -> StdResult { +pub fn wasm_execute(contract_addr: T, msg: &U, send: Vec) -> StdResult +where + T: Into, + U: Serialize, +{ let payload = to_binary(msg)?; Ok(WasmMsg::Execute { contract_addr: contract_addr.into(), msg: payload, - funds, + send, }) } @@ -261,16 +244,6 @@ where } } -#[cfg(feature = "stargate")] -impl From for CosmosMsg -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - fn from(msg: GovMsg) -> Self { - CosmosMsg::Gov(msg) - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/packages/std/src/results/events.rs b/packages/std/src/results/events.rs deleted file mode 100644 index b94004780..000000000 --- a/packages/std/src/results/events.rs +++ /dev/null @@ -1,172 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -/// A full [*Cosmos SDK* event]. -/// -/// This version uses string attributes (similar to [*Cosmos SDK* StringEvent]), -/// which then get magically converted to bytes for Tendermint somewhere between -/// the Rust-Go interface, JSON deserialization and the `NewEvent` call in Cosmos SDK. -/// -/// [*Cosmos SDK* event]: https://docs.cosmos.network/v0.42/core/events.html -/// [*Cosmos SDK* StringEvent]: https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/base/abci/v1beta1/abci.proto#L56-L70 -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] -pub struct Event { - /// The event type. This is renamed to "ty" because "type" is reserved in Rust. This sucks, we know. - #[serde(rename = "type")] - pub ty: String, - /// The attributes to be included in the event. - /// - /// You can learn more about these from [*Cosmos SDK* docs]. - /// - /// [*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html - pub attributes: Vec, -} - -impl Event { - /// Create a new event with the given type and an empty list of attributes. - #[must_use] - pub fn new(ty: impl Into) -> Self { - Event { - ty: ty.into(), - attributes: Vec::with_capacity(10), - } - } - - /// Add an attribute to the event. - #[must_use] - pub fn add_attribute(mut self, key: impl Into, value: impl Into) -> Self { - self.attributes.push(Attribute { - key: key.into(), - value: value.into(), - }); - self - } - - /// Bulk add attributes to the event. - /// - /// Anything that can be turned into an iterator and yields something - /// that can be converted into an `Attribute` is accepted. - #[must_use] - pub fn add_attributes>( - mut self, - attrs: impl IntoIterator, - ) -> Self { - self.attributes.extend(attrs.into_iter().map(A::into)); - self - } -} - -/// An key value pair that is used in the context of event attributes in logs -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, JsonSchema)] -pub struct Attribute { - pub key: String, - pub value: String, -} - -impl Attribute { - /// Creates a new Attribute. `attr` is just an alias for this. - pub fn new(key: impl Into, value: impl Into) -> Self { - let key = key.into(); - - #[cfg(debug_assertions)] - if key.starts_with('_') { - panic!( - "attribute key `{}` is invalid - keys starting with an underscore are reserved", - key - ); - } - - Self { - key, - value: value.into(), - } - } -} - -impl, V: Into> From<(K, V)> for Attribute { - fn from((k, v): (K, V)) -> Self { - Attribute::new(k, v) - } -} - -impl, V: AsRef> PartialEq<(K, V)> for Attribute { - fn eq(&self, (k, v): &(K, V)) -> bool { - (self.key.as_str(), self.value.as_str()) == (k.as_ref(), v.as_ref()) - } -} - -impl, V: AsRef> PartialEq for (K, V) { - fn eq(&self, attr: &Attribute) -> bool { - attr == self - } -} - -impl, V: AsRef> PartialEq<(K, V)> for &Attribute { - fn eq(&self, (k, v): &(K, V)) -> bool { - (self.key.as_str(), self.value.as_str()) == (k.as_ref(), v.as_ref()) - } -} - -impl, V: AsRef> PartialEq<&Attribute> for (K, V) { - fn eq(&self, attr: &&Attribute) -> bool { - attr == self - } -} - -impl PartialEq for &Attribute { - fn eq(&self, rhs: &Attribute) -> bool { - *self == rhs - } -} - -impl PartialEq<&Attribute> for Attribute { - fn eq(&self, rhs: &&Attribute) -> bool { - self == *rhs - } -} - -/// Creates a new Attribute. `Attribute::new` is an alias for this. -#[inline] -pub fn attr(key: impl Into, value: impl Into) -> Attribute { - Attribute::new(key, value) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::Uint128; - - #[test] - fn event_construction() { - let event_direct = Event { - ty: "test".to_string(), - attributes: vec![attr("foo", "bar"), attr("bar", "baz")], - }; - let event_builder = Event::new("test").add_attributes(vec![("foo", "bar"), ("bar", "baz")]); - - assert_eq!(event_direct, event_builder); - } - - #[test] - #[should_panic] - fn attribute_new_reserved_key_panicks() { - Attribute::new("_invalid", "value"); - } - - #[test] - #[should_panic] - fn attribute_new_reserved_key_panicks2() { - Attribute::new("_", "value"); - } - - #[test] - fn attr_works_for_different_types() { - let expected = ("foo", "42"); - - assert_eq!(attr("foo", "42"), expected); - assert_eq!(attr("foo", "42"), expected); - assert_eq!(attr("foo", "42"), expected); - assert_eq!(attr("foo", Uint128::new(42)), expected); - } -} diff --git a/packages/std/src/results/mod.rs b/packages/std/src/results/mod.rs index ba4a7edf3..db151d36a 100644 --- a/packages/std/src/results/mod.rs +++ b/packages/std/src/results/mod.rs @@ -1,23 +1,33 @@ //! This module contains the messages that are sent from the contract to the VM as an execution result +mod attribute; +mod context; mod contract_result; mod cosmos_msg; mod empty; -mod events; mod query; mod response; -mod submessages; +mod subcall; mod system_result; +pub use attribute::{attr, Attribute}; +#[allow(deprecated)] +pub use context::Context; pub use contract_result::ContractResult; pub use cosmos_msg::{wasm_execute, wasm_instantiate, BankMsg, CosmosMsg, WasmMsg}; #[cfg(feature = "staking")] pub use cosmos_msg::{DistributionMsg, StakingMsg}; -#[cfg(feature = "stargate")] -pub use cosmos_msg::{GovMsg, VoteOption}; pub use empty::Empty; -pub use events::{attr, Attribute, Event}; pub use query::QueryResponse; pub use response::Response; -pub use submessages::{Reply, ReplyOn, SubMsg, SubMsgExecutionResponse}; +pub use subcall::{Event, Reply, ReplyOn, SubMsg, SubcallResponse}; pub use system_result::SystemResult; + +#[deprecated(since = "0.14.0-0.4.0", note = "Renamed to Response.")] +pub type InitResponse = Response; + +#[deprecated(since = "0.14.0-0.4.0", note = "Renamed to Response.")] +pub type HandleResponse = Response; + +#[deprecated(since = "0.14.0-0.4.0", note = "Renamed to Response.")] +pub type MigrateResponse = Response; diff --git a/packages/std/src/results/response.rs b/packages/std/src/results/response.rs index b6f7453a7..85adfa418 100644 --- a/packages/std/src/results/response.rs +++ b/packages/std/src/results/response.rs @@ -2,9 +2,10 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt; -use crate::Binary; +use crate::{Binary, ReplyOn}; -use super::{Attribute, CosmosMsg, Empty, Event, SubMsg}; +use super::{Attribute, CosmosMsg, Empty}; +use crate::results::SubMsg; /// A response of a contract entry point, such as `instantiate`, `execute` or `migrate`. /// @@ -30,14 +31,19 @@ use super::{Attribute, CosmosMsg, Empty, Event, SubMsg}; /// ) -> StdResult { /// // ... /// -/// Ok(Response::new().add_attribute("action", "instantiate")) +/// Ok(Response { +/// submessages: vec![], +/// messages: vec![], +/// attributes: vec![attr("action", "instantiate")], +/// data: None, +/// }) /// } /// ``` /// /// Mutating: /// /// ``` -/// # use cosmwasm_std::{coins, BankMsg, Binary, DepsMut, Env, MessageInfo, SubMsg}; +/// # use cosmwasm_std::{coins, BankMsg, Binary, DepsMut, Env, MessageInfo}; /// # type InstantiateMsg = (); /// # type MyError = (); /// # @@ -49,43 +55,35 @@ use super::{Attribute, CosmosMsg, Empty, Event, SubMsg}; /// info: MessageInfo, /// msg: InstantiateMsg, /// ) -> Result { -/// let mut response = Response::new() -/// .add_attribute("Let the", "hacking begin") -/// .add_message(BankMsg::Send { -/// to_address: String::from("recipient"), -/// amount: coins(128, "uint"), -/// }) -/// .add_attribute("foo", "bar") -/// .set_data(b"the result data"); +/// let mut response = Response::new(); +/// // ... +/// response.add_attribute("Let the", "hacking begin"); +/// // ... +/// response.add_message(BankMsg::Send { +/// to_address: String::from("recipient"), +/// amount: coins(128, "uint"), +/// }); +/// response.add_attribute("foo", "bar"); +/// // ... +/// response.set_data(Binary::from(b"the result data")); /// Ok(response) /// } /// ``` #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[non_exhaustive] pub struct Response where T: Clone + fmt::Debug + PartialEq + JsonSchema, { - /// Optional list of messages to pass. These will be executed in order. - /// If the ReplyOn variant matches the result (Always, Success on Ok, Error on Err), - /// the runtime will invoke this contract's `reply` entry point - /// after execution. Otherwise, they act like "fire and forget". - /// Use `SubMsg::new` to create messages with the older "fire and forget" semantics. - pub messages: Vec>, - /// The attributes that will be emitted as part of a "wasm" event. - /// - /// More info about events (and their attributes) can be found in [*Cosmos SDK* docs]. - /// - /// [*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html + /// Optional list of "subcalls" to make. These will be executed in order + /// (and this contract's subcall_response entry point invoked) + /// *before* any of the "fire and forget" messages get executed. + pub submessages: Vec>, + /// After any submessages are processed, these are all dispatched in the host blockchain. + /// If they all succeed, then the transaction is committed. If any fail, then the transaction + /// and any local contract state changes are reverted. + pub messages: Vec>, + /// The attributes that will be emitted as part of a "wasm" event pub attributes: Vec, - /// Extra, custom events separate from the main `wasm` one. These will have - /// `wasm-` prepended to the type. - /// - /// More info about events can be found in [*Cosmos SDK* docs]. - /// - /// [*Cosmos SDK* docs]: https://docs.cosmos.network/v0.42/core/events.html - pub events: Vec, - /// The binary payload to include in the response. pub data: Option, } @@ -95,9 +93,9 @@ where { fn default() -> Self { Response { + submessages: vec![], messages: vec![], attributes: vec![], - events: vec![], data: None, } } @@ -111,116 +109,35 @@ where Self::default() } - /// Add an attribute included in the main `wasm` event. - #[must_use] - pub fn add_attribute(mut self, key: impl Into, value: impl Into) -> Self { - self.attributes.push(Attribute::new(key, value)); - self - } - - /// This creates a "fire and forget" message, by using `SubMsg::new()` to wrap it, - /// and adds it to the list of messages to process. - #[must_use] - pub fn add_message(mut self, msg: impl Into>) -> Self { - self.messages.push(SubMsg::new(msg)); - self - } - - /// This takes an explicit SubMsg (creates via eg. `reply_on_error`) - /// and adds it to the list of messages to process. - #[must_use] - pub fn add_submessage(mut self, msg: SubMsg) -> Self { - self.messages.push(msg); - self + pub fn add_attribute, V: Into>(&mut self, key: K, value: V) { + self.attributes.push(Attribute { + key: key.into(), + value: value.into(), + }); } - /// Adds an extra event to the response, separate from the main `wasm` event - /// that is always created. - /// - /// The `wasm-` prefix will be appended by the runtime to the provided type - /// of event. - #[must_use] - pub fn add_event(mut self, event: Event) -> Self { - self.events.push(event); - self + pub fn add_message>>(&mut self, msg: U) { + self.messages.push(msg.into()); } - /// Bulk add attributes included in the main `wasm` event. - /// - /// Anything that can be turned into an iterator and yields something - /// that can be converted into an `Attribute` is accepted. - /// - /// ## Examples - /// - /// ``` - /// use cosmwasm_std::{attr, Response}; - /// - /// let attrs = vec![ - /// ("action", "reaction"), - /// ("answer", "42"), - /// ("another", "attribute"), - /// ]; - /// let res: Response = Response::new().add_attributes(attrs.clone()); - /// assert_eq!(res.attributes, attrs); - /// ``` - #[must_use] - pub fn add_attributes>( - mut self, - attrs: impl IntoIterator, - ) -> Self { - self.attributes.extend(attrs.into_iter().map(A::into)); - self - } - - /// Bulk add "fire and forget" messages to the list of messages to process. - /// - /// ## Examples - /// - /// ``` - /// use cosmwasm_std::{CosmosMsg, Response}; - /// - /// fn make_response_with_msgs(msgs: Vec) -> Response { - /// Response::new().add_messages(msgs) - /// } - /// ``` - #[must_use] - pub fn add_messages>>(self, msgs: impl IntoIterator) -> Self { - self.add_submessages(msgs.into_iter().map(SubMsg::new)) - } - - /// Bulk add explicit SubMsg structs to the list of messages to process. - /// - /// ## Examples - /// - /// ``` - /// use cosmwasm_std::{SubMsg, Response}; - /// - /// fn make_response_with_submsgs(msgs: Vec) -> Response { - /// Response::new().add_submessages(msgs) - /// } - /// ``` - #[must_use] - pub fn add_submessages(mut self, msgs: impl IntoIterator>) -> Self { - self.messages.extend(msgs.into_iter()); - self - } - - /// Bulk add custom events to the response. These are separate from the main - /// `wasm` event. - /// - /// The `wasm-` prefix will be appended by the runtime to the provided types - /// of events. - #[must_use] - pub fn add_events(mut self, events: impl IntoIterator) -> Self { - self.events.extend(events.into_iter()); - self + pub fn add_submessage>>( + &mut self, + id: u64, + msg: U, + gas_limit: Option, + reply_on: ReplyOn, + ) { + let sub = SubMsg { + id, + msg: msg.into(), + gas_limit, + reply_on, + }; + self.submessages.push(sub); } - /// Set the binary data included in the response. - #[must_use] - pub fn set_data(mut self, data: impl Into) -> Self { + pub fn set_data>(&mut self, data: U) { self.data = Some(data.into()); - self } } @@ -228,39 +145,30 @@ where mod tests { use super::super::BankMsg; use super::*; - use crate::results::submessages::{ReplyOn, UNUSED_MSG_ID}; use crate::{coins, from_slice, to_vec}; #[test] fn can_serialize_and_deserialize_init_response() { let original = Response { - messages: vec![ - SubMsg { - id: 12, - msg: BankMsg::Send { - to_address: String::from("checker"), - amount: coins(888, "moon"), - } - .into(), - gas_limit: Some(12345u64), - reply_on: ReplyOn::Always, - }, - SubMsg { - id: UNUSED_MSG_ID, - msg: BankMsg::Send { - to_address: String::from("you"), - amount: coins(1015, "earth"), - } - .into(), - gas_limit: None, - reply_on: ReplyOn::Never, - }, - ], + submessages: vec![SubMsg { + id: 12, + msg: BankMsg::Send { + to_address: String::from("checker"), + amount: coins(888, "moon"), + } + .into(), + gas_limit: Some(12345u64), + reply_on: ReplyOn::Always, + }], + messages: vec![BankMsg::Send { + to_address: String::from("you"), + amount: coins(1015, "earth"), + } + .into()], attributes: vec![Attribute { key: "action".to_string(), value: "release".to_string(), }], - events: vec![], data: Some(Binary::from([0xAA, 0xBB])), }; let serialized = to_vec(&original).expect("encode contract result"); diff --git a/packages/std/src/results/subcall.rs b/packages/std/src/results/subcall.rs new file mode 100644 index 000000000..8447dc0e4 --- /dev/null +++ b/packages/std/src/results/subcall.rs @@ -0,0 +1,74 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use std::fmt; + +use crate::{Binary, ContractResult}; + +use super::{Attribute, CosmosMsg, Empty}; + +/// Use this to define when the contract gets a response callback. +/// If you only need it for errors or success you can select just those in order +/// to save gas. +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum ReplyOn { + /// Always perform a callback after SubMsg is processed + Always, + /// Only callback if SubMsg returned an error, no callback on success case + Error, + /// Only callback if SubMsg was successful, no callback on error case + Success, +} + +impl Default for ReplyOn { + fn default() -> Self { + ReplyOn::Always + } +} + +/// A sub-message that will guarantee a subcall_response callback on success or error +/// Note on error the subcall will revert any partial state changes due to this message, +/// but not revert any state changes in the calling contract (that must be done in the +/// subcall_response entry point) +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct SubMsg +where + T: Clone + fmt::Debug + PartialEq + JsonSchema, +{ + pub id: u64, + pub msg: CosmosMsg, + pub gas_limit: Option, + pub reply_on: ReplyOn, +} + +/// The Result object returned to subcall_response. We always get the same id back +/// and then must handle success and error cases ourselves +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Reply { + pub id: u64, + pub result: ContractResult, +} + +/// The information we get back from a successful sub-call, with full sdk events +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct SubcallResponse { + pub events: Vec, + pub data: Option, +} + +/// a full sdk event +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Event { + #[serde(rename = "type")] + pub kind: String, + pub attributes: Vec, +} + +impl Event { + pub fn new(kind: &str, attributes: Vec) -> Self { + Event { + kind: kind.to_string(), + attributes, + } + } +} diff --git a/packages/std/src/results/submessages.rs b/packages/std/src/results/submessages.rs deleted file mode 100644 index 8ee25d452..000000000 --- a/packages/std/src/results/submessages.rs +++ /dev/null @@ -1,119 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use std::fmt; - -use crate::{Binary, ContractResult}; - -use super::{CosmosMsg, Empty, Event}; - -/// Use this to define when the contract gets a response callback. -/// If you only need it for errors or success you can select just those in order -/// to save gas. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ReplyOn { - /// Always perform a callback after SubMsg is processed - Always, - /// Only callback if SubMsg returned an error, no callback on success case - Error, - /// Only callback if SubMsg was successful, no callback on error case - Success, - /// Never make a callback - this is like the original CosmosMsg semantics - Never, -} - -/// A submessage that will guarantee a `reply` call on success or error, depending on -/// the `reply_on` setting. If you do not need to process the result, use regular messages instead. -/// -/// Note: On error the submessage execution will revert any partial state changes due to this message, -/// but not revert any state changes in the calling contract. If this is required, it must be done -/// manually in the `reply` entry point. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct SubMsg -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - /// An arbitrary ID chosen by the contract. - /// This is typically used to match `Reply`s in the `reply` entry point to the submessage. - pub id: u64, - pub msg: CosmosMsg, - pub gas_limit: Option, - pub reply_on: ReplyOn, -} - -/// This is used for cases when we use ReplyOn::Never and the id doesn't matter -pub const UNUSED_MSG_ID: u64 = 0; - -impl SubMsg -where - T: Clone + fmt::Debug + PartialEq + JsonSchema, -{ - /// new creates a "fire and forget" message with the pre-0.14 semantics - pub fn new(msg: impl Into>) -> Self { - SubMsg { - id: UNUSED_MSG_ID, - msg: msg.into(), - reply_on: ReplyOn::Never, - gas_limit: None, - } - } - - /// create a `SubMsg` that will provide a `reply` with the given id if the message returns `Ok` - pub fn reply_on_success(msg: impl Into>, id: u64) -> Self { - Self::reply_on(msg.into(), id, ReplyOn::Success) - } - - /// create a `SubMsg` that will provide a `reply` with the given id if the message returns `Err` - pub fn reply_on_error(msg: impl Into>, id: u64) -> Self { - Self::reply_on(msg.into(), id, ReplyOn::Error) - } - - /// create a `SubMsg` that will always provide a `reply` with the given id - pub fn reply_always(msg: impl Into>, id: u64) -> Self { - Self::reply_on(msg.into(), id, ReplyOn::Always) - } - - /// Add a gas limit to the message. - /// - /// ## Examples - /// - /// ``` - /// # use cosmwasm_std::{coins, BankMsg, ReplyOn, SubMsg}; - /// # let msg = BankMsg::Send { to_address: String::from("you"), amount: coins(1015, "earth") }; - /// let sub_msg: SubMsg = SubMsg::reply_always(msg, 1234).with_gas_limit(60_000); - /// assert_eq!(sub_msg.id, 1234); - /// assert_eq!(sub_msg.gas_limit, Some(60_000)); - /// assert_eq!(sub_msg.reply_on, ReplyOn::Always); - /// ``` - #[must_use] - pub fn with_gas_limit(mut self, limit: u64) -> Self { - self.gas_limit = Some(limit); - self - } - - fn reply_on(msg: CosmosMsg, id: u64, reply_on: ReplyOn) -> Self { - SubMsg { - id, - msg, - reply_on, - gas_limit: None, - } - } -} - -/// The result object returned to `reply`. We always get the ID from the submessage -/// back and then must handle success and error cases ourselves. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct Reply { - /// The ID that the contract set when emitting the `SubMsg`. - /// Use this to identify which submessage triggered the `reply`. - pub id: u64, - pub result: ContractResult, -} - -/// The information we get back from a successful sub-call, with full sdk events -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct SubMsgExecutionResponse { - pub events: Vec, - pub data: Option, -} diff --git a/packages/std/src/timestamp.rs b/packages/std/src/timestamp.rs index 12d504aea..643df0cff 100644 --- a/packages/std/src/timestamp.rs +++ b/packages/std/src/timestamp.rs @@ -7,21 +7,6 @@ use crate::math::Uint64; /// A point in time in nanosecond precision. /// /// This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. -/// -/// ## Examples -/// -/// ``` -/// # use cosmwasm_std::Timestamp; -/// let ts = Timestamp::from_nanos(1_000_000_202); -/// assert_eq!(ts.nanos(), 1_000_000_202); -/// assert_eq!(ts.seconds(), 1); -/// assert_eq!(ts.subsec_nanos(), 202); -/// -/// let ts = ts.plus_seconds(2); -/// assert_eq!(ts.nanos(), 3_000_000_202); -/// assert_eq!(ts.seconds(), 3); -/// assert_eq!(ts.subsec_nanos(), 202); -/// ``` #[derive( Serialize, Deserialize, Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema, )] @@ -29,63 +14,35 @@ pub struct Timestamp(Uint64); impl Timestamp { /// Creates a timestamp from nanoseconds since epoch - #[must_use] pub const fn from_nanos(nanos_since_epoch: u64) -> Self { Timestamp(Uint64::new(nanos_since_epoch)) } /// Creates a timestamp from seconds since epoch - #[must_use] pub const fn from_seconds(seconds_since_epoch: u64) -> Self { Timestamp(Uint64::new(seconds_since_epoch * 1_000_000_000)) } - #[must_use] pub const fn plus_seconds(&self, addition: u64) -> Timestamp { - self.plus_nanos(addition * 1_000_000_000) + let nanos = Uint64::new(self.0.u64() + addition * 1_000_000_000); + Timestamp(nanos) } - #[must_use] pub const fn plus_nanos(&self, addition: u64) -> Timestamp { let nanos = Uint64::new(self.0.u64() + addition); Timestamp(nanos) } - #[must_use] - pub const fn minus_seconds(&self, subtrahend: u64) -> Timestamp { - self.minus_nanos(subtrahend * 1_000_000_000) - } - - #[must_use] - pub const fn minus_nanos(&self, subtrahend: u64) -> Timestamp { - let nanos = Uint64::new(self.0.u64() - subtrahend); - Timestamp(nanos) - } - /// Returns nanoseconds since epoch - #[inline] pub fn nanos(&self) -> u64 { self.0.u64() } - - /// Returns seconds since epoch (truncate nanoseconds) - #[inline] - pub fn seconds(&self) -> u64 { - self.0.u64() / 1_000_000_000 - } - - /// Returns nanoseconds since the last whole second (the remainder truncated - /// by `seconds()`) - #[inline] - pub fn subsec_nanos(&self) -> u64 { - self.0.u64() % 1_000_000_000 - } } impl fmt::Display for Timestamp { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let whole = self.seconds(); - let fractional = self.subsec_nanos(); + let whole = self.nanos() / 1_000_000_000; + let fractional = self.nanos() % 1_000_000_000; write!(f, "{}.{:09}", whole, fractional) } } @@ -126,62 +83,12 @@ mod tests { assert_eq!(sum.0.u64(), 123); } - #[test] - fn timestamp_minus_seconds() { - let earlier = Timestamp::from_seconds(123).minus_seconds(0); - assert_eq!(earlier.0.u64(), 123_000_000_000); - let earlier = Timestamp::from_seconds(123).minus_seconds(3); - assert_eq!(earlier.0.u64(), 120_000_000_000); - let earlier = Timestamp::from_seconds(123).minus_seconds(123); - assert_eq!(earlier.0.u64(), 0); - } - - #[test] - #[should_panic(expected = "attempt to subtract with overflow")] - fn timestamp_minus_seconds_panics_on_overflow() { - let _earlier = Timestamp::from_seconds(100).minus_seconds(101); - } - - #[test] - fn timestamp_minus_nanos() { - let earlier = Timestamp::from_seconds(123).minus_nanos(0); - assert_eq!(earlier.0.u64(), 123_000_000_000); - let earlier = Timestamp::from_seconds(123).minus_nanos(3); - assert_eq!(earlier.0.u64(), 122_999_999_997); - let earlier = Timestamp::from_seconds(123).minus_nanos(123_000_000_000); - assert_eq!(earlier.0.u64(), 0); - } - - #[test] - #[should_panic(expected = "attempt to subtract with overflow")] - fn timestamp_minus_nanos_panics_on_overflow() { - let _earlier = Timestamp::from_nanos(100).minus_nanos(101); - } - #[test] fn timestamp_nanos() { let sum = Timestamp::from_nanos(123); assert_eq!(sum.nanos(), 123); let sum = Timestamp::from_nanos(0); assert_eq!(sum.nanos(), 0); - let sum = Timestamp::from_nanos(987654321000); - assert_eq!(sum.nanos(), 987654321000); - } - - #[test] - fn timestamp_seconds() { - let sum = Timestamp::from_nanos(987654321000); - assert_eq!(sum.seconds(), 987); - let sum = Timestamp::from_seconds(1234567).plus_nanos(8765436); - assert_eq!(sum.seconds(), 1234567); - } - - #[test] - fn timestamp_subsec_nanos() { - let sum = Timestamp::from_nanos(987654321000); - assert_eq!(sum.subsec_nanos(), 654321000); - let sum = Timestamp::from_seconds(1234567).plus_nanos(8765436); - assert_eq!(sum.subsec_nanos(), 8765436); } #[test] diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index bb2cd1f21..02647d5ec 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -86,9 +86,7 @@ pub trait Api { fn addr_canonicalize(&self, human: &str) -> StdResult; /// Takes a canonical address and returns a human readble address. - /// This is the inverse of [`addr_canonicalize`]. - /// - /// [`addr_canonicalize`]: Api::addr_canonicalize + /// This is the inverse of [addr_canonicalize]. fn addr_humanize(&self, canonical: &CanonicalAddr) -> StdResult; fn secp256k1_verify( @@ -188,10 +186,10 @@ impl<'a> QuerierWrapper<'a> { } } - pub fn query_balance( + pub fn query_balance, V: Into>( &self, - address: impl Into, - denom: impl Into, + address: U, + denom: V, ) -> StdResult { let request = BankQuery::Balance { address: address.into(), @@ -202,7 +200,7 @@ impl<'a> QuerierWrapper<'a> { Ok(res.amount) } - pub fn query_all_balances(&self, address: impl Into) -> StdResult> { + pub fn query_all_balances>(&self, address: U) -> StdResult> { let request = BankQuery::AllBalances { address: address.into(), } @@ -213,10 +211,10 @@ impl<'a> QuerierWrapper<'a> { // this queries another wasm contract. You should know a priori the proper types for T and U // (response and request) based on the contract API - pub fn query_wasm_smart( + pub fn query_wasm_smart>( &self, - contract_addr: impl Into, - msg: &impl Serialize, + contract_addr: V, + msg: &U, ) -> StdResult { let request = WasmQuery::Smart { contract_addr: contract_addr.into(), @@ -233,10 +231,10 @@ impl<'a> QuerierWrapper<'a> { // // Similar return value to Storage.get(). Returns Some(val) or None if the data is there. // It only returns error on some runtime issue, not on any data cases. - pub fn query_wasm_raw( + pub fn query_wasm_raw, U: Into>( &self, - contract_addr: impl Into, - key: impl Into, + contract_addr: T, + key: U, ) -> StdResult>> { let request: QueryRequest = WasmQuery::Raw { contract_addr: contract_addr.into(), @@ -274,7 +272,7 @@ impl<'a> QuerierWrapper<'a> { } #[cfg(feature = "staking")] - pub fn query_validator(&self, address: impl Into) -> StdResult> { + pub fn query_validator>(&self, address: U) -> StdResult> { let request = StakingQuery::Validator { address: address.into(), } @@ -291,9 +289,9 @@ impl<'a> QuerierWrapper<'a> { } #[cfg(feature = "staking")] - pub fn query_all_delegations( + pub fn query_all_delegations>( &self, - delegator: impl Into, + delegator: U, ) -> StdResult> { let request = StakingQuery::AllDelegations { delegator: delegator.into(), @@ -304,10 +302,10 @@ impl<'a> QuerierWrapper<'a> { } #[cfg(feature = "staking")] - pub fn query_delegation( + pub fn query_delegation, V: Into>( &self, - delegator: impl Into, - validator: impl Into, + delegator: U, + validator: V, ) -> StdResult> { let request = StakingQuery::Delegation { delegator: delegator.into(), @@ -360,6 +358,6 @@ mod tests { .unwrap() .unwrap(); let balance: BalanceResponse = from_slice(&raw).unwrap(); - assert_eq!(balance.amount.amount, Uint128::new(5)); + assert_eq!(balance.amount.amount, Uint128(5)); } } diff --git a/packages/std/src/types.rs b/packages/std/src/types.rs index 700a38a8a..e1aa0fa65 100644 --- a/packages/std/src/types.rs +++ b/packages/std/src/types.rs @@ -12,7 +12,6 @@ pub struct Env { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct BlockInfo { - /// The height of a block is the number of blocks preceding it in the blockchain. pub height: u64, /// Absolute time of the block creation in seconds since the UNIX epoch (00:00:00 on 1970-01-01 UTC). /// @@ -37,8 +36,8 @@ pub struct BlockInfo { /// # }; /// # extern crate chrono; /// use chrono::NaiveDateTime; - /// let seconds = env.block.time.seconds(); - /// let nsecs = env.block.time.subsec_nanos(); + /// let seconds = env.block.time.nanos() / 1_000_000_000; + /// let nsecs = env.block.time.nanos() % 1_000_000_000; /// let dt = NaiveDateTime::from_timestamp(seconds as i64, nsecs as u32); /// ``` /// diff --git a/packages/storage/Cargo.toml b/packages/storage/Cargo.toml index 566f05888..526568558 100644 --- a/packages/storage/Cargo.toml +++ b/packages/storage/Cargo.toml @@ -10,11 +10,10 @@ license = "Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["iterator"] # This enables iterator functionality, as exposed in cosmwasm-std/iterator iterator = ["cosmwasm-std/iterator"] [dependencies] # Uses the path when built locally; uses the given version from crates.io when published -cosmwasm-std = { path = "../std", version = "0.14.0-0.4.0", default-features = false } +cosmwasm-std = { path = "../std", version = "0.14.0-0.4.0" } serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } diff --git a/packages/storage/src/prefixed_storage.rs b/packages/storage/src/prefixed_storage.rs index 53e30b204..a9094c76d 100644 --- a/packages/storage/src/prefixed_storage.rs +++ b/packages/storage/src/prefixed_storage.rs @@ -41,25 +41,23 @@ impl<'a> PrefixedStorage<'a> { prefix: to_length_prefixed_nested(namespaces), } } -} -impl<'a> Storage for PrefixedStorage<'a> { - fn get(&self, key: &[u8]) -> Option> { + pub fn get(&self, key: &[u8]) -> Option> { get_with_prefix(self.storage, &self.prefix, key) } - fn set(&mut self, key: &[u8], value: &[u8]) { + pub fn set(&mut self, key: &[u8], value: &[u8]) { set_with_prefix(self.storage, &self.prefix, key, value); } - fn remove(&mut self, key: &[u8]) { + pub fn remove(&mut self, key: &[u8]) { remove_with_prefix(self.storage, &self.prefix, key); } #[cfg(feature = "iterator")] /// range allows iteration over a set of keys, either forwards or backwards /// uses standard rust range notation, and eg db.range(b"foo"..b"bar") also works reverse - fn range<'b>( + pub fn range<'b>( &'b self, start: Option<&[u8]>, end: Option<&[u8]>, @@ -90,24 +88,14 @@ impl<'a> ReadonlyPrefixedStorage<'a> { prefix: to_length_prefixed_nested(namespaces), } } -} -impl<'a> Storage for ReadonlyPrefixedStorage<'a> { - fn get(&self, key: &[u8]) -> Option> { + pub fn get(&self, key: &[u8]) -> Option> { get_with_prefix(self.storage, &self.prefix, key) } - fn set(&mut self, _key: &[u8], _value: &[u8]) { - unimplemented!(); - } - - fn remove(&mut self, _key: &[u8]) { - unimplemented!(); - } - #[cfg(feature = "iterator")] /// range allows iteration over a set of keys, either forwards or backwards - fn range<'b>( + pub fn range<'b>( &'b self, start: Option<&[u8]>, end: Option<&[u8]>, diff --git a/packages/storage/src/sequence.rs b/packages/storage/src/sequence.rs index 30f9491cb..6d81de2b7 100644 --- a/packages/storage/src/sequence.rs +++ b/packages/storage/src/sequence.rs @@ -16,7 +16,7 @@ pub fn currval(seq: &Singleton) -> StdResult { /// nextval increments the counter by 1 and returns the new value. /// On the first time it is called (no sequence info in db) it will return 1. pub fn nextval(seq: &mut Singleton) -> StdResult { - let val = currval(seq)? + 1; + let val = currval(&seq)? + 1; seq.save(&val)?; Ok(val) } diff --git a/packages/storage/src/type_helpers.rs b/packages/storage/src/type_helpers.rs index a32bc3776..2bcdb0b1d 100644 --- a/packages/storage/src/type_helpers.rs +++ b/packages/storage/src/type_helpers.rs @@ -13,7 +13,7 @@ pub(crate) fn may_deserialize( value: &Option>, ) -> StdResult> { match value { - Some(data) => Ok(Some(from_slice(data)?)), + Some(vec) => Ok(Some(from_slice(&vec)?)), None => Ok(None), } } @@ -21,7 +21,7 @@ pub(crate) fn may_deserialize( /// must_deserialize parses json bytes from storage (Option), returning NotFound error if no data present pub(crate) fn must_deserialize(value: &Option>) -> StdResult { match value { - Some(data) => from_slice(data), + Some(vec) => from_slice(&vec), None => Err(StdError::not_found(type_name::())), } } diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index e2bceae4b..c14653404 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/line/cosmwasm/tree/main/packages/vm" license = "Apache-2.0" [features] -default = ["staking", "iterator"] +default = ["staking"] # backtraces provides much better context at runtime errors (in non-wasm code) # at the cost of a bit of code size and performance. # This feature requires Rust nightly because it depends on the unstable backtrace feature. @@ -36,7 +36,7 @@ required-features = ["iterator"] [dependencies] clru = "0.4.0" # Uses the path when built locally; uses the given version from crates.io when published -cosmwasm-std = { path = "../std", version = "0.14.0-0.4.0", default-features = false } +cosmwasm-std = { path = "../std", version = "0.14.0-0.4.0" } cosmwasm-crypto = { path = "../crypto", version = "0.14.0-0.4.0" } hex = "0.4" parity-wasm = "0.42" @@ -45,9 +45,8 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { version = "2.0.0", default-features = false, features = ["cranelift", "universal", "singlepass"] } -wasmer-middlewares = "2.0.0" -loupe = "0.1.3" +wasmer = { version = "1.0.2", default-features = false, features = ["jit", "singlepass"] } +wasmer-middlewares = { version = "1.0.2" } # Wasmer git/local (used for quick local debugging or patching) # wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.2", default-features = false, features = ["jit", "singlepass"] } diff --git a/packages/vm/README.md b/packages/vm/README.md index 53975d00a..805f77955 100644 --- a/packages/vm/README.md +++ b/packages/vm/README.md @@ -16,9 +16,6 @@ compatibility list: | cosmwasm-vm | Supported interface versions | cosmwasm-std | | ----------- | ---------------------------- | ------------ | -| 1.0 | TBD | 1.0 | -| 0.16 | `interface_version_7` | 0.16 | -| 0.15 | `interface_version_6` | 0.15 | | 0.14 | `interface_version_5` | 0.14 | | 0.13 | `cosmwasm_vm_version_4` | 0.11-0.13 | | 0.12 | `cosmwasm_vm_version_4` | 0.11-0.13 | @@ -27,17 +24,6 @@ compatibility list: | 0.9 | `cosmwasm_vm_version_2` | 0.9 | | 0.8 | `cosmwasm_vm_version_1` | 0.8 | -### Changes between interface versions - -**interface_version_5 -> interface_version_6** - -- Rename the fields from `send` to `funds` in `WasmMsg::Instantiate` and - `WasmMsg::Execute`. -- Merge messages and sub-messages. -- Change JSON representation of IBC acknowledgements ([CosmWasm/cosmwasm#975]). - -[CosmWasm/cosmwasm#975]: https://github.com/CosmWasm/cosmwasm/pull/975 - ## Setup There are demo files in `testdata/*.wasm`. Those are compiled and optimized @@ -53,20 +39,14 @@ To rebuild the test contracts, go to the repo root and do docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_hackatom",target=/code/contracts/hackatom/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/hackatom \ - && cp artifacts/hackatom.wasm packages/vm/testdata/hackatom_0.16.wasm + cosmwasm/rust-optimizer:0.11.0 ./contracts/hackatom \ + && cp artifacts/hackatom.wasm packages/vm/testdata/hackatom_0.14.wasm docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_ibc_reflect",target=/code/contracts/ibc-reflect/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/ibc-reflect \ - && cp artifacts/ibc_reflect.wasm packages/vm/testdata/ibc_reflect_0.16.wasm - -docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_floaty",target=/code/contracts/floaty/target \ - --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.1 ./contracts/floaty \ - && cp artifacts/floaty.wasm packages/vm/testdata/floaty.wasm + cosmwasm/rust-optimizer:0.11.0 ./contracts/ibc-reflect \ + && cp artifacts/ibc_reflect.wasm packages/vm/testdata/ibc_reflect_0.14.wasm ``` ## Testing diff --git a/packages/vm/examples/module_size.rs b/packages/vm/examples/module_size.rs index 1cbbe0c6c..8f489f993 100644 --- a/packages/vm/examples/module_size.rs +++ b/packages/vm/examples/module_size.rs @@ -11,7 +11,7 @@ use wasmer::Module; pub fn main() { let matches = App::new("Module size estimation") - .version("0.0.3") + .version("0.0.2") .author("Mauro Lacy ") .arg( Arg::with_name("WASM") @@ -41,10 +41,6 @@ pub fn main() { let module = module_compile(&wasm, memory_limit); mem::drop(wasm); - // Report loupe size - let loupe_size = loupe::size_of_val(&module); - println!("module size (loupe): {} bytes", loupe_size); - let serialized = module.serialize().unwrap(); mem::drop(module); @@ -57,10 +53,6 @@ pub fn main() { mem::drop(module); let ser_size = serialized.len(); println!("module size (serialized): {} bytes", ser_size); - println!( - "(loupe) module size ratio: {:.2}", - loupe_size as f32 / wasm_size as f32 - ); println!( "(serialized) module size ratio: {:.2}", ser_size as f32 / wasm_size as f32 @@ -69,7 +61,7 @@ pub fn main() { #[inline(never)] fn module_compile(wasm: &[u8], memory_limit: Option) -> Module { - compile(wasm, memory_limit).unwrap() + compile(&wasm, memory_limit).unwrap() } #[inline(never)] diff --git a/packages/vm/examples/module_size.sh b/packages/vm/examples/module_size.sh index 80ed757a4..55f352858 100755 --- a/packages/vm/examples/module_size.sh +++ b/packages/vm/examples/module_size.sh @@ -1,8 +1,5 @@ #!/bin/bash # Uses valgrind's massif tool to compute heap memory consumption of compiled modules. -# For a wasmer `Modulej , it has been determined that this method underestimates the size -# of the module significanty. -# Use loupe::size_of_val instead, to get a better estimation. set -e MAX_SNAPSHOTS=1000 diff --git a/packages/vm/src/backend.rs b/packages/vm/src/backend.rs index 238ac5f4f..11771bc36 100644 --- a/packages/vm/src/backend.rs +++ b/packages/vm/src/backend.rs @@ -187,7 +187,7 @@ impl BackendError { BackendError::OutOfGas {} } - pub fn unknown(msg: impl ToString) -> Self { + pub fn unknown(msg: S) -> Self { BackendError::Unknown { msg: Some(msg.to_string()), } @@ -198,7 +198,7 @@ impl BackendError { BackendError::Unknown { msg: None } } - pub fn user_err(msg: impl ToString) -> Self { + pub fn user_err(msg: S) -> Self { BackendError::UserErr { msg: msg.to_string(), } diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 775cd574a..279d18c91 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -9,19 +9,13 @@ use crate::backend::{Backend, BackendApi, Querier, Storage}; use crate::checksum::Checksum; use crate::compatibility::check_wasm; use crate::errors::{VmError, VmResult}; -use crate::features::required_features_from_module; use crate::instance::{Instance, InstanceOptions}; use crate::modules::{FileSystemCache, InMemoryCache, PinnedMemoryCache}; use crate::size::Size; use crate::static_analysis::{deserialize_wasm, has_ibc_entry_points}; use crate::wasm_backend::{compile, make_runtime_store}; -const STATE_DIR: &str = "state"; -// Things related to the state of the blockchain. const WASM_DIR: &str = "wasm"; - -const CACHE_DIR: &str = "cache"; -// Cacheable things. const MODULES_DIR: &str = "modules"; #[derive(Debug, Default, Clone, Copy)] @@ -73,10 +67,8 @@ pub struct Cache { type_querier: PhantomData, } -#[derive(PartialEq, Debug)] pub struct AnalysisReport { pub has_ibc_entry_points: bool, - pub required_features: HashSet, } impl Cache @@ -99,24 +91,11 @@ where memory_cache_size, instance_memory_limit, } = options; + let wasm_path = base_dir.join(WASM_DIR); + create_dir_all(&wasm_path) + .map_err(|e| VmError::cache_err(format!("Error creating Wasm dir for cache: {}", e)))?; - let state_path = base_dir.join(STATE_DIR); - let cache_path = base_dir.join(CACHE_DIR); - - let wasm_path = state_path.join(WASM_DIR); - - // Ensure all the needed directories exist on disk. - for path in [&state_path, &cache_path, &wasm_path].iter() { - create_dir_all(path).map_err(|e| { - VmError::cache_err(format!( - "Error creating directory {}: {}", - path.display(), - e - )) - })?; - } - - let fs_cache = FileSystemCache::new(cache_path.join(MODULES_DIR)) + let fs_cache = FileSystemCache::new(base_dir.join(MODULES_DIR)) .map_err(|e| VmError::cache_err(format!("Error file system cache: {}", e)))?; Ok(Cache { supported_features, @@ -188,7 +167,6 @@ where let module = deserialize_wasm(&wasm)?; Ok(AnalysisReport { has_ibc_entry_points: has_ibc_entry_points(&module), - required_features: required_features_from_module(&module), }) } @@ -214,9 +192,8 @@ where // Try to get module from file system cache let store = make_runtime_store(Some(cache.instance_memory_limit)); - if let Some(module) = cache.fs_cache.load(checksum, &store)? { + if let Some((module, module_size)) = cache.fs_cache.load(checksum, &store)? { cache.stats.hits_fs_cache += 1; - let module_size = loupe::size_of_val(&module); return cache .pinned_memory_cache .store(checksum, module, module_size); @@ -226,8 +203,7 @@ where let code = self.load_wasm_with_path(&cache.wasm_path, checksum)?; let module = compile(&code, Some(cache.instance_memory_limit))?; // Store into the fs cache too - cache.fs_cache.store(checksum, &module)?; - let module_size = loupe::size_of_val(&module); + let module_size = cache.fs_cache.store(checksum, &module)?; cache .pinned_memory_cache .store(checksum, module, module_size) @@ -276,11 +252,10 @@ where // Get module from file system cache let store = make_runtime_store(Some(cache.instance_memory_limit)); - if let Some(module) = cache.fs_cache.load(checksum, &store)? { + if let Some((module, module_size)) = cache.fs_cache.load(checksum, &store)? { cache.stats.hits_fs_cache += 1; let instance = Instance::from_module(&module, backend, options.gas_limit, options.print_debug)?; - let module_size = loupe::size_of_val(&module); cache.memory_cache.store(checksum, module, module_size)?; return Ok(instance); } @@ -295,8 +270,7 @@ where let module = compile(&wasm, Some(cache.instance_memory_limit))?; let instance = Instance::from_module(&module, backend, options.gas_limit, options.print_debug)?; - cache.fs_cache.store(checksum, &module)?; - let module_size = loupe::size_of_val(&module); + let module_size = cache.fs_cache.store(checksum, &module)?; cache.memory_cache.store(checksum, module, module_size)?; Ok(instance) } @@ -321,7 +295,7 @@ where /// save stores the wasm code in the given directory and returns an ID for lookup. /// It will create the directory if it doesn't exist. /// Saving the same byte code multiple times is allowed. -fn save_wasm_to_disk(dir: impl Into, wasm: &[u8]) -> VmResult { +fn save_wasm_to_disk>(dir: P, wasm: &[u8]) -> VmResult { // calculate filename let checksum = Checksum::generate(wasm); let filename = checksum.to_hex(); @@ -341,7 +315,7 @@ fn save_wasm_to_disk(dir: impl Into, wasm: &[u8]) -> VmResult Ok(checksum) } -fn load_wasm_from_disk(dir: impl Into, checksum: &Checksum) -> VmResult> { +fn load_wasm_from_disk>(dir: P, checksum: &Checksum) -> VmResult> { // this requires the directory and file to exist let path = dir.into().join(checksum.to_hex()); let mut file = File::open(path) @@ -363,7 +337,6 @@ mod tests { use cosmwasm_std::{coins, Empty}; use std::fs::OpenOptions; use std::io::Write; - use std::iter::FromIterator; use tempfile::TempDir; const TESTING_GAS_LIMIT: u64 = 4_000_000; @@ -375,7 +348,6 @@ mod tests { const TESTING_MEMORY_CACHE_SIZE: Size = Size::mebi(200); static CONTRACT: &[u8] = include_bytes!("../testdata/hackatom.wasm"); - static IBC_CONTRACT: &[u8] = include_bytes!("../testdata/ibc_reflect.wasm"); fn default_features() -> HashSet { features_from_csv("staking") @@ -390,15 +362,6 @@ mod tests { } } - fn make_stargate_testing_options() -> CacheOptions { - CacheOptions { - base_dir: TempDir::new().unwrap().into_path(), - supported_features: features_from_csv("staking,stargate"), - memory_cache_size: TESTING_MEMORY_CACHE_SIZE, - instance_memory_limit: TESTING_MEMORY_LIMIT, - } - } - #[test] fn save_wasm_works() { let cache: Cache = @@ -531,11 +494,7 @@ mod tests { let checksum = cache.save_wasm(CONTRACT).unwrap(); // Corrupt cache file - let filepath = tmp_dir - .path() - .join(STATE_DIR) - .join(WASM_DIR) - .join(&checksum.to_hex()); + let filepath = tmp_dir.path().join(WASM_DIR).join(&checksum.to_hex()); let mut file = OpenOptions::new().write(true).open(filepath).unwrap(); file.write_all(b"broken data").unwrap(); @@ -962,35 +921,6 @@ mod tests { assert_eq!(code, loaded); } - #[test] - fn analyze_works() { - let cache: Cache = - unsafe { Cache::new(make_stargate_testing_options()).unwrap() }; - - let checksum1 = cache.save_wasm(CONTRACT).unwrap(); - let report1 = cache.analyze(&checksum1).unwrap(); - assert_eq!( - report1, - AnalysisReport { - has_ibc_entry_points: false, - required_features: HashSet::new(), - } - ); - - let checksum2 = cache.save_wasm(IBC_CONTRACT).unwrap(); - let report2 = cache.analyze(&checksum2).unwrap(); - assert_eq!( - report2, - AnalysisReport { - has_ibc_entry_points: true, - required_features: HashSet::from_iter(vec![ - "staking".to_string(), - "stargate".to_string() - ]), - } - ); - } - #[test] fn pin_unpin_works() { let cache = unsafe { Cache::new(make_testing_options()).unwrap() }; diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs index e27f5abb6..41300d858 100644 --- a/packages/vm/src/calls.rs +++ b/packages/vm/src/calls.rs @@ -4,11 +4,6 @@ use std::fmt; use wasmer::Val; use cosmwasm_std::{ContractResult, Env, MessageInfo, QueryResponse, Reply, Response}; -#[cfg(feature = "stargate")] -use cosmwasm_std::{ - IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcPacketAckMsg, - IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, -}; use crate::backend::{BackendApi, Querier, Storage}; use crate::conversion::ref_to_u32; @@ -16,85 +11,12 @@ use crate::errors::{VmError, VmResult}; use crate::instance::Instance; use crate::serde::{from_slice, to_vec}; -/// The limits in here protect the host from allocating an unreasonable amount of memory -/// and copying an unreasonable amount of data. -/// -/// A JSON deserializer would want to set the limit to a much smaller value because -/// deserializing JSON is more expensive. As a consequence, any sane contract should hit -/// the deserializer limit before the read limit. -mod read_limits { - /// A mibi (mega binary) - const MI: usize = 1024 * 1024; - /// Max length (in bytes) of the result data from an instantiate call. - pub const RESULT_INSTANTIATE: usize = 64 * MI; - /// Max length (in bytes) of the result data from an execute call. - pub const RESULT_EXECUTE: usize = 64 * MI; - /// Max length (in bytes) of the result data from a migrate call. - pub const RESULT_MIGRATE: usize = 64 * MI; - /// Max length (in bytes) of the result data from a sudo call. - pub const RESULT_SUDO: usize = 64 * MI; - /// Max length (in bytes) of the result data from a reply call. - pub const RESULT_REPLY: usize = 64 * MI; - /// Max length (in bytes) of the result data from a query call. - pub const RESULT_QUERY: usize = 64 * MI; - /// Max length (in bytes) of the result data from a ibc_channel_open call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_CHANNEL_OPEN: usize = 64 * MI; - /// Max length (in bytes) of the result data from a ibc_channel_connect call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_CHANNEL_CONNECT: usize = 64 * MI; - /// Max length (in bytes) of the result data from a ibc_channel_close call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_CHANNEL_CLOSE: usize = 64 * MI; - /// Max length (in bytes) of the result data from a ibc_packet_receive call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_PACKET_RECEIVE: usize = 64 * MI; - /// Max length (in bytes) of the result data from a ibc_packet_ack call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_PACKET_ACK: usize = 64 * MI; - /// Max length (in bytes) of the result data from a ibc_packet_timeout call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_PACKET_TIMEOUT: usize = 64 * MI; -} - -/// The limits for the JSON deserialization. -/// -/// Those limits are not used when the Rust JSON deserializer is bypassed by using the -/// public `call_*_raw` functions directly. -mod deserialization_limits { - /// A kibi (kilo binary) - const KI: usize = 1024; - /// Max length (in bytes) of the result data from an instantiate call. - pub const RESULT_INSTANTIATE: usize = 256 * KI; - /// Max length (in bytes) of the result data from an execute call. - pub const RESULT_EXECUTE: usize = 256 * KI; - /// Max length (in bytes) of the result data from a migrate call. - pub const RESULT_MIGRATE: usize = 256 * KI; - /// Max length (in bytes) of the result data from a sudo call. - pub const RESULT_SUDO: usize = 256 * KI; - /// Max length (in bytes) of the result data from a reply call. - pub const RESULT_REPLY: usize = 256 * KI; - /// Max length (in bytes) of the result data from a query call. - pub const RESULT_QUERY: usize = 256 * KI; - /// Max length (in bytes) of the result data from a ibc_channel_open call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_CHANNEL_OPEN: usize = 256 * KI; - /// Max length (in bytes) of the result data from a ibc_channel_connect call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_CHANNEL_CONNECT: usize = 256 * KI; - /// Max length (in bytes) of the result data from a ibc_channel_close call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_CHANNEL_CLOSE: usize = 256 * KI; - /// Max length (in bytes) of the result data from a ibc_packet_receive call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_PACKET_RECEIVE: usize = 256 * KI; - /// Max length (in bytes) of the result data from a ibc_packet_ack call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_PACKET_ACK: usize = 256 * KI; - /// Max length (in bytes) of the result data from a ibc_packet_timeout call. - #[cfg(feature = "stargate")] - pub const RESULT_IBC_PACKET_TIMEOUT: usize = 256 * KI; -} +const MAX_LENGTH_INIT: usize = 100_000; +const MAX_LENGTH_EXECUTE: usize = 100_000; +const MAX_LENGTH_MIGRATE: usize = 100_000; +const MAX_LENGTH_SUDO: usize = 100_000; +const MAX_LENGTH_SUBCALL_RESPONSE: usize = 100_000; +const MAX_LENGTH_QUERY: usize = 100_000; pub fn call_instantiate( instance: &mut Instance, @@ -111,8 +33,7 @@ where let env = to_vec(env)?; let info = to_vec(info)?; let data = call_instantiate_raw(instance, &env, &info, msg)?; - let result: ContractResult> = - from_slice(&data, deserialization_limits::RESULT_INSTANTIATE)?; + let result: ContractResult> = from_slice(&data)?; Ok(result) } @@ -131,8 +52,7 @@ where let env = to_vec(env)?; let info = to_vec(info)?; let data = call_execute_raw(instance, &env, &info, msg)?; - let result: ContractResult> = - from_slice(&data, deserialization_limits::RESULT_EXECUTE)?; + let result: ContractResult> = from_slice(&data)?; Ok(result) } @@ -149,8 +69,7 @@ where { let env = to_vec(env)?; let data = call_migrate_raw(instance, &env, msg)?; - let result: ContractResult> = - from_slice(&data, deserialization_limits::RESULT_MIGRATE)?; + let result: ContractResult> = from_slice(&data)?; Ok(result) } @@ -167,8 +86,7 @@ where { let env = to_vec(env)?; let data = call_sudo_raw(instance, &env, msg)?; - let result: ContractResult> = - from_slice(&data, deserialization_limits::RESULT_SUDO)?; + let result: ContractResult> = from_slice(&data)?; Ok(result) } @@ -186,8 +104,7 @@ where let env = to_vec(env)?; let msg = to_vec(msg)?; let data = call_reply_raw(instance, &env, &msg)?; - let result: ContractResult> = - from_slice(&data, deserialization_limits::RESULT_REPLY)?; + let result: ContractResult> = from_slice(&data)?; Ok(result) } @@ -203,8 +120,7 @@ where { let env = to_vec(env)?; let data = call_query_raw(instance, &env, msg)?; - let result: ContractResult = - from_slice(&data, deserialization_limits::RESULT_QUERY)?; + let result: ContractResult = from_slice(&data)?; // Ensure query response is valid JSON if let ContractResult::Ok(binary_response) = &result { serde_json::from_slice::(binary_response.as_slice()).map_err(|e| { @@ -215,120 +131,6 @@ where Ok(result) } -#[cfg(feature = "stargate")] -pub fn call_ibc_channel_open( - instance: &mut Instance, - env: &Env, - msg: &IbcChannelOpenMsg, -) -> VmResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, -{ - let env = to_vec(env)?; - let msg = to_vec(msg)?; - let data = call_ibc_channel_open_raw(instance, &env, &msg)?; - let result: ContractResult<()> = - from_slice(&data, deserialization_limits::RESULT_IBC_CHANNEL_OPEN)?; - Ok(result) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_channel_connect( - instance: &mut Instance, - env: &Env, - msg: &IbcChannelConnectMsg, -) -> VmResult>> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, -{ - let env = to_vec(env)?; - let msg = to_vec(msg)?; - let data = call_ibc_channel_connect_raw(instance, &env, &msg)?; - let result = from_slice(&data, deserialization_limits::RESULT_IBC_CHANNEL_CONNECT)?; - Ok(result) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_channel_close( - instance: &mut Instance, - env: &Env, - msg: &IbcChannelCloseMsg, -) -> VmResult>> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, -{ - let env = to_vec(env)?; - let msg = to_vec(msg)?; - let data = call_ibc_channel_close_raw(instance, &env, &msg)?; - let result = from_slice(&data, deserialization_limits::RESULT_IBC_CHANNEL_CLOSE)?; - Ok(result) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_packet_receive( - instance: &mut Instance, - env: &Env, - msg: &IbcPacketReceiveMsg, -) -> VmResult>> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, -{ - let env = to_vec(env)?; - let msg = to_vec(msg)?; - let data = call_ibc_packet_receive_raw(instance, &env, &msg)?; - let result = from_slice(&data, deserialization_limits::RESULT_IBC_PACKET_RECEIVE)?; - Ok(result) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_packet_ack( - instance: &mut Instance, - env: &Env, - msg: &IbcPacketAckMsg, -) -> VmResult>> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, -{ - let env = to_vec(env)?; - let msg = to_vec(msg)?; - let data = call_ibc_packet_ack_raw(instance, &env, &msg)?; - let result = from_slice(&data, deserialization_limits::RESULT_IBC_PACKET_ACK)?; - Ok(result) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_packet_timeout( - instance: &mut Instance, - env: &Env, - msg: &IbcPacketTimeoutMsg, -) -> VmResult>> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, -{ - let env = to_vec(env)?; - let msg = to_vec(msg)?; - let data = call_ibc_packet_timeout_raw(instance, &env, &msg)?; - let result = from_slice(&data, deserialization_limits::RESULT_IBC_PACKET_TIMEOUT)?; - Ok(result) -} - /// Calls Wasm export "instantiate" and returns raw data from the contract. /// The result is length limited to prevent abuse but otherwise unchecked. pub fn call_instantiate_raw( @@ -343,12 +145,7 @@ where Q: Querier + 'static, { instance.set_storage_readonly(false); - call_raw( - instance, - "instantiate", - &[env, info, msg], - read_limits::RESULT_INSTANTIATE, - ) + call_raw(instance, "instantiate", &[env, info, msg], MAX_LENGTH_INIT) } /// Calls Wasm export "execute" and returns raw data from the contract. @@ -365,12 +162,7 @@ where Q: Querier + 'static, { instance.set_storage_readonly(false); - call_raw( - instance, - "execute", - &[env, info, msg], - read_limits::RESULT_EXECUTE, - ) + call_raw(instance, "execute", &[env, info, msg], MAX_LENGTH_EXECUTE) } /// Calls Wasm export "migrate" and returns raw data from the contract. @@ -386,12 +178,7 @@ where Q: Querier + 'static, { instance.set_storage_readonly(false); - call_raw( - instance, - "migrate", - &[env, msg], - read_limits::RESULT_MIGRATE, - ) + call_raw(instance, "migrate", &[env, msg], MAX_LENGTH_MIGRATE) } /// Calls Wasm export "sudo" and returns raw data from the contract. @@ -407,7 +194,7 @@ where Q: Querier + 'static, { instance.set_storage_readonly(false); - call_raw(instance, "sudo", &[env, msg], read_limits::RESULT_SUDO) + call_raw(instance, "sudo", &[env, msg], MAX_LENGTH_SUDO) } /// Calls Wasm export "reply" and returns raw data from the contract. @@ -423,7 +210,7 @@ where Q: Querier + 'static, { instance.set_storage_readonly(false); - call_raw(instance, "reply", &[env, msg], read_limits::RESULT_REPLY) + call_raw(instance, "reply", &[env, msg], MAX_LENGTH_SUBCALL_RESPONSE) } /// Calls Wasm export "query" and returns raw data from the contract. @@ -439,127 +226,7 @@ where Q: Querier + 'static, { instance.set_storage_readonly(true); - call_raw(instance, "query", &[env, msg], read_limits::RESULT_QUERY) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_channel_open_raw( - instance: &mut Instance, - env: &[u8], - msg: &[u8], -) -> VmResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, -{ - instance.set_storage_readonly(false); - call_raw( - instance, - "ibc_channel_open", - &[env, msg], - read_limits::RESULT_IBC_CHANNEL_OPEN, - ) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_channel_connect_raw( - instance: &mut Instance, - env: &[u8], - msg: &[u8], -) -> VmResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, -{ - instance.set_storage_readonly(false); - call_raw( - instance, - "ibc_channel_connect", - &[env, msg], - read_limits::RESULT_IBC_CHANNEL_CONNECT, - ) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_channel_close_raw( - instance: &mut Instance, - env: &[u8], - msg: &[u8], -) -> VmResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, -{ - instance.set_storage_readonly(false); - call_raw( - instance, - "ibc_channel_close", - &[env, msg], - read_limits::RESULT_IBC_CHANNEL_CLOSE, - ) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_packet_receive_raw( - instance: &mut Instance, - env: &[u8], - msg: &[u8], -) -> VmResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, -{ - instance.set_storage_readonly(false); - call_raw( - instance, - "ibc_packet_receive", - &[env, msg], - read_limits::RESULT_IBC_PACKET_RECEIVE, - ) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_packet_ack_raw( - instance: &mut Instance, - env: &[u8], - msg: &[u8], -) -> VmResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, -{ - instance.set_storage_readonly(false); - call_raw( - instance, - "ibc_packet_ack", - &[env, msg], - read_limits::RESULT_IBC_PACKET_ACK, - ) -} - -#[cfg(feature = "stargate")] -pub fn call_ibc_packet_timeout_raw( - instance: &mut Instance, - env: &[u8], - msg: &[u8], -) -> VmResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, -{ - instance.set_storage_readonly(false); - call_raw( - instance, - "ibc_packet_timeout", - &[env, msg], - read_limits::RESULT_IBC_PACKET_TIMEOUT, - ) + call_raw(instance, "query", &[env, msg], MAX_LENGTH_QUERY) } /// Calls a function with the given arguments. @@ -599,7 +266,7 @@ mod tests { #[test] fn call_instantiate_works() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); // init let info = mock_info("creator", &coins(1000, "earth")); @@ -611,7 +278,7 @@ mod tests { #[test] fn call_execute_works() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); // init let info = mock_info("creator", &coins(1000, "earth")); @@ -630,7 +297,7 @@ mod tests { #[test] fn call_migrate_works() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); // init let info = mock_info("creator", &coins(1000, "earth")); @@ -655,7 +322,7 @@ mod tests { #[test] fn call_query_works() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); // init let info = mock_info("creator", &coins(1000, "earth")); @@ -670,116 +337,4 @@ mod tests { let query_response = contract_result.unwrap(); assert_eq!(query_response.as_slice(), b"{\"verifier\":\"verifies\"}"); } - - #[cfg(feature = "stargate")] - mod ibc { - use super::*; - use crate::calls::{call_instantiate, call_reply}; - use crate::testing::{ - mock_env, mock_info, mock_instance, MockApi, MockQuerier, MockStorage, - }; - use cosmwasm_std::testing::{ - mock_ibc_channel_close_init, mock_ibc_channel_connect_ack, mock_ibc_channel_open_init, - mock_ibc_packet_ack, mock_ibc_packet_recv, mock_ibc_packet_timeout, mock_wasmd_attr, - }; - use cosmwasm_std::{ - Empty, Event, IbcAcknowledgement, IbcOrder, Reply, ReplyOn, SubMsgExecutionResponse, - }; - static CONTRACT: &[u8] = include_bytes!("../testdata/ibc_reflect.wasm"); - const IBC_VERSION: &str = "ibc-reflect-v1"; - fn setup( - instance: &mut Instance, - channel_id: &str, - account: &str, - ) { - // init - let info = mock_info("creator", &[]); - let msg = br#"{"reflect_code_id":77}"#; - call_instantiate::<_, _, _, Empty>(instance, &mock_env(), &info, msg) - .unwrap() - .unwrap(); - // first we try to open with a valid handshake - let handshake_open = - mock_ibc_channel_open_init(channel_id, IbcOrder::Ordered, IBC_VERSION); - call_ibc_channel_open(instance, &mock_env(), &handshake_open) - .unwrap() - .unwrap(); - // then we connect (with counter-party version set) - let handshake_connect = - mock_ibc_channel_connect_ack(channel_id, IbcOrder::Ordered, IBC_VERSION); - let res: IbcBasicResponse = call_ibc_channel_connect::<_, _, _, Empty>( - instance, - &mock_env(), - &handshake_connect, - ) - .unwrap() - .unwrap(); - assert_eq!(1, res.messages.len()); - assert_eq!( - res.events, - [Event::new("ibc").add_attribute("channel", "connect")] - ); - assert_eq!(ReplyOn::Success, res.messages[0].reply_on); - let id = res.messages[0].id; - let event = Event::new("instantiate").add_attributes(vec![ - // We have to force this one to avoid the debug assertion against _ - mock_wasmd_attr("_contract_address", account), - ]); - // which creates a reflect account. here we get the callback - let response = Reply { - id, - result: ContractResult::Ok(SubMsgExecutionResponse { - events: vec![event], - data: None, - }), - }; - call_reply::<_, _, _, Empty>(instance, &mock_env(), &response).unwrap(); - } - const CHANNEL_ID: &str = "channel-123"; - const ACCOUNT: &str = "account-456"; - #[test] - fn call_ibc_channel_open_and_connect_works() { - let mut instance = mock_instance(CONTRACT, &[]); - setup(&mut instance, CHANNEL_ID, ACCOUNT); - } - #[test] - fn call_ibc_channel_close_works() { - let mut instance = mock_instance(CONTRACT, &[]); - setup(&mut instance, CHANNEL_ID, ACCOUNT); - let handshake_close = - mock_ibc_channel_close_init(CHANNEL_ID, IbcOrder::Ordered, IBC_VERSION); - call_ibc_channel_close::<_, _, _, Empty>(&mut instance, &mock_env(), &handshake_close) - .unwrap() - .unwrap(); - } - #[test] - fn call_ibc_packet_ack_works() { - let mut instance = mock_instance(CONTRACT, &[]); - setup(&mut instance, CHANNEL_ID, ACCOUNT); - let ack = IbcAcknowledgement::new(br#"{}"#); - let msg = mock_ibc_packet_ack(CHANNEL_ID, br#"{}"#, ack).unwrap(); - call_ibc_packet_ack::<_, _, _, Empty>(&mut instance, &mock_env(), &msg) - .unwrap() - .unwrap(); - } - #[test] - fn call_ibc_packet_timeout_works() { - let mut instance = mock_instance(CONTRACT, &[]); - setup(&mut instance, CHANNEL_ID, ACCOUNT); - let msg = mock_ibc_packet_timeout(CHANNEL_ID, br#"{}"#).unwrap(); - call_ibc_packet_timeout::<_, _, _, Empty>(&mut instance, &mock_env(), &msg) - .unwrap() - .unwrap(); - } - #[test] - fn call_ibc_packet_receive_works() { - let mut instance = mock_instance(CONTRACT, &[]); - setup(&mut instance, CHANNEL_ID, ACCOUNT); - let who_am_i = br#"{"who_am_i":{}}"#; - let msg = mock_ibc_packet_recv(CHANNEL_ID, who_am_i).unwrap(); - call_ibc_packet_receive::<_, _, _, Empty>(&mut instance, &mock_env(), &msg) - .unwrap() - .unwrap(); - } - } } diff --git a/packages/vm/src/checksum.rs b/packages/vm/src/checksum.rs index b251a2844..c52d904a7 100644 --- a/packages/vm/src/checksum.rs +++ b/packages/vm/src/checksum.rs @@ -19,7 +19,7 @@ impl Checksum { } /// Creates a lowercase hex encoded copy of this checksum - pub fn to_hex(self) -> String { + pub fn to_hex(&self) -> String { self.to_string() } } diff --git a/packages/vm/src/compatibility.rs b/packages/vm/src/compatibility.rs index b6f521657..2165f140e 100644 --- a/packages/vm/src/compatibility.rs +++ b/packages/vm/src/compatibility.rs @@ -5,7 +5,7 @@ use std::collections::HashSet; use crate::errors::{VmError, VmResult}; use crate::features::required_features_from_module; use crate::limited::LimitedDisplay; -use crate::static_analysis::{deserialize_wasm, ExportInfo}; +use crate::static_analysis::{deserialize_wasm, exported_functions}; /// Lists all imports we provide upon instantiating the instance in Instance::from_module() /// This should be updated when new imports are added @@ -31,28 +31,20 @@ const SUPPORTED_IMPORTS: &[&str] = &[ /// Lists all entry points we expect to be present when calling a contract. /// Other optional exports exist, e.g. "execute", "migrate" and "query". -/// The marker export interface_version_* is checked separately. /// This is unlikely to change much, must be frozen at 1.0 to avoid breaking existing contracts const REQUIRED_EXPORTS: &[&str] = &[ - // IO + "interface_version_5", + "instantiate", "allocate", "deallocate", - // Required entry points - "instantiate", ]; -const INTERFACE_VERSION_PREFIX: &str = "interface_version_"; -/// Only one version is supported right now. This could potentially turn into a list -/// later, but maybe this never happens and new functionality is only added via features. -const SUPPORTED_INTERFACE_VERSION: &str = "interface_version_7"; - const MEMORY_LIMIT: u32 = 512; // in pages /// Checks if the data is valid wasm and compatibility with the CosmWasm API (imports and exports) pub fn check_wasm(wasm_code: &[u8], supported_features: &HashSet) -> VmResult<()> { let module = deserialize_wasm(wasm_code)?; check_wasm_memories(&module)?; - check_interface_version(&module)?; check_wasm_exports(&module)?; check_wasm_imports(&module, SUPPORTED_IMPORTS)?; check_wasm_features(&module, supported_features)?; @@ -95,47 +87,12 @@ fn check_wasm_memories(module: &Module) -> VmResult<()> { Ok(()) } -fn check_interface_version(module: &Module) -> VmResult<()> { - let mut interface_version_exports = module - .exported_function_names(Some(INTERFACE_VERSION_PREFIX)) - .into_iter(); - if let Some(first_interface_version_export) = interface_version_exports.next() { - if interface_version_exports.next().is_some() { - Err(VmError::static_validation_err( - "Wasm contract contains more than one marker export: interface_version_*", - )) - } else { - // Exactly one interface version found - - match first_interface_version_export.as_str() { - // Ok - SUPPORTED_INTERFACE_VERSION => Ok(()), - // Well known old versions for better error messages - "interface_version_6" => Err(VmError::static_validation_err( - "Wasm contract has incompatible CosmWasm 0.15 marker export interface_version_6 (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)" - )), - "interface_version_5" => Err(VmError::static_validation_err( - "Wasm contract has incompatible CosmWasm 0.14 marker export interface_version_5 (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)" - )), - // Unknown version - _ => Err(VmError::static_validation_err( - "Wasm contract has unknown interface_version_* marker export (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)", - )), - } - } - } else { - Err(VmError::static_validation_err( - "Wasm contract missing a required marker export: interface_version_*", - )) - } -} - fn check_wasm_exports(module: &Module) -> VmResult<()> { - let available_exports: HashSet = module.exported_function_names(None); + let available_exports: HashSet = exported_functions(module); for required_export in REQUIRED_EXPORTS { if !available_exports.contains(*required_export) { return Err(VmError::static_validation_err(format!( - "Wasm contract doesn't have required export: \"{}\". Exports required by VM: {:?}.", + "Wasm contract doesn't have required export: \"{}\". Exports required by VM: {:?}. Contract version too old for this VM?", required_export, REQUIRED_EXPORTS ))); } @@ -181,7 +138,7 @@ fn check_wasm_features(module: &Module, supported_features: &HashSet) -> let required_features = required_features_from_module(module); if !required_features.is_subset(supported_features) { // We switch to BTreeSet to get a sorted error message - let unsupported: BTreeSet<_> = required_features.difference(supported_features).collect(); + let unsupported: BTreeSet<_> = required_features.difference(&supported_features).collect(); return Err(VmError::static_validation_err(format!( "Wasm contract requires unsupported features: {}", unsupported.to_string_limited(200) @@ -195,10 +152,8 @@ mod tests { use super::*; use crate::errors::VmError; + static CONTRACT_0_6: &[u8] = include_bytes!("../testdata/hackatom_0.6.wasm"); static CONTRACT_0_7: &[u8] = include_bytes!("../testdata/hackatom_0.7.wasm"); - static CONTRACT_0_12: &[u8] = include_bytes!("../testdata/hackatom_0.12.wasm"); - static CONTRACT_0_14: &[u8] = include_bytes!("../testdata/hackatom_0.14.wasm"); - static CONTRACT_0_15: &[u8] = include_bytes!("../testdata/hackatom_0.15.wasm"); static CONTRACT: &[u8] = include_bytes!("../testdata/hackatom.wasm"); fn default_features() -> HashSet { @@ -213,38 +168,18 @@ mod tests { #[test] fn check_wasm_old_contract() { - match check_wasm(CONTRACT_0_15, &default_features()) { - Err(VmError::StaticValidationErr { msg, .. }) => assert_eq!( - msg, - "Wasm contract has incompatible CosmWasm 0.15 marker export interface_version_6 (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)" - ), - Err(e) => panic!("Unexpected error {:?}", e), - Ok(_) => panic!("This must not succeeed"), - }; - - match check_wasm(CONTRACT_0_14, &default_features()) { - Err(VmError::StaticValidationErr { msg, .. }) => assert_eq!( - msg, - "Wasm contract has incompatible CosmWasm 0.14 marker export interface_version_5 (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)" - ), - Err(e) => panic!("Unexpected error {:?}", e), - Ok(_) => panic!("This must not succeeed"), - }; - - match check_wasm(CONTRACT_0_12, &default_features()) { - Err(VmError::StaticValidationErr { msg, .. }) => assert_eq!( - msg, - "Wasm contract missing a required marker export: interface_version_*" - ), + match check_wasm(CONTRACT_0_7, &default_features()) { + Err(VmError::StaticValidationErr { msg, .. }) => assert!(msg.starts_with( + "Wasm contract doesn't have required export: \"interface_version_5\"" + )), Err(e) => panic!("Unexpected error {:?}", e), Ok(_) => panic!("This must not succeeed"), }; - match check_wasm(CONTRACT_0_7, &default_features()) { - Err(VmError::StaticValidationErr { msg, .. }) => assert_eq!( - msg, - "Wasm contract missing a required marker export: interface_version_*" - ), + match check_wasm(CONTRACT_0_6, &default_features()) { + Err(VmError::StaticValidationErr { msg, .. }) => assert!(msg.starts_with( + "Wasm contract doesn't have required export: \"interface_version_5\"" + )), Err(e) => panic!("Unexpected error {:?}", e), Ok(_) => panic!("This must not succeeed"), }; @@ -340,166 +275,25 @@ mod tests { } } - #[test] - fn check_interface_version_works() { - // valid - let wasm = wat::parse_str( - r#"(module - (type (func)) - (func (type 0) nop) - (export "add_one" (func 0)) - (export "allocate" (func 0)) - (export "interface_version_7" (func 0)) - (export "deallocate" (func 0)) - (export "instantiate" (func 0)) - )"#, - ) - .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); - check_interface_version(&module).unwrap(); - - // missing - let wasm = wat::parse_str( - r#"(module - (type (func)) - (func (type 0) nop) - (export "add_one" (func 0)) - (export "allocate" (func 0)) - (export "deallocate" (func 0)) - (export "instantiate" (func 0)) - )"#, - ) - .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); - match check_interface_version(&module).unwrap_err() { - VmError::StaticValidationErr { msg, .. } => { - assert_eq!( - msg, - "Wasm contract missing a required marker export: interface_version_*" - ); - } - err => panic!("Unexpected error {:?}", err), - } - - // multiple - let wasm = wat::parse_str( - r#"(module - (type (func)) - (func (type 0) nop) - (export "add_one" (func 0)) - (export "allocate" (func 0)) - (export "interface_version_7" (func 0)) - (export "interface_version_8" (func 0)) - (export "deallocate" (func 0)) - (export "instantiate" (func 0)) - )"#, - ) - .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); - match check_interface_version(&module).unwrap_err() { - VmError::StaticValidationErr { msg, .. } => { - assert_eq!( - msg, - "Wasm contract contains more than one marker export: interface_version_*" - ); - } - err => panic!("Unexpected error {:?}", err), - } - - // CosmWasm 0.15 - let wasm = wat::parse_str( - r#"(module - (type (func)) - (func (type 0) nop) - (export "add_one" (func 0)) - (export "allocate" (func 0)) - (export "interface_version_6" (func 0)) - (export "deallocate" (func 0)) - (export "instantiate" (func 0)) - )"#, - ) - .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); - match check_interface_version(&module).unwrap_err() { - VmError::StaticValidationErr { msg, .. } => { - assert_eq!(msg, "Wasm contract has incompatible CosmWasm 0.15 marker export interface_version_6 (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)"); - } - err => panic!("Unexpected error {:?}", err), - } - - // Unknown value - let wasm = wat::parse_str( - r#"(module - (type (func)) - (func (type 0) nop) - (export "add_one" (func 0)) - (export "allocate" (func 0)) - (export "interface_version_broken" (func 0)) - (export "deallocate" (func 0)) - (export "instantiate" (func 0)) - )"#, - ) - .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); - match check_interface_version(&module).unwrap_err() { - VmError::StaticValidationErr { msg, .. } => { - assert_eq!(msg, "Wasm contract has unknown interface_version_* marker export (see https://github.com/CosmWasm/cosmwasm/blob/main/packages/vm/README.md)"); - } - err => panic!("Unexpected error {:?}", err), - } - } - #[test] fn check_wasm_exports_works() { - // valid - let wasm = wat::parse_str( - r#"(module - (type (func)) - (func (type 0) nop) - (export "add_one" (func 0)) - (export "allocate" (func 0)) - (export "deallocate" (func 0)) - (export "instantiate" (func 0)) - )"#, - ) - .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); - check_wasm_exports(&module).unwrap(); - - // this is invalid, as it doesn't any required export - let wasm = wat::parse_str( - r#"(module - (type (func)) - (func (type 0) nop) - (export "add_one" (func 0)) - )"#, - ) - .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); - match check_wasm_exports(&module) { - Err(VmError::StaticValidationErr { msg, .. }) => { - assert!(msg.starts_with("Wasm contract doesn't have required export: \"allocate\"")); - } - Err(e) => panic!("Unexpected error {:?}", e), - Ok(_) => panic!("Didn't reject wasm with invalid api"), - } - // this is invalid, as it doesn't contain all required exports - let wasm = wat::parse_str( - r#"(module - (type (func)) - (func (type 0) nop) - (export "add_one" (func 0)) - (export "allocate" (func 0)) - )"#, - ) - .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + const WAT_MISSING_EXPORTS: &str = r#" + (module + (type $t0 (func (param i32) (result i32))) + (func $add_one (export "add_one") (type $t0) (param $p0 i32) (result i32) + get_local $p0 + i32.const 1 + i32.add)) + "#; + let wasm_missing_exports = wat::parse_str(WAT_MISSING_EXPORTS).unwrap(); + + let module = deserialize_wasm(&wasm_missing_exports).unwrap(); match check_wasm_exports(&module) { Err(VmError::StaticValidationErr { msg, .. }) => { - assert!( - msg.starts_with("Wasm contract doesn't have required export: \"deallocate\"") - ); + assert!(msg.starts_with( + "Wasm contract doesn't have required export: \"interface_version_5\"" + )); } Err(e) => panic!("Unexpected error {:?}", e), Ok(_) => panic!("Didn't reject wasm with invalid api"), @@ -511,9 +305,9 @@ mod tests { let module = deserialize_wasm(CONTRACT_0_7).unwrap(); match check_wasm_exports(&module) { Err(VmError::StaticValidationErr { msg, .. }) => { - assert!( - msg.starts_with("Wasm contract doesn't have required export: \"instantiate\"") - ) + assert!(msg.starts_with( + "Wasm contract doesn't have required export: \"interface_version_5\"" + )); } Err(e) => panic!("Unexpected error {:?}", e), Ok(_) => panic!("Didn't reject wasm with invalid api"), diff --git a/packages/vm/src/environment.rs b/packages/vm/src/environment.rs index afcdbd463..7769b1fc8 100644 --- a/packages/vm/src/environment.rs +++ b/packages/vm/src/environment.rs @@ -56,7 +56,7 @@ impl GasConfig { ); // 0.41 / 4. ~ 0.1 // sha1 cost factor - const SHA1_CALCULATE_FACTOR: (u64, u64) = (270, 15400); // 270 ns in crypto benchmarks when imports::MAX_LENGTH_SHA1_MESSAGE=80 + const SHA1_CALCULATE_FACTOR: (u64, u64) = (270, 15400); // 270 ns in crypto benchmarks when INPUT_MAX_LEN=80 fn calc_crypto_cost(factor: (u64, u64)) -> u64 { (GasConfig::BASE_CRYPTO_COST * factor.0) / factor.1 @@ -424,26 +424,26 @@ mod tests { ) { let env = Environment::new(MockApi::default(), gas_limit, false); - let module = compile(CONTRACT, TESTING_MEMORY_LIMIT).unwrap(); + let module = compile(&CONTRACT, TESTING_MEMORY_LIMIT).unwrap(); let store = module.store(); // we need stubs for all required imports let import_obj = imports! { "env" => { - "db_read" => Function::new_native(store, |_a: u32| -> u32 { 0 }), - "db_write" => Function::new_native(store, |_a: u32, _b: u32| {}), - "db_remove" => Function::new_native(store, |_a: u32| {}), - "db_scan" => Function::new_native(store, |_a: u32, _b: u32, _c: i32| -> u32 { 0 }), - "db_next" => Function::new_native(store, |_a: u32| -> u32 { 0 }), - "query_chain" => Function::new_native(store, |_a: u32| -> u32 { 0 }), - "addr_validate" => Function::new_native(store, |_a: u32| -> u32 { 0 }), - "addr_canonicalize" => Function::new_native(store, |_a: u32, _b: u32| -> u32 { 0 }), - "addr_humanize" => Function::new_native(store, |_a: u32, _b: u32| -> u32 { 0 }), - "secp256k1_verify" => Function::new_native(store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), - "secp256k1_recover_pubkey" => Function::new_native(store, |_a: u32, _b: u32, _c: u32| -> u64 { 0 }), - "ed25519_verify" => Function::new_native(store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), - "ed25519_batch_verify" => Function::new_native(store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), - "sha1_calculate" => Function::new_native(store, |_a: u32| -> u64 { 0 }), - "debug" => Function::new_native(store, |_a: u32| {}), + "db_read" => Function::new_native(&store, |_a: u32| -> u32 { 0 }), + "db_write" => Function::new_native(&store, |_a: u32, _b: u32| {}), + "db_remove" => Function::new_native(&store, |_a: u32| {}), + "db_scan" => Function::new_native(&store, |_a: u32, _b: u32, _c: i32| -> u32 { 0 }), + "db_next" => Function::new_native(&store, |_a: u32| -> u32 { 0 }), + "query_chain" => Function::new_native(&store, |_a: u32| -> u32 { 0 }), + "addr_validate" => Function::new_native(&store, |_a: u32| -> u32 { 0 }), + "addr_canonicalize" => Function::new_native(&store, |_a: u32, _b: u32| -> u32 { 0 }), + "addr_humanize" => Function::new_native(&store, |_a: u32, _b: u32| -> u32 { 0 }), + "secp256k1_verify" => Function::new_native(&store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), + "secp256k1_recover_pubkey" => Function::new_native(&store, |_a: u32, _b: u32, _c: u32| -> u64 { 0 }), + "ed25519_verify" => Function::new_native(&store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), + "ed25519_batch_verify" => Function::new_native(&store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), + "sha1_calculate" => Function::new_native(&store, |_a: u32| -> u64 { 0 }), + "debug" => Function::new_native(&store, |_a: u32| {}), }, }; let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); @@ -646,7 +646,7 @@ mod tests { let (env, _instance) = make_instance(TESTING_GAS_LIMIT); leave_default_data(&env); - assert!(env.is_storage_readonly()); + assert_eq!(env.is_storage_readonly(), true); } #[test] @@ -656,15 +656,15 @@ mod tests { // change env.set_storage_readonly(false); - assert!(!env.is_storage_readonly()); + assert_eq!(env.is_storage_readonly(), false); // still false env.set_storage_readonly(false); - assert!(!env.is_storage_readonly()); + assert_eq!(env.is_storage_readonly(), false); // change back env.set_storage_readonly(true); - assert!(env.is_storage_readonly()); + assert_eq!(env.is_storage_readonly(), true); } #[test] @@ -711,7 +711,7 @@ mod tests { let (env, _instance) = make_instance(TESTING_GAS_LIMIT); leave_default_data(&env); - env.call_function0("interface_version_7", &[]).unwrap(); + env.call_function0("interface_version_5", &[]).unwrap(); } #[test] @@ -725,7 +725,6 @@ mod tests { function_name, expected, actual, - .. } => { assert_eq!(function_name, "allocate"); assert_eq!(expected, 0); @@ -760,7 +759,6 @@ mod tests { function_name, expected, actual, - .. } => { assert_eq!(function_name, "deallocate"); assert_eq!(expected, 1); diff --git a/packages/vm/src/errors/communication_error.rs b/packages/vm/src/errors/communication_error.rs index a5fb88e0e..ccaa1cfa7 100644 --- a/packages/vm/src/errors/communication_error.rs +++ b/packages/vm/src/errors/communication_error.rs @@ -37,7 +37,7 @@ pub enum CommunicationError { } impl CommunicationError { - pub(crate) fn deref_err(offset: u32, msg: impl Into) -> Self { + pub(crate) fn deref_err>(offset: u32, msg: S) -> Self { CommunicationError::DerefErr { offset, msg: msg.into(), @@ -50,7 +50,7 @@ impl CommunicationError { } #[allow(dead_code)] - pub(crate) fn invalid_utf8(msg: impl ToString) -> Self { + pub(crate) fn invalid_utf8(msg: S) -> Self { CommunicationError::InvalidUtf8 { msg: msg.to_string(), } diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index 80d969328..d1d0bea81 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -81,14 +81,6 @@ pub enum VmError { #[cfg(feature = "backtraces")] backtrace: Backtrace, }, - #[error("Data too long for deserialization. Got: {length} bytes; limit: {max_length} bytes")] - DeserializationLimitExceeded { - /// the target type that was attempted - length: usize, - max_length: usize, - #[cfg(feature = "backtraces")] - backtrace: Backtrace, - }, #[error("Error serializing type {source_type}: {msg}")] SerializeErr { /// the source type that was attempted @@ -150,7 +142,7 @@ impl VmError { } } - pub(crate) fn cache_err(msg: impl Into) -> Self { + pub(crate) fn cache_err>(msg: S) -> Self { VmError::CacheErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -158,7 +150,7 @@ impl VmError { } } - pub(crate) fn compile_err(msg: impl Into) -> Self { + pub(crate) fn compile_err>(msg: S) -> Self { VmError::CompileErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -166,10 +158,10 @@ impl VmError { } } - pub(crate) fn conversion_err( - from_type: impl Into, - to_type: impl Into, - input: impl Into, + pub(crate) fn conversion_err, T: Into, U: Into>( + from_type: S, + to_type: T, + input: U, ) -> Self { VmError::ConversionErr { from_type: from_type.into(), @@ -195,7 +187,7 @@ impl VmError { } } - pub(crate) fn generic_err(msg: impl Into) -> Self { + pub(crate) fn generic_err>(msg: S) -> Self { VmError::GenericErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -203,7 +195,7 @@ impl VmError { } } - pub(crate) fn instantiation_err(msg: impl Into) -> Self { + pub(crate) fn instantiation_err>(msg: S) -> Self { VmError::InstantiationErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -218,7 +210,7 @@ impl VmError { } } - pub(crate) fn parse_err(target: impl Into, msg: impl Display) -> Self { + pub(crate) fn parse_err, M: Display>(target: T, msg: M) -> Self { VmError::ParseErr { target_type: target.into(), msg: msg.to_string(), @@ -227,16 +219,7 @@ impl VmError { } } - pub(crate) fn deserialization_limit_exceeded(length: usize, max_length: usize) -> Self { - VmError::DeserializationLimitExceeded { - length, - max_length, - #[cfg(feature = "backtraces")] - backtrace: Backtrace::capture(), - } - } - - pub(crate) fn serialize_err(source: impl Into, msg: impl Display) -> Self { + pub(crate) fn serialize_err, M: Display>(source: S, msg: M) -> Self { VmError::SerializeErr { source_type: source.into(), msg: msg.to_string(), @@ -245,7 +228,7 @@ impl VmError { } } - pub(crate) fn resolve_err(msg: impl Into) -> Self { + pub(crate) fn resolve_err>(msg: S) -> Self { VmError::ResolveErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -253,8 +236,8 @@ impl VmError { } } - pub(crate) fn result_mismatch( - function_name: impl Into, + pub(crate) fn result_mismatch>( + function_name: S, expected: usize, actual: usize, ) -> Self { @@ -267,7 +250,7 @@ impl VmError { } } - pub(crate) fn runtime_err(msg: impl Into) -> Self { + pub(crate) fn runtime_err>(msg: S) -> Self { VmError::RuntimeErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -275,7 +258,7 @@ impl VmError { } } - pub(crate) fn static_validation_err(msg: impl Into) -> Self { + pub(crate) fn static_validation_err>(msg: S) -> Self { VmError::StaticValidationErr { msg: msg.into(), #[cfg(feature = "backtraces")] @@ -283,7 +266,7 @@ impl VmError { } } - pub(crate) fn uninitialized_context_data(kind: impl Into) -> Self { + pub(crate) fn uninitialized_context_data>(kind: S) -> Self { VmError::UninitializedContextData { kind: kind.into(), #[cfg(feature = "backtraces")] diff --git a/packages/vm/src/features.rs b/packages/vm/src/features.rs index 4de16d0c9..daeb9fffa 100644 --- a/packages/vm/src/features.rs +++ b/packages/vm/src/features.rs @@ -1,6 +1,6 @@ +use parity_wasm::elements::{Internal, Module}; use std::collections::HashSet; - -use crate::static_analysis::ExportInfo; +use wasmer::{ExternType, Instance as WasmerInstance}; const REQUIRES_PREFIX: &str = "requires_"; @@ -13,27 +13,49 @@ pub fn features_from_csv(csv: &str) -> HashSet { .collect() } -/// Implementation for check_wasm, based on static analysis of the bytecode. -/// This is used for code upload, to perform check before compiling the Wasm. -pub fn required_features_from_module(module: &impl ExportInfo) -> HashSet { +pub fn required_features_from_wasmer_instance(wasmer_instance: &WasmerInstance) -> HashSet { + let module = wasmer_instance.module(); module - .exported_function_names(Some(REQUIRES_PREFIX)) - .into_iter() - .filter_map(|name| { - if name.len() > REQUIRES_PREFIX.len() { - let (_, required_feature) = name.split_at(REQUIRES_PREFIX.len()); - Some(required_feature.to_string()) - } else { - None + .exports() + .filter_map(|export| { + if let ExternType::Function { .. } = export.ty() { + let name = export.name(); + if name.starts_with(REQUIRES_PREFIX) && name.len() > REQUIRES_PREFIX.len() { + let required_feature = name.to_string().split_off(REQUIRES_PREFIX.len()); + return Some(required_feature); + } } + None }) .collect() } +/// Implementation for check_wasm, based on static analysis of the bytecode. +/// This is used for code upload, to perform check before compiling the Wasm. +pub fn required_features_from_module(module: &Module) -> HashSet { + match module.export_section() { + None => HashSet::new(), + Some(export_section) => export_section + .entries() + .iter() + .filter_map(|entry| { + if let Internal::Function(_) = entry.internal() { + let name = entry.field(); + if name.starts_with(REQUIRES_PREFIX) && name.len() > REQUIRES_PREFIX.len() { + let (_, required_feature) = name.split_at(REQUIRES_PREFIX.len()); + return Some(required_feature.to_string()); + } + } + None + }) + .collect(), + } +} + #[cfg(test)] mod tests { use super::*; - use crate::static_analysis::deserialize_wasm; + use parity_wasm::elements::deserialize_buffer; #[test] fn features_from_csv_works() { @@ -73,7 +95,7 @@ mod tests { )"#, ) .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_buffer(&wasm).unwrap(); let required_features = required_features_from_module(&module); assert_eq!(required_features.len(), 3); @@ -85,7 +107,7 @@ mod tests { #[test] fn required_features_from_module_works_without_exports_section() { let wasm = wat::parse_str(r#"(module)"#).unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); + let module = deserialize_buffer(&wasm).unwrap(); let required_features = required_features_from_module(&module); assert_eq!(required_features.len(), 0); } diff --git a/packages/vm/src/ibc_calls.rs b/packages/vm/src/ibc_calls.rs new file mode 100644 index 000000000..3c1cf1d21 --- /dev/null +++ b/packages/vm/src/ibc_calls.rs @@ -0,0 +1,349 @@ +#![cfg(feature = "stargate")] + +use cosmwasm_std::{ + ContractResult, Env, IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcPacket, + IbcReceiveResponse, +}; +use schemars::JsonSchema; +use serde::de::DeserializeOwned; +use std::fmt; + +use crate::backend::{BackendApi, Querier, Storage}; +use crate::calls::call_raw; +use crate::errors::VmResult; +use crate::instance::Instance; +use crate::serde::{from_slice, to_vec}; + +const MAX_LENGTH_IBC: usize = 100_000; + +pub fn call_ibc_channel_open( + instance: &mut Instance, + env: &Env, + channel: &IbcChannel, +) -> VmResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, +{ + let env = to_vec(env)?; + let channel = to_vec(channel)?; + let data = call_ibc_channel_open_raw(instance, &env, &channel)?; + let result: ContractResult<()> = from_slice(&data)?; + Ok(result) +} + +pub fn call_ibc_channel_connect( + instance: &mut Instance, + env: &Env, + channel: &IbcChannel, +) -> VmResult>> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, +{ + let env = to_vec(env)?; + let channel = to_vec(channel)?; + let data = call_ibc_channel_connect_raw(instance, &env, &channel)?; + let result = from_slice(&data)?; + Ok(result) +} + +pub fn call_ibc_channel_close( + instance: &mut Instance, + env: &Env, + channel: &IbcChannel, +) -> VmResult>> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, +{ + let env = to_vec(env)?; + let channel = to_vec(channel)?; + let data = call_ibc_channel_close_raw(instance, &env, &channel)?; + let result = from_slice(&data)?; + Ok(result) +} + +pub fn call_ibc_packet_receive( + instance: &mut Instance, + env: &Env, + packet: &IbcPacket, +) -> VmResult>> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, +{ + let env = to_vec(env)?; + let packet = to_vec(packet)?; + let data = call_ibc_packet_receive_raw(instance, &env, &packet)?; + let result = from_slice(&data)?; + Ok(result) +} + +pub fn call_ibc_packet_ack( + instance: &mut Instance, + env: &Env, + ack: &IbcAcknowledgement, +) -> VmResult>> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, +{ + let env = to_vec(env)?; + let ack = to_vec(ack)?; + let data = call_ibc_packet_ack_raw(instance, &env, &ack)?; + let result = from_slice(&data)?; + Ok(result) +} + +pub fn call_ibc_packet_timeout( + instance: &mut Instance, + env: &Env, + packet: &IbcPacket, +) -> VmResult>> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, +{ + let env = to_vec(env)?; + let packet = to_vec(packet)?; + let data = call_ibc_packet_timeout_raw(instance, &env, &packet)?; + let result = from_slice(&data)?; + Ok(result) +} + +pub fn call_ibc_channel_open_raw( + instance: &mut Instance, + env: &[u8], + channel: &[u8], +) -> VmResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, +{ + instance.set_storage_readonly(false); + call_raw( + instance, + "ibc_channel_open", + &[env, channel], + MAX_LENGTH_IBC, + ) +} + +pub fn call_ibc_channel_connect_raw( + instance: &mut Instance, + env: &[u8], + channel: &[u8], +) -> VmResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, +{ + instance.set_storage_readonly(false); + call_raw( + instance, + "ibc_channel_connect", + &[env, channel], + MAX_LENGTH_IBC, + ) +} + +pub fn call_ibc_channel_close_raw( + instance: &mut Instance, + env: &[u8], + channel: &[u8], +) -> VmResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, +{ + instance.set_storage_readonly(false); + call_raw( + instance, + "ibc_channel_close", + &[env, channel], + MAX_LENGTH_IBC, + ) +} + +pub fn call_ibc_packet_receive_raw( + instance: &mut Instance, + env: &[u8], + packet: &[u8], +) -> VmResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, +{ + instance.set_storage_readonly(false); + call_raw( + instance, + "ibc_packet_receive", + &[env, packet], + MAX_LENGTH_IBC, + ) +} + +pub fn call_ibc_packet_ack_raw( + instance: &mut Instance, + env: &[u8], + ack: &[u8], +) -> VmResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, +{ + instance.set_storage_readonly(false); + call_raw(instance, "ibc_packet_ack", &[env, ack], MAX_LENGTH_IBC) +} + +pub fn call_ibc_packet_timeout_raw( + instance: &mut Instance, + env: &[u8], + packet: &[u8], +) -> VmResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, +{ + instance.set_storage_readonly(false); + call_raw( + instance, + "ibc_packet_timeout", + &[env, packet], + MAX_LENGTH_IBC, + ) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::calls::{call_instantiate, call_reply}; + use crate::testing::{mock_env, mock_info, mock_instance, MockApi, MockQuerier, MockStorage}; + use cosmwasm_std::testing::{mock_ibc_channel, mock_ibc_packet_ack}; + use cosmwasm_std::{attr, Empty, Event, IbcOrder, Reply, SubcallResponse}; + + static CONTRACT: &[u8] = include_bytes!("../testdata/ibc_reflect.wasm"); + const IBC_VERSION: &str = "ibc-reflect-v1"; + + fn setup( + instance: &mut Instance, + channel_id: &str, + account: &str, + ) { + // init + let info = mock_info("creator", &[]); + let msg = br#"{"reflect_code_id":77}"#; + call_instantiate::<_, _, _, Empty>(instance, &mock_env(), &info, msg) + .unwrap() + .unwrap(); + + // first we try to open with a valid handshake + let mut handshake_open = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); + handshake_open.counterparty_version = None; + call_ibc_channel_open(instance, &mock_env(), &handshake_open) + .unwrap() + .unwrap(); + + // then we connect (with counter-party version set) + let handshake_connect = mock_ibc_channel(channel_id, IbcOrder::Ordered, IBC_VERSION); + let res: IbcBasicResponse = + call_ibc_channel_connect::<_, _, _, Empty>(instance, &mock_env(), &handshake_connect) + .unwrap() + .unwrap(); + assert_eq!(1, res.submessages.len()); + let id = res.submessages[0].id; + + let event = Event { + kind: "message".into(), + attributes: vec![attr("contract_address", &account)], + }; + // which creates a reflect account. here we get the callback + let response = Reply { + id, + result: ContractResult::Ok(SubcallResponse { + events: vec![event], + data: None, + }), + }; + call_reply::<_, _, _, Empty>(instance, &mock_env(), &response).unwrap(); + } + + const CHANNEL_ID: &str = "channel-123"; + const ACCOUNT: &str = "account-456"; + + #[test] + fn call_ibc_channel_open_and_connect_works() { + let mut instance = mock_instance(&CONTRACT, &[]); + + setup(&mut instance, CHANNEL_ID, ACCOUNT); + } + + #[test] + fn call_ibc_channel_close_works() { + let mut instance = mock_instance(&CONTRACT, &[]); + setup(&mut instance, CHANNEL_ID, ACCOUNT); + + let handshake_close = mock_ibc_channel(CHANNEL_ID, IbcOrder::Ordered, IBC_VERSION); + call_ibc_channel_close::<_, _, _, Empty>(&mut instance, &mock_env(), &handshake_close) + .unwrap() + .unwrap(); + } + + #[test] + fn call_ibc_packet_ack_works() { + let mut instance = mock_instance(&CONTRACT, &[]); + setup(&mut instance, CHANNEL_ID, ACCOUNT); + + let packet = mock_ibc_packet_ack(CHANNEL_ID, br#"{}"#).unwrap(); + let ack = IbcAcknowledgement { + acknowledgement: br#"{}"#.into(), + original_packet: packet, + }; + call_ibc_packet_ack::<_, _, _, Empty>(&mut instance, &mock_env(), &ack) + .unwrap() + .unwrap(); + } + + #[test] + fn call_ibc_packet_timeout_works() { + let mut instance = mock_instance(&CONTRACT, &[]); + setup(&mut instance, CHANNEL_ID, ACCOUNT); + + let packet = mock_ibc_packet_ack(CHANNEL_ID, br#"{}"#).unwrap(); + call_ibc_packet_timeout::<_, _, _, Empty>(&mut instance, &mock_env(), &packet) + .unwrap() + .unwrap(); + } + + #[test] + fn call_ibc_packet_receive_works() { + let mut instance = mock_instance(&CONTRACT, &[]); + + setup(&mut instance, CHANNEL_ID, ACCOUNT); + + let who_am_i = br#"{"who_am_i":{}}"#; + let packet = mock_ibc_packet_ack(CHANNEL_ID, who_am_i).unwrap(); + + call_ibc_packet_receive::<_, _, _, Empty>(&mut instance, &mock_env(), &packet) + .unwrap() + .unwrap(); + } +} diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 4e30e115d..a886d3750 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -8,7 +8,8 @@ use cosmwasm_crypto::{ sha1_calculate, CryptoError, }; use cosmwasm_crypto::{ - ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, EDDSA_PUBKEY_LEN, MESSAGE_HASH_MAX_LEN, + BATCH_MAX_LEN, ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, EDDSA_PUBKEY_LEN, INPUTS_MAX_CNT, + INPUT_MAX_LEN, MESSAGE_HASH_MAX_LEN, MESSAGE_MAX_LEN, }; #[cfg(feature = "iterator")] @@ -35,46 +36,155 @@ const MI: usize = 1024 * 1024; const MAX_LENGTH_DB_KEY: usize = 64 * KI; /// Max key length for db_write (i.e. when VM reads from Wasm memory) const MAX_LENGTH_DB_VALUE: usize = 128 * KI; -/// Typically 20 (Cosmos SDK, Ethereum), 32 (Nano, Substrate) or 54 (MockApi) -const MAX_LENGTH_CANONICAL_ADDRESS: usize = 64; -/// The max length of human address inputs (in bytes). -/// The maximum allowed size for [bech32](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32) -/// is 90 characters. -/// This value will increase with https://github.com/CosmWasm/cosmwasm/issues/1056. +/// Typically 20 (lbf-sdk, Cosmos SDK, Ethereum) or 32 (Nano, Substrate) +const MAX_LENGTH_CANONICAL_ADDRESS: usize = 32; +/// The maximum allowed size for bech32 (https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32) const MAX_LENGTH_HUMAN_ADDRESS: usize = 90; const MAX_LENGTH_QUERY_CHAIN_REQUEST: usize = 64 * KI; /// Length of a serialized Ed25519 signature const MAX_LENGTH_ED25519_SIGNATURE: usize = 64; -/// Max length of a Ed25519 message in bytes. -/// This is an arbitrary value, for performance / memory contraints. If you need to verify larger -/// messages, let us know. -const MAX_LENGTH_ED25519_MESSAGE: usize = 128 * 1024; -/// Max number of batch Ed25519 messages / signatures / public_keys. -/// This is an arbitrary value, for performance / memory contraints. If you need to batch-verify a -/// larger number of signatures, let us know. -const MAX_COUNT_ED25519_BATCH: usize = 256; -/// Max count of a inputs for sha1. -/// A limit is set to prevent malicious excessive input. -/// Now, we limit ourselves to only small sizes for use cases in Uuid. -pub const MAX_COUNT_SHA1_INPUT: usize = 4; -/// Max length of a input for sha1 -/// After executing the crypto bench according to this, -/// the gas factor is determined based on the result. -/// If you modify this value, you need to adjust the gas factor. -pub const MAX_LENGTH_SHA1_MESSAGE: usize = 80; /// Max length for a debug message const MAX_LENGTH_DEBUG: usize = 2 * MI; +// The block of native_* prefixed functions is tailored for Wasmer's +// Function::new_native_with_env interface. Those require an env in the first +// argument and cannot capiture other variables such as the Api. + +pub fn native_db_read( + env: &Environment, + key_ptr: u32, +) -> VmResult { + let ptr = do_read::(env, key_ptr)?; + Ok(ptr) +} + +pub fn native_db_write( + env: &Environment, + key_ptr: u32, + value_ptr: u32, +) -> VmResult<()> { + do_write(env, key_ptr, value_ptr) +} + +pub fn native_db_remove( + env: &Environment, + key_ptr: u32, +) -> VmResult<()> { + do_remove(env, key_ptr) +} + +pub fn native_addr_validate( + env: &Environment, + source_ptr: u32, +) -> VmResult { + do_addr_validate(&env, source_ptr) +} + +pub fn native_addr_canonicalize( + env: &Environment, + source_ptr: u32, + destination_ptr: u32, +) -> VmResult { + do_addr_canonicalize(&env, source_ptr, destination_ptr) +} + +pub fn native_addr_humanize( + env: &Environment, + source_ptr: u32, + destination_ptr: u32, +) -> VmResult { + do_addr_humanize(&env, source_ptr, destination_ptr) +} + +pub fn native_secp256k1_verify( + env: &Environment, + hash_ptr: u32, + signature_ptr: u32, + pubkey_ptr: u32, +) -> VmResult { + do_secp256k1_verify(env, hash_ptr, signature_ptr, pubkey_ptr) +} + +pub fn native_secp256k1_recover_pubkey( + env: &Environment, + hash_ptr: u32, + signature_ptr: u32, + recovery_param: u32, +) -> VmResult { + do_secp256k1_recover_pubkey(env, hash_ptr, signature_ptr, recovery_param) +} + +pub fn native_ed25519_verify( + env: &Environment, + message_ptr: u32, + signature_ptr: u32, + pubkey_ptr: u32, +) -> VmResult { + do_ed25519_verify(env, message_ptr, signature_ptr, pubkey_ptr) +} + +pub fn native_ed25519_batch_verify( + env: &Environment, + messages_ptr: u32, + signatures_ptr: u32, + pubkeys_ptr: u32, +) -> VmResult { + do_ed25519_batch_verify(env, messages_ptr, signatures_ptr, pubkeys_ptr) +} + +pub fn native_sha1_calculate( + env: &Environment, + hash_inputs_ptr: u32, +) -> VmResult { + do_sha1_calculate(env, hash_inputs_ptr) +} + +pub fn native_query_chain( + env: &Environment, + request_ptr: u32, +) -> VmResult { + do_query_chain(env, request_ptr) +} + +#[cfg(feature = "iterator")] +pub fn native_db_scan( + env: &Environment, + start_ptr: u32, + end_ptr: u32, + order: i32, +) -> VmResult { + do_scan(env, start_ptr, end_ptr, order) +} + +#[cfg(feature = "iterator")] +pub fn native_db_next( + env: &Environment, + iterator_id: u32, +) -> VmResult { + do_next(env, iterator_id) +} + +/// Prints a debug message to console. +/// This does not charge gas, so debug printing should be disabled when used in a blockchain module. +pub fn native_debug( + env: &Environment, + message_ptr: u32, +) -> VmResult<()> { + if env.print_debug { + let message_data = read_region(&env.memory(), message_ptr, MAX_LENGTH_DEBUG)?; + let msg = String::from_utf8_lossy(&message_data); + println!("{}", msg); + } + Ok(()) +} + +// // Import implementations // -// This block of do_* prefixed functions is tailored for Wasmer's -// Function::new_native_with_env interface. Those require an env in the first -// argument and cannot capture other variables. Thus everything is accessed -// through the env. /// Reads a storage entry from the VM's storage into Wasm memory -pub fn do_db_read( +fn do_read( env: &Environment, key_ptr: u32, ) -> VmResult { @@ -92,7 +202,7 @@ pub fn do_db_read( } /// Writes a storage entry from Wasm memory into the VM's storage -pub fn do_db_write( +fn do_write( env: &Environment, key_ptr: u32, value_ptr: u32, @@ -112,7 +222,7 @@ pub fn do_db_write( Ok(()) } -pub fn do_db_remove( +fn do_remove( env: &Environment, key_ptr: u32, ) -> VmResult<()> { @@ -130,7 +240,7 @@ pub fn do_db_remove( Ok(()) } -pub fn do_addr_validate( +fn do_addr_validate( env: &Environment, source_ptr: u32, ) -> VmResult { @@ -155,7 +265,7 @@ pub fn do_addr_validate( } } -pub fn do_addr_canonicalize( +fn do_addr_canonicalize( env: &Environment, source_ptr: u32, destination_ptr: u32, @@ -184,7 +294,7 @@ pub fn do_addr_canonicalize( } } -pub fn do_addr_humanize( +fn do_addr_humanize( env: &Environment, source_ptr: u32, destination_ptr: u32, @@ -205,7 +315,7 @@ pub fn do_addr_humanize( } } -pub fn do_secp256k1_verify( +fn do_secp256k1_verify( env: &Environment, hash_ptr: u32, signature_ptr: u32, @@ -226,6 +336,7 @@ pub fn do_secp256k1_verify( | CryptoError::GenericErr { .. } => err.code(), CryptoError::BatchErr { .. } | CryptoError::InvalidRecoveryParam { .. } + | CryptoError::MessageTooLong { .. } | CryptoError::InputsTooLarger { .. } | CryptoError::InputTooLong { .. } => panic!("Error must not happen for this call"), }, @@ -233,7 +344,7 @@ pub fn do_secp256k1_verify( )) } -pub fn do_secp256k1_recover_pubkey( +fn do_secp256k1_recover_pubkey( env: &Environment, hash_ptr: u32, signature_ptr: u32, @@ -261,19 +372,20 @@ pub fn do_secp256k1_recover_pubkey( | CryptoError::GenericErr { .. } => Ok(to_high_half(err.code())), CryptoError::BatchErr { .. } | CryptoError::InvalidPubkeyFormat { .. } + | CryptoError::MessageTooLong { .. } | CryptoError::InputsTooLarger { .. } | CryptoError::InputTooLong { .. } => panic!("Error must not happen for this call"), }, } } -pub fn do_ed25519_verify( +fn do_ed25519_verify( env: &Environment, message_ptr: u32, signature_ptr: u32, pubkey_ptr: u32, ) -> VmResult { - let message = read_region(&env.memory(), message_ptr, MAX_LENGTH_ED25519_MESSAGE)?; + let message = read_region(&env.memory(), message_ptr, MESSAGE_MAX_LEN)?; let signature = read_region(&env.memory(), signature_ptr, MAX_LENGTH_ED25519_SIGNATURE)?; let pubkey = read_region(&env.memory(), pubkey_ptr, EDDSA_PUBKEY_LEN)?; @@ -282,7 +394,8 @@ pub fn do_ed25519_verify( process_gas_info::(env, gas_info)?; Ok(result.map_or_else( |err| match err { - CryptoError::InvalidPubkeyFormat { .. } + CryptoError::MessageTooLong { .. } + | CryptoError::InvalidPubkeyFormat { .. } | CryptoError::InvalidSignatureFormat { .. } | CryptoError::GenericErr { .. } => err.code(), CryptoError::BatchErr { .. } @@ -295,7 +408,7 @@ pub fn do_ed25519_verify( )) } -pub fn do_ed25519_batch_verify( +fn do_ed25519_batch_verify( env: &Environment, messages_ptr: u32, signatures_ptr: u32, @@ -304,17 +417,17 @@ pub fn do_ed25519_batch_verify( let messages = read_region( &env.memory(), messages_ptr, - (MAX_LENGTH_ED25519_MESSAGE + 4) * MAX_COUNT_ED25519_BATCH, + (MESSAGE_MAX_LEN + 4) * BATCH_MAX_LEN, )?; let signatures = read_region( &env.memory(), signatures_ptr, - (MAX_LENGTH_ED25519_SIGNATURE + 4) * MAX_COUNT_ED25519_BATCH, + (MAX_LENGTH_ED25519_SIGNATURE + 4) * BATCH_MAX_LEN, )?; let public_keys = read_region( &env.memory(), public_keys_ptr, - (EDDSA_PUBKEY_LEN + 4) * MAX_COUNT_ED25519_BATCH, + (EDDSA_PUBKEY_LEN + 4) * BATCH_MAX_LEN, )?; let messages = decode_sections(&messages); @@ -332,6 +445,7 @@ pub fn do_ed25519_batch_verify( Ok(result.map_or_else( |err| match err { CryptoError::BatchErr { .. } + | CryptoError::MessageTooLong { .. } | CryptoError::InvalidPubkeyFormat { .. } | CryptoError::InvalidSignatureFormat { .. } | CryptoError::GenericErr { .. } => err.code(), @@ -351,7 +465,7 @@ pub fn do_sha1_calculate( let hash_inputs = read_region( &env.memory(), hash_inputs_ptr, - (MAX_LENGTH_SHA1_MESSAGE + 4) * MAX_COUNT_SHA1_INPUT, + (INPUT_MAX_LEN + 4) * INPUTS_MAX_CNT, )?; let hash_inputs = decode_sections(&hash_inputs); @@ -373,6 +487,7 @@ pub fn do_sha1_calculate( Ok(to_high_half(err.code())) } CryptoError::BatchErr { .. } + | CryptoError::MessageTooLong { .. } | CryptoError::InvalidPubkeyFormat { .. } | CryptoError::InvalidSignatureFormat { .. } | CryptoError::GenericErr { .. } @@ -384,20 +499,6 @@ pub fn do_sha1_calculate( } } -/// Prints a debug message to console. -/// This does not charge gas, so debug printing should be disabled when used in a blockchain module. -pub fn do_debug( - env: &Environment, - message_ptr: u32, -) -> VmResult<()> { - if env.print_debug { - let message_data = read_region(&env.memory(), message_ptr, MAX_LENGTH_DEBUG)?; - let msg = String::from_utf8_lossy(&message_data); - println!("{}", msg); - } - Ok(()) -} - /// Creates a Region in the contract, writes the given data to it and returns the memory location fn write_to_contract( env: &Environment, @@ -413,7 +514,7 @@ fn write_to_contract( Ok(target_ptr) } -pub fn do_query_chain( +fn do_query_chain( env: &Environment, request_ptr: u32, ) -> VmResult { @@ -429,7 +530,7 @@ pub fn do_query_chain( } #[cfg(feature = "iterator")] -pub fn do_db_scan( +fn do_scan( env: &Environment, start_ptr: u32, end_ptr: u32, @@ -450,7 +551,7 @@ pub fn do_db_scan( } #[cfg(feature = "iterator")] -pub fn do_db_next( +fn do_next( env: &Environment, iterator_id: u32, ) -> VmResult { @@ -535,26 +636,26 @@ mod tests { let gas_limit = TESTING_GAS_LIMIT; let env = Environment::new(api, gas_limit, false); - let module = compile(CONTRACT, TESTING_MEMORY_LIMIT).unwrap(); + let module = compile(&CONTRACT, TESTING_MEMORY_LIMIT).unwrap(); let store = module.store(); // we need stubs for all required imports let import_obj = imports! { "env" => { - "db_read" => Function::new_native(store, |_a: u32| -> u32 { 0 }), - "db_write" => Function::new_native(store, |_a: u32, _b: u32| {}), - "db_remove" => Function::new_native(store, |_a: u32| {}), - "db_scan" => Function::new_native(store, |_a: u32, _b: u32, _c: i32| -> u32 { 0 }), - "db_next" => Function::new_native(store, |_a: u32| -> u32 { 0 }), - "query_chain" => Function::new_native(store, |_a: u32| -> u32 { 0 }), - "addr_validate" => Function::new_native(store, |_a: u32| -> u32 { 0 }), - "addr_canonicalize" => Function::new_native(store, |_a: u32, _b: u32| -> u32 { 0 }), - "addr_humanize" => Function::new_native(store, |_a: u32, _b: u32| -> u32 { 0 }), - "secp256k1_verify" => Function::new_native(store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), - "secp256k1_recover_pubkey" => Function::new_native(store, |_a: u32, _b: u32, _c: u32| -> u64 { 0 }), - "ed25519_verify" => Function::new_native(store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), - "ed25519_batch_verify" => Function::new_native(store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), - "sha1_calculate" => Function::new_native(store, |_a: u32| -> u64 { 0 }), - "debug" => Function::new_native(store, |_a: u32| {}), + "db_read" => Function::new_native(&store, |_a: u32| -> u32 { 0 }), + "db_write" => Function::new_native(&store, |_a: u32, _b: u32| {}), + "db_remove" => Function::new_native(&store, |_a: u32| {}), + "db_scan" => Function::new_native(&store, |_a: u32, _b: u32, _c: i32| -> u32 { 0 }), + "db_next" => Function::new_native(&store, |_a: u32| -> u32 { 0 }), + "query_chain" => Function::new_native(&store, |_a: u32| -> u32 { 0 }), + "addr_validate" => Function::new_native(&store, |_a: u32| -> u32 { 0 }), + "addr_canonicalize" => Function::new_native(&store, |_a: u32, _b: u32| -> u32 { 0 }), + "addr_humanize" => Function::new_native(&store, |_a: u32, _b: u32| -> u32 { 0 }), + "secp256k1_verify" => Function::new_native(&store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), + "secp256k1_recover_pubkey" => Function::new_native(&store, |_a: u32, _b: u32, _c: u32| -> u64 { 0 }), + "ed25519_verify" => Function::new_native(&store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), + "ed25519_batch_verify" => Function::new_native(&store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }), + "sha1_calculate" => Function::new_native(&store, |_a: u32| -> u64 { 0 }), + "debug" => Function::new_native(&store, |_a: u32| {}), }, }; let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); @@ -606,37 +707,37 @@ mod tests { } #[test] - fn do_db_read_works() { + fn do_read_works() { let api = MockApi::default(); let (env, _instance) = make_instance(api); leave_default_data(&env); let key_ptr = write_data(&env, KEY1); - let result = do_db_read(&env, key_ptr); + let result = do_read(&env, key_ptr); let value_ptr = result.unwrap(); assert!(value_ptr > 0); assert_eq!(force_read(&env, value_ptr as u32), VALUE1); } #[test] - fn do_db_read_works_for_non_existent_key() { + fn do_read_works_for_non_existent_key() { let api = MockApi::default(); let (env, _instance) = make_instance(api); leave_default_data(&env); let key_ptr = write_data(&env, b"I do not exist in storage"); - let result = do_db_read(&env, key_ptr); + let result = do_read(&env, key_ptr); assert_eq!(result.unwrap(), 0); } #[test] - fn do_db_read_fails_for_large_key() { + fn do_read_fails_for_large_key() { let api = MockApi::default(); let (env, _instance) = make_instance(api); leave_default_data(&env); let key_ptr = write_data(&env, &vec![7u8; 300 * 1024]); - let result = do_db_read(&env, key_ptr); + let result = do_read(&env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionLengthTooBig { length, .. }, @@ -647,7 +748,7 @@ mod tests { } #[test] - fn do_db_write_works() { + fn do_write_works() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -656,7 +757,7 @@ mod tests { leave_default_data(&env); - do_db_write(&env, key_ptr, value_ptr).unwrap(); + do_write(&env, key_ptr, value_ptr).unwrap(); let val = env .with_storage_from_context::<_, _>(|store| { @@ -670,7 +771,7 @@ mod tests { } #[test] - fn do_db_write_can_override() { + fn do_write_can_override() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -679,7 +780,7 @@ mod tests { leave_default_data(&env); - do_db_write(&env, key_ptr, value_ptr).unwrap(); + do_write(&env, key_ptr, value_ptr).unwrap(); let val = env .with_storage_from_context::<_, _>(|store| { @@ -690,7 +791,7 @@ mod tests { } #[test] - fn do_db_write_works_for_empty_value() { + fn do_write_works_for_empty_value() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -699,7 +800,7 @@ mod tests { leave_default_data(&env); - do_db_write(&env, key_ptr, value_ptr).unwrap(); + do_write(&env, key_ptr, value_ptr).unwrap(); let val = env .with_storage_from_context::<_, _>(|store| { @@ -713,7 +814,7 @@ mod tests { } #[test] - fn do_db_write_fails_for_large_key() { + fn do_write_fails_for_large_key() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -722,7 +823,7 @@ mod tests { leave_default_data(&env); - let result = do_db_write(&env, key_ptr, value_ptr); + let result = do_write(&env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -739,7 +840,7 @@ mod tests { } #[test] - fn do_db_write_fails_for_large_value() { + fn do_write_fails_for_large_value() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -748,7 +849,7 @@ mod tests { leave_default_data(&env); - let result = do_db_write(&env, key_ptr, value_ptr); + let result = do_write(&env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -765,7 +866,7 @@ mod tests { } #[test] - fn do_db_write_is_prohibited_in_readonly_contexts() { + fn do_write_is_prohibited_in_readonly_contexts() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -775,7 +876,7 @@ mod tests { leave_default_data(&env); env.set_storage_readonly(true); - let result = do_db_write(&env, key_ptr, value_ptr); + let result = do_write(&env, key_ptr, value_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -783,7 +884,7 @@ mod tests { } #[test] - fn do_db_remove_works() { + fn do_remove_works() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -798,7 +899,7 @@ mod tests { }) .unwrap(); - do_db_remove(&env, key_ptr).unwrap(); + do_remove(&env, key_ptr).unwrap(); env.with_storage_from_context::<_, _>(|store| { println!("{:?}", store); @@ -815,7 +916,7 @@ mod tests { } #[test] - fn do_db_remove_works_for_non_existent_key() { + fn do_remove_works_for_non_existent_key() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -825,7 +926,7 @@ mod tests { leave_default_data(&env); // Note: right now we cannot differnetiate between an existent and a non-existent key - do_db_remove(&env, key_ptr).unwrap(); + do_remove(&env, key_ptr).unwrap(); let value = env .with_storage_from_context::<_, _>(|store| { @@ -836,7 +937,7 @@ mod tests { } #[test] - fn do_db_remove_fails_for_large_key() { + fn do_remove_fails_for_large_key() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -844,7 +945,7 @@ mod tests { leave_default_data(&env); - let result = do_db_remove(&env, key_ptr); + let result = do_remove(&env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -861,7 +962,7 @@ mod tests { } #[test] - fn do_db_remove_is_prohibited_in_readonly_contexts() { + fn do_remove_is_prohibited_in_readonly_contexts() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -870,7 +971,7 @@ mod tests { leave_default_data(&env); env.set_storage_readonly(true); - let result = do_db_remove(&env, key_ptr); + let result = do_remove(&env, key_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -897,7 +998,7 @@ mod tests { let source_ptr1 = write_data(&env, b"fo\x80o"); // invalid UTF-8 (fo�o) let source_ptr2 = write_data(&env, b""); // empty - let source_ptr3 = write_data(&env, b"addressexceedingaddressspacesuperlongreallylongiamensuringthatitislongerthaneverything"); // too long + let source_ptr3 = write_data(&env, b"addressexceedingaddressspace"); // too long leave_default_data(&env); @@ -970,7 +1071,7 @@ mod tests { let api = MockApi::default(); let source_ptr = write_data(&env, b"foo"); - let dest_ptr = create_empty(&mut instance, api.canonical_length() as u32); + let dest_ptr = create_empty(&mut instance, api.canonical_length as u32); leave_default_data(&env); @@ -978,7 +1079,7 @@ mod tests { let res = do_addr_canonicalize(&env, source_ptr, dest_ptr).unwrap(); assert_eq!(res, 0); let data = force_read(&env, dest_ptr); - assert_eq!(data.len(), api.canonical_length()); + assert_eq!(data.len(), api.canonical_length); } #[test] @@ -988,8 +1089,8 @@ mod tests { let source_ptr1 = write_data(&env, b"fo\x80o"); // invalid UTF-8 (fo�o) let source_ptr2 = write_data(&env, b""); // empty - let source_ptr3 = write_data(&env, b"addressexceedingaddressspacesuperlongreallylongiamensuringthatitislongerthaneverything"); // too long - let dest_ptr = create_empty(&mut instance, 70); + let source_ptr3 = write_data(&env, b"addressexceedingaddressspace"); // too long + let dest_ptr = create_empty(&mut instance, 8); leave_default_data(&env); @@ -1074,7 +1175,7 @@ mod tests { .. } => { assert_eq!(size, 7); - assert_eq!(required, api.canonical_length()); + assert_eq!(required, api.canonical_length); } err => panic!("Incorrect error returned: {:?}", err), } @@ -1086,9 +1187,9 @@ mod tests { let (env, mut instance) = make_instance(api); let api = MockApi::default(); - let source_data = vec![0x22; api.canonical_length()]; + let source_data = vec![0x22; api.canonical_length]; let source_ptr = write_data(&env, &source_data); - let dest_ptr = create_empty(&mut instance, 70); + let dest_ptr = create_empty(&mut instance, 50); leave_default_data(&env); @@ -1103,7 +1204,7 @@ mod tests { let (env, mut instance) = make_instance(api); let source_ptr = write_data(&env, b"foo"); // too short - let dest_ptr = create_empty(&mut instance, 70); + let dest_ptr = create_empty(&mut instance, 50); leave_default_data(&env); @@ -1119,7 +1220,7 @@ mod tests { let (env, mut instance) = make_instance(api); let source_ptr = write_data(&env, b"foo\0\0\0\0\0"); - let dest_ptr = create_empty(&mut instance, 70); + let dest_ptr = create_empty(&mut instance, 50); leave_default_data(&env); @@ -1138,8 +1239,8 @@ mod tests { let api = MockApi::default(); let (env, mut instance) = make_instance(api); - let source_ptr = write_data(&env, &[61; 65]); - let dest_ptr = create_empty(&mut instance, 70); + let source_ptr = write_data(&env, &[61; 33]); + let dest_ptr = create_empty(&mut instance, 50); leave_default_data(&env); @@ -1152,8 +1253,8 @@ mod tests { }, .. } => { - assert_eq!(length, 65); - assert_eq!(max_length, 64); + assert_eq!(length, 33); + assert_eq!(max_length, 32); } err => panic!("Incorrect error returned: {:?}", err), } @@ -1165,7 +1266,7 @@ mod tests { let (env, mut instance) = make_instance(api); let api = MockApi::default(); - let source_data = vec![0x22; api.canonical_length()]; + let source_data = vec![0x22; api.canonical_length]; let source_ptr = write_data(&env, &source_data); let dest_ptr = create_empty(&mut instance, 2); @@ -1178,7 +1279,7 @@ mod tests { .. } => { assert_eq!(size, 2); - assert_eq!(required, api.canonical_length()); + assert_eq!(required, api.canonical_length); } err => panic!("Incorrect error returned: {:?}", err), } @@ -1515,7 +1616,7 @@ mod tests { let mut msg = hex::decode(EDDSA_MSG_HEX).unwrap(); // extend / break msg - msg.extend_from_slice(&[0x00; MAX_LENGTH_ED25519_MESSAGE + 1]); + msg.extend_from_slice(&[0x00; MESSAGE_MAX_LEN + 1]); let msg_ptr = write_data(&env, &msg); let sig = hex::decode(EDDSA_SIG_HEX).unwrap(); let sig_ptr = write_data(&env, &sig); @@ -1774,13 +1875,13 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn do_db_scan_unbound_works() { + fn do_scan_unbound_works() { let api = MockApi::default(); let (env, _instance) = make_instance(api); leave_default_data(&env); // set up iterator over all space - let id = do_db_scan(&env, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan(&env, 0, 0, Order::Ascending.into()).unwrap(); assert_eq!(1, id); let item = env @@ -1801,13 +1902,13 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn do_db_scan_unbound_descending_works() { + fn do_scan_unbound_descending_works() { let api = MockApi::default(); let (env, _instance) = make_instance(api); leave_default_data(&env); // set up iterator over all space - let id = do_db_scan(&env, 0, 0, Order::Descending.into()).unwrap(); + let id = do_scan(&env, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(1, id); let item = env @@ -1828,7 +1929,7 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn do_db_scan_bound_works() { + fn do_scan_bound_works() { let api = MockApi::default(); let (env, _instance) = make_instance(api); @@ -1837,7 +1938,7 @@ mod tests { leave_default_data(&env); - let id = do_db_scan(&env, start, end, Order::Ascending.into()).unwrap(); + let id = do_scan(&env, start, end, Order::Ascending.into()).unwrap(); let item = env .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) @@ -1852,14 +1953,14 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn do_db_scan_multiple_iterators() { + fn do_scan_multiple_iterators() { let api = MockApi::default(); let (env, _instance) = make_instance(api); leave_default_data(&env); // unbounded, ascending and descending - let id1 = do_db_scan(&env, 0, 0, Order::Ascending.into()).unwrap(); - let id2 = do_db_scan(&env, 0, 0, Order::Descending.into()).unwrap(); + let id1 = do_scan(&env, 0, 0, Order::Ascending.into()).unwrap(); + let id2 = do_scan(&env, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(id1, 1); assert_eq!(id2, 2); @@ -1896,13 +1997,13 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn do_db_scan_errors_for_invalid_order_value() { + fn do_scan_errors_for_invalid_order_value() { let api = MockApi::default(); let (env, _instance) = make_instance(api); leave_default_data(&env); // set up iterator over all space - let result = do_db_scan(&env, 0, 0, 42); + let result = do_scan(&env, 0, 0, 42); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::InvalidOrder { .. }, @@ -1914,44 +2015,44 @@ mod tests { #[test] #[cfg(feature = "iterator")] - fn do_db_next_works() { + fn do_next_works() { let api = MockApi::default(); let (env, _instance) = make_instance(api); leave_default_data(&env); - let id = do_db_scan(&env, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan(&env, 0, 0, Order::Ascending.into()).unwrap(); // Entry 1 - let kv_region_ptr = do_db_next(&env, id).unwrap(); + let kv_region_ptr = do_next(&env, id).unwrap(); assert_eq!( force_read(&env, kv_region_ptr), [KEY1, b"\0\0\0\x03", VALUE1, b"\0\0\0\x06"].concat() ); // Entry 2 - let kv_region_ptr = do_db_next(&env, id).unwrap(); + let kv_region_ptr = do_next(&env, id).unwrap(); assert_eq!( force_read(&env, kv_region_ptr), [KEY2, b"\0\0\0\x04", VALUE2, b"\0\0\0\x05"].concat() ); // End - let kv_region_ptr = do_db_next(&env, id).unwrap(); + let kv_region_ptr = do_next(&env, id).unwrap(); assert_eq!(force_read(&env, kv_region_ptr), b"\0\0\0\0\0\0\0\0"); // API makes no guarantees for value_ptr in this case } #[test] #[cfg(feature = "iterator")] - fn do_db_next_fails_for_non_existent_id() { + fn do_next_fails_for_non_existent_id() { let api = MockApi::default(); let (env, _instance) = make_instance(api); leave_default_data(&env); let non_existent_id = 42u32; - let result = do_db_next(&env, non_existent_id); + let result = do_next(&env, non_existent_id); match result.unwrap_err() { VmError::BackendErr { source: BackendError::IteratorDoesNotExist { id, .. }, diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 1a676b612..05419abc2 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -7,14 +7,15 @@ use crate::backend::{Backend, BackendApi, Querier, Storage}; use crate::conversion::{ref_to_u32, to_u32}; use crate::environment::Environment; use crate::errors::{CommunicationError, VmError, VmResult}; -use crate::features::required_features_from_module; +use crate::features::required_features_from_wasmer_instance; use crate::imports::{ - do_addr_canonicalize, do_addr_humanize, do_addr_validate, do_db_read, do_db_remove, - do_db_write, do_debug, do_ed25519_batch_verify, do_ed25519_verify, do_query_chain, - do_secp256k1_recover_pubkey, do_secp256k1_verify, do_sha1_calculate, + native_addr_canonicalize, native_addr_humanize, native_addr_validate, native_db_read, + native_db_remove, native_db_write, native_debug, native_ed25519_batch_verify, + native_ed25519_verify, native_query_chain, native_secp256k1_recover_pubkey, + native_secp256k1_verify, native_sha1_calculate, }; #[cfg(feature = "iterator")] -use crate::imports::{do_db_next, do_db_scan}; +use crate::imports::{native_db_next, native_db_scan}; use crate::memory::{read_region, write_region}; use crate::size::Size; use crate::wasm_backend::compile; @@ -46,6 +47,7 @@ pub struct Instance { /// This instance should only be accessed via the Environment, which provides safe access. _inner: Box, env: Environment, + pub required_features: HashSet, } impl Instance @@ -85,14 +87,14 @@ where // Ownership of the value pointer is transferred to the contract. env_imports.insert( "db_read", - Function::new_native_with_env(store, env.clone(), do_db_read), + Function::new_native_with_env(store, env.clone(), native_db_read), ); // Writes the given value into the database entry at the given key. // Ownership of both input and output pointer is not transferred to the host. env_imports.insert( "db_write", - Function::new_native_with_env(store, env.clone(), do_db_write), + Function::new_native_with_env(store, env.clone(), native_db_write), ); // Removes the value at the given key. Different than writing &[] as future @@ -101,7 +103,7 @@ where // Ownership of both key pointer is not transferred to the host. env_imports.insert( "db_remove", - Function::new_native_with_env(store, env.clone(), do_db_remove), + Function::new_native_with_env(store, env.clone(), native_db_remove), ); // Reads human address from source_ptr and checks if it is valid. @@ -109,7 +111,7 @@ where // Ownership of the input pointer is not transferred to the host. env_imports.insert( "addr_validate", - Function::new_native_with_env(store, env.clone(), do_addr_validate), + Function::new_native_with_env(store, env.clone(), native_addr_validate), ); // Reads human address from source_ptr and writes canonicalized representation to destination_ptr. @@ -118,7 +120,7 @@ where // Ownership of both input and output pointer is not transferred to the host. env_imports.insert( "addr_canonicalize", - Function::new_native_with_env(store, env.clone(), do_addr_canonicalize), + Function::new_native_with_env(store, env.clone(), native_addr_canonicalize), ); // Reads canonical address from source_ptr and writes humanized representation to destination_ptr. @@ -127,7 +129,7 @@ where // Ownership of both input and output pointer is not transferred to the host. env_imports.insert( "addr_humanize", - Function::new_native_with_env(store, env.clone(), do_addr_humanize), + Function::new_native_with_env(store, env.clone(), native_addr_humanize), ); // Verifies message hashes against a signature with a public key, using the secp256k1 ECDSA parametrization. @@ -135,12 +137,12 @@ where // Ownership of input pointers is not transferred to the host. env_imports.insert( "secp256k1_verify", - Function::new_native_with_env(store, env.clone(), do_secp256k1_verify), + Function::new_native_with_env(store, env.clone(), native_secp256k1_verify), ); env_imports.insert( "secp256k1_recover_pubkey", - Function::new_native_with_env(store, env.clone(), do_secp256k1_recover_pubkey), + Function::new_native_with_env(store, env.clone(), native_secp256k1_recover_pubkey), ); // Verifies a message against a signature with a public key, using the ed25519 EdDSA scheme. @@ -148,7 +150,7 @@ where // Ownership of input pointers is not transferred to the host. env_imports.insert( "ed25519_verify", - Function::new_native_with_env(store, env.clone(), do_ed25519_verify), + Function::new_native_with_env(store, env.clone(), native_ed25519_verify), ); // Verifies a batch of messages against a batch of signatures with a batch of public keys, @@ -158,7 +160,7 @@ where // Ownership of input pointers is not transferred to the host. env_imports.insert( "ed25519_batch_verify", - Function::new_native_with_env(store, env.clone(), do_ed25519_batch_verify), + Function::new_native_with_env(store, env.clone(), native_ed25519_batch_verify), ); // Calculates the inputs using the sha1 @@ -167,7 +169,7 @@ where // Ownership of the hash pointer is transferred to the contract. env_imports.insert( "sha1_calculate", - Function::new_native_with_env(store, env.clone(), do_sha1_calculate), + Function::new_native_with_env(store, env.clone(), native_sha1_calculate), ); // Allows the contract to emit debug logs that the host can either process or ignore. @@ -176,12 +178,12 @@ where // Ownership of both input and output pointer is not transferred to the host. env_imports.insert( "debug", - Function::new_native_with_env(store, env.clone(), do_debug), + Function::new_native_with_env(store, env.clone(), native_debug), ); env_imports.insert( "query_chain", - Function::new_native_with_env(store, env.clone(), do_query_chain), + Function::new_native_with_env(store, env.clone(), native_query_chain), ); // Creates an iterator that will go from start to end. @@ -193,7 +195,7 @@ where #[cfg(feature = "iterator")] env_imports.insert( "db_scan", - Function::new_native_with_env(store, env.clone(), do_db_scan), + Function::new_native_with_env(store, env.clone(), native_db_scan), ); // Get next element of iterator with ID `iterator_id`. @@ -204,7 +206,7 @@ where #[cfg(feature = "iterator")] env_imports.insert( "db_next", - Function::new_native_with_env(store, env.clone(), do_db_next), + Function::new_native_with_env(store, env.clone(), native_db_next), ); import_obj.register("env", env_imports); @@ -215,6 +217,7 @@ where }, )?); + let required_features = required_features_from_wasmer_instance(wasmer_instance.as_ref()); let instance_ptr = NonNull::from(wasmer_instance.as_ref()); env.set_wasmer_instance(Some(instance_ptr)); env.set_gas_left(gas_limit); @@ -222,6 +225,7 @@ where let instance = Instance { _inner: wasmer_instance, env, + required_features, }; Ok(instance) } @@ -245,15 +249,6 @@ where } } - /// Returns the features required by this contract. - /// - /// This is not needed for production because we can do static analysis - /// on the Wasm file before instatiation to obtain this information. It's - /// only kept because it can be handy for integration testing. - pub fn required_features(&self) -> HashSet { - required_features_from_module(self._inner.module()) - } - /// Returns the size of the default memory in pages. /// This provides a rough idea of the peak memory consumption. Note that /// Wasm memory always grows in 64 KiB steps (pages) and can never shrink @@ -372,7 +367,7 @@ mod tests { let (instance_options, memory_limit) = mock_instance_options(); let instance = Instance::from_code(CONTRACT, backend, instance_options, memory_limit).unwrap(); - assert_eq!(instance.required_features().len(), 0); + assert_eq!(instance.required_features.len(), 0); } #[test] @@ -394,24 +389,24 @@ mod tests { let backend = mock_backend(&[]); let (instance_options, memory_limit) = mock_instance_options(); let instance = Instance::from_code(&wasm, backend, instance_options, memory_limit).unwrap(); - assert_eq!(instance.required_features().len(), 3); - assert!(instance.required_features().contains("nutrients")); - assert!(instance.required_features().contains("sun")); - assert!(instance.required_features().contains("water")); + assert_eq!(instance.required_features.len(), 3); + assert!(instance.required_features.contains("nutrients")); + assert!(instance.required_features.contains("sun")); + assert!(instance.required_features.contains("water")); } #[test] fn call_function0_works() { - let instance = mock_instance(CONTRACT, &[]); + let instance = mock_instance(&CONTRACT, &[]); instance - .call_function0("interface_version_7", &[]) + .call_function0("interface_version_5", &[]) .expect("error calling function"); } #[test] fn call_function1_works() { - let instance = mock_instance(CONTRACT, &[]); + let instance = mock_instance(&CONTRACT, &[]); // can call function few times let result = instance @@ -433,7 +428,7 @@ mod tests { #[test] fn allocate_deallocate_works() { let mut instance = mock_instance_with_options( - CONTRACT, + &CONTRACT, MockInstanceOptions { memory_limit: Some(Size::mebi(500)), ..Default::default() @@ -460,7 +455,7 @@ mod tests { #[test] fn write_and_read_memory_works() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); let sizes: Vec = vec![ 0, @@ -493,7 +488,7 @@ mod tests { fn errors_in_imports() { // set up an instance that will experience an error in an import let error_message = "Api failed intentionally"; - let mut instance = mock_instance_with_failing_api(CONTRACT, &[], error_message); + let mut instance = mock_instance_with_failing_api(&CONTRACT, &[], error_message); let init_result = call_instantiate::<_, _, _, serde_json::Value>( &mut instance, &mock_env(), @@ -511,7 +506,7 @@ mod tests { fn read_memory_errors_when_when_length_is_too_long() { let length = 6; let max_length = 5; - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); // Allocate sets length to 0. Write some data to increase length. let region_ptr = instance.allocate(length).expect("error allocating"); @@ -548,7 +543,7 @@ mod tests { (type (func)) (func (type 0) nop) - (export "interface_version_7" (func 0)) + (export "interface_version_5" (func 0)) (export "instantiate" (func 0)) (export "allocate" (func 0)) (export "deallocate" (func 0)) @@ -566,7 +561,7 @@ mod tests { (type (func)) (func (type 0) nop) - (export "interface_version_7" (func 0)) + (export "interface_version_5" (func 0)) (export "instantiate" (func 0)) (export "allocate" (func 0)) (export "deallocate" (func 0)) @@ -579,7 +574,7 @@ mod tests { #[test] fn memory_pages_grows_with_usage() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); assert_eq!(instance.memory_pages(), 17); @@ -595,7 +590,7 @@ mod tests { #[test] fn get_gas_left_works() { - let instance = mock_instance_with_gas_limit(CONTRACT, 123321); + let instance = mock_instance_with_gas_limit(&CONTRACT, 123321); let orig_gas = instance.get_gas_left(); assert_eq!(orig_gas, 123321); } @@ -603,7 +598,7 @@ mod tests { #[test] fn create_gas_report_works() { const LIMIT: u64 = 7_000_000; - let mut instance = mock_instance_with_gas_limit(CONTRACT, LIMIT); + let mut instance = mock_instance_with_gas_limit(&CONTRACT, LIMIT); let report1 = instance.create_gas_report(); assert_eq!(report1.used_externally, 0); @@ -620,7 +615,7 @@ mod tests { let report2 = instance.create_gas_report(); assert_eq!(report2.used_externally, 73); - assert_eq!(report2.used_internally, 36378); + assert_eq!(report2.used_internally, 38804); assert_eq!(report2.limit, LIMIT); assert_eq!( report2.remaining, @@ -630,23 +625,23 @@ mod tests { #[test] fn set_storage_readonly_works() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); - assert!(instance.env.is_storage_readonly()); + assert_eq!(instance.env.is_storage_readonly(), true); instance.set_storage_readonly(false); - assert!(!instance.env.is_storage_readonly()); + assert_eq!(instance.env.is_storage_readonly(), false); instance.set_storage_readonly(false); - assert!(!instance.env.is_storage_readonly()); + assert_eq!(instance.env.is_storage_readonly(), false); instance.set_storage_readonly(true); - assert!(instance.env.is_storage_readonly()); + assert_eq!(instance.env.is_storage_readonly(), true); } #[test] fn with_storage_works() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); // initial check instance @@ -677,7 +672,7 @@ mod tests { #[should_panic] fn with_storage_safe_for_panic() { // this should fail with the assertion, but not cause a double-free crash (issue #59) - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); instance .with_storage::<_, ()>(|_store| panic!("trigger failure")) .unwrap(); @@ -687,7 +682,7 @@ mod tests { fn with_querier_works_readonly() { let rich_addr = String::from("foobar"); let rich_balance = vec![coin(10000, "gold"), coin(8000, "silver")]; - let mut instance = mock_instance_with_balances(CONTRACT, &[(&rich_addr, &rich_balance)]); + let mut instance = mock_instance_with_balances(&CONTRACT, &[(&rich_addr, &rich_balance)]); // query one instance @@ -743,7 +738,7 @@ mod tests { let rich_addr = String::from("foobar"); let rich_balance1 = vec![coin(10000, "gold"), coin(500, "silver")]; let rich_balance2 = vec![coin(10000, "gold"), coin(8000, "silver")]; - let mut instance = mock_instance_with_balances(CONTRACT, &[(&rich_addr, &rich_balance1)]); + let mut instance = mock_instance_with_balances(&CONTRACT, &[(&rich_addr, &rich_balance1)]); // Get initial state instance @@ -808,7 +803,7 @@ mod singlepass_tests { #[test] fn contract_deducts_gas_init() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); let orig_gas = instance.get_gas_left(); // init contract @@ -819,12 +814,12 @@ mod singlepass_tests { .unwrap(); let init_used = orig_gas - instance.get_gas_left(); - assert_eq!(init_used, 36451); + assert_eq!(init_used, 38877); } #[test] fn contract_deducts_gas_execute() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); // init contract let info = mock_info("creator", &coins(1000, "earth")); @@ -842,12 +837,12 @@ mod singlepass_tests { .unwrap(); let execute_used = gas_before_execute - instance.get_gas_left(); - assert_eq!(execute_used, 159020); + assert_eq!(execute_used, 157981); } #[test] fn contract_enforces_gas_limit() { - let mut instance = mock_instance_with_gas_limit(CONTRACT, 20_000); + let mut instance = mock_instance_with_gas_limit(&CONTRACT, 20_000); // init contract let info = mock_info("creator", &coins(1000, "earth")); @@ -858,7 +853,7 @@ mod singlepass_tests { #[test] fn query_works_with_gas_metering() { - let mut instance = mock_instance(CONTRACT, &[]); + let mut instance = mock_instance(&CONTRACT, &[]); // init contract let info = mock_info("creator", &coins(1000, "earth")); @@ -876,6 +871,6 @@ mod singlepass_tests { assert_eq!(answer.as_slice(), b"{\"verifier\":\"verifies\"}"); let query_used = gas_before_query - instance.get_gas_left(); - assert_eq!(query_used, 27629); + assert_eq!(query_used, 28999); } } diff --git a/packages/vm/src/lib.rs b/packages/vm/src/lib.rs index 82f957ba4..3f72cb8ab 100644 --- a/packages/vm/src/lib.rs +++ b/packages/vm/src/lib.rs @@ -9,10 +9,13 @@ mod conversion; mod environment; mod errors; mod features; +#[cfg(feature = "stargate")] +mod ibc_calls; mod imports; mod instance; mod limited; mod memory; +mod middleware; mod modules; mod sections; mod serde; @@ -30,19 +33,20 @@ pub use crate::calls::{ call_migrate_raw, call_query, call_query_raw, call_reply, call_reply_raw, call_sudo, call_sudo_raw, }; -#[cfg(feature = "stargate")] -pub use crate::calls::{ - call_ibc_channel_close, call_ibc_channel_close_raw, call_ibc_channel_connect, - call_ibc_channel_connect_raw, call_ibc_channel_open, call_ibc_channel_open_raw, - call_ibc_packet_ack, call_ibc_packet_ack_raw, call_ibc_packet_receive, - call_ibc_packet_receive_raw, call_ibc_packet_timeout, call_ibc_packet_timeout_raw, -}; pub use crate::checksum::Checksum; + pub use crate::errors::{ CommunicationError, CommunicationResult, RegionValidationError, RegionValidationResult, VmError, VmResult, }; pub use crate::features::features_from_csv; +#[cfg(feature = "stargate")] +pub use crate::ibc_calls::{ + call_ibc_channel_close, call_ibc_channel_close_raw, call_ibc_channel_connect, + call_ibc_channel_connect_raw, call_ibc_channel_open, call_ibc_channel_open_raw, + call_ibc_packet_ack, call_ibc_packet_ack_raw, call_ibc_packet_receive, + call_ibc_packet_receive_raw, call_ibc_packet_timeout, call_ibc_packet_timeout_raw, +}; pub use crate::instance::{GasReport, Instance, InstanceOptions}; pub use crate::serde::{from_slice, to_vec}; pub use crate::size::Size; diff --git a/packages/vm/src/middleware/deterministic.rs b/packages/vm/src/middleware/deterministic.rs new file mode 100644 index 000000000..888a1f0ea --- /dev/null +++ b/packages/vm/src/middleware/deterministic.rs @@ -0,0 +1,201 @@ +use wasmer::wasmparser::Operator; +use wasmer::{ + FunctionMiddleware, LocalFunctionIndex, MiddlewareError, MiddlewareReaderState, + ModuleMiddleware, +}; + +/// A middleware that ensures only deterministic operations are used (i.e. no floats) +#[derive(Debug)] +pub struct Deterministic {} + +impl Deterministic { + pub fn new() -> Self { + Self {} + } +} + +impl ModuleMiddleware for Deterministic { + /// Generates a `FunctionMiddleware` for a given function. + fn generate_function_middleware(&self, _: LocalFunctionIndex) -> Box { + Box::new(FunctionDeterministic {}) + } +} + +#[derive(Debug)] +pub struct FunctionDeterministic {} + +impl FunctionMiddleware for FunctionDeterministic { + fn feed<'a>( + &mut self, + operator: Operator<'a>, + state: &mut MiddlewareReaderState<'a>, + ) -> Result<(), MiddlewareError> { + match operator { + Operator::Unreachable + | Operator::Nop + | Operator::Block { .. } + | Operator::Loop { .. } + | Operator::If { .. } + | Operator::Else + | Operator::End + | Operator::Br { .. } + | Operator::BrIf { .. } + | Operator::BrTable { .. } + | Operator::Return + | Operator::Call { .. } + | Operator::CallIndirect { .. } + | Operator::Drop + | Operator::Select + | Operator::LocalGet { .. } + | Operator::LocalSet { .. } + | Operator::LocalTee { .. } + | Operator::GlobalGet { .. } + | Operator::GlobalSet { .. } + | Operator::I32Load { .. } + | Operator::I64Load { .. } + | Operator::I32Load8S { .. } + | Operator::I32Load8U { .. } + | Operator::I32Load16S { .. } + | Operator::I32Load16U { .. } + | Operator::I64Load8S { .. } + | Operator::I64Load8U { .. } + | Operator::I64Load16S { .. } + | Operator::I64Load16U { .. } + | Operator::I64Load32S { .. } + | Operator::I64Load32U { .. } + | Operator::I32Store { .. } + | Operator::I64Store { .. } + | Operator::I32Store8 { .. } + | Operator::I32Store16 { .. } + | Operator::I64Store8 { .. } + | Operator::I64Store16 { .. } + | Operator::I64Store32 { .. } + | Operator::MemorySize { .. } + | Operator::MemoryGrow { .. } + | Operator::I32Const { .. } + | Operator::I64Const { .. } + | Operator::I32Eqz + | Operator::I32Eq + | Operator::I32Ne + | Operator::I32LtS + | Operator::I32LtU + | Operator::I32GtS + | Operator::I32GtU + | Operator::I32LeS + | Operator::I32LeU + | Operator::I32GeS + | Operator::I32GeU + | Operator::I64Eqz + | Operator::I64Eq + | Operator::I64Ne + | Operator::I64LtS + | Operator::I64LtU + | Operator::I64GtS + | Operator::I64GtU + | Operator::I64LeS + | Operator::I64LeU + | Operator::I64GeS + | Operator::I64GeU + | Operator::I32Clz + | Operator::I32Ctz + | Operator::I32Popcnt + | Operator::I32Add + | Operator::I32Sub + | Operator::I32Mul + | Operator::I32DivS + | Operator::I32DivU + | Operator::I32RemS + | Operator::I32RemU + | Operator::I32And + | Operator::I32Or + | Operator::I32Xor + | Operator::I32Shl + | Operator::I32ShrS + | Operator::I32ShrU + | Operator::I32Rotl + | Operator::I32Rotr + | Operator::I64Clz + | Operator::I64Ctz + | Operator::I64Popcnt + | Operator::I64Add + | Operator::I64Sub + | Operator::I64Mul + | Operator::I64DivS + | Operator::I64DivU + | Operator::I64RemS + | Operator::I64RemU + | Operator::I64And + | Operator::I64Or + | Operator::I64Xor + | Operator::I64Shl + | Operator::I64ShrS + | Operator::I64ShrU + | Operator::I64Rotl + | Operator::I64Rotr + | Operator::I32WrapI64 + | Operator::I32Extend8S + | Operator::I32Extend16S + | Operator::I64Extend8S + | Operator::I64Extend16S + | Operator::I64ExtendI32S + | Operator::I64ExtendI32U => { + state.push_operator(operator); + Ok(()) + } + _ => { + let msg = format!("Non-deterministic operator detected: {:?}", operator); + Err(MiddlewareError::new("Deterministic", msg)) + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::Arc; + use wasmer::{CompilerConfig, Cranelift, Module, Store, JIT}; + + #[test] + fn valid_wasm_instance_sanity() { + let wasm = wat::parse_str( + r#" + (module + (func (export "sum") (param i32 i32) (result i32) + get_local 0 + get_local 1 + i32.add + )) + "#, + ) + .unwrap(); + + let deterministic = Arc::new(Deterministic::new()); + let mut compiler_config = Cranelift::default(); + compiler_config.push_middleware(deterministic); + let store = Store::new(&JIT::new(compiler_config).engine()); + let result = Module::new(&store, &wasm); + assert!(result.is_ok()); + } + + #[test] + fn parser_floats_are_not_supported() { + let wasm = wat::parse_str( + r#" + (module + (func $to_float (param i32) (result f32) + get_local 0 + f32.convert_u/i32 + )) + "#, + ) + .unwrap(); + + let deterministic = Arc::new(Deterministic::new()); + let mut compiler_config = Cranelift::default(); + compiler_config.push_middleware(deterministic); + let store = Store::new(&JIT::new(compiler_config).engine()); + let result = Module::new(&store, &wasm); + assert!(result.is_err()); + } +} diff --git a/packages/vm/src/middleware/mod.rs b/packages/vm/src/middleware/mod.rs new file mode 100644 index 000000000..35c05d023 --- /dev/null +++ b/packages/vm/src/middleware/mod.rs @@ -0,0 +1,3 @@ +mod deterministic; + +pub use deterministic::Deterministic; diff --git a/packages/vm/src/modules/file_system_cache.rs b/packages/vm/src/modules/file_system_cache.rs index 1fc8b4b9f..036c61cad 100644 --- a/packages/vm/src/modules/file_system_cache.rs +++ b/packages/vm/src/modules/file_system_cache.rs @@ -31,7 +31,7 @@ impl FileSystemCache { /// /// This method is unsafe because there's no way to ensure the artifacts /// stored in this cache haven't been corrupted or tampered with. - pub unsafe fn new(path: impl Into) -> io::Result { + pub unsafe fn new>(path: P) -> io::Result { let path: PathBuf = path.into(); if path.exists() { let metadata = path.metadata()?; @@ -64,13 +64,23 @@ impl FileSystemCache { /// Loads a serialized module from the file system and returns a module (i.e. artifact + store), /// along with the size of the serialized module. - pub fn load(&self, checksum: &Checksum, store: &Store) -> VmResult> { + /// The serialized module size is a good approximation (~100.06 %) of the in-memory module size. + /// It should not be considered as the exact in-memory module size. + pub fn load(&self, checksum: &Checksum, store: &Store) -> VmResult> { let filename = checksum.to_hex(); let file_path = self.latest_modules_path().join(filename); let result = unsafe { Module::deserialize_from_file(store, &file_path) }; match result { - Ok(module) => Ok(Some(module)), + Ok(module) => { + let module_size = file_path + .metadata() + .map_err(|e| { + VmError::cache_err(format!("Error getting module file size: {}", e)) + })? + .len(); + Ok(Some((module, module_size as usize))) + } Err(DeserializeError::Io(err)) => match err.kind() { io::ErrorKind::NotFound => Ok(None), _ => Err(VmError::cache_err(format!( @@ -86,16 +96,22 @@ impl FileSystemCache { } /// Stores a serialized module to the file system. Returns the size of the serialized module. - pub fn store(&mut self, checksum: &Checksum, module: &Module) -> VmResult<()> { + /// The serialized module size is a good approximation (~100.06 %) of the in-memory module size. + /// It should not be considered as the exact in-memory module size. + pub fn store(&mut self, checksum: &Checksum, module: &Module) -> VmResult { let modules_dir = self.latest_modules_path(); fs::create_dir_all(&modules_dir) .map_err(|e| VmError::cache_err(format!("Error creating directory: {}", e)))?; let filename = checksum.to_hex(); let path = modules_dir.join(filename); module - .serialize_to_file(path) + .serialize_to_file(path.clone()) .map_err(|e| VmError::cache_err(format!("Error writing module to disk: {}", e)))?; - Ok(()) + let module_size = path + .metadata() + .map_err(|e| VmError::cache_err(format!("Error getting module file size: {}", e)))? + .len(); + Ok(module_size as usize) } /// The path to the latest version of the modules. @@ -151,7 +167,8 @@ mod tests { // Check the returned module is functional. // This is not really testing the cache API but better safe than sorry. { - let cached_module = cached.unwrap(); + let (cached_module, module_size) = cached.unwrap(); + assert_eq!(module_size, module.serialize().unwrap().len()); let import_object = imports! {}; let instance = WasmerInstance::new(&cached_module, &import_object).unwrap(); set_remaining_points(&instance, TESTING_GAS_LIMIT); diff --git a/packages/vm/src/modules/in_memory_cache.rs b/packages/vm/src/modules/in_memory_cache.rs index 9f7d9eaa3..563b9c6de 100644 --- a/packages/vm/src/modules/in_memory_cache.rs +++ b/packages/vm/src/modules/in_memory_cache.rs @@ -108,12 +108,12 @@ mod tests { let key_size = mem::size_of::(); assert_eq!(key_size, 32); - // A Module consists of a Store (3 Arcs) and an Arc to the Engine. + // A Module consists of a Store (2 Arcs) and an Arc to the Engine. // This is 3 * 64bit of data, but we don't get any guarantee how the Rust structs // Module and Store are aligned (https://doc.rust-lang.org/reference/type-layout.html#the-default-representation). // So we get this value by trial and error. It can change over time and across platforms. let value_size = mem::size_of::(); - assert_eq!(value_size, 56); + assert_eq!(value_size, 48); // Just in case we want to go that route let boxed_value_size = mem::size_of::>(); diff --git a/packages/vm/src/modules/pinned_memory_cache.rs b/packages/vm/src/modules/pinned_memory_cache.rs index 4efa5d497..82df59fb9 100644 --- a/packages/vm/src/modules/pinned_memory_cache.rs +++ b/packages/vm/src/modules/pinned_memory_cache.rs @@ -131,18 +131,18 @@ mod tests { .unwrap(); let checksum = Checksum::generate(&wasm); - assert!(!cache.has(&checksum)); + assert_eq!(cache.has(&checksum), false); // Add let original = compile(&wasm, None).unwrap(); cache.store(&checksum, original, 0).unwrap(); - assert!(cache.has(&checksum)); + assert_eq!(cache.has(&checksum), true); // Remove cache.remove(&checksum).unwrap(); - assert!(!cache.has(&checksum)); + assert_eq!(cache.has(&checksum), false); } #[test] diff --git a/packages/vm/src/serde.rs b/packages/vm/src/serde.rs index c884dd1b8..8e1640028 100644 --- a/packages/vm/src/serde.rs +++ b/packages/vm/src/serde.rs @@ -7,20 +7,10 @@ use std::any::type_name; use crate::errors::{VmError, VmResult}; -/// Deserializes JSON data into a document of type `T`. -/// -/// The deserialization limit ensure it is not possible to slow down the execution by -/// providing overly large JSON documents. -pub fn from_slice<'a, T>(value: &'a [u8], deserialization_limit: usize) -> VmResult +pub fn from_slice<'a, T>(value: &'a [u8]) -> VmResult where T: Deserialize<'a>, { - if value.len() > deserialization_limit { - return Err(VmError::deserialization_limit_exceeded( - value.len(), - deserialization_limit, - )); - } serde_json::from_slice(value).map_err(|e| VmError::parse_err(type_name::(), e)) } @@ -30,100 +20,3 @@ where { serde_json::to_vec(data).map_err(|e| VmError::serialize_err(type_name::(), e)) } - -#[cfg(test)] -mod tests { - use super::*; - use serde::Deserialize; - - const LIMIT: usize = 20_000; - - #[derive(Serialize, Deserialize, Debug, PartialEq)] - #[serde(rename_all = "snake_case")] - enum SomeMsg { - Refund {}, - ReleaseAll { - image: String, - amount: u32, - time: u64, - karma: i32, - }, - Cowsay { - text: String, - }, - } - - #[test] - fn from_slice_works() { - let deserialized: SomeMsg = from_slice(br#"{"refund":{}}"#, LIMIT).unwrap(); - assert_eq!(deserialized, SomeMsg::Refund {}); - - let deserialized: SomeMsg = from_slice( - br#"{"release_all":{"image":"foo","amount":42,"time":18446744073709551615,"karma":-17}}"#, LIMIT - ) - .unwrap(); - assert_eq!( - deserialized, - SomeMsg::ReleaseAll { - image: "foo".to_string(), - amount: 42, - time: 18446744073709551615, - karma: -17 - } - ); - } - - #[test] - fn from_slice_works_for_special_chars() { - let deserialized: SomeMsg = - from_slice(br#"{"cowsay":{"text":"foo\"bar\\\"bla"}}"#, LIMIT).unwrap(); - assert_eq!( - deserialized, - SomeMsg::Cowsay { - text: "foo\"bar\\\"bla".to_string(), - } - ); - } - - #[test] - fn from_slice_errors_when_exceeding_deserialization_limit() { - let result = from_slice::(br#"{"refund":{}}"#, 5); - match result.unwrap_err() { - VmError::DeserializationLimitExceeded { - length, max_length, .. - } => { - assert_eq!(length, 13); - assert_eq!(max_length, 5); - } - err => panic!("Unexpected error: {:?}", err), - } - } - - #[test] - fn to_vec_works() { - let msg = SomeMsg::Refund {}; - let serialized = to_vec(&msg).unwrap(); - assert_eq!(serialized, br#"{"refund":{}}"#); - - let msg = SomeMsg::ReleaseAll { - image: "foo".to_string(), - amount: 42, - time: 9007199254740999, // Number.MAX_SAFE_INTEGER + 7 - karma: -17, - }; - let serialized = String::from_utf8(to_vec(&msg).unwrap()).unwrap(); - assert_eq!( - serialized, - r#"{"release_all":{"image":"foo","amount":42,"time":9007199254740999,"karma":-17}}"# - ); - } - - #[test] - fn to_vec_works_for_special_chars() { - let msg = SomeMsg::Cowsay { - text: "foo\"bar\\\"bla".to_string(), - }; - let serialized = String::from_utf8(to_vec(&msg).unwrap()).unwrap(); - assert_eq!(serialized, r#"{"cowsay":{"text":"foo\"bar\\\"bla"}}"#); - } -} diff --git a/packages/vm/src/static_analysis.rs b/packages/vm/src/static_analysis.rs index 4be596ff8..d2cf7503b 100644 --- a/packages/vm/src/static_analysis.rs +++ b/packages/vm/src/static_analysis.rs @@ -13,7 +13,7 @@ pub const REQUIRED_IBC_EXPORTS: &[&str] = &[ ]; pub fn deserialize_wasm(wasm_code: &[u8]) -> VmResult { - deserialize_buffer(wasm_code).map_err(|err| { + deserialize_buffer(&wasm_code).map_err(|err| { VmError::static_validation_err(format!( "Wasm bytecode could not be deserialized. Deserialization error: \"{}\"", err @@ -21,62 +21,26 @@ pub fn deserialize_wasm(wasm_code: &[u8]) -> VmResult { }) } -/// A trait that allows accessing shared functionality of `parity_wasm::elements::Module` -/// and `wasmer::Module` in a shared fashion. -pub trait ExportInfo { - /// Returns all exported function names with the given prefix - fn exported_function_names(&self, prefix: Option<&str>) -> HashSet; -} - -impl ExportInfo for Module { - fn exported_function_names(&self, prefix: Option<&str>) -> HashSet { - self.export_section() - .map_or(HashSet::default(), |export_section| { - export_section - .entries() - .iter() - .filter_map(|entry| match entry.internal() { - Internal::Function(_) => Some(entry.field()), - _ => None, - }) - .filter(|name| { - if let Some(required_prefix) = prefix { - name.starts_with(required_prefix) - } else { - true - } - }) - .map(|name| name.to_string()) - .collect() - }) - } -} - -impl ExportInfo for wasmer::Module { - fn exported_function_names(&self, prefix: Option<&str>) -> HashSet { - self.exports() - .functions() - .filter_map(|function_export| { - let name = function_export.name(); - if let Some(required_prefix) = prefix { - if name.starts_with(required_prefix) { - Some(name.to_string()) - } else { - None - } - } else { - Some(name.to_string()) - } - }) - .collect() - } +pub fn exported_functions(module: &Module) -> HashSet { + module + .export_section() + .map_or(HashSet::default(), |export_section| { + export_section + .entries() + .iter() + .filter_map(|entry| match entry.internal() { + Internal::Function(_) => Some(entry.field().to_string()), + _ => None, + }) + .collect() + }) } /// Returns true if and only if all IBC entry points ([`REQUIRED_IBC_EXPORTS`]) /// exist as exported functions. This does not guarantee the entry points /// are functional and for simplicity does not even check their signatures. -pub fn has_ibc_entry_points(module: &impl ExportInfo) -> bool { - let available_exports = module.exported_function_names(None); +pub fn has_ibc_entry_points(module: &Module) -> bool { + let available_exports = exported_functions(module); REQUIRED_IBC_EXPORTS .iter() .all(|required| available_exports.contains(*required)) @@ -87,7 +51,6 @@ mod tests { use super::*; use parity_wasm::elements::Internal; use std::iter::FromIterator; - use wasmer::{Cranelift, Store, Universal}; static CONTRACT: &[u8] = include_bytes!("../testdata/hackatom.wasm"); static CORRUPTED: &[u8] = include_bytes!("../testdata/corrupted.wasm"); @@ -125,37 +88,10 @@ mod tests { } #[test] - fn exported_function_names_works_for_parity_with_no_prefix() { - let wasm = wat::parse_str(r#"(module)"#).unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); - let exports = module.exported_function_names(None); - assert_eq!(exports, HashSet::new()); - - let wasm = wat::parse_str( - r#"(module - (memory 3) - (export "memory" (memory 0)) - - (type (func)) - (func (type 0) nop) - (export "foo" (func 0)) - (export "bar" (func 0)) - )"#, - ) - .unwrap(); - let module = deserialize_wasm(&wasm).unwrap(); - let exports = module.exported_function_names(None); - assert_eq!( - exports, - HashSet::from_iter(vec!["foo".to_string(), "bar".to_string()]) - ); - } - - #[test] - fn exported_function_names_works_for_parity_with_prefix() { + fn exported_functions_works() { let wasm = wat::parse_str(r#"(module)"#).unwrap(); let module = deserialize_wasm(&wasm).unwrap(); - let exports = module.exported_function_names(Some("b")); + let exports = exported_functions(&module); assert_eq!(exports, HashSet::new()); let wasm = wat::parse_str( @@ -167,74 +103,14 @@ mod tests { (func (type 0) nop) (export "foo" (func 0)) (export "bar" (func 0)) - (export "baz" (func 0)) )"#, ) .unwrap(); let module = deserialize_wasm(&wasm).unwrap(); - let exports = module.exported_function_names(Some("b")); - assert_eq!( - exports, - HashSet::from_iter(vec!["bar".to_string(), "baz".to_string()]) - ); - } - - #[test] - fn exported_function_names_works_for_wasmer_with_no_prefix() { - let wasm = wat::parse_str(r#"(module)"#).unwrap(); - let store = Store::new(&Universal::new(Cranelift::default()).engine()); - let module = wasmer::Module::new(&store, wasm).unwrap(); - let exports = module.exported_function_names(None); - assert_eq!(exports, HashSet::new()); - - let wasm = wat::parse_str( - r#"(module - (memory 3) - (export "memory" (memory 0)) - - (type (func)) - (func (type 0) nop) - (export "foo" (func 0)) - (export "bar" (func 0)) - )"#, - ) - .unwrap(); - let store = Store::new(&Universal::new(Cranelift::default()).engine()); - let module = wasmer::Module::new(&store, wasm).unwrap(); - let exports = module.exported_function_names(None); - assert_eq!( - exports, - HashSet::from_iter(vec!["foo".to_string(), "bar".to_string()]) - ); - } - - #[test] - fn exported_function_names_works_for_wasmer_with_prefix() { - let wasm = wat::parse_str(r#"(module)"#).unwrap(); - let store = Store::new(&Universal::new(Cranelift::default()).engine()); - let module = wasmer::Module::new(&store, wasm).unwrap(); - let exports = module.exported_function_names(Some("b")); - assert_eq!(exports, HashSet::new()); - - let wasm = wat::parse_str( - r#"(module - (memory 3) - (export "memory" (memory 0)) - - (type (func)) - (func (type 0) nop) - (export "foo" (func 0)) - (export "bar" (func 0)) - (export "baz" (func 0)) - )"#, - ) - .unwrap(); - let store = Store::new(&Universal::new(Cranelift::default()).engine()); - let module = wasmer::Module::new(&store, wasm).unwrap(); - let exports = module.exported_function_names(Some("b")); + let exports = exported_functions(&module); assert_eq!( exports, - HashSet::from_iter(vec!["bar".to_string(), "baz".to_string()]) + HashSet::from_iter(vec!["foo".to_string(), "bar".to_string(),]) ); } @@ -248,7 +124,7 @@ mod tests { (type (func)) (func (type 0) nop) - (export "interface_version_7" (func 0)) + (export "interface_version_5" (func 0)) (export "instantiate" (func 0)) (export "allocate" (func 0)) (export "deallocate" (func 0)) @@ -256,7 +132,7 @@ mod tests { ) .unwrap(); let module = deserialize_wasm(&wasm).unwrap(); - assert!(!has_ibc_entry_points(&module)); + assert_eq!(has_ibc_entry_points(&module), false); // IBC contract let wasm = wat::parse_str( @@ -266,7 +142,7 @@ mod tests { (type (func)) (func (type 0) nop) - (export "interface_version_7" (func 0)) + (export "interface_version_5" (func 0)) (export "instantiate" (func 0)) (export "execute" (func 0)) (export "allocate" (func 0)) @@ -281,7 +157,7 @@ mod tests { ) .unwrap(); let module = deserialize_wasm(&wasm).unwrap(); - assert!(has_ibc_entry_points(&module)); + assert_eq!(has_ibc_entry_points(&module), true); // Missing packet ack let wasm = wat::parse_str( @@ -291,7 +167,7 @@ mod tests { (type (func)) (func (type 0) nop) - (export "interface_version_7" (func 0)) + (export "interface_version_5" (func 0)) (export "instantiate" (func 0)) (export "execute" (func 0)) (export "allocate" (func 0)) @@ -305,6 +181,6 @@ mod tests { ) .unwrap(); let module = deserialize_wasm(&wasm).unwrap(); - assert!(!has_ibc_entry_points(&module)); + assert_eq!(has_ibc_entry_points(&module), false); } } diff --git a/packages/vm/src/testing/calls.rs b/packages/vm/src/testing/calls.rs index 55df5a196..37c8bfaf3 100644 --- a/packages/vm/src/testing/calls.rs +++ b/packages/vm/src/testing/calls.rs @@ -6,20 +6,10 @@ use serde::{de::DeserializeOwned, Serialize}; use std::fmt; use cosmwasm_std::{ContractResult, Env, MessageInfo, QueryResponse, Reply, Response}; -#[cfg(feature = "stargate")] -use cosmwasm_std::{ - IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcPacketAckMsg, - IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, -}; use crate::calls::{ call_execute, call_instantiate, call_migrate, call_query, call_reply, call_sudo, }; -#[cfg(feature = "stargate")] -use crate::calls::{ - call_ibc_channel_close, call_ibc_channel_connect, call_ibc_channel_open, call_ibc_packet_ack, - call_ibc_packet_receive, call_ibc_packet_timeout, -}; use crate::instance::Instance; use crate::serde::to_vec; use crate::{BackendApi, Querier, Storage}; @@ -136,110 +126,3 @@ where let serialized_msg = to_vec(&msg).expect("Testing error: Could not seralize request message"); call_query(instance, &env, &serialized_msg).expect("VM error") } - -// ibc_channel_open mimicks the call signature of the smart contracts. -// thus it moves env and channel rather than take them as reference. -// this is inefficient here, but only used in test code -#[cfg(feature = "stargate")] -pub fn ibc_channel_open( - instance: &mut Instance, - env: Env, - msg: IbcChannelOpenMsg, -) -> ContractResult<()> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, -{ - call_ibc_channel_open(instance, &env, &msg).expect("VM error") -} - -// ibc_channel_connect mimicks the call signature of the smart contracts. -// thus it moves env and channel rather than take them as reference. -// this is inefficient here, but only used in test code -#[cfg(feature = "stargate")] -pub fn ibc_channel_connect( - instance: &mut Instance, - env: Env, - msg: IbcChannelConnectMsg, -) -> ContractResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, -{ - call_ibc_channel_connect(instance, &env, &msg).expect("VM error") -} - -// ibc_channel_close mimicks the call signature of the smart contracts. -// thus it moves env and channel rather than take them as reference. -// this is inefficient here, but only used in test code -#[cfg(feature = "stargate")] -pub fn ibc_channel_close( - instance: &mut Instance, - env: Env, - msg: IbcChannelCloseMsg, -) -> ContractResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, -{ - call_ibc_channel_close(instance, &env, &msg).expect("VM error") -} - -// ibc_packet_receive mimicks the call signature of the smart contracts. -// thus it moves env and packet rather than take them as reference. -// this is inefficient here, but only used in test code -#[cfg(feature = "stargate")] -pub fn ibc_packet_receive( - instance: &mut Instance, - env: Env, - msg: IbcPacketReceiveMsg, -) -> ContractResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, -{ - call_ibc_packet_receive(instance, &env, &msg).expect("VM error") -} - -// ibc_packet_ack mimicks the call signature of the smart contracts. -// thus it moves env and acknowledgement rather than take them as reference. -// this is inefficient here, but only used in test code -#[cfg(feature = "stargate")] -pub fn ibc_packet_ack( - instance: &mut Instance, - env: Env, - msg: IbcPacketAckMsg, -) -> ContractResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, -{ - call_ibc_packet_ack(instance, &env, &msg).expect("VM error") -} - -// ibc_packet_timeout mimicks the call signature of the smart contracts. -// thus it moves env and packet rather than take them as reference. -// this is inefficient here, but only used in test code -#[cfg(feature = "stargate")] -pub fn ibc_packet_timeout( - instance: &mut Instance, - env: Env, - msg: IbcPacketTimeoutMsg, -) -> ContractResult> -where - A: BackendApi + 'static, - S: Storage + 'static, - Q: Querier + 'static, - U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, -{ - call_ibc_packet_timeout(instance, &env, &msg).expect("VM error") -} diff --git a/packages/vm/src/testing/contract.rs b/packages/vm/src/testing/contract.rs index d1ebc19da..009cc5708 100644 --- a/packages/vm/src/testing/contract.rs +++ b/packages/vm/src/testing/contract.rs @@ -106,9 +106,9 @@ mod test { use cosmwasm_std::{QueryResponse, Response}; static CONTRACT_WITHOUT_MIGRATE: &[u8] = - include_bytes!("../../testdata/queue_0.16.2_without_migrate.wasm"); + include_bytes!("../../testdata/queue_0.14_without_migrate.wasm"); static CONTRACT_WITH_MIGRATE: &[u8] = - include_bytes!("../../testdata/queue_0.16.2_with_migrate.wasm"); + include_bytes!("../../testdata/queue_0.14_with_migrate.wasm"); #[test] fn test_sanity_integration_test_flow() { @@ -123,7 +123,7 @@ mod test { // init let mut instance = contract.generate_instance().unwrap(); let msg = "{}".as_bytes(); - let _: Response = call_instantiate(&mut instance, &env, &info, msg) + let _: Response = call_instantiate(&mut instance, &env, &info, &msg) .unwrap() .into_result() .unwrap(); @@ -132,7 +132,7 @@ mod test { // query and confirm the queue is empty let mut instance = contract.generate_instance().unwrap(); let msg = "{\"count\": {}}".as_bytes(); - let res: QueryResponse = call_query(&mut instance, &env, msg) + let res: QueryResponse = call_query(&mut instance, &env, &msg) .unwrap() .into_result() .unwrap(); @@ -142,7 +142,7 @@ mod test { // handle and enqueue 42 let mut instance = contract.generate_instance().unwrap(); let msg = "{\"enqueue\": {\"value\": 42}}".as_bytes(); - let _: Response = call_execute(&mut instance, &env, &info, msg) + let _: Response = call_execute(&mut instance, &env, &info, &msg) .unwrap() .into_result() .unwrap(); @@ -151,7 +151,7 @@ mod test { // query and confirm the length of the queue is 1 let mut instance = contract.generate_instance().unwrap(); let msg = "{\"count\": {}}".as_bytes(); - let res: QueryResponse = call_query(&mut instance, &env, msg) + let res: QueryResponse = call_query(&mut instance, &env, &msg) .unwrap() .into_result() .unwrap(); @@ -161,7 +161,7 @@ mod test { // query and confirm the sum of the queue is 42 let mut instance = contract.generate_instance().unwrap(); let msg = "{\"sum\": {}}".as_bytes(); - let res: QueryResponse = call_query(&mut instance, &env, msg) + let res: QueryResponse = call_query(&mut instance, &env, &msg) .unwrap() .into_result() .unwrap(); @@ -172,7 +172,7 @@ mod test { contract.change_wasm(CONTRACT_WITH_MIGRATE).unwrap(); let mut instance = contract.generate_instance().unwrap(); let msg = "{}".as_bytes(); - let _: Response = call_migrate(&mut instance, &env, msg) + let _: Response = call_migrate(&mut instance, &env, &msg) .unwrap() .into_result() .unwrap(); @@ -181,7 +181,7 @@ mod test { // query and check the length of the queue is 3 let mut instance = contract.generate_instance().unwrap(); let msg = "{\"count\": {}}".as_bytes(); - let res: QueryResponse = call_query(&mut instance, &env, msg) + let res: QueryResponse = call_query(&mut instance, &env, &msg) .unwrap() .into_result() .unwrap(); @@ -191,7 +191,7 @@ mod test { // query and check the sum of the queue is 303 let mut instance = contract.generate_instance().unwrap(); let msg = "{\"sum\": {}}".as_bytes(); - let res: QueryResponse = call_query(&mut instance, &env, msg) + let res: QueryResponse = call_query(&mut instance, &env, &msg) .unwrap() .into_result() .unwrap(); diff --git a/packages/vm/src/testing/ibc_calls.rs b/packages/vm/src/testing/ibc_calls.rs new file mode 100644 index 000000000..6bedbb8a4 --- /dev/null +++ b/packages/vm/src/testing/ibc_calls.rs @@ -0,0 +1,117 @@ +#![cfg(feature = "stargate")] +use schemars::JsonSchema; +use serde::de::DeserializeOwned; +use std::fmt; + +use cosmwasm_std::{ + ContractResult, Env, IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcPacket, + IbcReceiveResponse, +}; + +use crate::ibc_calls::{ + call_ibc_channel_close, call_ibc_channel_connect, call_ibc_channel_open, call_ibc_packet_ack, + call_ibc_packet_receive, call_ibc_packet_timeout, +}; +use crate::instance::Instance; +use crate::{BackendApi, Querier, Storage}; + +// ibc_channel_open mimicks the call signature of the smart contracts. +// thus it moves env and channel rather than take them as reference. +// this is inefficient here, but only used in test code +pub fn ibc_channel_open( + instance: &mut Instance, + env: Env, + channel: IbcChannel, +) -> ContractResult<()> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, +{ + call_ibc_channel_open(instance, &env, &channel).expect("VM error") +} + +// ibc_channel_connect mimicks the call signature of the smart contracts. +// thus it moves env and channel rather than take them as reference. +// this is inefficient here, but only used in test code +pub fn ibc_channel_connect( + instance: &mut Instance, + env: Env, + channel: IbcChannel, +) -> ContractResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, +{ + call_ibc_channel_connect(instance, &env, &channel).expect("VM error") +} + +// ibc_channel_close mimicks the call signature of the smart contracts. +// thus it moves env and channel rather than take them as reference. +// this is inefficient here, but only used in test code +pub fn ibc_channel_close( + instance: &mut Instance, + env: Env, + channel: IbcChannel, +) -> ContractResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, +{ + call_ibc_channel_close(instance, &env, &channel).expect("VM error") +} + +// ibc_packet_receive mimicks the call signature of the smart contracts. +// thus it moves env and packet rather than take them as reference. +// this is inefficient here, but only used in test code +pub fn ibc_packet_receive( + instance: &mut Instance, + env: Env, + packet: IbcPacket, +) -> ContractResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, +{ + call_ibc_packet_receive(instance, &env, &packet).expect("VM error") +} + +// ibc_packet_ack mimicks the call signature of the smart contracts. +// thus it moves env and acknowledgement rather than take them as reference. +// this is inefficient here, but only used in test code +pub fn ibc_packet_ack( + instance: &mut Instance, + env: Env, + ack: IbcAcknowledgement, +) -> ContractResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, +{ + call_ibc_packet_ack(instance, &env, &ack).expect("VM error") +} + +// ibc_packet_timeout mimicks the call signature of the smart contracts. +// thus it moves env and packet rather than take them as reference. +// this is inefficient here, but only used in test code +pub fn ibc_packet_timeout( + instance: &mut Instance, + env: Env, + packet: IbcPacket, +) -> ContractResult> +where + A: BackendApi + 'static, + S: Storage + 'static, + Q: Querier + 'static, + U: DeserializeOwned + Clone + PartialEq + JsonSchema + fmt::Debug, +{ + call_ibc_packet_timeout(instance, &env, &packet).expect("VM error") +} diff --git a/packages/vm/src/testing/mock.rs b/packages/vm/src/testing/mock.rs index 2371d0dee..9d53b8477 100644 --- a/packages/vm/src/testing/mock.rs +++ b/packages/vm/src/testing/mock.rs @@ -31,14 +31,6 @@ pub fn mock_backend_with_balances( } } -/// Length of canonical addresses created with this API. Contracts should not make any assumtions -/// what this value is. -/// The value here must be restorable with `SHUFFLES_ENCODE` + `SHUFFLES_DECODE` in-shuffles. -const CANONICAL_LENGTH: usize = 54; - -const SHUFFLES_ENCODE: usize = 18; -const SHUFFLES_DECODE: usize = 2; - /// Zero-pads all human addresses to make them fit the canonical_length and /// trims off zeros for the reverse operation. /// This is not really smart, but allows us to see a difference (and consistent length for canonical adddresses). @@ -46,11 +38,11 @@ const SHUFFLES_DECODE: usize = 2; pub struct MockApi { /// Length of canonical addresses created with this API. Contracts should not make any assumtions /// what this value is. - canonical_length: usize, + pub canonical_length: usize, /// `canonicalize_cost` is consumed gas value when the contract all api `canonical_address` - canonicalize_cost: u64, + pub canonicalize_cost: u64, /// `humanize_cost` is consumed gas value when the contract all api `human_address` - humanize_cost: u64, + pub humanize_cost: u64, /// When set, all calls to the API fail with BackendError::Unknown containing this message backend_error: Option<&'static str>, } @@ -65,21 +57,6 @@ impl MockApi { } } - /// Read-only getter for `canonical_length`, which must not be changed by the caller. - pub fn canonical_length(&self) -> usize { - self.canonical_length - } - - /// Read-only getter for `canonical_length`, which must not be changed by the caller. - pub fn canonicalize_cost(&self) -> u64 { - self.canonicalize_cost - } - - /// Read-only getter for `canonical_length`, which must not be changed by the caller. - pub fn humanize_cost(&self) -> u64 { - self.humanize_cost - } - pub fn new_failing(backend_error: &'static str) -> Self { MockApi { backend_error: Some(backend_error), @@ -91,7 +68,7 @@ impl MockApi { impl Default for MockApi { fn default() -> Self { MockApi { - canonical_length: CANONICAL_LENGTH, + canonical_length: 24, canonicalize_cost: DEFAULT_GAS_COST_CANONICALIZE, humanize_cost: DEFAULT_GAS_COST_HUMANIZE, backend_error: None, @@ -132,7 +109,7 @@ impl BackendApi for MockApi { // the most obvious structure (https://github.com/CosmWasm/cosmwasm/issues/552) let rotate_by = digit_sum(&out) % self.canonical_length; out.rotate_left(rotate_by); - for _ in 0..SHUFFLES_ENCODE { + for _ in 0..18 { out = riffle_shuffle(&out); } (Ok(out), gas_info) @@ -156,7 +133,7 @@ impl BackendApi for MockApi { let mut tmp: Vec = canonical.into(); // Shuffle two more times which restored the original value (24 elements are back to original after 20 rounds) - for _ in 0..SHUFFLES_DECODE { + for _ in 0..2 { tmp = riffle_shuffle(&tmp); } // Rotate back @@ -255,7 +232,7 @@ mod test { #[test] fn canonical_address_max_input_length() { let api = MockApi::default(); - let human = "longer-than-the-address-length-supported-by-this-api-longer-than-54"; + let human = "longer-than-the-address-length-supported-by-this-api"; match api.canonical_address(human).0.unwrap_err() { BackendError::UserErr { .. } => {} err => panic!("Unexpected error: {:?}", err), @@ -267,7 +244,7 @@ mod test { let api = MockApi::default(); let original = "alice"; - let (canonical_res, gas_cost) = api.canonical_address(original); + let (canonical_res, gas_cost) = api.canonical_address(&original); assert_eq!(gas_cost.cost, DEFAULT_GAS_COST_CANONICALIZE); assert_eq!(gas_cost.externally_used, 0); let canonical = canonical_res.unwrap(); @@ -279,13 +256,13 @@ mod test { #[test] fn test_specified_gas_cost() { let canonicalize_cost: u64 = 42; - let humanize_cost: u64 = 101010; + let humanize_cost: u64 = 10101010; assert_ne!(canonicalize_cost, DEFAULT_GAS_COST_CANONICALIZE); assert_ne!(humanize_cost, DEFAULT_GAS_COST_HUMANIZE); let api = MockApi::new_with_gas_cost(canonicalize_cost, humanize_cost); let original = "bob"; - let (canonical_res, gas_cost) = api.canonical_address(original); + let (canonical_res, gas_cost) = api.canonical_address(&original); assert_eq!(gas_cost.cost, canonicalize_cost); assert_eq!(gas_cost.externally_used, 0); let canonical = canonical_res.unwrap(); diff --git a/packages/vm/src/testing/mod.rs b/packages/vm/src/testing/mod.rs index bf6b3b41f..8b1ffc751 100644 --- a/packages/vm/src/testing/mod.rs +++ b/packages/vm/src/testing/mod.rs @@ -2,6 +2,7 @@ mod calls; mod contract; +mod ibc_calls; mod instance; mod mock; mod querier; @@ -9,12 +10,12 @@ mod result; mod storage; pub use calls::{execute, instantiate, migrate, query, reply, sudo}; +pub use contract::Contract; #[cfg(feature = "stargate")] -pub use calls::{ +pub use ibc_calls::{ ibc_channel_close, ibc_channel_connect, ibc_channel_open, ibc_packet_ack, ibc_packet_receive, ibc_packet_timeout, }; -pub use contract::Contract; pub use instance::{ mock_instance, mock_instance_options, mock_instance_with_balances, mock_instance_with_failing_api, mock_instance_with_gas_limit, mock_instance_with_options, diff --git a/packages/vm/src/testing/querier.rs b/packages/vm/src/testing/querier.rs index b852798f3..a6d6c36bb 100644 --- a/packages/vm/src/testing/querier.rs +++ b/packages/vm/src/testing/querier.rs @@ -28,9 +28,9 @@ impl MockQuerier { } // set a new balance for the given address and return the old balance - pub fn update_balance( + pub fn update_balance>( &mut self, - addr: impl Into, + addr: U, balance: Vec, ) -> Option> { self.querier.update_balance(addr, balance) @@ -46,7 +46,6 @@ impl MockQuerier { self.querier.update_staking(denom, validators, delegations); } - #[must_use] pub fn with_custom_handler(mut self, handler: CH) -> Self where CH: Fn(&C) -> MockQuerierCustomHandlerResult, diff --git a/packages/vm/src/wasm_backend/compile.rs b/packages/vm/src/wasm_backend/compile.rs index 1b3ca63bb..132640f62 100644 --- a/packages/vm/src/wasm_backend/compile.rs +++ b/packages/vm/src/wasm_backend/compile.rs @@ -1,9 +1,11 @@ +// use wasmer_middleware_common::metering; use wasmer::Module; use crate::errors::VmResult; use crate::size::Size; use super::store::make_compile_time_store; +// use crate::middleware::DeterministicMiddleware; /// Compiles a given Wasm bytecode into a module. /// The given memory limit (in bytes) is used when memories are created. @@ -14,16 +16,3 @@ pub fn compile(code: &[u8], memory_limit: Option) -> VmResult { let module = Module::new(&store, code)?; Ok(module) } - -#[cfg(test)] -mod tests { - use super::*; - - static CONTRACT: &[u8] = include_bytes!("../../testdata/floaty.wasm"); - - #[test] - fn contract_with_floats_fails_check() { - let err = compile(CONTRACT, None).unwrap_err(); - assert!(err.to_string().contains("Float operator detected:")); - } -} diff --git a/packages/vm/src/wasm_backend/gatekeeper.rs b/packages/vm/src/wasm_backend/gatekeeper.rs deleted file mode 100644 index 7d5f625a0..000000000 --- a/packages/vm/src/wasm_backend/gatekeeper.rs +++ /dev/null @@ -1,752 +0,0 @@ -use loupe::MemoryUsage; -use wasmer::wasmparser::Operator; -use wasmer::{ - FunctionMiddleware, LocalFunctionIndex, MiddlewareError, MiddlewareReaderState, - ModuleMiddleware, -}; - -#[derive(Debug, MemoryUsage, Clone, Copy)] -struct GatekeeperConfig { - /// True iff float operations are allowed. - /// - /// Note: there are float operations in the SIMD block as well and we do not yet handle - /// any combination of `allow_floats` and `allow_feature_simd` properly. - allow_floats: bool, - // - // Standardized features - // - /// True iff operations of the "Bulk memory operations" feature are allowed. - /// See and . - allow_feature_bulk_memory_operations: bool, - /// True iff operations of the "Reference types" feature are allowed. - /// See and . - allow_feature_reference_types: bool, - /// True iff operations of the "Fixed-width SIMD" feature are allowed. - /// See and . - allow_feature_simd: bool, - // - // In-progress proposals - // - /// True iff operations of the "Exception handling" feature are allowed. - /// Note, this feature is not yet standardized! - /// See and . - allow_feature_exception_handling: bool, - /// True iff operations of the "Threads and atomics" feature are allowed. - /// Note, this feature is not yet standardized! - /// See and . - allow_feature_threads: bool, -} - -/// A middleware that ensures only deterministic operations are used (i.e. no floats). -/// It also disallows the use of Wasm features that are not explicitly enabled. -#[derive(Debug, MemoryUsage)] -#[non_exhaustive] -pub struct Gatekeeper { - config: GatekeeperConfig, -} - -impl Gatekeeper { - /// Creates a new Gatekeeper with a custom config. - /// - /// A costum configuration is potentially dangerous (non-final Wasm proposals, floats in SIMD operation). - /// For this reason, only [`Gatekeeper::default()`] is public. - fn new(config: GatekeeperConfig) -> Self { - Self { config } - } -} - -impl Default for Gatekeeper { - fn default() -> Self { - Self::new(GatekeeperConfig { - allow_floats: false, - allow_feature_bulk_memory_operations: false, - allow_feature_reference_types: false, - allow_feature_simd: false, - allow_feature_exception_handling: false, - allow_feature_threads: false, - }) - } -} - -impl ModuleMiddleware for Gatekeeper { - /// Generates a `FunctionMiddleware` for a given function. - fn generate_function_middleware(&self, _: LocalFunctionIndex) -> Box { - Box::new(FunctionGatekeeper::new(self.config)) - } -} - -#[derive(Debug)] -#[non_exhaustive] -struct FunctionGatekeeper { - config: GatekeeperConfig, -} - -impl FunctionGatekeeper { - fn new(config: GatekeeperConfig) -> Self { - Self { config } - } -} - -/// The name used in errors -const MIDDLEWARE_NAME: &str = "Gatekeeper"; - -impl FunctionMiddleware for FunctionGatekeeper { - fn feed<'a>( - &mut self, - operator: Operator<'a>, - state: &mut MiddlewareReaderState<'a>, - ) -> Result<(), MiddlewareError> { - match operator { - Operator::Unreachable - | Operator::Nop - | Operator::Block { .. } - | Operator::Loop { .. } - | Operator::If { .. } - | Operator::Else - | Operator::End - | Operator::Br { .. } - | Operator::BrIf { .. } - | Operator::BrTable { .. } - | Operator::Return - | Operator::Call { .. } - | Operator::CallIndirect { .. } - | Operator::Drop - | Operator::Select - | Operator::LocalGet { .. } - | Operator::LocalSet { .. } - | Operator::LocalTee { .. } - | Operator::GlobalGet { .. } - | Operator::GlobalSet { .. } - | Operator::I32Load { .. } - | Operator::I64Load { .. } - | Operator::I32Load8S { .. } - | Operator::I32Load8U { .. } - | Operator::I32Load16S { .. } - | Operator::I32Load16U { .. } - | Operator::I64Load8S { .. } - | Operator::I64Load8U { .. } - | Operator::I64Load16S { .. } - | Operator::I64Load16U { .. } - | Operator::I64Load32S { .. } - | Operator::I64Load32U { .. } - | Operator::I32Store { .. } - | Operator::I64Store { .. } - | Operator::I32Store8 { .. } - | Operator::I32Store16 { .. } - | Operator::I64Store8 { .. } - | Operator::I64Store16 { .. } - | Operator::I64Store32 { .. } - | Operator::MemorySize { .. } - | Operator::MemoryGrow { .. } - | Operator::I32Const { .. } - | Operator::I64Const { .. } - | Operator::I32Eqz - | Operator::I32Eq - | Operator::I32Ne - | Operator::I32LtS - | Operator::I32LtU - | Operator::I32GtS - | Operator::I32GtU - | Operator::I32LeS - | Operator::I32LeU - | Operator::I32GeS - | Operator::I32GeU - | Operator::I64Eqz - | Operator::I64Eq - | Operator::I64Ne - | Operator::I64LtS - | Operator::I64LtU - | Operator::I64GtS - | Operator::I64GtU - | Operator::I64LeS - | Operator::I64LeU - | Operator::I64GeS - | Operator::I64GeU - | Operator::I32Clz - | Operator::I32Ctz - | Operator::I32Popcnt - | Operator::I32Add - | Operator::I32Sub - | Operator::I32Mul - | Operator::I32DivS - | Operator::I32DivU - | Operator::I32RemS - | Operator::I32RemU - | Operator::I32And - | Operator::I32Or - | Operator::I32Xor - | Operator::I32Shl - | Operator::I32ShrS - | Operator::I32ShrU - | Operator::I32Rotl - | Operator::I32Rotr - | Operator::I64Clz - | Operator::I64Ctz - | Operator::I64Popcnt - | Operator::I64Add - | Operator::I64Sub - | Operator::I64Mul - | Operator::I64DivS - | Operator::I64DivU - | Operator::I64RemS - | Operator::I64RemU - | Operator::I64And - | Operator::I64Or - | Operator::I64Xor - | Operator::I64Shl - | Operator::I64ShrS - | Operator::I64ShrU - | Operator::I64Rotl - | Operator::I64Rotr - | Operator::I32WrapI64 - | Operator::I32Extend8S - | Operator::I32Extend16S - | Operator::I64Extend8S - | Operator::I64Extend16S - | Operator::I64ExtendI32S - | Operator::I64Extend32S - | Operator::I64ExtendI32U => { - state.push_operator(operator); - Ok(()) - } - Operator::RefNull { .. } - | Operator::RefIsNull - | Operator::RefFunc { .. } - | Operator::ReturnCall { .. } - | Operator::ReturnCallIndirect { .. } - | Operator::TypedSelect { .. } - | Operator::TableGet { .. } - | Operator::TableSet { .. } - | Operator::TableGrow { .. } - | Operator::TableSize { .. } => { - if self.config.allow_feature_reference_types { - state.push_operator(operator); - Ok(()) - } else { - let msg = format!("Reference type operation detected: {:?}. Reference types are not supported.", operator); - Err(MiddlewareError::new(MIDDLEWARE_NAME, msg)) - } - } - Operator::MemoryAtomicNotify { .. } - | Operator::MemoryAtomicWait32 { .. } - | Operator::MemoryAtomicWait64 { .. } - | Operator::AtomicFence { .. } - | Operator::I32AtomicLoad { .. } - | Operator::I64AtomicLoad { .. } - | Operator::I32AtomicLoad8U { .. } - | Operator::I32AtomicLoad16U { .. } - | Operator::I64AtomicLoad8U { .. } - | Operator::I64AtomicLoad16U { .. } - | Operator::I64AtomicLoad32U { .. } - | Operator::I32AtomicStore { .. } - | Operator::I64AtomicStore { .. } - | Operator::I32AtomicStore8 { .. } - | Operator::I32AtomicStore16 { .. } - | Operator::I64AtomicStore8 { .. } - | Operator::I64AtomicStore16 { .. } - | Operator::I64AtomicStore32 { .. } - | Operator::I32AtomicRmwAdd { .. } - | Operator::I64AtomicRmwAdd { .. } - | Operator::I32AtomicRmw8AddU { .. } - | Operator::I32AtomicRmw16AddU { .. } - | Operator::I64AtomicRmw8AddU { .. } - | Operator::I64AtomicRmw16AddU { .. } - | Operator::I64AtomicRmw32AddU { .. } - | Operator::I32AtomicRmwSub { .. } - | Operator::I64AtomicRmwSub { .. } - | Operator::I32AtomicRmw8SubU { .. } - | Operator::I32AtomicRmw16SubU { .. } - | Operator::I64AtomicRmw8SubU { .. } - | Operator::I64AtomicRmw16SubU { .. } - | Operator::I64AtomicRmw32SubU { .. } - | Operator::I32AtomicRmwAnd { .. } - | Operator::I64AtomicRmwAnd { .. } - | Operator::I32AtomicRmw8AndU { .. } - | Operator::I32AtomicRmw16AndU { .. } - | Operator::I64AtomicRmw8AndU { .. } - | Operator::I64AtomicRmw16AndU { .. } - | Operator::I64AtomicRmw32AndU { .. } - | Operator::I32AtomicRmwOr { .. } - | Operator::I64AtomicRmwOr { .. } - | Operator::I32AtomicRmw8OrU { .. } - | Operator::I32AtomicRmw16OrU { .. } - | Operator::I64AtomicRmw8OrU { .. } - | Operator::I64AtomicRmw16OrU { .. } - | Operator::I64AtomicRmw32OrU { .. } - | Operator::I32AtomicRmwXor { .. } - | Operator::I64AtomicRmwXor { .. } - | Operator::I32AtomicRmw8XorU { .. } - | Operator::I32AtomicRmw16XorU { .. } - | Operator::I64AtomicRmw8XorU { .. } - | Operator::I64AtomicRmw16XorU { .. } - | Operator::I64AtomicRmw32XorU { .. } - | Operator::I32AtomicRmwXchg { .. } - | Operator::I64AtomicRmwXchg { .. } - | Operator::I32AtomicRmw8XchgU { .. } - | Operator::I32AtomicRmw16XchgU { .. } - | Operator::I64AtomicRmw8XchgU { .. } - | Operator::I64AtomicRmw16XchgU { .. } - | Operator::I64AtomicRmw32XchgU { .. } - | Operator::I32AtomicRmwCmpxchg { .. } - | Operator::I64AtomicRmwCmpxchg { .. } - | Operator::I32AtomicRmw8CmpxchgU { .. } - | Operator::I32AtomicRmw16CmpxchgU { .. } - | Operator::I64AtomicRmw8CmpxchgU { .. } - | Operator::I64AtomicRmw16CmpxchgU { .. } - | Operator::I64AtomicRmw32CmpxchgU { .. } => { - if self.config.allow_feature_threads { - state.push_operator(operator); - Ok(()) - } else { - let msg = format!("Threads operator detected: {:?}. The Wasm Threads extension is not supported.", operator); - Err(MiddlewareError::new(MIDDLEWARE_NAME, msg)) - } - } - Operator::V128Load { .. } - | Operator::V128Store { .. } - | Operator::V128Const { .. } - | Operator::I8x16Splat - | Operator::I8x16ExtractLaneS { .. } - | Operator::I8x16ExtractLaneU { .. } - | Operator::I8x16ReplaceLane { .. } - | Operator::I16x8Splat - | Operator::I16x8ExtractLaneS { .. } - | Operator::I16x8ExtractLaneU { .. } - | Operator::I16x8ReplaceLane { .. } - | Operator::I32x4Splat - | Operator::I32x4ExtractLane { .. } - | Operator::I32x4ReplaceLane { .. } - | Operator::I64x2Splat - | Operator::I64x2ExtractLane { .. } - | Operator::I64x2ReplaceLane { .. } - | Operator::I8x16Eq - | Operator::I8x16Ne - | Operator::I8x16LtS - | Operator::I8x16LtU - | Operator::I8x16GtS - | Operator::I8x16GtU - | Operator::I8x16LeS - | Operator::I8x16LeU - | Operator::I8x16GeS - | Operator::I8x16GeU - | Operator::I16x8Eq - | Operator::I16x8Ne - | Operator::I16x8LtS - | Operator::I16x8LtU - | Operator::I16x8GtS - | Operator::I16x8GtU - | Operator::I16x8LeS - | Operator::I16x8LeU - | Operator::I16x8GeS - | Operator::I16x8GeU - | Operator::I32x4Eq - | Operator::I32x4Ne - | Operator::I32x4LtS - | Operator::I32x4LtU - | Operator::I32x4GtS - | Operator::I32x4GtU - | Operator::I32x4LeS - | Operator::I32x4LeU - | Operator::I32x4GeS - | Operator::I32x4GeU - | Operator::V128Not - | Operator::V128And - | Operator::V128AndNot - | Operator::V128Or - | Operator::V128Xor - | Operator::V128Bitselect - | Operator::I8x16Abs - | Operator::I8x16Neg - | Operator::V128AnyTrue - | Operator::I8x16AllTrue - | Operator::I8x16Bitmask - | Operator::I8x16Shl - | Operator::I8x16ShrS - | Operator::I8x16ShrU - | Operator::I8x16Add - | Operator::I8x16AddSatS - | Operator::I8x16AddSatU - | Operator::I8x16Sub - | Operator::I8x16SubSatS - | Operator::I8x16SubSatU - | Operator::I8x16MinS - | Operator::I8x16MinU - | Operator::I8x16MaxS - | Operator::I8x16MaxU - | Operator::I16x8Abs - | Operator::I16x8Neg - | Operator::I16x8AllTrue - | Operator::I16x8Bitmask - | Operator::I16x8Shl - | Operator::I16x8ShrS - | Operator::I16x8ShrU - | Operator::I16x8Add - | Operator::I16x8AddSatS - | Operator::I16x8AddSatU - | Operator::I16x8Sub - | Operator::I16x8SubSatS - | Operator::I16x8SubSatU - | Operator::I16x8Mul - | Operator::I16x8MinS - | Operator::I16x8MinU - | Operator::I16x8MaxS - | Operator::I16x8MaxU - | Operator::I32x4Abs - | Operator::I32x4Neg - | Operator::I32x4AllTrue - | Operator::I32x4Bitmask - | Operator::I32x4Shl - | Operator::I32x4ShrS - | Operator::I32x4ShrU - | Operator::I32x4Add - | Operator::I32x4Sub - | Operator::I32x4Mul - | Operator::I32x4MinS - | Operator::I32x4MinU - | Operator::I32x4MaxS - | Operator::I32x4MaxU - | Operator::I32x4DotI16x8S - | Operator::I64x2Neg - | Operator::I64x2Shl - | Operator::I64x2ShrS - | Operator::I64x2ShrU - | Operator::I64x2Add - | Operator::I64x2Sub - | Operator::I64x2Mul - | Operator::I8x16Swizzle - | Operator::I8x16Shuffle { .. } - | Operator::V128Load8Splat { .. } - | Operator::V128Load16Splat { .. } - | Operator::V128Load32Splat { .. } - | Operator::V128Load32Zero { .. } - | Operator::V128Load64Splat { .. } - | Operator::V128Load64Zero { .. } - | Operator::I8x16NarrowI16x8S - | Operator::I8x16NarrowI16x8U - | Operator::I16x8NarrowI32x4S - | Operator::I16x8NarrowI32x4U - | Operator::I16x8ExtendLowI8x16S - | Operator::I16x8ExtendHighI8x16S - | Operator::I16x8ExtendLowI8x16U - | Operator::I16x8ExtendHighI8x16U - | Operator::I32x4ExtendLowI16x8S - | Operator::I32x4ExtendHighI16x8S - | Operator::I32x4ExtendLowI16x8U - | Operator::I32x4ExtendHighI16x8U - | Operator::V128Load8x8S { .. } - | Operator::V128Load8x8U { .. } - | Operator::V128Load16x4S { .. } - | Operator::V128Load16x4U { .. } - | Operator::V128Load32x2S { .. } - | Operator::V128Load32x2U { .. } - | Operator::I8x16RoundingAverageU - | Operator::I16x8RoundingAverageU - | Operator::V128Load8Lane { .. } - | Operator::V128Load16Lane { .. } - | Operator::V128Load32Lane { .. } - | Operator::V128Load64Lane { .. } - | Operator::V128Store8Lane { .. } - | Operator::V128Store16Lane { .. } - | Operator::V128Store32Lane { .. } - | Operator::V128Store64Lane { .. } - | Operator::I64x2Eq - | Operator::I64x2Ne - | Operator::I64x2LtS - | Operator::I64x2GtS - | Operator::I64x2LeS - | Operator::I64x2GeS - | Operator::I8x16Popcnt - | Operator::I16x8ExtAddPairwiseI8x16S - | Operator::I16x8ExtAddPairwiseI8x16U - | Operator::I16x8Q15MulrSatS - | Operator::I16x8ExtMulLowI8x16S - | Operator::I16x8ExtMulHighI8x16S - | Operator::I16x8ExtMulLowI8x16U - | Operator::I16x8ExtMulHighI8x16U - | Operator::I32x4ExtAddPairwiseI16x8S - | Operator::I32x4ExtAddPairwiseI16x8U - | Operator::I32x4ExtMulLowI16x8S - | Operator::I32x4ExtMulHighI16x8S - | Operator::I32x4ExtMulLowI16x8U - | Operator::I32x4ExtMulHighI16x8U - | Operator::I64x2Abs - | Operator::I64x2AllTrue - | Operator::I64x2Bitmask - | Operator::I64x2ExtendLowI32x4S - | Operator::I64x2ExtendHighI32x4S - | Operator::I64x2ExtendLowI32x4U - | Operator::I64x2ExtendHighI32x4U - | Operator::I64x2ExtMulLowI32x4S - | Operator::I64x2ExtMulHighI32x4S - | Operator::I64x2ExtMulLowI32x4U - | Operator::I64x2ExtMulHighI32x4U - | Operator::I32x4TruncSatF64x2SZero - | Operator::I32x4TruncSatF64x2UZero - | Operator::F64x2ConvertLowI32x4S - | Operator::F64x2ConvertLowI32x4U - | Operator::F32x4DemoteF64x2Zero - | Operator::F64x2PromoteLowF32x4 => { - if self.config.allow_feature_simd { - state.push_operator(operator); - Ok(()) - } else { - let msg = format!( - "SIMD operator detected: {:?}. The Wasm SIMD extension is not supported.", - operator - ); - Err(MiddlewareError::new(MIDDLEWARE_NAME, msg)) - } - } - Operator::F32Load { .. } - | Operator::F64Load { .. } - | Operator::F32Store { .. } - | Operator::F64Store { .. } - | Operator::F32Const { .. } - | Operator::F64Const { .. } - | Operator::F32Eq - | Operator::F32Ne - | Operator::F32Lt - | Operator::F32Gt - | Operator::F32Le - | Operator::F32Ge - | Operator::F64Eq - | Operator::F64Ne - | Operator::F64Lt - | Operator::F64Gt - | Operator::F64Le - | Operator::F64Ge - | Operator::F32Abs - | Operator::F32Neg - | Operator::F32Ceil - | Operator::F32Floor - | Operator::F32Trunc - | Operator::F32Nearest - | Operator::F32Sqrt - | Operator::F32Add - | Operator::F32Sub - | Operator::F32Mul - | Operator::F32Div - | Operator::F32Min - | Operator::F32Max - | Operator::F32Copysign - | Operator::F64Abs - | Operator::F64Neg - | Operator::F64Ceil - | Operator::F64Floor - | Operator::F64Trunc - | Operator::F64Nearest - | Operator::F64Sqrt - | Operator::F64Add - | Operator::F64Sub - | Operator::F64Mul - | Operator::F64Div - | Operator::F64Min - | Operator::F64Max - | Operator::F64Copysign - | Operator::I32TruncF32S - | Operator::I32TruncF32U - | Operator::I32TruncF64S - | Operator::I32TruncF64U - | Operator::I64TruncF32S - | Operator::I64TruncF32U - | Operator::I64TruncF64S - | Operator::I64TruncF64U - | Operator::F32ConvertI32S - | Operator::F32ConvertI32U - | Operator::F32ConvertI64S - | Operator::F32ConvertI64U - | Operator::F32DemoteF64 - | Operator::F64ConvertI32S - | Operator::F64ConvertI32U - | Operator::F64ConvertI64S - | Operator::F64ConvertI64U - | Operator::F64PromoteF32 - | Operator::I32ReinterpretF32 - | Operator::I64ReinterpretF64 - | Operator::F32ReinterpretI32 - | Operator::F64ReinterpretI64 - | Operator::I32TruncSatF32S - | Operator::I32TruncSatF32U - | Operator::I32TruncSatF64S - | Operator::I32TruncSatF64U - | Operator::I64TruncSatF32S - | Operator::I64TruncSatF32U - | Operator::I64TruncSatF64S - | Operator::I64TruncSatF64U - | Operator::F32x4Splat - | Operator::F32x4ExtractLane { .. } - | Operator::F32x4ReplaceLane { .. } - | Operator::F64x2Splat - | Operator::F64x2ExtractLane { .. } - | Operator::F64x2ReplaceLane { .. } - | Operator::F32x4Eq - | Operator::F32x4Ne - | Operator::F32x4Lt - | Operator::F32x4Gt - | Operator::F32x4Le - | Operator::F32x4Ge - | Operator::F64x2Eq - | Operator::F64x2Ne - | Operator::F64x2Lt - | Operator::F64x2Gt - | Operator::F64x2Le - | Operator::F64x2Ge - | Operator::F32x4Ceil - | Operator::F32x4Floor - | Operator::F32x4Trunc - | Operator::F32x4Nearest - | Operator::F64x2Ceil - | Operator::F64x2Floor - | Operator::F64x2Trunc - | Operator::F64x2Nearest - | Operator::F32x4Abs - | Operator::F32x4Neg - | Operator::F32x4Sqrt - | Operator::F32x4Add - | Operator::F32x4Sub - | Operator::F32x4Mul - | Operator::F32x4Div - | Operator::F32x4Min - | Operator::F32x4Max - | Operator::F32x4PMin - | Operator::F32x4PMax - | Operator::F64x2Abs - | Operator::F64x2Neg - | Operator::F64x2Sqrt - | Operator::F64x2Add - | Operator::F64x2Sub - | Operator::F64x2Mul - | Operator::F64x2Div - | Operator::F64x2Min - | Operator::F64x2Max - | Operator::F64x2PMin - | Operator::F64x2PMax - | Operator::I32x4TruncSatF32x4S - | Operator::I32x4TruncSatF32x4U - | Operator::F32x4ConvertI32x4S - | Operator::F32x4ConvertI32x4U => { - if self.config.allow_floats { - state.push_operator(operator); - Ok(()) - } else { - let msg = format!( - "Float operator detected: {:?}. The use of floats is not supported.", - operator - ); - Err(MiddlewareError::new(MIDDLEWARE_NAME, msg)) - } - } - Operator::MemoryInit { .. } - | Operator::DataDrop { .. } - | Operator::MemoryCopy { .. } - | Operator::MemoryFill { .. } - | Operator::TableInit { .. } - | Operator::ElemDrop { .. } - | Operator::TableCopy { .. } - | Operator::TableFill { .. } => { - if self.config.allow_feature_bulk_memory_operations { - state.push_operator(operator); - Ok(()) - } else { - let msg = format!("Bulk memory operation detected: {:?}. Bulk memory operations are not supported.", operator); - Err(MiddlewareError::new(MIDDLEWARE_NAME, msg)) - } - } - Operator::Try { .. } - | Operator::Catch { .. } - | Operator::Throw { .. } - | Operator::Rethrow { .. } - | Operator::Unwind { .. } - | Operator::Delegate { .. } - | Operator::CatchAll => { - if self.config.allow_feature_exception_handling { - state.push_operator(operator); - Ok(()) - } else { - let msg = format!("Exception handling operation detected: {:?}. Exception handling is not supported.", operator); - Err(MiddlewareError::new(MIDDLEWARE_NAME, msg)) - } - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use std::sync::Arc; - use wasmer::{CompilerConfig, Cranelift, Module, Store, Universal}; - - #[test] - fn valid_wasm_instance_sanity() { - let wasm = wat::parse_str( - r#" - (module - (func (export "sum") (param i32 i32) (result i32) - get_local 0 - get_local 1 - i32.add - )) - "#, - ) - .unwrap(); - - let deterministic = Arc::new(Gatekeeper::default()); - let mut compiler_config = Cranelift::default(); - compiler_config.push_middleware(deterministic); - let store = Store::new(&Universal::new(compiler_config).engine()); - let result = Module::new(&store, &wasm); - assert!(result.is_ok()); - } - - #[test] - fn parser_floats_are_not_supported() { - let wasm = wat::parse_str( - r#" - (module - (func $to_float (param i32) (result f32) - get_local 0 - f32.convert_u/i32 - )) - "#, - ) - .unwrap(); - - let deterministic = Arc::new(Gatekeeper::default()); - let mut compiler_config = Cranelift::default(); - compiler_config.push_middleware(deterministic); - let store = Store::new(&Universal::new(compiler_config).engine()); - let result = Module::new(&store, &wasm); - assert!(result - .unwrap_err() - .to_string() - .contains("Float operator detected:")); - } - - #[test] - fn bulk_operations_not_supported() { - let wasm = wat::parse_str( - r#" - (module - (memory (export "memory") 1) - (func (param $dst i32) (param $src i32) (param $size i32) (result i32) - local.get $dst - local.get $src - local.get $size - memory.copy - local.get $dst)) - "#, - ) - .unwrap(); - - let deterministic = Arc::new(Gatekeeper::default()); - let mut compiler_config = Cranelift::default(); - compiler_config.push_middleware(deterministic); - let store = Store::new(&Universal::new(compiler_config).engine()); - let result = Module::new(&store, &wasm); - assert!(result - .unwrap_err() - .to_string() - .contains("Bulk memory operation")); - } -} diff --git a/packages/vm/src/wasm_backend/limiting_tunables.rs b/packages/vm/src/wasm_backend/limiting_tunables.rs index 007bc34a4..4bf3f3ba3 100644 --- a/packages/vm/src/wasm_backend/limiting_tunables.rs +++ b/packages/vm/src/wasm_backend/limiting_tunables.rs @@ -1,7 +1,6 @@ use std::ptr::NonNull; use std::sync::Arc; -use loupe::MemoryUsage; use wasmer::{ vm::{self, MemoryError, MemoryStyle, TableStyle, VMMemoryDefinition, VMTableDefinition}, MemoryType, Pages, TableType, Tunables, @@ -11,7 +10,6 @@ use wasmer::{ /// /// After adjusting the memory limits, it delegates all other logic /// to the base tunables. -#[derive(MemoryUsage)] pub struct LimitingTunables { /// The maxium a linear memory is allowed to be (in Wasm pages, 65 KiB each). /// Since Wasmer ensures there is only none or one memory, this is practically diff --git a/packages/vm/src/wasm_backend/mod.rs b/packages/vm/src/wasm_backend/mod.rs index 3e503c1da..1a53211db 100644 --- a/packages/vm/src/wasm_backend/mod.rs +++ b/packages/vm/src/wasm_backend/mod.rs @@ -1,5 +1,4 @@ mod compile; -mod gatekeeper; mod limiting_tunables; mod store; diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs index 97a914360..041e3c7ef 100644 --- a/packages/vm/src/wasm_backend/store.rs +++ b/packages/vm/src/wasm_backend/store.rs @@ -5,14 +5,14 @@ use wasmer::Cranelift; #[cfg(not(feature = "cranelift"))] use wasmer::Singlepass; use wasmer::{ - wasmparser::Operator, BaseTunables, CompilerConfig, Engine, Pages, Store, Target, Universal, + wasmparser::Operator, BaseTunables, CompilerConfig, Engine, Pages, Store, Target, JIT, WASM_PAGE_SIZE, }; use wasmer_middlewares::Metering; +use crate::middleware::Deterministic; use crate::size::Size; -use super::gatekeeper::Gatekeeper; use super::limiting_tunables::LimitingTunables; /// WebAssembly linear memory objects have sizes measured in pages. Each page @@ -32,7 +32,7 @@ fn cost(_operator: &Operator) -> u64 { /// If memory_limit is None, no limit is applied. pub fn make_compile_time_store(memory_limit: Option) -> Store { let gas_limit = 0; - let deterministic = Arc::new(Gatekeeper::default()); + let deterministic = Arc::new(Deterministic::new()); let metering = Arc::new(Metering::new(gas_limit, cost)); #[cfg(feature = "cranelift")] @@ -40,7 +40,7 @@ pub fn make_compile_time_store(memory_limit: Option) -> Store { let mut config = Cranelift::default(); config.push_middleware(deterministic); config.push_middleware(metering); - let engine = Universal::new(config).engine(); + let engine = JIT::new(config).engine(); make_store_with_engine(&engine, memory_limit) } @@ -49,7 +49,7 @@ pub fn make_compile_time_store(memory_limit: Option) -> Store { let mut config = Singlepass::default(); config.push_middleware(deterministic); config.push_middleware(metering); - let engine = Universal::new(config).engine(); + let engine = JIT::new(config).engine(); make_store_with_engine(&engine, memory_limit) } } @@ -57,7 +57,7 @@ pub fn make_compile_time_store(memory_limit: Option) -> Store { /// Created a store with no compiler and the given memory limit (in bytes) /// If memory_limit is None, no limit is applied. pub fn make_runtime_store(memory_limit: Option) -> Store { - let engine = Universal::headless().engine(); + let engine = JIT::headless().engine(); make_store_with_engine(&engine, memory_limit) } diff --git a/packages/vm/testdata/floaty.wasm b/packages/vm/testdata/floaty.wasm deleted file mode 100644 index 8334867cf..000000000 Binary files a/packages/vm/testdata/floaty.wasm and /dev/null differ diff --git a/packages/vm/testdata/hackatom.wasm b/packages/vm/testdata/hackatom.wasm index 333e1ca11..e871ad74c 120000 --- a/packages/vm/testdata/hackatom.wasm +++ b/packages/vm/testdata/hackatom.wasm @@ -1 +1 @@ -hackatom_0.16.wasm \ No newline at end of file +hackatom_0.14.wasm \ No newline at end of file diff --git a/packages/vm/testdata/hackatom_0.15.wasm b/packages/vm/testdata/hackatom_0.15.wasm deleted file mode 100644 index 92f5db409..000000000 Binary files a/packages/vm/testdata/hackatom_0.15.wasm and /dev/null differ diff --git a/packages/vm/testdata/hackatom_0.16.wasm b/packages/vm/testdata/hackatom_0.16.wasm deleted file mode 100644 index 1787fc84a..000000000 Binary files a/packages/vm/testdata/hackatom_0.16.wasm and /dev/null differ diff --git a/packages/vm/testdata/hackatom_0.6.wasm b/packages/vm/testdata/hackatom_0.6.wasm new file mode 100644 index 000000000..cf773511d Binary files /dev/null and b/packages/vm/testdata/hackatom_0.6.wasm differ diff --git a/packages/vm/testdata/ibc_reflect.wasm b/packages/vm/testdata/ibc_reflect.wasm index 43a733375..60cef25e8 120000 --- a/packages/vm/testdata/ibc_reflect.wasm +++ b/packages/vm/testdata/ibc_reflect.wasm @@ -1 +1 @@ -ibc_reflect_0.16.wasm \ No newline at end of file +ibc_reflect_0.14.wasm \ No newline at end of file diff --git a/packages/vm/testdata/ibc_reflect_0.14.wasm b/packages/vm/testdata/ibc_reflect_0.14.wasm index e23d34604..6851c111e 100644 Binary files a/packages/vm/testdata/ibc_reflect_0.14.wasm and b/packages/vm/testdata/ibc_reflect_0.14.wasm differ diff --git a/packages/vm/testdata/ibc_reflect_0.15.wasm b/packages/vm/testdata/ibc_reflect_0.15.wasm deleted file mode 100644 index e80ecfe4a..000000000 Binary files a/packages/vm/testdata/ibc_reflect_0.15.wasm and /dev/null differ diff --git a/packages/vm/testdata/ibc_reflect_0.16.wasm b/packages/vm/testdata/ibc_reflect_0.16.wasm deleted file mode 100644 index 5c4ced504..000000000 Binary files a/packages/vm/testdata/ibc_reflect_0.16.wasm and /dev/null differ diff --git a/packages/vm/testdata/queue_0.16.2_with_migrate.wasm b/packages/vm/testdata/queue_0.16.2_with_migrate.wasm deleted file mode 100644 index 0ba7a39fe..000000000 Binary files a/packages/vm/testdata/queue_0.16.2_with_migrate.wasm and /dev/null differ diff --git a/packages/vm/testdata/queue_0.16.2_without_migrate.wasm b/packages/vm/testdata/queue_0.16.2_without_migrate.wasm deleted file mode 100644 index d51fb9393..000000000 Binary files a/packages/vm/testdata/queue_0.16.2_without_migrate.wasm and /dev/null differ