diff --git a/.circleci/config.yml b/.circleci/config.yml index 33de36d561..8003775578 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,11 +7,10 @@ workflows: - package_schema - package_std - package_storage + - package_vm - package_vm_cranelift - - package_vm_singlepass - contract_burner - contract_hackatom - - contract_hackatom_in_singlepass_vm - contract_queue - contract_reflect - contract_staking @@ -19,14 +18,15 @@ workflows: - clippy - benchmarking: requires: + - package_vm - package_vm_cranelift - - package_vm_singlepass filters: branches: only: - master # 👇 Add your branch here if benchmarking matters to your work - benchmarking + - upgrade-to-wasmer-reborn deploy: jobs: - build_and_upload_devcontracts: @@ -154,7 +154,7 @@ jobs: - target/debug/deps key: cargocache-v2-package_storage-rust:1.47.0-{{ checksum "Cargo.lock" }} - package_vm_cranelift: + package_vm: docker: - image: rust:1.47.0 steps: @@ -164,26 +164,34 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_vm_cranelift-rust:1.47.0-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_vm-rust:1.47.0-{{ checksum "Cargo.lock" }} - run: name: Build working_directory: ~/project/packages/vm - command: cargo build --locked --no-default-features --features default-cranelift,iterator + command: cargo build --locked + - run: + name: Build with iterator + working_directory: ~/project/packages/vm + command: cargo build --locked --features iterator - run: name: Test working_directory: ~/project/packages/vm - command: cargo test --locked --no-default-features --features default-cranelift,iterator + command: cargo test --locked + - run: + name: Test with iterator + working_directory: ~/project/packages/vm + command: cargo test --locked --features iterator - save_cache: paths: - /usr/local/cargo/registry - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_vm_cranelift-rust:1.47.0-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_vm-rust:1.47.0-{{ checksum "Cargo.lock" }} - package_vm_singlepass: + package_vm_cranelift: docker: - - image: rustlang/rust:nightly + - image: rust:1.47.0 steps: - checkout - run: @@ -191,30 +199,30 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_vm_singlepass-rust:nightly-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_vm_cranelift-rust:1.47.0-{{ checksum "Cargo.lock" }} - run: name: Build working_directory: ~/project/packages/vm - command: cargo build --locked + command: cargo build --locked --features cranelift - run: name: Build with iterator working_directory: ~/project/packages/vm - command: cargo build --locked --features iterator + command: cargo build --locked --features cranelift,iterator - run: name: Test working_directory: ~/project/packages/vm - command: cargo test --locked + command: cargo test --locked --features cranelift - run: name: Test with iterator working_directory: ~/project/packages/vm - command: cargo test --locked --features iterator + command: cargo test --locked --features cranelift,iterator - save_cache: paths: - /usr/local/cargo/registry - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_vm_singlepass-rust:nightly-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_vm_cranelift-rust:1.47.0-{{ checksum "Cargo.lock" }} contract_burner: docker: @@ -241,8 +249,11 @@ jobs: name: Unit tests command: cargo unit-test --locked - run: - name: Integration tests + name: Integration tests (cranelift backend) command: cargo integration-test --locked + - run: + name: Integration tests (singlepass backend) + command: cargo integration-test --locked --no-default-features - run: name: Build and run schema generator command: cargo schema --locked @@ -291,8 +302,11 @@ jobs: name: Unit tests command: cargo unit-test --locked - run: - name: Integration tests + name: Integration tests (cranelift backend) command: cargo integration-test --locked + - run: + name: Integration tests (singlepass backend) + command: cargo integration-test --locked --no-default-features - run: name: Build and run schema generator command: cargo schema --locked @@ -316,43 +330,6 @@ jobs: - target/wasm32-unknown-unknown/release/deps key: cargocache-v2-contract_hackatom-rust:1.47.0-{{ checksum "Cargo.lock" }} - # In this job we use singlepass as the VM to execute integration tests. This requires Rust nightly. - # Avoid duplicating generic checks like unit tests or schema generation – they belong in the generic hackatom job. - contract_hackatom_in_singlepass_vm: - docker: - - image: rustlang/rust:nightly - environment: - RUST_BACKTRACE: 1 - working_directory: ~/cosmwasm/contracts/hackatom - steps: - - checkout: - path: ~/cosmwasm - - run: - name: Version information - command: rustc --version; cargo --version; rustup --version - - restore_cache: - keys: - - cargocache-v2-contract_hackatom_in_singlepass_vm-rust:nightly-{{ checksum "Cargo.lock" }} - - run: - name: Add wasm32 target - command: rustup target add wasm32-unknown-unknown && rustup target list --installed - - run: - name: Build wasm binary - command: cargo wasm --locked - - run: - name: Integration tests - command: cargo integration-test --no-default-features --features singlepass --locked - - save_cache: - paths: - - /usr/local/cargo/registry - - target/debug/.fingerprint - - target/debug/build - - target/debug/deps - - target/wasm32-unknown-unknown/release/.fingerprint - - target/wasm32-unknown-unknown/release/build - - target/wasm32-unknown-unknown/release/deps - key: cargocache-v2-contract_hackatom_in_singlepass_vm-rust:nightly-{{ checksum "Cargo.lock" }} - contract_queue: docker: - image: rust:1.47.0 @@ -378,8 +355,11 @@ jobs: name: Unit tests command: cargo unit-test --locked - run: - name: Integration tests + name: Integration tests (cranelift backend) command: cargo integration-test --locked + - run: + name: Integration tests (singlepass backend) + command: cargo integration-test --locked --no-default-features - run: name: Build and run schema generator command: cargo schema --locked @@ -428,8 +408,11 @@ jobs: name: Unit tests command: cargo unit-test --locked - run: - name: Integration tests + name: Integration tests (cranelift backend) command: cargo integration-test --locked + - run: + name: Integration tests (singlepass backend) + command: cargo integration-test --locked --no-default-features - run: name: Build and run schema generator command: cargo schema --locked @@ -478,8 +461,11 @@ jobs: name: Unit tests command: cargo unit-test --locked - run: - name: Integration tests + name: Integration tests (cranelift backend) command: cargo integration-test --locked + - run: + name: Integration tests (singlepass backend) + command: cargo integration-test --locked --no-default-features - run: name: Build and run schema generator command: cargo schema --locked @@ -551,23 +537,11 @@ jobs: clippy: docker: - image: rust:1.47.0 - environment: - # Make sure to choose version with clippy present: https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu.html - NIGHTLY_TOOLCHAIN: nightly-2020-09-08 steps: - checkout - run: - name: Install Rust nightly - command: | - rustup --version - rustup toolchain install $NIGHTLY_TOOLCHAIN --allow-downgrade --profile minimal --component clippy - rustup target list --installed - - run: - name: Version information (default; stable) + name: Version information command: rustc --version && cargo --version - - run: - name: Version information (nightly) - command: rustc +$NIGHTLY_TOOLCHAIN --version && cargo +$NIGHTLY_TOOLCHAIN --version - restore_cache: keys: - cargocache-v2-clippy-rust:1.47.0-{{ checksum "Cargo.lock" }}-{{ checksum "contracts/burner/Cargo.lock" }}-{{ checksum "contracts/hackatom/Cargo.lock" }}-{{ checksum "contracts/queue/Cargo.lock" }}-{{ checksum "contracts/reflect/Cargo.lock" }}-{{ checksum "contracts/staking/Cargo.lock" }} @@ -598,21 +572,13 @@ jobs: working_directory: ~/project/packages/storage command: cargo clippy --features iterator -- -D warnings - run: - name: Clippy linting on vm (singlepass; no feature flags) + name: Clippy linting on vm (no feature flags) working_directory: ~/project/packages/vm - command: cargo +$NIGHTLY_TOOLCHAIN clippy -- -D warnings - - run: - name: Clippy linting on vm (singlepass; all feature flags) - working_directory: ~/project/packages/vm - command: cargo +$NIGHTLY_TOOLCHAIN clippy --features iterator -- -D warnings - - run: - name: Clippy linting on vm (cranelift; no feature flags) - working_directory: ~/project/packages/vm - command: cargo +$NIGHTLY_TOOLCHAIN clippy --no-default-features --features default-cranelift -- -D warnings + command: cargo clippy -- -D warnings - run: - name: Clippy linting on vm (cranelift; all feature flags) + name: Clippy linting on vm (all feature flags) working_directory: ~/project/packages/vm - command: cargo +$NIGHTLY_TOOLCHAIN clippy --no-default-features --features default-cranelift,iterator -- -D warnings + command: cargo clippy --features cranelift,iterator -- -D warnings # # Contracts # @@ -663,32 +629,23 @@ jobs: docker: - image: rust:1.47.0 environment: - NIGHTLY_TOOLCHAIN: nightly-2020-09-08 + RUST_BACKTRACE: 1 steps: - checkout - - run: - name: Install Rust nightly - command: | - rustup --version - rustup toolchain install $NIGHTLY_TOOLCHAIN --allow-downgrade --profile minimal --component clippy - rustup target list --installed - run: name: Version information (default; stable) command: rustc --version && cargo --version - - run: - name: Version information (nightly) - command: rustc +$NIGHTLY_TOOLCHAIN --version && cargo +$NIGHTLY_TOOLCHAIN --version - restore_cache: keys: - cargocache-v2-benchmarking-rust:1.47.0-{{ checksum "Cargo.lock" }} - run: name: Run benchmarks (Singlepass) working_directory: ~/project/packages/vm - command: cargo +$NIGHTLY_TOOLCHAIN bench --no-default-features --features singlepass,default-singlepass -- --save-baseline singlepass + command: cargo bench --no-default-features -- --save-baseline singlepass - run: name: Run benchmarks (Cranelift) working_directory: ~/project/packages/vm - command: cargo +$NIGHTLY_TOOLCHAIN bench --no-default-features --features cranelift,default-cranelift -- --save-baseline cranelift + command: cargo bench --no-default-features --features cranelift -- --save-baseline cranelift - save_cache: paths: - /usr/local/cargo/registry diff --git a/.mergify.yml b/.mergify.yml index 79856e3100..0a4f1f4cd0 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -11,11 +11,10 @@ pull_request_rules: - "status-success=ci/circleci: package_schema" - "status-success=ci/circleci: package_std" - "status-success=ci/circleci: package_storage" + - "status-success=ci/circleci: package_vm" - "status-success=ci/circleci: package_vm_cranelift" - - "status-success=ci/circleci: package_vm_singlepass" - "status-success=ci/circleci: contract_burner" - "status-success=ci/circleci: contract_hackatom" - - "status-success=ci/circleci: contract_hackatom_in_singlepass_vm" - "status-success=ci/circleci: contract_queue" - "status-success=ci/circleci: contract_reflect" - "status-success=ci/circleci: contract_staking" diff --git a/Cargo.lock b/Cargo.lock index 2d1725c64f..ac3dc800e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,16 +1,19 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "arrayref" -version = "0.3.6" +name = "addr2line" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" +dependencies = [ + "gimli", +] [[package]] -name = "arrayvec" -version = "0.5.2" +name = "adler" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "atty" @@ -29,6 +32,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707b586e0e2f247cbde68cdd2c3ce69ea7b7be43e1c5b426e37c9319c4b9838e" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object 0.21.1", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.0" @@ -51,28 +68,13 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake3" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac", - "digest 0.9.0", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -150,15 +152,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "clru" version = "0.2.1" @@ -171,12 +164,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "cosmwasm-schema" version = "0.12.1" @@ -222,10 +209,8 @@ dependencies = [ "sha2", "tempfile", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-engine", "wat", ] @@ -237,18 +222,18 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", "cranelift-bforest", @@ -257,6 +242,7 @@ dependencies = [ "cranelift-entity", "gimli", "log", + "regalloc", "smallvec", "target-lexicon", "thiserror", @@ -264,9 +250,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -274,27 +260,40 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] -name = "cranelift-native" -version = "0.59.0" +name = "cranelift-frontend" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", - "raw-cpuid", + "log", + "smallvec", "target-lexicon", ] +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +dependencies = [ + "cfg-if 0.1.10", +] + [[package]] name = "criterion" version = "0.3.3" @@ -354,9 +353,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", @@ -378,16 +377,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array 0.14.4", - "subtle", -] - [[package]] name = "csv" version = "1.1.5" @@ -411,12 +400,38 @@ dependencies = [ ] [[package]] -name = "digest" -version = "0.8.1" +name = "darling" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ - "generic-array 0.12.3", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote", + "syn", ] [[package]] @@ -425,19 +440,19 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] name = "dynasm" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a814e1edeb85dd2a3c6fc0d6bf76d02ca5695d438c70ecee3d90774f3259c5" +checksum = "62a59fbab09460c1569eeea9b5e4cf62f13f5198b1c2ba0e5196dd7fdd17cd42" dependencies = [ "bitflags", "byteorder", "lazy_static", - "owning_ref", + "proc-macro-error", "proc-macro2", "quote", "syn", @@ -445,11 +460,12 @@ dependencies = [ [[package]] name = "dynasmrt" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a393aaeb4441a48bcf47b5b6155971f82cc1eb77e22855403ccc0415ac8328d" +checksum = "85bec3edae2841d37b1c3dc7f3fd403c9061f26e9ffeeee97a3ea909b1bb2ef1" dependencies = [ "byteorder", + "dynasm", "memmap", ] @@ -460,40 +476,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] -name = "errno" -version = "0.2.7" +name = "enumset" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +checksum = "3691ce759534316ad900d57dd8e688e2c4263f9750c0f7c1e9b9a4516d4ca241" dependencies = [ - "errno-dragonfly", - "libc", - "winapi", + "enumset_derive", + "num-traits", ] [[package]] -name = "errno-dragonfly" -version = "0.1.1" +name = "enumset_derive" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" dependencies = [ - "gcc", - "libc", + "darling", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "gcc" -version = "0.3.55" +name = "fallible-iterator" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] -name = "generic-array" -version = "0.12.3" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" @@ -518,12 +532,13 @@ dependencies = [ [[package]] name = "gimli" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ - "byteorder", + "fallible-iterator", "indexmap", + "stable_deref_trait", ] [[package]] @@ -534,9 +549,12 @@ checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177" [[package]] name = "hashbrown" -version = "0.9.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" +dependencies = [ + "autocfg", +] [[package]] name = "hermit-abi" @@ -553,11 +571,17 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +[[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.6.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" dependencies = [ "autocfg", "hashbrown", @@ -602,17 +626,17 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.80" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" [[package]] -name = "lock_api" -version = "0.3.4" +name = "libloading" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "2cadb8e769f070c45df05c78c7520eb4cd17061d4ab262e43cfc68b4d00ac71c" dependencies = [ - "scopeguard", + "winapi", ] [[package]] @@ -624,6 +648,15 @@ dependencies = [ "cfg-if 0.1.10", ] +[[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.3.4" @@ -642,26 +675,29 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.5.6" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" dependencies = [ "autocfg", ] [[package]] -name = "nix" -version = "0.15.0" +name = "miniz_oxide" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", + "adler", + "autocfg", ] +[[package]] +name = "more-asserts" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" + [[package]] name = "num-integer" version = "0.1.44" @@ -692,35 +728,32 @@ dependencies = [ ] [[package]] -name = "oorandom" -version = "11.1.3" +name = "object" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "object" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] -name = "owning_ref" -version = "0.4.1" +name = "oorandom" +version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] -name = "page_size" -version = "0.4.2" +name = "opaque-debug" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" -dependencies = [ - "libc", - "winapi", -] +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "parity-wasm" @@ -728,30 +761,6 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" -[[package]] -name = "parking_lot" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall", - "smallvec", - "winapi", -] - [[package]] name = "plotters" version = "0.2.15" @@ -766,9 +775,33 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" + +[[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 = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] [[package]] name = "proc-macro2" @@ -871,6 +904,17 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[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 = "regex" version = "1.4.2" @@ -895,6 +939,18 @@ version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +[[package]] +name = "region" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +dependencies = [ + "bitflags", + "libc", + "mach", + "winapi", +] + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -904,6 +960,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -981,16 +1049,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-bench" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" -dependencies = [ - "byteorder", - "serde", -] - [[package]] name = "serde-json-wasm" version = "0.2.1" @@ -1061,7 +1119,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -1078,10 +1136,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] -name = "subtle" -version = "2.3.0" +name = "strsim" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "syn" @@ -1096,9 +1154,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" [[package]] name = "tempfile" @@ -1164,6 +1222,37 @@ dependencies = [ "serde_json", ] +[[package]] +name = "tracing" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0aae59226cf195d8e74d4b34beae1859257efb4e5fed3f147d2dc2c7d372178" +dependencies = [ + "cfg-if 0.1.10", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2734b5a028fa697686f16c6d18c2c6a3c7e41513f9a213abb6754c4acb3c8d7" +dependencies = [ + "lazy_static", +] + [[package]] name = "typenum" version = "1.12.0" @@ -1188,12 +1277,6 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - [[package]] name = "walkdir" version = "2.3.1" @@ -1272,146 +1355,206 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" [[package]] -name = "wasmer-clif-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691ea323652d540a10722066dbf049936f4367bb22a96f8992a262a942a8b11b" +name = "wasmer" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", + "target-lexicon", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-compiler-singlepass", + "wasmer-derive", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "winapi", +] + +[[package]] +name = "wasmer-compiler" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "enumset", + "raw-cpuid", "serde", - "serde-bench", "serde_bytes", - "serde_derive", + "smallvec", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", + "thiserror", + "wasmer-types", + "wasmer-vm", "wasmparser", - "winapi", ] [[package]] -name = "wasmer-clif-fork-frontend" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a" +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", - "log", + "cranelift-frontend", + "gimli", + "more-asserts", + "rayon", + "serde", "smallvec", - "target-lexicon", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-clif-fork-wasm" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5" +name = "wasmer-compiler-singlepass" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-middleware-common" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd94068186b25fbe5213442648ffe0fa65ee77389bed020404486fd22056cc87" +name = "wasmer-derive" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "wasmer-runtime-core", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "wasmer-runtime-core" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d4253f097502423d8b19d54cb18745f61b984b9dbce32424cba7945cfef367" +name = "wasmer-engine" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "backtrace", "bincode", - "blake3", - "cc", - "digest 0.8.1", - "errno", - "hex", - "indexmap", "lazy_static", - "libc", - "nix", - "page_size", - "parking_lot", - "rustc_version", + "more-asserts", + "rustc-demangle", "serde", - "serde-bench", "serde_bytes", - "serde_derive", - "smallvec", "target-lexicon", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine-jit" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "bincode", + "cfg-if 0.1.10", + "region", + "serde", + "serde_bytes", + "wasmer-compiler", + "wasmer-engine", + "wasmer-types", + "wasmer-vm", "winapi", ] [[package]] -name = "wasmer-singlepass-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cf84179dd5e92b784f7bc190b237f1184916a6d6d3f87d4dd94ca371a2cc25" +name = "wasmer-engine-native" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "libc", - "nix", + "cfg-if 0.1.10", + "leb128", + "libloading", "serde", - "serde_derive", - "smallvec", - "wasmer-runtime-core", + "tempfile", + "tracing", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-types", + "wasmer-vm", + "which", ] [[package]] -name = "wasmer-win-exception-handler" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf22ce6dc66d893099aac853d451bf9443fa8f5443f5bf4fc63f3aebd7b592b1" +name = "wasmer-object" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "object 0.22.0", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "backtrace", "cc", + "cfg-if 0.1.10", + "indexmap", "libc", - "wasmer-runtime-core", + "memoffset", + "more-asserts", + "region", + "serde", + "thiserror", + "wasmer-types", "winapi", ] [[package]] name = "wasmparser" -version = "0.51.4" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" [[package]] name = "wast" -version = "27.0.0" +version = "21.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" +checksum = "0b1844f66a2bc8526d71690104c0e78a8e59ffa1597b7245769d174ebb91deb5" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.28" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" +checksum = "ce85d72b74242c340e9e3492cfb602652d7bb324c3172dd441b5577e39a2e18c" dependencies = [ "wast", ] @@ -1426,6 +1569,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +dependencies = [ + "libc", + "thiserror", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/README.md b/README.md index 7653e16948..1bf22e9c3b 100644 --- a/README.md +++ b/README.md @@ -314,7 +314,7 @@ cargo fmt \ && (cd packages/std && cargo wasm-debug --features iterator && cargo test --features iterator && cargo clippy --features iterator -- -D warnings && cargo schema) \ && (cd packages/storage && cargo build && cargo test --features iterator && cargo clippy --features iterator -- -D warnings) \ && (cd packages/schema && cargo build && cargo test && cargo clippy -- -D warnings) \ - && (cd packages/vm && cargo +nightly build --features iterator && cargo +nightly test --features iterator && cargo +nightly clippy --features iterator -- -D warnings) + && (cd packages/vm && cargo build --features iterator && cargo test --features iterator && cargo clippy --features iterator -- -D warnings) ``` **Contracts** diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 8a1109f59b..bda9e1ecb4 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -1,16 +1,19 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "arrayref" -version = "0.3.6" +name = "addr2line" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +dependencies = [ + "gimli 0.23.0", +] [[package]] -name = "arrayvec" -version = "0.5.2" +name = "adler" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "autocfg" @@ -18,6 +21,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.0" @@ -40,28 +57,13 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake3" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac", - "digest 0.9.0", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -99,15 +101,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "clru" version = "0.2.1" @@ -120,12 +113,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "cosmwasm-schema" version = "0.12.1" @@ -159,10 +146,8 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-engine", ] [[package]] @@ -173,26 +158,27 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli", + "gimli 0.22.0", "log", + "regalloc", "smallvec", "target-lexicon", "thiserror", @@ -200,9 +186,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -210,27 +196,40 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] -name = "cranelift-native" -version = "0.59.0" +name = "cranelift-frontend" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", - "raw-cpuid", + "log", + "smallvec", "target-lexicon", ] +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crossbeam-channel" version = "0.5.0" @@ -254,9 +253,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", @@ -279,22 +278,38 @@ dependencies = [ ] [[package]] -name = "crypto-mac" -version = "0.8.0" +name = "darling" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" dependencies = [ - "generic-array 0.14.4", - "subtle", + "darling_core", + "darling_macro", ] [[package]] -name = "digest" -version = "0.8.1" +name = "darling_core" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ - "generic-array 0.12.3", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote", + "syn", ] [[package]] @@ -303,19 +318,19 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] name = "dynasm" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a814e1edeb85dd2a3c6fc0d6bf76d02ca5695d438c70ecee3d90774f3259c5" +checksum = "62a59fbab09460c1569eeea9b5e4cf62f13f5198b1c2ba0e5196dd7fdd17cd42" dependencies = [ "bitflags", "byteorder", "lazy_static", - "owning_ref", + "proc-macro-error", "proc-macro2", "quote", "syn", @@ -323,11 +338,12 @@ dependencies = [ [[package]] name = "dynasmrt" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a393aaeb4441a48bcf47b5b6155971f82cc1eb77e22855403ccc0415ac8328d" +checksum = "85bec3edae2841d37b1c3dc7f3fd403c9061f26e9ffeeee97a3ea909b1bb2ef1" dependencies = [ "byteorder", + "dynasm", "memmap", ] @@ -338,40 +354,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] -name = "errno" -version = "0.2.7" +name = "enumset" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1" dependencies = [ - "errno-dragonfly", - "libc", - "winapi", + "enumset_derive", + "num-traits", ] [[package]] -name = "errno-dragonfly" -version = "0.1.1" +name = "enumset_derive" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" dependencies = [ - "gcc", - "libc", + "darling", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "gcc" -version = "0.3.55" +name = "fallible-iterator" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] -name = "generic-array" -version = "0.12.3" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" @@ -383,16 +397,34 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "wasi", +] + [[package]] name = "gimli" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ - "byteorder", + "fallible-iterator", "indexmap", + "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + [[package]] name = "hashbrown" version = "0.9.1" @@ -414,6 +446,12 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +[[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.6.0" @@ -437,6 +475,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leb128" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" + [[package]] name = "libc" version = "0.2.80" @@ -444,12 +488,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" [[package]] -name = "lock_api" -version = "0.3.4" +name = "libloading" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0" dependencies = [ - "scopeguard", + "cfg-if 1.0.0", + "winapi", ] [[package]] @@ -461,6 +506,15 @@ dependencies = [ "cfg-if 0.1.10", ] +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "memmap" version = "0.7.0" @@ -473,24 +527,36 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.5.6" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ + "adler", "autocfg", ] [[package]] -name = "nix" -version = "0.15.0" +name = "more-asserts" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" +checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", + "autocfg", ] [[package]] @@ -503,6 +569,16 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +dependencies = [ + "crc32fast", + "indexmap", +] + [[package]] name = "opaque-debug" version = "0.3.0" @@ -510,52 +586,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "owning_ref" -version = "0.4.1" +name = "parity-wasm" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "page_size" -version = "0.4.2" +name = "pin-project-lite" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" -dependencies = [ - "libc", - "winapi", -] +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" [[package]] -name = "parity-wasm" -version = "0.42.1" +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "lock_api", - "parking_lot_core", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] -name = "parking_lot_core" -version = "0.7.2" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall", - "smallvec", - "winapi", + "proc-macro2", + "quote", + "version_check", ] [[package]] @@ -576,6 +645,47 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + [[package]] name = "raw-cpuid" version = "7.0.3" @@ -618,6 +728,50 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[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 = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +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 = "rustc-demangle" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -686,16 +840,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-bench" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" -dependencies = [ - "byteorder", - "serde", -] - [[package]] name = "serde-json-wasm" version = "0.2.1" @@ -756,7 +900,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -773,10 +917,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] -name = "subtle" -version = "2.3.0" +name = "strsim" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "syn" @@ -791,9 +935,23 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -815,6 +973,38 @@ dependencies = [ "syn", ] +[[package]] +name = "tracing" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + [[package]] name = "typenum" version = "1.12.0" @@ -834,137 +1024,207 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] -name = "void" -version = "1.0.2" +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "wasmer-clif-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691ea323652d540a10722066dbf049936f4367bb22a96f8992a262a942a8b11b" +name = "wasmer" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", + "target-lexicon", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-compiler-singlepass", + "wasmer-derive", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "winapi", +] + +[[package]] +name = "wasmer-compiler" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "enumset", + "raw-cpuid", "serde", - "serde-bench", "serde_bytes", - "serde_derive", + "smallvec", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", + "thiserror", + "wasmer-types", + "wasmer-vm", "wasmparser", - "winapi", ] [[package]] -name = "wasmer-clif-fork-frontend" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a" +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", - "log", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", "smallvec", - "target-lexicon", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-clif-fork-wasm" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5" +name = "wasmer-compiler-singlepass" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-middleware-common" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd94068186b25fbe5213442648ffe0fa65ee77389bed020404486fd22056cc87" +name = "wasmer-derive" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "wasmer-runtime-core", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "wasmer-runtime-core" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d4253f097502423d8b19d54cb18745f61b984b9dbce32424cba7945cfef367" +name = "wasmer-engine" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "backtrace", "bincode", - "blake3", - "cc", - "digest 0.8.1", - "errno", - "hex", - "indexmap", "lazy_static", - "libc", - "nix", - "page_size", - "parking_lot", - "rustc_version", + "more-asserts", + "rustc-demangle", "serde", - "serde-bench", "serde_bytes", - "serde_derive", - "smallvec", "target-lexicon", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine-jit" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "bincode", + "cfg-if 0.1.10", + "region", + "serde", + "serde_bytes", + "wasmer-compiler", + "wasmer-engine", + "wasmer-types", + "wasmer-vm", "winapi", ] [[package]] -name = "wasmer-singlepass-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cf84179dd5e92b784f7bc190b237f1184916a6d6d3f87d4dd94ca371a2cc25" +name = "wasmer-engine-native" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "libc", - "nix", + "cfg-if 0.1.10", + "leb128", + "libloading", "serde", - "serde_derive", - "smallvec", - "wasmer-runtime-core", + "tempfile", + "tracing", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-types", + "wasmer-vm", + "which", ] [[package]] -name = "wasmer-win-exception-handler" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf22ce6dc66d893099aac853d451bf9443fa8f5443f5bf4fc63f3aebd7b592b1" +name = "wasmer-object" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "object", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "backtrace", "cc", + "cfg-if 0.1.10", + "indexmap", "libc", - "wasmer-runtime-core", + "memoffset", + "more-asserts", + "region", + "serde", + "thiserror", + "wasmer-types", "winapi", ] [[package]] name = "wasmparser" -version = "0.51.4" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "which" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +dependencies = [ + "libc", + "thiserror", +] [[package]] name = "winapi" diff --git a/contracts/burner/Cargo.toml b/contracts/burner/Cargo.toml index d21a542057..1f78e4da8c 100644 --- a/contracts/burner/Cargo.toml +++ b/contracts/burner/Cargo.toml @@ -22,12 +22,13 @@ 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"] -cranelift = ["cosmwasm-vm/default-cranelift"] -singlepass = ["cosmwasm-vm/default-singlepass"] [dependencies] cosmwasm-std = { path = "../../packages/std", features = ["iterator"] } diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 88e237e801..fe166554c7 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -1,16 +1,19 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "arrayref" -version = "0.3.6" +name = "addr2line" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +dependencies = [ + "gimli 0.23.0", +] [[package]] -name = "arrayvec" -version = "0.5.2" +name = "adler" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "autocfg" @@ -18,6 +21,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.0" @@ -40,28 +57,13 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake3" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac", - "digest 0.9.0", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -88,15 +90,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "clru" version = "0.2.1" @@ -109,12 +102,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "cosmwasm-schema" version = "0.12.1" @@ -156,10 +143,8 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-engine", ] [[package]] @@ -170,26 +155,27 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli", + "gimli 0.22.0", "log", + "regalloc", "smallvec", "target-lexicon", "thiserror", @@ -197,9 +183,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -207,27 +193,40 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] -name = "cranelift-native" -version = "0.59.0" +name = "cranelift-frontend" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", - "raw-cpuid", + "log", + "smallvec", "target-lexicon", ] +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crossbeam-channel" version = "0.5.0" @@ -251,9 +250,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", @@ -276,22 +275,38 @@ dependencies = [ ] [[package]] -name = "crypto-mac" -version = "0.8.0" +name = "darling" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" dependencies = [ - "generic-array 0.14.4", - "subtle", + "darling_core", + "darling_macro", ] [[package]] -name = "digest" -version = "0.8.1" +name = "darling_core" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ - "generic-array 0.12.3", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote", + "syn", ] [[package]] @@ -300,19 +315,19 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] name = "dynasm" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a814e1edeb85dd2a3c6fc0d6bf76d02ca5695d438c70ecee3d90774f3259c5" +checksum = "62a59fbab09460c1569eeea9b5e4cf62f13f5198b1c2ba0e5196dd7fdd17cd42" dependencies = [ "bitflags", "byteorder", "lazy_static", - "owning_ref", + "proc-macro-error", "proc-macro2", "quote", "syn", @@ -320,11 +335,12 @@ dependencies = [ [[package]] name = "dynasmrt" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a393aaeb4441a48bcf47b5b6155971f82cc1eb77e22855403ccc0415ac8328d" +checksum = "85bec3edae2841d37b1c3dc7f3fd403c9061f26e9ffeeee97a3ea909b1bb2ef1" dependencies = [ "byteorder", + "dynasm", "memmap", ] @@ -335,40 +351,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] -name = "errno" -version = "0.2.7" +name = "enumset" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1" dependencies = [ - "errno-dragonfly", - "libc", - "winapi", + "enumset_derive", + "num-traits", ] [[package]] -name = "errno-dragonfly" -version = "0.1.1" +name = "enumset_derive" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" dependencies = [ - "gcc", - "libc", + "darling", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "gcc" -version = "0.3.55" +name = "fallible-iterator" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] -name = "generic-array" -version = "0.12.3" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" @@ -380,16 +394,34 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "wasi", +] + [[package]] name = "gimli" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ - "byteorder", + "fallible-iterator", "indexmap", + "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + [[package]] name = "hackatom" version = "0.0.0" @@ -425,6 +457,12 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +[[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.6.0" @@ -448,6 +486,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leb128" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" + [[package]] name = "libc" version = "0.2.80" @@ -455,12 +499,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" [[package]] -name = "lock_api" -version = "0.3.4" +name = "libloading" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0" dependencies = [ - "scopeguard", + "cfg-if 1.0.0", + "winapi", ] [[package]] @@ -472,6 +517,15 @@ dependencies = [ "cfg-if 0.1.10", ] +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "memmap" version = "0.7.0" @@ -484,24 +538,36 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.5.6" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ + "adler", "autocfg", ] [[package]] -name = "nix" -version = "0.15.0" +name = "more-asserts" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" +checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", + "autocfg", ] [[package]] @@ -514,6 +580,16 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +dependencies = [ + "crc32fast", + "indexmap", +] + [[package]] name = "opaque-debug" version = "0.3.0" @@ -521,52 +597,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "owning_ref" -version = "0.4.1" +name = "parity-wasm" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "page_size" -version = "0.4.2" +name = "pin-project-lite" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" -dependencies = [ - "libc", - "winapi", -] +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" [[package]] -name = "parity-wasm" -version = "0.42.1" +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "lock_api", - "parking_lot_core", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] -name = "parking_lot_core" -version = "0.7.2" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall", - "smallvec", - "winapi", + "proc-macro2", + "quote", + "version_check", ] [[package]] @@ -587,6 +656,47 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + [[package]] name = "raw-cpuid" version = "7.0.3" @@ -629,6 +739,50 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[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 = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +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 = "rustc-demangle" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -697,16 +851,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-bench" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" -dependencies = [ - "byteorder", - "serde", -] - [[package]] name = "serde-json-wasm" version = "0.2.1" @@ -767,7 +911,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -784,10 +928,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] -name = "subtle" -version = "2.3.0" +name = "strsim" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "syn" @@ -802,9 +946,23 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -826,6 +984,38 @@ dependencies = [ "syn", ] +[[package]] +name = "tracing" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + [[package]] name = "typenum" version = "1.12.0" @@ -845,137 +1035,207 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] -name = "void" -version = "1.0.2" +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "wasmer-clif-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691ea323652d540a10722066dbf049936f4367bb22a96f8992a262a942a8b11b" +name = "wasmer" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", + "target-lexicon", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-compiler-singlepass", + "wasmer-derive", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "winapi", +] + +[[package]] +name = "wasmer-compiler" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "enumset", + "raw-cpuid", "serde", - "serde-bench", "serde_bytes", - "serde_derive", + "smallvec", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", + "thiserror", + "wasmer-types", + "wasmer-vm", "wasmparser", - "winapi", ] [[package]] -name = "wasmer-clif-fork-frontend" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a" +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", - "log", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", "smallvec", - "target-lexicon", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-clif-fork-wasm" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5" +name = "wasmer-compiler-singlepass" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-middleware-common" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd94068186b25fbe5213442648ffe0fa65ee77389bed020404486fd22056cc87" +name = "wasmer-derive" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "wasmer-runtime-core", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "wasmer-runtime-core" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d4253f097502423d8b19d54cb18745f61b984b9dbce32424cba7945cfef367" +name = "wasmer-engine" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "backtrace", "bincode", - "blake3", - "cc", - "digest 0.8.1", - "errno", - "hex", - "indexmap", "lazy_static", - "libc", - "nix", - "page_size", - "parking_lot", - "rustc_version", + "more-asserts", + "rustc-demangle", "serde", - "serde-bench", "serde_bytes", - "serde_derive", - "smallvec", "target-lexicon", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine-jit" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "bincode", + "cfg-if 0.1.10", + "region", + "serde", + "serde_bytes", + "wasmer-compiler", + "wasmer-engine", + "wasmer-types", + "wasmer-vm", "winapi", ] [[package]] -name = "wasmer-singlepass-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cf84179dd5e92b784f7bc190b237f1184916a6d6d3f87d4dd94ca371a2cc25" +name = "wasmer-engine-native" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "libc", - "nix", + "cfg-if 0.1.10", + "leb128", + "libloading", "serde", - "serde_derive", - "smallvec", - "wasmer-runtime-core", + "tempfile", + "tracing", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-types", + "wasmer-vm", + "which", ] [[package]] -name = "wasmer-win-exception-handler" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf22ce6dc66d893099aac853d451bf9443fa8f5443f5bf4fc63f3aebd7b592b1" +name = "wasmer-object" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "object", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "backtrace", "cc", + "cfg-if 0.1.10", + "indexmap", "libc", - "wasmer-runtime-core", + "memoffset", + "more-asserts", + "region", + "serde", + "thiserror", + "wasmer-types", "winapi", ] [[package]] name = "wasmparser" -version = "0.51.4" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "which" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +dependencies = [ + "libc", + "thiserror", +] [[package]] name = "winapi" diff --git a/contracts/hackatom/Cargo.toml b/contracts/hackatom/Cargo.toml index e9118bd3ae..dd7c422bcf 100644 --- a/contracts/hackatom/Cargo.toml +++ b/contracts/hackatom/Cargo.toml @@ -22,11 +22,12 @@ 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"] -cranelift = ["cosmwasm-vm/default-cranelift"] -singlepass = ["cosmwasm-vm/default-singlepass"] [dependencies] cosmwasm-std = { path = "../../packages/std" } diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 1a79216a1c..75af29e165 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -1,16 +1,19 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "arrayref" -version = "0.3.6" +name = "addr2line" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +dependencies = [ + "gimli 0.23.0", +] [[package]] -name = "arrayvec" -version = "0.5.2" +name = "adler" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "autocfg" @@ -18,6 +21,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.0" @@ -40,28 +57,13 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake3" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac", - "digest 0.9.0", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -88,15 +90,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "clru" version = "0.2.1" @@ -109,12 +102,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "cosmwasm-schema" version = "0.12.1" @@ -148,10 +135,8 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-engine", ] [[package]] @@ -162,26 +147,27 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli", + "gimli 0.22.0", "log", + "regalloc", "smallvec", "target-lexicon", "thiserror", @@ -189,9 +175,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -199,27 +185,40 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] -name = "cranelift-native" -version = "0.59.0" +name = "cranelift-frontend" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", - "raw-cpuid", + "log", + "smallvec", "target-lexicon", ] +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crossbeam-channel" version = "0.5.0" @@ -243,9 +242,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", @@ -268,22 +267,38 @@ dependencies = [ ] [[package]] -name = "crypto-mac" -version = "0.8.0" +name = "darling" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" dependencies = [ - "generic-array 0.14.4", - "subtle", + "darling_core", + "darling_macro", ] [[package]] -name = "digest" -version = "0.8.1" +name = "darling_core" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ - "generic-array 0.12.3", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote", + "syn", ] [[package]] @@ -292,19 +307,19 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] name = "dynasm" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a814e1edeb85dd2a3c6fc0d6bf76d02ca5695d438c70ecee3d90774f3259c5" +checksum = "62a59fbab09460c1569eeea9b5e4cf62f13f5198b1c2ba0e5196dd7fdd17cd42" dependencies = [ "bitflags", "byteorder", "lazy_static", - "owning_ref", + "proc-macro-error", "proc-macro2", "quote", "syn", @@ -312,11 +327,12 @@ dependencies = [ [[package]] name = "dynasmrt" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a393aaeb4441a48bcf47b5b6155971f82cc1eb77e22855403ccc0415ac8328d" +checksum = "85bec3edae2841d37b1c3dc7f3fd403c9061f26e9ffeeee97a3ea909b1bb2ef1" dependencies = [ "byteorder", + "dynasm", "memmap", ] @@ -327,40 +343,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] -name = "errno" -version = "0.2.7" +name = "enumset" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1" dependencies = [ - "errno-dragonfly", - "libc", - "winapi", + "enumset_derive", + "num-traits", ] [[package]] -name = "errno-dragonfly" -version = "0.1.1" +name = "enumset_derive" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" dependencies = [ - "gcc", - "libc", + "darling", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "gcc" -version = "0.3.55" +name = "fallible-iterator" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] -name = "generic-array" -version = "0.12.3" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" @@ -372,16 +386,34 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "wasi", +] + [[package]] name = "gimli" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ - "byteorder", + "fallible-iterator", "indexmap", + "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + [[package]] name = "hashbrown" version = "0.9.1" @@ -403,6 +435,12 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +[[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.6.0" @@ -426,6 +464,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leb128" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" + [[package]] name = "libc" version = "0.2.80" @@ -433,12 +477,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" [[package]] -name = "lock_api" -version = "0.3.4" +name = "libloading" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0" dependencies = [ - "scopeguard", + "cfg-if 1.0.0", + "winapi", ] [[package]] @@ -450,6 +495,15 @@ dependencies = [ "cfg-if 0.1.10", ] +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "memmap" version = "0.7.0" @@ -462,24 +516,36 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.5.6" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ + "adler", "autocfg", ] [[package]] -name = "nix" -version = "0.15.0" +name = "more-asserts" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" +checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", + "autocfg", ] [[package]] @@ -492,6 +558,16 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +dependencies = [ + "crc32fast", + "indexmap", +] + [[package]] name = "opaque-debug" version = "0.3.0" @@ -499,52 +575,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "owning_ref" -version = "0.4.1" +name = "parity-wasm" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "page_size" -version = "0.4.2" +name = "pin-project-lite" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" -dependencies = [ - "libc", - "winapi", -] +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" [[package]] -name = "parity-wasm" -version = "0.42.1" +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "lock_api", - "parking_lot_core", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] -name = "parking_lot_core" -version = "0.7.2" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall", - "smallvec", - "winapi", + "proc-macro2", + "quote", + "version_check", ] [[package]] @@ -576,6 +645,47 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + [[package]] name = "raw-cpuid" version = "7.0.3" @@ -618,6 +728,50 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[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 = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +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 = "rustc-demangle" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -686,16 +840,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-bench" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" -dependencies = [ - "byteorder", - "serde", -] - [[package]] name = "serde-json-wasm" version = "0.2.1" @@ -756,7 +900,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -773,10 +917,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] -name = "subtle" -version = "2.3.0" +name = "strsim" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "syn" @@ -791,9 +935,23 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -815,6 +973,38 @@ dependencies = [ "syn", ] +[[package]] +name = "tracing" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + [[package]] name = "typenum" version = "1.12.0" @@ -834,137 +1024,207 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] -name = "void" -version = "1.0.2" +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "wasmer-clif-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691ea323652d540a10722066dbf049936f4367bb22a96f8992a262a942a8b11b" +name = "wasmer" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", + "target-lexicon", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-compiler-singlepass", + "wasmer-derive", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "winapi", +] + +[[package]] +name = "wasmer-compiler" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "enumset", + "raw-cpuid", "serde", - "serde-bench", "serde_bytes", - "serde_derive", + "smallvec", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", + "thiserror", + "wasmer-types", + "wasmer-vm", "wasmparser", - "winapi", ] [[package]] -name = "wasmer-clif-fork-frontend" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a" +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", - "log", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", "smallvec", - "target-lexicon", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-clif-fork-wasm" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5" +name = "wasmer-compiler-singlepass" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-middleware-common" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd94068186b25fbe5213442648ffe0fa65ee77389bed020404486fd22056cc87" +name = "wasmer-derive" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "wasmer-runtime-core", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "wasmer-runtime-core" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d4253f097502423d8b19d54cb18745f61b984b9dbce32424cba7945cfef367" +name = "wasmer-engine" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "backtrace", "bincode", - "blake3", - "cc", - "digest 0.8.1", - "errno", - "hex", - "indexmap", "lazy_static", - "libc", - "nix", - "page_size", - "parking_lot", - "rustc_version", + "more-asserts", + "rustc-demangle", "serde", - "serde-bench", "serde_bytes", - "serde_derive", - "smallvec", "target-lexicon", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine-jit" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "bincode", + "cfg-if 0.1.10", + "region", + "serde", + "serde_bytes", + "wasmer-compiler", + "wasmer-engine", + "wasmer-types", + "wasmer-vm", "winapi", ] [[package]] -name = "wasmer-singlepass-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cf84179dd5e92b784f7bc190b237f1184916a6d6d3f87d4dd94ca371a2cc25" +name = "wasmer-engine-native" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "libc", - "nix", + "cfg-if 0.1.10", + "leb128", + "libloading", "serde", - "serde_derive", - "smallvec", - "wasmer-runtime-core", + "tempfile", + "tracing", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-types", + "wasmer-vm", + "which", ] [[package]] -name = "wasmer-win-exception-handler" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf22ce6dc66d893099aac853d451bf9443fa8f5443f5bf4fc63f3aebd7b592b1" +name = "wasmer-object" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "object", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "backtrace", "cc", + "cfg-if 0.1.10", + "indexmap", "libc", - "wasmer-runtime-core", + "memoffset", + "more-asserts", + "region", + "serde", + "thiserror", + "wasmer-types", "winapi", ] [[package]] name = "wasmparser" -version = "0.51.4" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "which" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +dependencies = [ + "libc", + "thiserror", +] [[package]] name = "winapi" diff --git a/contracts/queue/Cargo.toml b/contracts/queue/Cargo.toml index 6a2deb60da..138007708a 100644 --- a/contracts/queue/Cargo.toml +++ b/contracts/queue/Cargo.toml @@ -22,11 +22,12 @@ 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"] -cranelift = ["cosmwasm-vm/default-cranelift"] -singlepass = ["cosmwasm-vm/default-singlepass"] [dependencies] cosmwasm-std = { path = "../../packages/std", features = ["iterator"] } diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 3298c748b2..451cc67c0a 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -1,16 +1,19 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "arrayref" -version = "0.3.6" +name = "addr2line" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +dependencies = [ + "gimli 0.23.0", +] [[package]] -name = "arrayvec" -version = "0.5.2" +name = "adler" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "autocfg" @@ -18,6 +21,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.0" @@ -40,28 +57,13 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake3" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac", - "digest 0.9.0", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -88,15 +90,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "clru" version = "0.2.1" @@ -109,12 +102,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "cosmwasm-schema" version = "0.12.1" @@ -156,10 +143,8 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-engine", ] [[package]] @@ -170,26 +155,27 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli", + "gimli 0.22.0", "log", + "regalloc", "smallvec", "target-lexicon", "thiserror", @@ -197,9 +183,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -207,27 +193,40 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] -name = "cranelift-native" -version = "0.59.0" +name = "cranelift-frontend" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", - "raw-cpuid", + "log", + "smallvec", "target-lexicon", ] +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crossbeam-channel" version = "0.5.0" @@ -251,9 +250,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", @@ -276,22 +275,38 @@ dependencies = [ ] [[package]] -name = "crypto-mac" -version = "0.8.0" +name = "darling" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" dependencies = [ - "generic-array 0.14.4", - "subtle", + "darling_core", + "darling_macro", ] [[package]] -name = "digest" -version = "0.8.1" +name = "darling_core" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ - "generic-array 0.12.3", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote", + "syn", ] [[package]] @@ -300,19 +315,19 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] name = "dynasm" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a814e1edeb85dd2a3c6fc0d6bf76d02ca5695d438c70ecee3d90774f3259c5" +checksum = "62a59fbab09460c1569eeea9b5e4cf62f13f5198b1c2ba0e5196dd7fdd17cd42" dependencies = [ "bitflags", "byteorder", "lazy_static", - "owning_ref", + "proc-macro-error", "proc-macro2", "quote", "syn", @@ -320,11 +335,12 @@ dependencies = [ [[package]] name = "dynasmrt" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a393aaeb4441a48bcf47b5b6155971f82cc1eb77e22855403ccc0415ac8328d" +checksum = "85bec3edae2841d37b1c3dc7f3fd403c9061f26e9ffeeee97a3ea909b1bb2ef1" dependencies = [ "byteorder", + "dynasm", "memmap", ] @@ -335,40 +351,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] -name = "errno" -version = "0.2.7" +name = "enumset" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1" dependencies = [ - "errno-dragonfly", - "libc", - "winapi", + "enumset_derive", + "num-traits", ] [[package]] -name = "errno-dragonfly" -version = "0.1.1" +name = "enumset_derive" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" dependencies = [ - "gcc", - "libc", + "darling", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "gcc" -version = "0.3.55" +name = "fallible-iterator" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] -name = "generic-array" -version = "0.12.3" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" @@ -380,16 +394,34 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "wasi", +] + [[package]] name = "gimli" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ - "byteorder", + "fallible-iterator", "indexmap", + "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + [[package]] name = "hashbrown" version = "0.9.1" @@ -411,6 +443,12 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +[[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.6.0" @@ -434,6 +472,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leb128" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" + [[package]] name = "libc" version = "0.2.80" @@ -441,12 +485,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" [[package]] -name = "lock_api" -version = "0.3.4" +name = "libloading" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0" dependencies = [ - "scopeguard", + "cfg-if 1.0.0", + "winapi", ] [[package]] @@ -458,6 +503,15 @@ dependencies = [ "cfg-if 0.1.10", ] +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "memmap" version = "0.7.0" @@ -470,24 +524,36 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.5.6" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ + "adler", "autocfg", ] [[package]] -name = "nix" -version = "0.15.0" +name = "more-asserts" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" +checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", + "autocfg", ] [[package]] @@ -500,6 +566,16 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +dependencies = [ + "crc32fast", + "indexmap", +] + [[package]] name = "opaque-debug" version = "0.3.0" @@ -507,52 +583,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "owning_ref" -version = "0.4.1" +name = "parity-wasm" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "page_size" -version = "0.4.2" +name = "pin-project-lite" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" -dependencies = [ - "libc", - "winapi", -] +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" [[package]] -name = "parity-wasm" -version = "0.42.1" +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "lock_api", - "parking_lot_core", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] -name = "parking_lot_core" -version = "0.7.2" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall", - "smallvec", - "winapi", + "proc-macro2", + "quote", + "version_check", ] [[package]] @@ -573,6 +642,47 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + [[package]] name = "raw-cpuid" version = "7.0.3" @@ -628,6 +738,50 @@ dependencies = [ "thiserror", ] +[[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 = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +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 = "rustc-demangle" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -696,16 +850,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-bench" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" -dependencies = [ - "byteorder", - "serde", -] - [[package]] name = "serde-json-wasm" version = "0.2.1" @@ -766,7 +910,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -783,10 +927,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] -name = "subtle" -version = "2.3.0" +name = "strsim" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "syn" @@ -801,9 +945,23 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -825,6 +983,38 @@ dependencies = [ "syn", ] +[[package]] +name = "tracing" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + [[package]] name = "typenum" version = "1.12.0" @@ -844,137 +1034,207 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] -name = "void" -version = "1.0.2" +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "wasmer-clif-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691ea323652d540a10722066dbf049936f4367bb22a96f8992a262a942a8b11b" +name = "wasmer" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", + "target-lexicon", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-compiler-singlepass", + "wasmer-derive", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "winapi", +] + +[[package]] +name = "wasmer-compiler" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "enumset", + "raw-cpuid", "serde", - "serde-bench", "serde_bytes", - "serde_derive", + "smallvec", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", + "thiserror", + "wasmer-types", + "wasmer-vm", "wasmparser", - "winapi", ] [[package]] -name = "wasmer-clif-fork-frontend" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a" +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", - "log", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", "smallvec", - "target-lexicon", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-clif-fork-wasm" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5" +name = "wasmer-compiler-singlepass" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-middleware-common" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd94068186b25fbe5213442648ffe0fa65ee77389bed020404486fd22056cc87" +name = "wasmer-derive" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "wasmer-runtime-core", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "wasmer-runtime-core" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d4253f097502423d8b19d54cb18745f61b984b9dbce32424cba7945cfef367" +name = "wasmer-engine" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "backtrace", "bincode", - "blake3", - "cc", - "digest 0.8.1", - "errno", - "hex", - "indexmap", "lazy_static", - "libc", - "nix", - "page_size", - "parking_lot", - "rustc_version", + "more-asserts", + "rustc-demangle", "serde", - "serde-bench", "serde_bytes", - "serde_derive", - "smallvec", "target-lexicon", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine-jit" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "bincode", + "cfg-if 0.1.10", + "region", + "serde", + "serde_bytes", + "wasmer-compiler", + "wasmer-engine", + "wasmer-types", + "wasmer-vm", "winapi", ] [[package]] -name = "wasmer-singlepass-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cf84179dd5e92b784f7bc190b237f1184916a6d6d3f87d4dd94ca371a2cc25" +name = "wasmer-engine-native" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "libc", - "nix", + "cfg-if 0.1.10", + "leb128", + "libloading", "serde", - "serde_derive", - "smallvec", - "wasmer-runtime-core", + "tempfile", + "tracing", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-types", + "wasmer-vm", + "which", ] [[package]] -name = "wasmer-win-exception-handler" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf22ce6dc66d893099aac853d451bf9443fa8f5443f5bf4fc63f3aebd7b592b1" +name = "wasmer-object" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "object", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "backtrace", "cc", + "cfg-if 0.1.10", + "indexmap", "libc", - "wasmer-runtime-core", + "memoffset", + "more-asserts", + "region", + "serde", + "thiserror", + "wasmer-types", "winapi", ] [[package]] name = "wasmparser" -version = "0.51.4" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "which" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +dependencies = [ + "libc", + "thiserror", +] [[package]] name = "winapi" diff --git a/contracts/reflect/Cargo.toml b/contracts/reflect/Cargo.toml index 4267c4a660..40b374771d 100644 --- a/contracts/reflect/Cargo.toml +++ b/contracts/reflect/Cargo.toml @@ -24,12 +24,13 @@ 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"] -cranelift = ["cosmwasm-vm/default-cranelift"] -singlepass = ["cosmwasm-vm/default-singlepass"] [dependencies] cosmwasm-std = { path = "../../packages/std", features = ["staking"] } diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 91e747808d..3a8c7ca2ea 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -1,16 +1,19 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "arrayref" -version = "0.3.6" +name = "addr2line" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +dependencies = [ + "gimli 0.23.0", +] [[package]] -name = "arrayvec" -version = "0.5.2" +name = "adler" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "autocfg" @@ -18,6 +21,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.0" @@ -40,28 +57,13 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake3" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac", - "digest 0.9.0", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -88,15 +90,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "clru" version = "0.2.1" @@ -109,12 +102,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "cosmwasm-schema" version = "0.12.1" @@ -156,10 +143,8 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-engine", ] [[package]] @@ -170,26 +155,27 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli", + "gimli 0.22.0", "log", + "regalloc", "smallvec", "target-lexicon", "thiserror", @@ -197,9 +183,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -207,27 +193,40 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.59.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] [[package]] -name = "cranelift-native" -version = "0.59.0" +name = "cranelift-frontend" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", - "raw-cpuid", + "log", + "smallvec", "target-lexicon", ] +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crossbeam-channel" version = "0.5.0" @@ -251,9 +250,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", @@ -276,22 +275,38 @@ dependencies = [ ] [[package]] -name = "crypto-mac" -version = "0.8.0" +name = "darling" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" dependencies = [ - "generic-array 0.14.4", - "subtle", + "darling_core", + "darling_macro", ] [[package]] -name = "digest" -version = "0.8.1" +name = "darling_core" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ - "generic-array 0.12.3", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote", + "syn", ] [[package]] @@ -300,7 +315,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -311,14 +326,14 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dynasm" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a814e1edeb85dd2a3c6fc0d6bf76d02ca5695d438c70ecee3d90774f3259c5" +checksum = "62a59fbab09460c1569eeea9b5e4cf62f13f5198b1c2ba0e5196dd7fdd17cd42" dependencies = [ "bitflags", "byteorder", "lazy_static", - "owning_ref", + "proc-macro-error", "proc-macro2", "quote", "syn", @@ -326,11 +341,12 @@ dependencies = [ [[package]] name = "dynasmrt" -version = "0.5.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a393aaeb4441a48bcf47b5b6155971f82cc1eb77e22855403ccc0415ac8328d" +checksum = "85bec3edae2841d37b1c3dc7f3fd403c9061f26e9ffeeee97a3ea909b1bb2ef1" dependencies = [ "byteorder", + "dynasm", "memmap", ] @@ -341,40 +357,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] -name = "errno" -version = "0.2.7" +name = "enumset" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1" dependencies = [ - "errno-dragonfly", - "libc", - "winapi", + "enumset_derive", + "num-traits", ] [[package]] -name = "errno-dragonfly" -version = "0.1.1" +name = "enumset_derive" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" dependencies = [ - "gcc", - "libc", + "darling", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "gcc" -version = "0.3.55" +name = "fallible-iterator" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] -name = "generic-array" -version = "0.12.3" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" @@ -386,16 +400,34 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "wasi", +] + [[package]] name = "gimli" -version = "0.20.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ - "byteorder", + "fallible-iterator", "indexmap", + "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + [[package]] name = "hashbrown" version = "0.9.1" @@ -417,6 +449,12 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +[[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.6.0" @@ -440,6 +478,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leb128" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" + [[package]] name = "libc" version = "0.2.80" @@ -447,12 +491,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" [[package]] -name = "lock_api" -version = "0.3.4" +name = "libloading" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0" dependencies = [ - "scopeguard", + "cfg-if 1.0.0", + "winapi", ] [[package]] @@ -464,6 +509,15 @@ dependencies = [ "cfg-if 0.1.10", ] +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "memmap" version = "0.7.0" @@ -476,24 +530,36 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.5.6" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ + "adler", "autocfg", ] [[package]] -name = "nix" -version = "0.15.0" +name = "more-asserts" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" +checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", + "autocfg", ] [[package]] @@ -506,6 +572,16 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +dependencies = [ + "crc32fast", + "indexmap", +] + [[package]] name = "opaque-debug" version = "0.3.0" @@ -513,52 +589,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "owning_ref" -version = "0.4.1" +name = "parity-wasm" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "page_size" -version = "0.4.2" +name = "pin-project-lite" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" -dependencies = [ - "libc", - "winapi", -] +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" [[package]] -name = "parity-wasm" -version = "0.42.1" +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "lock_api", - "parking_lot_core", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] -name = "parking_lot_core" -version = "0.7.2" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall", - "smallvec", - "winapi", + "proc-macro2", + "quote", + "version_check", ] [[package]] @@ -579,6 +648,47 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + [[package]] name = "raw-cpuid" version = "7.0.3" @@ -621,6 +731,50 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[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 = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +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 = "rustc-demangle" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -689,16 +843,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-bench" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" -dependencies = [ - "byteorder", - "serde", -] - [[package]] name = "serde-json-wasm" version = "0.2.1" @@ -759,7 +903,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -810,10 +954,10 @@ dependencies = [ ] [[package]] -name = "subtle" -version = "2.3.0" +name = "strsim" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "syn" @@ -828,9 +972,23 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -852,6 +1010,38 @@ dependencies = [ "syn", ] +[[package]] +name = "tracing" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + [[package]] name = "typenum" version = "1.12.0" @@ -871,137 +1061,207 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] -name = "void" -version = "1.0.2" +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "wasmer-clif-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691ea323652d540a10722066dbf049936f4367bb22a96f8992a262a942a8b11b" +name = "wasmer" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", + "target-lexicon", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-compiler-singlepass", + "wasmer-derive", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "winapi", +] + +[[package]] +name = "wasmer-compiler" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "enumset", + "raw-cpuid", "serde", - "serde-bench", "serde_bytes", - "serde_derive", + "smallvec", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", + "thiserror", + "wasmer-types", + "wasmer-vm", "wasmparser", - "winapi", ] [[package]] -name = "wasmer-clif-fork-frontend" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a" +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", - "log", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", "smallvec", - "target-lexicon", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-clif-fork-wasm" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5" +name = "wasmer-compiler-singlepass" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-middleware-common" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd94068186b25fbe5213442648ffe0fa65ee77389bed020404486fd22056cc87" +name = "wasmer-derive" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ - "wasmer-runtime-core", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "wasmer-runtime-core" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d4253f097502423d8b19d54cb18745f61b984b9dbce32424cba7945cfef367" +name = "wasmer-engine" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "backtrace", "bincode", - "blake3", - "cc", - "digest 0.8.1", - "errno", - "hex", - "indexmap", "lazy_static", - "libc", - "nix", - "page_size", - "parking_lot", - "rustc_version", + "more-asserts", + "rustc-demangle", "serde", - "serde-bench", "serde_bytes", - "serde_derive", - "smallvec", "target-lexicon", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine-jit" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "bincode", + "cfg-if 0.1.10", + "region", + "serde", + "serde_bytes", + "wasmer-compiler", + "wasmer-engine", + "wasmer-types", + "wasmer-vm", "winapi", ] [[package]] -name = "wasmer-singlepass-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cf84179dd5e92b784f7bc190b237f1184916a6d6d3f87d4dd94ca371a2cc25" +name = "wasmer-engine-native" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "libc", - "nix", + "cfg-if 0.1.10", + "leb128", + "libloading", "serde", - "serde_derive", - "smallvec", - "wasmer-runtime-core", + "tempfile", + "tracing", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-types", + "wasmer-vm", + "which", ] [[package]] -name = "wasmer-win-exception-handler" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf22ce6dc66d893099aac853d451bf9443fa8f5443f5bf4fc63f3aebd7b592b1" +name = "wasmer-object" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ + "object", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" +dependencies = [ + "backtrace", "cc", + "cfg-if 0.1.10", + "indexmap", "libc", - "wasmer-runtime-core", + "memoffset", + "more-asserts", + "region", + "serde", + "thiserror", + "wasmer-types", "winapi", ] [[package]] name = "wasmparser" -version = "0.51.4" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "which" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +dependencies = [ + "libc", + "thiserror", +] [[package]] name = "winapi" diff --git a/contracts/staking/Cargo.toml b/contracts/staking/Cargo.toml index 6f0700f159..9f03f1f02d 100644 --- a/contracts/staking/Cargo.toml +++ b/contracts/staking/Cargo.toml @@ -22,12 +22,13 @@ 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"] -cranelift = ["cosmwasm-vm/default-cranelift"] -singlepass = ["cosmwasm-vm/default-singlepass"] [dependencies] cosmwasm-std = { path = "../../packages/std", features = ["staking"] } diff --git a/devtools/set_version.sh b/devtools/set_version.sh index 8e210ab6c6..9b005a10fd 100755 --- a/devtools/set_version.sh +++ b/devtools/set_version.sh @@ -42,7 +42,7 @@ for package_dir in packages/*/; do FILES_MODIFIED+=("$CARGO_TOML") done -cargo +nightly build +cargo build FILES_MODIFIED+=("Cargo.lock") for contract_dir in contracts/*/; do diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index c9fee57ffd..078b1eaee0 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -12,13 +12,7 @@ circle-ci = { repository = "CosmWasm/cosmwasm", branch = "master" } maintenance = { status = "actively-developed" } [features] -default = ["default-singlepass", "staking"] -# multiple backends may be activated here (available through eg. backends::cranelift::*) -cranelift = ["wasmer-clif-backend"] -singlepass = ["wasmer-singlepass-backend"] -# default selects which *one* is re-exported in backends/mod.rs (available through eg backends::*) -default-cranelift = ["wasmer-clif-backend"] -default-singlepass = ["wasmer-singlepass-backend"] +default = ["staking"] # The backtraces fature is unused for now, i.e. it does nothing. backtraces = [] # iterator allows us to iterate over all DB items in a given range @@ -28,6 +22,9 @@ backtraces = [] # we keep this optional, to allow possible future integration (or different Cosmos Backends) iterator = ["cosmwasm-std/iterator"] staking = ["cosmwasm-std/staking"] +metering = [] +# Use cranelift backend instead of singlepass. This is required for development on Windows. +cranelift = ["wasmer/cranelift"] [lib] # See https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options @@ -45,10 +42,12 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer-runtime-core = "=0.17.0" -wasmer-middleware-common = "=0.17.0" -wasmer-clif-backend = { version = "=0.17.0", optional = true } -wasmer-singlepass-backend = { version = "=0.17.0", optional = true } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "df3a21160a9a", default-features = false, features = ["jit", "singlepass"] } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "df3a21160a9a" } + +# Wasmer local (used for quick local debugging or patching) +# wasmer = { path = "../../../wasmer/lib/api", default-features = false, features = ["jit", "singlepass"] } +# wasmer-engine = { path = "../../../wasmer/lib/engine" } [dev-dependencies] criterion = "0.3" diff --git a/packages/vm/README.md b/packages/vm/README.md index 978eab0d19..eb625ac10f 100644 --- a/packages/vm/README.md +++ b/packages/vm/README.md @@ -44,34 +44,28 @@ docker run --rm -v "$(pwd)":/code \ ## Testing By default, this repository is built and tested with the singlepass backend. -This requires running Rust nighty: +You can enable the `cranelift` feature to override the default backend with Cranelift ```sh cd packages/vm -cargo +nightly test -``` - -To test with Rust stable, you need to switch to cranelift: - -```sh -cd packages/vm -cargo test --no-default-features --features default-cranelift +cargo test --features iterator +cargo test --features cranelift,iterator ``` ## Benchmarking -Using Singlepass (requires Rust nightly): +Using Singlepass: ``` cd packages/vm -cargo +nightly bench --no-default-features --features singlepass,default-singlepass +cargo bench --no-default-features ``` Using Cranelift: ``` cd packages/vm -cargo bench --no-default-features --features cranelift,default-cranelift +cargo bench --no-default-features --features cranelift ``` ## License diff --git a/packages/vm/benches/main.rs b/packages/vm/benches/main.rs index 894826af2e..fa4b91f406 100644 --- a/packages/vm/benches/main.rs +++ b/packages/vm/benches/main.rs @@ -11,12 +11,16 @@ use cosmwasm_vm::{ InstanceOptions, Size, }; -const MEMORY_CACHE_SIZE: Size = Size::mebi(200); -const GAS_LIMIT: u64 = 400_000; -const INSTANCE_OPTIONS: InstanceOptions = InstanceOptions { - gas_limit: GAS_LIMIT, +// Instance +const DEFAULT_MEMORY_LIMIT: Size = Size::mebi(64); +const DEFAULT_GAS_LIMIT: u64 = 400_000; +const DEFAULT_INSTANCE_OPTIONS: InstanceOptions = InstanceOptions { + gas_limit: DEFAULT_GAS_LIMIT, print_debug: false, + memory_limit: DEFAULT_MEMORY_LIMIT, }; +// Cache +const MEMORY_CACHE_SIZE: Size = Size::mebi(200); static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); @@ -34,8 +38,8 @@ fn bench_instance(c: &mut Criterion) { group.bench_function("execute init", |b| { let backend = mock_backend(&[]); let much_gas: InstanceOptions = InstanceOptions { - gas_limit: 5_000_000_000, - print_debug: false, + gas_limit: 500_000_000_000, + ..DEFAULT_INSTANCE_OPTIONS }; let mut instance = Instance::from_code(CONTRACT, backend, much_gas).unwrap(); @@ -51,8 +55,8 @@ fn bench_instance(c: &mut Criterion) { group.bench_function("execute handle", |b| { let backend = mock_backend(&[]); let much_gas: InstanceOptions = InstanceOptions { - gas_limit: 5_000_000_000, - print_debug: false, + gas_limit: 500_000_000_000, + ..DEFAULT_INSTANCE_OPTIONS }; let mut instance = Instance::from_code(CONTRACT, backend, much_gas).unwrap(); @@ -105,7 +109,7 @@ fn bench_cache(c: &mut Criterion) { b.iter(|| { let _ = cache - .get_instance(&checksum, mock_backend(&[]), INSTANCE_OPTIONS) + .get_instance(&checksum, mock_backend(&[]), DEFAULT_INSTANCE_OPTIONS) .unwrap(); assert_eq!(cache.stats().hits_memory_cache, 0); assert!(cache.stats().hits_fs_cache >= 1); @@ -119,13 +123,13 @@ fn bench_cache(c: &mut Criterion) { unsafe { Cache::new(options.clone()).unwrap() }; // Load into memory cache - .get_instance(&checksum, mock_backend(&[]), INSTANCE_OPTIONS) + .get_instance(&checksum, mock_backend(&[]), DEFAULT_INSTANCE_OPTIONS) .unwrap(); b.iter(|| { let backend = mock_backend(&[]); let _ = cache - .get_instance(&checksum, backend, INSTANCE_OPTIONS) + .get_instance(&checksum, backend, DEFAULT_INSTANCE_OPTIONS) .unwrap(); assert_eq!(cache.stats().hits_fs_cache, 1); assert!(cache.stats().hits_memory_cache >= 1); diff --git a/packages/vm/src/backends/cranelift.rs b/packages/vm/src/backends/cranelift.rs deleted file mode 100644 index 7f9e30beb6..0000000000 --- a/packages/vm/src/backends/cranelift.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![cfg(any(feature = "cranelift", feature = "default-cranelift"))] -use wasmer_clif_backend::CraneliftCompiler; -use wasmer_runtime_core::{ - backend::Compiler, backend::CompilerConfig, compile_with_config, module::Module, vm::Ctx, -}; - -use crate::errors::VmResult; - -const FAKE_GAS_AVAILABLE: u64 = 1_000_000; - -pub const BACKEND_NAME: &str = "cranelift"; - -pub fn compile(code: &[u8]) -> VmResult { - let config = CompilerConfig { - enable_verification: false, // As discussed in https://github.com/CosmWasm/cosmwasm/issues/155 - ..Default::default() - }; - let module = compile_with_config(code, compiler().as_ref(), config)?; - Ok(module) -} - -pub fn compiler() -> Box { - Box::new(CraneliftCompiler::new()) -} - -/// Set the amount of gas units that can be used in the context. -pub fn set_gas_left(_ctx: &mut Ctx, _amount: u64) {} - -/// Get how many more gas units can be used in the context. -pub fn get_gas_left(_ctx: &Ctx) -> u64 { - FAKE_GAS_AVAILABLE -} diff --git a/packages/vm/src/backends/mod.rs b/packages/vm/src/backends/mod.rs deleted file mode 100644 index c21865f6f2..0000000000 --- a/packages/vm/src/backends/mod.rs +++ /dev/null @@ -1,89 +0,0 @@ -pub mod cranelift; -pub mod singlepass; - -pub use wasmer_runtime_core::backend::Compiler; -use wasmer_runtime_core::vm::Ctx; - -pub fn compiler_for_backend(backend: &str) -> Option> { - match backend { - #[cfg(any(feature = "cranelift", feature = "default-cranelift"))] - "cranelift" => Some(cranelift::compiler()), - - #[cfg(any(feature = "singlepass", feature = "default-singlepass"))] - "singlepass" => Some(singlepass::compiler()), - - _ => None, - } -} - -#[derive(Debug)] -pub struct InsufficientGasLeft; - -/// Decreases gas left by the given amount. -/// If the amount exceeds the available gas, the remaining gas is set to 0 and -/// an InsufficientGasLeft error is returned. -pub fn decrease_gas_left(ctx: &mut Ctx, amount: u64) -> Result<(), InsufficientGasLeft> { - let remaining = get_gas_left(ctx); - if amount > remaining { - set_gas_left(ctx, 0); - Err(InsufficientGasLeft) - } else { - set_gas_left(ctx, remaining - amount); - Ok(()) - } -} - -#[cfg(feature = "default-cranelift")] -pub use cranelift::{compile, get_gas_left, set_gas_left, BACKEND_NAME}; - -#[cfg(feature = "default-singlepass")] -pub use singlepass::{compile, get_gas_left, set_gas_left, BACKEND_NAME}; - -#[cfg(test)] -#[cfg(feature = "default-singlepass")] -mod test { - use super::*; - use wasmer_runtime_core::{imports, Instance as WasmerInstance}; - - fn instantiate(code: &[u8]) -> WasmerInstance { - let module = compile(code).unwrap(); - let import_obj = imports! { "env" => {}, }; - module.instantiate(&import_obj).unwrap() - } - - #[test] - fn decrease_gas_left_works() { - let wasm = wat::parse_str("(module)").unwrap(); - let mut instance = instantiate(&wasm); - - let before = get_gas_left(instance.context()); - decrease_gas_left(instance.context_mut(), 32).unwrap(); - let after = get_gas_left(instance.context()); - assert_eq!(after, before - 32); - } - - #[test] - fn decrease_gas_left_can_consume_all_gas() { - let wasm = wat::parse_str("(module)").unwrap(); - let mut instance = instantiate(&wasm); - - let before = get_gas_left(instance.context()); - decrease_gas_left(instance.context_mut(), before).unwrap(); - let after = get_gas_left(instance.context()); - assert_eq!(after, 0); - } - - #[test] - fn decrease_gas_left_errors_for_amount_greater_than_remaining() { - let wasm = wat::parse_str("(module)").unwrap(); - let mut instance = instantiate(&wasm); - - let before = get_gas_left(instance.context()); - let result = decrease_gas_left(instance.context_mut(), before + 1); - match result.unwrap_err() { - InsufficientGasLeft => {} - } - let after = get_gas_left(instance.context()); - assert_eq!(after, 0); - } -} diff --git a/packages/vm/src/backends/singlepass.rs b/packages/vm/src/backends/singlepass.rs deleted file mode 100644 index 8d33dd9202..0000000000 --- a/packages/vm/src/backends/singlepass.rs +++ /dev/null @@ -1,115 +0,0 @@ -#![cfg(any(feature = "singlepass", feature = "default-singlepass"))] -use wasmer_middleware_common::metering; -use wasmer_runtime_core::{ - backend::Compiler, - codegen::{MiddlewareChain, StreamingCompiler}, - compile_with, - module::Module, - vm::Ctx, -}; -use wasmer_singlepass_backend::ModuleCodeGenerator as SinglePassMCG; - -use crate::errors::VmResult; -use crate::middleware::DeterministicMiddleware; - -/// In Wasmer, the gas limit is set on modules during compilation and is included in the cached modules. -/// This causes issues when trying to instantiate the same compiled module with a different gas limit. -/// A fix for this is proposed here: https://github.com/wasmerio/wasmer/pull/996. -/// -/// To work around this limitation, we set the gas limit of all Wasmer instances to this very high value, -/// assuming users won't request more than this amount of gas. In order to set the real gas limit, we pretend -/// to consume the difference between the two in `set_gas_left` ("points used" in the metering middleware). -/// Since we observed overflow behaviour in the points used, we ensure both MAX_GAS_LIMIT and points used stay -/// far below u64::MAX. -const MAX_GAS_LIMIT: u64 = u64::MAX / 2; - -pub const BACKEND_NAME: &str = "singlepass"; - -pub fn compile(code: &[u8]) -> VmResult { - let module = compile_with(code, compiler().as_ref())?; - Ok(module) -} - -pub fn compiler() -> Box { - let c: StreamingCompiler = StreamingCompiler::new(move || { - let mut chain = MiddlewareChain::new(); - chain.push(DeterministicMiddleware::new()); - chain.push(metering::Metering::new(MAX_GAS_LIMIT)); - chain - }); - Box::new(c) -} - -/// Set the amount of gas units that can be used in the context. -pub fn set_gas_left(ctx: &mut Ctx, amount: u64) { - if amount > MAX_GAS_LIMIT { - panic!( - "Attempted to set gas limit larger than max gas limit (got: {}; maximum: {}).", - amount, MAX_GAS_LIMIT - ); - } else { - let used = MAX_GAS_LIMIT - amount; - metering::set_points_used_ctx(ctx, used); - } -} - -/// Get how many more gas units can be used in the context. -pub fn get_gas_left(ctx: &Ctx) -> u64 { - let used = metering::get_points_used_ctx(ctx); - // when running out of gas, get_points_used can exceed MAX_GAS_LIMIT - MAX_GAS_LIMIT.saturating_sub(used) -} - -#[cfg(test)] -mod test { - use super::*; - use wasmer_runtime_core::{imports, Instance as WasmerInstance}; - - fn instantiate(code: &[u8]) -> WasmerInstance { - let module = compile(code).unwrap(); - let import_obj = imports! { "env" => {}, }; - module.instantiate(&import_obj).unwrap() - } - - #[test] - fn get_gas_left_defaults_to_constant() { - let wasm = wat::parse_str("(module)").unwrap(); - let instance = instantiate(&wasm); - let gas_left = get_gas_left(instance.context()); - assert_eq!(gas_left, MAX_GAS_LIMIT); - } - - #[test] - fn set_gas_left_works() { - let wasm = wat::parse_str("(module)").unwrap(); - let mut instance = instantiate(&wasm); - - let limit = 3456789; - set_gas_left(instance.context_mut(), limit); - assert_eq!(get_gas_left(instance.context()), limit); - - let limit = 1; - set_gas_left(instance.context_mut(), limit); - assert_eq!(get_gas_left(instance.context()), limit); - - let limit = 0; - set_gas_left(instance.context_mut(), limit); - assert_eq!(get_gas_left(instance.context()), limit); - - let limit = MAX_GAS_LIMIT; - set_gas_left(instance.context_mut(), limit); - assert_eq!(get_gas_left(instance.context()), limit); - } - - #[test] - #[should_panic( - expected = "Attempted to set gas limit larger than max gas limit (got: 9223372036854775808; maximum: 9223372036854775807)." - )] - fn set_gas_left_panic_for_values_too_large() { - let wasm = wat::parse_str("(module)").unwrap(); - let mut instance = instantiate(&wasm); - - let limit = MAX_GAS_LIMIT + 1; - set_gas_left(instance.context_mut(), limit); - } -} diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 1c2f12f488..2d94d9689b 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -5,13 +5,13 @@ use std::marker::PhantomData; use std::path::PathBuf; use crate::backend::{Api, Backend, Querier, Storage}; -use crate::backends::compile; use crate::checksum::Checksum; use crate::compatibility::check_wasm; use crate::errors::{VmError, VmResult}; use crate::instance::{Instance, InstanceOptions}; use crate::modules::{FileSystemCache, InMemoryCache}; use crate::size::Size; +use crate::wasm_backend::compile; const WASM_DIR: &str = "wasm"; const MODULES_DIR: &str = "modules"; @@ -44,9 +44,9 @@ pub struct Cache { impl Cache where - S: Storage, - A: Api + 'static, // 'static is needed by `impl<…> Instance` - Q: Querier, + S: Storage + 'static, // 'static is needed by `impl<…> Instance` + A: Api + 'static, // 'static is needed by `impl<…> Instance` + Q: Querier + 'static, // 'static is needed by `impl<…> Instance` { /// new stores the data for cache under base_dir /// @@ -88,7 +88,7 @@ where pub fn save_wasm(&mut self, wasm: &[u8]) -> VmResult { check_wasm(wasm, &self.supported_features)?; let checksum = save_wasm_to_disk(&self.wasm_path, wasm)?; - let module = compile(wasm)?; + let module = compile(wasm, None)?; self.fs_cache.store(&checksum, &module)?; Ok(checksum) } @@ -125,7 +125,7 @@ where } // Get module from file system cache - if let Some(module) = self.fs_cache.load(checksum)? { + if let Some(module) = self.fs_cache.load(checksum, options.memory_limit)? { self.stats.hits_fs_cache += 1; let instance = Instance::from_module(&module, backend, options.gas_limit, options.print_debug)?; @@ -136,7 +136,7 @@ where // Re-compile module from wasm let wasm = self.load_wasm(checksum)?; self.stats.misses += 1; - let module = compile(&wasm)?; + let module = compile(&wasm, Some(options.memory_limit))?; let instance = Instance::from_module(&module, backend, options.gas_limit, options.print_debug)?; self.fs_cache.store(checksum, &module)?; @@ -181,7 +181,7 @@ fn load_wasm_from_disk>(dir: P, checksum: &Checksum) -> VmResul } #[cfg(test)] -mod test { +mod tests { use super::*; use crate::calls::{call_handle, call_init}; use crate::errors::VmError; @@ -193,8 +193,10 @@ mod test { use tempfile::TempDir; const TESTING_GAS_LIMIT: u64 = 400_000; + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); const TESTING_OPTIONS: InstanceOptions = InstanceOptions { gas_limit: TESTING_GAS_LIMIT, + memory_limit: TESTING_MEMORY_LIMIT, print_debug: false, }; const TESTING_MEMORY_CACHE_SIZE: Size = Size::mebi(200); @@ -476,7 +478,7 @@ mod test { } #[test] - #[cfg(feature = "default-singlepass")] + #[cfg(feature = "metering")] fn resets_gas_when_reusing_instance() { let mut cache = unsafe { Cache::new(make_testing_options()).unwrap() }; let id = cache.save_wasm(CONTRACT).unwrap(); @@ -508,7 +510,7 @@ mod test { } #[test] - #[cfg(feature = "default-singlepass")] + #[cfg(feature = "metering")] fn recovers_from_out_of_gas() { let mut cache = unsafe { Cache::new(make_testing_options()).unwrap() }; let id = cache.save_wasm(CONTRACT).unwrap(); @@ -519,6 +521,7 @@ mod test { // Init from module cache let options = InstanceOptions { gas_limit: 10, + memory_limit: TESTING_MEMORY_LIMIT, print_debug: false, }; let mut instance1 = cache.get_instance(&id, backend1, options).unwrap(); @@ -537,6 +540,7 @@ mod test { // Init from memory cache let options = InstanceOptions { gas_limit: TESTING_GAS_LIMIT, + memory_limit: TESTING_MEMORY_LIMIT, print_debug: false, }; let mut instance2 = cache.get_instance(&id, backend2, options).unwrap(); diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs index fd3dfdde99..9fd80a7011 100644 --- a/packages/vm/src/calls.rs +++ b/packages/vm/src/calls.rs @@ -1,15 +1,17 @@ +use schemars::JsonSchema; use serde::de::DeserializeOwned; use std::fmt; +use wasmer::Val; use cosmwasm_std::{ ContractResult, Env, HandleResponse, InitResponse, MessageInfo, MigrateResponse, QueryResponse, }; use crate::backend::{Api, Querier, Storage}; +use crate::conversion::ref_to_u32; use crate::errors::{VmError, VmResult}; -use crate::instance::{Func, Instance}; +use crate::instance::Instance; use crate::serde::{from_slice, to_vec}; -use schemars::JsonSchema; const MAX_LENGTH_INIT: usize = 100_000; const MAX_LENGTH_HANDLE: usize = 100_000; @@ -23,9 +25,9 @@ pub fn call_init( msg: &[u8], ) -> VmResult>> where - S: Storage, + S: Storage + 'static, A: Api + 'static, - Q: Querier, + Q: Querier + 'static, U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, { let env = to_vec(env)?; @@ -42,9 +44,9 @@ pub fn call_handle( msg: &[u8], ) -> VmResult>> where - S: Storage, + S: Storage + 'static, A: Api + 'static, - Q: Querier, + Q: Querier + 'static, U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, { let env = to_vec(env)?; @@ -61,9 +63,9 @@ pub fn call_migrate( msg: &[u8], ) -> VmResult>> where - S: Storage, + S: Storage + 'static, A: Api + 'static, - Q: Querier, + Q: Querier + 'static, U: DeserializeOwned + Clone + fmt::Debug + JsonSchema + PartialEq, { let env = to_vec(env)?; @@ -73,7 +75,7 @@ where Ok(result) } -pub fn call_query( +pub fn call_query( instance: &mut Instance, env: &Env, msg: &[u8], @@ -94,7 +96,7 @@ pub fn call_query( /// Calls Wasm export "init" and returns raw data from the contract. /// The result is length limited to prevent abuse but otherwise unchecked. -pub fn call_init_raw( +pub fn call_init_raw( instance: &mut Instance, env: &[u8], info: &[u8], @@ -106,7 +108,7 @@ pub fn call_init_raw( /// Calls Wasm export "handle" and returns raw data from the contract. /// The result is length limited to prevent abuse but otherwise unchecked. -pub fn call_handle_raw( +pub fn call_handle_raw( instance: &mut Instance, env: &[u8], info: &[u8], @@ -118,7 +120,7 @@ pub fn call_handle_raw( /// Calls Wasm export "migrate" and returns raw data from the contract. /// The result is length limited to prevent abuse but otherwise unchecked. -pub fn call_migrate_raw( +pub fn call_migrate_raw( instance: &mut Instance, env: &[u8], info: &[u8], @@ -130,7 +132,7 @@ pub fn call_migrate_raw( /// Calls Wasm export "query" and returns raw data from the contract. /// The result is length limited to prevent abuse but otherwise unchecked. -pub fn call_query_raw( +pub fn call_query_raw( instance: &mut Instance, env: &[u8], msg: &[u8], @@ -139,35 +141,20 @@ pub fn call_query_raw( call_raw(instance, "query", &[env, msg], MAX_LENGTH_QUERY) } -fn call_raw( +fn call_raw( instance: &mut Instance, name: &str, args: &[&[u8]], result_max_length: usize, ) -> VmResult> { - let mut arg_region_ptrs = Vec::::with_capacity(args.len()); + let mut arg_region_ptrs = Vec::::with_capacity(args.len()); for arg in args { let region_ptr = instance.allocate(arg.len())?; instance.write_memory(region_ptr, arg)?; - arg_region_ptrs.push(region_ptr); + arg_region_ptrs.push(region_ptr.into()); } - - let res_region_ptr = match args.len() { - 1 => { - let func: Func = instance.func(name)?; - func.call(arg_region_ptrs[0])? - } - 2 => { - let func: Func<(u32, u32), u32> = instance.func(name)?; - func.call(arg_region_ptrs[0], arg_region_ptrs[1])? - } - 3 => { - let func: Func<(u32, u32, u32), u32> = instance.func(name)?; - func.call(arg_region_ptrs[0], arg_region_ptrs[1], arg_region_ptrs[2])? - } - _ => panic!("call_raw called with unsupported number of arguments"), - }; - + let result = instance.call_function(name, &arg_region_ptrs)?; + let res_region_ptr = ref_to_u32(&result[0])?; let data = instance.read_memory(res_region_ptr, result_max_length)?; // free return value in wasm (arguments were freed in wasm code) instance.deallocate(res_region_ptr)?; diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs deleted file mode 100644 index a588910bad..0000000000 --- a/packages/vm/src/context.rs +++ /dev/null @@ -1,578 +0,0 @@ -//! Internal details to be used by instance.rs only - -use std::ffi::c_void; -use std::ptr::NonNull; - -use wasmer_runtime_core::{ - typed_func::{Func, Wasm, WasmTypeList}, - vm::Ctx, - Instance as WasmerInstance, -}; - -use crate::backend::{GasInfo, Querier, Storage}; -use crate::backends::decrease_gas_left; -use crate::errors::{VmError, VmResult}; - -/** context data **/ - -#[derive(Clone, PartialEq, Debug, Default)] -pub struct GasState { - /// Gas limit for the computation. - pub gas_limit: u64, - /// Tracking the gas used in the cosmos SDK, in cosmwasm units. - #[allow(unused)] - pub externally_used_gas: u64, -} - -impl GasState { - fn with_limit(gas_limit: u64) -> Self { - Self { - gas_limit, - externally_used_gas: 0, - } - } - - #[allow(unused)] - fn increase_externally_used_gas(&mut self, amount: u64) { - self.externally_used_gas += amount; - } - - pub(crate) fn set_gas_limit(&mut self, gas_limit: u64) { - self.gas_limit = gas_limit; - } - - /// Get the amount of gas units still left for the rest of the calculation. - /// - /// We need the amount of gas used in wasmer since it is not tracked inside this object. - #[allow(unused)] - fn get_gas_left(&self, wasmer_used_gas: u64) -> u64 { - self.gas_limit - .saturating_sub(self.externally_used_gas) - .saturating_sub(wasmer_used_gas) - } - - /// Get the amount of gas units used so far inside wasmer. - /// - /// We need the amount of gas left in wasmer since it is not tracked inside this object. - #[allow(unused)] - pub(crate) fn get_gas_used_in_wasmer(&self, wasmer_gas_left: u64) -> u64 { - self.gas_limit - .saturating_sub(self.externally_used_gas) - .saturating_sub(wasmer_gas_left) - } -} - -struct ContextData { - gas_state: GasState, - storage: Option, - storage_readonly: bool, - querier: Option, - /// A non-owning link to the wasmer instance - wasmer_instance: Option>, -} - -pub fn setup_context(gas_limit: u64) -> (*mut c_void, fn(*mut c_void)) { - ( - create_unmanaged_context_data::(gas_limit), - destroy_unmanaged_context_data::, - ) -} - -fn create_unmanaged_context_data(gas_limit: u64) -> *mut c_void { - let data = ContextData:: { - gas_state: GasState::with_limit(gas_limit), - storage: None, - storage_readonly: true, - querier: None, - wasmer_instance: None, - }; - let heap_data = Box::new(data); // move from stack to heap - Box::into_raw(heap_data) as *mut c_void // give up ownership -} - -fn destroy_unmanaged_context_data(ptr: *mut c_void) { - if !ptr.is_null() { - // obtain ownership and drop instance of ContextData when box gets out of scope - let _dying = unsafe { Box::from_raw(ptr as *mut ContextData) }; - } -} - -/// Get a mutable reference to the context's data. Ownership remains in the Context. -fn get_context_data_mut<'a, 'b, S: Storage, Q: Querier>( - ctx: &'a mut Ctx, -) -> &'b mut ContextData { - unsafe { - let ptr = ctx.data as *mut ContextData; - ptr.as_mut() - .expect("The pointer ctx.data was null in get_context_data_mut; this is a bug.") - } -} - -fn get_context_data<'a, 'b, S: Storage, Q: Querier>(ctx: &'a Ctx) -> &'b ContextData { - unsafe { - let ptr = ctx.data as *mut ContextData; - ptr.as_ref() - .expect("The pointer ctx.data was null in get_context_data; this is a bug.") - } -} - -/// Creates a back reference from a contact to its partent instance -pub fn set_wasmer_instance( - ctx: &mut Ctx, - wasmer_instance: Option>, -) { - let context_data = ctx.data as *mut ContextData; - unsafe { - (*context_data).wasmer_instance = wasmer_instance; - } -} - -/// Returns the original storage and querier as owned instances, and closes any remaining -/// iterators. This is meant to be called when recycling the instance. -pub(crate) fn move_out_of_context( - source: &mut Ctx, -) -> (Option, Option) { - let b = get_context_data_mut::(source); - (b.storage.take(), b.querier.take()) -} - -/// Moves owned instances of storage and querier into the context. -/// Should be followed by exactly one call to move_out_of_context when the instance is finished. -pub(crate) fn move_into_context(target: &mut Ctx, storage: S, querier: Q) { - let b = get_context_data_mut::(target); - b.storage = Some(storage); - b.querier = Some(querier); -} - -pub fn get_gas_state_mut<'a, 'b, S: Storage + 'b, Q: Querier + 'b>( - ctx: &'a mut Ctx, -) -> &'b mut GasState { - &mut get_context_data_mut::(ctx).gas_state -} - -pub fn get_gas_state<'a, 'b, S: Storage + 'b, Q: Querier + 'b>(ctx: &'a Ctx) -> &'b GasState { - &get_context_data::(ctx).gas_state -} - -pub fn process_gas_info(ctx: &mut Ctx, info: GasInfo) -> VmResult<()> { - decrease_gas_left(ctx, info.cost)?; - account_for_externally_used_gas::(ctx, info.externally_used)?; - Ok(()) -} - -/// Use this function to adjust the VM's gas limit when a call into the backend -/// reported there was externally metered gas used. -/// This does not increase the VM's gas usage but ensures the overall limit is not exceeded. -fn account_for_externally_used_gas( - ctx: &mut Ctx, - amount: u64, -) -> VmResult<()> { - account_for_externally_used_gas_impl::(ctx, amount) -} - -#[cfg(feature = "default-singlepass")] -fn account_for_externally_used_gas_impl( - ctx: &mut Ctx, - used_gas: u64, -) -> VmResult<()> { - use crate::backends::{get_gas_left, set_gas_left}; - - let ctx_data = get_context_data_mut::(ctx); - if let Some(mut instance_ptr) = ctx_data.wasmer_instance { - let instance = unsafe { instance_ptr.as_mut() }; - let gas_state = &mut ctx_data.gas_state; - - let wasmer_used_gas = gas_state.get_gas_used_in_wasmer(get_gas_left(instance.context())); - - gas_state.increase_externally_used_gas(used_gas); - // These lines reduce the amount of gas available to wasmer - // so it can not consume gas that was consumed externally. - let new_limit = gas_state.get_gas_left(wasmer_used_gas); - // This tells wasmer how much more gas it can consume from this point in time. - set_gas_left(instance.context_mut(), new_limit); - - if gas_state.externally_used_gas + wasmer_used_gas > gas_state.gas_limit { - Err(VmError::GasDepletion) - } else { - Ok(()) - } - } else { - Err(VmError::uninitialized_context_data("wasmer_instance")) - } -} - -#[cfg(feature = "default-cranelift")] -fn account_for_externally_used_gas_impl( - _ctx: &mut Ctx, - _used_gas: u64, -) -> VmResult<()> { - Ok(()) -} - -/// Returns true iff the storage is set to readonly mode -pub fn is_storage_readonly(ctx: &Ctx) -> bool { - let context_data = get_context_data::(ctx); - context_data.storage_readonly -} - -pub fn set_storage_readonly(ctx: &mut Ctx, new_value: bool) { - let mut context_data = get_context_data_mut::(ctx); - context_data.storage_readonly = new_value; -} - -pub(crate) fn with_func_from_context( - ctx: &mut Ctx, - name: &str, - callback: Callback, -) -> VmResult -where - S: Storage, - Q: Querier, - Args: WasmTypeList, - Rets: WasmTypeList, - Callback: FnOnce(Func) -> VmResult, -{ - let ctx_data = get_context_data::(ctx); - match ctx_data.wasmer_instance { - Some(instance_ptr) => { - let func = unsafe { instance_ptr.as_ref() }.exports.get(name)?; - callback(func) - } - None => Err(VmError::uninitialized_context_data("wasmer_instance")), - } -} - -pub(crate) fn with_storage_from_context<'a, 'b, S: 'b, Q: 'b, F, T>( - ctx: &'a mut Ctx, - func: F, -) -> VmResult -where - S: Storage, - Q: Querier, - F: FnOnce(&'b mut S) -> VmResult, -{ - let b = get_context_data_mut::(ctx); - match b.storage.as_mut() { - Some(data) => func(data), - None => Err(VmError::uninitialized_context_data("storage")), - } -} - -pub(crate) fn with_querier_from_context<'a, 'b, S: 'b, Q: 'b, F, T>( - ctx: &'a mut Ctx, - func: F, -) -> VmResult -where - S: Storage, - Q: Querier, - F: FnOnce(&'b mut Q) -> VmResult, -{ - let b = get_context_data_mut::(ctx); - match b.querier.as_mut() { - Some(querier) => func(querier), - None => Err(VmError::uninitialized_context_data("querier")), - } -} - -#[cfg(test)] -mod test { - use super::*; - use crate::backend::Storage; - use crate::backends::{compile, decrease_gas_left, set_gas_left}; - use crate::errors::VmError; - use crate::testing::{MockQuerier, MockStorage}; - use cosmwasm_std::{ - coins, from_binary, to_vec, AllBalanceResponse, BankQuery, Empty, HumanAddr, QueryRequest, - }; - use wasmer_runtime_core::{imports, typed_func::Func}; - - static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); - - // shorthands for function generics below - type MS = MockStorage; - type MQ = MockQuerier; - - // prepared data - const INIT_KEY: &[u8] = b"foo"; - const INIT_VALUE: &[u8] = b"bar"; - // this account has some coins - const INIT_ADDR: &str = "someone"; - const INIT_AMOUNT: u128 = 500; - const INIT_DENOM: &str = "TOKEN"; - - const GAS_LIMIT: u64 = 5_000_000; - const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000; - - fn make_instance() -> Box { - let module = compile(&CONTRACT).unwrap(); - // we need stubs for all required imports - let import_obj = imports! { - || { setup_context::(GAS_LIMIT) }, - "env" => { - "db_read" => Func::new(|_a: u32| -> u32 { 0 }), - "db_write" => Func::new(|_a: u32, _b: u32| {}), - "db_remove" => Func::new(|_a: u32| {}), - "db_scan" => Func::new(|_a: u32, _b: u32, _c: i32| -> u32 { 0 }), - "db_next" => Func::new(|_a: u32| -> u32 { 0 }), - "query_chain" => Func::new(|_a: u32| -> u32 { 0 }), - "canonicalize_address" => Func::new(|_a: u32, _b: u32| -> u32 { 0 }), - "humanize_address" => Func::new(|_a: u32, _b: u32| -> u32 { 0 }), - "debug" => Func::new(|_a: u32| {}), - }, - }; - let mut instance = Box::from(module.instantiate(&import_obj).unwrap()); - - let instance_ptr = NonNull::from(instance.as_ref()); - set_wasmer_instance::(instance.context_mut(), Some(instance_ptr)); - - instance - } - - fn leave_default_data(ctx: &mut Ctx) { - // create some mock data - let mut storage = MockStorage::new(); - storage - .set(INIT_KEY, INIT_VALUE) - .0 - .expect("error setting value"); - let querier: MockQuerier = - MockQuerier::new(&[(&HumanAddr::from(INIT_ADDR), &coins(INIT_AMOUNT, INIT_DENOM))]); - move_into_context(ctx, storage, querier); - } - - #[test] - fn leave_and_take_context_data() { - // this creates an instance - let mut instance = make_instance(); - let ctx = instance.context_mut(); - - // empty data on start - let (inits, initq) = move_out_of_context::(ctx); - assert!(inits.is_none()); - assert!(initq.is_none()); - - // store it on the instance - leave_default_data(ctx); - let (s, q) = move_out_of_context::(ctx); - assert!(s.is_some()); - assert!(q.is_some()); - assert_eq!( - s.unwrap().get(INIT_KEY).0.unwrap(), - Some(INIT_VALUE.to_vec()) - ); - - // now is empty again - let (ends, endq) = move_out_of_context::(ctx); - assert!(ends.is_none()); - assert!(endq.is_none()); - } - - #[test] - #[cfg(feature = "default-singlepass")] - fn gas_tracking_works_correctly() { - let mut instance = make_instance(); - - let gas_limit = 100; - set_gas_left(instance.context_mut(), gas_limit); - get_gas_state_mut::(instance.context_mut()).set_gas_limit(gas_limit); - let context = instance.context_mut(); - - // Consume all the Gas that we allocated - account_for_externally_used_gas::(context, 70).unwrap(); - account_for_externally_used_gas::(context, 4).unwrap(); - account_for_externally_used_gas::(context, 6).unwrap(); - account_for_externally_used_gas::(context, 20).unwrap(); - // Using one more unit of gas triggers a failure - match account_for_externally_used_gas::(context, 1).unwrap_err() { - VmError::GasDepletion => {} - err => panic!("unexpected error: {:?}", err), - } - } - - #[test] - #[cfg(feature = "default-singlepass")] - fn gas_tracking_works_correctly_with_gas_consumption_in_wasmer() { - let mut instance = make_instance(); - - let gas_limit = 100; - set_gas_left(instance.context_mut(), gas_limit); - get_gas_state_mut::(instance.context_mut()).set_gas_limit(gas_limit); - let context = instance.context_mut(); - - // Some gas was consumed externally - account_for_externally_used_gas::(context, 50).unwrap(); - account_for_externally_used_gas::(context, 4).unwrap(); - - // Consume 20 gas directly in wasmer - decrease_gas_left(instance.context_mut(), 20).unwrap(); - - let context = instance.context_mut(); - account_for_externally_used_gas::(context, 6).unwrap(); - account_for_externally_used_gas::(context, 20).unwrap(); - // Using one more unit of gas triggers a failure - match account_for_externally_used_gas::(context, 1).unwrap_err() { - VmError::GasDepletion => {} - err => panic!("unexpected error: {:?}", err), - } - } - - #[test] - fn is_storage_readonly_defaults_to_true() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); - - assert_eq!(is_storage_readonly::(ctx), true); - } - - #[test] - fn set_storage_readonly_can_change_flag() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); - - // change - set_storage_readonly::(ctx, false); - assert_eq!(is_storage_readonly::(ctx), false); - - // still false - set_storage_readonly::(ctx, false); - assert_eq!(is_storage_readonly::(ctx), false); - - // change back - set_storage_readonly::(ctx, true); - assert_eq!(is_storage_readonly::(ctx), true); - } - - #[test] - fn with_func_from_context_works() { - let mut instance = make_instance(); - leave_default_data(instance.context_mut()); - - let ctx = instance.context_mut(); - let ptr = with_func_from_context::(ctx, "allocate", |alloc_func| { - let ptr = alloc_func.call(10)?; - Ok(ptr) - }) - .unwrap(); - assert!(ptr > 0); - } - - #[test] - fn with_func_from_context_fails_for_missing_instance() { - let mut instance = make_instance(); - leave_default_data(instance.context_mut()); - - // Clear context's wasmer_instance - set_wasmer_instance::(instance.context_mut(), None); - - let ctx = instance.context_mut(); - let res = with_func_from_context::(ctx, "allocate", |_func| { - panic!("unexpected callback call"); - }); - match res.unwrap_err() { - VmError::UninitializedContextData { kind, .. } => assert_eq!(kind, "wasmer_instance"), - err => panic!("Unexpected error: {:?}", err), - } - } - - #[test] - fn with_func_from_context_fails_for_missing_function() { - let mut instance = make_instance(); - leave_default_data(instance.context_mut()); - - let ctx = instance.context_mut(); - let res = with_func_from_context::(ctx, "doesnt_exist", |_func| { - panic!("unexpected callback call"); - }); - match res.unwrap_err() { - VmError::ResolveErr { msg, .. } => { - assert_eq!( - msg, - "Wasmer resolve error: ExportNotFound { name: \"doesnt_exist\" }" - ); - } - err => panic!("Unexpected error: {:?}", err), - } - } - - #[test] - fn with_storage_from_context_set_get() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); - - let val = with_storage_from_context::(ctx, |store| { - Ok(store.get(INIT_KEY).0.expect("error getting value")) - }) - .unwrap(); - assert_eq!(val, Some(INIT_VALUE.to_vec())); - - let set_key: &[u8] = b"more"; - let set_value: &[u8] = b"data"; - - with_storage_from_context::(ctx, |store| { - store - .set(set_key, set_value) - .0 - .expect("error setting value"); - Ok(()) - }) - .unwrap(); - - with_storage_from_context::(ctx, |store| { - assert_eq!(store.get(INIT_KEY).0.unwrap(), Some(INIT_VALUE.to_vec())); - assert_eq!(store.get(set_key).0.unwrap(), Some(set_value.to_vec())); - Ok(()) - }) - .unwrap(); - } - - #[test] - #[should_panic(expected = "A panic occurred in the callback.")] - fn with_storage_from_context_handles_panics() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); - - with_storage_from_context::(ctx, |_store| { - panic!("A panic occurred in the callback.") - }) - .unwrap(); - } - - #[test] - fn with_querier_from_context_works() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); - - let res = with_querier_from_context::(ctx, |querier| { - let req: QueryRequest = QueryRequest::Bank(BankQuery::AllBalances { - address: HumanAddr::from(INIT_ADDR), - }); - let (result, _gas_info) = - querier.query_raw(&to_vec(&req).unwrap(), DEFAULT_QUERY_GAS_LIMIT); - Ok(result.unwrap()) - }) - .unwrap() - .unwrap() - .unwrap(); - let balance: AllBalanceResponse = from_binary(&res).unwrap(); - - assert_eq!(balance.amount, coins(INIT_AMOUNT, INIT_DENOM)); - } - - #[test] - #[should_panic(expected = "A panic occurred in the callback.")] - fn with_querier_from_context_handles_panics() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); - - with_querier_from_context::(ctx, |_querier| { - panic!("A panic occurred in the callback.") - }) - .unwrap(); - } -} diff --git a/packages/vm/src/conversion.rs b/packages/vm/src/conversion.rs index c6fd82dc9c..e763021c1a 100644 --- a/packages/vm/src/conversion.rs +++ b/packages/vm/src/conversion.rs @@ -12,6 +12,14 @@ pub fn to_u32 + Display + Copy>(input: T) -> VmResult { }) } +/// Safely converts input of type &T to u32. +/// Errors with a cosmwasm_vm::errors::VmError::ConversionErr if conversion cannot be done. +pub fn ref_to_u32 + ToString + Clone>(input: &T) -> VmResult { + input.clone().try_into().map_err(|_| { + VmError::conversion_err(type_name::(), type_name::(), input.to_string()) + }) +} + /// Safely converts input of type T to i32. /// Errors with a cosmwasm_vm::errors::VmError::ConversionErr if conversion cannot be done. /// @@ -98,6 +106,47 @@ mod test { }; } + #[test] + fn ref_to_u32_works() { + // i32 + assert_eq!(ref_to_u32(&0i32).unwrap(), 0); + assert_eq!(ref_to_u32(&1i32).unwrap(), 1); + assert_eq!(ref_to_u32(&2147483647i32).unwrap(), 2147483647); + match ref_to_u32(&-1i32).unwrap_err() { + VmError::ConversionErr { + from_type, + to_type, + input, + .. + } => { + assert_eq!(from_type, "i32"); + assert_eq!(to_type, "u32"); + assert_eq!(input, "-1"); + } + err => panic!("Unexpected error: {:?}", err), + }; + + // usize + assert_eq!(ref_to_u32(&0usize).unwrap(), 0); + assert_eq!(ref_to_u32(&1usize).unwrap(), 1); + assert_eq!(ref_to_u32(&2147483647usize).unwrap(), 2147483647); + assert_eq!(ref_to_u32(&2147483648usize).unwrap(), 2147483648); + assert_eq!(ref_to_u32(&4294967295usize).unwrap(), 4294967295); + match ref_to_u32(&4294967296usize).unwrap_err() { + VmError::ConversionErr { + from_type, + to_type, + input, + .. + } => { + assert_eq!(from_type, "usize"); + assert_eq!(to_type, "u32"); + assert_eq!(input, "4294967296"); + } + err => panic!("Unexpected error: {:?}", err), + }; + } + #[test] fn to_i32_works_for_usize() { assert_eq!(to_i32(0usize).unwrap(), 0); diff --git a/packages/vm/src/environment.rs b/packages/vm/src/environment.rs new file mode 100644 index 0000000000..0fee1f2df5 --- /dev/null +++ b/packages/vm/src/environment.rs @@ -0,0 +1,580 @@ +//! Internal details to be used by instance.rs only +use std::borrow::{Borrow, BorrowMut}; +use std::ptr::NonNull; +use std::sync::{Arc, RwLock}; + +use wasmer::{Function, HostEnvInitError, Instance as WasmerInstance, Memory, WasmerEnv}; + +use crate::backend::{GasInfo, Querier, Storage}; +use crate::errors::{VmError, VmResult}; +use crate::wasm_backend::{decrease_gas_left, get_gas_left, set_gas_left}; + +/** context data **/ + +#[derive(Clone, PartialEq, Debug, Default)] +pub struct GasState { + /// Gas limit for the computation. + pub gas_limit: u64, + /// Tracking the gas used in the cosmos SDK, in cosmwasm units. + #[allow(unused)] + pub externally_used_gas: u64, +} + +impl GasState { + fn with_limit(gas_limit: u64) -> Self { + Self { + gas_limit, + externally_used_gas: 0, + } + } + + #[allow(unused)] + fn increase_externally_used_gas(&mut self, amount: u64) { + self.externally_used_gas += amount; + } + + pub(crate) fn set_gas_limit(&mut self, gas_limit: u64) { + self.gas_limit = gas_limit; + } + + /// Get the amount of gas units still left for the rest of the calculation. + /// + /// We need the amount of gas used in wasmer since it is not tracked inside this object. + #[allow(unused)] + fn get_gas_left(&self, wasmer_used_gas: u64) -> u64 { + self.gas_limit + .saturating_sub(self.externally_used_gas) + .saturating_sub(wasmer_used_gas) + } + + /// Get the amount of gas units used so far inside wasmer. + /// + /// We need the amount of gas left in wasmer since it is not tracked inside this object. + #[allow(unused)] + pub(crate) fn get_gas_used_in_wasmer(&self, wasmer_gas_left: u64) -> u64 { + self.gas_limit + .saturating_sub(self.externally_used_gas) + .saturating_sub(wasmer_gas_left) + } +} + +/// A environment that provides access to the ContextData. +/// The environment is clonable but clones access the same underlying data. +pub struct Environment { + data: Arc>>, + pub print_debug: bool, +} + +impl Clone for Environment { + fn clone(&self) -> Self { + Environment { + data: self.data.clone(), + print_debug: self.print_debug, + } + } +} + +impl WasmerEnv for Environment { + fn init_with_instance(&mut self, _instance: &WasmerInstance) -> Result<(), HostEnvInitError> { + Ok(()) + } +} + +impl Environment { + pub fn new(gas_limit: u64, print_debug: bool) -> Self { + Environment { + data: Arc::new(RwLock::new(ContextData::new(gas_limit))), + print_debug, + } + } + + pub fn with_context_data_mut(&self, callback: C) -> R + where + C: FnOnce(&mut ContextData) -> R, + { + let mut guard = self.data.as_ref().write().unwrap(); + let context_data = guard.borrow_mut(); + callback(context_data) + } + + pub fn with_context_data(&self, callback: C) -> R + where + C: FnOnce(&ContextData) -> R, + { + let guard = self.data.as_ref().read().unwrap(); + let context_data = guard.borrow(); + callback(context_data) + } + + pub fn with_gas_state_mut(&self, callback: C) -> R + where + C: FnOnce(&mut GasState) -> R, + { + self.with_context_data_mut(|context_data| callback(&mut context_data.gas_state)) + } + + pub fn with_gas_state(&self, callback: C) -> R + where + C: FnOnce(&GasState) -> R, + { + self.with_context_data(|context_data| callback(&context_data.gas_state)) + } + + pub fn with_func_from_context(&self, name: &str, callback: C) -> VmResult + where + C: FnOnce(&Function) -> VmResult, + { + self.with_context_data_mut(|context_data| match context_data.wasmer_instance { + Some(instance_ptr) => { + let func = unsafe { instance_ptr.as_ref() } + .exports + .get_function(name)?; + callback(func) + } + None => Err(VmError::uninitialized_context_data("wasmer_instance")), + }) + } + + pub fn with_storage_from_context(&self, callback: C) -> VmResult + where + C: FnOnce(&mut S) -> VmResult, + { + self.with_context_data_mut(|context_data| match context_data.storage.as_mut() { + Some(data) => callback(data), + None => Err(VmError::uninitialized_context_data("storage")), + }) + } + + pub fn with_querier_from_context(&self, callback: C) -> VmResult + where + C: FnOnce(&mut Q) -> VmResult, + { + self.with_context_data_mut(|context_data| match context_data.querier.as_mut() { + Some(querier) => callback(querier), + None => Err(VmError::uninitialized_context_data("querier")), + }) + } + + /// Creates a back reference from a contact to its partent instance + pub fn set_wasmer_instance(&self, wasmer_instance: Option>) { + self.with_context_data_mut(|context_data| { + context_data.wasmer_instance = wasmer_instance; + }); + } + + /// Returns true iff the storage is set to readonly mode + pub fn is_storage_readonly(&self) -> bool { + self.with_context_data(|context_data| context_data.storage_readonly) + } + + pub fn set_storage_readonly(&self, new_value: bool) { + self.with_context_data_mut(|context_data| { + context_data.storage_readonly = new_value; + }) + } + + pub fn memory(&self) -> Memory { + self.with_context_data(|context| { + let ptr = context + .wasmer_instance + .expect("Wasmer instance is not set. This is a bug."); + let instance = unsafe { ptr.as_ref() }; + let mut memories: Vec = instance + .exports + .iter() + .memories() + .map(|pair| pair.1.clone()) + .collect(); + memories.pop().unwrap() + }) + } +} + +pub struct ContextData { + gas_state: GasState, + storage: Option, + storage_readonly: bool, + querier: Option, + /// A non-owning link to the wasmer instance + wasmer_instance: Option>, +} + +impl ContextData { + pub fn new(gas_limit: u64) -> Self { + ContextData:: { + gas_state: GasState::with_limit(gas_limit), + storage: None, + storage_readonly: true, + querier: None, + wasmer_instance: None, + } + } +} + +/// Returns the original storage and querier as owned instances, and closes any remaining +/// iterators. This is meant to be called when recycling the instance. +pub(crate) fn move_out_of_environment( + env: &Environment, +) -> (Option, Option) { + env.with_context_data_mut(|context_data| { + (context_data.storage.take(), context_data.querier.take()) + }) +} + +/// Moves owned instances of storage and querier into the env. +/// Should be followed by exactly one call to move_out_of_environment when the instance is finished. +pub(crate) fn move_into_environment( + env: &Environment, + storage: S, + querier: Q, +) { + env.with_context_data_mut(|context_data| { + context_data.storage = Some(storage); + context_data.querier = Some(querier); + }); +} + +pub fn process_gas_info( + env: &Environment, + info: GasInfo, +) -> VmResult<()> { + decrease_gas_left(env, info.cost)?; + account_for_externally_used_gas(env, info.externally_used)?; + Ok(()) +} + +/// Use this function to adjust the VM's gas limit when a call into the backend +/// reported there was externally metered gas used. +/// This does not increase the VM's gas usage but ensures the overall limit is not exceeded. +fn account_for_externally_used_gas( + env: &Environment, + amount: u64, +) -> VmResult<()> { + account_for_externally_used_gas_impl(env, amount) +} + +fn account_for_externally_used_gas_impl( + env: &Environment, + used_gas: u64, +) -> VmResult<()> { + env.with_context_data_mut(|context_data| { + let gas_state = &mut context_data.gas_state; + + let wasmer_used_gas = gas_state.get_gas_used_in_wasmer(get_gas_left(env)); + + gas_state.increase_externally_used_gas(used_gas); + // These lines reduce the amount of gas available to wasmer + // so it can not consume gas that was consumed externally. + let new_limit = gas_state.get_gas_left(wasmer_used_gas); + // This tells wasmer how much more gas it can consume from this point in time. + set_gas_left(env, new_limit); + + if gas_state.externally_used_gas + wasmer_used_gas > gas_state.gas_limit { + Err(VmError::GasDepletion) + } else { + Ok(()) + } + }) +} + +#[cfg(test)] +mod test { + use super::*; + use crate::backend::Storage; + use crate::conversion::ref_to_u32; + use crate::errors::VmError; + use crate::size::Size; + use crate::testing::{MockQuerier, MockStorage}; + #[cfg(feature = "metering")] + use crate::wasm_backend::decrease_gas_left; + use crate::wasm_backend::{compile, set_gas_left}; + use cosmwasm_std::{ + coins, from_binary, to_vec, AllBalanceResponse, BankQuery, Empty, HumanAddr, QueryRequest, + }; + use wasmer::{imports, Function, FunctionType, Instance as WasmerInstance, Type, Val}; + + static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); + + // shorthands for function generics below + type MS = MockStorage; + type MQ = MockQuerier; + + // prepared data + const INIT_KEY: &[u8] = b"foo"; + const INIT_VALUE: &[u8] = b"bar"; + // this account has some coins + const INIT_ADDR: &str = "someone"; + const INIT_AMOUNT: u128 = 500; + const INIT_DENOM: &str = "TOKEN"; + + const GAS_LIMIT: u64 = 5_000_000; + const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000; + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); + + fn make_instance() -> (Environment, Box) { + let env = Environment::new(GAS_LIMIT, false); + + let module = compile(&CONTRACT, Some(TESTING_MEMORY_LIMIT)).unwrap(); + let store = module.store(); + let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); + let i32_to_i32 = FunctionType::new(vec![Type::I32], vec![Type::I32]); + let i32i32_to_void = FunctionType::new(vec![Type::I32, Type::I32], vec![]); + let i32i32_to_i32 = FunctionType::new(vec![Type::I32, Type::I32], vec![Type::I32]); + let i32i32i32_to_i32 = + FunctionType::new(vec![Type::I32, Type::I32, Type::I32], vec![Type::I32]); + // we need stubs for all required imports + let import_obj = imports! { + "env" => { + "db_read" => Function::new(store, &i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "db_write" => Function::new(store, &i32i32_to_void, |_args: &[Val]| { Ok(vec![]) }), + "db_remove" => Function::new(store, &i32_to_void, |_args: &[Val]| { Ok(vec![]) }), + "db_scan" => Function::new(store, &i32i32i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "db_next" => Function::new(store, &i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "query_chain" => Function::new(store, &i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "canonicalize_address" => Function::new(store, &i32i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "humanize_address" => Function::new(store, &i32i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "debug" => Function::new(store, &i32_to_void, |_args: &[Val]| { Ok(vec![]) }), + }, + }; + let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); + + let instance_ptr = NonNull::from(instance.as_ref()); + env.set_wasmer_instance(Some(instance_ptr)); + + (env, instance) + } + + fn leave_default_data(env: &Environment) { + // create some mock data + let mut storage = MockStorage::new(); + storage + .set(INIT_KEY, INIT_VALUE) + .0 + .expect("error setting value"); + let querier: MockQuerier = + MockQuerier::new(&[(&HumanAddr::from(INIT_ADDR), &coins(INIT_AMOUNT, INIT_DENOM))]); + move_into_environment(env, storage, querier); + } + + #[test] + fn leave_and_take_context_data() { + let (env, _instance) = make_instance(); + + // empty data on start + let (inits, initq) = move_out_of_environment::(&env); + assert!(inits.is_none()); + assert!(initq.is_none()); + + // store it on the instance + leave_default_data(&env); + let (s, q) = move_out_of_environment::(&env); + assert!(s.is_some()); + assert!(q.is_some()); + assert_eq!( + s.unwrap().get(INIT_KEY).0.unwrap(), + Some(INIT_VALUE.to_vec()) + ); + + // now is empty again + let (ends, endq) = move_out_of_environment::(&env); + assert!(ends.is_none()); + assert!(endq.is_none()); + } + + #[test] + fn gas_tracking_works_correctly() { + let (env, _instance) = make_instance(); + + let gas_limit = 100; + set_gas_left(&env, gas_limit); + env.with_gas_state_mut(|state| state.set_gas_limit(gas_limit)); + + // Consume all the Gas that we allocated + account_for_externally_used_gas::(&env, 70).unwrap(); + account_for_externally_used_gas::(&env, 4).unwrap(); + account_for_externally_used_gas::(&env, 6).unwrap(); + account_for_externally_used_gas::(&env, 20).unwrap(); + // Using one more unit of gas triggers a failure + match account_for_externally_used_gas::(&env, 1).unwrap_err() { + VmError::GasDepletion => {} + err => panic!("unexpected error: {:?}", err), + } + } + + #[test] + #[cfg(feature = "metering")] + fn gas_tracking_works_correctly_with_gas_consumption_in_wasmer() { + let (env, _instance) = make_instance(); + + let gas_limit = 100; + set_gas_left(&env, gas_limit); + env.with_gas_state_mut(|state| state.set_gas_limit(gas_limit)); + + // Some gas was consumed externally + account_for_externally_used_gas::(&env, 50).unwrap(); + account_for_externally_used_gas::(&env, 4).unwrap(); + + // Consume 20 gas directly in wasmer + decrease_gas_left(&env, 20).unwrap(); + + account_for_externally_used_gas::(&env, 6).unwrap(); + account_for_externally_used_gas::(&env, 20).unwrap(); + // Using one more unit of gas triggers a failure + match account_for_externally_used_gas::(&env, 1).unwrap_err() { + VmError::GasDepletion => {} + err => panic!("unexpected error: {:?}", err), + } + } + + #[test] + fn is_storage_readonly_defaults_to_true() { + let (env, _instance) = make_instance(); + leave_default_data(&env); + + assert_eq!(env.is_storage_readonly(), true); + } + + #[test] + fn set_storage_readonly_can_change_flag() { + let (env, _instance) = make_instance(); + leave_default_data(&env); + + // change + env.set_storage_readonly(false); + assert_eq!(env.is_storage_readonly(), false); + + // still false + env.set_storage_readonly(false); + assert_eq!(env.is_storage_readonly(), false); + + // change back + env.set_storage_readonly(true); + assert_eq!(env.is_storage_readonly(), true); + } + + #[test] + fn with_func_from_context_works() { + let (env, _instance) = make_instance(); + leave_default_data(&env); + + let ptr = env + .with_func_from_context::<_, _>("allocate", |alloc_func| { + let result = alloc_func.call(&[10u32.into()])?; + let ptr = ref_to_u32(&result[0])?; + Ok(ptr) + }) + .unwrap(); + assert!(ptr > 0); + } + + #[test] + fn with_func_from_context_fails_for_missing_instance() { + let (env, _instance) = make_instance(); + leave_default_data(&env); + + // Clear context's wasmer_instance + env.set_wasmer_instance(None); + + let res = env.with_func_from_context::<_, ()>("allocate", |_func| { + panic!("unexpected callback call"); + }); + match res.unwrap_err() { + VmError::UninitializedContextData { kind, .. } => assert_eq!(kind, "wasmer_instance"), + err => panic!("Unexpected error: {:?}", err), + } + } + + #[test] + fn with_func_from_context_fails_for_missing_function() { + let (env, _instance) = make_instance(); + leave_default_data(&env); + + let res = env.with_func_from_context::<_, ()>("doesnt_exist", |_func| { + panic!("unexpected callback call"); + }); + match res.unwrap_err() { + VmError::ResolveErr { msg, .. } => { + assert_eq!(msg, "Could not get export: Missing export doesnt_exist"); + } + err => panic!("Unexpected error: {:?}", err), + } + } + + #[test] + fn with_storage_from_context_set_get() { + let (env, _instance) = make_instance(); + leave_default_data(&env); + + let val = env + .with_storage_from_context::<_, _>(|store| { + Ok(store.get(INIT_KEY).0.expect("error getting value")) + }) + .unwrap(); + assert_eq!(val, Some(INIT_VALUE.to_vec())); + + let set_key: &[u8] = b"more"; + let set_value: &[u8] = b"data"; + + env.with_storage_from_context::<_, _>(|store| { + store + .set(set_key, set_value) + .0 + .expect("error setting value"); + Ok(()) + }) + .unwrap(); + + env.with_storage_from_context::<_, _>(|store| { + assert_eq!(store.get(INIT_KEY).0.unwrap(), Some(INIT_VALUE.to_vec())); + assert_eq!(store.get(set_key).0.unwrap(), Some(set_value.to_vec())); + Ok(()) + }) + .unwrap(); + } + + #[test] + #[should_panic(expected = "A panic occurred in the callback.")] + fn with_storage_from_context_handles_panics() { + let (env, _instance) = make_instance(); + leave_default_data(&env); + + env.with_storage_from_context::<_, ()>(|_store| { + panic!("A panic occurred in the callback.") + }) + .unwrap(); + } + + #[test] + fn with_querier_from_context_works() { + let (env, _instance) = make_instance(); + leave_default_data(&env); + + let res = env + .with_querier_from_context::<_, _>(|querier| { + let req: QueryRequest = QueryRequest::Bank(BankQuery::AllBalances { + address: HumanAddr::from(INIT_ADDR), + }); + let (result, _gas_info) = + querier.query_raw(&to_vec(&req).unwrap(), DEFAULT_QUERY_GAS_LIMIT); + Ok(result.unwrap()) + }) + .unwrap() + .unwrap() + .unwrap(); + let balance: AllBalanceResponse = from_binary(&res).unwrap(); + + assert_eq!(balance.amount, coins(INIT_AMOUNT, INIT_DENOM)); + } + + #[test] + #[should_panic(expected = "A panic occurred in the callback.")] + fn with_querier_from_context_handles_panics() { + let (env, _instance) = make_instance(); + leave_default_data(&env); + + env.with_querier_from_context::<_, ()>(|_querier| { + panic!("A panic occurred in the callback.") + }) + .unwrap(); + } +} diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index f1dce0878f..89f6c8fdd5 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -3,7 +3,7 @@ use thiserror::Error; use super::communication_error::CommunicationError; use crate::backend::BackendError; -use crate::backends::InsufficientGasLeft; +use crate::wasm_backend::InsufficientGasLeft; #[derive(Error, Debug)] #[non_exhaustive] @@ -135,46 +135,33 @@ impl From for VmError { } } -impl From for VmError { - fn from(original: wasmer_runtime_core::cache::Error) -> Self { - VmError::cache_err(format!("Wasmer cache error: {:?}", original)) +impl From for VmError { + fn from(original: wasmer::ExportError) -> Self { + VmError::resolve_err(format!("Could not get export: {}", original)) } } -impl From for VmError { - fn from(original: wasmer_runtime_core::error::CompileError) -> Self { - VmError::compile_err(format!("Wasmer compile error: {:?}", original)) +impl From for VmError { + fn from(original: wasmer::SerializeError) -> Self { + VmError::cache_err(format!("Could not serialize module: {}", original)) } } -impl From for VmError { - fn from(original: wasmer_runtime_core::error::ResolveError) -> Self { - VmError::resolve_err(format!("Wasmer resolve error: {:?}", original)) +impl From for VmError { + fn from(original: wasmer::DeserializeError) -> Self { + VmError::cache_err(format!("Could not deserialize module: {}", original)) } } -impl From for VmError { - fn from(original: wasmer_runtime_core::error::RuntimeError) -> Self { - use wasmer_runtime_core::error::{InvokeError, RuntimeError}; - - fn runtime_error(err: RuntimeError) -> VmError { - VmError::runtime_err(format!("Wasmer runtime error: {:?}", err)) - } +impl From for VmError { + fn from(original: wasmer::RuntimeError) -> Self { + VmError::runtime_err(format!("Wasmer runtime error: {}", original)) + } +} - match original { - // TODO: fix the issue described below: - // `InvokeError::FailedWithNoError` happens when running out of gas in singlepass v0.17 - // but it's supposed to indicate bugs in Wasmer... - // https://github.com/wasmerio/wasmer/issues/1452 - // https://github.com/CosmWasm/cosmwasm/issues/375 - RuntimeError::InvokeError(InvokeError::FailedWithNoError) => VmError::GasDepletion, - // This variant contains the error we return from imports. - RuntimeError::User(err) => match err.downcast::() { - Ok(err) => *err, - Err(err) => runtime_error(RuntimeError::User(err)), - }, - _ => runtime_error(original), - } +impl From for VmError { + fn from(original: wasmer::CompileError) -> Self { + VmError::compile_err(format!("Could not compile: {}", original)) } } @@ -184,6 +171,19 @@ impl From for VmError { } } +impl From for VmError { + fn from(_original: std::convert::Infallible) -> Self { + unreachable!(); + } +} + +impl From for wasmer::RuntimeError { + fn from(original: VmError) -> wasmer::RuntimeError { + let msg: String = original.to_string(); + wasmer::RuntimeError::new(msg) + } +} + #[cfg(test)] mod test { use super::*; diff --git a/packages/vm/src/features.rs b/packages/vm/src/features.rs index bb38e4d2d1..5567e41dd0 100644 --- a/packages/vm/src/features.rs +++ b/packages/vm/src/features.rs @@ -1,7 +1,7 @@ use parity_wasm::elements::{Internal, Module}; use std::collections::HashSet; use std::iter::FromIterator; -use wasmer_runtime_core::{export::Export, Instance as WasmerInstance}; +use wasmer::{ExternType, Instance as WasmerInstance}; const REQUIRES_PREFIX: &str = "requires_"; @@ -16,10 +16,12 @@ pub fn features_from_csv(csv: &str) -> HashSet { } pub fn required_features_from_wasmer_instance(wasmer_instance: &WasmerInstance) -> HashSet { - HashSet::from_iter(wasmer_instance.exports().filter_map(|(mut name, export)| { - if let Export::Function { .. } = export { + let module = wasmer_instance.module(); + HashSet::from_iter(module.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.split_off(REQUIRES_PREFIX.len()); + let required_feature = name.to_string().split_off(REQUIRES_PREFIX.len()); return Some(required_feature); } } diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 4c48cdeeef..8ceef0cdb1 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -6,20 +6,16 @@ use std::convert::TryInto; #[cfg(feature = "iterator")] use cosmwasm_std::Order; use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr}; -use wasmer_runtime_core::vm::Ctx; use crate::backend::{Api, BackendError, Querier, Storage}; -use crate::backends::get_gas_left; -use crate::context::{ - is_storage_readonly, process_gas_info, with_func_from_context, with_querier_from_context, - with_storage_from_context, -}; -use crate::conversion::to_u32; +use crate::conversion::{ref_to_u32, to_u32}; +use crate::environment::{process_gas_info, Environment}; use crate::errors::{CommunicationError, VmError, VmResult}; #[cfg(feature = "iterator")] use crate::memory::maybe_read_region; use crate::memory::{read_region, write_region}; use crate::serde::to_vec; +use crate::wasm_backend::get_gas_left; /// A kibi (kilo binary) const KI: usize = 1024; @@ -37,53 +33,122 @@ const MAX_LENGTH_QUERY_CHAIN_REQUEST: usize = 64 * KI; /// 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_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 +// + /// Reads a storage entry from the VM's storage into Wasm memory -pub fn do_read(ctx: &mut Ctx, key_ptr: u32) -> VmResult { - let key = read_region(ctx, key_ptr, MAX_LENGTH_DB_KEY)?; +fn do_read(env: &Environment, key_ptr: u32) -> VmResult { + let key = read_region(&env.memory(), key_ptr, MAX_LENGTH_DB_KEY)?; - let (result, gas_info) = - with_storage_from_context::(ctx, |store| Ok(store.get(&key)))?; - process_gas_info::(ctx, gas_info)?; + let (result, gas_info) = env.with_storage_from_context::<_, _>(|store| Ok(store.get(&key)))?; + process_gas_info::(env, gas_info)?; let value = result?; let out_data = match value { Some(data) => data, None => return Ok(0), }; - write_to_contract::(ctx, &out_data) + write_to_contract::(env, &out_data) } /// Writes a storage entry from Wasm memory into the VM's storage -pub fn do_write( - ctx: &mut Ctx, +fn do_write( + env: &Environment, key_ptr: u32, value_ptr: u32, ) -> VmResult<()> { - if is_storage_readonly::(ctx) { + if env.is_storage_readonly() { return Err(VmError::write_access_denied()); } - let key = read_region(ctx, key_ptr, MAX_LENGTH_DB_KEY)?; - let value = read_region(ctx, value_ptr, MAX_LENGTH_DB_VALUE)?; + let key = read_region(&env.memory(), key_ptr, MAX_LENGTH_DB_KEY)?; + let value = read_region(&env.memory(), value_ptr, MAX_LENGTH_DB_VALUE)?; let (result, gas_info) = - with_storage_from_context::(ctx, |store| Ok(store.set(&key, &value)))?; - process_gas_info::(ctx, gas_info)?; + env.with_storage_from_context::<_, _>(|store| Ok(store.set(&key, &value)))?; + process_gas_info::(env, gas_info)?; result?; Ok(()) } -pub fn do_remove(ctx: &mut Ctx, key_ptr: u32) -> VmResult<()> { - if is_storage_readonly::(ctx) { +fn do_remove(env: &Environment, key_ptr: u32) -> VmResult<()> { + if env.is_storage_readonly() { return Err(VmError::write_access_denied()); } - let key = read_region(ctx, key_ptr, MAX_LENGTH_DB_KEY)?; + let key = read_region(&env.memory(), key_ptr, MAX_LENGTH_DB_KEY)?; let (result, gas_info) = - with_storage_from_context::(ctx, |store| Ok(store.remove(&key)))?; - process_gas_info::(ctx, gas_info)?; + env.with_storage_from_context::<_, _>(|store| Ok(store.remove(&key)))?; + process_gas_info(env, gas_info)?; result?; Ok(()) @@ -91,30 +156,30 @@ pub fn do_remove(ctx: &mut Ctx, key_ptr: u32) -> VmResul pub fn do_canonicalize_address( api: A, - ctx: &mut Ctx, + env: &Environment, source_ptr: u32, destination_ptr: u32, ) -> VmResult { - let source_data = read_region(ctx, source_ptr, MAX_LENGTH_HUMAN_ADDRESS)?; + let source_data = read_region(&env.memory(), source_ptr, MAX_LENGTH_HUMAN_ADDRESS)?; if source_data.is_empty() { - return Ok(write_to_contract::(ctx, b"Input is empty")?); + return Ok(write_to_contract::(env, b"Input is empty")?); } let source_string = match String::from_utf8(source_data) { Ok(s) => s, - Err(_) => return Ok(write_to_contract::(ctx, b"Input is not valid UTF-8")?), + Err(_) => return Ok(write_to_contract::(env, b"Input is not valid UTF-8")?), }; let human: HumanAddr = source_string.into(); let (result, gas_info) = api.canonical_address(&human); - process_gas_info::(ctx, gas_info)?; + process_gas_info::(env, gas_info)?; match result { Ok(canonical) => { - write_region(ctx, destination_ptr, canonical.as_slice())?; + write_region(&env.memory(), destination_ptr, canonical.as_slice())?; Ok(0) } Err(BackendError::UserErr { msg, .. }) => { - Ok(write_to_contract::(ctx, msg.as_bytes())?) + Ok(write_to_contract::(env, msg.as_bytes())?) } Err(err) => Err(VmError::from(err)), } @@ -122,87 +187,89 @@ pub fn do_canonicalize_address( pub fn do_humanize_address( api: A, - ctx: &mut Ctx, + env: &Environment, source_ptr: u32, destination_ptr: u32, ) -> VmResult { - let canonical = Binary(read_region(ctx, source_ptr, MAX_LENGTH_CANONICAL_ADDRESS)?); + let canonical = Binary(read_region( + &env.memory(), + source_ptr, + MAX_LENGTH_CANONICAL_ADDRESS, + )?); let (result, gas_info) = api.human_address(&CanonicalAddr(canonical)); - process_gas_info::(ctx, gas_info)?; + process_gas_info::(env, gas_info)?; match result { Ok(human) => { - write_region(ctx, destination_ptr, human.as_str().as_bytes())?; + write_region(&env.memory(), destination_ptr, human.as_str().as_bytes())?; Ok(0) } Err(BackendError::UserErr { msg, .. }) => { - Ok(write_to_contract::(ctx, msg.as_bytes())?) + Ok(write_to_contract::(env, msg.as_bytes())?) } Err(err) => Err(VmError::from(err)), } } -/// 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 print_debug_message(ctx: &mut Ctx, message_ptr: u32) -> VmResult<()> { - let message_data = read_region(ctx, 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(ctx: &mut Ctx, input: &[u8]) -> VmResult { - let target_ptr = with_func_from_context::(ctx, "allocate", |allocate| { +fn write_to_contract( + env: &Environment, + input: &[u8], +) -> VmResult { + let target_ptr = env.with_func_from_context::<_, u32>("allocate", |allocate| { let out_size = to_u32(input.len())?; - let ptr = allocate.call(out_size)?; + let result = allocate.call(&[out_size.into()])?; + let ptr = ref_to_u32(&result[0])?; if ptr == 0 { return Err(CommunicationError::zero_address().into()); } Ok(ptr) })?; - write_region(ctx, target_ptr, input)?; + write_region(&env.memory(), target_ptr, input)?; Ok(target_ptr) } -pub fn do_query_chain(ctx: &mut Ctx, request_ptr: u32) -> VmResult { - let request = read_region(ctx, request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; +fn do_query_chain( + env: &Environment, + request_ptr: u32, +) -> VmResult { + let request = read_region(&env.memory(), request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; - let gas_remaining = get_gas_left(ctx); - let (result, gas_info) = with_querier_from_context::(ctx, |querier| { + let gas_remaining = get_gas_left(env); + let (result, gas_info) = env.with_querier_from_context::<_, _>(|querier| { Ok(querier.query_raw(&request, gas_remaining)) })?; - process_gas_info::(ctx, gas_info)?; + process_gas_info::(env, gas_info)?; let serialized = to_vec(&result?)?; - write_to_contract::(ctx, &serialized) + write_to_contract::(env, &serialized) } #[cfg(feature = "iterator")] -pub fn do_scan( - ctx: &mut Ctx, +fn do_scan( + env: &Environment, start_ptr: u32, end_ptr: u32, order: i32, ) -> VmResult { - let start = maybe_read_region(ctx, start_ptr, MAX_LENGTH_DB_KEY)?; - let end = maybe_read_region(ctx, end_ptr, MAX_LENGTH_DB_KEY)?; + let start = maybe_read_region(&env.memory(), start_ptr, MAX_LENGTH_DB_KEY)?; + let end = maybe_read_region(&env.memory(), end_ptr, MAX_LENGTH_DB_KEY)?; let order: Order = order .try_into() .map_err(|_| CommunicationError::invalid_order(order))?; - let (result, gas_info) = with_storage_from_context::(ctx, |store| { + let (result, gas_info) = env.with_storage_from_context::<_, _>(|store| { Ok(store.scan(start.as_deref(), end.as_deref(), order)) })?; - process_gas_info::(ctx, gas_info)?; + process_gas_info::(env, gas_info)?; let iterator_id = result?; Ok(iterator_id) } #[cfg(feature = "iterator")] -pub fn do_next(ctx: &mut Ctx, iterator_id: u32) -> VmResult { +fn do_next(env: &Environment, iterator_id: u32) -> VmResult { let (result, gas_info) = - with_storage_from_context::(ctx, |store| Ok(store.next(iterator_id)))?; - process_gas_info::(ctx, gas_info)?; + env.with_storage_from_context::<_, _>(|store| Ok(store.next(iterator_id)))?; + process_gas_info::(env, gas_info)?; // Empty key will later be treated as _no more element_. let (key, value) = result?.unwrap_or_else(|| (Vec::::new(), Vec::::new())); @@ -214,7 +281,7 @@ pub fn do_next(ctx: &mut Ctx, iterator_id: u32) -> VmRes out_data.extend(key); out_data.extend_from_slice(&keylen_bytes); - write_to_contract::(ctx, &out_data) + write_to_contract::(env, &out_data) } #[cfg(test)] @@ -225,14 +292,13 @@ mod test { SystemError, SystemResult, WasmQuery, }; use std::ptr::NonNull; - use wasmer_runtime_core::{imports, typed_func::Func, Instance as WasmerInstance}; + use wasmer::{imports, Function, FunctionType, Instance as WasmerInstance, Type, Val}; use crate::backend::{BackendError, Storage}; - use crate::backends::compile; - use crate::context::{ - move_into_context, set_storage_readonly, set_wasmer_instance, setup_context, - }; + use crate::environment::move_into_environment; + use crate::size::Size; use crate::testing::{MockApi, MockQuerier, MockStorage}; + use crate::wasm_backend::compile; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); @@ -253,101 +319,112 @@ mod test { const INIT_DENOM: &str = "TOKEN"; const GAS_LIMIT: u64 = 5_000_000; - - fn make_instance() -> Box { - let module = compile(&CONTRACT).unwrap(); + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); + + fn make_instance() -> (Environment, Box) { + let env = Environment::new(GAS_LIMIT, false); + + let module = compile(&CONTRACT, Some(TESTING_MEMORY_LIMIT)).unwrap(); + let store = module.store(); + let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); + let i32_to_i32 = FunctionType::new(vec![Type::I32], vec![Type::I32]); + let i32i32_to_void = FunctionType::new(vec![Type::I32, Type::I32], vec![]); + let i32i32_to_i32 = FunctionType::new(vec![Type::I32, Type::I32], vec![Type::I32]); + let i32i32i32_to_i32 = + FunctionType::new(vec![Type::I32, Type::I32, Type::I32], vec![Type::I32]); // we need stubs for all required imports let import_obj = imports! { - || { setup_context::(GAS_LIMIT) }, "env" => { - "db_read" => Func::new(|_a: u32| -> u32 { 0 }), - "db_write" => Func::new(|_a: u32, _b: u32| {}), - "db_remove" => Func::new(|_a: u32| {}), - "db_scan" => Func::new(|_a: u32, _b: u32, _c: i32| -> u32 { 0 }), - "db_next" => Func::new(|_a: u32| -> u32 { 0 }), - "query_chain" => Func::new(|_a: u32| -> u32 { 0 }), - "canonicalize_address" => Func::new(|_a: i32, _b: i32| -> u32 { 0 }), - "humanize_address" => Func::new(|_a: i32, _b: i32| -> u32 { 0 }), - "debug" => Func::new(|_a: u32| {}), + "db_read" => Function::new(store, &i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "db_write" => Function::new(store, &i32i32_to_void, |_args: &[Val]| { Ok(vec![]) }), + "db_remove" => Function::new(store, &i32_to_void, |_args: &[Val]| { Ok(vec![]) }), + "db_scan" => Function::new(store, &i32i32i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "db_next" => Function::new(store, &i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "query_chain" => Function::new(store, &i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "canonicalize_address" => Function::new(store, &i32i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "humanize_address" => Function::new(store, &i32i32_to_i32, |_args: &[Val]| { Ok(vec![Val::I32(0)]) }), + "debug" => Function::new(store, &i32_to_void, |_args: &[Val]| { Ok(vec![]) }), }, }; - let mut instance = Box::from(module.instantiate(&import_obj).unwrap()); + let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); - set_wasmer_instance::(instance.context_mut(), Some(instance_ptr)); - set_storage_readonly::(instance.context_mut(), false); + env.set_wasmer_instance(Some(instance_ptr)); + env.set_storage_readonly(false); - instance + (env, instance) } - fn leave_default_data(ctx: &mut Ctx) { + fn leave_default_data(env: &Environment) { // create some mock data let mut storage = MockStorage::new(); storage.set(KEY1, VALUE1).0.expect("error setting"); storage.set(KEY2, VALUE2).0.expect("error setting"); let querier: MockQuerier = MockQuerier::new(&[(&HumanAddr::from(INIT_ADDR), &coins(INIT_AMOUNT, INIT_DENOM))]); - move_into_context(ctx, storage, querier); + move_into_environment(env, storage, querier); } - fn write_data(wasmer_instance: &mut WasmerInstance, data: &[u8]) -> u32 { - let allocate: Func = wasmer_instance - .exports - .get("allocate") - .expect("error getting function"); - let region_ptr = allocate - .call(data.len() as u32) - .expect("error calling allocate"); - write_region(wasmer_instance.context_mut(), region_ptr, data).expect("error writing"); + fn write_data(env: &Environment, data: &[u8]) -> u32 { + let region_ptr = env + .with_func_from_context::<_, _>("allocate", |alloc_func| { + let result = alloc_func + .call(&[(data.len() as u32).into()]) + .expect("error calling allocate"); + let ptr = ref_to_u32(&result[0])?; + Ok(ptr) + }) + .unwrap(); + write_region(&env.memory(), region_ptr, data).expect("error writing"); region_ptr } fn create_empty(wasmer_instance: &mut WasmerInstance, capacity: u32) -> u32 { - let allocate: Func = wasmer_instance + let allocate = wasmer_instance .exports - .get("allocate") + .get_function("allocate") .expect("error getting function"); - let region_ptr = allocate.call(capacity).expect("error calling allocate"); + let result = allocate + .call(&[capacity.into()]) + .expect("error calling allocate"); + let region_ptr = ref_to_u32(&result[0]).expect("error converting result"); region_ptr } /// A Region reader that is just good enough for the tests in this file - fn force_read(ctx: &mut Ctx, region_ptr: u32) -> Vec { - read_region(ctx, region_ptr, 5000).unwrap() + fn force_read(env: &Environment, region_ptr: u32) -> Vec { + read_region(&env.memory(), region_ptr, 5000).unwrap() } #[test] fn do_read_works() { - let mut instance = make_instance(); - leave_default_data(instance.context_mut()); + let (env, _instance) = make_instance(); + leave_default_data(&env); - let key_ptr = write_data(&mut instance, KEY1); - let ctx = instance.context_mut(); - let result = do_read::(ctx, key_ptr); + let key_ptr = write_data(&env, KEY1); + let result = do_read::(&env, key_ptr); let value_ptr = result.unwrap(); assert!(value_ptr > 0); - assert_eq!(force_read(ctx, value_ptr as u32), VALUE1); + assert_eq!(force_read(&env, value_ptr as u32), VALUE1); } #[test] fn do_read_works_for_non_existent_key() { - let mut instance = make_instance(); - leave_default_data(instance.context_mut()); + let (env, _instance) = make_instance(); + leave_default_data(&env); - let key_ptr = write_data(&mut instance, b"I do not exist in storage"); - let ctx = instance.context_mut(); - let result = do_read::(ctx, key_ptr); + let key_ptr = write_data(&env, b"I do not exist in storage"); + let result = do_read::(&env, key_ptr); assert_eq!(result.unwrap(), 0); } #[test] fn do_read_fails_for_large_key() { - let mut instance = make_instance(); - leave_default_data(instance.context_mut()); + let (env, _instance) = make_instance(); + leave_default_data(&env); - let key_ptr = write_data(&mut instance, &vec![7u8; 300 * 1024]); - let ctx = instance.context_mut(); - let result = do_read::(ctx, key_ptr); + let key_ptr = write_data(&env, &vec![7u8; 300 * 1024]); + let result = do_read::(&env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionLengthTooBig { length, .. }, @@ -358,78 +435,77 @@ mod test { #[test] fn do_write_works() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let key_ptr = write_data(&mut instance, b"new storage key"); - let value_ptr = write_data(&mut instance, b"new value"); + let key_ptr = write_data(&env, b"new storage key"); + let value_ptr = write_data(&env, b"new value"); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - do_write::(ctx, key_ptr, value_ptr).unwrap(); + do_write::(&env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(ctx, |store| { - Ok(store - .get(b"new storage key") - .0 - .expect("error getting value")) - }) - .unwrap(); + let val = env + .with_storage_from_context::<_, _>(|store| { + Ok(store + .get(b"new storage key") + .0 + .expect("error getting value")) + }) + .unwrap(); assert_eq!(val, Some(b"new value".to_vec())); } #[test] fn do_write_can_override() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let key_ptr = write_data(&mut instance, KEY1); - let value_ptr = write_data(&mut instance, VALUE2); + let key_ptr = write_data(&env, KEY1); + let value_ptr = write_data(&env, VALUE2); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - do_write::(ctx, key_ptr, value_ptr).unwrap(); + do_write::(&env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(ctx, |store| { - Ok(store.get(KEY1).0.expect("error getting value")) - }) - .unwrap(); + let val = env + .with_storage_from_context::<_, _>(|store| { + Ok(store.get(KEY1).0.expect("error getting value")) + }) + .unwrap(); assert_eq!(val, Some(VALUE2.to_vec())); } #[test] fn do_write_works_for_empty_value() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let key_ptr = write_data(&mut instance, b"new storage key"); - let value_ptr = write_data(&mut instance, b""); + let key_ptr = write_data(&env, b"new storage key"); + let value_ptr = write_data(&env, b""); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - do_write::(ctx, key_ptr, value_ptr).unwrap(); + do_write::(&env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(ctx, |store| { - Ok(store - .get(b"new storage key") - .0 - .expect("error getting value")) - }) - .unwrap(); + let val = env + .with_storage_from_context::<_, _>(|store| { + Ok(store + .get(b"new storage key") + .0 + .expect("error getting value")) + }) + .unwrap(); assert_eq!(val, Some(b"".to_vec())); } #[test] fn do_write_fails_for_large_key() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let key_ptr = write_data(&mut instance, &vec![4u8; 300 * 1024]); - let value_ptr = write_data(&mut instance, b"new value"); + let key_ptr = write_data(&env, &vec![4u8; 300 * 1024]); + let value_ptr = write_data(&env, b"new value"); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let result = do_write::(ctx, key_ptr, value_ptr); + let result = do_write::(&env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -446,15 +522,14 @@ mod test { #[test] fn do_write_fails_for_large_value() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let key_ptr = write_data(&mut instance, b"new storage key"); - let value_ptr = write_data(&mut instance, &vec![5u8; 300 * 1024]); + let key_ptr = write_data(&env, b"new storage key"); + let value_ptr = write_data(&env, &vec![5u8; 300 * 1024]); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let result = do_write::(ctx, key_ptr, value_ptr); + let result = do_write::(&env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -471,16 +546,15 @@ mod test { #[test] fn do_write_is_prohibited_in_readonly_contexts() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let key_ptr = write_data(&mut instance, b"new storage key"); - let value_ptr = write_data(&mut instance, b"new value"); + let key_ptr = write_data(&env, b"new storage key"); + let value_ptr = write_data(&env, b"new value"); - let ctx = instance.context_mut(); - leave_default_data(ctx); - set_storage_readonly::(ctx, true); + leave_default_data(&env); + env.set_storage_readonly(true); - let result = do_write::(ctx, key_ptr, value_ptr); + let result = do_write::(&env, key_ptr, value_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -489,53 +563,64 @@ mod test { #[test] fn do_remove_works() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); let existing_key = KEY1; - let key_ptr = write_data(&mut instance, existing_key); + let key_ptr = write_data(&env, existing_key); + + leave_default_data(&env); - let ctx = instance.context_mut(); - leave_default_data(ctx); + env.with_storage_from_context::<_, _>(|store| { + println!("{:?}", store); + Ok(()) + }) + .unwrap(); - do_remove::(ctx, key_ptr).unwrap(); + do_remove::(&env, key_ptr).unwrap(); - let value = with_storage_from_context::(ctx, |store| { - Ok(store.get(existing_key).0.expect("error getting value")) + env.with_storage_from_context::<_, _>(|store| { + println!("{:?}", store); + Ok(()) }) .unwrap(); + + let value = env + .with_storage_from_context::<_, _>(|store| { + Ok(store.get(existing_key).0.expect("error getting value")) + }) + .unwrap(); assert_eq!(value, None); } #[test] fn do_remove_works_for_non_existent_key() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); let non_existent_key = b"I do not exist"; - let key_ptr = write_data(&mut instance, non_existent_key); + let key_ptr = write_data(&env, non_existent_key); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); // Note: right now we cannot differnetiate between an existent and a non-existent key - do_remove::(ctx, key_ptr).unwrap(); + do_remove::(&env, key_ptr).unwrap(); - let value = with_storage_from_context::(ctx, |store| { - Ok(store.get(non_existent_key).0.expect("error getting value")) - }) - .unwrap(); + let value = env + .with_storage_from_context::<_, _>(|store| { + Ok(store.get(non_existent_key).0.expect("error getting value")) + }) + .unwrap(); assert_eq!(value, None); } #[test] fn do_remove_fails_for_large_key() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let key_ptr = write_data(&mut instance, &vec![26u8; 300 * 1024]); + let key_ptr = write_data(&env, &vec![26u8; 300 * 1024]); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let result = do_remove::(ctx, key_ptr); + let result = do_remove::(&env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -552,15 +637,14 @@ mod test { #[test] fn do_remove_is_prohibited_in_readonly_contexts() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let key_ptr = write_data(&mut instance, b"a storage key"); + let key_ptr = write_data(&env, b"a storage key"); - let ctx = instance.context_mut(); - leave_default_data(ctx); - set_storage_readonly::(ctx, true); + leave_default_data(&env); + env.set_storage_readonly(true); - let result = do_remove::(ctx, key_ptr); + let result = do_remove::(&env, key_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -569,61 +653,59 @@ mod test { #[test] fn do_canonicalize_address_works() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); let api = MockApi::default(); - let source_ptr = write_data(&mut instance, b"foo"); + let source_ptr = write_data(&env, b"foo"); let dest_ptr = create_empty(&mut instance, api.canonical_length as u32); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - do_canonicalize_address::(api, ctx, source_ptr, dest_ptr).unwrap(); - let data = force_read(ctx, dest_ptr); + let api = MockApi::default(); + do_canonicalize_address::(api, &env, source_ptr, dest_ptr).unwrap(); + let data = force_read(&env, dest_ptr); assert_eq!(data.len(), api.canonical_length); } #[test] fn do_canonicalize_address_reports_invalid_input_back_to_contract() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); - let source_ptr1 = write_data(&mut instance, b"fo\x80o"); // invalid UTF-8 (fo�o) - let source_ptr2 = write_data(&mut instance, b""); // empty - let source_ptr3 = write_data(&mut instance, b"addressexceedingaddressspace"); // too long + 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"addressexceedingaddressspace"); // too long let dest_ptr = create_empty(&mut instance, 8); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); let api = MockApi::default(); - let res = do_canonicalize_address::(api, ctx, source_ptr1, dest_ptr).unwrap(); + let res = do_canonicalize_address::(api, &env, source_ptr1, dest_ptr).unwrap(); assert_ne!(res, 0); - let err = String::from_utf8(force_read(ctx, res)).unwrap(); + let err = String::from_utf8(force_read(&env, res)).unwrap(); assert_eq!(err, "Input is not valid UTF-8"); - let res = do_canonicalize_address::(api, ctx, source_ptr2, dest_ptr).unwrap(); + let res = do_canonicalize_address::(api, &env, source_ptr2, dest_ptr).unwrap(); assert_ne!(res, 0); - let err = String::from_utf8(force_read(ctx, res)).unwrap(); + let err = String::from_utf8(force_read(&env, res)).unwrap(); assert_eq!(err, "Input is empty"); - let res = do_canonicalize_address::(api, ctx, source_ptr3, dest_ptr).unwrap(); + let res = do_canonicalize_address::(api, &env, source_ptr3, dest_ptr).unwrap(); assert_ne!(res, 0); - let err = String::from_utf8(force_read(ctx, res)).unwrap(); + let err = String::from_utf8(force_read(&env, res)).unwrap(); assert_eq!(err, "Invalid input: human address too long"); } #[test] fn do_canonicalize_address_fails_for_broken_backend() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); - let source_ptr = write_data(&mut instance, b"foo"); + let source_ptr = write_data(&env, b"foo"); let dest_ptr = create_empty(&mut instance, 7); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); let api = MockApi::new_failing("Temporarily unavailable"); - let result = do_canonicalize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::BackendErr { source: BackendError::Unknown { msg, .. }, @@ -636,16 +718,15 @@ mod test { #[test] fn do_canonicalize_address_fails_for_large_inputs() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); - let source_ptr = write_data(&mut instance, &vec![61; 100]); + let source_ptr = write_data(&env, &vec![61; 100]); let dest_ptr = create_empty(&mut instance, 8); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); let api = MockApi::default(); - let result = do_canonicalize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -662,16 +743,15 @@ mod test { #[test] fn do_canonicalize_address_fails_for_small_destination_region() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); - let source_ptr = write_data(&mut instance, b"foo"); + let source_ptr = write_data(&env, b"foo"); let dest_ptr = create_empty(&mut instance, 7); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); let api = MockApi::default(); - let result = do_canonicalize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionTooSmall { size, required, .. }, @@ -685,50 +765,48 @@ mod test { #[test] fn do_humanize_address_works() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); let api = MockApi::default(); let source_data = vec![0x22; api.canonical_length]; - let source_ptr = write_data(&mut instance, &source_data); + let source_ptr = write_data(&env, &source_data); let dest_ptr = create_empty(&mut instance, 50); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let error_ptr = do_humanize_address::(api, ctx, source_ptr, dest_ptr).unwrap(); + let api = MockApi::default(); + let error_ptr = do_humanize_address::(api, &env, source_ptr, dest_ptr).unwrap(); assert_eq!(error_ptr, 0); - assert_eq!(force_read(ctx, dest_ptr), source_data); + assert_eq!(force_read(&env, dest_ptr), source_data); } #[test] fn do_humanize_address_reports_invalid_input_back_to_contract() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); - let source_ptr = write_data(&mut instance, b"foo"); // too short + let source_ptr = write_data(&env, b"foo"); // too short let dest_ptr = create_empty(&mut instance, 50); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); let api = MockApi::default(); - let res = do_humanize_address::(api, ctx, source_ptr, dest_ptr).unwrap(); + let res = do_humanize_address::(api, &env, source_ptr, dest_ptr).unwrap(); assert_ne!(res, 0); - let err = String::from_utf8(force_read(ctx, res)).unwrap(); + let err = String::from_utf8(force_read(&env, res)).unwrap(); assert_eq!(err, "Invalid input: canonical address length not correct"); } #[test] fn do_humanize_address_fails_for_broken_backend() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); - let source_ptr = write_data(&mut instance, b"foo\0\0\0\0\0"); + let source_ptr = write_data(&env, b"foo\0\0\0\0\0"); let dest_ptr = create_empty(&mut instance, 50); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); let api = MockApi::new_failing("Temporarily unavailable"); - let result = do_humanize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::BackendErr { source: BackendError::Unknown { msg, .. }, @@ -739,16 +817,15 @@ mod test { #[test] fn do_humanize_address_fails_for_input_too_long() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); - let source_ptr = write_data(&mut instance, &vec![61; 33]); + let source_ptr = write_data(&env, &vec![61; 33]); let dest_ptr = create_empty(&mut instance, 50); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); let api = MockApi::default(); - let result = do_humanize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -765,17 +842,17 @@ mod test { #[test] fn do_humanize_address_fails_for_destination_region_too_small() { - let mut instance = make_instance(); + let (env, mut instance) = make_instance(); let api = MockApi::default(); let source_data = vec![0x22; api.canonical_length]; - let source_ptr = write_data(&mut instance, &source_data); + let source_ptr = write_data(&env, &source_data); let dest_ptr = create_empty(&mut instance, 2); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let result = do_humanize_address::(api, ctx, source_ptr, dest_ptr); + let api = MockApi::default(); + let result = do_humanize_address::(api, &env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionTooSmall { size, required, .. }, @@ -789,19 +866,18 @@ mod test { #[test] fn do_query_chain_works() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); let request: QueryRequest = QueryRequest::Bank(BankQuery::AllBalances { address: HumanAddr::from(INIT_ADDR), }); let request_data = cosmwasm_std::to_vec(&request).unwrap(); - let request_ptr = write_data(&mut instance, &request_data); + let request_ptr = write_data(&env, &request_data); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let response_ptr = do_query_chain::(ctx, request_ptr).unwrap(); - let response = force_read(ctx, response_ptr); + let response_ptr = do_query_chain::(&env, request_ptr).unwrap(); + let response = force_read(&env, response_ptr); let query_result: cosmwasm_std::QuerierResult = cosmwasm_std::from_slice(&response).unwrap(); @@ -813,16 +889,15 @@ mod test { #[test] fn do_query_chain_fails_for_broken_request() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); let request = b"Not valid JSON for sure"; - let request_ptr = write_data(&mut instance, request); + let request_ptr = write_data(&env, request); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let response_ptr = do_query_chain::(ctx, request_ptr).unwrap(); - let response = force_read(ctx, response_ptr); + let response_ptr = do_query_chain::(&env, request_ptr).unwrap(); + let response = force_read(&env, response_ptr); let query_result: cosmwasm_std::QuerierResult = cosmwasm_std::from_slice(&response).unwrap(); @@ -837,20 +912,19 @@ mod test { #[test] fn do_query_chain_fails_for_missing_contract() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); let request: QueryRequest = QueryRequest::Wasm(WasmQuery::Smart { contract_addr: HumanAddr::from("non-existent"), msg: Binary::from(b"{}" as &[u8]), }); let request_data = cosmwasm_std::to_vec(&request).unwrap(); - let request_ptr = write_data(&mut instance, &request_data); + let request_ptr = write_data(&env, &request_data); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let response_ptr = do_query_chain::(ctx, request_ptr).unwrap(); - let response = force_read(ctx, response_ptr); + let response_ptr = do_query_chain::(&env, request_ptr).unwrap(); + let response = force_read(&env, response_ptr); let query_result: cosmwasm_std::QuerierResult = cosmwasm_std::from_slice(&response).unwrap(); @@ -866,121 +940,129 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_works() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); + let (env, _instance) = make_instance(); + leave_default_data(&env); // set up iterator over all space - let id = do_scan::(ctx, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan::(&env, 0, 0, Order::Ascending.into()).unwrap(); assert_eq!(1, id); - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) + .unwrap(); assert!(item.0.unwrap().is_none()); } #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_descending_works() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); + let (env, _instance) = make_instance(); + leave_default_data(&env); // set up iterator over all space - let id = do_scan::(ctx, 0, 0, Order::Descending.into()).unwrap(); + let id = do_scan::(&env, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(1, id); - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) + .unwrap(); assert!(item.0.unwrap().is_none()); } #[test] #[cfg(feature = "iterator")] fn do_scan_bound_works() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let start = write_data(&mut instance, b"anna"); - let end = write_data(&mut instance, b"bert"); + let start = write_data(&env, b"anna"); + let end = write_data(&env, b"bert"); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let id = do_scan::(ctx, start, end, Order::Ascending.into()).unwrap(); + let id = do_scan::(&env, start, end, Order::Ascending.into()).unwrap(); - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) + .unwrap(); assert!(item.0.unwrap().is_none()); } #[test] #[cfg(feature = "iterator")] fn do_scan_multiple_iterators() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); + let (env, _instance) = make_instance(); + leave_default_data(&env); // unbounded, ascending and descending - let id1 = do_scan::(ctx, 0, 0, Order::Ascending.into()).unwrap(); - let id2 = do_scan::(ctx, 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); // first item, first iterator - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id1))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id1))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); // second item, first iterator - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id1))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id1))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); // first item, second iterator - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id2))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id2))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); // end, first iterator - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id1))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id1))) + .unwrap(); assert!(item.0.unwrap().is_none()); // second item, second iterator - let item = - with_storage_from_context::(ctx, |store| Ok(store.next(id2))).unwrap(); + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id2))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); } #[test] #[cfg(feature = "iterator")] fn do_scan_errors_for_invalid_order_value() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); + let (env, _instance) = make_instance(); + leave_default_data(&env); // set up iterator over all space - let result = do_scan::(ctx, 0, 0, 42); + let result = do_scan::(&env, 0, 0, 42); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::InvalidOrder { .. }, @@ -992,43 +1074,41 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_next_works() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); - let id = do_scan::(ctx, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan::(&env, 0, 0, Order::Ascending.into()).unwrap(); // Entry 1 - let kv_region_ptr = do_next::(ctx, id).unwrap(); + let kv_region_ptr = do_next::(&env, id).unwrap(); assert_eq!( - force_read(ctx, kv_region_ptr), + force_read(&env, kv_region_ptr), [VALUE1, KEY1, b"\0\0\0\x03"].concat() ); // Entry 2 - let kv_region_ptr = do_next::(ctx, id).unwrap(); + let kv_region_ptr = do_next::(&env, id).unwrap(); assert_eq!( - force_read(ctx, kv_region_ptr), + force_read(&env, kv_region_ptr), [VALUE2, KEY2, b"\0\0\0\x04"].concat() ); // End - let kv_region_ptr = do_next::(ctx, id).unwrap(); - assert_eq!(force_read(ctx, kv_region_ptr), b"\0\0\0\0"); + let kv_region_ptr = do_next::(&env, id).unwrap(); + assert_eq!(force_read(&env, kv_region_ptr), b"\0\0\0\0"); // API makes no guarantees for value_ptr in this case } #[test] #[cfg(feature = "iterator")] fn do_next_fails_for_non_existent_id() { - let mut instance = make_instance(); + let (env, _instance) = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&env); let non_existent_id = 42u32; - let result = do_next::(ctx, 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 594398be77..5e3800457f 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -2,33 +2,24 @@ use std::collections::HashSet; use std::marker::PhantomData; use std::ptr::NonNull; -pub use wasmer_runtime_core::typed_func::Func; -use wasmer_runtime_core::{ - imports, - module::Module, - typed_func::{Wasm, WasmTypeList}, - vm::Ctx, - Instance as WasmerInstance, +use wasmer::{ + Exports, Function, FunctionType, ImportObject, Instance as WasmerInstance, Module, Type, Val, }; use crate::backend::{Api, Backend, Querier, Storage}; -use crate::backends::{compile, get_gas_left, set_gas_left}; -use crate::context::{ - get_gas_state, get_gas_state_mut, move_into_context, move_out_of_context, set_storage_readonly, - set_wasmer_instance, setup_context, with_querier_from_context, with_storage_from_context, -}; -use crate::conversion::to_u32; +use crate::conversion::{ref_to_u32, to_u32}; +use crate::environment::{move_into_environment, move_out_of_environment, Environment}; use crate::errors::{CommunicationError, VmError, VmResult}; use crate::features::required_features_from_wasmer_instance; use crate::imports::{ - do_canonicalize_address, do_humanize_address, do_query_chain, do_read, do_remove, do_write, - print_debug_message, + do_canonicalize_address, do_humanize_address, native_db_read, native_db_remove, + native_db_write, native_debug, native_query_chain, }; #[cfg(feature = "iterator")] -use crate::imports::{do_next, do_scan}; -use crate::memory::{get_memory_info, read_region, write_region}; - -const WASM_PAGE_SIZE: u64 = 64 * 1024; +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, get_gas_left, set_gas_left}; #[derive(Copy, Clone, Debug)] pub struct GasReport { @@ -46,6 +37,8 @@ pub struct GasReport { #[derive(Copy, Clone, Debug)] pub struct InstanceOptions { pub gas_limit: u64, + /// Memory limit in bytes. Use a value that is divisible by the Wasm page size 65536, e.g. full MiBs. + pub memory_limit: Size, pub print_debug: bool, } @@ -54,6 +47,7 @@ pub struct Instance { /// lifetime of the instance in the cache. This is needed e.g. when linking the wasmer /// instance to a context. See also https://github.com/CosmWasm/cosmwasm/pull/245 inner: Box, + env: Environment, pub api: A, pub required_features: HashSet, // This does not store data but only fixes type information @@ -63,9 +57,9 @@ pub struct Instance { impl Instance where - S: Storage, - A: Api + 'static, // 'static is needed here to allow copying API instances into closures - Q: Querier, + S: Storage + 'static, // 'static is needed here to allow using this in an Environment that is cloned into closures + A: Api + 'static, // 'static is needed here to allow copying API instances into closures + Q: Querier + 'static, // 'static is needed here to allow using this in an Environment that is cloned into closures { /// This is the only Instance constructor that can be called from outside of cosmwasm-vm, /// e.g. in test code that needs a customized variant of cosmwasm_vm::testing::mock_instance*. @@ -74,7 +68,7 @@ where backend: Backend, options: InstanceOptions, ) -> VmResult { - let module = compile(code)?; + let module = compile(code, Some(options.memory_limit))?; Instance::from_module(&module, backend, options.gas_limit, options.print_debug) } @@ -84,102 +78,128 @@ where gas_limit: u64, print_debug: bool, ) -> VmResult { - let mut import_obj = - imports! { move || { setup_context::(gas_limit) }, "env" => {}, }; - // copy this so it can be moved into the closures, without pulling in deps let api = backend.api; - import_obj.extend(imports! { - "env" => { - // Reads the database entry at the given key into the the value. - // Returns 0 if key does not exist and pointer to result region otherwise. - // Ownership of the key pointer is not transferred to the host. - // Ownership of the value pointer is transferred to the contract. - "db_read" => Func::new(move |ctx: &mut Ctx, key_ptr: u32| -> VmResult { - do_read::(ctx, key_ptr) - }), - // 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. - "db_write" => Func::new(move |ctx: &mut Ctx, key_ptr: u32, value_ptr: u32| -> VmResult<()> { - do_write::(ctx, key_ptr, value_ptr) - }), - // Removes the value at the given key. Different than writing &[] as future - // scans will not find this key. - // At the moment it is not possible to differentiate between a key that existed before and one that did not exist (https://github.com/CosmWasm/cosmwasm/issues/290). - // Ownership of both key pointer is not transferred to the host. - "db_remove" => Func::new(move |ctx: &mut Ctx, key_ptr: u32| -> VmResult<()> { - do_remove::(ctx, key_ptr) - }), - // Reads human address from source_ptr and writes canonicalized representation to destination_ptr. - // A prepared and sufficiently large memory Region is expected at destination_ptr that points to pre-allocated memory. - // Returns 0 on success. Returns a non-zero memory location to a Region containing an UTF-8 encoded error string for invalid inputs. - // Ownership of both input and output pointer is not transferred to the host. - "canonicalize_address" => Func::new(move |ctx: &mut Ctx, source_ptr: u32, destination_ptr: u32| -> VmResult { - do_canonicalize_address::(api, ctx, source_ptr, destination_ptr) - }), - // Reads canonical address from source_ptr and writes humanized representation to destination_ptr. - // A prepared and sufficiently large memory Region is expected at destination_ptr that points to pre-allocated memory. - // Returns 0 on success. Returns a non-zero memory location to a Region containing an UTF-8 encoded error string for invalid inputs. - // Ownership of both input and output pointer is not transferred to the host. - "humanize_address" => Func::new(move |ctx: &mut Ctx, source_ptr: u32, destination_ptr: u32| -> VmResult { - do_humanize_address::(api, ctx, source_ptr, destination_ptr) - }), - // Allows the contract to emit debug logs that the host can either process or ignore. - // This is never written to chain. - // Takes a pointer argument of a memory region that must contain an UTF-8 encoded string. - // Ownership of both input and output pointer is not transferred to the host. - "debug" => Func::new(move |ctx: &mut Ctx, message_ptr: u32|-> VmResult<()> { - if print_debug { - print_debug_message(ctx, message_ptr)?; - } - Ok(()) - }), - "query_chain" => Func::new(move |ctx: &mut Ctx, request_ptr: u32| -> VmResult { - do_query_chain::(ctx, request_ptr) - }), - }, - }); + let store = module.store(); + + let env = Environment::new(gas_limit, print_debug); + + let i32i32_to_i32 = FunctionType::new(vec![Type::I32, Type::I32], vec![Type::I32]); + + let mut import_obj = ImportObject::new(); + let mut env_imports = Exports::new(); + + // Reads the database entry at the given key into the the value. + // Returns 0 if key does not exist and pointer to result region otherwise. + // Ownership of the key pointer is not transferred to the host. + // Ownership of the value pointer is transferred to the contract. + env_imports.insert( + "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(), native_db_write), + ); + + // Removes the value at the given key. Different than writing &[] as future + // scans will not find this key. + // At the moment it is not possible to differentiate between a key that existed before and one that did not exist (https://github.com/CosmWasm/cosmwasm/issues/290). + // Ownership of both key pointer is not transferred to the host. + env_imports.insert( + "db_remove", + Function::new_native_with_env(store, env.clone(), native_db_remove), + ); + + // Reads human address from source_ptr and writes canonicalized representation to destination_ptr. + // A prepared and sufficiently large memory Region is expected at destination_ptr that points to pre-allocated memory. + // Returns 0 on success. Returns a non-zero memory location to a Region containing an UTF-8 encoded error string for invalid inputs. + // Ownership of both input and output pointer is not transferred to the host. + env_imports.insert( + "canonicalize_address", + Function::new_with_env(store, &i32i32_to_i32, env.clone(), move |env, args| { + let source_ptr = ref_to_u32(&args[0])?; + let destination_ptr = ref_to_u32(&args[1])?; + let ptr = + do_canonicalize_address::(api, &env, source_ptr, destination_ptr)?; + Ok(vec![ptr.into()]) + }), + ); + + // Reads canonical address from source_ptr and writes humanized representation to destination_ptr. + // A prepared and sufficiently large memory Region is expected at destination_ptr that points to pre-allocated memory. + // Returns 0 on success. Returns a non-zero memory location to a Region containing an UTF-8 encoded error string for invalid inputs. + // Ownership of both input and output pointer is not transferred to the host. + env_imports.insert( + "humanize_address", + Function::new_with_env(store, &i32i32_to_i32, env.clone(), move |env, args| { + let source_ptr = ref_to_u32(&args[0])?; + let destination_ptr = ref_to_u32(&args[1])?; + let ptr = do_humanize_address::(api, &env, source_ptr, destination_ptr)?; + Ok(vec![ptr.into()]) + }), + ); + + // Allows the contract to emit debug logs that the host can either process or ignore. + // This is never written to chain. + // Takes a pointer argument of a memory region that must contain an UTF-8 encoded string. + // 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(), native_debug), + ); + + env_imports.insert( + "query_chain", + Function::new_native_with_env(store, env.clone(), native_query_chain), + ); + + // Creates an iterator that will go from start to end. + // If start_ptr == 0, the start is unbounded. + // If end_ptr == 0, the end is unbounded. + // Order is defined in cosmwasm_std::Order and may be 1 (ascending) or 2 (descending). All other values result in an error. + // Ownership of both start and end pointer is not transferred to the host. + // Returns an iterator ID. #[cfg(feature = "iterator")] - import_obj.extend(imports! { - "env" => { - // Creates an iterator that will go from start to end. - // If start_ptr == 0, the start is unbounded. - // If end_ptr == 0, the end is unbounded. - // Order is defined in cosmwasm_std::Order and may be 1 (ascending) or 2 (descending). All other values result in an error. - // Ownership of both start and end pointer is not transferred to the host. - // Returns an iterator ID. - "db_scan" => Func::new(move |ctx: &mut Ctx, start_ptr: u32, end_ptr: u32, order: i32| -> VmResult { - do_scan::(ctx, start_ptr, end_ptr, order) - }), - // Get next element of iterator with ID `iterator_id`. - // Creates a region containing both key and value and returns its address. - // Ownership of the result region is transferred to the contract. - // The KV region uses the format value || key || keylen, where keylen is a fixed size big endian u32 value. - // An empty key (i.e. KV region ends with \0\0\0\0) means no more element, no matter what the value is. - "db_next" => Func::new(move |ctx: &mut Ctx, iterator_id: u32| -> VmResult { - do_next::(ctx, iterator_id) - }), - }, - }); + env_imports.insert( + "db_scan", + Function::new_native_with_env(store, env.clone(), native_db_scan), + ); + + // Get next element of iterator with ID `iterator_id`. + // Creates a region containing both key and value and returns its address. + // Ownership of the result region is transferred to the contract. + // The KV region uses the format value || key || keylen, where keylen is a fixed size big endian u32 value. + // An empty key (i.e. KV region ends with \0\0\0\0) means no more element, no matter what the value is. + #[cfg(feature = "iterator")] + env_imports.insert( + "db_next", + Function::new_native_with_env(store, env.clone(), native_db_next), + ); + + import_obj.register("env", env_imports); - let mut wasmer_instance = - Box::from(module.instantiate(&import_obj).map_err(|original| { + let wasmer_instance = Box::from(WasmerInstance::new(&module, &import_obj).map_err( + |original| { VmError::instantiation_err(format!("Error instantiating module: {:?}", original)) - })?); + }, + )?); - set_gas_left(wasmer_instance.context_mut(), gas_limit); - get_gas_state_mut::(wasmer_instance.context_mut()).set_gas_limit(gas_limit); + set_gas_left(&env, gas_limit); + env.with_gas_state_mut(|gas_state| { + gas_state.set_gas_limit(gas_limit); + }); let required_features = required_features_from_wasmer_instance(wasmer_instance.as_ref()); let instance_ptr = NonNull::from(wasmer_instance.as_ref()); - set_wasmer_instance::(wasmer_instance.context_mut(), Some(instance_ptr)); - move_into_context( - wasmer_instance.context_mut(), - backend.storage, - backend.querier, - ); + env.set_wasmer_instance(Some(instance_ptr)); + move_into_environment(&env, backend.storage, backend.querier); let instance = Instance { inner: wasmer_instance, + env, api: backend.api, required_features, type_storage: PhantomData:: {}, @@ -190,8 +210,8 @@ where /// Decomposes this instance into its components. /// External dependencies are returned for reuse, the rest is dropped. - pub fn recycle(mut self) -> Option> { - if let (Some(storage), Some(querier)) = move_out_of_context(self.inner.context_mut()) { + pub fn recycle(self) -> Option> { + if let (Some(storage), Some(querier)) = move_out_of_environment(&self.env) { Some(Backend { storage, api: self.api, @@ -207,7 +227,7 @@ where /// Wasm memory always grows in 64 KiB steps (pages) and can never shrink /// (https://github.com/WebAssembly/design/issues/1300#issuecomment-573867836). pub fn get_memory_size(&self) -> u64 { - (get_memory_info(self.inner.context()).size as u64) * WASM_PAGE_SIZE + self.env.memory().data_size() } /// Returns the currently remaining gas. @@ -219,8 +239,8 @@ where /// This is a snapshot and multiple reports can be created during the lifetime of /// an instance. pub fn create_gas_report(&self) -> GasReport { - let state = get_gas_state::(self.inner.context()).clone(); - let gas_left = get_gas_left(self.inner.context()); + let state = self.env.with_gas_state(|gas_state| gas_state.clone()); + let gas_left = get_gas_left(&self.env); GasReport { limit: state.gas_limit, remaining: gas_left, @@ -233,22 +253,22 @@ where /// for multiple calls in integration tests, this should be set to the desired value /// right before every call. pub fn set_storage_readonly(&mut self, new_value: bool) { - set_storage_readonly::(self.inner.context_mut(), new_value); + self.env.set_storage_readonly(new_value); } pub fn with_storage VmResult, T>(&mut self, func: F) -> VmResult { - with_storage_from_context::(self.inner.context_mut(), func) + self.env.with_storage_from_context::(func) } pub fn with_querier VmResult, T>(&mut self, func: F) -> VmResult { - with_querier_from_context::(self.inner.context_mut(), func) + self.env.with_querier_from_context::(func) } /// Requests memory allocation by the instance and returns a pointer /// in the Wasm address space to the created Region object. pub(crate) fn allocate(&mut self, size: usize) -> VmResult { - let alloc: Func = self.func("allocate")?; - let ptr = alloc.call(to_u32(size)?)?; + let ret = self.call_function("allocate", &[to_u32(size)?.into()])?; + let ptr = ref_to_u32(&ret.as_ref()[0])?; if ptr == 0 { return Err(CommunicationError::zero_address().into()); } @@ -259,58 +279,54 @@ where // allocated by us, or a pointer from a return value after we copy it into rust. // we need to clean up the wasm-side buffers to avoid memory leaks pub(crate) fn deallocate(&mut self, ptr: u32) -> VmResult<()> { - let dealloc: Func = self.func("deallocate")?; - dealloc.call(ptr)?; + self.call_function("deallocate", &[ptr.into()])?; Ok(()) } /// Copies all data described by the Region at the given pointer from Wasm to the caller. pub(crate) fn read_memory(&self, region_ptr: u32, max_length: usize) -> VmResult> { - read_region(self.inner.context(), region_ptr, max_length) + read_region(&self.env.memory(), region_ptr, max_length) } /// Copies data to the memory region that was created before using allocate. pub(crate) fn write_memory(&mut self, region_ptr: u32, data: &[u8]) -> VmResult<()> { - write_region(self.inner.context(), region_ptr, data)?; + write_region(&self.env.memory(), region_ptr, data)?; Ok(()) } - pub(crate) fn func(&self, name: &str) -> VmResult> - where - Args: WasmTypeList, - Rets: WasmTypeList, - { - let function = self.inner.exports.get(name)?; - Ok(function) + pub(crate) fn call_function(&self, name: &str, args: &[Val]) -> VmResult> { + let function = self.inner.exports.get_function(name)?; + let result = function.call(args)?; + Ok(result) } } #[cfg(test)] -mod test { +mod tests { use super::*; use crate::backend::Storage; - use crate::context::is_storage_readonly; + use crate::call_init; use crate::errors::VmError; + #[cfg(feature = "metering")] + use crate::testing::mock_instance_with_gas_limit; use crate::testing::{ mock_backend, mock_env, mock_info, mock_instance, mock_instance_options, - mock_instance_with_balances, mock_instance_with_failing_api, mock_instance_with_gas_limit, - MockQuerier, MockStorage, + mock_instance_with_balances, mock_instance_with_failing_api, mock_instance_with_options, + MockInstanceOptions, }; - use crate::{call_init, BackendError}; + #[cfg(feature = "metering")] + use cosmwasm_std::coins; use cosmwasm_std::{ - coin, coins, from_binary, AllBalanceResponse, BalanceResponse, BankQuery, Empty, HumanAddr, + coin, from_binary, AllBalanceResponse, BalanceResponse, BankQuery, Empty, HumanAddr, QueryRequest, }; + const WASM_PAGE_SIZE: u64 = 64 * 1024; const KIB: usize = 1024; const MIB: usize = 1024 * 1024; const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); - // shorthands for function generics below - type MS = MockStorage; - type MQ = MockQuerier; - #[test] fn required_features_works() { let backend = mock_backend(&[]); @@ -343,46 +359,38 @@ mod test { } #[test] - fn func_works() { + fn call_func_works() { let instance = mock_instance(&CONTRACT, &[]); - // can get func - let allocate: Func = instance.func("allocate").expect("error getting func"); + // can call function few times + let result = instance + .call_function("allocate", &[0u32.into()]) + .expect("error calling allocate"); + assert_eq!(result.len(), 1); + assert_ne!(result[0].unwrap_i32(), 0); - // can call a few times - let _ptr1 = allocate.call(0).expect("error calling allocate func"); - let _ptr2 = allocate.call(1).expect("error calling allocate func"); - let _ptr3 = allocate.call(33).expect("error calling allocate func"); - } - - #[test] - fn func_errors_for_non_existent_function() { - let instance = mock_instance(&CONTRACT, &[]); - let missing_function = "bar_foo345"; - match instance.func::<(), ()>(missing_function).err().unwrap() { - VmError::ResolveErr { msg, .. } => assert_eq!( - msg, - "Wasmer resolve error: ExportNotFound { name: \"bar_foo345\" }" - ), - e => panic!("unexpected error: {:?}", e), - } - } + let result = instance + .call_function("allocate", &[1u32.into()]) + .expect("error calling allocate"); + assert_eq!(result.len(), 1); + assert_ne!(result[0].unwrap_i32(), 0); - #[test] - fn func_errors_for_wrong_signature() { - let instance = mock_instance(&CONTRACT, &[]); - match instance.func::<(), ()>("allocate").err().unwrap() { - VmError::ResolveErr { msg, .. } => assert_eq!( - msg, - "Wasmer resolve error: Signature { expected: FuncSig { params: [I32], returns: [I32] }, found: [] }" - ), - e => panic!("unexpected error: {:?}", e), - } + let result = instance + .call_function("allocate", &[33u32.into()]) + .expect("error calling allocate"); + assert_eq!(result.len(), 1); + assert_ne!(result[0].unwrap_i32(), 0); } #[test] fn allocate_deallocate_works() { - let mut instance = mock_instance(&CONTRACT, &[]); + let mut instance = mock_instance_with_options( + &CONTRACT, + MockInstanceOptions { + memory_limit: Size::mebi(500), + ..Default::default() + }, + ); let sizes: Vec = vec![ 0, @@ -434,7 +442,7 @@ mod test { } #[test] - fn errors_in_imports_are_unwrapped_from_wasmer_errors() { + 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); @@ -445,13 +453,9 @@ mod test { b"{\"verifier\": \"some1\", \"beneficiary\": \"some2\"}", ); - // in this case we get a `VmError::BackendErr` rather than a `VmError::RuntimeErr` because the conversion - // from wasmer `RuntimeError` to `VmError` unwraps errors that happen in WASM imports. match init_result.unwrap_err() { - VmError::BackendErr { - source: BackendError::Unknown { msg, .. }, - } if msg == Some(error_message.to_string()) => {} - other => panic!("unexpected error: {:?}", other), + VmError::RuntimeErr { msg, .. } => assert!(msg.contains(error_message)), + err => panic!("Unexpected error: {:?}", err), } } @@ -502,52 +506,16 @@ mod test { } #[test] - #[cfg(feature = "default-cranelift")] - fn set_get_and_gas_cranelift() { - let instance = mock_instance_with_gas_limit(&CONTRACT, 123321); - let orig_gas = instance.get_gas_left(); - assert_eq!(orig_gas, 1_000_000); // We expect a dummy value for cranelift - } - - #[test] - #[cfg(feature = "default-singlepass")] - fn set_get_and_gas_singlepass() { + #[cfg(feature = "metering")] + fn set_get_and_gas() { let instance = mock_instance_with_gas_limit(&CONTRACT, 123321); let orig_gas = instance.get_gas_left(); assert_eq!(orig_gas, 123321); } #[test] - #[cfg(feature = "default-cranelift")] - fn create_gas_report_works_cranelift() { - const LIMIT: u64 = 7_000_000; - /// Value hardcoded in cranelift backend - const FAKE_REMANING: u64 = 1_000_000; - let mut instance = mock_instance_with_gas_limit(&CONTRACT, LIMIT); - - let report1 = instance.create_gas_report(); - assert_eq!(report1.used_externally, 0); - assert_eq!(report1.used_internally, LIMIT - FAKE_REMANING); - assert_eq!(report1.limit, LIMIT); - assert_eq!(report1.remaining, FAKE_REMANING); - - // init contract - let info = mock_info("creator", &coins(1000, "earth")); - let msg = r#"{"verifier": "verifies", "beneficiary": "benefits"}"#.as_bytes(); - call_init::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg) - .unwrap() - .unwrap(); - - let report2 = instance.create_gas_report(); - assert_eq!(report2.used_externally, 0); - assert_eq!(report2.used_internally, LIMIT - FAKE_REMANING); - assert_eq!(report2.limit, LIMIT); - assert_eq!(report2.remaining, FAKE_REMANING); - } - - #[test] - #[cfg(feature = "default-singlepass")] - fn create_gas_report_works_singlepass() { + #[cfg(feature = "metering")] + fn create_gas_report_works() { const LIMIT: u64 = 7_000_000; let mut instance = mock_instance_with_gas_limit(&CONTRACT, LIMIT); @@ -578,28 +546,16 @@ mod test { fn set_storage_readonly_works() { let mut instance = mock_instance(&CONTRACT, &[]); - assert_eq!( - is_storage_readonly::(instance.inner.context()), - true - ); + assert_eq!(instance.env.is_storage_readonly(), true); instance.set_storage_readonly(false); - assert_eq!( - is_storage_readonly::(instance.inner.context()), - false - ); + assert_eq!(instance.env.is_storage_readonly(), false); instance.set_storage_readonly(false); - assert_eq!( - is_storage_readonly::(instance.inner.context()), - false - ); + assert_eq!(instance.env.is_storage_readonly(), false); instance.set_storage_readonly(true); - assert_eq!( - is_storage_readonly::(instance.inner.context()), - true - ); + assert_eq!(instance.env.is_storage_readonly(), true); } #[test] @@ -756,8 +712,8 @@ mod test { } #[cfg(test)] -#[cfg(feature = "default-singlepass")] -mod singlepass_test { +#[cfg(feature = "metering")] +mod singlepass_tests { use cosmwasm_std::{coins, Empty}; use crate::calls::{call_handle, call_init, call_query}; diff --git a/packages/vm/src/lib.rs b/packages/vm/src/lib.rs index 42e75d4344..d24affcca3 100644 --- a/packages/vm/src/lib.rs +++ b/packages/vm/src/lib.rs @@ -1,11 +1,10 @@ mod backend; -mod backends; mod cache; mod calls; mod checksum; mod compatibility; -mod context; mod conversion; +mod environment; mod errors; mod features; mod imports; @@ -17,6 +16,7 @@ mod modules; mod serde; mod size; pub mod testing; +mod wasm_backend; pub use crate::backend::{Api, Backend, BackendError, BackendResult, GasInfo, Querier, Storage}; pub use crate::cache::{Cache, CacheOptions, Stats}; diff --git a/packages/vm/src/memory.rs b/packages/vm/src/memory.rs index e8cdf48776..a689497ff1 100644 --- a/packages/vm/src/memory.rs +++ b/packages/vm/src/memory.rs @@ -1,8 +1,4 @@ -use wasmer_runtime_core::{ - memory::ptr::{Array, WasmPtr}, - types::ValueType, - vm::Ctx, -}; +use wasmer::{Array, ValueType, WasmPtr}; use crate::conversion::to_u32; use crate::errors::{ @@ -29,43 +25,11 @@ struct Region { unsafe impl ValueType for Region {} -/// A Wasm memory descriptor -#[derive(Debug, Clone)] -pub struct MemoryDescriptor { - /// The minimum number of allowed pages - pub minimum: u32, - /// The maximum number of allowed pages - pub maximum: Option, - /// This memory can be shared between Wasm threads - pub shared: bool, -} - -#[derive(Debug, Clone)] -pub struct MemoryInfo { - pub descriptor: MemoryDescriptor, - /// Current memory size in pages - pub size: u32, -} - -/// Get information about the default memory `memory(0)` -pub fn get_memory_info(ctx: &Ctx) -> MemoryInfo { - let memory = ctx.memory(0); - let descriptor = memory.descriptor(); - MemoryInfo { - descriptor: MemoryDescriptor { - minimum: descriptor.minimum.0, - maximum: descriptor.maximum.map(|pages| pages.0), - shared: descriptor.shared, - }, - size: memory.size().0, - } -} - /// Expects a (fixed size) Region struct at ptr, which is read. This links to the /// memory region, which is copied in the second step. /// Errors if the length of the region exceeds `max_length`. -pub fn read_region(ctx: &Ctx, ptr: u32, max_length: usize) -> VmResult> { - let region = get_region(ctx, ptr)?; +pub fn read_region(memory: &wasmer::Memory, ptr: u32, max_length: usize) -> VmResult> { + let region = get_region(memory, ptr)?; if region.length > to_u32(max_length)? { return Err( @@ -73,7 +37,6 @@ pub fn read_region(ctx: &Ctx, ptr: u32, max_length: usize) -> VmResult> ); } - let memory = ctx.memory(0); match WasmPtr::::new(region.offset).deref(memory, 0, region.length) { Some(cells) => { // In case you want to do some premature optimization, this shows how to cast a `&'mut [Cell]` to `&mut [u8]`: @@ -96,26 +59,28 @@ pub fn read_region(ctx: &Ctx, ptr: u32, max_length: usize) -> VmResult> /// maybe_read_region is like read_region, but gracefully handles null pointer (0) by returning None /// meant to be used where the argument is optional (like scan) #[cfg(feature = "iterator")] -pub fn maybe_read_region(ctx: &Ctx, ptr: u32, max_length: usize) -> VmResult>> { +pub fn maybe_read_region( + memory: &wasmer::Memory, + ptr: u32, + max_length: usize, +) -> VmResult>> { if ptr == 0 { Ok(None) } else { - read_region(ctx, ptr, max_length).map(Some) + read_region(memory, ptr, max_length).map(Some) } } /// A prepared and sufficiently large memory Region is expected at ptr that points to pre-allocated memory. /// /// Returns number of bytes written on success. -pub fn write_region(ctx: &Ctx, ptr: u32, data: &[u8]) -> VmResult<()> { - let mut region = get_region(ctx, ptr)?; +pub fn write_region(memory: &wasmer::Memory, ptr: u32, data: &[u8]) -> VmResult<()> { + let mut region = get_region(memory, ptr)?; let region_capacity = region.capacity as usize; if data.len() > region_capacity { return Err(CommunicationError::region_too_small(region_capacity, data.len()).into()); } - - let memory = ctx.memory(0); match WasmPtr::::new(region.offset).deref(memory, 0, region.capacity) { Some(cells) => { // In case you want to do some premature optimization, this shows how to cast a `&'mut [Cell]` to `&mut [u8]`: @@ -124,7 +89,7 @@ pub fn write_region(ctx: &Ctx, ptr: u32, data: &[u8]) -> VmResult<()> { cells[i].set(data[i]) } region.length = data.len() as u32; - set_region(ctx, ptr, region)?; + set_region(memory, ptr, region)?; Ok(()) }, None => Err(CommunicationError::deref_err(region.offset, format!( @@ -136,8 +101,7 @@ pub fn write_region(ctx: &Ctx, ptr: u32, data: &[u8]) -> VmResult<()> { } /// Reads in a Region at ptr in wasm memory and returns a copy of it -fn get_region(ctx: &Ctx, ptr: u32) -> CommunicationResult { - let memory = ctx.memory(0); +fn get_region(memory: &wasmer::Memory, ptr: u32) -> CommunicationResult { let wptr = WasmPtr::::new(ptr); match wptr.deref(memory) { Some(cell) => { @@ -174,8 +138,7 @@ fn validate_region(region: &Region) -> RegionValidationResult<()> { } /// Overrides a Region at ptr in wasm memory with data -fn set_region(ctx: &Ctx, ptr: u32, data: Region) -> CommunicationResult<()> { - let memory = ctx.memory(0); +fn set_region(memory: &wasmer::Memory, ptr: u32, data: Region) -> CommunicationResult<()> { let wptr = WasmPtr::::new(ptr); match wptr.deref(memory) { diff --git a/packages/vm/src/middleware/deterministic.rs b/packages/vm/src/middleware/deterministic.rs index 26d8e852ff..809e2a08c0 100644 --- a/packages/vm/src/middleware/deterministic.rs +++ b/packages/vm/src/middleware/deterministic.rs @@ -163,7 +163,7 @@ fn parse_wasm_opcode(opcode: &Operator) -> Result<(), CompileError> { /// Middleware is only supported in singlepass backend, see /// https://github.com/CosmWasm/cosmwasm/issues/311 -#[cfg(all(test, feature = "default-singlepass"))] +#[cfg(test)] mod tests { // No 'use super::*;' here. This is strange and means we are not testing the functions in this module directly. use crate::backends::compile; diff --git a/packages/vm/src/middleware/mod.rs b/packages/vm/src/middleware/mod.rs index 1701973143..88c79ae6c6 100644 --- a/packages/vm/src/middleware/mod.rs +++ b/packages/vm/src/middleware/mod.rs @@ -1,3 +1,3 @@ -mod deterministic; - -pub use deterministic::DeterministicMiddleware; +// mod deterministic; +// +// pub use deterministic::DeterministicMiddleware; diff --git a/packages/vm/src/modules/file_system_cache.rs b/packages/vm/src/modules/file_system_cache.rs index e77a4def10..3a33808df8 100644 --- a/packages/vm/src/modules/file_system_cache.rs +++ b/packages/vm/src/modules/file_system_cache.rs @@ -8,11 +8,21 @@ use std::{ path::PathBuf, }; -use wasmer_runtime_core::{cache::Artifact, module::Module}; +use wasmer::Module; -use crate::backends::{compiler_for_backend, BACKEND_NAME}; use crate::checksum::Checksum; use crate::errors::{VmError, VmResult}; +use crate::size::Size; +use crate::wasm_backend::make_store_headless; + +/// Bump this version whenever the module system changes in a way +/// that old stored modules would be corrupt when loaded in the new system. +/// This needs to be done e.g. when switching between the jit/native engine. +/// +/// The string is used as a folder and should be named in a way that is +/// easy to interprete for system admins. It should allow easy clearing +/// of old versions. +const MODULE_SERIALIZATION_VERSION: &str = "v1"; /// Representation of a directory that contains compiled Wasm artifacts. pub struct FileSystemCache { @@ -58,11 +68,13 @@ impl FileSystemCache { } } - pub fn load(&self, checksum: &Checksum) -> VmResult> { - let backend = BACKEND_NAME; - + pub fn load(&self, checksum: &Checksum, memory_limit: Size) -> VmResult> { let filename = checksum.to_hex(); - let file_path = self.path.clone().join(backend).join(filename); + let file_path = self + .path + .clone() + .join(MODULE_SERIALIZATION_VERSION) + .join(filename); let file = match File::open(file_path) { Ok(file) => file, @@ -80,27 +92,17 @@ impl FileSystemCache { let mmap = unsafe { Mmap::map(&file) } .map_err(|e| VmError::cache_err(format!("Mmap error: {}", e)))?; - let serialized_cache = Artifact::deserialize(&mmap[..])?; - let module = unsafe { - wasmer_runtime_core::load_cache_with( - serialized_cache, - compiler_for_backend(backend) - .ok_or_else(|| VmError::cache_err(format!("Unsupported backend: {}", backend)))? - .as_ref(), - ) - }?; + let store = make_store_headless(Some(memory_limit)); + let module = unsafe { Module::deserialize(&store, &mmap[..]) }?; Ok(Some(module)) } - /// Stores a serialization of the module to the file system pub fn store(&mut self, checksum: &Checksum, module: &Module) -> VmResult<()> { - let backend_str = module.info().backend.to_string(); - let modules_dir = self.path.clone().join(backend_str); + let modules_dir = self.path.clone().join(MODULE_SERIALIZATION_VERSION); fs::create_dir_all(&modules_dir) .map_err(|e| VmError::cache_err(format!("Error creating direcory: {}", e)))?; - let serialized_cache = module.cache()?; - let buffer = serialized_cache.serialize()?; + let buffer = module.serialize()?; let filename = checksum.to_hex(); let mut file = File::create(modules_dir.join(filename)) @@ -115,13 +117,14 @@ impl FileSystemCache { #[cfg(test)] mod tests { use super::*; - use crate::backends::compile; + use crate::wasm_backend::compile; use tempfile::TempDir; + use wasmer::{imports, Instance as WasmerInstance}; + + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); #[test] fn test_file_system_cache_run() { - use wasmer_runtime_core::{imports, typed_func::Func}; - let tmp_dir = TempDir::new().unwrap(); let mut cache = unsafe { FileSystemCache::new(tmp_dir.path()).unwrap() }; @@ -137,29 +140,28 @@ mod tests { ) .unwrap(); let checksum = Checksum::generate(&wasm); - let module = compile(&wasm).unwrap(); + let module = compile(&wasm, Some(TESTING_MEMORY_LIMIT)).unwrap(); // Module does not exist - let cached = cache.load(&checksum).unwrap(); + let cached = cache.load(&checksum, TESTING_MEMORY_LIMIT).unwrap(); assert!(cached.is_none()); // Store module cache.store(&checksum, &module).unwrap(); // Load module - let cached = cache.load(&checksum).unwrap(); + let cached = cache.load(&checksum, TESTING_MEMORY_LIMIT).unwrap(); assert!(cached.is_some()); // Check the returned module is functional. // This is not really testing the cache API but better safe than sorry. { - assert_eq!(module.info().backend.to_string(), BACKEND_NAME.to_string()); let cached_module = cached.unwrap(); let import_object = imports! {}; - let instance = cached_module.instantiate(&import_object).unwrap(); - let add_one: Func = instance.exports.get("add_one").unwrap(); - let value = add_one.call(42).unwrap(); - assert_eq!(value, 43); + let instance = WasmerInstance::new(&cached_module, &import_object).unwrap(); + let add_one = instance.exports.get_function("add_one").unwrap(); + let result = add_one.call(&[42.into()]).unwrap(); + assert_eq!(result[0].unwrap_i32(), 43); } } } diff --git a/packages/vm/src/modules/in_memory_cache.rs b/packages/vm/src/modules/in_memory_cache.rs index e72eb899ac..967f8c4800 100644 --- a/packages/vm/src/modules/in_memory_cache.rs +++ b/packages/vm/src/modules/in_memory_cache.rs @@ -1,5 +1,5 @@ use clru::CLruCache; -use wasmer_runtime_core::module::Module; +use wasmer::Module; use crate::{Checksum, Size, VmResult}; @@ -33,12 +33,13 @@ impl InMemoryCache { #[cfg(test)] mod tests { use super::*; - use crate::backends::{compile, BACKEND_NAME}; + use crate::wasm_backend::compile; + use wasmer::{imports, Instance as WasmerInstance}; + + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); #[test] fn test_in_memory_cache_run() { - use wasmer_runtime_core::{imports, typed_func::Func}; - let mut cache = InMemoryCache::new(Size::mebi(200)); // Create module @@ -53,7 +54,7 @@ mod tests { ) .unwrap(); let checksum = Checksum::generate(&wasm); - let module = compile(&wasm).unwrap(); + let module = compile(&wasm, Some(TESTING_MEMORY_LIMIT)).unwrap(); // Module does not exist let cached = cache.load(&checksum).unwrap(); @@ -69,13 +70,12 @@ mod tests { // Check the returned module is functional. // This is not really testing the cache API but better safe than sorry. { - assert_eq!(module.info().backend.to_string(), BACKEND_NAME.to_string()); let cached_module = cached.unwrap(); let import_object = imports! {}; - let instance = cached_module.instantiate(&import_object).unwrap(); - let add_one: Func = instance.exports.get("add_one").unwrap(); - let value = add_one.call(42).unwrap(); - assert_eq!(value, 43); + let instance = WasmerInstance::new(&cached_module, &import_object).unwrap(); + let add_one = instance.exports.get_function("add_one").unwrap(); + let result = add_one.call(&[42.into()]).unwrap(); + assert_eq!(result[0].unwrap_i32(), 43); } } } diff --git a/packages/vm/src/testing/instance.rs b/packages/vm/src/testing/instance.rs index 7798bf9db6..3fab880d1c 100644 --- a/packages/vm/src/testing/instance.rs +++ b/packages/vm/src/testing/instance.rs @@ -7,6 +7,7 @@ use std::collections::HashSet; use crate::compatibility::check_wasm; use crate::features::features_from_csv; use crate::instance::{Instance, InstanceOptions}; +use crate::size::Size; use crate::{Api, Backend, Querier, Storage}; use super::mock::{MockApi, MOCK_CONTRACT_ADDR}; @@ -14,6 +15,7 @@ use super::querier::MockQuerier; use super::storage::MockStorage; const DEFAULT_GAS_LIMIT: u64 = 500_000; +const DEFAULT_MEMORY_LIMIT: Size = Size::mebi(16); const DEFAULT_PRINT_DEBUG: bool = true; pub fn mock_instance( @@ -83,6 +85,8 @@ pub struct MockInstanceOptions<'a> { pub supported_features: HashSet, pub gas_limit: u64, pub print_debug: bool, + /// Memory limit in bytes. Use a value that is divisible by the Wasm page size 65536, e.g. full MiBs. + pub memory_limit: Size, } impl Default for MockInstanceOptions<'_> { @@ -97,6 +101,7 @@ impl Default for MockInstanceOptions<'_> { supported_features: features_from_csv("staking"), gas_limit: DEFAULT_GAS_LIMIT, print_debug: DEFAULT_PRINT_DEBUG, + memory_limit: DEFAULT_MEMORY_LIMIT, } } } @@ -131,6 +136,7 @@ pub fn mock_instance_with_options( }; let options = InstanceOptions { gas_limit: options.gas_limit, + memory_limit: options.memory_limit, print_debug: options.print_debug, }; Instance::from_code(wasm, backend, options).unwrap() @@ -140,13 +146,16 @@ pub fn mock_instance_with_options( pub fn mock_instance_options() -> InstanceOptions { InstanceOptions { gas_limit: DEFAULT_GAS_LIMIT, + memory_limit: DEFAULT_MEMORY_LIMIT, print_debug: DEFAULT_PRINT_DEBUG, } } /// Runs a series of IO tests, hammering especially on allocate and deallocate. /// This could be especially useful when run with some kind of leak detector. -pub fn test_io(instance: &mut Instance) { +pub fn test_io( + instance: &mut Instance, +) { let sizes: Vec = vec![0, 1, 3, 10, 200, 2000, 5 * 1024]; let bytes: Vec = vec![0x00, 0xA5, 0xFF]; diff --git a/packages/vm/src/wasm_backend/compile.rs b/packages/vm/src/wasm_backend/compile.rs new file mode 100644 index 0000000000..e88526497c --- /dev/null +++ b/packages/vm/src/wasm_backend/compile.rs @@ -0,0 +1,16 @@ +// use wasmer_middleware_common::metering; +use wasmer::Module; + +use crate::errors::VmResult; +use crate::size::Size; + +use super::store::make_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. +pub fn compile(code: &[u8], memory_limit: Option) -> VmResult { + let store = make_store(memory_limit); + let module = Module::new(&store, code)?; + Ok(module) +} diff --git a/packages/vm/src/wasm_backend/gas.rs b/packages/vm/src/wasm_backend/gas.rs new file mode 100644 index 0000000000..8f8fd1dfb5 --- /dev/null +++ b/packages/vm/src/wasm_backend/gas.rs @@ -0,0 +1,170 @@ +use crate::backend::{Querier, Storage}; +use crate::environment::Environment; + +/// In Wasmer, the gas limit is set on modules during compilation and is included in the cached modules. +/// This causes issues when trying to instantiate the same compiled module with a different gas limit. +/// A fix for this is proposed here: https://github.com/wasmerio/wasmer/pull/996. +/// +/// To work around this limitation, we set the gas limit of all Wasmer instances to this very high value, +/// assuming users won't request more than this amount of gas. In order to set the real gas limit, we pretend +/// to consume the difference between the two in `set_gas_left` ("points used" in the metering middleware). +/// Since we observed overflow behaviour in the points used, we ensure both MAX_GAS_LIMIT and points used stay +/// far below u64::MAX. +// const MAX_GAS_LIMIT: u64 = u64::MAX / 2; + +const FAKE_GAS_AVAILABLE: u64 = 1_000_000; + +#[derive(Debug)] +pub struct InsufficientGasLeft; + +/// Decreases gas left by the given amount. +/// If the amount exceeds the available gas, the remaining gas is set to 0 and +/// an InsufficientGasLeft error is returned. +pub fn decrease_gas_left( + env: &Environment, + amount: u64, +) -> Result<(), InsufficientGasLeft> { + let remaining = get_gas_left(env); + if amount > remaining { + set_gas_left(env, 0); + Err(InsufficientGasLeft) + } else { + set_gas_left(env, remaining - amount); + Ok(()) + } +} + +/// Set the amount of gas units that can be used in the context. +pub fn set_gas_left(_env: &Environment, _amount: u64) {} + +/// Get how many more gas units can be used in the context. +pub fn get_gas_left(_env: &Environment) -> u64 { + FAKE_GAS_AVAILABLE +} + +// /// Set the amount of gas units that can be used in the context. +// pub fn set_gas_left(ctx: &mut Ctx, amount: u64) { +// if amount > MAX_GAS_LIMIT { +// panic!( +// "Attempted to set gas limit larger than max gas limit (got: {}; maximum: {}).", +// amount, MAX_GAS_LIMIT +// ); +// } else { +// let used = MAX_GAS_LIMIT - amount; +// metering::set_points_used_ctx(ctx, used); +// } +// } + +// /// Get how many more gas units can be used in the context. +// pub fn get_gas_left(ctx: &Ctx) -> u64 { +// let used = metering::get_points_used_ctx(ctx); +// // when running out of gas, get_points_used can exceed MAX_GAS_LIMIT +// MAX_GAS_LIMIT.saturating_sub(used) +// } + +#[cfg(test)] +#[cfg(feature = "metering")] +mod tests { + use super::*; + use crate::size::Size; + use crate::testing::{MockQuerier, MockStorage}; + use crate::wasm_backend::compile; + use std::ptr::NonNull; + use wasmer::{imports, Instance as WasmerInstance}; + + type MS = MockStorage; + type MQ = MockQuerier; + const GAS_LIMIT: u64 = 5_000_000; + const MAX_GAS_LIMIT: u64 = u64::MAX / 2; + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); + + fn instantiate(code: &[u8]) -> (Environment, Box) { + let env = Environment::new(GAS_LIMIT, false); + let module = compile(code, Some(TESTING_MEMORY_LIMIT)).unwrap(); + let import_obj = imports! { "env" => {}, }; + let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); + + let instance_ptr = NonNull::from(instance.as_ref()); + env.set_wasmer_instance(Some(instance_ptr)); + + (env, instance) + } + + #[test] + fn decrease_gas_left_works() { + let wasm = wat::parse_str("(module)").unwrap(); + let (env, _) = instantiate(&wasm); + + let before = get_gas_left(&env); + decrease_gas_left(&env, 32).unwrap(); + let after = get_gas_left(&env); + assert_eq!(after, before - 32); + } + + #[test] + fn decrease_gas_left_can_consume_all_gas() { + let wasm = wat::parse_str("(module)").unwrap(); + let (env, _) = instantiate(&wasm); + + let before = get_gas_left(&env); + decrease_gas_left(&env, before).unwrap(); + let after = get_gas_left(&env); + assert_eq!(after, 0); + } + + #[test] + fn decrease_gas_left_errors_for_amount_greater_than_remaining() { + let wasm = wat::parse_str("(module)").unwrap(); + let (env, _) = instantiate(&wasm); + + let before = get_gas_left(&env); + let result = decrease_gas_left(&env, before + 1); + match result.unwrap_err() { + InsufficientGasLeft => {} + } + let after = get_gas_left(&env); + assert_eq!(after, 0); + } + + #[test] + fn get_gas_left_defaults_to_constant() { + let wasm = wat::parse_str("(module)").unwrap(); + let (env, _) = instantiate(&wasm); + let gas_left = get_gas_left(&env); + assert_eq!(gas_left, MAX_GAS_LIMIT); + } + + #[test] + fn set_gas_left_works() { + let wasm = wat::parse_str("(module)").unwrap(); + let (env, _) = instantiate(&wasm); + + let limit = 3456789; + set_gas_left(&env, limit); + assert_eq!(get_gas_left(&env), limit); + + let limit = 1; + set_gas_left(&env, limit); + assert_eq!(get_gas_left(&env), limit); + + let limit = 0; + set_gas_left(&env, limit); + assert_eq!(get_gas_left(&env), limit); + + let limit = MAX_GAS_LIMIT; + set_gas_left(&env, limit); + assert_eq!(get_gas_left(&env), limit); + } + + #[test] + #[should_panic( + expected = "Attempted to set gas limit larger than max gas limit (got: 9223372036854775808; maximum: 9223372036854775807)." + )] + fn set_gas_left_panic_for_values_too_large() { + let wasm = wat::parse_str("(module)").unwrap(); + let (env, _) = instantiate(&wasm); + + let limit = MAX_GAS_LIMIT + 1; + set_gas_left(&env, limit); + } +} diff --git a/packages/vm/src/wasm_backend/limiting_tunables.rs b/packages/vm/src/wasm_backend/limiting_tunables.rs new file mode 100644 index 0000000000..58cfdb110b --- /dev/null +++ b/packages/vm/src/wasm_backend/limiting_tunables.rs @@ -0,0 +1,219 @@ +use std::ptr::NonNull; +use std::sync::Arc; + +use wasmer::{ + vm::{self, MemoryError, MemoryStyle, TableStyle, VMMemoryDefinition, VMTableDefinition}, + MemoryType, Pages, TableType, +}; +use wasmer_engine::Tunables; + +/// A custom tunables that allows you to set a memory limit. +/// +/// After adjusting the memory limits, it delegates all other logic +/// to the base tunables. +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 + /// an upper limit for the guest memory. + limit: Pages, + /// The base implementation we delegate all the logic to + base: T, +} + +impl LimitingTunables { + pub fn new(base: T, limit: Pages) -> Self { + Self { limit, base } + } + + /// Takes in input memory type as requested by the guest and sets + /// a maximum if missing. The resulting memory type is final if + /// valid. However, this can produce invalid types, such that + /// validate_memory must be called before creating the memory. + fn adjust_memory(&self, requested: &MemoryType) -> MemoryType { + let mut adjusted = *requested; + if requested.maximum.is_none() { + adjusted.maximum = Some(self.limit); + } + adjusted + } + + /// Ensures the a given memory type does not exceed the memory limit. + /// Call this after adjusting the memory. + fn validate_memory(&self, ty: &MemoryType) -> Result<(), MemoryError> { + if ty.minimum > self.limit { + return Err(MemoryError::Generic( + "Minimum exceeds the allowed memory limit".to_string(), + )); + } + + if let Some(max) = ty.maximum { + if max > self.limit { + return Err(MemoryError::Generic( + "Maximum exceeds the allowed memory limit".to_string(), + )); + } + } else { + return Err(MemoryError::Generic("Maximum unset".to_string())); + } + + Ok(()) + } +} + +impl Tunables for LimitingTunables { + /// Construct a `MemoryStyle` for the provided `MemoryType` + /// + /// Delegated to base. + fn memory_style(&self, memory: &MemoryType) -> MemoryStyle { + let adjusted = self.adjust_memory(memory); + self.base.memory_style(&adjusted) + } + + /// Construct a `TableStyle` for the provided `TableType` + /// + /// Delegated to base. + fn table_style(&self, table: &TableType) -> TableStyle { + self.base.table_style(table) + } + + /// Create a memory owned by the host given a [`MemoryType`] and a [`MemoryStyle`]. + /// + /// The requested memory type is validated, adjusted to the limited and then passed to base. + fn create_host_memory( + &self, + ty: &MemoryType, + style: &MemoryStyle, + ) -> Result, MemoryError> { + let adjusted = self.adjust_memory(ty); + self.validate_memory(&adjusted)?; + self.base.create_host_memory(&adjusted, style) + } + + /// Create a memory owned by the VM given a [`MemoryType`] and a [`MemoryStyle`]. + /// + /// Delegated to base. + unsafe fn create_vm_memory( + &self, + ty: &MemoryType, + style: &MemoryStyle, + vm_definition_location: NonNull, + ) -> Result, MemoryError> { + let adjusted = self.adjust_memory(ty); + self.validate_memory(&adjusted)?; + self.base + .create_vm_memory(&adjusted, style, vm_definition_location) + } + + /// Create a table owned by the host given a [`TableType`] and a [`TableStyle`]. + /// + /// Delegated to base. + fn create_host_table( + &self, + ty: &TableType, + style: &TableStyle, + ) -> Result, String> { + self.base.create_host_table(ty, style) + } + + /// Create a table owned by the VM given a [`TableType`] and a [`TableStyle`]. + /// + /// Delegated to base. + unsafe fn create_vm_table( + &self, + ty: &TableType, + style: &TableStyle, + vm_definition_location: NonNull, + ) -> Result, String> { + self.base.create_vm_table(ty, style, vm_definition_location) + } +} + +#[cfg(test)] +mod test { + use super::*; + use wasmer::{Target, Tunables as ReferenceTunables}; + + #[test] + fn adjust_memory_works() { + let limit = Pages(12); + let limiting = + LimitingTunables::new(ReferenceTunables::for_target(&Target::default()), limit); + + // No maximum + let requested = MemoryType::new(3, None, true); + let adjusted = limiting.adjust_memory(&requested); + assert_eq!(adjusted, MemoryType::new(3, Some(12), true)); + + // Maximum smaller than limit + let requested = MemoryType::new(3, Some(7), true); + let adjusted = limiting.adjust_memory(&requested); + assert_eq!(adjusted, requested); + + // Maximum equal to limit + let requested = MemoryType::new(3, Some(12), true); + let adjusted = limiting.adjust_memory(&requested); + assert_eq!(adjusted, requested); + + // Maximum greater than limit + let requested = MemoryType::new(3, Some(20), true); + let adjusted = limiting.adjust_memory(&requested); + assert_eq!(adjusted, requested); + + // Minimum greater than maximum (not our problem) + let requested = MemoryType::new(5, Some(3), true); + let adjusted = limiting.adjust_memory(&requested); + assert_eq!(adjusted, requested); + + // Minimum greater than limit + let requested = MemoryType::new(20, Some(20), true); + let adjusted = limiting.adjust_memory(&requested); + assert_eq!(adjusted, requested); + } + + #[test] + fn validate_memory_works() { + let limit = Pages(12); + let limiting = + LimitingTunables::new(ReferenceTunables::for_target(&Target::default()), limit); + + // Maximum smaller than limit + let memory = MemoryType::new(3, Some(7), true); + limiting.validate_memory(&memory).unwrap(); + + // Maximum equal to limit + let memory = MemoryType::new(3, Some(12), true); + limiting.validate_memory(&memory).unwrap(); + + // Maximum greater than limit + let memory = MemoryType::new(3, Some(20), true); + let result = limiting.validate_memory(&memory); + match result.unwrap_err() { + MemoryError::Generic(msg) => { + assert_eq!(msg, "Maximum exceeds the allowed memory limit") + } + err => panic!("Unexpected error: {:?}", err), + } + + // Maximum not set + let memory = MemoryType::new(3, None, true); + let result = limiting.validate_memory(&memory); + match result.unwrap_err() { + MemoryError::Generic(msg) => assert_eq!(msg, "Maximum unset"), + err => panic!("Unexpected error: {:?}", err), + } + + // Minimum greater than maximum (not our problem) + let memory = MemoryType::new(5, Some(3), true); + limiting.validate_memory(&memory).unwrap(); + + // Minimum greater than limit + let memory = MemoryType::new(20, Some(20), true); + let result = limiting.validate_memory(&memory); + match result.unwrap_err() { + MemoryError::Generic(msg) => { + assert_eq!(msg, "Minimum exceeds the allowed memory limit") + } + err => panic!("Unexpected error: {:?}", err), + } + } +} diff --git a/packages/vm/src/wasm_backend/mod.rs b/packages/vm/src/wasm_backend/mod.rs new file mode 100644 index 0000000000..f739fc75ee --- /dev/null +++ b/packages/vm/src/wasm_backend/mod.rs @@ -0,0 +1,9 @@ +mod compile; +mod gas; +mod limiting_tunables; +mod store; + +pub use compile::compile; +pub use gas::{decrease_gas_left, get_gas_left, set_gas_left, InsufficientGasLeft}; +pub use limiting_tunables::LimitingTunables; +pub use store::{make_store, make_store_headless}; diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs new file mode 100644 index 0000000000..9db5e12094 --- /dev/null +++ b/packages/vm/src/wasm_backend/store.rs @@ -0,0 +1,52 @@ +#[cfg(feature = "cranelift")] +use wasmer::Cranelift; +#[cfg(not(feature = "cranelift"))] +use wasmer::Singlepass; +use wasmer::{ + Bytes, Engine, Pages, Store, Target, + Tunables as ReferenceTunables, /* See https://github.com/wasmerio/wasmer/issues/1872 */ + JIT, +}; + +use crate::size::Size; + +use super::limiting_tunables::LimitingTunables; + +/// Created a store with the default compiler and the given memory limit (in bytes) +/// If memory_limit is None, no limit is applied. +pub fn make_store(memory_limit: Option) -> Store { + #[cfg(feature = "cranelift")] + { + let compiler = Cranelift::default(); + let engine = JIT::new(compiler).engine(); + make_store_with_engine(&engine, memory_limit) + } + + #[cfg(not(feature = "cranelift"))] + { + let compiler = Singlepass::default(); + let engine = JIT::new(compiler).engine(); + make_store_with_engine(&engine, memory_limit) + } +} + +/// 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_store_headless(memory_limit: Option) -> Store { + let engine = JIT::headless().engine(); + make_store_with_engine(&engine, memory_limit) +} + +/// Creates a store from an engine and an optional memory limit. +/// If no limit is set, the no custom tunables will be used. +fn make_store_with_engine(engine: &dyn Engine, memory_limit: Option) -> Store { + match memory_limit { + Some(limit) => { + let pages = Pages::from(Bytes(limit.0)); + let base = ReferenceTunables::for_target(&Target::default()); + let tunables = LimitingTunables::new(base, pages); + Store::new_with_tunables(engine, tunables) + } + None => Store::new(engine), + } +}