From d0bfe862f0c55011b9620c94f03d51a2d6121108 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 10 Sep 2020 09:28:59 +0200 Subject: [PATCH 001/110] Update Wasmer dependencies --- Cargo.lock | 613 ++++++++++++++++++++++++----------------- packages/vm/Cargo.toml | 15 +- 2 files changed, 364 insertions(+), 264 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fda4facd34..72f1d6690d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,17 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" - [[package]] name = "autocfg" version = "1.0.0" @@ -48,9 +36,9 @@ checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" [[package]] name = "bincode" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf" +checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" dependencies = [ "byteorder", "serde", @@ -62,28 +50,13 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake3" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68df31bdf2bbb567e5adf8f21ac125dc0e897b1381e7b841f181521f06fc3134" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", - "crypto-mac", - "digest 0.8.1", -] - [[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.3", + "generic-array", ] [[package]] @@ -115,15 +88,6 @@ dependencies = [ "time", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "cmake" version = "0.1.42" @@ -133,12 +97,6 @@ dependencies = [ "cc", ] -[[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.10.1" @@ -184,10 +142,9 @@ dependencies = [ "snafu", "tempfile", "wabt", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-compiler-cranelift", + "wasmer-compiler-singlepass", ] [[package]] @@ -198,18 +155,18 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.59.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818" +checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.59.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e" +checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" dependencies = [ "byteorder", "cranelift-bforest", @@ -218,6 +175,8 @@ dependencies = [ "cranelift-entity", "gimli", "log", + "regalloc", + "serde", "smallvec", "target-lexicon", "thiserror", @@ -225,9 +184,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.59.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9" +checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -235,27 +194,40 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.59.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d" +checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" [[package]] name = "cranelift-entity" -version = "0.59.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38" +checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" +dependencies = [ + "serde", +] [[package]] -name = "cranelift-native" -version = "0.59.0" +name = "cranelift-frontend" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b" +checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" 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", +] + [[package]] name = "crossbeam-deque" version = "0.7.3" @@ -304,22 +276,38 @@ dependencies = [ ] [[package]] -name = "crypto-mac" -version = "0.7.0" +name = "darling" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" dependencies = [ - "generic-array 0.12.3", - "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 = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +dependencies = [ + "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 = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ - "generic-array 0.12.3", + "darling_core", + "quote", + "syn", ] [[package]] @@ -328,7 +316,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.3", + "generic-array", ] [[package]] @@ -339,14 +327,14 @@ checksum = "807e5847c39ad6a11eac66de492ed1406f76a260eb8656e8740cad9eabc69c27" [[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", @@ -354,11 +342,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", ] @@ -369,40 +358,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" [[package]] -name = "errno" -version = "0.2.4" +name = "enumset" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" +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" @@ -427,12 +414,13 @@ dependencies = [ [[package]] name = "gimli" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" +checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" dependencies = [ - "byteorder", + "fallible-iterator", "indexmap", + "stable_deref_trait", ] [[package]] @@ -441,6 +429,15 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" +[[package]] +name = "hashbrown" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" +dependencies = [ + "autocfg", +] + [[package]] name = "hermit-abi" version = "0.1.8" @@ -456,13 +453,20 @@ 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.3.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" +checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" dependencies = [ "autocfg", + "hashbrown", "serde", ] @@ -478,19 +482,25 @@ 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.68" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" +checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" [[package]] -name = "lock_api" -version = "0.3.3" +name = "libloading" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" +checksum = "2cadb8e769f070c45df05c78c7520eb4cd17061d4ab262e43cfc68b4d00ac71c" dependencies = [ - "scopeguard", + "winapi", ] [[package]] @@ -502,6 +512,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "maybe-uninit" version = "2.0.0" @@ -528,17 +547,10 @@ dependencies = [ ] [[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" -dependencies = [ - "bitflags", - "cc", - "cfg-if", - "libc", - "void", -] +checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" [[package]] name = "num-integer" @@ -570,29 +582,20 @@ dependencies = [ ] [[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "owning_ref" -version = "0.4.1" +name = "object" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" +checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" dependencies = [ - "stable_deref_trait", + "crc32fast", + "indexmap", ] [[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" @@ -601,40 +604,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" [[package]] -name = "parking_lot" -version = "0.10.0" +name = "ppv-lite86" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" -dependencies = [ - "lock_api", - "parking_lot_core", -] +checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" [[package]] -name = "parking_lot_core" -version = "0.7.0" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "smallvec", - "winapi", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] -name = "ppv-lite86" -version = "0.2.6" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] [[package]] name = "proc-macro2" -version = "1.0.9" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" +checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" dependencies = [ "unicode-xid", ] @@ -730,6 +733,29 @@ version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +[[package]] +name = "regalloc" +version = "0.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" +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.2" @@ -745,6 +771,12 @@ 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" @@ -813,16 +845,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" @@ -883,15 +905,15 @@ dependencies = [ "block-buffer", "cfg-if", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] [[package]] name = "smallvec" -version = "1.2.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" +checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" [[package]] name = "snafu" @@ -922,10 +944,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" [[package]] -name = "subtle" -version = "1.0.0" +name = "strsim" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "syn" @@ -989,6 +1011,37 @@ dependencies = [ "winapi", ] +[[package]] +name = "tracing" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0aae59226cf195d8e74d4b34beae1859257efb4e5fed3f147d2dc2c7d372178" +dependencies = [ + "cfg-if", + "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.11.2" @@ -1007,12 +1060,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 = "wabt" version = "0.9.2" @@ -1043,131 +1090,185 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "wasmer-clif-backend" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691ea323652d540a10722066dbf049936f4367bb22a96f8992a262a942a8b11b" +name = "wasm-common" +version = "1.0.0-alpha.1" dependencies = [ - "byteorder", - "cranelift-codegen", "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", "serde", - "serde-bench", - "serde_bytes", - "serde_derive", +] + +[[package]] +name = "wasmer" +version = "1.0.0-alpha.1" +dependencies = [ + "cfg-if", + "indexmap", + "more-asserts", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", - "wasmparser", + "thiserror", + "wasm-common", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-vm", + "wat", "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" +version = "1.0.0-alpha.1" dependencies = [ - "cranelift-codegen", - "log", + "enumset", + "raw-cpuid", + "serde", + "serde_bytes", "smallvec", "target-lexicon", + "thiserror", + "wasm-common", + "wasmer-vm", + "wasmparser", ] [[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-cranelift" +version = "1.0.0-alpha.1" dependencies = [ "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "cranelift-frontend", + "gimli", + "more-asserts", + "rayon", + "serde", + "tracing", + "wasm-common", + "wasmer-compiler", + "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-compiler-singlepass" +version = "1.0.0-alpha.1" dependencies = [ - "wasmer-runtime-core", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasm-common", + "wasmer-compiler", + "wasmer-vm", ] [[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-alpha.1" 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", + "wasm-common", + "wasmer-compiler", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine-jit" +version = "1.0.0-alpha.1" +dependencies = [ + "bincode", + "cfg-if", + "region", + "serde", + "serde_bytes", + "wasm-common", + "wasmer-compiler", + "wasmer-engine", + "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-alpha.1" dependencies = [ "bincode", - "byteorder", - "dynasm", - "dynasmrt", - "lazy_static", - "libc", - "nix", + "cfg-if", + "leb128", + "libloading", "serde", - "serde_derive", - "smallvec", - "wasmer-runtime-core", + "tempfile", + "tracing", + "wasm-common", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-vm", ] [[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-alpha.1" dependencies = [ + "object", + "thiserror", + "wasm-common", + "wasmer-compiler", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-alpha.1" +dependencies = [ + "backtrace", "cc", + "cfg-if", + "indexmap", "libc", - "wasmer-runtime-core", + "memoffset", + "more-asserts", + "region", + "serde", + "thiserror", + "wasm-common", "winapi", ] [[package]] name = "wasmparser" -version = "0.51.4" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" +checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" + +[[package]] +name = "wast" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1844f66a2bc8526d71690104c0e78a8e59ffa1597b7245769d174ebb91deb5" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce85d72b74242c340e9e3492cfb602652d7bb324c3172dd441b5577e39a2e18c" +dependencies = [ + "wast", +] [[package]] name = "winapi" diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 1768f2a5f7..7cdefff528 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -14,11 +14,11 @@ 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"] +cranelift = ["wasmer-compiler-cranelift"] +singlepass = ["wasmer-compiler-singlepass"] # 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-cranelift = ["wasmer-compiler-cranelift"] +default-singlepass = ["wasmer-compiler-singlepass"] # enable this for better error reporting backtraces = ["snafu/backtraces"] # iterator allows us to iterate over all DB items in a given range @@ -33,10 +33,9 @@ staking = ["cosmwasm-std/staking"] # Uses the path when built locally; uses the given version from crates.io when published cosmwasm-std = { path = "../std", version = "0.10.1" } serde_json = "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 = { path = "../../../wasmer-reborn/lib/api" } +wasmer-compiler-cranelift = { path = "../../../wasmer-reborn/lib/compiler-cranelift", optional = true } +wasmer-compiler-singlepass = { path = "../../../wasmer-reborn/lib/compiler-singlepass", optional = true } schemars = "0.7" serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } snafu = { version = "0.6.3" } From 5aef528580eaecb2279dd6c2893696336e38c413 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 5 Aug 2020 10:05:36 +0200 Subject: [PATCH 002/110] Disable middleware --- packages/vm/src/backends/singlepass.rs | 69 ++++++++++++++------------ packages/vm/src/middleware/mod.rs | 6 +-- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/packages/vm/src/backends/singlepass.rs b/packages/vm/src/backends/singlepass.rs index ebc32ca297..5f59d4a5c7 100644 --- a/packages/vm/src/backends/singlepass.rs +++ b/packages/vm/src/backends/singlepass.rs @@ -1,16 +1,11 @@ #![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 wasmer_middleware_common::metering; +use wasmer_runtime_core::{backend::Compiler, compile_with, module::Module, vm::Ctx}; +use wasmer_singlepass_backend::SinglepassCompiler; use crate::errors::VmResult; -use crate::middleware::DeterministicMiddleware; +// 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. @@ -23,19 +18,21 @@ use crate::middleware::DeterministicMiddleware; /// far below u64::MAX. const MAX_GAS_LIMIT: u64 = u64::MAX / 2; +const FAKE_GAS_AVAILABLE: u64 = 1_000_000; + 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) + // 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(SinglepassCompiler::new()) } pub fn backend() -> &'static str { @@ -43,25 +40,33 @@ pub fn backend() -> &'static str { } /// 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); - } -} +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 { - 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) +pub fn get_gas_left(_ctx: &Ctx) -> 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)] mod test { use super::*; 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; From de354aa35d149c51b721971ad0f586c616c23fcc Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 5 Aug 2020 14:30:10 +0200 Subject: [PATCH 003/110] Adapt code to new API --- Cargo.lock | 77 +++++ packages/vm/Cargo.toml | 2 + packages/vm/src/backends/cranelift.rs | 1 + packages/vm/src/backends/mod.rs | 18 +- packages/vm/src/backends/singlepass.rs | 40 +-- packages/vm/src/context.rs | 144 +++++----- packages/vm/src/imports.rs | 372 +++++++++++++------------ packages/vm/src/instance.rs | 83 +++--- packages/vm/src/memory.rs | 15 +- packages/vm/src/modules.rs | 19 +- 10 files changed, 435 insertions(+), 336 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72f1d6690d..9d0e41e1cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,17 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" + [[package]] name = "autocfg" version = "1.0.0" @@ -50,6 +62,21 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "blake3" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce4f9586c9a3151c4b49b19e82ba163dd073614dd057e53c969e1a4db5b52720" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", + "crypto-mac", + "digest", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -97,6 +124,12 @@ dependencies = [ "cc", ] +[[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.10.1" @@ -142,9 +175,11 @@ dependencies = [ "snafu", "tempfile", "wabt", + "wasm-common", "wasmer", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", + "wasmer-runtime-core", ] [[package]] @@ -275,6 +310,16 @@ 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", + "subtle", +] + [[package]] name = "darling" version = "0.10.2" @@ -949,6 +994,12 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" +[[package]] +name = "subtle" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "502d53007c02d7605a05df1c1a73ee436952781653da5d0bf57ad608f66932c1" + [[package]] name = "syn" version = "1.0.16" @@ -1117,6 +1168,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "wasmer-cache" +version = "1.0.0-alpha.1" +dependencies = [ + "blake3", + "hex", + "memmap", + "thiserror", + "wasmer", +] + [[package]] name = "wasmer-compiler" version = "1.0.0-alpha.1" @@ -1228,6 +1290,21 @@ dependencies = [ "wasmer-compiler", ] +[[package]] +name = "wasmer-runtime-core" +version = "0.18.0" +dependencies = [ + "blake3", + "lazy_static", + "wasm-common", + "wasmer", + "wasmer-cache", + "wasmer-compiler", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-vm", +] + [[package]] name = "wasmer-vm" version = "1.0.0-alpha.1" diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 7cdefff528..53c5269567 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -33,7 +33,9 @@ staking = ["cosmwasm-std/staking"] # Uses the path when built locally; uses the given version from crates.io when published cosmwasm-std = { path = "../std", version = "0.10.1" } serde_json = "1.0" +wasm-common = { path = "../../../wasmer-reborn/lib/wasm-common" } wasmer = { path = "../../../wasmer-reborn/lib/api" } +wasmer-runtime-core = { path = "../../../wasmer-reborn/lib/deprecated/runtime-core" } wasmer-compiler-cranelift = { path = "../../../wasmer-reborn/lib/compiler-cranelift", optional = true } wasmer-compiler-singlepass = { path = "../../../wasmer-reborn/lib/compiler-singlepass", optional = true } schemars = "0.7" diff --git a/packages/vm/src/backends/cranelift.rs b/packages/vm/src/backends/cranelift.rs index 573bcdb804..128032821f 100644 --- a/packages/vm/src/backends/cranelift.rs +++ b/packages/vm/src/backends/cranelift.rs @@ -1,4 +1,5 @@ #![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, diff --git a/packages/vm/src/backends/mod.rs b/packages/vm/src/backends/mod.rs index 3502982738..b799aee312 100644 --- a/packages/vm/src/backends/mod.rs +++ b/packages/vm/src/backends/mod.rs @@ -57,9 +57,9 @@ mod test { let wasm = wat2wasm("(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()); + let before = get_gas_left(&instance.context()); + decrease_gas_left(&mut instance.context_mut(), 32).unwrap(); + let after = get_gas_left(&instance.context()); assert_eq!(after, before - 32); } @@ -68,9 +68,9 @@ mod test { let wasm = wat2wasm("(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()); + let before = get_gas_left(&instance.context()); + decrease_gas_left(&mut instance.context_mut(), before).unwrap(); + let after = get_gas_left(&instance.context()); assert_eq!(after, 0); } @@ -79,12 +79,12 @@ mod test { let wasm = wat2wasm("(module)").unwrap(); let mut instance = instantiate(&wasm); - let before = get_gas_left(instance.context()); - let result = decrease_gas_left(instance.context_mut(), before + 1); + let before = get_gas_left(&instance.context()); + let result = decrease_gas_left(&mut instance.context_mut(), before + 1); match result.unwrap_err() { InsufficientGasLeft => {} } - let after = get_gas_left(instance.context()); + 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 index 5f59d4a5c7..4ff6f4bb41 100644 --- a/packages/vm/src/backends/singlepass.rs +++ b/packages/vm/src/backends/singlepass.rs @@ -1,8 +1,13 @@ #![cfg(any(feature = "singlepass", feature = "default-singlepass"))] // use wasmer_middleware_common::metering; -use wasmer_runtime_core::{backend::Compiler, compile_with, module::Module, vm::Ctx}; -use wasmer_singlepass_backend::SinglepassCompiler; +use wasmer_compiler_singlepass::{Singlepass, SinglepassCompiler}; +use wasmer_runtime_core::{ + backend::{Backend, Compiler}, + compile_with, + module::Module, + vm::Ctx, +}; use crate::errors::VmResult; // use crate::middleware::DeterministicMiddleware; @@ -21,18 +26,13 @@ const MAX_GAS_LIMIT: u64 = u64::MAX / 2; const FAKE_GAS_AVAILABLE: u64 = 1_000_000; pub fn compile(code: &[u8]) -> VmResult { - let module = compile_with(code, compiler().as_ref())?; + let module = compile_with(code, Backend::Auto)?; 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(SinglepassCompiler::new()) + let config = Singlepass::default(); + Box::new(SinglepassCompiler::new(&config)) } pub fn backend() -> &'static str { @@ -83,7 +83,7 @@ mod test { fn get_gas_left_defaults_to_constant() { let wasm = wat2wasm("(module)").unwrap(); let instance = instantiate(&wasm); - let gas_left = get_gas_left(instance.context()); + let gas_left = get_gas_left(&instance.context()); assert_eq!(gas_left, MAX_GAS_LIMIT); } @@ -93,20 +93,20 @@ mod test { let mut instance = instantiate(&wasm); let limit = 3456789; - set_gas_left(instance.context_mut(), limit); - assert_eq!(get_gas_left(instance.context()), limit); + set_gas_left(&mut 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); + set_gas_left(&mut 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); + set_gas_left(&mut 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); + set_gas_left(&mut instance.context_mut(), limit); + assert_eq!(get_gas_left(&instance.context()), limit); } #[test] @@ -118,6 +118,6 @@ mod test { let mut instance = instantiate(&wasm); let limit = MAX_GAS_LIMIT + 1; - set_gas_left(instance.context_mut(), limit); + set_gas_left(&mut instance.context_mut(), limit); } } diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index e7b4a13446..7c15af4652 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -9,7 +9,7 @@ use std::marker::PhantomData; use std::ptr::NonNull; use wasmer_runtime_core::{ - typed_func::{Func, Wasm, WasmTypeList}, + typed_func::{Func, WasmTypeList}, vm::Ctx, Instance as WasmerInstance, }; @@ -232,14 +232,14 @@ fn account_for_externally_used_gas_impl( 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())); + 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); + set_gas_left(&mut instance.context_mut(), new_limit); if gas_state.externally_used_gas + wasmer_used_gas > gas_state.gas_limit { Err(VmError::GasDepletion) @@ -300,9 +300,9 @@ pub(crate) fn with_func_from_context( where S: Storage, Q: Querier, - Args: WasmTypeList, - Rets: WasmTypeList, - Callback: FnOnce(Func) -> VmResult, + Args: WasmTypeList + Clone, + Rets: WasmTypeList + Clone, + Callback: FnOnce(Func) -> VmResult, { let ctx_data = get_context_data::(ctx); match ctx_data.wasmer_instance { @@ -376,7 +376,7 @@ mod test { use cosmwasm_std::{ coins, from_binary, to_vec, AllBalanceResponse, BankQuery, Empty, HumanAddr, QueryRequest, }; - use wasmer_runtime_core::{imports, typed_func::Func}; + use wasmer_runtime_core::imports; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); @@ -399,23 +399,22 @@ mod test { 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| {}), + "db_read" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + "db_write" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| {}), + "db_remove" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), + "db_scan" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32, _c: i32| -> u32 { 0 }), + "db_next" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + "query_chain" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + "canonicalize_address" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| -> u32 { 0 }), + "humanize_address" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| -> u32 { 0 }), + "debug" => Func::new(|_ctx: &mut Ctx, _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)); + set_wasmer_instance::(&mut instance.context_mut(), Some(instance_ptr)); instance } @@ -439,13 +438,13 @@ mod test { let ctx = instance.context_mut(); // empty data on start - let (inits, initq) = move_out_of_context::(ctx); + let (inits, initq) = move_out_of_context::(&mut 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); + leave_default_data(&mut ctx); + let (s, q) = move_out_of_context::(&mut ctx); assert!(s.is_some()); assert!(q.is_some()); assert_eq!( @@ -454,7 +453,7 @@ mod test { ); // now is empty again - let (ends, endq) = move_out_of_context::(ctx); + let (ends, endq) = move_out_of_context::(&mut ctx); assert!(ends.is_none()); assert!(endq.is_none()); } @@ -465,17 +464,17 @@ mod test { 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); + set_gas_left(&mut instance.context_mut(), gas_limit); + get_gas_state_mut::(&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(); + account_for_externally_used_gas::(&mut context, 70).unwrap(); + account_for_externally_used_gas::(&mut context, 4).unwrap(); + account_for_externally_used_gas::(&mut context, 6).unwrap(); + account_for_externally_used_gas::(&mut context, 20).unwrap(); // Using one more unit of gas triggers a failure - match account_for_externally_used_gas::(context, 1).unwrap_err() { + match account_for_externally_used_gas::(&mut context, 1).unwrap_err() { VmError::GasDepletion => {} err => panic!("unexpected error: {:?}", err), } @@ -487,22 +486,22 @@ mod test { 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); + set_gas_left(&mut instance.context_mut(), gas_limit); + get_gas_state_mut::(&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(); + account_for_externally_used_gas::(&mut context, 50).unwrap(); + account_for_externally_used_gas::(&mut context, 4).unwrap(); // Consume 20 gas directly in wasmer - decrease_gas_left(instance.context_mut(), 20).unwrap(); + decrease_gas_left(&mut 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(); + account_for_externally_used_gas::(&mut context, 6).unwrap(); + account_for_externally_used_gas::(&mut context, 20).unwrap(); // Using one more unit of gas triggers a failure - match account_for_externally_used_gas::(context, 1).unwrap_err() { + match account_for_externally_used_gas::(&mut context, 1).unwrap_err() { VmError::GasDepletion => {} err => panic!("unexpected error: {:?}", err), } @@ -512,28 +511,28 @@ mod test { fn is_storage_readonly_defaults_to_true() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - assert_eq!(is_storage_readonly::(ctx), true); + 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); + leave_default_data(&mut ctx); // change - set_storage_readonly::(ctx, false); - assert_eq!(is_storage_readonly::(ctx), false); + set_storage_readonly::(&mut ctx, false); + assert_eq!(is_storage_readonly::(&ctx), false); // still false - set_storage_readonly::(ctx, false); - assert_eq!(is_storage_readonly::(ctx), false); + set_storage_readonly::(&mut ctx, false); + assert_eq!(is_storage_readonly::(&ctx), false); // change back - set_storage_readonly::(ctx, true); - assert_eq!(is_storage_readonly::(ctx), true); + set_storage_readonly::(&mut ctx, true); + assert_eq!(is_storage_readonly::(&ctx), true); } #[test] @@ -562,29 +561,31 @@ mod test { #[test] fn with_func_from_context_works() { let mut instance = make_instance(); - leave_default_data(instance.context_mut()); + leave_default_data(&mut 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(); + let ptr = + with_func_from_context::(&mut 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()); + leave_default_data(&mut instance.context_mut()); // Clear context's wasmer_instance - set_wasmer_instance::(instance.context_mut(), None); + set_wasmer_instance::(&mut instance.context_mut(), None); let ctx = instance.context_mut(); - let res = with_func_from_context::(ctx, "allocate", |_func| { - panic!("unexpected callback call"); - }); + let res = + with_func_from_context::(&mut ctx, "allocate", |_func| { + panic!("unexpected callback call"); + }); match res.unwrap_err() { VmError::UninitializedContextData { kind, .. } => assert_eq!(kind, "wasmer_instance"), e => panic!("Unexpected error: {}", e), @@ -594,12 +595,13 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_function() { let mut instance = make_instance(); - leave_default_data(instance.context_mut()); + leave_default_data(&mut instance.context_mut()); let ctx = instance.context_mut(); - let res = with_func_from_context::(ctx, "doesnt_exist", |_func| { - panic!("unexpected callback call"); - }); + let res = + with_func_from_context::(&mut ctx, "doesnt_exist", |_func| { + panic!("unexpected callback call"); + }); match res.unwrap_err() { VmError::ResolveErr { msg, .. } => { assert_eq!( @@ -615,9 +617,9 @@ mod test { fn with_storage_from_context_set_get() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let val = with_storage_from_context::(ctx, |store| { + let val = with_storage_from_context::(&mut ctx, |store| { Ok(store.get(INIT_KEY).0.expect("error getting value")) }) .unwrap(); @@ -626,7 +628,7 @@ mod test { let set_key: &[u8] = b"more"; let set_value: &[u8] = b"data"; - with_storage_from_context::(ctx, |store| { + with_storage_from_context::(&mut &mut ctx, |store| { store .set(set_key, set_value) .0 @@ -635,7 +637,7 @@ mod test { }) .unwrap(); - with_storage_from_context::(ctx, |store| { + with_storage_from_context::(&mut 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(()) @@ -648,9 +650,9 @@ mod test { fn with_storage_from_context_handles_panics() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - with_storage_from_context::(ctx, |_store| { + with_storage_from_context::(&mut ctx, |_store| { panic!("A panic occurred in the callback.") }) .unwrap(); @@ -660,9 +662,9 @@ mod test { fn with_querier_from_context_works() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let res = with_querier_from_context::(ctx, |querier| { + let res = with_querier_from_context::(&mut ctx, |querier| { let req: QueryRequest = QueryRequest::Bank(BankQuery::AllBalances { address: HumanAddr::from(INIT_ADDR), }); @@ -683,9 +685,9 @@ mod test { fn with_querier_from_context_handles_panics() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - with_querier_from_context::(ctx, |_querier| { + with_querier_from_context::(&mut ctx, |_querier| { panic!("A panic occurred in the callback.") }) .unwrap(); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 8385a30c2c..261aa47a27 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -42,18 +42,18 @@ const MAX_LENGTH_DEBUG: usize = 2 * MI; /// 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)?; + let key = read_region(&mut ctx, 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)?; + with_storage_from_context::(&mut ctx, |store| Ok(store.get(&key)))?; + process_gas_info::(&mut ctx, 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::(&mut ctx, &out_data) } /// Writes a storage entry from Wasm memory into the VM's storage @@ -62,31 +62,31 @@ pub fn do_write( key_ptr: u32, value_ptr: u32, ) -> VmResult<()> { - if is_storage_readonly::(ctx) { + if is_storage_readonly::(&mut ctx) { 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(&mut ctx, key_ptr, MAX_LENGTH_DB_KEY)?; + let value = read_region(&mut ctx, 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)?; + with_storage_from_context::(&mut ctx, |store| Ok(store.set(&key, &value)))?; + process_gas_info::(&mut ctx, gas_info)?; result?; Ok(()) } pub fn do_remove(ctx: &mut Ctx, key_ptr: u32) -> VmResult<()> { - if is_storage_readonly::(ctx) { + if is_storage_readonly::(&mut ctx) { return Err(VmError::write_access_denied()); } - let key = read_region(ctx, key_ptr, MAX_LENGTH_DB_KEY)?; + let key = read_region(&mut ctx, 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)?; + with_storage_from_context::(&mut ctx, |store| Ok(store.remove(&key)))?; + process_gas_info::(&mut ctx, gas_info)?; result?; Ok(()) @@ -98,25 +98,32 @@ pub fn do_canonicalize_address( source_ptr: u32, destination_ptr: u32, ) -> VmResult { - let source_data = read_region(ctx, source_ptr, MAX_LENGTH_HUMAN_ADDRESS)?; + let source_data = read_region(&mut ctx, 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::(&mut ctx, 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::( + &mut ctx, + 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::(&mut ctx, gas_info)?; match result { Ok(canonical) => { - write_region(ctx, destination_ptr, canonical.as_slice())?; + write_region(&mut ctx, destination_ptr, canonical.as_slice())?; Ok(0) } - Err(FfiError::UserErr { msg, .. }) => Ok(write_to_contract::(ctx, msg.as_bytes())?), + Err(FfiError::UserErr { msg, .. }) => { + Ok(write_to_contract::(&mut ctx, msg.as_bytes())?) + } Err(err) => Err(VmError::from(err)), } } @@ -127,16 +134,22 @@ pub fn do_humanize_address( source_ptr: u32, destination_ptr: u32, ) -> VmResult { - let canonical = Binary(read_region(ctx, source_ptr, MAX_LENGTH_CANONICAL_ADDRESS)?); + let canonical = Binary(read_region( + &mut ctx, + source_ptr, + MAX_LENGTH_CANONICAL_ADDRESS, + )?); let (result, gas_info) = api.human_address(&CanonicalAddr(canonical)); - process_gas_info::(ctx, gas_info)?; + process_gas_info::(&mut ctx, gas_info)?; match result { Ok(human) => { - write_region(ctx, destination_ptr, human.as_str().as_bytes())?; + write_region(&mut ctx, destination_ptr, human.as_str().as_bytes())?; Ok(0) } - Err(FfiError::UserErr { msg, .. }) => Ok(write_to_contract::(ctx, msg.as_bytes())?), + Err(FfiError::UserErr { msg, .. }) => { + Ok(write_to_contract::(&mut ctx, msg.as_bytes())?) + } Err(err) => Err(VmError::from(err)), } } @@ -152,28 +165,29 @@ pub fn print_debug_message(ctx: &mut Ctx, message_ptr: u32) -> VmResult<()> { /// 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| { - let out_size = to_u32(input.len())?; - let ptr = allocate.call(out_size)?; - if ptr == 0 { - return Err(CommunicationError::zero_address().into()); - } - Ok(ptr) - })?; - write_region(ctx, target_ptr, input)?; + let target_ptr = + with_func_from_context::(&mut ctx, "allocate", |allocate| { + let out_size = to_u32(input.len())?; + let ptr = allocate.call(out_size)?; + if ptr == 0 { + return Err(CommunicationError::zero_address().into()); + } + Ok(ptr) + })?; + write_region(&mut ctx, 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)?; + let request = read_region(&mut ctx, 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(&mut ctx); + let (result, gas_info) = with_querier_from_context::(&mut ctx, |querier| { Ok(querier.query_raw(&request, gas_remaining)) })?; - process_gas_info::(ctx, gas_info)?; + process_gas_info::(&mut ctx, gas_info)?; let serialized = to_vec(&result?)?; - write_to_contract::(ctx, &serialized) + write_to_contract::(&mut ctx, &serialized) } #[cfg(feature = "iterator")] @@ -183,26 +197,26 @@ pub fn do_scan( 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(&mut ctx, start_ptr, MAX_LENGTH_DB_KEY)?; + let end = maybe_read_region(&mut ctx, 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) = with_storage_from_context::(&mut ctx, |store| { Ok(store.range(start.as_deref(), end.as_deref(), order)) })?; - process_gas_info::(ctx, gas_info)?; + process_gas_info::(&mut ctx, gas_info)?; let iterator = result?; - let iterator_id = add_iterator::(ctx, iterator); + let iterator_id = add_iterator::(&mut ctx, iterator); Ok(iterator_id) } #[cfg(feature = "iterator")] pub fn do_next(ctx: &mut Ctx, iterator_id: u32) -> VmResult { let (result, gas_info) = - with_iterator_from_context::(ctx, iterator_id, |iter| Ok(iter.next()))?; - process_gas_info::(ctx, gas_info)?; + with_iterator_from_context::(&mut ctx, iterator_id, |iter| Ok(iter.next()))?; + process_gas_info::(&mut ctx, 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 +228,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::(&mut ctx, &out_data) } #[cfg(test)] @@ -228,9 +242,7 @@ mod test { use wasmer_runtime_core::{imports, typed_func::Func, Instance as WasmerInstance}; use crate::backends::compile; - use crate::context::{ - move_into_context, set_storage_readonly, set_wasmer_instance, setup_context, - }; + use crate::context::{move_into_context, set_storage_readonly, set_wasmer_instance}; use crate::testing::{MockApi, MockQuerier, MockStorage}; use crate::traits::Storage; use crate::FfiError; @@ -259,24 +271,23 @@ mod test { 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: i32, _b: i32| -> u32 { 0 }), - "humanize_address" => Func::new(|_a: i32, _b: i32| -> u32 { 0 }), - "debug" => Func::new(|_a: u32| {}), + "db_read" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + "db_write" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| {}), + "db_remove" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), + "db_scan" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32, _c: i32| -> u32 { 0 }), + "db_next" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + "query_chain" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + "canonicalize_address" => Func::new(|_ctx: &mut Ctx, _a: i32, _b: i32| -> u32 { 0 }), + "humanize_address" => Func::new(|_ctx: &mut Ctx, _a: i32, _b: i32| -> u32 { 0 }), + "debug" => Func::new(|_ctx: &mut Ctx, _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)); - set_storage_readonly::(instance.context_mut(), false); + set_wasmer_instance::(&mut instance.context_mut(), Some(instance_ptr)); + set_storage_readonly::(&mut instance.context_mut(), false); instance } @@ -288,7 +299,7 @@ mod test { 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_context(&mut ctx, storage, querier); } fn write_data(wasmer_instance: &mut WasmerInstance, data: &[u8]) -> u32 { @@ -299,7 +310,7 @@ mod test { 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"); + write_region(&mut wasmer_instance.context_mut(), region_ptr, data).expect("error writing"); region_ptr } @@ -314,41 +325,41 @@ mod test { /// 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() + read_region(&mut ctx, region_ptr, 5000).unwrap() } #[test] fn do_read_works() { let mut instance = make_instance(); - leave_default_data(instance.context_mut()); + leave_default_data(&mut instance.context_mut()); let key_ptr = write_data(&mut instance, KEY1); let ctx = instance.context_mut(); - let result = do_read::(ctx, key_ptr); + let result = do_read::(&mut ctx, 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(&mut ctx, 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()); + leave_default_data(&mut instance.context_mut()); 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 result = do_read::(&mut ctx, 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()); + leave_default_data(&mut instance.context_mut()); let key_ptr = write_data(&mut instance, &vec![7u8; 300 * 1024]); let ctx = instance.context_mut(); - let result = do_read::(ctx, key_ptr); + let result = do_read::(&mut ctx, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionLengthTooBig { length, .. }, @@ -365,11 +376,11 @@ mod test { let value_ptr = write_data(&mut instance, b"new value"); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - do_write::(ctx, key_ptr, value_ptr).unwrap(); + do_write::(&mut ctx, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(ctx, |store| { + let val = with_storage_from_context::(&mut ctx, |store| { Ok(store .get(b"new storage key") .0 @@ -387,11 +398,11 @@ mod test { let value_ptr = write_data(&mut instance, VALUE2); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - do_write::(ctx, key_ptr, value_ptr).unwrap(); + do_write::(&mut ctx, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(ctx, |store| { + let val = with_storage_from_context::(&mut ctx, |store| { Ok(store.get(KEY1).0.expect("error getting value")) }) .unwrap(); @@ -406,11 +417,11 @@ mod test { let value_ptr = write_data(&mut instance, b""); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - do_write::(ctx, key_ptr, value_ptr).unwrap(); + do_write::(&mut ctx, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(ctx, |store| { + let val = with_storage_from_context::(&mut ctx, |store| { Ok(store .get(b"new storage key") .0 @@ -428,9 +439,9 @@ mod test { let value_ptr = write_data(&mut instance, b"new value"); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let result = do_write::(ctx, key_ptr, value_ptr); + let result = do_write::(&mut ctx, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -453,9 +464,9 @@ mod test { let value_ptr = write_data(&mut instance, &vec![5u8; 300 * 1024]); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let result = do_write::(ctx, key_ptr, value_ptr); + let result = do_write::(&mut ctx, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -478,10 +489,10 @@ mod test { let value_ptr = write_data(&mut instance, b"new value"); let ctx = instance.context_mut(); - leave_default_data(ctx); - set_storage_readonly::(ctx, true); + leave_default_data(&mut ctx); + set_storage_readonly::(&mut ctx, true); - let result = do_write::(ctx, key_ptr, value_ptr); + let result = do_write::(&mut ctx, key_ptr, value_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -496,11 +507,11 @@ mod test { let key_ptr = write_data(&mut instance, existing_key); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - do_remove::(ctx, key_ptr).unwrap(); + do_remove::(&mut ctx, key_ptr).unwrap(); - let value = with_storage_from_context::(ctx, |store| { + let value = with_storage_from_context::(&mut ctx, |store| { Ok(store.get(existing_key).0.expect("error getting value")) }) .unwrap(); @@ -515,12 +526,12 @@ mod test { let key_ptr = write_data(&mut instance, non_existent_key); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); // Note: right now we cannot differnetiate between an existent and a non-existent key - do_remove::(ctx, key_ptr).unwrap(); + do_remove::(&mut ctx, key_ptr).unwrap(); - let value = with_storage_from_context::(ctx, |store| { + let value = with_storage_from_context::(&mut ctx, |store| { Ok(store.get(non_existent_key).0.expect("error getting value")) }) .unwrap(); @@ -534,9 +545,9 @@ mod test { let key_ptr = write_data(&mut instance, &vec![26u8; 300 * 1024]); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let result = do_remove::(ctx, key_ptr); + let result = do_remove::(&mut ctx, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -558,10 +569,10 @@ mod test { let key_ptr = write_data(&mut instance, b"a storage key"); let ctx = instance.context_mut(); - leave_default_data(ctx); - set_storage_readonly::(ctx, true); + leave_default_data(&mut ctx); + set_storage_readonly::(&mut ctx, true); - let result = do_remove::(ctx, key_ptr); + let result = do_remove::(&mut ctx, key_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -576,11 +587,11 @@ mod test { let dest_ptr = create_empty(&mut instance, 8); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new(8); - do_canonicalize_address::(api, ctx, source_ptr, dest_ptr).unwrap(); - assert_eq!(force_read(ctx, dest_ptr), b"foo\0\0\0\0\0"); + do_canonicalize_address::(api, &mut ctx, source_ptr, dest_ptr).unwrap(); + assert_eq!(force_read(&mut ctx, dest_ptr), b"foo\0\0\0\0\0"); } #[test] @@ -593,22 +604,25 @@ mod test { let dest_ptr = create_empty(&mut instance, 8); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new(8); - let res = do_canonicalize_address::(api, ctx, source_ptr1, dest_ptr).unwrap(); + let res = + do_canonicalize_address::(api, &mut ctx, 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(&mut ctx, 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, &mut ctx, 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(&mut ctx, 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, &mut ctx, 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(&mut ctx, res)).unwrap(); assert_eq!(err, "Invalid input: human address too long"); } @@ -620,10 +634,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 7); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new_failing(8, "Temporarily unavailable"); - let result = do_canonicalize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &mut ctx, source_ptr, dest_ptr); match result.unwrap_err() { VmError::FfiErr { source: FfiError::Unknown { msg, .. }, @@ -642,10 +656,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 8); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new(8); - let result = do_canonicalize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &mut ctx, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -668,10 +682,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 7); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new(8); - let result = do_canonicalize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &mut ctx, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionTooSmall { size, required, .. }, @@ -691,12 +705,13 @@ mod test { let dest_ptr = create_empty(&mut instance, 50); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new(8); - let error_ptr = do_humanize_address::(api, ctx, source_ptr, dest_ptr).unwrap(); + let error_ptr = + do_humanize_address::(api, &mut ctx, source_ptr, dest_ptr).unwrap(); assert_eq!(error_ptr, 0); - assert_eq!(force_read(ctx, dest_ptr), b"foo"); + assert_eq!(force_read(&mut ctx, dest_ptr), b"foo"); } #[test] @@ -707,12 +722,12 @@ mod test { let dest_ptr = create_empty(&mut instance, 50); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new(8); - let res = do_humanize_address::(api, ctx, source_ptr, dest_ptr).unwrap(); + let res = do_humanize_address::(api, &mut ctx, 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(&mut ctx, res)).unwrap(); assert_eq!(err, "Invalid input: canonical address length not correct"); } @@ -724,10 +739,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 50); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new_failing(8, "Temporarily unavailable"); - let result = do_humanize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &mut ctx, source_ptr, dest_ptr); match result.unwrap_err() { VmError::FfiErr { source: FfiError::Unknown { msg, .. }, @@ -744,10 +759,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 50); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new(8); - let result = do_humanize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &mut ctx, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -770,10 +785,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 2); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let api = MockApi::new(8); - let result = do_humanize_address::(api, ctx, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &mut ctx, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionTooSmall { size, required, .. }, @@ -796,10 +811,10 @@ mod test { let request_ptr = write_data(&mut instance, &request_data); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let response_ptr = do_query_chain::(ctx, request_ptr).unwrap(); - let response = force_read(ctx, response_ptr); + let response_ptr = do_query_chain::(&mut ctx, request_ptr).unwrap(); + let response = force_read(&mut ctx, response_ptr); let query_result: cosmwasm_std::QuerierResult = cosmwasm_std::from_slice(&response).unwrap(); @@ -817,10 +832,10 @@ mod test { let request_ptr = write_data(&mut instance, request); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let response_ptr = do_query_chain::(ctx, request_ptr).unwrap(); - let response = force_read(ctx, response_ptr); + let response_ptr = do_query_chain::(&mut ctx, request_ptr).unwrap(); + let response = force_read(&mut ctx, response_ptr); let query_result: cosmwasm_std::QuerierResult = cosmwasm_std::from_slice(&response).unwrap(); @@ -845,10 +860,10 @@ mod test { let request_ptr = write_data(&mut instance, &request_data); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let response_ptr = do_query_chain::(ctx, request_ptr).unwrap(); - let response = force_read(ctx, response_ptr); + let response_ptr = do_query_chain::(&mut ctx, request_ptr).unwrap(); + let response = force_read(&mut ctx, response_ptr); let query_result: cosmwasm_std::QuerierResult = cosmwasm_std::from_slice(&response).unwrap(); @@ -866,22 +881,22 @@ mod test { fn do_scan_unbound_works() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); // set up iterator over all space - let id = do_scan::(ctx, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan::(&mut ctx, 0, 0, Order::Ascending.into()).unwrap(); assert_eq!(1, id); - let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); - let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) + .unwrap(); assert!(item.0.unwrap().is_none()); } @@ -890,22 +905,22 @@ mod test { fn do_scan_unbound_descending_works() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); // set up iterator over all space - let id = do_scan::(ctx, 0, 0, Order::Descending.into()).unwrap(); + let id = do_scan::(&mut ctx, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(1, id); - let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); - let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) + .unwrap(); assert!(item.0.unwrap().is_none()); } @@ -918,16 +933,16 @@ mod test { let end = write_data(&mut instance, b"bert"); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let id = do_scan::(ctx, start, end, Order::Ascending.into()).unwrap(); + let id = do_scan::(&mut ctx, start, end, Order::Ascending.into()).unwrap(); - let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) + .unwrap(); assert!(item.0.unwrap().is_none()); } @@ -936,37 +951,42 @@ mod test { fn do_scan_multiple_iterators() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); // 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::(&mut ctx, 0, 0, Order::Ascending.into()).unwrap(); + let id2 = do_scan::(&mut ctx, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(id1, 1); assert_eq!(id2, 2); // first item, first iterator let item = - with_iterator_from_context::(ctx, id1, |iter| Ok(iter.next())).unwrap(); + with_iterator_from_context::(&mut ctx, id1, |iter| Ok(iter.next())) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); // second item, first iterator let item = - with_iterator_from_context::(ctx, id1, |iter| Ok(iter.next())).unwrap(); + with_iterator_from_context::(&mut ctx, id1, |iter| Ok(iter.next())) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); // first item, second iterator let item = - with_iterator_from_context::(ctx, id2, |iter| Ok(iter.next())).unwrap(); + with_iterator_from_context::(&mut ctx, id2, |iter| Ok(iter.next())) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); // end, first iterator let item = - with_iterator_from_context::(ctx, id1, |iter| Ok(iter.next())).unwrap(); + with_iterator_from_context::(&mut ctx, id1, |iter| Ok(iter.next())) + .unwrap(); assert!(item.0.unwrap().is_none()); // second item, second iterator let item = - with_iterator_from_context::(ctx, id2, |iter| Ok(iter.next())).unwrap(); + with_iterator_from_context::(&mut ctx, id2, |iter| Ok(iter.next())) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); } @@ -975,10 +995,10 @@ mod test { fn do_scan_errors_for_invalid_order_value() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); // set up iterator over all space - let result = do_scan::(ctx, 0, 0, 42); + let result = do_scan::(&mut ctx, 0, 0, 42); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::InvalidOrder { .. }, @@ -993,27 +1013,27 @@ mod test { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); - let id = do_scan::(ctx, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan::(&mut ctx, 0, 0, Order::Ascending.into()).unwrap(); // Entry 1 - let kv_region_ptr = do_next::(ctx, id).unwrap(); + let kv_region_ptr = do_next::(&mut ctx, id).unwrap(); assert_eq!( - force_read(ctx, kv_region_ptr), + force_read(&mut ctx, 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::(&mut ctx, id).unwrap(); assert_eq!( - force_read(ctx, kv_region_ptr), + force_read(&mut ctx, 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::(&mut ctx, id).unwrap(); + assert_eq!(force_read(&mut ctx, kv_region_ptr), b"\0\0\0\0"); // API makes no guarantees for value_ptr in this case } @@ -1023,10 +1043,10 @@ mod test { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(ctx); + leave_default_data(&mut ctx); let non_existent_id = 42u32; - let result = do_next::(ctx, non_existent_id); + let result = do_next::(&mut ctx, non_existent_id); match result.unwrap_err() { VmError::IteratorDoesNotExist { id, .. } => assert_eq!(id, non_existent_id), e => panic!("Unexpected error: {:?}", e), diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 4882c5804e..4945c30594 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -4,17 +4,13 @@ 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, + imports, module::Module, typed_func::WasmTypeList, vm::Ctx, Instance as WasmerInstance, }; 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, + set_wasmer_instance, with_querier_from_context, with_storage_from_context, }; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; @@ -79,12 +75,9 @@ 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 = deps.api; - import_obj.extend(imports! { + let import_obj = 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. @@ -132,12 +125,6 @@ where "query_chain" => Func::new(move |ctx: &mut Ctx, request_ptr: u32| -> VmResult { do_query_chain::(ctx, request_ptr) }), - }, - }); - - #[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. @@ -145,7 +132,14 @@ where // 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) + #[cfg(feature = "iterator")] + { + do_scan::(ctx, start_ptr, end_ptr, order) + } + #[cfg(not(feature = "iterator"))] + { + Err(VmError::generic_err("Import db_scan not implemented due to missing iterator feature")) + } }), // Get next element of iterator with ID `iterator_id`. // Creates a region containing both key and value and returns its address. @@ -153,10 +147,17 @@ where // 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) + #[cfg(feature = "iterator")] + { + do_next::(ctx, iterator_id) + } + #[cfg(not(feature = "iterator"))] + { + Err(VmError::generic_err("Import db_next not implemented due to missing iterator feature")) + } }), }, - }); + }; let wasmer_instance = Box::from(module.instantiate(&import_obj).map_err(|original| { VmError::instantiation_err(format!("Error instantiating module: {:?}", original)) @@ -169,12 +170,16 @@ where deps: Extern, gas_limit: u64, ) -> Self { - 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(&mut wasmer_instance.context_mut(), gas_limit); + get_gas_state_mut::(&mut wasmer_instance.context_mut()).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(), deps.storage, deps.querier); + set_wasmer_instance::(&mut wasmer_instance.context_mut(), Some(instance_ptr)); + move_into_context( + &mut wasmer_instance.context_mut(), + deps.storage, + deps.querier, + ); Instance { inner: wasmer_instance, api: deps.api, @@ -187,7 +192,7 @@ 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()) { + if let (Some(storage), Some(querier)) = move_out_of_context(&mut self.inner.context_mut()) { Some(Extern { storage, api: self.api, @@ -203,7 +208,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 + (get_memory_info(&self.inner.context()).size as u64) * WASM_PAGE_SIZE } /// Returns the currently remaining gas. @@ -215,8 +220,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 = get_gas_state::(&self.inner.context()).clone(); + let gas_left = get_gas_left(&self.inner.context()); GasReport { limit: state.gas_limit, remaining: gas_left, @@ -229,15 +234,15 @@ 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); + set_storage_readonly::(&mut self.inner.context_mut(), new_value); } pub fn with_storage VmResult, T>(&mut self, func: F) -> VmResult { - with_storage_from_context::(self.inner.context_mut(), func) + with_storage_from_context::(&mut self.inner.context_mut(), func) } pub fn with_querier VmResult, T>(&mut self, func: F) -> VmResult { - with_querier_from_context::(self.inner.context_mut(), func) + with_querier_from_context::(&mut self.inner.context_mut(), func) } /// Requests memory allocation by the instance and returns a pointer @@ -262,19 +267,19 @@ where /// 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.inner.context(), 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.inner.context(), region_ptr, data)?; Ok(()) } - pub(crate) fn func(&self, name: &str) -> VmResult> + pub(crate) fn func(&self, name: &str) -> VmResult> where - Args: WasmTypeList, - Rets: WasmTypeList, + Args: WasmTypeList + Clone, + Rets: WasmTypeList + Clone, { let function = self.inner.exports.get(name)?; Ok(function) @@ -575,25 +580,25 @@ mod test { let mut instance = mock_instance(&CONTRACT, &[]); assert_eq!( - is_storage_readonly::(instance.inner.context()), + is_storage_readonly::(&instance.inner.context()), true ); instance.set_storage_readonly(false); assert_eq!( - is_storage_readonly::(instance.inner.context()), + is_storage_readonly::(&instance.inner.context()), false ); instance.set_storage_readonly(false); assert_eq!( - is_storage_readonly::(instance.inner.context()), + is_storage_readonly::(&instance.inner.context()), false ); instance.set_storage_readonly(true); assert_eq!( - is_storage_readonly::(instance.inner.context()), + is_storage_readonly::(&instance.inner.context()), true ); } diff --git a/packages/vm/src/memory.rs b/packages/vm/src/memory.rs index e8cdf48776..02b7be372b 100644 --- a/packages/vm/src/memory.rs +++ b/packages/vm/src/memory.rs @@ -1,3 +1,4 @@ +use wasm_common::MemoryIndex; use wasmer_runtime_core::{ memory::ptr::{Array, WasmPtr}, types::ValueType, @@ -49,15 +50,17 @@ pub struct MemoryInfo { /// 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(); + let memory_type = (*ctx.module_info) + .memories + .get(MemoryIndex::from_u32(0)) + .unwrap(); MemoryInfo { descriptor: MemoryDescriptor { - minimum: descriptor.minimum.0, - maximum: descriptor.maximum.map(|pages| pages.0), - shared: descriptor.shared, + minimum: memory_type.minimum.0, + maximum: memory_type.maximum.map(|pages| pages.0), + shared: memory_type.shared, }, - size: memory.size().0, + size: 0, } } diff --git a/packages/vm/src/modules.rs b/packages/vm/src/modules.rs index d133313eb8..54433f53ec 100644 --- a/packages/vm/src/modules.rs +++ b/packages/vm/src/modules.rs @@ -8,9 +8,9 @@ use std::{ path::PathBuf, }; -use wasmer_runtime_core::{cache::Artifact, module::Module}; +use wasmer_runtime_core::{cache::Artifact, load_cache_with, module::Module}; -use crate::backends::{backend, compiler_for_backend}; +use crate::backends::backend; use crate::checksum::Checksum; use crate::errors::{VmError, VmResult}; @@ -71,20 +71,12 @@ impl FileSystemCache { .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 module = unsafe { load_cache_with(serialized_cache) }?; Ok(module) } 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(backend()); fs::create_dir_all(&modules_dir) .map_err(|e| VmError::cache_err(format!("Error creating direcory: {}", e)))?; @@ -126,9 +118,6 @@ mod tests { let module = compile(&wasm).unwrap(); - // assert we are using the proper backend - assert_eq!(backend().to_string(), module.info().backend.to_string()); - let cache_dir = env::temp_dir(); let mut fs_cache = unsafe { FileSystemCache::new(cache_dir).unwrap() }; From 94102a7c8497317a305f5fa1a529575f848bb9cc Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 8 Sep 2020 10:15:40 +0200 Subject: [PATCH 004/110] Update to latest master of Wasmer --- Cargo.lock | 58 +++++++++++++++++++-------------------- packages/vm/Cargo.toml | 10 +++---- packages/vm/src/memory.rs | 2 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d0e41e1cf..a215db182b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,11 +175,11 @@ dependencies = [ "snafu", "tempfile", "wabt", - "wasm-common", "wasmer", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-runtime-core", + "wasmer-types", ] [[package]] @@ -1140,29 +1140,21 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasm-common" -version = "1.0.0-alpha.1" -dependencies = [ - "cranelift-entity", - "serde", -] - [[package]] name = "wasmer" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "cfg-if", "indexmap", "more-asserts", "target-lexicon", "thiserror", - "wasm-common", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-engine", "wasmer-engine-jit", "wasmer-engine-native", + "wasmer-types", "wasmer-vm", "wat", "winapi", @@ -1170,7 +1162,7 @@ dependencies = [ [[package]] name = "wasmer-cache" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "blake3", "hex", @@ -1181,7 +1173,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "enumset", "raw-cpuid", @@ -1190,14 +1182,14 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror", - "wasm-common", + "wasmer-types", "wasmer-vm", "wasmparser", ] [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1206,14 +1198,14 @@ dependencies = [ "rayon", "serde", "tracing", - "wasm-common", "wasmer-compiler", + "wasmer-types", "wasmer-vm", ] [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "byteorder", "dynasm", @@ -1223,14 +1215,14 @@ dependencies = [ "rayon", "serde", "smallvec", - "wasm-common", "wasmer-compiler", + "wasmer-types", "wasmer-vm", ] [[package]] name = "wasmer-engine" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "backtrace", "bincode", @@ -1241,30 +1233,30 @@ dependencies = [ "serde_bytes", "target-lexicon", "thiserror", - "wasm-common", "wasmer-compiler", + "wasmer-types", "wasmer-vm", ] [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "bincode", "cfg-if", "region", "serde", "serde_bytes", - "wasm-common", "wasmer-compiler", "wasmer-engine", + "wasmer-types", "wasmer-vm", "winapi", ] [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "bincode", "cfg-if", @@ -1273,21 +1265,21 @@ dependencies = [ "serde", "tempfile", "tracing", - "wasm-common", "wasmer-compiler", "wasmer-engine", "wasmer-object", + "wasmer-types", "wasmer-vm", ] [[package]] name = "wasmer-object" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "object", "thiserror", - "wasm-common", "wasmer-compiler", + "wasmer-types", ] [[package]] @@ -1296,18 +1288,26 @@ version = "0.18.0" dependencies = [ "blake3", "lazy_static", - "wasm-common", "wasmer", "wasmer-cache", "wasmer-compiler", "wasmer-engine", "wasmer-engine-jit", + "wasmer-types", "wasmer-vm", ] +[[package]] +name = "wasmer-types" +version = "1.0.0-alpha01.0" +dependencies = [ + "cranelift-entity", + "serde", +] + [[package]] name = "wasmer-vm" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha01.0" dependencies = [ "backtrace", "cc", @@ -1319,7 +1319,7 @@ dependencies = [ "region", "serde", "thiserror", - "wasm-common", + "wasmer-types", "winapi", ] diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 53c5269567..ca86d5aefb 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -33,11 +33,11 @@ staking = ["cosmwasm-std/staking"] # Uses the path when built locally; uses the given version from crates.io when published cosmwasm-std = { path = "../std", version = "0.10.1" } serde_json = "1.0" -wasm-common = { path = "../../../wasmer-reborn/lib/wasm-common" } -wasmer = { path = "../../../wasmer-reborn/lib/api" } -wasmer-runtime-core = { path = "../../../wasmer-reborn/lib/deprecated/runtime-core" } -wasmer-compiler-cranelift = { path = "../../../wasmer-reborn/lib/compiler-cranelift", optional = true } -wasmer-compiler-singlepass = { path = "../../../wasmer-reborn/lib/compiler-singlepass", optional = true } +wasmer = { path = "../../../wasmer/lib/api" } +wasmer-compiler-cranelift = { path = "../../../wasmer/lib/compiler-cranelift", optional = true } +wasmer-compiler-singlepass = { path = "../../../wasmer/lib/compiler-singlepass", optional = true } +wasmer-runtime-core = { path = "../../../wasmer/lib/deprecated/runtime-core" } +wasmer-types = { path = "../../../wasmer/lib/wasmer-types" } schemars = "0.7" serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } snafu = { version = "0.6.3" } diff --git a/packages/vm/src/memory.rs b/packages/vm/src/memory.rs index 02b7be372b..d140e6df8b 100644 --- a/packages/vm/src/memory.rs +++ b/packages/vm/src/memory.rs @@ -1,9 +1,9 @@ -use wasm_common::MemoryIndex; use wasmer_runtime_core::{ memory::ptr::{Array, WasmPtr}, types::ValueType, vm::Ctx, }; +use wasmer_types::MemoryIndex; use crate::conversion::to_u32; use crate::errors::{ From cadafc5486ebb479d902e5c50b3634e513cc3007 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 8 Sep 2020 10:30:37 +0200 Subject: [PATCH 005/110] Update Wasmer error handling --- packages/vm/src/backends/singlepass.rs | 5 ++-- packages/vm/src/errors/vm_error.rs | 33 ++++++++------------------ 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/packages/vm/src/backends/singlepass.rs b/packages/vm/src/backends/singlepass.rs index 4ff6f4bb41..077a7f169f 100644 --- a/packages/vm/src/backends/singlepass.rs +++ b/packages/vm/src/backends/singlepass.rs @@ -9,7 +9,7 @@ use wasmer_runtime_core::{ vm::Ctx, }; -use crate::errors::VmResult; +use crate::errors::{VmError, VmResult}; // use crate::middleware::DeterministicMiddleware; /// In Wasmer, the gas limit is set on modules during compilation and is included in the cached modules. @@ -26,8 +26,7 @@ const MAX_GAS_LIMIT: u64 = u64::MAX / 2; const FAKE_GAS_AVAILABLE: u64 = 1_000_000; pub fn compile(code: &[u8]) -> VmResult { - let module = compile_with(code, Backend::Auto)?; - Ok(module) + compile_with(code, Backend::Auto).map_err(|err| VmError::compile_err(err.to_string())) } pub fn compiler() -> Box { diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index 83d6b4ef9a..809dabcae4 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -199,34 +199,15 @@ impl From for VmError { } } -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_runtime_core::error::ExportError) -> Self { + VmError::resolve_err(format!("Wasmer export error: {:?}", 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)) - } - - 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), - } + VmError::runtime_err(format!("Wasmer runtime error: {:?}", original)) } } @@ -236,6 +217,12 @@ impl From for VmError { } } +impl From for VmError { + fn from(_original: std::convert::Infallible) -> Self { + unreachable!(); + } +} + #[cfg(test)] mod test { use super::*; From cc94242b4a40535c11bf903cce88aaa2ed925664 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 14 Sep 2020 11:27:29 +0200 Subject: [PATCH 006/110] Make VM compile (no iterator or tests) --- Cargo.lock | 79 +---- packages/vm/Cargo.toml | 4 +- packages/vm/src/backends/cranelift.rs | 20 +- packages/vm/src/backends/mod.rs | 31 +- packages/vm/src/backends/singlepass.rs | 33 +-- packages/vm/src/calls.rs | 22 +- packages/vm/src/context.rs | 381 +++++++++++++----------- packages/vm/src/errors/vm_error.rs | 35 ++- packages/vm/src/features.rs | 10 +- packages/vm/src/imports.rs | 395 ++++++++++++------------- packages/vm/src/instance.rs | 222 ++++++++------ packages/vm/src/memory.rs | 72 +---- packages/vm/src/modules.rs | 22 +- 13 files changed, 623 insertions(+), 703 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a215db182b..236838e9b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,17 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" - [[package]] name = "autocfg" version = "1.0.0" @@ -62,21 +50,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake3" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce4f9586c9a3151c4b49b19e82ba163dd073614dd057e53c969e1a4db5b52720" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", - "crypto-mac", - "digest", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -124,12 +97,6 @@ dependencies = [ "cc", ] -[[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.10.1" @@ -176,9 +143,11 @@ dependencies = [ "tempfile", "wabt", "wasmer", + "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", - "wasmer-runtime-core", + "wasmer-engine", + "wasmer-engine-jit", "wasmer-types", ] @@ -310,16 +279,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", - "subtle", -] - [[package]] name = "darling" version = "0.10.2" @@ -994,12 +953,6 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" -[[package]] -name = "subtle" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "502d53007c02d7605a05df1c1a73ee436952781653da5d0bf57ad608f66932c1" - [[package]] name = "syn" version = "1.0.16" @@ -1160,17 +1113,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "wasmer-cache" -version = "1.0.0-alpha01.0" -dependencies = [ - "blake3", - "hex", - "memmap", - "thiserror", - "wasmer", -] - [[package]] name = "wasmer-compiler" version = "1.0.0-alpha01.0" @@ -1282,21 +1224,6 @@ dependencies = [ "wasmer-types", ] -[[package]] -name = "wasmer-runtime-core" -version = "0.18.0" -dependencies = [ - "blake3", - "lazy_static", - "wasmer", - "wasmer-cache", - "wasmer-compiler", - "wasmer-engine", - "wasmer-engine-jit", - "wasmer-types", - "wasmer-vm", -] - [[package]] name = "wasmer-types" version = "1.0.0-alpha01.0" diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index ca86d5aefb..e7709c02c5 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -34,9 +34,11 @@ staking = ["cosmwasm-std/staking"] cosmwasm-std = { path = "../std", version = "0.10.1" } serde_json = "1.0" wasmer = { path = "../../../wasmer/lib/api" } +wasmer-compiler = { path = "../../../wasmer/lib/compiler" } wasmer-compiler-cranelift = { path = "../../../wasmer/lib/compiler-cranelift", optional = true } wasmer-compiler-singlepass = { path = "../../../wasmer/lib/compiler-singlepass", optional = true } -wasmer-runtime-core = { path = "../../../wasmer/lib/deprecated/runtime-core" } +wasmer-engine = { path = "../../../wasmer/lib/engine" } +wasmer-engine-jit = { path = "../../../wasmer/lib/engine-jit" } wasmer-types = { path = "../../../wasmer/lib/wasmer-types" } schemars = "0.7" serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } diff --git a/packages/vm/src/backends/cranelift.rs b/packages/vm/src/backends/cranelift.rs index 128032821f..5fe18b5340 100644 --- a/packages/vm/src/backends/cranelift.rs +++ b/packages/vm/src/backends/cranelift.rs @@ -1,9 +1,8 @@ #![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 wasmer::Module; +use wasmer_compiler_cranelift::Cranelift; +use wasmer_engine_jit::JIT; use crate::errors::VmResult; @@ -14,22 +13,21 @@ pub fn compile(code: &[u8]) -> VmResult { 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)?; + let compiler = Cranelift::default(); + let engine = JIT::new(&mut compiler).engine(); + let store = Store::new(&engine); + let module = Module::new(&store, code)?; Ok(module) } -pub fn compiler() -> Box { - Box::new(CraneliftCompiler::new()) -} - pub fn backend() -> &'static str { "cranelift" } /// Set the amount of gas units that can be used in the context. -pub fn set_gas_left(_ctx: &mut Ctx, _amount: u64) {} +pub fn set_gas_left(_env: &mut Env, _amount: u64) {} /// Get how many more gas units can be used in the context. -pub fn get_gas_left(_ctx: &Ctx) -> u64 { +pub fn get_gas_left(_env: &Env) -> u64 { FAKE_GAS_AVAILABLE } diff --git a/packages/vm/src/backends/mod.rs b/packages/vm/src/backends/mod.rs index b799aee312..01d41924aa 100644 --- a/packages/vm/src/backends/mod.rs +++ b/packages/vm/src/backends/mod.rs @@ -1,20 +1,8 @@ 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, - } -} +use crate::context::Env; +use crate::traits::{Querier, Storage}; #[derive(Debug)] pub struct InsufficientGasLeft; @@ -22,13 +10,16 @@ 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); +pub fn decrease_gas_left( + env: &mut Env, + amount: u64, +) -> Result<(), InsufficientGasLeft> { + let remaining = get_gas_left(env); if amount > remaining { - set_gas_left(ctx, 0); + set_gas_left(env, 0); Err(InsufficientGasLeft) } else { - set_gas_left(ctx, remaining - amount); + set_gas_left(env, remaining - amount); Ok(()) } } @@ -44,12 +35,12 @@ pub use singlepass::{backend, compile, get_gas_left, set_gas_left}; mod test { use super::*; use wabt::wat2wasm; - use wasmer_runtime_core::{imports, Instance as WasmerInstance}; + use wasmer::{imports, Instance as WasmerInstance}; fn instantiate(code: &[u8]) -> WasmerInstance { let module = compile(code).unwrap(); let import_obj = imports! { "env" => {}, }; - module.instantiate(&import_obj).unwrap() + WasmerInstance::new(&module, &import_obj).unwrap() } #[test] diff --git a/packages/vm/src/backends/singlepass.rs b/packages/vm/src/backends/singlepass.rs index 077a7f169f..6608249dbd 100644 --- a/packages/vm/src/backends/singlepass.rs +++ b/packages/vm/src/backends/singlepass.rs @@ -1,15 +1,13 @@ #![cfg(any(feature = "singlepass", feature = "default-singlepass"))] // use wasmer_middleware_common::metering; -use wasmer_compiler_singlepass::{Singlepass, SinglepassCompiler}; -use wasmer_runtime_core::{ - backend::{Backend, Compiler}, - compile_with, - module::Module, - vm::Ctx, -}; - -use crate::errors::{VmError, VmResult}; +use wasmer::{Module, Store}; +use wasmer_compiler_singlepass::Singlepass; +use wasmer_engine_jit::JIT; + +use crate::context::Env; +use crate::errors::VmResult; +use crate::traits::{Querier, Storage}; // use crate::middleware::DeterministicMiddleware; /// In Wasmer, the gas limit is set on modules during compilation and is included in the cached modules. @@ -26,12 +24,11 @@ const MAX_GAS_LIMIT: u64 = u64::MAX / 2; const FAKE_GAS_AVAILABLE: u64 = 1_000_000; pub fn compile(code: &[u8]) -> VmResult { - compile_with(code, Backend::Auto).map_err(|err| VmError::compile_err(err.to_string())) -} - -pub fn compiler() -> Box { - let config = Singlepass::default(); - Box::new(SinglepassCompiler::new(&config)) + let compiler = Singlepass::default(); + let engine = JIT::new(&compiler).engine(); + let store = Store::new(&engine); + let module = Module::new(&store, code)?; + Ok(module) } pub fn backend() -> &'static str { @@ -39,10 +36,10 @@ pub fn backend() -> &'static str { } /// Set the amount of gas units that can be used in the context. -pub fn set_gas_left(_ctx: &mut Ctx, _amount: u64) {} +pub fn set_gas_left(_env: &mut Env, _amount: u64) {} /// Get how many more gas units can be used in the context. -pub fn get_gas_left(_ctx: &Ctx) -> u64 { +pub fn get_gas_left(_env: &Env) -> u64 { FAKE_GAS_AVAILABLE } @@ -70,7 +67,7 @@ pub fn get_gas_left(_ctx: &Ctx) -> u64 { mod test { use super::*; use wabt::wat2wasm; - use wasmer_runtime_core::{imports, Instance as WasmerInstance}; + use wasmer::{imports, Instance as WasmerInstance}; fn instantiate(code: &[u8]) -> WasmerInstance { let module = compile(code).unwrap(); diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs index d39fda5920..bdb0d0aee7 100644 --- a/packages/vm/src/calls.rs +++ b/packages/vm/src/calls.rs @@ -2,9 +2,10 @@ use serde::de::DeserializeOwned; use std::fmt; use cosmwasm_std::{Env, HandleResult, InitResult, MigrateResult, QueryResult}; +use wasmer::Val; use crate::errors::{VmError, VmResult}; -use crate::instance::{Func, Instance}; +use crate::instance::Instance; use crate::serde::{from_slice, to_vec}; use crate::traits::{Api, Querier, Storage}; use schemars::JsonSchema; @@ -131,25 +132,14 @@ fn call_raw( 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])? - } - _ => panic!("call_raw called with unsupported number of arguments"), - }; - + let result = instance.call_function(name, &arg_region_ptrs)?; + let res_region_ptr = result[0].unwrap_i32() as u32; 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 index 7c15af4652..cbdc5b7a83 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -1,18 +1,15 @@ //! Internal details to be used by instance.rs only +use std::borrow::{Borrow, BorrowMut}; #[cfg(feature = "iterator")] use std::collections::HashMap; #[cfg(feature = "iterator")] use std::convert::TryInto; -use std::ffi::c_void; #[cfg(not(feature = "iterator"))] use std::marker::PhantomData; use std::ptr::NonNull; +use std::sync::{Arc, RwLock}; -use wasmer_runtime_core::{ - typed_func::{Func, WasmTypeList}, - vm::Ctx, - Instance as WasmerInstance, -}; +use wasmer::{Function, Instance as WasmerInstance}; use crate::backends::decrease_gas_left; use crate::errors::{VmError, VmResult}; @@ -70,7 +67,87 @@ impl GasState { } } -struct ContextData<'a, S: Storage, Q: Querier> { +// #[derive(Clone)] +pub struct Env { + pub memory: wasmer::Memory, + pub context_data: Arc>>, +} + +impl Clone for Env { + fn clone(&self) -> Self { + Env { + memory: self.memory.clone(), + context_data: self.context_data.clone(), + } + } +} + +impl Env { + /// Get a mutable reference to the context's data. Ownership remains in the Context. + // NOTE: This is actually not really implemented safely at the moment. I did this as a + // nicer and less-terrible version of the previous solution to the following issue: + // + // +--->> Go pointer + // | + // Env ->> ContextData +-> iterators: Box --+ + // | | + // +-> storage: impl Storage <<------------+ + // | + // +-> querier: impl Querier + // + // -> : Ownership + // ->> : Mutable borrow + // + // As you can see, there's a cyclical reference here... changing this function to return the same lifetime as it + // returns (and adjusting a few other functions to only have one lifetime instead of two) triggers an error + // elsewhere where we try to add iterators to the context. That's not legal according to Rust's rules, and it + // complains that we're trying to borrow ctx mutably twice. This needs a better solution because this function + // probably triggers unsoundness. + // pub fn get_context_data_mut(&mut self) -> &mut ContextData { + // let mut guard = self.context_data.as_ref().write().unwrap(); + // guard.borrow_mut() + // } + + pub fn with_context_data_mut( + &mut self, + callback: Callback, + ) -> CallbackReturn + where + Callback: FnOnce(&mut ContextData) -> CallbackReturn, + { + let mut guard = self.context_data.as_ref().write().unwrap(); + let context_data = guard.borrow_mut(); + callback(context_data) + } + + pub fn with_context_data(&self, callback: Callback) -> CallbackReturn + where + Callback: FnOnce(&ContextData) -> CallbackReturn, + { + let guard = self.context_data.as_ref().read().unwrap(); + let context_data = guard.borrow(); + callback(context_data) + } + + pub fn with_gas_state_mut( + &mut self, + callback: Callback, + ) -> CallbackReturn + where + Callback: FnOnce(&mut GasState) -> CallbackReturn, + { + self.with_context_data_mut(|context_data| callback(&mut context_data.gas_state)) + } + + pub fn with_gas_state(&self, callback: Callback) -> CallbackReturn + where + Callback: FnOnce(&GasState) -> CallbackReturn, + { + self.with_context_data(|context_data| callback(&context_data.gas_state)) + } +} + +pub struct ContextData { gas_state: GasState, storage: Option, storage_readonly: bool, @@ -80,88 +157,33 @@ struct ContextData<'a, S: Storage, Q: Querier> { #[cfg(feature = "iterator")] iterators: HashMap>, #[cfg(not(feature = "iterator"))] - iterators: PhantomData<&'a mut ()>, -} - -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, - #[cfg(feature = "iterator")] - iterators: HashMap::new(), - #[cfg(not(feature = "iterator"))] - iterators: PhantomData::default(), - }; - let heap_data = Box::new(data); // move from stack to heap - Box::into_raw(heap_data) as *mut c_void // give up ownership + iterators: PhantomData<()>, } -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 mut dying = unsafe { Box::from_raw(ptr as *mut ContextData) }; - // Ensure all iterators are dropped before the storage - destroy_iterators(&mut dying); - } -} - -/// Get a mutable reference to the context's data. Ownership remains in the Context. -// NOTE: This is actually not really implemented safely at the moment. I did this as a -// nicer and less-terrible version of the previous solution to the following issue: -// -// +--->> Go pointer -// | -// Ctx ->> ContextData +-> iterators: Box --+ -// | | -// +-> storage: impl Storage <<------------+ -// | -// +-> querier: impl Querier -// -// -> : Ownership -// ->> : Mutable borrow -// -// As you can see, there's a cyclical reference here... changing this function to return the same lifetime as it -// returns (and adjusting a few other functions to only have one lifetime instead of two) triggers an error -// elsewhere where we try to add iterators to the context. That's not legal according to Rust's rules, and it -// complains that we're trying to borrow ctx mutably twice. This needs a better solution because this function -// probably triggers unsoundness. -fn get_context_data_mut<'a, 'b, S: Storage, Q: Querier>( - ctx: &'a mut Ctx, -) -> &'b mut ContextData<'b, S, Q> { - 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<'b, S, Q> { - 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.") +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, + #[cfg(feature = "iterator")] + iterators: HashMap::new(), + #[cfg(not(feature = "iterator"))] + iterators: PhantomData::default(), + } } } /// Creates a back reference from a contact to its partent instance pub fn set_wasmer_instance( - ctx: &mut Ctx, + env: &mut Env, wasmer_instance: Option>, ) { - let context_data = ctx.data as *mut ContextData; - unsafe { - (*context_data).wasmer_instance = wasmer_instance; - } + env.with_context_data_mut(|context_data| { + context_data.wasmer_instance = wasmer_instance; + }); } #[cfg(feature = "iterator")] @@ -175,38 +197,37 @@ fn destroy_iterators(_context: &mut ContextData) { /// 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, + env: &mut Env, ) -> (Option, Option) { - let mut b = get_context_data_mut::(source); - // Destroy all existing iterators which are (in contrast to the storage) - // not reused between different instances. - // This is also important because the iterators are pointers to Go memory which should not be stored long term - // Paragraphs 5-7: https://golang.org/cmd/cgo/#hdr-Passing_pointers - destroy_iterators(&mut b); - (b.storage.take(), b.querier.take()) + env.with_context_data_mut(|context_data| { + // Destroy all existing iterators which are (in contrast to the storage) + // not reused between different instances. + // This is also important because the iterators are pointers to Go memory which should not be stored long term + // Paragraphs 5-7: https://golang.org/cmd/cgo/#hdr-Passing_pointers + destroy_iterators(context_data); + (context_data.storage.take(), context_data.querier.take()) + }) } -/// Moves owned instances of storage and querier into the context. +/// Moves owned instances of storage and querier into the env. /// 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, 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, Q: Querier + 'b>(ctx: &'a Ctx) -> &'b GasState { - &get_context_data::(ctx).gas_state +pub(crate) fn move_into_context( + env: &mut Env, + 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(ctx: &mut Ctx, info: GasInfo) -> VmResult<()> { - decrease_gas_left(ctx, info.cost)?; - account_for_externally_used_gas::(ctx, info.externally_used)?; +pub fn process_gas_info( + env: &mut Env, + info: GasInfo, +) -> VmResult<()> { + decrease_gas_left(env, info.cost)?; + account_for_externally_used_gas(env, info.externally_used)?; Ok(()) } @@ -214,41 +235,42 @@ pub fn process_gas_info(ctx: &mut Ctx, info: GasInfo) -> /// 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, + env: &mut Env, amount: u64, ) -> VmResult<()> { - account_for_externally_used_gas_impl::(ctx, amount) + account_for_externally_used_gas_impl(env, amount) } #[cfg(feature = "default-singlepass")] fn account_for_externally_used_gas_impl( - ctx: &mut Ctx, + env: &mut Env, 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; + // WFT?! + let mut env1 = env.clone(); + let env2 = env.clone(); + let mut env3 = env.clone(); + + env1.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(&instance.context())); + let wasmer_used_gas = gas_state.get_gas_used_in_wasmer(get_gas_left(&env2)); 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(&mut instance.context_mut(), new_limit); + set_gas_left(&mut env3, 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")] @@ -260,14 +282,14 @@ fn account_for_externally_used_gas_impl( } /// 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 is_storage_readonly(env: &Env) -> bool { + env.with_context_data(|context_data| 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 fn set_storage_readonly(env: &mut Env, new_value: bool) { + env.with_context_data_mut(|context_data| { + context_data.storage_readonly = new_value; + }) } /// Add the iterator to the context's data. A new ID is assigned and returned. @@ -275,93 +297,90 @@ pub fn set_storage_readonly(ctx: &mut Ctx, new_value: bo #[cfg(feature = "iterator")] #[must_use = "without the returned iterator ID, the iterator cannot be accessed"] pub fn add_iterator<'a, S: Storage, Q: Querier>( - ctx: &mut Ctx, + env: &mut Env, iter: Box, ) -> u32 { - let b = get_context_data_mut::(ctx); - let last_id: u32 = b - .iterators - .len() - .try_into() - .expect("Found more iterator IDs than supported"); - let new_id = last_id + 1; - if new_id > (i32::MAX as u32) { - panic!("Iterator ID exceeded i32::MAX. This must not happen."); - } - b.iterators.insert(new_id, iter); - new_id + env.with_context_data_mut(|context_data| { + let last_id: u32 = context_data + .iterators + .len() + .try_into() + .expect("Found more iterator IDs than supported"); + let new_id = last_id + 1; + if new_id > (i32::MAX as u32) { + panic!("Iterator ID exceeded i32::MAX. This must not happen."); + } + context_data.iterators.insert(new_id, iter); + new_id + }) } -pub(crate) fn with_func_from_context( - ctx: &mut Ctx, +// TODO: move into Env +pub(crate) fn with_func_from_context( + mut env: Env, name: &str, callback: Callback, ) -> VmResult where S: Storage, Q: Querier, - Args: WasmTypeList + Clone, - Rets: WasmTypeList + Clone, - Callback: FnOnce(Func) -> VmResult, + Callback: FnOnce(&Function) -> VmResult, { - let ctx_data = get_context_data::(ctx); - match ctx_data.wasmer_instance { + env.with_context_data_mut(|context_data| match context_data.wasmer_instance { Some(instance_ptr) => { - let func = unsafe { instance_ptr.as_ref() }.exports.get(name)?; + let func = unsafe { instance_ptr.as_ref() } + .exports + .get_function(name)?; callback(func) } None => Err(VmError::uninitialized_context_data("wasmer_instance")), - } + }) } -pub(crate) fn with_storage_from_context<'a, 'b, S, Q: 'b, F, T>( - ctx: &'a mut Ctx, - func: F, -) -> VmResult +// TODO: move into Env +pub(crate) fn with_storage_from_context(mut env: Env, func: F) -> VmResult where S: Storage, Q: Querier, - F: FnOnce(&'b mut S) -> VmResult, + F: FnOnce(&mut S) -> VmResult, { - let b = get_context_data_mut::(ctx); - match b.storage.as_mut() { + env.with_context_data_mut(|context_data| match context_data.storage.as_mut() { Some(data) => func(data), None => Err(VmError::uninitialized_context_data("storage")), - } + }) } -pub(crate) fn with_querier_from_context<'a, 'b, S, Q: 'b, F, T>( - ctx: &'a mut Ctx, - func: F, -) -> VmResult +// TODO: move into Env +pub(crate) fn with_querier_from_context(mut env: Env, func: F) -> VmResult where S: Storage, Q: Querier, - F: FnOnce(&'b mut Q) -> VmResult, + F: FnOnce(&mut Q) -> VmResult, { - let b = get_context_data_mut::(ctx); - match b.querier.as_mut() { + env.with_context_data_mut(|context_data| match context_data.querier.as_mut() { Some(querier) => func(querier), None => Err(VmError::uninitialized_context_data("querier")), - } + }) } +// TODO: move into Env #[cfg(feature = "iterator")] -pub(crate) fn with_iterator_from_context<'a, 'b, S, Q: 'b, F, T>( - ctx: &'a mut Ctx, +pub(crate) fn with_iterator_from_context( + env: Env, iterator_id: u32, func: F, ) -> VmResult where S: Storage, Q: Querier, - F: FnOnce(&'b mut (dyn StorageIterator + 'b)) -> VmResult, + F: FnOnce(&mut (dyn StorageIterator)) -> VmResult, { - let b = get_context_data_mut::(ctx); - match b.iterators.get_mut(&iterator_id) { - Some(iterator) => func(iterator), - None => Err(VmError::iterator_does_not_exist(iterator_id)), - } + env.with_context_data_mut( + |context_data| match context_data.iterators.get_mut(&iterator_id) { + Some(iterator) => func(iterator), + None => Err(VmError::iterator_does_not_exist(iterator_id)), + }, + ) } #[cfg(test)] @@ -376,7 +395,7 @@ mod test { use cosmwasm_std::{ coins, from_binary, to_vec, AllBalanceResponse, BankQuery, Empty, HumanAddr, QueryRequest, }; - use wasmer_runtime_core::imports; + use wasmer::imports; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); @@ -400,18 +419,18 @@ mod test { // we need stubs for all required imports let import_obj = imports! { "env" => { - "db_read" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - "db_write" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| {}), - "db_remove" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), - "db_scan" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32, _c: i32| -> u32 { 0 }), - "db_next" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - "query_chain" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - "canonicalize_address" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| -> u32 { 0 }), - "humanize_address" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| -> u32 { 0 }), - "debug" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), + // "db_read" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + // "db_write" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| {}), + // "db_remove" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), + // "db_scan" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32, _c: i32| -> u32 { 0 }), + // "db_next" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + // "query_chain" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + // "canonicalize_address" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| -> u32 { 0 }), + // "humanize_address" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| -> u32 { 0 }), + // "debug" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), }, }; - let mut instance = Box::from(module.instantiate(&import_obj).unwrap()); + let mut instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); set_wasmer_instance::(&mut instance.context_mut(), Some(instance_ptr)); diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index 809dabcae4..a209e273e4 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -187,30 +187,36 @@ 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_engine::SerializeError) -> Self { + VmError::cache_err(format!("Could not serialize module: {:?}", original)) } } -impl From for VmError { - fn from(original: wasmer_runtime_core::error::ExportError) -> Self { - VmError::resolve_err(format!("Wasmer export error: {:?}", original)) +impl From for VmError { + fn from(original: wasmer_engine::DeserializeError) -> Self { + VmError::cache_err(format!("Could not deserialize module: {:?}", original)) } } -impl From for VmError { - fn from(original: wasmer_runtime_core::error::RuntimeError) -> Self { +impl From for VmError { + fn from(original: wasmer_engine::RuntimeError) -> Self { VmError::runtime_err(format!("Wasmer runtime error: {:?}", original)) } } +impl From for VmError { + fn from(original: wasmer_compiler::CompileError) -> Self { + VmError::compile_err(format!("Could not compile: {:?}", original)) + } +} + impl From for VmError { fn from(_original: InsufficientGasLeft) -> Self { VmError::GasDepletion @@ -223,6 +229,13 @@ impl From for VmError { } } +impl Into for VmError { + fn into(self) -> wasmer_engine::RuntimeError { + let msg: String = self.to_string(); + wasmer_engine::RuntimeError::new(msg) + } +} + #[cfg(test)] mod test { use super::*; diff --git a/packages/vm/src/features.rs b/packages/vm/src/features.rs index b7f3611fd6..9b1a1402e9 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 261aa47a27..bf6635e964 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -6,14 +6,13 @@ 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::backends::get_gas_left; #[cfg(feature = "iterator")] use crate::context::{add_iterator, with_iterator_from_context}; use crate::context::{ is_storage_readonly, process_gas_info, with_func_from_context, with_querier_from_context, - with_storage_from_context, + with_storage_from_context, Env, }; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; @@ -41,52 +40,52 @@ const MAX_LENGTH_QUERY_CHAIN_REQUEST: usize = 64 * KI; const MAX_LENGTH_DEBUG: usize = 2 * MI; /// 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(&mut ctx, key_ptr, MAX_LENGTH_DB_KEY)?; +pub fn do_read(env: &mut Env, key_ptr: u32) -> VmResult { + let key = read_region(&env.memory, key_ptr, MAX_LENGTH_DB_KEY)?; let (result, gas_info) = - with_storage_from_context::(&mut ctx, |store| Ok(store.get(&key)))?; - process_gas_info::(&mut ctx, gas_info)?; + with_storage_from_context::(env.clone(), |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::(&mut 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, + env: &mut Env, key_ptr: u32, value_ptr: u32, ) -> VmResult<()> { - if is_storage_readonly::(&mut ctx) { + if is_storage_readonly::(env) { return Err(VmError::write_access_denied()); } - let key = read_region(&mut ctx, key_ptr, MAX_LENGTH_DB_KEY)?; - let value = read_region(&mut 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::(&mut ctx, |store| Ok(store.set(&key, &value)))?; - process_gas_info::(&mut ctx, gas_info)?; + with_storage_from_context::(env.clone(), |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::(&mut ctx) { +pub fn do_remove(env: &mut Env, key_ptr: u32) -> VmResult<()> { + if is_storage_readonly::(env) { return Err(VmError::write_access_denied()); } - let key = read_region(&mut 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::(&mut ctx, |store| Ok(store.remove(&key)))?; - process_gas_info::(&mut ctx, gas_info)?; + with_storage_from_context::(env.clone(), |store| Ok(store.remove(&key)))?; + process_gas_info(env, gas_info)?; result?; Ok(()) @@ -94,129 +93,126 @@ pub fn do_remove(ctx: &mut Ctx, key_ptr: u32) -> VmResul pub fn do_canonicalize_address( api: A, - ctx: &mut Ctx, + env: &mut Env, source_ptr: u32, destination_ptr: u32, ) -> VmResult { - let source_data = read_region(&mut 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::(&mut 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::( - &mut 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::(&mut ctx, gas_info)?; + process_gas_info::(env, gas_info)?; match result { Ok(canonical) => { - write_region(&mut ctx, destination_ptr, canonical.as_slice())?; + write_region(&env.memory, destination_ptr, canonical.as_slice())?; Ok(0) } - Err(FfiError::UserErr { msg, .. }) => { - Ok(write_to_contract::(&mut ctx, msg.as_bytes())?) - } + Err(FfiError::UserErr { msg, .. }) => Ok(write_to_contract::(env, msg.as_bytes())?), Err(err) => Err(VmError::from(err)), } } pub fn do_humanize_address( api: A, - ctx: &mut Ctx, + env: &mut Env, source_ptr: u32, destination_ptr: u32, ) -> VmResult { let canonical = Binary(read_region( - &mut ctx, + &env.memory, source_ptr, MAX_LENGTH_CANONICAL_ADDRESS, )?); let (result, gas_info) = api.human_address(&CanonicalAddr(canonical)); - process_gas_info::(&mut ctx, gas_info)?; + process_gas_info::(env, gas_info)?; match result { Ok(human) => { - write_region(&mut ctx, destination_ptr, human.as_str().as_bytes())?; + write_region(&env.memory, destination_ptr, human.as_str().as_bytes())?; Ok(0) } - Err(FfiError::UserErr { msg, .. }) => { - Ok(write_to_contract::(&mut ctx, msg.as_bytes())?) - } + Err(FfiError::UserErr { msg, .. }) => 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)?; +pub fn print_debug_message( + env: &Env, + message_ptr: u32, +) -> VmResult<()> { + let message_data = read_region(&env.memory, message_ptr, MAX_LENGTH_DEBUG)?; let msg = String::from_utf8_lossy(&message_data); println!("{}", msg); Ok(()) } /// Creates a Region in the contract, writes the given data to it and returns the memory location -fn write_to_contract(ctx: &mut Ctx, input: &[u8]) -> VmResult { - let target_ptr = - with_func_from_context::(&mut ctx, "allocate", |allocate| { - let out_size = to_u32(input.len())?; - let ptr = allocate.call(out_size)?; - if ptr == 0 { - return Err(CommunicationError::zero_address().into()); - } - Ok(ptr) - })?; - write_region(&mut ctx, target_ptr, input)?; +fn write_to_contract(env: &Env, input: &[u8]) -> VmResult { + let target_ptr = with_func_from_context::(env.clone(), "allocate", |allocate| { + let out_size = to_u32(input.len())?; + let result = allocate.call(&[out_size.into()])?; + let ptr = result[0].unwrap_i32() as u32; + if ptr == 0 { + return Err(CommunicationError::zero_address().into()); + } + Ok(ptr) + })?; + 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(&mut ctx, request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; +pub fn do_query_chain( + env: &mut Env, + request_ptr: u32, +) -> VmResult { + let request = read_region(&env.memory, request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; - let gas_remaining = get_gas_left(&mut ctx); - let (result, gas_info) = with_querier_from_context::(&mut ctx, |querier| { + let gas_remaining = get_gas_left(env); + let (result, gas_info) = with_querier_from_context::(env.clone(), |querier| { Ok(querier.query_raw(&request, gas_remaining)) })?; - process_gas_info::(&mut ctx, gas_info)?; + process_gas_info::(env, gas_info)?; let serialized = to_vec(&result?)?; - write_to_contract::(&mut ctx, &serialized) + write_to_contract::(env, &serialized) } #[cfg(feature = "iterator")] pub fn do_scan( - ctx: &mut Ctx, + env: &mut Env, start_ptr: u32, end_ptr: u32, order: i32, ) -> VmResult { - let start = maybe_read_region(&mut ctx, start_ptr, MAX_LENGTH_DB_KEY)?; - let end = maybe_read_region(&mut 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::(&mut ctx, |store| { + let (result, gas_info) = with_storage_from_context::(env.clone(), |store| { Ok(store.range(start.as_deref(), end.as_deref(), order)) })?; - process_gas_info::(&mut ctx, gas_info)?; + process_gas_info(env, gas_info)?; let iterator = result?; - let iterator_id = add_iterator::(&mut ctx, iterator); + let iterator_id = add_iterator(env, iterator); Ok(iterator_id) } #[cfg(feature = "iterator")] -pub fn do_next(ctx: &mut Ctx, iterator_id: u32) -> VmResult { +pub fn do_next(env: &mut Env, iterator_id: u32) -> VmResult { let (result, gas_info) = - with_iterator_from_context::(&mut ctx, iterator_id, |iter| Ok(iter.next()))?; - process_gas_info::(&mut ctx, gas_info)?; + with_iterator_from_context::(env.clone(), iterator_id, |iter| Ok(iter.next()))?; + 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())); @@ -228,7 +224,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::(&mut ctx, &out_data) + write_to_contract::(env, &out_data) } #[cfg(test)] @@ -239,7 +235,7 @@ mod test { SystemError, WasmQuery, }; use std::ptr::NonNull; - use wasmer_runtime_core::{imports, typed_func::Func, Instance as WasmerInstance}; + use wasmer::{imports, Function, Instance as WasmerInstance}; use crate::backends::compile; use crate::context::{move_into_context, set_storage_readonly, set_wasmer_instance}; @@ -272,15 +268,15 @@ mod test { // we need stubs for all required imports let import_obj = imports! { "env" => { - "db_read" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - "db_write" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| {}), - "db_remove" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), - "db_scan" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32, _c: i32| -> u32 { 0 }), - "db_next" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - "query_chain" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - "canonicalize_address" => Func::new(|_ctx: &mut Ctx, _a: i32, _b: i32| -> u32 { 0 }), - "humanize_address" => Func::new(|_ctx: &mut Ctx, _a: i32, _b: i32| -> u32 { 0 }), - "debug" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), + // "db_read" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + // "db_write" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| {}), + // "db_remove" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), + // "db_scan" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32, _c: i32| -> u32 { 0 }), + // "db_next" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + // "query_chain" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), + // "canonicalize_address" => Func::new(|_ctx: &mut Ctx, _a: i32, _b: i32| -> u32 { 0 }), + // "humanize_address" => Func::new(|_ctx: &mut Ctx, _a: i32, _b: i32| -> u32 { 0 }), + // "debug" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), }, }; let mut instance = Box::from(module.instantiate(&import_obj).unwrap()); @@ -299,13 +295,13 @@ mod test { 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(&mut ctx, storage, querier); + move_into_context(env, storage, querier); } fn write_data(wasmer_instance: &mut WasmerInstance, data: &[u8]) -> u32 { - let allocate: Func = wasmer_instance + let allocate: Function = wasmer_instance .exports - .get("allocate") + .get_function("allocate") .expect("error getting function"); let region_ptr = allocate .call(data.len() as u32) @@ -315,17 +311,17 @@ mod test { } fn create_empty(wasmer_instance: &mut WasmerInstance, capacity: u32) -> u32 { - let allocate: Func = wasmer_instance + let allocate: Function = wasmer_instance .exports - .get("allocate") + .get_function("allocate") .expect("error getting function"); let region_ptr = allocate.call(capacity).expect("error calling allocate"); 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(&mut ctx, region_ptr, 5000).unwrap() + fn force_read(env: &Env, region_ptr: u32) -> Vec { + read_region(env, region_ptr, 5000).unwrap() } #[test] @@ -335,10 +331,10 @@ mod test { let key_ptr = write_data(&mut instance, KEY1); let ctx = instance.context_mut(); - let result = do_read::(&mut ctx, key_ptr); + let result = do_read::(env, key_ptr); let value_ptr = result.unwrap(); assert!(value_ptr > 0); - assert_eq!(force_read(&mut ctx, value_ptr as u32), VALUE1); + assert_eq!(force_read(env, value_ptr as u32), VALUE1); } #[test] @@ -348,7 +344,7 @@ mod test { let key_ptr = write_data(&mut instance, b"I do not exist in storage"); let ctx = instance.context_mut(); - let result = do_read::(&mut ctx, key_ptr); + let result = do_read::(env, key_ptr); assert_eq!(result.unwrap(), 0); } @@ -359,7 +355,7 @@ mod test { let key_ptr = write_data(&mut instance, &vec![7u8; 300 * 1024]); let ctx = instance.context_mut(); - let result = do_read::(&mut ctx, key_ptr); + let result = do_read::(env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionLengthTooBig { length, .. }, @@ -376,11 +372,11 @@ mod test { let value_ptr = write_data(&mut instance, b"new value"); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - do_write::(&mut ctx, key_ptr, value_ptr).unwrap(); + do_write::(env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(&mut ctx, |store| { + let val = with_storage_from_context::(env, |store| { Ok(store .get(b"new storage key") .0 @@ -398,11 +394,11 @@ mod test { let value_ptr = write_data(&mut instance, VALUE2); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - do_write::(&mut ctx, key_ptr, value_ptr).unwrap(); + do_write::(env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(&mut ctx, |store| { + let val = with_storage_from_context::(env, |store| { Ok(store.get(KEY1).0.expect("error getting value")) }) .unwrap(); @@ -417,11 +413,11 @@ mod test { let value_ptr = write_data(&mut instance, b""); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - do_write::(&mut ctx, key_ptr, value_ptr).unwrap(); + do_write::(env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(&mut ctx, |store| { + let val = with_storage_from_context::(env, |store| { Ok(store .get(b"new storage key") .0 @@ -439,9 +435,9 @@ mod test { let value_ptr = write_data(&mut instance, b"new value"); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - let result = do_write::(&mut ctx, key_ptr, value_ptr); + let result = do_write::(env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -464,9 +460,9 @@ mod test { let value_ptr = write_data(&mut instance, &vec![5u8; 300 * 1024]); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - let result = do_write::(&mut ctx, key_ptr, value_ptr); + let result = do_write::(env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -489,10 +485,10 @@ mod test { let value_ptr = write_data(&mut instance, b"new value"); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); - set_storage_readonly::(&mut ctx, true); + leave_default_data(env); + set_storage_readonly::(env, true); - let result = do_write::(&mut 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), @@ -507,11 +503,11 @@ mod test { let key_ptr = write_data(&mut instance, existing_key); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - do_remove::(&mut ctx, key_ptr).unwrap(); + do_remove::(env, key_ptr).unwrap(); - let value = with_storage_from_context::(&mut ctx, |store| { + let value = with_storage_from_context::(env, |store| { Ok(store.get(existing_key).0.expect("error getting value")) }) .unwrap(); @@ -526,12 +522,12 @@ mod test { let key_ptr = write_data(&mut instance, non_existent_key); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); // Note: right now we cannot differnetiate between an existent and a non-existent key - do_remove::(&mut ctx, key_ptr).unwrap(); + do_remove::(env, key_ptr).unwrap(); - let value = with_storage_from_context::(&mut ctx, |store| { + let value = with_storage_from_context::(env, |store| { Ok(store.get(non_existent_key).0.expect("error getting value")) }) .unwrap(); @@ -545,9 +541,9 @@ mod test { let key_ptr = write_data(&mut instance, &vec![26u8; 300 * 1024]); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - let result = do_remove::(&mut ctx, key_ptr); + let result = do_remove::(env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -569,10 +565,10 @@ mod test { let key_ptr = write_data(&mut instance, b"a storage key"); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); - set_storage_readonly::(&mut ctx, true); + leave_default_data(env); + set_storage_readonly::(env, true); - let result = do_remove::(&mut ctx, key_ptr); + let result = do_remove::(env, key_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -587,11 +583,11 @@ mod test { let dest_ptr = create_empty(&mut instance, 8); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new(8); - do_canonicalize_address::(api, &mut ctx, source_ptr, dest_ptr).unwrap(); - assert_eq!(force_read(&mut ctx, dest_ptr), b"foo\0\0\0\0\0"); + do_canonicalize_address::(api, env, source_ptr, dest_ptr).unwrap(); + assert_eq!(force_read(env, dest_ptr), b"foo\0\0\0\0\0"); } #[test] @@ -604,25 +600,22 @@ mod test { let dest_ptr = create_empty(&mut instance, 8); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new(8); - let res = - do_canonicalize_address::(api, &mut 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(&mut 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, &mut 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(&mut 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, &mut 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(&mut ctx, res)).unwrap(); + let err = String::from_utf8(force_read(env, res)).unwrap(); assert_eq!(err, "Invalid input: human address too long"); } @@ -634,10 +627,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 7); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new_failing(8, "Temporarily unavailable"); - let result = do_canonicalize_address::(api, &mut ctx, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::FfiErr { source: FfiError::Unknown { msg, .. }, @@ -656,10 +649,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 8); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new(8); - let result = do_canonicalize_address::(api, &mut ctx, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -682,10 +675,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 7); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new(8); - let result = do_canonicalize_address::(api, &mut 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, .. }, @@ -705,13 +698,12 @@ mod test { let dest_ptr = create_empty(&mut instance, 50); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new(8); - let error_ptr = - do_humanize_address::(api, &mut ctx, source_ptr, dest_ptr).unwrap(); + let error_ptr = do_humanize_address::(api, env, source_ptr, dest_ptr).unwrap(); assert_eq!(error_ptr, 0); - assert_eq!(force_read(&mut ctx, dest_ptr), b"foo"); + assert_eq!(force_read(env, dest_ptr), b"foo"); } #[test] @@ -722,12 +714,12 @@ mod test { let dest_ptr = create_empty(&mut instance, 50); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new(8); - let res = do_humanize_address::(api, &mut 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(&mut ctx, res)).unwrap(); + let err = String::from_utf8(force_read(env, res)).unwrap(); assert_eq!(err, "Invalid input: canonical address length not correct"); } @@ -739,10 +731,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 50); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new_failing(8, "Temporarily unavailable"); - let result = do_humanize_address::(api, &mut ctx, source_ptr, dest_ptr); + let result = do_humanize_address::(api, env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::FfiErr { source: FfiError::Unknown { msg, .. }, @@ -759,10 +751,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 50); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new(8); - let result = do_humanize_address::(api, &mut ctx, source_ptr, dest_ptr); + let result = do_humanize_address::(api, env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -785,10 +777,10 @@ mod test { let dest_ptr = create_empty(&mut instance, 2); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let api = MockApi::new(8); - let result = do_humanize_address::(api, &mut ctx, source_ptr, dest_ptr); + let result = do_humanize_address::(api, env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionTooSmall { size, required, .. }, @@ -811,10 +803,10 @@ mod test { let request_ptr = write_data(&mut instance, &request_data); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - let response_ptr = do_query_chain::(&mut ctx, request_ptr).unwrap(); - let response = force_read(&mut 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(); @@ -832,10 +824,10 @@ mod test { let request_ptr = write_data(&mut instance, request); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - let response_ptr = do_query_chain::(&mut ctx, request_ptr).unwrap(); - let response = force_read(&mut 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(); @@ -860,10 +852,10 @@ mod test { let request_ptr = write_data(&mut instance, &request_data); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - let response_ptr = do_query_chain::(&mut ctx, request_ptr).unwrap(); - let response = force_read(&mut 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(); @@ -881,22 +873,22 @@ mod test { fn do_scan_unbound_works() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); // set up iterator over all space - let id = do_scan::(&mut 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_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) - .unwrap(); + let item = + with_iterator_from_context::(env, id, |iter| Ok(iter.next())).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) - .unwrap(); + let item = + with_iterator_from_context::(env, id, |iter| Ok(iter.next())).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); - let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) - .unwrap(); + let item = + with_iterator_from_context::(env, id, |iter| Ok(iter.next())).unwrap(); assert!(item.0.unwrap().is_none()); } @@ -905,22 +897,22 @@ mod test { fn do_scan_unbound_descending_works() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); // set up iterator over all space - let id = do_scan::(&mut 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_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) - .unwrap(); + let item = + with_iterator_from_context::(env, id, |iter| Ok(iter.next())).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); - let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) - .unwrap(); + let item = + with_iterator_from_context::(env, id, |iter| Ok(iter.next())).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) - .unwrap(); + let item = + with_iterator_from_context::(env, id, |iter| Ok(iter.next())).unwrap(); assert!(item.0.unwrap().is_none()); } @@ -933,16 +925,16 @@ mod test { let end = write_data(&mut instance, b"bert"); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - let id = do_scan::(&mut ctx, start, end, Order::Ascending.into()).unwrap(); + let id = do_scan::(env, start, end, Order::Ascending.into()).unwrap(); - let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) - .unwrap(); + let item = + with_iterator_from_context::(env, id, |iter| Ok(iter.next())).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = with_iterator_from_context::(&mut ctx, id, |iter| Ok(iter.next())) - .unwrap(); + let item = + with_iterator_from_context::(env, id, |iter| Ok(iter.next())).unwrap(); assert!(item.0.unwrap().is_none()); } @@ -951,42 +943,37 @@ mod test { fn do_scan_multiple_iterators() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); // unbounded, ascending and descending - let id1 = do_scan::(&mut ctx, 0, 0, Order::Ascending.into()).unwrap(); - let id2 = do_scan::(&mut 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_iterator_from_context::(&mut ctx, id1, |iter| Ok(iter.next())) - .unwrap(); + with_iterator_from_context::(env, id1, |iter| Ok(iter.next())).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); // second item, first iterator let item = - with_iterator_from_context::(&mut ctx, id1, |iter| Ok(iter.next())) - .unwrap(); + with_iterator_from_context::(env, id1, |iter| Ok(iter.next())).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); // first item, second iterator let item = - with_iterator_from_context::(&mut ctx, id2, |iter| Ok(iter.next())) - .unwrap(); + with_iterator_from_context::(env, id2, |iter| Ok(iter.next())).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); // end, first iterator let item = - with_iterator_from_context::(&mut ctx, id1, |iter| Ok(iter.next())) - .unwrap(); + with_iterator_from_context::(env, id1, |iter| Ok(iter.next())).unwrap(); assert!(item.0.unwrap().is_none()); // second item, second iterator let item = - with_iterator_from_context::(&mut ctx, id2, |iter| Ok(iter.next())) - .unwrap(); + with_iterator_from_context::(env, id2, |iter| Ok(iter.next())).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); } @@ -995,10 +982,10 @@ mod test { fn do_scan_errors_for_invalid_order_value() { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); // set up iterator over all space - let result = do_scan::(&mut ctx, 0, 0, 42); + let result = do_scan::(env, 0, 0, 42); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::InvalidOrder { .. }, @@ -1013,27 +1000,27 @@ mod test { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); - let id = do_scan::(&mut 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::(&mut ctx, id).unwrap(); + let kv_region_ptr = do_next::(env, id).unwrap(); assert_eq!( - force_read(&mut 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::(&mut ctx, id).unwrap(); + let kv_region_ptr = do_next::(env, id).unwrap(); assert_eq!( - force_read(&mut 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::(&mut ctx, id).unwrap(); - assert_eq!(force_read(&mut 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 } @@ -1043,10 +1030,10 @@ mod test { let mut instance = make_instance(); let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + leave_default_data(env); let non_existent_id = 42u32; - let result = do_next::(&mut ctx, non_existent_id); + let result = do_next::(env, non_existent_id); match result.unwrap_err() { VmError::IteratorDoesNotExist { id, .. } => assert_eq!(id, non_existent_id), e => panic!("Unexpected error: {:?}", e), diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 4945c30594..e2c941f5fb 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -1,16 +1,17 @@ use std::collections::HashSet; use std::marker::PhantomData; use std::ptr::NonNull; +use std::sync::{Arc, RwLock}; -pub use wasmer_runtime_core::typed_func::Func; -use wasmer_runtime_core::{ - imports, module::Module, typed_func::WasmTypeList, vm::Ctx, Instance as WasmerInstance, +use wasmer::{ + imports, Function, FunctionType, Instance as WasmerInstance, Module, Store, Type, Val, }; +use wasmer_engine_jit::JIT; 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, with_querier_from_context, with_storage_from_context, + move_into_context, move_out_of_context, set_storage_readonly, set_wasmer_instance, + with_querier_from_context, with_storage_from_context, ContextData, Env, }; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; @@ -21,11 +22,26 @@ use crate::imports::{ }; #[cfg(feature = "iterator")] use crate::imports::{do_next, do_scan}; -use crate::memory::{get_memory_info, read_region, write_region}; +use crate::memory::{read_region, write_region}; use crate::traits::{Api, Extern, Querier, Storage}; const WASM_PAGE_SIZE: u64 = 64 * 1024; +/// Like std::try but using Into instead of From +macro_rules! try_into { + ($expr:expr) => { + match $expr { + std::result::Result::Ok(val) => val, + std::result::Result::Err(err) => { + return std::result::Result::Err(err.into()); + } + } + }; + ($expr:expr,) => { + $crate::try_into!($expr) + }; +} + #[derive(Copy, Clone, Debug)] pub struct GasReport { /// The original limit the instance was created with @@ -44,6 +60,7 @@ pub struct Instance, + env: Env, pub api: A, pub required_features: HashSet, // This does not store data but only fixes type information @@ -77,53 +94,88 @@ where ) -> VmResult { // copy this so it can be moved into the closures, without pulling in deps let api = deps.api; + + let engine = JIT::headless().engine(); + let store = Store::new(&engine); + + let env = Env { + memory: wasmer::Memory::new(&store, wasmer::MemoryType::new(0, Some(5000), false)) + .expect("could not create memory"), + context_data: Arc::new(RwLock::new(ContextData::new(gas_limit))), + }; + let _env2 = env.clone(); + let _env3 = env.clone(); + + let i32_to_i32 = FunctionType::new(vec![Type::I32], vec![Type::I32]); + let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); + 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]); + let import_obj = 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) + "db_read" => Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { + let key_ptr = args[0].unwrap_i32() as u32; + let ptr = try_into!(do_read::(&mut env, key_ptr)); + Ok(vec![ptr.into()]) }), // 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) + "db_write" => Function::new_with_env(&store, &i32i32_to_void, env.clone(), |mut env, args| { + let key_ptr = args[0].unwrap_i32() as u32; + let value_ptr = args[1].unwrap_i32() as u32; + try_into!(do_write::(&mut env, key_ptr, value_ptr)); + Ok(vec![]) }), // 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) + "db_remove" => Function::new_with_env(&store, &i32_to_void, env.clone(), |mut env, args| { + let key_ptr = args[0].unwrap_i32() as u32; + try_into!(do_remove::(&mut env, key_ptr)); + Ok(vec![]) }), // 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) + "canonicalize_address" => Function::new_with_env(&store, &i32i32_to_i32, env.clone(), move |mut env, args| { + let source_ptr = args[0].unwrap_i32() as u32; + let destination_ptr = args[1].unwrap_i32() as u32; + let ptr = try_into!(do_canonicalize_address::(api, &mut 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. - "humanize_address" => Func::new(move |ctx: &mut Ctx, source_ptr: u32, destination_ptr: u32| -> VmResult { - do_humanize_address::(api, ctx, source_ptr, destination_ptr) + "humanize_address" => Function::new_with_env(&store, &i32i32_to_i32, env.clone(), move |mut env, args| { + let source_ptr = args[0].unwrap_i32() as u32; + let destination_ptr = args[1].unwrap_i32() as u32; + let ptr = try_into!(do_humanize_address::(api, &mut 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. - "debug" => Func::new(move |ctx: &mut Ctx, message_ptr: u32|-> VmResult<()> { + "debug" => Function::new_with_env(&store, &i32_to_void, env.clone(), move |mut env, args| { + let message_ptr = args[0].unwrap_i32() as u32; if print_debug { - print_debug_message(ctx, message_ptr)?; + try_into!(print_debug_message(&mut env, message_ptr)); } - Ok(()) + Ok(vec![]) }), - "query_chain" => Func::new(move |ctx: &mut Ctx, request_ptr: u32| -> VmResult { - do_query_chain::(ctx, request_ptr) + "query_chain" => Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { + let request_ptr = args[0].unwrap_i32() as u32; + let response_ptr = try_into!(do_query_chain::(&mut env, request_ptr)); + Ok(vec![response_ptr.into()]) }), // Creates an iterator that will go from start to end. // If start_ptr == 0, the start is unbounded. @@ -131,14 +183,18 @@ where // 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 { + "db_scan" => Function::new_with_env(&store, &i32i32i32_to_i32, env.clone(), |mut env, args| { + let start_ptr = args[0].unwrap_i32() as u32; + let end_ptr = args[1].unwrap_i32() as u32; + let order = args[2].unwrap_i32(); #[cfg(feature = "iterator")] { - do_scan::(ctx, start_ptr, end_ptr, order) + let response_ptr = try_into!(do_scan::(&mut env, start_ptr, end_ptr, order)); + Ok(vec![response_ptr.into()]) } #[cfg(not(feature = "iterator"))] { - Err(VmError::generic_err("Import db_scan not implemented due to missing iterator feature")) + Err(wasmer_engine::RuntimeError::new("Import db_scan not implemented due to missing iterator feature")) } }), // Get next element of iterator with ID `iterator_id`. @@ -146,42 +202,46 @@ where // 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 { + "db_next" => Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { #[cfg(feature = "iterator")] { - do_next::(ctx, iterator_id) + let iterator_id = args[0].unwrap_i32() as u32; + let response_ptr = try_into!(do_next::(&mut env, iterator_id)); + Ok(vec![response_ptr.into()]) } #[cfg(not(feature = "iterator"))] { - Err(VmError::generic_err("Import db_next not implemented due to missing iterator feature")) + Err(wasmer_engine::RuntimeError::new("Import db_next not implemented due to missing iterator feature")) } }), }, }; - let wasmer_instance = Box::from(module.instantiate(&import_obj).map_err(|original| { - VmError::instantiation_err(format!("Error instantiating module: {:?}", original)) - })?); - Ok(Instance::from_wasmer(wasmer_instance, deps, gas_limit)) + let wasmer_instance = Box::from(WasmerInstance::new(&module, &import_obj).map_err( + |original| { + VmError::instantiation_err(format!("Error instantiating module: {:?}", original)) + }, + )?); + Ok(Instance::from_wasmer(wasmer_instance, env, deps, gas_limit)) } - pub(crate) fn from_wasmer( - mut wasmer_instance: Box, + fn from_wasmer( + wasmer_instance: Box, + mut env: Env, deps: Extern, gas_limit: u64, ) -> Self { - set_gas_left(&mut wasmer_instance.context_mut(), gas_limit); - get_gas_state_mut::(&mut wasmer_instance.context_mut()).set_gas_limit(gas_limit); + set_gas_left(&mut 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::(&mut wasmer_instance.context_mut(), Some(instance_ptr)); - move_into_context( - &mut wasmer_instance.context_mut(), - deps.storage, - deps.querier, - ); + set_wasmer_instance::(&mut env, Some(instance_ptr)); + move_into_context(&mut env, deps.storage, deps.querier); Instance { inner: wasmer_instance, + env, api: deps.api, required_features, type_storage: PhantomData:: {}, @@ -192,7 +252,7 @@ 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(&mut self.inner.context_mut()) { + if let (Some(storage), Some(querier)) = move_out_of_context(&mut self.env) { Some(Extern { storage, api: self.api, @@ -208,7 +268,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. @@ -220,8 +280,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, @@ -234,22 +294,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::(&mut self.inner.context_mut(), new_value); + set_storage_readonly::(&mut self.env, new_value); } pub fn with_storage VmResult, T>(&mut self, func: F) -> VmResult { - with_storage_from_context::(&mut self.inner.context_mut(), func) + with_storage_from_context::(self.env.clone(), func) } pub fn with_querier VmResult, T>(&mut self, func: F) -> VmResult { - with_querier_from_context::(&mut self.inner.context_mut(), func) + with_querier_from_context::(self.env.clone(), 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 = ret.as_ref()[0].unwrap_i32() as u32; if ptr == 0 { return Err(CommunicationError::zero_address().into()); } @@ -260,29 +320,25 @@ 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 + Clone, - Rets: WasmTypeList + Clone, - { - 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) } } @@ -345,41 +401,19 @@ mod test { } #[test] - fn func_works() { - let instance = mock_instance(&CONTRACT, &[]); - - // can get func - let allocate: Func = instance.func("allocate").expect("error getting func"); - - // 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() { + fn call_func_works() { 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), - } - } - #[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), - } + // can call function few times + let _ptr1 = instance + .call_function("allocate", &[0u32.into()]) + .expect("error calling allocate"); + let _ptr2 = instance + .call_function("allocate", &[1u32.into()]) + .expect("error calling allocate"); + let _ptr3 = instance + .call_function("allocate", &[33u32.into()]) + .expect("error calling allocate"); } #[test] diff --git a/packages/vm/src/memory.rs b/packages/vm/src/memory.rs index d140e6df8b..47165d860d 100644 --- a/packages/vm/src/memory.rs +++ b/packages/vm/src/memory.rs @@ -1,9 +1,4 @@ -use wasmer_runtime_core::{ - memory::ptr::{Array, WasmPtr}, - types::ValueType, - vm::Ctx, -}; -use wasmer_types::MemoryIndex; +use wasmer::{Array, ValueType, WasmPtr}; use crate::conversion::to_u32; use crate::errors::{ @@ -30,45 +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_type = (*ctx.module_info) - .memories - .get(MemoryIndex::from_u32(0)) - .unwrap(); - MemoryInfo { - descriptor: MemoryDescriptor { - minimum: memory_type.minimum.0, - maximum: memory_type.maximum.map(|pages| pages.0), - shared: memory_type.shared, - }, - 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( @@ -76,8 +37,7 @@ 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) { + 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]`: // https://github.com/wasmerio/wasmer/blob/0.13.1/lib/wasi/src/syscalls/mod.rs#L79-L81 @@ -99,27 +59,29 @@ 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) { + 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]`: // https://github.com/wasmerio/wasmer/blob/0.13.1/lib/wasi/src/syscalls/mod.rs#L79-L81 @@ -127,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!( @@ -139,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) => { @@ -177,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/modules.rs b/packages/vm/src/modules.rs index 54433f53ec..b348a7f663 100644 --- a/packages/vm/src/modules.rs +++ b/packages/vm/src/modules.rs @@ -8,7 +8,8 @@ use std::{ path::PathBuf, }; -use wasmer_runtime_core::{cache::Artifact, load_cache_with, module::Module}; +use wasmer::{Module, Store}; +use wasmer_engine_jit::JIT; use crate::backends::backend; use crate::checksum::Checksum; @@ -70,8 +71,9 @@ 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 { load_cache_with(serialized_cache) }?; + let engine = JIT::headless().engine(); + let store = Store::new(&engine); + let module = unsafe { Module::deserialize(&store, &mmap[..]) }?; Ok(module) } @@ -80,8 +82,7 @@ impl FileSystemCache { 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)) @@ -99,11 +100,10 @@ mod tests { use crate::backends::compile; use std::env; use wabt::wat2wasm; + use wasmer::{imports, Instance as WasmerInstance}; #[test] fn test_file_system_cache_run() { - use wasmer_runtime_core::{imports, typed_func::Func}; - let wasm = wat2wasm( r#"(module (type $t0 (func (param i32) (result i32))) @@ -129,12 +129,12 @@ mod tests { let cached_module = cached_result.unwrap(); let import_object = imports! {}; - let instance = cached_module.instantiate(&import_object).unwrap(); - let add_one: Func = instance.exports.get("add_one").unwrap(); + let instance = WasmerInstance::new(&cached_module, &import_object).unwrap(); + let add_one = instance.exports.get_function("add_one").unwrap(); - let value = add_one.call(42).unwrap(); + let result = add_one.call(&[42.into()]).unwrap(); // verify it works - assert_eq!(value, 43); + assert_eq!(result[0].unwrap_i32(), 43); } } From 020ad3b3b8db64a2cc270d89aa145e21ca53cbaa Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 15 Sep 2020 17:45:59 +0200 Subject: [PATCH 007/110] Replace try_into! with ? --- packages/vm/src/errors/vm_error.rs | 6 +++--- packages/vm/src/instance.rs | 33 ++++++++---------------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index a209e273e4..fd72c23175 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -229,9 +229,9 @@ impl From for VmError { } } -impl Into for VmError { - fn into(self) -> wasmer_engine::RuntimeError { - let msg: String = self.to_string(); +impl From for wasmer_engine::RuntimeError { + fn from(original: VmError) -> wasmer_engine::RuntimeError { + let msg: String = original.to_string(); wasmer_engine::RuntimeError::new(msg) } } diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index e2c941f5fb..ffdc76beaa 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -27,21 +27,6 @@ use crate::traits::{Api, Extern, Querier, Storage}; const WASM_PAGE_SIZE: u64 = 64 * 1024; -/// Like std::try but using Into instead of From -macro_rules! try_into { - ($expr:expr) => { - match $expr { - std::result::Result::Ok(val) => val, - std::result::Result::Err(err) => { - return std::result::Result::Err(err.into()); - } - } - }; - ($expr:expr,) => { - $crate::try_into!($expr) - }; -} - #[derive(Copy, Clone, Debug)] pub struct GasReport { /// The original limit the instance was created with @@ -121,7 +106,7 @@ where // Ownership of the value pointer is transferred to the contract. "db_read" => Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { let key_ptr = args[0].unwrap_i32() as u32; - let ptr = try_into!(do_read::(&mut env, key_ptr)); + let ptr = do_read::(&mut env, key_ptr)?; Ok(vec![ptr.into()]) }), // Writes the given value into the database entry at the given key. @@ -129,7 +114,7 @@ where "db_write" => Function::new_with_env(&store, &i32i32_to_void, env.clone(), |mut env, args| { let key_ptr = args[0].unwrap_i32() as u32; let value_ptr = args[1].unwrap_i32() as u32; - try_into!(do_write::(&mut env, key_ptr, value_ptr)); + do_write::(&mut env, key_ptr, value_ptr)?; Ok(vec![]) }), // Removes the value at the given key. Different than writing &[] as future @@ -138,7 +123,7 @@ where // Ownership of both key pointer is not transferred to the host. "db_remove" => Function::new_with_env(&store, &i32_to_void, env.clone(), |mut env, args| { let key_ptr = args[0].unwrap_i32() as u32; - try_into!(do_remove::(&mut env, key_ptr)); + do_remove::(&mut env, key_ptr)?; Ok(vec![]) }), // Reads human address from source_ptr and writes canonicalized representation to destination_ptr. @@ -148,7 +133,7 @@ where "canonicalize_address" => Function::new_with_env(&store, &i32i32_to_i32, env.clone(), move |mut env, args| { let source_ptr = args[0].unwrap_i32() as u32; let destination_ptr = args[1].unwrap_i32() as u32; - let ptr = try_into!(do_canonicalize_address::(api, &mut env, source_ptr, destination_ptr)); + let ptr = do_canonicalize_address::(api, &mut env, source_ptr, destination_ptr)?; Ok(vec![ptr.into()]) }), // Reads canonical address from source_ptr and writes humanized representation to destination_ptr. @@ -158,7 +143,7 @@ where "humanize_address" => Function::new_with_env(&store, &i32i32_to_i32, env.clone(), move |mut env, args| { let source_ptr = args[0].unwrap_i32() as u32; let destination_ptr = args[1].unwrap_i32() as u32; - let ptr = try_into!(do_humanize_address::(api, &mut env, source_ptr, destination_ptr)); + let ptr = do_humanize_address::(api, &mut env, source_ptr, destination_ptr)?; Ok(vec![ptr.into()]) }), // Allows the contract to emit debug logs that the host can either process or ignore. @@ -168,13 +153,13 @@ where "debug" => Function::new_with_env(&store, &i32_to_void, env.clone(), move |mut env, args| { let message_ptr = args[0].unwrap_i32() as u32; if print_debug { - try_into!(print_debug_message(&mut env, message_ptr)); + print_debug_message(&mut env, message_ptr)?; } Ok(vec![]) }), "query_chain" => Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { let request_ptr = args[0].unwrap_i32() as u32; - let response_ptr = try_into!(do_query_chain::(&mut env, request_ptr)); + let response_ptr = do_query_chain::(&mut env, request_ptr)?; Ok(vec![response_ptr.into()]) }), // Creates an iterator that will go from start to end. @@ -189,7 +174,7 @@ where let order = args[2].unwrap_i32(); #[cfg(feature = "iterator")] { - let response_ptr = try_into!(do_scan::(&mut env, start_ptr, end_ptr, order)); + let response_ptr = do_scan::(&mut env, start_ptr, end_ptr, order)?; Ok(vec![response_ptr.into()]) } #[cfg(not(feature = "iterator"))] @@ -206,7 +191,7 @@ where #[cfg(feature = "iterator")] { let iterator_id = args[0].unwrap_i32() as u32; - let response_ptr = try_into!(do_next::(&mut env, iterator_id)); + let response_ptr = do_next::(&mut env, iterator_id)?; Ok(vec![response_ptr.into()]) } #[cfg(not(feature = "iterator"))] From b4805cc42c5bdfe3f7fb021d1a59f835d9e40951 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 15 Sep 2020 18:12:00 +0200 Subject: [PATCH 008/110] Update Lockfile to latest Wasmer master --- Cargo.lock | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 236838e9b7..df17c9b8ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1095,7 +1095,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "cfg-if", "indexmap", @@ -1115,7 +1115,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "enumset", "raw-cpuid", @@ -1131,7 +1131,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "byteorder", "dynasm", @@ -1164,7 +1164,7 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "backtrace", "bincode", @@ -1182,7 +1182,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "bincode", "cfg-if", @@ -1198,7 +1198,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "bincode", "cfg-if", @@ -1212,11 +1212,12 @@ dependencies = [ "wasmer-object", "wasmer-types", "wasmer-vm", + "which", ] [[package]] name = "wasmer-object" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "object", "thiserror", @@ -1226,7 +1227,7 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "cranelift-entity", "serde", @@ -1234,7 +1235,7 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha01.0" +version = "1.0.0-alpha3" dependencies = [ "backtrace", "cc", @@ -1274,6 +1275,16 @@ dependencies = [ "wast", ] +[[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.8" From cd9d05bda6e8d07b8b3e6b8de3bda346294d8ff2 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 09:17:58 +0200 Subject: [PATCH 009/110] Add FfiError::IteratorDoesNotExist --- packages/vm/src/ffi.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/vm/src/ffi.rs b/packages/vm/src/ffi.rs index 0e4fb40776..1a7ccee8c5 100644 --- a/packages/vm/src/ffi.rs +++ b/packages/vm/src/ffi.rs @@ -51,6 +51,11 @@ pub enum FfiError { BadArgument { backtrace: snafu::Backtrace }, #[snafu(display("VM received invalid UTF-8 data from backend"))] InvalidUtf8 { backtrace: snafu::Backtrace }, + #[snafu(display("Iterator with ID {} does not exist", id))] + IteratorDoesNotExist { + id: u32, + backtrace: snafu::Backtrace, + }, #[snafu(display("Ran out of gas during FFI call"))] OutOfGas {}, #[snafu(display("Unknown error during FFI call: {:?}", msg))] @@ -75,6 +80,10 @@ impl FfiError { BadArgument {}.build() } + pub fn iterator_does_not_exist(iterator_id: u32) -> Self { + IteratorDoesNotExist { id: iterator_id }.build() + } + pub fn out_of_gas() -> Self { OutOfGas {}.build() } @@ -150,6 +159,15 @@ mod test { } } + #[test] + fn iterator_does_not_exist_works() { + let error = FfiError::iterator_does_not_exist(15); + match error { + FfiError::IteratorDoesNotExist { id, .. } => assert_eq!(id, 15), + e => panic!("Unexpected error: {:?}", e), + } + } + #[test] fn ffi_error_out_of_gas() { let error = FfiError::out_of_gas(); From ea96f77427d42d1fa823cbcc04d99eab45ab0eb0 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 6 Oct 2020 21:06:05 +0200 Subject: [PATCH 010/110] Replace range with scan/next in Storage trait --- packages/vm/src/traits.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/vm/src/traits.rs b/packages/vm/src/traits.rs index 5cc96887fd..e84cbcef35 100644 --- a/packages/vm/src/traits.rs +++ b/packages/vm/src/traits.rs @@ -68,18 +68,26 @@ pub trait Storage { /// is not great yet and might not be possible in all backends. But we're trying to get there. fn get(&self, key: &[u8]) -> FfiResult>>; - #[cfg(feature = "iterator")] /// Allows iteration over a set of key/value pairs, either forwards or backwards. + /// Returns an interator ID that is unique within the Storage instance. /// /// The bound `start` is inclusive and `end` is exclusive. /// /// If `start` is lexicographically greater than or equal to `end`, an empty range is described, mo matter of the order. - fn range<'a>( - &'a self, - start: Option<&[u8]>, - end: Option<&[u8]>, - order: Order, - ) -> FfiResult>; + /// + /// This call must not change data in the storage, but creating and storing a new iterator can be a mutating operation on + /// the Storage implementation. + #[cfg(feature = "iterator")] + fn scan(&mut self, start: Option<&[u8]>, end: Option<&[u8]>, order: Order) -> FfiResult; + + /// Returns the next element of the iterator with the given ID. + /// + /// If the ID is not found, a FfiError::IteratorDoesNotExist is returned. + /// + /// This call must not change data in the storage, but incrementing an iterator can be a mutating operation on + /// the Storage implementation. + #[cfg(feature = "iterator")] + fn next(&mut self, iterator_id: u32) -> FfiResult>; fn set(&mut self, key: &[u8], value: &[u8]) -> FfiResult<()>; From 786719f0d930c9ed752c5aca48e8305e70053604 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 6 Oct 2020 23:41:56 +0200 Subject: [PATCH 011/110] Update MockStorage to new trait --- packages/vm/src/imports.rs | 7 +- packages/vm/src/testing/storage.rs | 174 ++++++++++++++++++----------- 2 files changed, 111 insertions(+), 70 deletions(-) diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index e1746af6f1..2eb790198d 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -10,7 +10,7 @@ use wasmer_runtime_core::vm::Ctx; use crate::backends::get_gas_left; #[cfg(feature = "iterator")] -use crate::context::{add_iterator, with_iterator_from_context}; +use crate::context::with_iterator_from_context; use crate::context::{ is_storage_readonly, process_gas_info, with_func_from_context, with_querier_from_context, with_storage_from_context, @@ -190,11 +190,10 @@ pub fn do_scan( .map_err(|_| CommunicationError::invalid_order(order))?; let (result, gas_info) = with_storage_from_context::(ctx, |store| { - Ok(store.range(start.as_deref(), end.as_deref(), order)) + Ok(store.scan(start.as_deref(), end.as_deref(), order)) })?; process_gas_info::(ctx, gas_info)?; - let iterator = result?; - let iterator_id = add_iterator::(ctx, iterator); + let iterator_id = result?; Ok(iterator_id) } diff --git a/packages/vm/src/testing/storage.rs b/packages/vm/src/testing/storage.rs index ef6e8eef60..f3eeab203d 100644 --- a/packages/vm/src/testing/storage.rs +++ b/packages/vm/src/testing/storage.rs @@ -1,5 +1,9 @@ use std::collections::BTreeMap; #[cfg(feature = "iterator")] +use std::collections::HashMap; +#[cfg(feature = "iterator")] +use std::convert::TryInto; +#[cfg(feature = "iterator")] use std::ops::{Bound, RangeBounds}; #[cfg(feature = "iterator")] @@ -7,6 +11,8 @@ use cosmwasm_std::{Order, KV}; #[cfg(feature = "iterator")] use crate::traits::StorageIterator; +#[cfg(feature = "iterator")] +use crate::FfiError; use crate::{FfiResult, GasInfo, Storage}; #[cfg(feature = "iterator")] @@ -44,15 +50,40 @@ impl StorageIterator for MockIterator<'_> { } } +#[cfg(feature = "iterator")] +#[derive(Default, Debug)] +struct Iter { + data: Vec, + position: usize, +} + #[derive(Default, Debug)] pub struct MockStorage { data: BTreeMap, Vec>, + #[cfg(feature = "iterator")] + iterators: HashMap, } impl MockStorage { pub fn new() -> Self { MockStorage::default() } + + #[cfg(feature = "iterator")] + pub fn all(&mut self, iterator_id: u32) -> FfiResult> { + let mut out: Vec = Vec::new(); + let mut total = GasInfo::free(); + loop { + let (value, info) = self.next(iterator_id); + total.cost += info.cost; // TODO: implement GasInfo+GasInfo + if let Some(v) = value.unwrap() { + out.push(v); + } else { + break; + } + } + (Ok(out), total) + } } impl Storage for MockStorage { @@ -62,38 +93,57 @@ impl Storage for MockStorage { } #[cfg(feature = "iterator")] - /// range allows iteration over a set of keys, either forwards or backwards - /// uses standard rust range notation, and eg db.range(b"foo"..b"bar") also works reverse - fn range<'a>( - &'a self, - start: Option<&[u8]>, - end: Option<&[u8]>, - order: Order, - ) -> FfiResult> { + fn scan(&mut self, start: Option<&[u8]>, end: Option<&[u8]>, order: Order) -> FfiResult { let gas_info = GasInfo::with_externally_used(GAS_COST_RANGE); let bounds = range_bounds(start, end); - // BTreeMap.range panics if range is start > end. - // However, this cases represent just empty range and we treat it as such. - match (bounds.start_bound(), bounds.end_bound()) { - (Bound::Included(start), Bound::Excluded(end)) if start > end => { - return (Ok(Box::new(MockIterator::empty())), gas_info); + let values: Vec = match (bounds.start_bound(), bounds.end_bound()) { + // BTreeMap.range panics if range is start > end. + // However, this cases represent just empty range and we treat it as such. + (Bound::Included(start), Bound::Excluded(end)) if start > end => Vec::new(), + _ => match order { + Order::Ascending => self.data.range(bounds).map(clone_item).collect(), + Order::Descending => self.data.range(bounds).rev().map(clone_item).collect(), + }, + }; + + let last_id: u32 = self + .iterators + .len() + .try_into() + .expect("Found more iterator IDs than supported"); + let new_id = last_id + 1; + let iter = Iter { + data: values, + position: 0, + }; + self.iterators.insert(new_id, iter); + + (Ok(new_id), gas_info) + } + + #[cfg(feature = "iterator")] + fn next(&mut self, iterator_id: u32) -> FfiResult> { + let iterator = match self.iterators.get_mut(&iterator_id) { + Some(i) => i, + None => { + return ( + Err(FfiError::iterator_does_not_exist(iterator_id)), + GasInfo::free(), + ) } - _ => {} - } + }; - let original_iter = self.data.range(bounds); - let iter: Box> = match order { - Order::Ascending => Box::new(original_iter.map(clone_item).map(|item| { - let gas_cost = (item.0.len() + item.1.len()) as u64; - (item, gas_cost) - })), - Order::Descending => Box::new(original_iter.rev().map(clone_item).map(|item| { - let gas_cost = (item.0.len() + item.1.len()) as u64; - (item, gas_cost) - })), + let (value, gas_info): (Option, GasInfo) = if iterator.data.len() > iterator.position { + let item = iterator.data[iterator.position].clone(); + iterator.position += 1; + let gas_cost = (item.0.len() + item.1.len()) as u64; + (Some(item), GasInfo::with_cost(gas_cost)) + } else { + (None, GasInfo::with_externally_used(GAS_COST_LAST_ITERATION)) }; - (Ok(Box::new(MockIterator { source: iter })), gas_info) + + (Ok(value), gas_info) } fn set(&mut self, key: &[u8], value: &[u8]) -> FfiResult<()> { @@ -160,16 +210,8 @@ mod test { // ensure we had previously set "foo" = "bar" assert_eq!(store.get(b"foo").0.unwrap(), Some(b"bar".to_vec())); - assert_eq!( - store - .range(None, None, Order::Ascending) - .0 - .unwrap() - .elements() - .unwrap() - .len(), - 1 - ); + let iter_id = store.scan(None, None, Order::Ascending).0.unwrap(); + assert_eq!(store.all(iter_id).0.unwrap().len(), 1); // setup - add some data, and delete part of it as well store.set(b"ant", b"hill").0.expect("error setting value"); @@ -181,8 +223,8 @@ mod test { // unbounded { - let iter = store.range(None, None, Order::Ascending).0.unwrap(); - let elements = iter.elements().unwrap(); + let iter_id = store.scan(None, None, Order::Ascending).0.unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!( elements, vec![ @@ -195,8 +237,8 @@ mod test { // unbounded (descending) { - let iter = store.range(None, None, Order::Descending).0.unwrap(); - let elements = iter.elements().unwrap(); + let iter_id = store.scan(None, None, Order::Descending).0.unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!( elements, vec![ @@ -209,21 +251,21 @@ mod test { // bounded { - let iter = store - .range(Some(b"f"), Some(b"n"), Order::Ascending) + let iter_id = store + .scan(Some(b"f"), Some(b"n"), Order::Ascending) .0 .unwrap(); - let elements = iter.elements().unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!(elements, vec![(b"foo".to_vec(), b"bar".to_vec())]); } // bounded (descending) { - let iter = store - .range(Some(b"air"), Some(b"loop"), Order::Descending) + let iter_id = store + .scan(Some(b"air"), Some(b"loop"), Order::Descending) .0 .unwrap(); - let elements = iter.elements().unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!( elements, vec![ @@ -235,48 +277,48 @@ mod test { // bounded empty [a, a) { - let iter = store - .range(Some(b"foo"), Some(b"foo"), Order::Ascending) + let iter_id = store + .scan(Some(b"foo"), Some(b"foo"), Order::Ascending) .0 .unwrap(); - let elements = iter.elements().unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!(elements, vec![]); } // bounded empty [a, a) (descending) { - let iter = store - .range(Some(b"foo"), Some(b"foo"), Order::Descending) + let iter_id = store + .scan(Some(b"foo"), Some(b"foo"), Order::Descending) .0 .unwrap(); - let elements = iter.elements().unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!(elements, vec![]); } // bounded empty [a, b) with b < a { - let iter = store - .range(Some(b"z"), Some(b"a"), Order::Ascending) + let iter_id = store + .scan(Some(b"z"), Some(b"a"), Order::Ascending) .0 .unwrap(); - let elements = iter.elements().unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!(elements, vec![]); } // bounded empty [a, b) with b < a (descending) { - let iter = store - .range(Some(b"z"), Some(b"a"), Order::Descending) + let iter_id = store + .scan(Some(b"z"), Some(b"a"), Order::Descending) .0 .unwrap(); - let elements = iter.elements().unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!(elements, vec![]); } // right unbounded { - let iter = store.range(Some(b"f"), None, Order::Ascending).0.unwrap(); - let elements = iter.elements().unwrap(); + let iter_id = store.scan(Some(b"f"), None, Order::Ascending).0.unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!( elements, vec![ @@ -288,8 +330,8 @@ mod test { // right unbounded (descending) { - let iter = store.range(Some(b"f"), None, Order::Descending).0.unwrap(); - let elements = iter.elements().unwrap(); + let iter_id = store.scan(Some(b"f"), None, Order::Descending).0.unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!( elements, vec![ @@ -301,15 +343,15 @@ mod test { // left unbounded { - let iter = store.range(None, Some(b"f"), Order::Ascending).0.unwrap(); - let elements = iter.elements().unwrap(); + let iter_id = store.scan(None, Some(b"f"), Order::Ascending).0.unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!(elements, vec![(b"ant".to_vec(), b"hill".to_vec()),]); } // left unbounded (descending) { - let iter = store.range(None, Some(b"no"), Order::Descending).0.unwrap(); - let elements = iter.elements().unwrap(); + let iter_id = store.scan(None, Some(b"no"), Order::Descending).0.unwrap(); + let elements = store.all(iter_id).0.unwrap(); assert_eq!( elements, vec![ From fad1b70690d7138bf794b7876978b0260f242129 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 00:03:03 +0200 Subject: [PATCH 012/110] Use with_storage_from_context in do_next --- packages/vm/src/imports.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 2eb790198d..518eb89826 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -200,7 +200,7 @@ pub fn do_scan( #[cfg(feature = "iterator")] pub fn do_next(ctx: &mut Ctx, iterator_id: u32) -> VmResult { let (result, gas_info) = - with_iterator_from_context::(ctx, iterator_id, |iter| Ok(iter.next()))?; + with_storage_from_context::(ctx, |store| Ok(store.next(iterator_id)))?; process_gas_info::(ctx, gas_info)?; // Empty key will later be treated as _no more element_. @@ -1030,7 +1030,9 @@ mod test { let non_existent_id = 42u32; let result = do_next::(ctx, non_existent_id); match result.unwrap_err() { - VmError::IteratorDoesNotExist { id, .. } => assert_eq!(id, non_existent_id), + VmError::FfiErr { + source: FfiError::IteratorDoesNotExist { id, .. }, + } => assert_eq!(id, non_existent_id), e => panic!("Unexpected error: {:?}", e), } } From 8605e14c319cadcbd7e7d08dcf5715eac2f75ca3 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 00:03:18 +0200 Subject: [PATCH 013/110] Remove with_iterator_from_context --- packages/vm/src/context.rs | 50 -------------------------------------- packages/vm/src/imports.rs | 28 ++++++++++----------- 2 files changed, 13 insertions(+), 65 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index cf266fd9c5..eb1ac9a42e 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -346,24 +346,6 @@ where } } -#[cfg(feature = "iterator")] -pub(crate) fn with_iterator_from_context<'a, 'b, S: 'b, Q: 'b, F, T>( - ctx: &'a mut Ctx, - iterator_id: u32, - func: F, -) -> VmResult -where - S: Storage, - Q: Querier, - F: FnOnce(&'b mut (dyn StorageIterator + 'b)) -> VmResult, -{ - let b = get_context_data_mut::(ctx); - match b.iterators.get_mut(&iterator_id) { - Some(iterator) => func(iterator), - None => Err(VmError::iterator_does_not_exist(iterator_id)), - } -} - #[cfg(test)] mod test { use super::*; @@ -690,36 +672,4 @@ mod test { }) .unwrap(); } - - #[test] - #[cfg(feature = "iterator")] - fn with_iterator_from_context_works() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); - - let id = add_iterator::(ctx, Box::new(MockIterator::empty())); - with_iterator_from_context::(ctx, id, |iter| { - assert!(iter.next().0.unwrap().is_none()); - Ok(()) - }) - .expect("must not error"); - } - - #[test] - #[cfg(feature = "iterator")] - fn with_iterator_from_context_errors_for_non_existent_iterator_id() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); - - let missing_id = 42u32; - let result = with_iterator_from_context::(ctx, missing_id, |_iter| { - panic!("this should not be called"); - }); - match result.unwrap_err() { - VmError::IteratorDoesNotExist { id, .. } => assert_eq!(id, missing_id), - err => panic!("Unexpected error: {:?}", err), - } - } } diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 518eb89826..4e90b997b9 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -9,8 +9,6 @@ use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr}; use wasmer_runtime_core::vm::Ctx; use crate::backends::get_gas_left; -#[cfg(feature = "iterator")] -use crate::context::with_iterator_from_context; use crate::context::{ is_storage_readonly, process_gas_info, with_func_from_context, with_querier_from_context, with_storage_from_context, @@ -875,15 +873,15 @@ mod test { assert_eq!(1, id); let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); assert!(item.0.unwrap().is_none()); } @@ -899,15 +897,15 @@ mod test { assert_eq!(1, id); let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); assert!(item.0.unwrap().is_none()); } @@ -925,11 +923,11 @@ mod test { let id = do_scan::(ctx, start, end, Order::Ascending.into()).unwrap(); let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); let item = - with_iterator_from_context::(ctx, id, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id))).unwrap(); assert!(item.0.unwrap().is_none()); } @@ -948,27 +946,27 @@ mod test { // first item, first iterator let item = - with_iterator_from_context::(ctx, id1, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |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_iterator_from_context::(ctx, id1, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |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_iterator_from_context::(ctx, id2, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id2))).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); // end, first iterator let item = - with_iterator_from_context::(ctx, id1, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id1))).unwrap(); assert!(item.0.unwrap().is_none()); // second item, second iterator let item = - with_iterator_from_context::(ctx, id2, |iter| Ok(iter.next())).unwrap(); + with_storage_from_context::(ctx, |store| Ok(store.next(id2))).unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); } From ae4cc8ba3030e91cc790762296b8ca2c68a7698b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 00:03:34 +0200 Subject: [PATCH 014/110] Remove VmError::IteratorDoesNotExist --- packages/vm/src/errors/vm_error.rs | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index 83d6b4ef9a..7101a2468f 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -43,11 +43,6 @@ pub enum VmError { }, #[snafu(display("Hash doesn't match stored data"))] IntegrityErr { backtrace: snafu::Backtrace }, - #[snafu(display("Iterator with ID {} does not exist", id))] - IteratorDoesNotExist { - id: u32, - backtrace: snafu::Backtrace, - }, #[snafu(display("Error parsing into type {}: {}", target, msg))] ParseErr { /// the target type that was attempted @@ -128,11 +123,6 @@ impl VmError { IntegrityErr {}.build() } - #[cfg(feature = "iterator")] - pub(crate) fn iterator_does_not_exist(iterator_id: u32) -> Self { - IteratorDoesNotExist { id: iterator_id }.build() - } - pub(crate) fn parse_err, M: Display>(target: T, msg: M) -> Self { ParseErr { target: target.into(), @@ -308,16 +298,6 @@ mod test { } } - #[test] - #[cfg(feature = "iterator")] - fn iterator_does_not_exist_works() { - let error = VmError::iterator_does_not_exist(15); - match error { - VmError::IteratorDoesNotExist { id, .. } => assert_eq!(id, 15), - e => panic!("Unexpected error: {:?}", e), - } - } - #[test] fn parse_err_works() { let error = VmError::parse_err("Book", "Missing field: title"); From 069a6a57cf637b95cf69714788f80e0aa01f6a9a Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 00:12:10 +0200 Subject: [PATCH 015/110] Remove iterators from ContextData --- packages/vm/src/context.rs | 89 +++----------------------------------- 1 file changed, 6 insertions(+), 83 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index eb1ac9a42e..1c936764be 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -1,11 +1,6 @@ //! Internal details to be used by instance.rs only -#[cfg(feature = "iterator")] -use std::collections::HashMap; -#[cfg(feature = "iterator")] -use std::convert::TryInto; + use std::ffi::c_void; -#[cfg(not(feature = "iterator"))] -use std::marker::PhantomData; use std::ptr::NonNull; use wasmer_runtime_core::{ @@ -17,8 +12,6 @@ use wasmer_runtime_core::{ use crate::backends::decrease_gas_left; use crate::errors::{VmError, VmResult}; use crate::ffi::GasInfo; -#[cfg(feature = "iterator")] -use crate::traits::StorageIterator; use crate::traits::{Querier, Storage}; /** context data **/ @@ -70,17 +63,13 @@ impl GasState { } } -struct ContextData<'a, S: Storage, Q: Querier> { +struct ContextData { gas_state: GasState, storage: Option, storage_readonly: bool, querier: Option, /// A non-owning link to the wasmer instance wasmer_instance: Option>, - #[cfg(feature = "iterator")] - iterators: HashMap>, - #[cfg(not(feature = "iterator"))] - iterators: PhantomData<&'a mut ()>, } pub fn setup_context(gas_limit: u64) -> (*mut c_void, fn(*mut c_void)) { @@ -97,10 +86,6 @@ fn create_unmanaged_context_data(gas_limit: u64) -> *mut storage_readonly: true, querier: None, wasmer_instance: None, - #[cfg(feature = "iterator")] - iterators: HashMap::new(), - #[cfg(not(feature = "iterator"))] - iterators: PhantomData::default(), }; let heap_data = Box::new(data); // move from stack to heap Box::into_raw(heap_data) as *mut c_void // give up ownership @@ -109,9 +94,7 @@ fn create_unmanaged_context_data(gas_limit: u64) -> *mut 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 mut dying = unsafe { Box::from_raw(ptr as *mut ContextData) }; - // Ensure all iterators are dropped before the storage - destroy_iterators(&mut dying); + let _dying = unsafe { Box::from_raw(ptr as *mut ContextData) }; } } @@ -137,7 +120,7 @@ fn destroy_unmanaged_context_data(ptr: *mut c_void) { // probably triggers unsoundness. fn get_context_data_mut<'a, 'b, S: Storage, Q: Querier>( ctx: &'a mut Ctx, -) -> &'b mut ContextData<'b, S, Q> { +) -> &'b mut ContextData { unsafe { let ptr = ctx.data as *mut ContextData; ptr.as_mut() @@ -145,7 +128,7 @@ fn get_context_data_mut<'a, 'b, S: Storage, Q: Querier>( } } -fn get_context_data<'a, 'b, S: Storage, Q: Querier>(ctx: &'a Ctx) -> &'b ContextData<'b, S, Q> { +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() @@ -164,25 +147,12 @@ pub fn set_wasmer_instance( } } -#[cfg(feature = "iterator")] -fn destroy_iterators(context: &mut ContextData) { - context.iterators.clear(); -} - -#[cfg(not(feature = "iterator"))] -fn destroy_iterators(_context: &mut ContextData) {} - /// 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 mut b = get_context_data_mut::(source); - // Destroy all existing iterators which are (in contrast to the storage) - // not reused between different instances. - // This is also important because the iterators are pointers to Go memory which should not be stored long term - // Paragraphs 5-7: https://golang.org/cmd/cgo/#hdr-Passing_pointers - destroy_iterators(&mut b); + let b = get_context_data_mut::(source); (b.storage.take(), b.querier.take()) } @@ -270,28 +240,6 @@ pub fn set_storage_readonly(ctx: &mut Ctx, new_value: bo context_data.storage_readonly = new_value; } -/// Add the iterator to the context's data. A new ID is assigned and returned. -/// IDs are guaranteed to be in the range [0, 2**31-1], i.e. fit in the non-negative part if type i32. -#[cfg(feature = "iterator")] -#[must_use = "without the returned iterator ID, the iterator cannot be accessed"] -pub fn add_iterator<'a, S: Storage, Q: Querier>( - ctx: &mut Ctx, - iter: Box, -) -> u32 { - let b = get_context_data_mut::(ctx); - let last_id: u32 = b - .iterators - .len() - .try_into() - .expect("Found more iterator IDs than supported"); - let new_id = last_id + 1; - if new_id > (i32::MAX as u32) { - panic!("Iterator ID exceeded i32::MAX. This must not happen."); - } - b.iterators.insert(new_id, iter); - new_id -} - pub(crate) fn with_func_from_context( ctx: &mut Ctx, name: &str, @@ -351,8 +299,6 @@ mod test { use super::*; use crate::backends::{compile, decrease_gas_left, set_gas_left}; use crate::errors::VmError; - #[cfg(feature = "iterator")] - use crate::testing::MockIterator; use crate::testing::{MockQuerier, MockStorage}; use crate::traits::Storage; use cosmwasm_std::{ @@ -518,29 +464,6 @@ mod test { assert_eq!(is_storage_readonly::(ctx), true); } - #[test] - #[cfg(feature = "iterator")] - fn add_iterator_works() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(ctx); - - assert_eq!(get_context_data_mut::(ctx).iterators.len(), 0); - let id1 = add_iterator::(ctx, Box::new(MockIterator::empty())); - let id2 = add_iterator::(ctx, Box::new(MockIterator::empty())); - let id3 = add_iterator::(ctx, Box::new(MockIterator::empty())); - assert_eq!(get_context_data_mut::(ctx).iterators.len(), 3); - assert!(get_context_data_mut::(ctx) - .iterators - .contains_key(&id1)); - assert!(get_context_data_mut::(ctx) - .iterators - .contains_key(&id2)); - assert!(get_context_data_mut::(ctx) - .iterators - .contains_key(&id3)); - } - #[test] fn with_func_from_context_works() { let mut instance = make_instance(); From 0bf8d4d13851750354bef850d9279433124052a0 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 00:22:31 +0200 Subject: [PATCH 016/110] Implement AddAssign for GasInfo --- packages/vm/src/ffi.rs | 10 ++++++++++ packages/vm/src/testing/storage.rs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/vm/src/ffi.rs b/packages/vm/src/ffi.rs index 1a7ccee8c5..1f40456ddc 100644 --- a/packages/vm/src/ffi.rs +++ b/packages/vm/src/ffi.rs @@ -1,5 +1,6 @@ use snafu::Snafu; use std::fmt::Debug; +use std::ops::AddAssign; use std::string::FromUtf8Error; /// A result type for calling into the backend via FFI. Such a call causes @@ -43,6 +44,15 @@ impl GasInfo { } } +impl AddAssign for GasInfo { + fn add_assign(&mut self, other: Self) { + *self = GasInfo { + cost: self.cost + other.cost, + externally_used: self.externally_used + other.cost, + }; + } +} + #[derive(Debug, Snafu)] pub enum FfiError { #[snafu(display("Panic in FFI call"))] diff --git a/packages/vm/src/testing/storage.rs b/packages/vm/src/testing/storage.rs index f3eeab203d..e50f8e30f1 100644 --- a/packages/vm/src/testing/storage.rs +++ b/packages/vm/src/testing/storage.rs @@ -75,7 +75,7 @@ impl MockStorage { let mut total = GasInfo::free(); loop { let (value, info) = self.next(iterator_id); - total.cost += info.cost; // TODO: implement GasInfo+GasInfo + total += info; if let Some(v) = value.unwrap() { out.push(v); } else { From 1c648c7b1a7b8e8c4195cf8544f3e73383e27003 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 12:04:09 +0200 Subject: [PATCH 017/110] Handle errors in self.next perperly --- packages/vm/src/testing/storage.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/vm/src/testing/storage.rs b/packages/vm/src/testing/storage.rs index e50f8e30f1..a12d6e7aab 100644 --- a/packages/vm/src/testing/storage.rs +++ b/packages/vm/src/testing/storage.rs @@ -74,12 +74,17 @@ impl MockStorage { let mut out: Vec = Vec::new(); let mut total = GasInfo::free(); loop { - let (value, info) = self.next(iterator_id); + let (result, info) = self.next(iterator_id); total += info; - if let Some(v) = value.unwrap() { - out.push(v); - } else { - break; + match result { + Err(err) => return (Err(err), total), + Ok(ok) => { + if let Some(v) = ok { + out.push(v); + } else { + break; + } + } } } (Ok(out), total) From b14e190e8c5921895b75e6a9ce1f6a61543cd2ec Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 12:40:54 +0200 Subject: [PATCH 018/110] Adapt burner integration tests to new storage --- contracts/burner/tests/integration.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/contracts/burner/tests/integration.rs b/contracts/burner/tests/integration.rs index 365a1316a6..6ee6b06ee5 100644 --- a/contracts/burner/tests/integration.rs +++ b/contracts/burner/tests/integration.rs @@ -21,7 +21,6 @@ use cosmwasm_std::{ coins, BankMsg, ContractResult, HumanAddr, InitResponse, MigrateResponse, Order, }; use cosmwasm_vm::testing::{init, migrate, mock_env, mock_info, mock_instance, MOCK_CONTRACT_ADDR}; -use cosmwasm_vm::StorageIterator; use burner::msg::{InitMsg, MigrateMsg}; use cosmwasm_vm::Storage; @@ -55,13 +54,8 @@ fn migrate_cleans_up_data() { storage.set(b"foo", b"bar").0.unwrap(); storage.set(b"key2", b"data2").0.unwrap(); storage.set(b"key3", b"cool stuff").0.unwrap(); - let cnt = storage - .range(None, None, Order::Ascending) - .0 - .unwrap() - .elements() - .unwrap() - .len(); + let iter_id = storage.scan(None, None, Order::Ascending).0.unwrap(); + let cnt = storage.all(iter_id).0.unwrap().len(); assert_eq!(3, cnt); Ok(()) }) @@ -89,13 +83,8 @@ fn migrate_cleans_up_data() { // check there is no data in storage deps.with_storage(|storage| { - let cnt = storage - .range(None, None, Order::Ascending) - .0 - .unwrap() - .elements() - .unwrap() - .len(); + let iter_id = storage.scan(None, None, Order::Ascending).0.unwrap(); + let cnt = storage.all(iter_id).0.unwrap().len(); assert_eq!(0, cnt); Ok(()) }) From c90020b1e161a5d73c1b371b4ee73f91ecf001d7 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 13:48:19 +0200 Subject: [PATCH 019/110] Add note on iterator IDs --- packages/vm/src/traits.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/vm/src/traits.rs b/packages/vm/src/traits.rs index e84cbcef35..db03127a64 100644 --- a/packages/vm/src/traits.rs +++ b/packages/vm/src/traits.rs @@ -77,6 +77,8 @@ pub trait Storage { /// /// This call must not change data in the storage, but creating and storing a new iterator can be a mutating operation on /// the Storage implementation. + /// The implementation must ensure that iterator IDs are assigned in a deterministic manner as this is + /// environment data that is injected into the contract. #[cfg(feature = "iterator")] fn scan(&mut self, start: Option<&[u8]>, end: Option<&[u8]>, order: Order) -> FfiResult; From a40eb0ed5880a6f03d436320867429446a678b24 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 7 Oct 2020 14:09:03 +0200 Subject: [PATCH 020/110] Remove StorageIterator and MockIterator --- packages/vm/src/lib.rs | 3 --- packages/vm/src/testing/mod.rs | 2 -- packages/vm/src/testing/storage.rs | 31 ------------------------------ packages/vm/src/traits.rs | 31 ------------------------------ 4 files changed, 67 deletions(-) diff --git a/packages/vm/src/lib.rs b/packages/vm/src/lib.rs index 75301acbf7..5eab7f0169 100644 --- a/packages/vm/src/lib.rs +++ b/packages/vm/src/lib.rs @@ -33,6 +33,3 @@ pub use crate::instance::{GasReport, Instance}; pub use crate::modules::FileSystemCache; pub use crate::serde::{from_slice, to_vec}; pub use crate::traits::{Api, Extern, Querier, Storage}; - -#[cfg(feature = "iterator")] -pub use crate::traits::StorageIterator; diff --git a/packages/vm/src/testing/mod.rs b/packages/vm/src/testing/mod.rs index 4490297be3..46783fb4b5 100644 --- a/packages/vm/src/testing/mod.rs +++ b/packages/vm/src/testing/mod.rs @@ -16,6 +16,4 @@ pub use mock::{ MOCK_CONTRACT_ADDR, }; pub use querier::MockQuerier; -#[cfg(feature = "iterator")] -pub use storage::MockIterator; pub use storage::MockStorage; diff --git a/packages/vm/src/testing/storage.rs b/packages/vm/src/testing/storage.rs index a12d6e7aab..b8138cc4c7 100644 --- a/packages/vm/src/testing/storage.rs +++ b/packages/vm/src/testing/storage.rs @@ -9,8 +9,6 @@ use std::ops::{Bound, RangeBounds}; #[cfg(feature = "iterator")] use cosmwasm_std::{Order, KV}; -#[cfg(feature = "iterator")] -use crate::traits::StorageIterator; #[cfg(feature = "iterator")] use crate::FfiError; use crate::{FfiResult, GasInfo, Storage}; @@ -21,35 +19,6 @@ const GAS_COST_LAST_ITERATION: u64 = 37; #[cfg(feature = "iterator")] const GAS_COST_RANGE: u64 = 11; -/// A storage iterator for testing only. This type uses a Rust iterator -/// as a data source, which does not provide a gas value for the last iteration. -#[cfg(feature = "iterator")] -pub struct MockIterator<'a> { - source: Box + 'a>, -} - -#[cfg(feature = "iterator")] -impl MockIterator<'_> { - pub fn empty() -> Self { - MockIterator { - source: Box::new(std::iter::empty()), - } - } -} - -#[cfg(feature = "iterator")] -impl StorageIterator for MockIterator<'_> { - fn next(&mut self) -> FfiResult> { - match self.source.next() { - Some((kv, gas_used)) => (Ok(Some(kv)), GasInfo::with_externally_used(gas_used)), - None => ( - Ok(None), - GasInfo::with_externally_used(GAS_COST_LAST_ITERATION), - ), - } - } -} - #[cfg(feature = "iterator")] #[derive(Default, Debug)] struct Iter { diff --git a/packages/vm/src/traits.rs b/packages/vm/src/traits.rs index db03127a64..c163502499 100644 --- a/packages/vm/src/traits.rs +++ b/packages/vm/src/traits.rs @@ -2,8 +2,6 @@ use cosmwasm_std::{Binary, CanonicalAddr, ContractResult, HumanAddr, SystemResul #[cfg(feature = "iterator")] use cosmwasm_std::{Order, KV}; -#[cfg(feature = "iterator")] -use crate::ffi::FfiError; use crate::ffi::FfiResult; /// Holds all external dependencies of the contract. @@ -29,35 +27,6 @@ impl Extern { } } -#[cfg(feature = "iterator")] -pub trait StorageIterator { - fn next(&mut self) -> FfiResult>; - - /// Collects all elements, ignoring gas costs - fn elements(mut self) -> Result, FfiError> - where - Self: Sized, - { - let mut out: Vec = Vec::new(); - loop { - let (result, _gas_info) = self.next(); - match result { - Ok(Some(kv)) => out.push(kv), - Ok(None) => break, - Err(err) => return Err(err), - } - } - Ok(out) - } -} - -#[cfg(feature = "iterator")] -impl StorageIterator for Box { - fn next(&mut self) -> FfiResult> { - (**self).next() - } -} - /// Access to the VM's backend storage, i.e. the chain pub trait Storage { /// Returns Err on error. From 5fe4cbe632d2042ab4c7821ffb7fe4c2a73a9631 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 12 Oct 2020 11:38:42 +0200 Subject: [PATCH 021/110] Add CHANGELOG entries --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a0eb0435a..7e9674e6aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # CHANGELOG +## 0.12.0 (unreleased) + +**cosmwasm-vm** + +- Remove `Storage::range` and `StorageIterator`. The storage implementation is + now responsible for maintaining iterators internally and make them accessible + via the new `Storage::scan` and `Storage::next` methods. +- Add `FfiError::IteratorDoesNotExist`. Looking at this, `FfiError` should + probably be renamed to something that includes before, on and behind the FFI + boundary to Go. +- `MockStorage` now implementes the new `Storage` trait and has an additional + `MockStorage::all` for getting all elements of an iterator in tests. + ## 0.11.1 (unreleased) **cosmwasm-std** From 30a3e82670269d1538e0a1ed00135c7c2d5ddb27 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 12 Oct 2020 11:44:45 +0200 Subject: [PATCH 022/110] Remove outdated doc comment --- packages/vm/src/context.rs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 1c936764be..0866a02ad2 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -99,25 +99,6 @@ fn destroy_unmanaged_context_data(ptr: *mut c_void) { } /// Get a mutable reference to the context's data. Ownership remains in the Context. -// NOTE: This is actually not really implemented safely at the moment. I did this as a -// nicer and less-terrible version of the previous solution to the following issue: -// -// +--->> Go pointer -// | -// Ctx ->> ContextData +-> iterators: Box --+ -// | | -// +-> storage: impl Storage <<------------+ -// | -// +-> querier: impl Querier -// -// -> : Ownership -// ->> : Mutable borrow -// -// As you can see, there's a cyclical reference here... changing this function to return the same lifetime as it -// returns (and adjusting a few other functions to only have one lifetime instead of two) triggers an error -// elsewhere where we try to add iterators to the context. That's not legal according to Rust's rules, and it -// complains that we're trying to borrow ctx mutably twice. This needs a better solution because this function -// probably triggers unsoundness. fn get_context_data_mut<'a, 'b, S: Storage, Q: Querier>( ctx: &'a mut Ctx, ) -> &'b mut ContextData { From a709584741a16569a041fefbe69df3cce11085d1 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 12 Oct 2020 11:55:37 +0200 Subject: [PATCH 023/110] Bump wasmer version in lockfile --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54463e7566..547ede609d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1095,7 +1095,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "cfg-if", "indexmap", @@ -1115,7 +1115,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "enumset", "raw-cpuid", @@ -1131,7 +1131,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "byteorder", "dynasm", @@ -1164,7 +1164,7 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "backtrace", "bincode", @@ -1182,7 +1182,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "bincode", "cfg-if", @@ -1198,7 +1198,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "bincode", "cfg-if", @@ -1217,7 +1217,7 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "object", "thiserror", @@ -1227,7 +1227,7 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "cranelift-entity", "serde", @@ -1235,7 +1235,7 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha3" +version = "1.0.0-alpha4" dependencies = [ "backtrace", "cc", From 4efb55fbd4e3a81be59edb8127bedb95d4ce2fa3 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 12 Oct 2020 14:36:08 +0200 Subject: [PATCH 024/110] Update a lot of tests --- packages/vm/src/context.rs | 112 ++++++------- packages/vm/src/imports.rs | 326 +++++++++++++++++------------------- packages/vm/src/instance.rs | 3 + 3 files changed, 216 insertions(+), 225 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 74fd7ab04c..510b5b4797 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -300,7 +300,9 @@ mod test { use cosmwasm_std::{ coins, from_binary, to_vec, AllBalanceResponse, BankQuery, Empty, HumanAddr, QueryRequest, }; - use wasmer::imports; + use std::sync::{Arc, RwLock}; + use wasmer::{imports, Store}; + use wasmer_engine_jit::JIT; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); @@ -319,7 +321,16 @@ mod test { const GAS_LIMIT: u64 = 5_000_000; const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000; - fn make_instance() -> Box { + fn make_instance() -> (Env, Box) { + let engine = JIT::headless().engine(); + let store = Store::new(&engine); + + let mut env = Env { + memory: wasmer::Memory::new(&store, wasmer::MemoryType::new(0, Some(5000), false)) + .expect("could not create memory"), + context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), + }; + let module = compile(&CONTRACT).unwrap(); // we need stubs for all required imports let import_obj = imports! { @@ -338,12 +349,12 @@ mod test { let mut instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); - set_wasmer_instance::(&mut instance.context_mut(), Some(instance_ptr)); + set_wasmer_instance::(&mut env, Some(instance_ptr)); - instance + (env, instance) } - fn leave_default_data(ctx: &mut Ctx) { + fn leave_default_data(env: &mut Env) { // create some mock data let mut storage = MockStorage::new(); storage @@ -352,23 +363,21 @@ mod test { .expect("error setting value"); let querier: MockQuerier = MockQuerier::new(&[(&HumanAddr::from(INIT_ADDR), &coins(INIT_AMOUNT, INIT_DENOM))]); - move_into_context(ctx, storage, querier); + move_into_context(env, storage, querier); } #[test] fn leave_and_take_context_data() { - // this creates an instance - let mut instance = make_instance(); - let ctx = instance.context_mut(); + let (mut env, mut instance) = make_instance(); // empty data on start - let (inits, initq) = move_out_of_context::(&mut ctx); + let (inits, initq) = move_out_of_context::(&mut env); assert!(inits.is_none()); assert!(initq.is_none()); // store it on the instance - leave_default_data(&mut ctx); - let (s, q) = move_out_of_context::(&mut ctx); + leave_default_data(&mut env); + let (s, q) = move_out_of_context::(&mut env); assert!(s.is_some()); assert!(q.is_some()); assert_eq!( @@ -377,7 +386,7 @@ mod test { ); // now is empty again - let (ends, endq) = move_out_of_context::(&mut ctx); + let (ends, endq) = move_out_of_context::(&mut env); assert!(ends.is_none()); assert!(endq.is_none()); } @@ -385,11 +394,11 @@ mod test { #[test] #[cfg(feature = "default-singlepass")] fn gas_tracking_works_correctly() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let gas_limit = 100; set_gas_left(&mut instance.context_mut(), gas_limit); - get_gas_state_mut::(&mut instance.context_mut()).set_gas_limit(gas_limit); + env.with_gas_state_mut(|state| state.set_gas_limit(gas_limit)); let context = instance.context_mut(); // Consume all the Gas that we allocated @@ -407,11 +416,11 @@ mod test { #[test] #[cfg(feature = "default-singlepass")] fn gas_tracking_works_correctly_with_gas_consumption_in_wasmer() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let gas_limit = 100; set_gas_left(&mut instance.context_mut(), gas_limit); - get_gas_state_mut::(&mut instance.context_mut()).set_gas_limit(gas_limit); + env.with_gas_state_mut(|state| state.set_gas_limit(gas_limit)); let context = instance.context_mut(); // Some gas was consumed externally @@ -433,40 +442,37 @@ mod test { #[test] fn is_storage_readonly_defaults_to_true() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); - assert_eq!(is_storage_readonly::(&ctx), true); + assert_eq!(is_storage_readonly::(&env), true); } #[test] fn set_storage_readonly_can_change_flag() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); // change - set_storage_readonly::(&mut ctx, false); - assert_eq!(is_storage_readonly::(&ctx), false); + set_storage_readonly::(&mut env, false); + assert_eq!(is_storage_readonly::(&env), false); // still false - set_storage_readonly::(&mut ctx, false); - assert_eq!(is_storage_readonly::(&ctx), false); + set_storage_readonly::(&mut env, false); + assert_eq!(is_storage_readonly::(&env), false); // change back - set_storage_readonly::(&mut ctx, true); - assert_eq!(is_storage_readonly::(&ctx), true); + set_storage_readonly::(&mut env, true); + assert_eq!(is_storage_readonly::(&env), true); } #[test] fn with_func_from_context_works() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); leave_default_data(&mut instance.context_mut()); - let ctx = instance.context_mut(); let ptr = - with_func_from_context::(&mut ctx, "allocate", |alloc_func| { + with_func_from_context::(&mut env, "allocate", |alloc_func| { let ptr = alloc_func.call(10)?; Ok(ptr) }) @@ -476,15 +482,14 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_instance() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); leave_default_data(&mut instance.context_mut()); // Clear context's wasmer_instance set_wasmer_instance::(&mut instance.context_mut(), None); - let ctx = instance.context_mut(); let res = - with_func_from_context::(&mut ctx, "allocate", |_func| { + with_func_from_context::(&mut env, "allocate", |_func| { panic!("unexpected callback call"); }); match res.unwrap_err() { @@ -495,12 +500,11 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_function() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); leave_default_data(&mut instance.context_mut()); - let ctx = instance.context_mut(); let res = - with_func_from_context::(&mut ctx, "doesnt_exist", |_func| { + with_func_from_context::(&mut env, "doesnt_exist", |_func| { panic!("unexpected callback call"); }); match res.unwrap_err() { @@ -516,11 +520,10 @@ mod test { #[test] fn with_storage_from_context_set_get() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); - let val = with_storage_from_context::(&mut ctx, |store| { + let val = with_storage_from_context::(&mut env, |store| { Ok(store.get(INIT_KEY).0.expect("error getting value")) }) .unwrap(); @@ -538,7 +541,7 @@ mod test { }) .unwrap(); - with_storage_from_context::(&mut ctx, |store| { + with_storage_from_context::(&mut env, |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(()) @@ -549,11 +552,10 @@ mod test { #[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(&mut ctx); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); - with_storage_from_context::(&mut ctx, |_store| { + with_storage_from_context::(&mut env, |_store| { panic!("A panic occurred in the callback.") }) .unwrap(); @@ -561,11 +563,10 @@ mod test { #[test] fn with_querier_from_context_works() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(&mut ctx); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); - let res = with_querier_from_context::(&mut ctx, |querier| { + let res = with_querier_from_context::(&mut env, |querier| { let req: QueryRequest = QueryRequest::Bank(BankQuery::AllBalances { address: HumanAddr::from(INIT_ADDR), }); @@ -584,11 +585,10 @@ mod test { #[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(&mut ctx); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); - with_querier_from_context::(&mut ctx, |_querier| { + with_querier_from_context::(env.clone(), |_querier| { panic!("A panic occurred in the callback.") }) .unwrap(); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 9aad3ae95e..3d92b817dc 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -232,10 +232,14 @@ mod test { SystemError, SystemResult, WasmQuery, }; use std::ptr::NonNull; - use wasmer::{imports, Function, Instance as WasmerInstance}; + use std::sync::{Arc, RwLock}; + use wasmer::{imports, Instance as WasmerInstance, Store}; + use wasmer_engine_jit::JIT; use crate::backends::compile; - use crate::context::{move_into_context, set_storage_readonly, set_wasmer_instance}; + use crate::context::{ + move_into_context, set_storage_readonly, set_wasmer_instance, ContextData, + }; use crate::testing::{MockApi, MockQuerier, MockStorage}; use crate::traits::Storage; use crate::FfiError; @@ -260,7 +264,16 @@ mod test { const GAS_LIMIT: u64 = 5_000_000; - fn make_instance() -> Box { + fn make_instance() -> (Env, Box) { + let engine = JIT::headless().engine(); + let store = Store::new(&engine); + + let mut env = Env { + memory: wasmer::Memory::new(&store, wasmer::MemoryType::new(0, Some(5000), false)) + .expect("could not create memory"), + context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), + }; + let module = compile(&CONTRACT).unwrap(); // we need stubs for all required imports let import_obj = imports! { @@ -276,16 +289,16 @@ mod test { // "debug" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), }, }; - let mut instance = Box::from(module.instantiate(&import_obj).unwrap()); + let mut instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); - set_wasmer_instance::(&mut instance.context_mut(), Some(instance_ptr)); - set_storage_readonly::(&mut instance.context_mut(), false); + set_wasmer_instance::(&mut env, Some(instance_ptr)); + set_storage_readonly::(&mut env, false); - instance + (env, instance) } - fn leave_default_data(ctx: &mut Ctx) { + fn leave_default_data(env: &mut Env) { // create some mock data let mut storage = MockStorage::new(); storage.set(KEY1, VALUE1).0.expect("error setting"); @@ -296,63 +309,64 @@ mod test { } fn write_data(wasmer_instance: &mut WasmerInstance, data: &[u8]) -> u32 { - let allocate: Function = wasmer_instance + let allocate = wasmer_instance .exports .get_function("allocate") .expect("error getting function"); - let region_ptr = allocate - .call(data.len() as u32) + let result = allocate + .call(&[(data.len() as u32).into()]) .expect("error calling allocate"); - write_region(&mut wasmer_instance.context_mut(), region_ptr, data).expect("error writing"); + let region_ptr = result[0].unwrap_i32() as u32; + // write_region(&mut wasmer_instance, region_ptr, data).expect("error writing"); region_ptr } fn create_empty(wasmer_instance: &mut WasmerInstance, capacity: u32) -> u32 { - let allocate: Function = wasmer_instance + let allocate = wasmer_instance .exports .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 = result[0].unwrap_i32() as u32; region_ptr } /// A Region reader that is just good enough for the tests in this file - fn force_read(env: &Env, region_ptr: u32) -> Vec { - read_region(env, region_ptr, 5000).unwrap() + fn force_read(&env: &Env, 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(&mut instance.context_mut()); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); let key_ptr = write_data(&mut instance, KEY1); - let ctx = instance.context_mut(); - let result = do_read::(env, key_ptr); + let result = do_read::(&mut env, key_ptr); let value_ptr = result.unwrap(); assert!(value_ptr > 0); - assert_eq!(force_read(env, 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(&mut instance.context_mut()); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); let key_ptr = write_data(&mut instance, b"I do not exist in storage"); - let ctx = instance.context_mut(); - let result = do_read::(env, key_ptr); + let result = do_read::(&mut env, key_ptr); assert_eq!(result.unwrap(), 0); } #[test] fn do_read_fails_for_large_key() { - let mut instance = make_instance(); - leave_default_data(&mut instance.context_mut()); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); let key_ptr = write_data(&mut instance, &vec![7u8; 300 * 1024]); - let ctx = instance.context_mut(); - let result = do_read::(env, key_ptr); + let result = do_read::(&mut env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionLengthTooBig { length, .. }, @@ -363,15 +377,14 @@ mod test { #[test] fn do_write_works() { - let mut instance = make_instance(); + let (mut env, mut 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 ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - do_write::(env, key_ptr, value_ptr).unwrap(); + do_write::(&mut env, key_ptr, value_ptr).unwrap(); let val = with_storage_from_context::(env, |store| { Ok(store @@ -385,15 +398,14 @@ mod test { #[test] fn do_write_can_override() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, KEY1); let value_ptr = write_data(&mut instance, VALUE2); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - do_write::(env, key_ptr, value_ptr).unwrap(); + do_write::(&mut env, key_ptr, value_ptr).unwrap(); let val = with_storage_from_context::(env, |store| { Ok(store.get(KEY1).0.expect("error getting value")) @@ -404,15 +416,14 @@ mod test { #[test] fn do_write_works_for_empty_value() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, b"new storage key"); let value_ptr = write_data(&mut instance, b""); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - do_write::(env, key_ptr, value_ptr).unwrap(); + do_write::(&mut env, key_ptr, value_ptr).unwrap(); let val = with_storage_from_context::(env, |store| { Ok(store @@ -426,15 +437,14 @@ mod test { #[test] fn do_write_fails_for_large_key() { - let mut instance = make_instance(); + let (mut env, mut 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 ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - let result = do_write::(env, key_ptr, value_ptr); + let result = do_write::(&mut env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -451,15 +461,14 @@ mod test { #[test] fn do_write_fails_for_large_value() { - let mut instance = make_instance(); + let (mut env, mut 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 ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - let result = do_write::(env, key_ptr, value_ptr); + let result = do_write::(&mut env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -476,16 +485,15 @@ mod test { #[test] fn do_write_is_prohibited_in_readonly_contexts() { - let mut instance = make_instance(); + let (mut env, mut 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 ctx = instance.context_mut(); - leave_default_data(env); - set_storage_readonly::(env, true); + leave_default_data(&mut env); + set_storage_readonly::(&mut env, true); - let result = do_write::(env, key_ptr, value_ptr); + let result = do_write::(&mut env, key_ptr, value_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -494,15 +502,14 @@ mod test { #[test] fn do_remove_works() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let existing_key = KEY1; let key_ptr = write_data(&mut instance, existing_key); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - do_remove::(env, key_ptr).unwrap(); + do_remove::(&mut env, key_ptr).unwrap(); let value = with_storage_from_context::(env, |store| { Ok(store.get(existing_key).0.expect("error getting value")) @@ -513,16 +520,15 @@ mod test { #[test] fn do_remove_works_for_non_existent_key() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let non_existent_key = b"I do not exist"; let key_ptr = write_data(&mut instance, non_existent_key); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); // Note: right now we cannot differnetiate between an existent and a non-existent key - do_remove::(env, key_ptr).unwrap(); + do_remove::(&mut env, key_ptr).unwrap(); let value = with_storage_from_context::(env, |store| { Ok(store.get(non_existent_key).0.expect("error getting value")) @@ -533,14 +539,13 @@ mod test { #[test] fn do_remove_fails_for_large_key() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, &vec![26u8; 300 * 1024]); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - let result = do_remove::(env, key_ptr); + let result = do_remove::(&mut env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -557,15 +562,14 @@ mod test { #[test] fn do_remove_is_prohibited_in_readonly_contexts() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, b"a storage key"); - let ctx = instance.context_mut(); - leave_default_data(env); - set_storage_readonly::(env, true); + leave_default_data(&mut env); + set_storage_readonly::(&mut env, true); - let result = do_remove::(env, key_ptr); + let result = do_remove::(&mut env, key_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -574,62 +578,62 @@ mod test { #[test] fn do_canonicalize_address_works() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let api = MockApi::default(); let source_ptr = write_data(&mut instance, b"foo"); let dest_ptr = create_empty(&mut instance, api.canonical_length as u32); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::new(8); - do_canonicalize_address::(api, env, source_ptr, dest_ptr).unwrap(); - let data = force_read(ctx, dest_ptr); + do_canonicalize_address::(api, &mut 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 (mut 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 dest_ptr = create_empty(&mut instance, 8); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::default(); - let res = do_canonicalize_address::(api, env, source_ptr1, dest_ptr).unwrap(); + let res = + do_canonicalize_address::(api, &mut env, source_ptr1, dest_ptr).unwrap(); assert_ne!(res, 0); - let err = String::from_utf8(force_read(env, 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, env, source_ptr2, dest_ptr).unwrap(); + let res = + do_canonicalize_address::(api, &mut env, source_ptr2, dest_ptr).unwrap(); assert_ne!(res, 0); - let err = String::from_utf8(force_read(env, res)).unwrap(); + let err = String::from_utf8(force_read(&env, res)).unwrap(); assert_eq!(err, "Input is empty"); - let res = do_canonicalize_address::(api, env, source_ptr3, dest_ptr).unwrap(); + let res = + do_canonicalize_address::(api, &mut env, source_ptr3, dest_ptr).unwrap(); assert_ne!(res, 0); - let err = String::from_utf8(force_read(env, 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 (mut env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, b"foo"); let dest_ptr = create_empty(&mut instance, 7); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::new_failing("Temporarily unavailable"); - let result = do_canonicalize_address::(api, env, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &mut env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::FfiErr { source: FfiError::Unknown { msg, .. }, @@ -642,16 +646,15 @@ mod test { #[test] fn do_canonicalize_address_fails_for_large_inputs() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, &vec![61; 100]); let dest_ptr = create_empty(&mut instance, 8); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::default(); - let result = do_canonicalize_address::(api, env, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &mut env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -668,16 +671,15 @@ mod test { #[test] fn do_canonicalize_address_fails_for_small_destination_region() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, b"foo"); let dest_ptr = create_empty(&mut instance, 7); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::default(); - let result = do_canonicalize_address::(api, env, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &mut env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionTooSmall { size, required, .. }, @@ -691,51 +693,49 @@ mod test { #[test] fn do_humanize_address_works() { - let mut instance = make_instance(); + let (mut 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 dest_ptr = create_empty(&mut instance, 50); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::default(); - let error_ptr = do_humanize_address::(api, env, source_ptr, dest_ptr).unwrap(); + let error_ptr = + do_humanize_address::(api, &mut 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 (mut env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, b"foo"); // too short let dest_ptr = create_empty(&mut instance, 50); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::default(); - let res = do_humanize_address::(api, env, source_ptr, dest_ptr).unwrap(); + let res = do_humanize_address::(api, &mut env, source_ptr, dest_ptr).unwrap(); assert_ne!(res, 0); - let err = String::from_utf8(force_read(env, 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 (mut env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, b"foo\0\0\0\0\0"); let dest_ptr = create_empty(&mut instance, 50); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::new_failing("Temporarily unavailable"); - let result = do_humanize_address::(api, env, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &mut env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::FfiErr { source: FfiError::Unknown { msg, .. }, @@ -746,16 +746,15 @@ mod test { #[test] fn do_humanize_address_fails_for_input_too_long() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, &vec![61; 33]); let dest_ptr = create_empty(&mut instance, 50); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::default(); - let result = do_humanize_address::(api, env, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &mut env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -772,18 +771,17 @@ mod test { #[test] fn do_humanize_address_fails_for_destination_region_too_small() { - let mut instance = make_instance(); + let (mut 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 dest_ptr = create_empty(&mut instance, 2); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let api = MockApi::default(); - let result = do_humanize_address::(api, env, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &mut env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionTooSmall { size, required, .. }, @@ -797,7 +795,7 @@ mod test { #[test] fn do_query_chain_works() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let request: QueryRequest = QueryRequest::Bank(BankQuery::AllBalances { address: HumanAddr::from(INIT_ADDR), @@ -805,11 +803,10 @@ mod test { let request_data = cosmwasm_std::to_vec(&request).unwrap(); let request_ptr = write_data(&mut instance, &request_data); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - let response_ptr = do_query_chain::(env, request_ptr).unwrap(); - let response = force_read(env, response_ptr); + let response_ptr = do_query_chain::(&mut env, request_ptr).unwrap(); + let response = force_read(&env, response_ptr); let query_result: cosmwasm_std::QuerierResult = cosmwasm_std::from_slice(&response).unwrap(); @@ -821,16 +818,15 @@ mod test { #[test] fn do_query_chain_fails_for_broken_request() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let request = b"Not valid JSON for sure"; let request_ptr = write_data(&mut instance, request); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - let response_ptr = do_query_chain::(env, request_ptr).unwrap(); - let response = force_read(env, response_ptr); + let response_ptr = do_query_chain::(&mut env, request_ptr).unwrap(); + let response = force_read(&env, response_ptr); let query_result: cosmwasm_std::QuerierResult = cosmwasm_std::from_slice(&response).unwrap(); @@ -845,7 +841,7 @@ mod test { #[test] fn do_query_chain_fails_for_missing_contract() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let request: QueryRequest = QueryRequest::Wasm(WasmQuery::Smart { contract_addr: HumanAddr::from("non-existent"), @@ -854,11 +850,10 @@ mod test { let request_data = cosmwasm_std::to_vec(&request).unwrap(); let request_ptr = write_data(&mut instance, &request_data); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - let response_ptr = do_query_chain::(env, request_ptr).unwrap(); - let response = force_read(env, response_ptr); + let response_ptr = do_query_chain::(&mut env, request_ptr).unwrap(); + let response = force_read(&env, response_ptr); let query_result: cosmwasm_std::QuerierResult = cosmwasm_std::from_slice(&response).unwrap(); @@ -874,12 +869,11 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_works() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(env); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); // set up iterator over all space - let id = do_scan::(env, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan::(&mut env, 0, 0, Order::Ascending.into()).unwrap(); assert_eq!(1, id); let item = @@ -898,12 +892,11 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_descending_works() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(env); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); // set up iterator over all space - let id = do_scan::(env, 0, 0, Order::Descending.into()).unwrap(); + let id = do_scan::(&mut env, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(1, id); let item = @@ -922,15 +915,14 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_bound_works() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); let start = write_data(&mut instance, b"anna"); let end = write_data(&mut instance, b"bert"); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - let id = do_scan::(env, start, end, Order::Ascending.into()).unwrap(); + let id = do_scan::(&mut env, start, end, Order::Ascending.into()).unwrap(); let item = with_storage_from_context::(env, |store| Ok(store.next(id))).unwrap(); @@ -944,13 +936,12 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_multiple_iterators() { - let mut instance = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(env); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); // unbounded, ascending and descending - let id1 = do_scan::(env, 0, 0, Order::Ascending.into()).unwrap(); - let id2 = do_scan::(env, 0, 0, Order::Descending.into()).unwrap(); + let id1 = do_scan::(&mut env, 0, 0, Order::Ascending.into()).unwrap(); + let id2 = do_scan::(&mut env, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(id1, 1); assert_eq!(id2, 2); @@ -983,12 +974,11 @@ mod test { #[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(env); + let (mut env, mut instance) = make_instance(); + leave_default_data(&mut env); // set up iterator over all space - let result = do_scan::(env, 0, 0, 42); + let result = do_scan::(&mut env, 0, 0, 42); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::InvalidOrder { .. }, @@ -1000,43 +990,41 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_next_works() { - let mut instance = make_instance(); + let (mut env, mut instance) = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); - let id = do_scan::(env, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan::(&mut env, 0, 0, Order::Ascending.into()).unwrap(); // Entry 1 - let kv_region_ptr = do_next::(env, id).unwrap(); + let kv_region_ptr = do_next::(&mut env, id).unwrap(); assert_eq!( - force_read(env, 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::(env, id).unwrap(); + let kv_region_ptr = do_next::(&mut env, id).unwrap(); assert_eq!( - force_read(env, kv_region_ptr), + force_read(&env, kv_region_ptr), [VALUE2, KEY2, b"\0\0\0\x04"].concat() ); // End - let kv_region_ptr = do_next::(env, id).unwrap(); - assert_eq!(force_read(env, kv_region_ptr), b"\0\0\0\0"); + let kv_region_ptr = do_next::(&mut 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 (mut env, mut instance) = make_instance(); - let ctx = instance.context_mut(); - leave_default_data(env); + leave_default_data(&mut env); let non_existent_id = 42u32; - let result = do_next::(env, non_existent_id); + let result = do_next::(&mut env, non_existent_id); match result.unwrap_err() { VmError::FfiErr { source: FfiError::IteratorDoesNotExist { id, .. }, diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 24a5b374c2..ee594ed689 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -588,6 +588,8 @@ mod test { ); } + /* + TODO: Move to env testing #[test] fn set_storage_readonly_works() { let mut instance = mock_instance(&CONTRACT, &[]); @@ -615,6 +617,7 @@ mod test { true ); } + */ #[test] fn with_storage_works() { From 370bc5c703f089f2ec7a7c7df7d482619bee0970 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 12 Oct 2020 14:48:35 +0200 Subject: [PATCH 025/110] Let with_{func,querier,storage}_from_context take env references --- packages/vm/src/context.rs | 15 ++++--- packages/vm/src/imports.rs | 78 ++++++++++++++++++------------------- packages/vm/src/instance.rs | 4 +- 3 files changed, 48 insertions(+), 49 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 510b5b4797..b777d90d42 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -244,7 +244,7 @@ pub fn set_storage_readonly(env: &mut Env, new_val // TODO: move into Env pub(crate) fn with_func_from_context( - mut env: Env, + env: &mut Env, name: &str, callback: Callback, ) -> VmResult @@ -265,7 +265,7 @@ where } // TODO: move into Env -pub(crate) fn with_storage_from_context(mut env: Env, func: F) -> VmResult +pub(crate) fn with_storage_from_context(env: &mut Env, func: F) -> VmResult where S: Storage, Q: Querier, @@ -278,7 +278,7 @@ where } // TODO: move into Env -pub(crate) fn with_querier_from_context(mut env: Env, func: F) -> VmResult +pub(crate) fn with_querier_from_context(env: &mut Env, func: F) -> VmResult where S: Storage, Q: Querier, @@ -503,10 +503,9 @@ mod test { let (mut env, mut instance) = make_instance(); leave_default_data(&mut instance.context_mut()); - let res = - with_func_from_context::(&mut env, "doesnt_exist", |_func| { - panic!("unexpected callback call"); - }); + let res = with_func_from_context::(&mut env, "doesnt_exist", |_func| { + panic!("unexpected callback call"); + }); match res.unwrap_err() { VmError::ResolveErr { msg, .. } => { assert_eq!( @@ -588,7 +587,7 @@ mod test { let (mut env, mut instance) = make_instance(); leave_default_data(&mut env); - with_querier_from_context::(env.clone(), |_querier| { + with_querier_from_context::(&mut env, |_querier| { panic!("A panic occurred in the callback.") }) .unwrap(); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 3d92b817dc..6eb861f6ff 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -42,7 +42,7 @@ pub fn do_read(env: &mut Env, key_ptr: u32) -> VmR let key = read_region(&env.memory, key_ptr, MAX_LENGTH_DB_KEY)?; let (result, gas_info) = - with_storage_from_context::(env.clone(), |store| Ok(store.get(&key)))?; + with_storage_from_context::(env, |store| Ok(store.get(&key)))?; process_gas_info::(env, gas_info)?; let value = result?; @@ -67,7 +67,7 @@ pub fn do_write( let value = read_region(&env.memory, value_ptr, MAX_LENGTH_DB_VALUE)?; let (result, gas_info) = - with_storage_from_context::(env.clone(), |store| Ok(store.set(&key, &value)))?; + with_storage_from_context::(env, |store| Ok(store.set(&key, &value)))?; process_gas_info::(env, gas_info)?; result?; @@ -82,7 +82,7 @@ pub fn do_remove(env: &mut Env, key_ptr: u32) -> V let key = read_region(&env.memory, key_ptr, MAX_LENGTH_DB_KEY)?; let (result, gas_info) = - with_storage_from_context::(env.clone(), |store| Ok(store.remove(&key)))?; + with_storage_from_context::(env, |store| Ok(store.remove(&key)))?; process_gas_info(env, gas_info)?; result?; @@ -155,8 +155,8 @@ pub fn print_debug_message( } /// Creates a Region in the contract, writes the given data to it and returns the memory location -fn write_to_contract(env: &Env, input: &[u8]) -> VmResult { - let target_ptr = with_func_from_context::(env.clone(), "allocate", |allocate| { +fn write_to_contract(env: &mut Env, input: &[u8]) -> VmResult { + let target_ptr = with_func_from_context::(env, "allocate", |allocate| { let out_size = to_u32(input.len())?; let result = allocate.call(&[out_size.into()])?; let ptr = result[0].unwrap_i32() as u32; @@ -176,7 +176,7 @@ pub fn do_query_chain( let request = read_region(&env.memory, request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; let gas_remaining = get_gas_left(env); - let (result, gas_info) = with_querier_from_context::(env.clone(), |querier| { + let (result, gas_info) = with_querier_from_context::(env, |querier| { Ok(querier.query_raw(&request, gas_remaining)) })?; process_gas_info::(env, gas_info)?; @@ -197,7 +197,7 @@ pub fn do_scan( .try_into() .map_err(|_| CommunicationError::invalid_order(order))?; - let (result, gas_info) = with_storage_from_context::(env.clone(), |store| { + let (result, gas_info) = with_storage_from_context::(env, |store| { Ok(store.scan(start.as_deref(), end.as_deref(), order)) })?; process_gas_info::(env, gas_info)?; @@ -208,7 +208,7 @@ pub fn do_scan( #[cfg(feature = "iterator")] pub fn do_next(env: &mut Env, iterator_id: u32) -> VmResult { let (result, gas_info) = - with_storage_from_context::(env.clone(), |store| Ok(store.next(iterator_id)))?; + with_storage_from_context::(env, |store| Ok(store.next(iterator_id)))?; process_gas_info::(env, gas_info)?; // Empty key will later be treated as _no more element_. @@ -386,7 +386,7 @@ mod test { do_write::(&mut env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(env, |store| { + let val = with_storage_from_context::(&mut env, |store| { Ok(store .get(b"new storage key") .0 @@ -407,7 +407,7 @@ mod test { do_write::(&mut env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(env, |store| { + let val = with_storage_from_context::(&mut env, |store| { Ok(store.get(KEY1).0.expect("error getting value")) }) .unwrap(); @@ -425,7 +425,7 @@ mod test { do_write::(&mut env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(env, |store| { + let val = with_storage_from_context::(&mut env, |store| { Ok(store .get(b"new storage key") .0 @@ -511,7 +511,7 @@ mod test { do_remove::(&mut env, key_ptr).unwrap(); - let value = with_storage_from_context::(env, |store| { + let value = with_storage_from_context::(&mut env, |store| { Ok(store.get(existing_key).0.expect("error getting value")) }) .unwrap(); @@ -530,7 +530,7 @@ mod test { // Note: right now we cannot differnetiate between an existent and a non-existent key do_remove::(&mut env, key_ptr).unwrap(); - let value = with_storage_from_context::(env, |store| { + let value = with_storage_from_context::(&mut env, |store| { Ok(store.get(non_existent_key).0.expect("error getting value")) }) .unwrap(); @@ -876,16 +876,16 @@ mod test { let id = do_scan::(&mut env, 0, 0, Order::Ascending.into()).unwrap(); assert_eq!(1, id); - let item = - with_storage_from_context::(env, |store| Ok(store.next(id))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = - with_storage_from_context::(env, |store| Ok(store.next(id))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); - let item = - with_storage_from_context::(env, |store| Ok(store.next(id))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + .unwrap(); assert!(item.0.unwrap().is_none()); } @@ -899,16 +899,16 @@ mod test { let id = do_scan::(&mut env, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(1, id); - let item = - with_storage_from_context::(env, |store| Ok(store.next(id))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY2.to_vec(), VALUE2.to_vec())); - let item = - with_storage_from_context::(env, |store| Ok(store.next(id))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = - with_storage_from_context::(env, |store| Ok(store.next(id))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + .unwrap(); assert!(item.0.unwrap().is_none()); } @@ -924,12 +924,12 @@ mod test { let id = do_scan::(&mut env, start, end, Order::Ascending.into()).unwrap(); - let item = - with_storage_from_context::(env, |store| Ok(store.next(id))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); - let item = - with_storage_from_context::(env, |store| Ok(store.next(id))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + .unwrap(); assert!(item.0.unwrap().is_none()); } @@ -946,28 +946,28 @@ mod test { assert_eq!(id2, 2); // first item, first iterator - let item = - with_storage_from_context::(env, |store| Ok(store.next(id1))).unwrap(); + let item = with_storage_from_context::(&mut env, |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::(env, |store| Ok(store.next(id1))).unwrap(); + let item = with_storage_from_context::(&mut env, |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::(env, |store| Ok(store.next(id2))).unwrap(); + let item = with_storage_from_context::(&mut env, |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::(env, |store| Ok(store.next(id1))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id1))) + .unwrap(); assert!(item.0.unwrap().is_none()); // second item, second iterator - let item = - with_storage_from_context::(env, |store| Ok(store.next(id2))).unwrap(); + let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id2))) + .unwrap(); assert_eq!(item.0.unwrap().unwrap(), (KEY1.to_vec(), VALUE1.to_vec())); } diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index ee594ed689..cc75ad7a36 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -276,11 +276,11 @@ where } pub fn with_storage VmResult, T>(&mut self, func: F) -> VmResult { - with_storage_from_context::(self.env.clone(), func) + with_storage_from_context::(&mut self.env, func) } pub fn with_querier VmResult, T>(&mut self, func: F) -> VmResult { - with_querier_from_context::(self.env.clone(), func) + with_querier_from_context::(&mut self.env, func) } /// Requests memory allocation by the instance and returns a pointer From 5b57ab3c89c8dc5b02d7a0d147d57df334ea602f Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 12 Oct 2020 14:55:52 +0200 Subject: [PATCH 026/110] Avoid MockApi::new --- packages/vm/src/imports.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 6eb861f6ff..008b568916 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -586,7 +586,7 @@ mod test { leave_default_data(&mut env); - let api = MockApi::new(8); + let api = MockApi::default(); do_canonicalize_address::(api, &mut env, source_ptr, dest_ptr).unwrap(); let data = force_read(&env, dest_ptr); assert_eq!(data.len(), api.canonical_length); From 9856ae4ba367eb6e94128708c1fafc4157deac30 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 12 Oct 2020 15:09:01 +0200 Subject: [PATCH 027/110] Resolve more test problems --- packages/vm/src/context.rs | 62 ++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index b777d90d42..851721b8bd 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -397,17 +397,16 @@ mod test { let (mut env, mut instance) = make_instance(); let gas_limit = 100; - set_gas_left(&mut instance.context_mut(), gas_limit); + set_gas_left(&mut env, gas_limit); env.with_gas_state_mut(|state| state.set_gas_limit(gas_limit)); - let context = instance.context_mut(); // Consume all the Gas that we allocated - account_for_externally_used_gas::(&mut context, 70).unwrap(); - account_for_externally_used_gas::(&mut context, 4).unwrap(); - account_for_externally_used_gas::(&mut context, 6).unwrap(); - account_for_externally_used_gas::(&mut context, 20).unwrap(); + account_for_externally_used_gas::(&mut env, 70).unwrap(); + account_for_externally_used_gas::(&mut env, 4).unwrap(); + account_for_externally_used_gas::(&mut env, 6).unwrap(); + account_for_externally_used_gas::(&mut env, 20).unwrap(); // Using one more unit of gas triggers a failure - match account_for_externally_used_gas::(&mut context, 1).unwrap_err() { + match account_for_externally_used_gas::(&mut env, 1).unwrap_err() { VmError::GasDepletion => {} err => panic!("unexpected error: {:?}", err), } @@ -419,22 +418,20 @@ mod test { let (mut env, mut instance) = make_instance(); let gas_limit = 100; - set_gas_left(&mut instance.context_mut(), gas_limit); + set_gas_left(&mut env, gas_limit); env.with_gas_state_mut(|state| state.set_gas_limit(gas_limit)); - let context = instance.context_mut(); // Some gas was consumed externally - account_for_externally_used_gas::(&mut context, 50).unwrap(); - account_for_externally_used_gas::(&mut context, 4).unwrap(); + account_for_externally_used_gas::(&mut env, 50).unwrap(); + account_for_externally_used_gas::(&mut env, 4).unwrap(); // Consume 20 gas directly in wasmer - decrease_gas_left(&mut instance.context_mut(), 20).unwrap(); + decrease_gas_left(&mut env, 20).unwrap(); - let context = instance.context_mut(); - account_for_externally_used_gas::(&mut context, 6).unwrap(); - account_for_externally_used_gas::(&mut context, 20).unwrap(); + account_for_externally_used_gas::(&mut env, 6).unwrap(); + account_for_externally_used_gas::(&mut env, 20).unwrap(); // Using one more unit of gas triggers a failure - match account_for_externally_used_gas::(&mut context, 1).unwrap_err() { + match account_for_externally_used_gas::(&mut env, 1).unwrap_err() { VmError::GasDepletion => {} err => panic!("unexpected error: {:?}", err), } @@ -469,29 +466,28 @@ mod test { #[test] fn with_func_from_context_works() { let (mut env, mut instance) = make_instance(); - leave_default_data(&mut instance.context_mut()); - - let ptr = - with_func_from_context::(&mut env, "allocate", |alloc_func| { - let ptr = alloc_func.call(10)?; - Ok(ptr) - }) - .unwrap(); + leave_default_data(&mut env); + + let ptr = with_func_from_context::(&mut env, "allocate", |alloc_func| { + let result = alloc_func.call(&[10u32.into()])?; + let ptr = result[0].unwrap_i32() as u32; + Ok(ptr) + }) + .unwrap(); assert!(ptr > 0); } #[test] fn with_func_from_context_fails_for_missing_instance() { let (mut env, mut instance) = make_instance(); - leave_default_data(&mut instance.context_mut()); + leave_default_data(&mut env); // Clear context's wasmer_instance - set_wasmer_instance::(&mut instance.context_mut(), None); + set_wasmer_instance::(&mut env, None); - let res = - with_func_from_context::(&mut env, "allocate", |_func| { - panic!("unexpected callback call"); - }); + let res = with_func_from_context::(&mut env, "allocate", |_func| { + panic!("unexpected callback call"); + }); match res.unwrap_err() { VmError::UninitializedContextData { kind, .. } => assert_eq!(kind, "wasmer_instance"), err => panic!("Unexpected error: {:?}", err), @@ -501,9 +497,9 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_function() { let (mut env, mut instance) = make_instance(); - leave_default_data(&mut instance.context_mut()); + leave_default_data(&mut env); - let res = with_func_from_context::(&mut env, "doesnt_exist", |_func| { + let res = with_func_from_context::(&mut env, "doesnt_exist", |_func| { panic!("unexpected callback call"); }); match res.unwrap_err() { @@ -531,7 +527,7 @@ mod test { let set_key: &[u8] = b"more"; let set_value: &[u8] = b"data"; - with_storage_from_context::(&mut &mut ctx, |store| { + with_storage_from_context::(&mut env, |store| { store .set(set_key, set_value) .0 From e8fdb4c4a38d931257cae5bd3a4f1dbf2f163765 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 12 Oct 2020 22:18:11 +0200 Subject: [PATCH 028/110] Remove unused imports --- packages/vm/src/context.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 851721b8bd..79f0a2d5f5 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -1,9 +1,5 @@ //! Internal details to be used by instance.rs only use std::borrow::{Borrow, BorrowMut}; -#[cfg(feature = "iterator")] -use std::collections::HashMap; -#[cfg(feature = "iterator")] -use std::convert::TryInto; use std::ptr::NonNull; use std::sync::{Arc, RwLock}; From ed031f36b9dec97cd8422ccc653648697bf38c6f Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 15:00:55 +0200 Subject: [PATCH 029/110] Use memory from instance in Env --- packages/vm/src/context.rs | 31 +++++++++++++++++++----------- packages/vm/src/imports.rs | 38 ++++++++++++++++--------------------- packages/vm/src/instance.rs | 8 +++----- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 79f0a2d5f5..6e41013a77 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -3,7 +3,7 @@ use std::borrow::{Borrow, BorrowMut}; use std::ptr::NonNull; use std::sync::{Arc, RwLock}; -use wasmer::{Function, Instance as WasmerInstance}; +use wasmer::{Function, Instance as WasmerInstance, Memory}; use crate::backends::decrease_gas_left; use crate::errors::{VmError, VmResult}; @@ -61,14 +61,12 @@ impl GasState { // #[derive(Clone)] pub struct Env { - pub memory: wasmer::Memory, pub context_data: Arc>>, } impl Clone for Env { fn clone(&self) -> Self { Env { - memory: self.memory.clone(), context_data: self.context_data.clone(), } } @@ -112,6 +110,23 @@ impl Env { { self.with_context_data(|context_data| callback(&context_data.gas_state)) } + + 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(); + let memory = memories.pop().unwrap(); + memory + }) + } } pub struct ContextData { @@ -297,8 +312,7 @@ mod test { coins, from_binary, to_vec, AllBalanceResponse, BankQuery, Empty, HumanAddr, QueryRequest, }; use std::sync::{Arc, RwLock}; - use wasmer::{imports, Store}; - use wasmer_engine_jit::JIT; + use wasmer::imports; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); @@ -318,12 +332,7 @@ mod test { const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000; fn make_instance() -> (Env, Box) { - let engine = JIT::headless().engine(); - let store = Store::new(&engine); - let mut env = Env { - memory: wasmer::Memory::new(&store, wasmer::MemoryType::new(0, Some(5000), false)) - .expect("could not create memory"), context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), }; @@ -342,7 +351,7 @@ mod test { // "debug" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), }, }; - let mut instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); + let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); set_wasmer_instance::(&mut env, Some(instance_ptr)); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 008b568916..2a476054f4 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -39,7 +39,7 @@ const MAX_LENGTH_DEBUG: usize = 2 * MI; /// Reads a storage entry from the VM's storage into Wasm memory pub fn do_read(env: &mut Env, key_ptr: u32) -> VmResult { - let key = read_region(&env.memory, 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::(env, |store| Ok(store.get(&key)))?; @@ -63,8 +63,8 @@ pub fn do_write( return Err(VmError::write_access_denied()); } - 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 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::(env, |store| Ok(store.set(&key, &value)))?; @@ -79,7 +79,7 @@ pub fn do_remove(env: &mut Env, key_ptr: u32) -> V return Err(VmError::write_access_denied()); } - let key = read_region(&env.memory, 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::(env, |store| Ok(store.remove(&key)))?; @@ -95,7 +95,7 @@ pub fn do_canonicalize_address( source_ptr: u32, destination_ptr: u32, ) -> VmResult { - let source_data = read_region(&env.memory, 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::(env, b"Input is empty")?); } @@ -110,7 +110,7 @@ pub fn do_canonicalize_address( process_gas_info::(env, gas_info)?; match result { Ok(canonical) => { - write_region(&env.memory, destination_ptr, canonical.as_slice())?; + write_region(&env.memory(), destination_ptr, canonical.as_slice())?; Ok(0) } Err(FfiError::UserErr { msg, .. }) => Ok(write_to_contract::(env, msg.as_bytes())?), @@ -125,7 +125,7 @@ pub fn do_humanize_address( destination_ptr: u32, ) -> VmResult { let canonical = Binary(read_region( - &env.memory, + &env.memory(), source_ptr, MAX_LENGTH_CANONICAL_ADDRESS, )?); @@ -134,7 +134,7 @@ pub fn do_humanize_address( process_gas_info::(env, gas_info)?; match result { Ok(human) => { - write_region(&env.memory, destination_ptr, human.as_str().as_bytes())?; + write_region(&env.memory(), destination_ptr, human.as_str().as_bytes())?; Ok(0) } Err(FfiError::UserErr { msg, .. }) => Ok(write_to_contract::(env, msg.as_bytes())?), @@ -148,7 +148,7 @@ pub fn print_debug_message( env: &Env, message_ptr: u32, ) -> VmResult<()> { - let message_data = read_region(&env.memory, message_ptr, MAX_LENGTH_DEBUG)?; + let message_data = read_region(&env.memory(), message_ptr, MAX_LENGTH_DEBUG)?; let msg = String::from_utf8_lossy(&message_data); println!("{}", msg); Ok(()) @@ -165,7 +165,7 @@ fn write_to_contract(env: &mut Env, input: &[u8]) } Ok(ptr) })?; - write_region(&env.memory, target_ptr, input)?; + write_region(&env.memory(), target_ptr, input)?; Ok(target_ptr) } @@ -173,7 +173,7 @@ pub fn do_query_chain( env: &mut Env, request_ptr: u32, ) -> VmResult { - let request = read_region(&env.memory, request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; + let request = read_region(&env.memory(), request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; let gas_remaining = get_gas_left(env); let (result, gas_info) = with_querier_from_context::(env, |querier| { @@ -191,8 +191,8 @@ pub fn do_scan( end_ptr: u32, order: i32, ) -> VmResult { - 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 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))?; @@ -233,8 +233,7 @@ mod test { }; use std::ptr::NonNull; use std::sync::{Arc, RwLock}; - use wasmer::{imports, Instance as WasmerInstance, Store}; - use wasmer_engine_jit::JIT; + use wasmer::{imports, Instance as WasmerInstance}; use crate::backends::compile; use crate::context::{ @@ -265,12 +264,7 @@ mod test { const GAS_LIMIT: u64 = 5_000_000; fn make_instance() -> (Env, Box) { - let engine = JIT::headless().engine(); - let store = Store::new(&engine); - let mut env = Env { - memory: wasmer::Memory::new(&store, wasmer::MemoryType::new(0, Some(5000), false)) - .expect("could not create memory"), context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), }; @@ -289,7 +283,7 @@ mod test { // "debug" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), }, }; - let mut instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); + let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); set_wasmer_instance::(&mut env, Some(instance_ptr)); @@ -335,7 +329,7 @@ mod test { /// A Region reader that is just good enough for the tests in this file fn force_read(&env: &Env, region_ptr: u32) -> Vec { - read_region(&env.memory, region_ptr, 5000).unwrap() + read_region(&env.memory(), region_ptr, 5000).unwrap() } #[test] diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index cc75ad7a36..2612db8541 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -84,8 +84,6 @@ where let store = Store::new(&engine); let mut env = Env { - memory: wasmer::Memory::new(&store, wasmer::MemoryType::new(0, Some(5000), false)) - .expect("could not create memory"), context_data: Arc::new(RwLock::new(ContextData::new(gas_limit))), }; let _env2 = env.clone(); @@ -246,7 +244,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 { - self.env.memory.data_size() + self.env.memory().data_size() } /// Returns the currently remaining gas. @@ -304,12 +302,12 @@ where /// 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.env.memory, 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.env.memory, region_ptr, data)?; + write_region(&self.env.memory(), region_ptr, data)?; Ok(()) } From 452e0c0a810c68165f634936adcf81fdd8c4cb47 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 15:38:05 +0200 Subject: [PATCH 030/110] Remove unnecessary & --- packages/vm/src/imports.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 2a476054f4..10027a2a7d 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -328,7 +328,7 @@ mod test { } /// A Region reader that is just good enough for the tests in this file - fn force_read(&env: &Env, region_ptr: u32) -> Vec { + fn force_read(env: &Env, region_ptr: u32) -> Vec { read_region(&env.memory(), region_ptr, 5000).unwrap() } From 7863c5f93c398229e68a51ded6510f4742e39b7b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 15:43:20 +0200 Subject: [PATCH 031/110] Adapt backend tests --- packages/vm/src/backends/mod.rs | 44 ++++++++++++++++-------- packages/vm/src/backends/singlepass.rs | 46 +++++++++++++++++--------- 2 files changed, 61 insertions(+), 29 deletions(-) diff --git a/packages/vm/src/backends/mod.rs b/packages/vm/src/backends/mod.rs index 01d41924aa..6ec3aa5eb1 100644 --- a/packages/vm/src/backends/mod.rs +++ b/packages/vm/src/backends/mod.rs @@ -34,48 +34,64 @@ pub use singlepass::{backend, compile, get_gas_left, set_gas_left}; #[cfg(feature = "default-singlepass")] mod test { use super::*; + use crate::context::{set_wasmer_instance, ContextData}; + use crate::testing::{MockQuerier, MockStorage}; + use std::ptr::NonNull; + use std::sync::{Arc, RwLock}; use wabt::wat2wasm; use wasmer::{imports, Instance as WasmerInstance}; - fn instantiate(code: &[u8]) -> WasmerInstance { + type MS = MockStorage; + type MQ = MockQuerier; + const GAS_LIMIT: u64 = 5_000_000; + + fn instantiate(code: &[u8]) -> (Env, Box) { + let mut env = Env { + context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), + }; let module = compile(code).unwrap(); let import_obj = imports! { "env" => {}, }; - WasmerInstance::new(&module, &import_obj).unwrap() + let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); + + let instance_ptr = NonNull::from(instance.as_ref()); + set_wasmer_instance::(&mut env, Some(instance_ptr)); + + (env, instance) } #[test] fn decrease_gas_left_works() { let wasm = wat2wasm("(module)").unwrap(); - let mut instance = instantiate(&wasm); + let (mut env, _) = instantiate(&wasm); - let before = get_gas_left(&instance.context()); - decrease_gas_left(&mut instance.context_mut(), 32).unwrap(); - let after = get_gas_left(&instance.context()); + let before = get_gas_left(&env); + decrease_gas_left(&mut 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 = wat2wasm("(module)").unwrap(); - let mut instance = instantiate(&wasm); + let (mut env, _) = instantiate(&wasm); - let before = get_gas_left(&instance.context()); - decrease_gas_left(&mut instance.context_mut(), before).unwrap(); - let after = get_gas_left(&instance.context()); + let before = get_gas_left(&env); + decrease_gas_left(&mut 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 = wat2wasm("(module)").unwrap(); - let mut instance = instantiate(&wasm); + let (mut env, _) = instantiate(&wasm); - let before = get_gas_left(&instance.context()); - let result = decrease_gas_left(&mut instance.context_mut(), before + 1); + let before = get_gas_left(&env); + let result = decrease_gas_left(&mut env, before + 1); match result.unwrap_err() { InsufficientGasLeft => {} } - let after = get_gas_left(&instance.context()); + let after = get_gas_left(&env); assert_eq!(after, 0); } } diff --git a/packages/vm/src/backends/singlepass.rs b/packages/vm/src/backends/singlepass.rs index 6608249dbd..ee41165035 100644 --- a/packages/vm/src/backends/singlepass.rs +++ b/packages/vm/src/backends/singlepass.rs @@ -66,43 +66,59 @@ pub fn get_gas_left(_env: &Env) -> u64 { #[cfg(test)] mod test { use super::*; + use crate::context::{set_wasmer_instance, ContextData}; + use crate::testing::{MockQuerier, MockStorage}; + use std::ptr::NonNull; + use std::sync::{Arc, RwLock}; use wabt::wat2wasm; use wasmer::{imports, Instance as WasmerInstance}; - fn instantiate(code: &[u8]) -> WasmerInstance { + type MS = MockStorage; + type MQ = MockQuerier; + const GAS_LIMIT: u64 = 5_000_000; + + fn instantiate(code: &[u8]) -> (Env, Box) { + let mut env = Env { + context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), + }; let module = compile(code).unwrap(); let import_obj = imports! { "env" => {}, }; - 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::(&mut env, Some(instance_ptr)); + + (env, instance) } #[test] fn get_gas_left_defaults_to_constant() { let wasm = wat2wasm("(module)").unwrap(); - let instance = instantiate(&wasm); - let gas_left = get_gas_left(&instance.context()); + 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 = wat2wasm("(module)").unwrap(); - let mut instance = instantiate(&wasm); + let (mut env, _) = instantiate(&wasm); let limit = 3456789; - set_gas_left(&mut instance.context_mut(), limit); - assert_eq!(get_gas_left(&instance.context()), limit); + set_gas_left(&mut env, limit); + assert_eq!(get_gas_left(&env), limit); let limit = 1; - set_gas_left(&mut instance.context_mut(), limit); - assert_eq!(get_gas_left(&instance.context()), limit); + set_gas_left(&mut env, limit); + assert_eq!(get_gas_left(&env), limit); let limit = 0; - set_gas_left(&mut instance.context_mut(), limit); - assert_eq!(get_gas_left(&instance.context()), limit); + set_gas_left(&mut env, limit); + assert_eq!(get_gas_left(&env), limit); let limit = MAX_GAS_LIMIT; - set_gas_left(&mut instance.context_mut(), limit); - assert_eq!(get_gas_left(&instance.context()), limit); + set_gas_left(&mut env, limit); + assert_eq!(get_gas_left(&env), limit); } #[test] @@ -111,9 +127,9 @@ mod test { )] fn set_gas_left_panic_for_values_too_large() { let wasm = wat2wasm("(module)").unwrap(); - let mut instance = instantiate(&wasm); + let (mut env, _) = instantiate(&wasm); let limit = MAX_GAS_LIMIT + 1; - set_gas_left(&mut instance.context_mut(), limit); + set_gas_left(&mut env, limit); } } From 91b0f4ccc5a936e8537f6c4dfa7c4b545a3b69c4 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 15:46:07 +0200 Subject: [PATCH 032/110] Remove unused variables --- packages/vm/src/context.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 6e41013a77..209c895e55 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -373,7 +373,7 @@ mod test { #[test] fn leave_and_take_context_data() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); // empty data on start let (inits, initq) = move_out_of_context::(&mut env); @@ -399,7 +399,7 @@ mod test { #[test] #[cfg(feature = "default-singlepass")] fn gas_tracking_works_correctly() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); let gas_limit = 100; set_gas_left(&mut env, gas_limit); @@ -420,7 +420,7 @@ mod test { #[test] #[cfg(feature = "default-singlepass")] fn gas_tracking_works_correctly_with_gas_consumption_in_wasmer() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); let gas_limit = 100; set_gas_left(&mut env, gas_limit); @@ -444,7 +444,7 @@ mod test { #[test] fn is_storage_readonly_defaults_to_true() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); assert_eq!(is_storage_readonly::(&env), true); @@ -452,7 +452,7 @@ mod test { #[test] fn set_storage_readonly_can_change_flag() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); // change @@ -470,7 +470,7 @@ mod test { #[test] fn with_func_from_context_works() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); let ptr = with_func_from_context::(&mut env, "allocate", |alloc_func| { @@ -484,7 +484,7 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_instance() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); // Clear context's wasmer_instance @@ -501,7 +501,7 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_function() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); let res = with_func_from_context::(&mut env, "doesnt_exist", |_func| { @@ -520,7 +520,7 @@ mod test { #[test] fn with_storage_from_context_set_get() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); let val = with_storage_from_context::(&mut env, |store| { @@ -552,7 +552,7 @@ mod test { #[test] #[should_panic(expected = "A panic occurred in the callback.")] fn with_storage_from_context_handles_panics() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); with_storage_from_context::(&mut env, |_store| { @@ -563,7 +563,7 @@ mod test { #[test] fn with_querier_from_context_works() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); let res = with_querier_from_context::(&mut env, |querier| { @@ -585,7 +585,7 @@ mod test { #[test] #[should_panic(expected = "A panic occurred in the callback.")] fn with_querier_from_context_handles_panics() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); with_querier_from_context::(&mut env, |_querier| { From 0ed43d7fafd25c4d0df103229f8a13f28fe1a239 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 15:53:07 +0200 Subject: [PATCH 033/110] Remove pointless clones --- packages/vm/src/instance.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 2612db8541..2337222545 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -86,8 +86,6 @@ where let mut env = Env { context_data: Arc::new(RwLock::new(ContextData::new(gas_limit))), }; - let _env2 = env.clone(); - let _env3 = env.clone(); let i32_to_i32 = FunctionType::new(vec![Type::I32], vec![Type::I32]); let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); From 9761fc355c2f156f3f8b07d3d71beef6749578d5 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 15:57:46 +0200 Subject: [PATCH 034/110] Re-enable test set_storage_readonly_works --- packages/vm/src/instance.rs | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 2337222545..42f5e09981 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -584,36 +584,21 @@ mod test { ); } - /* - TODO: Move to env testing #[test] fn set_storage_readonly_works() { let mut instance = mock_instance(&CONTRACT, &[]); - assert_eq!( - is_storage_readonly::(&instance.inner.context()), - true - ); + assert_eq!(is_storage_readonly::(&instance.env), true); instance.set_storage_readonly(false); - assert_eq!( - is_storage_readonly::(&instance.inner.context()), - false - ); + assert_eq!(is_storage_readonly::(&instance.env), false); instance.set_storage_readonly(false); - assert_eq!( - is_storage_readonly::(&instance.inner.context()), - false - ); + assert_eq!(is_storage_readonly::(&instance.env), false); instance.set_storage_readonly(true); - assert_eq!( - is_storage_readonly::(&instance.inner.context()), - true - ); + assert_eq!(is_storage_readonly::(&instance.env), true); } - */ #[test] fn with_storage_works() { From 6a3554ad39f6bf4d4b0a3cff2f263dcce2ed8fc0 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 15:58:19 +0200 Subject: [PATCH 035/110] Move pointers to block where they are used --- packages/vm/src/instance.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 42f5e09981..2457323afb 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -165,11 +165,11 @@ where // Ownership of both start and end pointer is not transferred to the host. // Returns an iterator ID. "db_scan" => Function::new_with_env(&store, &i32i32i32_to_i32, env.clone(), |mut env, args| { - let start_ptr = args[0].unwrap_i32() as u32; - let end_ptr = args[1].unwrap_i32() as u32; - let order = args[2].unwrap_i32(); #[cfg(feature = "iterator")] { + let start_ptr = args[0].unwrap_i32() as u32; + let end_ptr = args[1].unwrap_i32() as u32; + let order = args[2].unwrap_i32(); let response_ptr = do_scan::(&mut env, start_ptr, end_ptr, order)?; Ok(vec![response_ptr.into()]) } From 6a282b5d280a25d3a60abf3bb48c4d87fdb43bf1 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 16:40:33 +0200 Subject: [PATCH 036/110] Manually create import object --- packages/vm/src/instance.rs | 236 ++++++++++++++++++++---------------- 1 file changed, 132 insertions(+), 104 deletions(-) diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 2457323afb..2531c89eff 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -4,7 +4,8 @@ use std::ptr::NonNull; use std::sync::{Arc, RwLock}; use wasmer::{ - imports, Function, FunctionType, Instance as WasmerInstance, Module, Store, Type, Val, + Exports, Function, FunctionType, ImportObject, Instance as WasmerInstance, Module, Store, Type, + Val, }; use wasmer_engine_jit::JIT; @@ -91,112 +92,139 @@ where let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); 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]); + #[cfg(feature = "iterator")] let i32i32i32_to_i32 = FunctionType::new(vec![Type::I32, Type::I32, Type::I32], vec![Type::I32]); - let import_obj = 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" => Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { - let key_ptr = args[0].unwrap_i32() as u32; - let ptr = do_read::(&mut env, key_ptr)?; - Ok(vec![ptr.into()]) - }), - // 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" => Function::new_with_env(&store, &i32i32_to_void, env.clone(), |mut env, args| { - let key_ptr = args[0].unwrap_i32() as u32; - let value_ptr = args[1].unwrap_i32() as u32; - do_write::(&mut env, key_ptr, value_ptr)?; - Ok(vec![]) - }), - // 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" => Function::new_with_env(&store, &i32_to_void, env.clone(), |mut env, args| { - let key_ptr = args[0].unwrap_i32() as u32; - do_remove::(&mut env, key_ptr)?; - Ok(vec![]) - }), - // 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" => Function::new_with_env(&store, &i32i32_to_i32, env.clone(), move |mut env, args| { - let source_ptr = args[0].unwrap_i32() as u32; - let destination_ptr = args[1].unwrap_i32() as u32; - let ptr = do_canonicalize_address::(api, &mut 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. - "humanize_address" => Function::new_with_env(&store, &i32i32_to_i32, env.clone(), move |mut env, args| { - let source_ptr = args[0].unwrap_i32() as u32; - let destination_ptr = args[1].unwrap_i32() as u32; - let ptr = do_humanize_address::(api, &mut 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. - "debug" => Function::new_with_env(&store, &i32_to_void, env.clone(), move |mut env, args| { - let message_ptr = args[0].unwrap_i32() as u32; - if print_debug { - print_debug_message(&mut env, message_ptr)?; - } - Ok(vec![]) - }), - "query_chain" => Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { - let request_ptr = args[0].unwrap_i32() as u32; - let response_ptr = do_query_chain::(&mut env, request_ptr)?; - Ok(vec![response_ptr.into()]) - }), - // 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" => Function::new_with_env(&store, &i32i32i32_to_i32, env.clone(), |mut env, args| { - #[cfg(feature = "iterator")] - { - let start_ptr = args[0].unwrap_i32() as u32; - let end_ptr = args[1].unwrap_i32() as u32; - let order = args[2].unwrap_i32(); - let response_ptr = do_scan::(&mut env, start_ptr, end_ptr, order)?; - Ok(vec![response_ptr.into()]) - } - #[cfg(not(feature = "iterator"))] - { - Err(wasmer_engine::RuntimeError::new("Import db_scan not implemented due to missing iterator feature")) - } - }), - // 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" => Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { - #[cfg(feature = "iterator")] - { - let iterator_id = args[0].unwrap_i32() as u32; - let response_ptr = do_next::(&mut env, iterator_id)?; - Ok(vec![response_ptr.into()]) - } - #[cfg(not(feature = "iterator"))] - { - Err(wasmer_engine::RuntimeError::new("Import db_next not implemented due to missing iterator feature")) - } - }), - }, - }; + 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_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { + let key_ptr = args[0].unwrap_i32() as u32; + let ptr = do_read::(&mut env, key_ptr)?; + Ok(vec![ptr.into()]) + }), + ); + + // 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_with_env(&store, &i32i32_to_void, env.clone(), |mut env, args| { + let key_ptr = args[0].unwrap_i32() as u32; + let value_ptr = args[1].unwrap_i32() as u32; + do_write::(&mut env, key_ptr, value_ptr)?; + Ok(vec![]) + }), + ); + + // 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_with_env(&store, &i32_to_void, env.clone(), |mut env, args| { + let key_ptr = args[0].unwrap_i32() as u32; + do_remove::(&mut env, key_ptr)?; + Ok(vec![]) + }), + ); + + // 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 |mut env, args| { + let source_ptr = args[0].unwrap_i32() as u32; + let destination_ptr = args[1].unwrap_i32() as u32; + let ptr = + do_canonicalize_address::(api, &mut 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 |mut env, args| { + let source_ptr = args[0].unwrap_i32() as u32; + let destination_ptr = args[1].unwrap_i32() as u32; + let ptr = + do_humanize_address::(api, &mut 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_with_env(&store, &i32_to_void, env.clone(), move |mut env, args| { + let message_ptr = args[0].unwrap_i32() as u32; + if print_debug { + print_debug_message(&mut env, message_ptr)?; + } + Ok(vec![]) + }), + ); + + env_imports.insert( + "query_chain", + Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { + let request_ptr = args[0].unwrap_i32() as u32; + let response_ptr = do_query_chain::(&mut env, request_ptr)?; + Ok(vec![response_ptr.into()]) + }), + ); + + // 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")] + env_imports.insert( + "db_scan", + Function::new_with_env(&store, &i32i32i32_to_i32, env.clone(), |mut env, args| { + let start_ptr = args[0].unwrap_i32() as u32; + let end_ptr = args[1].unwrap_i32() as u32; + let order = args[2].unwrap_i32(); + let response_ptr = do_scan::(&mut env, start_ptr, end_ptr, order)?; + Ok(vec![response_ptr.into()]) + }), + ); + + // 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_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { + let iterator_id = args[0].unwrap_i32() as u32; + let response_ptr = do_next::(&mut env, iterator_id)?; + Ok(vec![response_ptr.into()]) + }), + ); + + import_obj.register("env", env_imports); let wasmer_instance = Box::from(WasmerInstance::new(&module, &import_obj).map_err( |original| { From 737bfcf32f2e33e8bc1e5bde76806d003039b910 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 17:07:26 +0200 Subject: [PATCH 037/110] Add constructor function for Env --- packages/vm/src/backends/mod.rs | 7 ++----- packages/vm/src/backends/singlepass.rs | 7 ++----- packages/vm/src/context.rs | 23 ++++++++++++++--------- packages/vm/src/imports.rs | 9 ++------- packages/vm/src/instance.rs | 7 ++----- 5 files changed, 22 insertions(+), 31 deletions(-) diff --git a/packages/vm/src/backends/mod.rs b/packages/vm/src/backends/mod.rs index 6ec3aa5eb1..8dda22d6d8 100644 --- a/packages/vm/src/backends/mod.rs +++ b/packages/vm/src/backends/mod.rs @@ -34,10 +34,9 @@ pub use singlepass::{backend, compile, get_gas_left, set_gas_left}; #[cfg(feature = "default-singlepass")] mod test { use super::*; - use crate::context::{set_wasmer_instance, ContextData}; + use crate::context::set_wasmer_instance; use crate::testing::{MockQuerier, MockStorage}; use std::ptr::NonNull; - use std::sync::{Arc, RwLock}; use wabt::wat2wasm; use wasmer::{imports, Instance as WasmerInstance}; @@ -46,9 +45,7 @@ mod test { const GAS_LIMIT: u64 = 5_000_000; fn instantiate(code: &[u8]) -> (Env, Box) { - let mut env = Env { - context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), - }; + let mut env = Env::new(GAS_LIMIT); let module = compile(code).unwrap(); let import_obj = imports! { "env" => {}, }; let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); diff --git a/packages/vm/src/backends/singlepass.rs b/packages/vm/src/backends/singlepass.rs index ee41165035..28cae7b301 100644 --- a/packages/vm/src/backends/singlepass.rs +++ b/packages/vm/src/backends/singlepass.rs @@ -66,10 +66,9 @@ pub fn get_gas_left(_env: &Env) -> u64 { #[cfg(test)] mod test { use super::*; - use crate::context::{set_wasmer_instance, ContextData}; + use crate::context::set_wasmer_instance; use crate::testing::{MockQuerier, MockStorage}; use std::ptr::NonNull; - use std::sync::{Arc, RwLock}; use wabt::wat2wasm; use wasmer::{imports, Instance as WasmerInstance}; @@ -78,9 +77,7 @@ mod test { const GAS_LIMIT: u64 = 5_000_000; fn instantiate(code: &[u8]) -> (Env, Box) { - let mut env = Env { - context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), - }; + let mut env = Env::new(GAS_LIMIT); let module = compile(code).unwrap(); let import_obj = imports! { "env" => {}, }; let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 209c895e55..66e66f79ed 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -59,20 +59,28 @@ impl GasState { } } -// #[derive(Clone)] +/// A ContextEnv is an env that provides access to the +/// ContextData. The env is clonable but a clone accesses +/// the same underlying data. pub struct Env { - pub context_data: Arc>>, + data: Arc>>, } impl Clone for Env { fn clone(&self) -> Self { Env { - context_data: self.context_data.clone(), + data: self.data.clone(), } } } impl Env { + pub fn new(gas_limit: u64) -> Self { + Env { + data: Arc::new(RwLock::new(ContextData::new(gas_limit))), + } + } + pub fn with_context_data_mut( &mut self, callback: Callback, @@ -80,7 +88,7 @@ impl Env { where Callback: FnOnce(&mut ContextData) -> CallbackReturn, { - let mut guard = self.context_data.as_ref().write().unwrap(); + let mut guard = self.data.as_ref().write().unwrap(); let context_data = guard.borrow_mut(); callback(context_data) } @@ -89,7 +97,7 @@ impl Env { where Callback: FnOnce(&ContextData) -> CallbackReturn, { - let guard = self.context_data.as_ref().read().unwrap(); + let guard = self.data.as_ref().read().unwrap(); let context_data = guard.borrow(); callback(context_data) } @@ -311,7 +319,6 @@ mod test { use cosmwasm_std::{ coins, from_binary, to_vec, AllBalanceResponse, BankQuery, Empty, HumanAddr, QueryRequest, }; - use std::sync::{Arc, RwLock}; use wasmer::imports; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); @@ -332,9 +339,7 @@ mod test { const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000; fn make_instance() -> (Env, Box) { - let mut env = Env { - context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), - }; + let mut env = Env::new(GAS_LIMIT); let module = compile(&CONTRACT).unwrap(); // we need stubs for all required imports diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 10027a2a7d..1db4cdd068 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -232,13 +232,10 @@ mod test { SystemError, SystemResult, WasmQuery, }; use std::ptr::NonNull; - use std::sync::{Arc, RwLock}; use wasmer::{imports, Instance as WasmerInstance}; use crate::backends::compile; - use crate::context::{ - move_into_context, set_storage_readonly, set_wasmer_instance, ContextData, - }; + use crate::context::{move_into_context, set_storage_readonly, set_wasmer_instance}; use crate::testing::{MockApi, MockQuerier, MockStorage}; use crate::traits::Storage; use crate::FfiError; @@ -264,9 +261,7 @@ mod test { const GAS_LIMIT: u64 = 5_000_000; fn make_instance() -> (Env, Box) { - let mut env = Env { - context_data: Arc::new(RwLock::new(ContextData::new(GAS_LIMIT))), - }; + let mut env = Env::new(GAS_LIMIT); let module = compile(&CONTRACT).unwrap(); // we need stubs for all required imports diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 2531c89eff..140e900afc 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -1,7 +1,6 @@ use std::collections::HashSet; use std::marker::PhantomData; use std::ptr::NonNull; -use std::sync::{Arc, RwLock}; use wasmer::{ Exports, Function, FunctionType, ImportObject, Instance as WasmerInstance, Module, Store, Type, @@ -12,7 +11,7 @@ use wasmer_engine_jit::JIT; use crate::backends::{compile, get_gas_left, set_gas_left}; use crate::context::{ move_into_context, move_out_of_context, set_storage_readonly, set_wasmer_instance, - with_querier_from_context, with_storage_from_context, ContextData, Env, + with_querier_from_context, with_storage_from_context, Env, }; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; @@ -84,9 +83,7 @@ where let engine = JIT::headless().engine(); let store = Store::new(&engine); - let mut env = Env { - context_data: Arc::new(RwLock::new(ContextData::new(gas_limit))), - }; + let mut env = Env::new(gas_limit); let i32_to_i32 = FunctionType::new(vec![Type::I32], vec![Type::I32]); let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); From 9bc3a5700717ed1353235f69a09c84d9e5cd6c39 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 17:18:42 +0200 Subject: [PATCH 038/110] Move with_func_from_context/with_storage_from_context/with_querier_from_context into env --- packages/vm/src/context.rs | 150 ++++++++++++++++++------------------ packages/vm/src/imports.rs | 77 +++++++++--------- packages/vm/src/instance.rs | 7 +- 3 files changed, 117 insertions(+), 117 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 66e66f79ed..aaebea51ac 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -119,6 +119,51 @@ impl Env { self.with_context_data(|context_data| callback(&context_data.gas_state)) } + pub fn with_func_from_context( + &mut self, + name: &str, + callback: Callback, + ) -> VmResult + where + S: Storage, + Q: Querier, + Callback: 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(&mut self, func: F) -> VmResult + where + S: Storage, + Q: Querier, + F: FnOnce(&mut S) -> VmResult, + { + self.with_context_data_mut(|context_data| match context_data.storage.as_mut() { + Some(data) => func(data), + None => Err(VmError::uninitialized_context_data("storage")), + }) + } + + pub fn with_querier_from_context(&mut self, func: F) -> VmResult + where + S: Storage, + Q: Querier, + F: FnOnce(&mut Q) -> VmResult, + { + self.with_context_data_mut(|context_data| match context_data.querier.as_mut() { + Some(querier) => func(querier), + None => Err(VmError::uninitialized_context_data("querier")), + }) + } + pub fn memory(&self) -> Memory { self.with_context_data(|context| { let ptr = context @@ -261,54 +306,6 @@ pub fn set_storage_readonly(env: &mut Env, new_val }) } -// TODO: move into Env -pub(crate) fn with_func_from_context( - env: &mut Env, - name: &str, - callback: Callback, -) -> VmResult -where - S: Storage, - Q: Querier, - Callback: FnOnce(&Function) -> VmResult, -{ - env.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")), - }) -} - -// TODO: move into Env -pub(crate) fn with_storage_from_context(env: &mut Env, func: F) -> VmResult -where - S: Storage, - Q: Querier, - F: FnOnce(&mut S) -> VmResult, -{ - env.with_context_data_mut(|context_data| match context_data.storage.as_mut() { - Some(data) => func(data), - None => Err(VmError::uninitialized_context_data("storage")), - }) -} - -// TODO: move into Env -pub(crate) fn with_querier_from_context(env: &mut Env, func: F) -> VmResult -where - S: Storage, - Q: Querier, - F: FnOnce(&mut Q) -> VmResult, -{ - env.with_context_data_mut(|context_data| match context_data.querier.as_mut() { - Some(querier) => func(querier), - None => Err(VmError::uninitialized_context_data("querier")), - }) -} - #[cfg(test)] mod test { use super::*; @@ -478,12 +475,13 @@ mod test { let (mut env, _) = make_instance(); leave_default_data(&mut env); - let ptr = with_func_from_context::(&mut env, "allocate", |alloc_func| { - let result = alloc_func.call(&[10u32.into()])?; - let ptr = result[0].unwrap_i32() as u32; - Ok(ptr) - }) - .unwrap(); + let ptr = env + .with_func_from_context::<_, _>("allocate", |alloc_func| { + let result = alloc_func.call(&[10u32.into()])?; + let ptr = result[0].unwrap_i32() as u32; + Ok(ptr) + }) + .unwrap(); assert!(ptr > 0); } @@ -495,7 +493,7 @@ mod test { // Clear context's wasmer_instance set_wasmer_instance::(&mut env, None); - let res = with_func_from_context::(&mut env, "allocate", |_func| { + let res = env.with_func_from_context::<_, ()>("allocate", |_func| { panic!("unexpected callback call"); }); match res.unwrap_err() { @@ -509,7 +507,7 @@ mod test { let (mut env, _) = make_instance(); leave_default_data(&mut env); - let res = with_func_from_context::(&mut env, "doesnt_exist", |_func| { + let res = env.with_func_from_context::<_, ()>("doesnt_exist", |_func| { panic!("unexpected callback call"); }); match res.unwrap_err() { @@ -528,16 +526,17 @@ mod test { let (mut env, _) = make_instance(); leave_default_data(&mut env); - let val = with_storage_from_context::(&mut env, |store| { - Ok(store.get(INIT_KEY).0.expect("error getting value")) - }) - .unwrap(); + 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"; - with_storage_from_context::(&mut env, |store| { + env.with_storage_from_context::<_, _>(|store| { store .set(set_key, set_value) .0 @@ -546,7 +545,7 @@ mod test { }) .unwrap(); - with_storage_from_context::(&mut env, |store| { + 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(()) @@ -560,7 +559,7 @@ mod test { let (mut env, _) = make_instance(); leave_default_data(&mut env); - with_storage_from_context::(&mut env, |_store| { + env.with_storage_from_context::<_, ()>(|_store| { panic!("A panic occurred in the callback.") }) .unwrap(); @@ -571,17 +570,18 @@ mod test { let (mut env, _) = make_instance(); leave_default_data(&mut env); - let res = with_querier_from_context::(&mut env, |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 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)); @@ -593,7 +593,7 @@ mod test { let (mut env, _) = make_instance(); leave_default_data(&mut env); - with_querier_from_context::(&mut env, |_querier| { + env.with_querier_from_context::<_, ()>(|_querier| { panic!("A panic occurred in the callback.") }) .unwrap(); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 1db4cdd068..36a399a070 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -8,10 +8,7 @@ use cosmwasm_std::Order; use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr}; 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, Env, -}; +use crate::context::{is_storage_readonly, process_gas_info, Env}; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; use crate::ffi::FfiError; @@ -41,8 +38,7 @@ const MAX_LENGTH_DEBUG: usize = 2 * MI; pub fn do_read(env: &mut Env, key_ptr: u32) -> VmResult { let key = read_region(&env.memory(), key_ptr, MAX_LENGTH_DB_KEY)?; - let (result, gas_info) = - with_storage_from_context::(env, |store| Ok(store.get(&key)))?; + let (result, gas_info) = env.with_storage_from_context::<_, _>(|store| Ok(store.get(&key)))?; process_gas_info::(env, gas_info)?; let value = result?; @@ -67,7 +63,7 @@ pub fn do_write( let value = read_region(&env.memory(), value_ptr, MAX_LENGTH_DB_VALUE)?; let (result, gas_info) = - with_storage_from_context::(env, |store| Ok(store.set(&key, &value)))?; + env.with_storage_from_context::<_, _>(|store| Ok(store.set(&key, &value)))?; process_gas_info::(env, gas_info)?; result?; @@ -82,7 +78,7 @@ pub fn do_remove(env: &mut Env, key_ptr: u32) -> V let key = read_region(&env.memory(), key_ptr, MAX_LENGTH_DB_KEY)?; let (result, gas_info) = - with_storage_from_context::(env, |store| Ok(store.remove(&key)))?; + env.with_storage_from_context::<_, _>(|store| Ok(store.remove(&key)))?; process_gas_info(env, gas_info)?; result?; @@ -156,7 +152,7 @@ pub fn print_debug_message( /// Creates a Region in the contract, writes the given data to it and returns the memory location fn write_to_contract(env: &mut Env, input: &[u8]) -> VmResult { - let target_ptr = with_func_from_context::(env, "allocate", |allocate| { + let target_ptr = env.with_func_from_context::<_, u32>("allocate", |allocate| { let out_size = to_u32(input.len())?; let result = allocate.call(&[out_size.into()])?; let ptr = result[0].unwrap_i32() as u32; @@ -176,7 +172,7 @@ pub fn do_query_chain( let request = read_region(&env.memory(), request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; let gas_remaining = get_gas_left(env); - let (result, gas_info) = with_querier_from_context::(env, |querier| { + let (result, gas_info) = env.with_querier_from_context::<_, _>(|querier| { Ok(querier.query_raw(&request, gas_remaining)) })?; process_gas_info::(env, gas_info)?; @@ -197,7 +193,7 @@ pub fn do_scan( .try_into() .map_err(|_| CommunicationError::invalid_order(order))?; - let (result, gas_info) = with_storage_from_context::(env, |store| { + let (result, gas_info) = env.with_storage_from_context::<_, _>(|store| { Ok(store.scan(start.as_deref(), end.as_deref(), order)) })?; process_gas_info::(env, gas_info)?; @@ -208,7 +204,7 @@ pub fn do_scan( #[cfg(feature = "iterator")] pub fn do_next(env: &mut Env, iterator_id: u32) -> VmResult { let (result, gas_info) = - with_storage_from_context::(env, |store| Ok(store.next(iterator_id)))?; + 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_. @@ -375,13 +371,14 @@ mod test { do_write::(&mut env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(&mut env, |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())); } @@ -396,10 +393,11 @@ mod test { do_write::(&mut env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(&mut env, |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())); } @@ -414,13 +412,14 @@ mod test { do_write::(&mut env, key_ptr, value_ptr).unwrap(); - let val = with_storage_from_context::(&mut env, |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())); } @@ -500,10 +499,11 @@ mod test { do_remove::(&mut env, key_ptr).unwrap(); - let value = with_storage_from_context::(&mut env, |store| { - Ok(store.get(existing_key).0.expect("error getting value")) - }) - .unwrap(); + let value = env + .with_storage_from_context::<_, _>(|store| { + Ok(store.get(existing_key).0.expect("error getting value")) + }) + .unwrap(); assert_eq!(value, None); } @@ -519,10 +519,11 @@ mod test { // Note: right now we cannot differnetiate between an existent and a non-existent key do_remove::(&mut env, key_ptr).unwrap(); - let value = with_storage_from_context::(&mut env, |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); } diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 140e900afc..8cbe64e67e 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -10,8 +10,7 @@ use wasmer_engine_jit::JIT; use crate::backends::{compile, get_gas_left, set_gas_left}; use crate::context::{ - move_into_context, move_out_of_context, set_storage_readonly, set_wasmer_instance, - with_querier_from_context, with_storage_from_context, Env, + move_into_context, move_out_of_context, set_storage_readonly, set_wasmer_instance, Env, }; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; @@ -297,11 +296,11 @@ where } pub fn with_storage VmResult, T>(&mut self, func: F) -> VmResult { - with_storage_from_context::(&mut self.env, func) + self.env.with_storage_from_context::(func) } pub fn with_querier VmResult, T>(&mut self, func: F) -> VmResult { - with_querier_from_context::(&mut self.env, func) + self.env.with_querier_from_context::(func) } /// Requests memory allocation by the instance and returns a pointer From 8816b615270bcacad73523c8de7222146cb7c4ca Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 17:23:32 +0200 Subject: [PATCH 039/110] move set_wasmer_instance into env --- packages/vm/src/backends/mod.rs | 3 +-- packages/vm/src/backends/singlepass.rs | 3 +-- packages/vm/src/context.rs | 21 +++++++++------------ packages/vm/src/imports.rs | 4 ++-- packages/vm/src/instance.rs | 6 ++---- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/packages/vm/src/backends/mod.rs b/packages/vm/src/backends/mod.rs index 8dda22d6d8..aa8e3b3140 100644 --- a/packages/vm/src/backends/mod.rs +++ b/packages/vm/src/backends/mod.rs @@ -34,7 +34,6 @@ pub use singlepass::{backend, compile, get_gas_left, set_gas_left}; #[cfg(feature = "default-singlepass")] mod test { use super::*; - use crate::context::set_wasmer_instance; use crate::testing::{MockQuerier, MockStorage}; use std::ptr::NonNull; use wabt::wat2wasm; @@ -51,7 +50,7 @@ mod test { let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); - set_wasmer_instance::(&mut env, Some(instance_ptr)); + env.set_wasmer_instance(Some(instance_ptr)); (env, instance) } diff --git a/packages/vm/src/backends/singlepass.rs b/packages/vm/src/backends/singlepass.rs index 28cae7b301..c744b5a0e4 100644 --- a/packages/vm/src/backends/singlepass.rs +++ b/packages/vm/src/backends/singlepass.rs @@ -66,7 +66,6 @@ pub fn get_gas_left(_env: &Env) -> u64 { #[cfg(test)] mod test { use super::*; - use crate::context::set_wasmer_instance; use crate::testing::{MockQuerier, MockStorage}; use std::ptr::NonNull; use wabt::wat2wasm; @@ -83,7 +82,7 @@ mod test { let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); - set_wasmer_instance::(&mut env, Some(instance_ptr)); + env.set_wasmer_instance(Some(instance_ptr)); (env, instance) } diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index aaebea51ac..7d9ffd5465 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -164,6 +164,13 @@ impl Env { }) } + /// Creates a back reference from a contact to its partent instance + pub fn set_wasmer_instance(&mut self, wasmer_instance: Option>) { + self.with_context_data_mut(|context_data| { + context_data.wasmer_instance = wasmer_instance; + }); + } + pub fn memory(&self) -> Memory { self.with_context_data(|context| { let ptr = context @@ -203,16 +210,6 @@ impl ContextData { } } -/// Creates a back reference from a contact to its partent instance -pub fn set_wasmer_instance( - env: &mut Env, - wasmer_instance: Option>, -) { - env.with_context_data_mut(|context_data| { - 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( @@ -356,7 +353,7 @@ mod test { let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); - set_wasmer_instance::(&mut env, Some(instance_ptr)); + env.set_wasmer_instance(Some(instance_ptr)); (env, instance) } @@ -491,7 +488,7 @@ mod test { leave_default_data(&mut env); // Clear context's wasmer_instance - set_wasmer_instance::(&mut env, None); + env.set_wasmer_instance(None); let res = env.with_func_from_context::<_, ()>("allocate", |_func| { panic!("unexpected callback call"); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 36a399a070..4c6064827e 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -231,7 +231,7 @@ mod test { use wasmer::{imports, Instance as WasmerInstance}; use crate::backends::compile; - use crate::context::{move_into_context, set_storage_readonly, set_wasmer_instance}; + use crate::context::{move_into_context, set_storage_readonly}; use crate::testing::{MockApi, MockQuerier, MockStorage}; use crate::traits::Storage; use crate::FfiError; @@ -277,7 +277,7 @@ mod test { let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); let instance_ptr = NonNull::from(instance.as_ref()); - set_wasmer_instance::(&mut env, Some(instance_ptr)); + env.set_wasmer_instance(Some(instance_ptr)); set_storage_readonly::(&mut env, false); (env, instance) diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 8cbe64e67e..dd558ffaf9 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -9,9 +9,7 @@ use wasmer::{ use wasmer_engine_jit::JIT; use crate::backends::{compile, get_gas_left, set_gas_left}; -use crate::context::{ - move_into_context, move_out_of_context, set_storage_readonly, set_wasmer_instance, Env, -}; +use crate::context::{move_into_context, move_out_of_context, set_storage_readonly, Env}; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; use crate::features::required_features_from_wasmer_instance; @@ -234,7 +232,7 @@ where }); let required_features = required_features_from_wasmer_instance(wasmer_instance.as_ref()); let instance_ptr = NonNull::from(wasmer_instance.as_ref()); - set_wasmer_instance::(&mut env, Some(instance_ptr)); + env.set_wasmer_instance(Some(instance_ptr)); move_into_context(&mut env, deps.storage, deps.querier); let instance = Instance { inner: wasmer_instance, From a85533fda16ef1c08139f47cf85bf2aa61c4fd64 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 17:32:03 +0200 Subject: [PATCH 040/110] Move is_storage_readonly/set_storage_readonly to env --- packages/vm/src/context.rs | 36 ++++++++++++++++++------------------ packages/vm/src/imports.rs | 14 +++++++------- packages/vm/src/instance.rs | 17 ++++++----------- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 7d9ffd5465..381fcbcafa 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -171,6 +171,17 @@ impl Env { }); } + /// 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(&mut 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 @@ -292,17 +303,6 @@ fn account_for_externally_used_gas_impl( Ok(()) } -/// Returns true iff the storage is set to readonly mode -pub fn is_storage_readonly(env: &Env) -> bool { - env.with_context_data(|context_data| context_data.storage_readonly) -} - -pub fn set_storage_readonly(env: &mut Env, new_value: bool) { - env.with_context_data_mut(|context_data| { - context_data.storage_readonly = new_value; - }) -} - #[cfg(test)] mod test { use super::*; @@ -446,7 +446,7 @@ mod test { let (mut env, _) = make_instance(); leave_default_data(&mut env); - assert_eq!(is_storage_readonly::(&env), true); + assert_eq!(env.is_storage_readonly(), true); } #[test] @@ -455,16 +455,16 @@ mod test { leave_default_data(&mut env); // change - set_storage_readonly::(&mut env, false); - assert_eq!(is_storage_readonly::(&env), false); + env.set_storage_readonly(false); + assert_eq!(env.is_storage_readonly(), false); // still false - set_storage_readonly::(&mut env, false); - assert_eq!(is_storage_readonly::(&env), false); + env.set_storage_readonly(false); + assert_eq!(env.is_storage_readonly(), false); // change back - set_storage_readonly::(&mut env, true); - assert_eq!(is_storage_readonly::(&env), true); + env.set_storage_readonly(true); + assert_eq!(env.is_storage_readonly(), true); } #[test] diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 4c6064827e..3216d9b39d 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -8,7 +8,7 @@ use cosmwasm_std::Order; use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr}; use crate::backends::get_gas_left; -use crate::context::{is_storage_readonly, process_gas_info, Env}; +use crate::context::{process_gas_info, Env}; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; use crate::ffi::FfiError; @@ -55,7 +55,7 @@ pub fn do_write( key_ptr: u32, value_ptr: u32, ) -> VmResult<()> { - if is_storage_readonly::(env) { + if env.is_storage_readonly() { return Err(VmError::write_access_denied()); } @@ -71,7 +71,7 @@ pub fn do_write( } pub fn do_remove(env: &mut Env, key_ptr: u32) -> VmResult<()> { - if is_storage_readonly::(env) { + if env.is_storage_readonly() { return Err(VmError::write_access_denied()); } @@ -231,7 +231,7 @@ mod test { use wasmer::{imports, Instance as WasmerInstance}; use crate::backends::compile; - use crate::context::{move_into_context, set_storage_readonly}; + use crate::context::move_into_context; use crate::testing::{MockApi, MockQuerier, MockStorage}; use crate::traits::Storage; use crate::FfiError; @@ -278,7 +278,7 @@ mod test { let instance_ptr = NonNull::from(instance.as_ref()); env.set_wasmer_instance(Some(instance_ptr)); - set_storage_readonly::(&mut env, false); + env.set_storage_readonly(false); (env, instance) } @@ -479,7 +479,7 @@ mod test { let value_ptr = write_data(&mut instance, b"new value"); leave_default_data(&mut env); - set_storage_readonly::(&mut env, true); + env.set_storage_readonly(true); let result = do_write::(&mut env, key_ptr, value_ptr); match result.unwrap_err() { @@ -557,7 +557,7 @@ mod test { let key_ptr = write_data(&mut instance, b"a storage key"); leave_default_data(&mut env); - set_storage_readonly::(&mut env, true); + env.set_storage_readonly(true); let result = do_remove::(&mut env, key_ptr); match result.unwrap_err() { diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index dd558ffaf9..c19e41d00a 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -9,7 +9,7 @@ use wasmer::{ use wasmer_engine_jit::JIT; use crate::backends::{compile, get_gas_left, set_gas_left}; -use crate::context::{move_into_context, move_out_of_context, set_storage_readonly, Env}; +use crate::context::{move_into_context, move_out_of_context, Env}; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; use crate::features::required_features_from_wasmer_instance; @@ -290,7 +290,7 @@ 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::(&mut self.env, new_value); + self.env.set_storage_readonly(new_value); } pub fn with_storage VmResult, T>(&mut self, func: F) -> VmResult { @@ -341,7 +341,6 @@ where #[cfg(test)] mod test { use super::*; - use crate::context::is_storage_readonly; use crate::errors::VmError; use crate::testing::{ mock_dependencies, mock_env, mock_info, mock_instance, mock_instance_with_balances, @@ -361,10 +360,6 @@ mod test { 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 deps = mock_dependencies(&[]); @@ -610,16 +605,16 @@ mod test { fn set_storage_readonly_works() { let mut instance = mock_instance(&CONTRACT, &[]); - assert_eq!(is_storage_readonly::(&instance.env), true); + assert_eq!(instance.env.is_storage_readonly(), true); instance.set_storage_readonly(false); - assert_eq!(is_storage_readonly::(&instance.env), false); + assert_eq!(instance.env.is_storage_readonly(), false); instance.set_storage_readonly(false); - assert_eq!(is_storage_readonly::(&instance.env), false); + assert_eq!(instance.env.is_storage_readonly(), false); instance.set_storage_readonly(true); - assert_eq!(is_storage_readonly::(&instance.env), true); + assert_eq!(instance.env.is_storage_readonly(), true); } #[test] From f401ab866aa69bfc2b63e06e485fcce7082a507b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 13 Oct 2020 17:35:22 +0200 Subject: [PATCH 041/110] Remove obsolete where clauses --- packages/vm/src/context.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 381fcbcafa..60d114cd3f 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -125,8 +125,6 @@ impl Env { callback: Callback, ) -> VmResult where - S: Storage, - Q: Querier, Callback: FnOnce(&Function) -> VmResult, { self.with_context_data_mut(|context_data| match context_data.wasmer_instance { @@ -142,8 +140,6 @@ impl Env { pub fn with_storage_from_context(&mut self, func: F) -> VmResult where - S: Storage, - Q: Querier, F: FnOnce(&mut S) -> VmResult, { self.with_context_data_mut(|context_data| match context_data.storage.as_mut() { @@ -154,8 +150,6 @@ impl Env { pub fn with_querier_from_context(&mut self, func: F) -> VmResult where - S: Storage, - Q: Querier, F: FnOnce(&mut Q) -> VmResult, { self.with_context_data_mut(|context_data| match context_data.querier.as_mut() { From e73bf2d7ac85e1c767fc52d9a488e87c934b21f4 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 14 Oct 2020 10:30:48 +0200 Subject: [PATCH 042/110] Remove unused imports --- packages/vm/src/instance.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index c19e41d00a..d3ca21f655 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -344,7 +344,7 @@ mod test { use crate::errors::VmError; use crate::testing::{ mock_dependencies, mock_env, mock_info, mock_instance, mock_instance_with_balances, - mock_instance_with_failing_api, mock_instance_with_gas_limit, MockQuerier, MockStorage, + mock_instance_with_failing_api, mock_instance_with_gas_limit, }; use crate::traits::Storage; use crate::{call_init, FfiError}; From 65b394b4db7fffa03b34dc042b59e2cb65c568ef Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 14 Oct 2020 10:56:49 +0200 Subject: [PATCH 043/110] Use new_native_with_env instead of closures where possible --- packages/vm/src/imports.rs | 65 ++++++++++++++++++++++++++++++++----- packages/vm/src/instance.rs | 50 +++++----------------------- 2 files changed, 65 insertions(+), 50 deletions(-) diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 3216d9b39d..30f9fa9cfb 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -34,8 +34,58 @@ 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: &mut Env, key_ptr: u32) -> VmResult { + let ptr = do_read::(env, key_ptr)?; + Ok(ptr) +} + +pub fn native_db_write( + env: &mut Env, + key_ptr: u32, + value_ptr: u32, +) -> VmResult<()> { + do_write(env, key_ptr, value_ptr) +} + +pub fn native_db_remove(env: &mut Env, key_ptr: u32) -> VmResult<()> { + do_remove(env, key_ptr) +} + +pub fn native_query_chain( + env: &mut Env, + request_ptr: u32, +) -> VmResult { + do_query_chain(env, request_ptr) +} + +#[cfg(feature = "iterator")] +pub fn native_db_scan( + env: &mut Env, + 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: &mut Env, + iterator_id: u32, +) -> VmResult { + do_next(env, iterator_id) +} + +// +// Import implementations +// + /// Reads a storage entry from the VM's storage into Wasm memory -pub fn do_read(env: &mut Env, key_ptr: u32) -> VmResult { +fn do_read(env: &mut Env, key_ptr: u32) -> VmResult { let key = read_region(&env.memory(), key_ptr, MAX_LENGTH_DB_KEY)?; let (result, gas_info) = env.with_storage_from_context::<_, _>(|store| Ok(store.get(&key)))?; @@ -50,7 +100,7 @@ pub fn do_read(env: &mut Env, key_ptr: u32) -> VmR } /// Writes a storage entry from Wasm memory into the VM's storage -pub fn do_write( +fn do_write( env: &mut Env, key_ptr: u32, value_ptr: u32, @@ -70,7 +120,7 @@ pub fn do_write( Ok(()) } -pub fn do_remove(env: &mut Env, key_ptr: u32) -> VmResult<()> { +fn do_remove(env: &mut Env, key_ptr: u32) -> VmResult<()> { if env.is_storage_readonly() { return Err(VmError::write_access_denied()); } @@ -165,10 +215,7 @@ fn write_to_contract(env: &mut Env, input: &[u8]) Ok(target_ptr) } -pub fn do_query_chain( - env: &mut Env, - request_ptr: u32, -) -> VmResult { +fn do_query_chain(env: &mut Env, request_ptr: u32) -> VmResult { let request = read_region(&env.memory(), request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; let gas_remaining = get_gas_left(env); @@ -181,7 +228,7 @@ pub fn do_query_chain( } #[cfg(feature = "iterator")] -pub fn do_scan( +fn do_scan( env: &mut Env, start_ptr: u32, end_ptr: u32, @@ -202,7 +249,7 @@ pub fn do_scan( } #[cfg(feature = "iterator")] -pub fn do_next(env: &mut Env, iterator_id: u32) -> VmResult { +fn do_next(env: &mut Env, iterator_id: u32) -> VmResult { let (result, gas_info) = env.with_storage_from_context::<_, _>(|store| Ok(store.next(iterator_id)))?; process_gas_info::(env, gas_info)?; diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index d3ca21f655..7c53d5691a 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -14,11 +14,11 @@ use crate::conversion::to_u32; 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_query_chain, print_debug_message, }; #[cfg(feature = "iterator")] -use crate::imports::{do_next, do_scan}; +use crate::imports::{native_db_next, native_db_scan}; use crate::memory::{read_region, write_region}; use crate::traits::{Api, Extern, Querier, Storage}; @@ -82,13 +82,8 @@ where let mut env = Env::new(gas_limit); - let i32_to_i32 = FunctionType::new(vec![Type::I32], vec![Type::I32]); let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); - 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]); - #[cfg(feature = "iterator")] - let i32i32i32_to_i32 = - FunctionType::new(vec![Type::I32, Type::I32, Type::I32], vec![Type::I32]); let mut import_obj = ImportObject::new(); let mut env_imports = Exports::new(); @@ -99,23 +94,14 @@ where // Ownership of the value pointer is transferred to the contract. env_imports.insert( "db_read", - Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { - let key_ptr = args[0].unwrap_i32() as u32; - let ptr = do_read::(&mut env, key_ptr)?; - Ok(vec![ptr.into()]) - }), + 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_with_env(&store, &i32i32_to_void, env.clone(), |mut env, args| { - let key_ptr = args[0].unwrap_i32() as u32; - let value_ptr = args[1].unwrap_i32() as u32; - do_write::(&mut env, key_ptr, value_ptr)?; - Ok(vec![]) - }), + Function::new_native_with_env(&store, env.clone(), native_db_write), ); // Removes the value at the given key. Different than writing &[] as future @@ -124,11 +110,7 @@ where // Ownership of both key pointer is not transferred to the host. env_imports.insert( "db_remove", - Function::new_with_env(&store, &i32_to_void, env.clone(), |mut env, args| { - let key_ptr = args[0].unwrap_i32() as u32; - do_remove::(&mut env, key_ptr)?; - Ok(vec![]) - }), + Function::new_native_with_env(&store, env.clone(), native_db_remove), ); // Reads human address from source_ptr and writes canonicalized representation to destination_ptr. @@ -178,11 +160,7 @@ where env_imports.insert( "query_chain", - Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { - let request_ptr = args[0].unwrap_i32() as u32; - let response_ptr = do_query_chain::(&mut env, request_ptr)?; - Ok(vec![response_ptr.into()]) - }), + Function::new_native_with_env(&store, env.clone(), native_query_chain), ); // Creates an iterator that will go from start to end. @@ -194,13 +172,7 @@ where #[cfg(feature = "iterator")] env_imports.insert( "db_scan", - Function::new_with_env(&store, &i32i32i32_to_i32, env.clone(), |mut env, args| { - let start_ptr = args[0].unwrap_i32() as u32; - let end_ptr = args[1].unwrap_i32() as u32; - let order = args[2].unwrap_i32(); - let response_ptr = do_scan::(&mut env, start_ptr, end_ptr, order)?; - Ok(vec![response_ptr.into()]) - }), + Function::new_native_with_env(&store, env.clone(), native_db_scan), ); // Get next element of iterator with ID `iterator_id`. @@ -211,11 +183,7 @@ where #[cfg(feature = "iterator")] env_imports.insert( "db_next", - Function::new_with_env(&store, &i32_to_i32, env.clone(), |mut env, args| { - let iterator_id = args[0].unwrap_i32() as u32; - let response_ptr = do_next::(&mut env, iterator_id)?; - Ok(vec![response_ptr.into()]) - }), + Function::new_native_with_env(&store, env.clone(), native_db_next), ); import_obj.register("env", env_imports); From d5bf5a6d4325a7d82f94bb4a19448cac86616920 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 14 Oct 2020 11:19:10 +0200 Subject: [PATCH 044/110] Move WASM_PAGE_SIZE to tests --- packages/vm/src/instance.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 7c53d5691a..2f28984cbe 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -22,8 +22,6 @@ use crate::imports::{native_db_next, native_db_scan}; use crate::memory::{read_region, write_region}; use crate::traits::{Api, Extern, Querier, Storage}; -const WASM_PAGE_SIZE: u64 = 64 * 1024; - #[derive(Copy, Clone, Debug)] pub struct GasReport { /// The original limit the instance was created with @@ -322,6 +320,7 @@ mod test { }; use wabt::wat2wasm; + const WASM_PAGE_SIZE: u64 = 64 * 1024; const KIB: usize = 1024; const MIB: usize = 1024 * 1024; const DEFAULT_GAS_LIMIT: u64 = 500_000; From 02c60295d6a6e0fe64add53706fb5047d52d7168 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 27 Oct 2020 23:19:11 +0100 Subject: [PATCH 045/110] Fix iterator tests --- packages/vm/src/imports.rs | 51 ++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 30f9fa9cfb..bae4eac02d 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -906,22 +906,25 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_works() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); // set up iterator over all space let id = do_scan::(&mut env, 0, 0, Order::Ascending.into()).unwrap(); assert_eq!(1, id); - let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + 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::(&mut env, |store| Ok(store.next(id))) + 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::(&mut env, |store| Ok(store.next(id))) + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) .unwrap(); assert!(item.0.unwrap().is_none()); } @@ -929,22 +932,25 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_descending_works() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); // set up iterator over all space let id = do_scan::(&mut env, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(1, id); - let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + 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::(&mut env, |store| Ok(store.next(id))) + 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::(&mut env, |store| Ok(store.next(id))) + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) .unwrap(); assert!(item.0.unwrap().is_none()); } @@ -961,11 +967,13 @@ mod test { let id = do_scan::(&mut env, start, end, Order::Ascending.into()).unwrap(); - let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id))) + 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::(&mut env, |store| Ok(store.next(id))) + let item = env + .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) .unwrap(); assert!(item.0.unwrap().is_none()); } @@ -973,7 +981,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_multiple_iterators() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); // unbounded, ascending and descending @@ -983,27 +991,32 @@ mod test { assert_eq!(id2, 2); // first item, first iterator - let item = with_storage_from_context::(&mut env, |store| Ok(store.next(id1))) + 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::(&mut env, |store| Ok(store.next(id1))) + 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::(&mut env, |store| Ok(store.next(id2))) + 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::(&mut env, |store| Ok(store.next(id1))) + 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::(&mut env, |store| Ok(store.next(id2))) + 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())); } @@ -1011,7 +1024,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_errors_for_invalid_order_value() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); // set up iterator over all space @@ -1027,7 +1040,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_next_works() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); @@ -1056,7 +1069,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_next_fails_for_non_existent_id() { - let (mut env, mut instance) = make_instance(); + let (mut env, _) = make_instance(); leave_default_data(&mut env); From 8bd2d50beea847508232697a6b4eddf15c171460 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 27 Oct 2020 23:25:59 +0100 Subject: [PATCH 046/110] Use Wasmer from Github --- Cargo.lock | 10 ++++++++++ packages/vm/Cargo.toml | 31 ++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3423863334..8422525130 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1102,6 +1102,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1122,6 +1123,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "enumset", "raw-cpuid", @@ -1138,6 +1140,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1154,6 +1157,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "byteorder", "dynasm", @@ -1171,6 +1175,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "backtrace", "bincode", @@ -1189,6 +1194,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1205,6 +1211,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1224,6 +1231,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "object 0.19.0", "thiserror", @@ -1234,6 +1242,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "cranelift-entity", "serde", @@ -1242,6 +1251,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha4" +source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" dependencies = [ "backtrace", "cc", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 72ce7d69c5..045a13959f 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -32,21 +32,30 @@ staking = ["cosmwasm-std/staking"] [dependencies] # Uses the path when built locally; uses the given version from crates.io when published cosmwasm-std = { path = "../std", version = "0.11.2" } -serde_json = "1.0" -wasmer = { path = "../../../wasmer/lib/api" } -wasmer-compiler = { path = "../../../wasmer/lib/compiler" } -wasmer-compiler-cranelift = { path = "../../../wasmer/lib/compiler-cranelift", optional = true } -wasmer-compiler-singlepass = { path = "../../../wasmer/lib/compiler-singlepass", optional = true } -wasmer-engine = { path = "../../../wasmer/lib/engine" } -wasmer-engine-jit = { path = "../../../wasmer/lib/engine-jit" } -wasmer-types = { path = "../../../wasmer/lib/wasmer-types" } +hex = "0.4" +memmap = "0.7" +parity-wasm = "0.42" schemars = "0.7" +serde_json = "1.0" serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } sha2 = "0.9.1" thiserror = "1.0" -hex = "0.4" -memmap = "0.7" -parity-wasm = "0.42" +wasmer = { git = "https://github.com/wasmerio/wasmer", branch = "master" } +wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", branch = "master" } +wasmer-compiler-cranelift = { git = "https://github.com/wasmerio/wasmer", branch = "master", optional = true } +wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", branch = "master", optional = true } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", branch = "master" } +wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", branch = "master" } +wasmer-types = { git = "https://github.com/wasmerio/wasmer", branch = "master" } + +# Wasmer local (used for quick local debugging or patching) +# wasmer = { path = "../../../wasmer/lib/api" } +# wasmer-compiler = { path = "../../../wasmer/lib/compiler" } +# wasmer-compiler-cranelift = { path = "../../../wasmer/lib/compiler-cranelift", optional = true } +# wasmer-compiler-singlepass = { path = "../../../wasmer/lib/compiler-singlepass", optional = true } +# wasmer-engine = { path = "../../../wasmer/lib/engine" } +# wasmer-engine-jit = { path = "../../../wasmer/lib/engine-jit" } +# wasmer-types = { path = "../../../wasmer/lib/wasmer-types" } [dev-dependencies] tempfile = "3.1.0" From f5e7d75e7d2d436b5a1072b81bedc19eb3cda09f Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 28 Oct 2020 12:28:46 +0100 Subject: [PATCH 047/110] Remove cranelift backend --- Cargo.lock | 1 - contracts/burner/Cargo.toml | 4 +- contracts/hackatom/Cargo.toml | 4 +- contracts/queue/Cargo.toml | 4 +- contracts/reflect/Cargo.toml | 4 +- contracts/staking/Cargo.toml | 4 +- packages/vm/Cargo.toml | 14 ++----- packages/vm/README.md | 12 +----- packages/vm/src/backends/cranelift.rs | 33 ---------------- packages/vm/src/backends/mod.rs | 6 --- packages/vm/src/backends/singlepass.rs | 2 - packages/vm/src/cache.rs | 2 - packages/vm/src/context.rs | 11 ------ packages/vm/src/instance.rs | 43 +-------------------- packages/vm/src/middleware/deterministic.rs | 2 +- 15 files changed, 12 insertions(+), 134 deletions(-) delete mode 100644 packages/vm/src/backends/cranelift.rs diff --git a/Cargo.lock b/Cargo.lock index 8422525130..4f3cb00123 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -156,7 +156,6 @@ dependencies = [ "wabt", "wasmer", "wasmer-compiler", - "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-engine", "wasmer-engine-jit", diff --git a/contracts/burner/Cargo.toml b/contracts/burner/Cargo.toml index 659e4d9977..70a99f31d3 100644 --- a/contracts/burner/Cargo.toml +++ b/contracts/burner/Cargo.toml @@ -22,12 +22,10 @@ incremental = false overflow-checks = true [features] -default = ["cranelift"] +default = [] # 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.toml b/contracts/hackatom/Cargo.toml index c45b42bc76..a93320605f 100644 --- a/contracts/hackatom/Cargo.toml +++ b/contracts/hackatom/Cargo.toml @@ -22,11 +22,9 @@ incremental = false overflow-checks = true [features] -default = ["cranelift"] +default = [] # 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.toml b/contracts/queue/Cargo.toml index 098898457c..8240158642 100644 --- a/contracts/queue/Cargo.toml +++ b/contracts/queue/Cargo.toml @@ -22,11 +22,9 @@ incremental = false overflow-checks = true [features] -default = ["cranelift"] +default = [] # 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.toml b/contracts/reflect/Cargo.toml index 3712cf5b67..df612ba1ce 100644 --- a/contracts/reflect/Cargo.toml +++ b/contracts/reflect/Cargo.toml @@ -24,12 +24,10 @@ incremental = false overflow-checks = true [features] -default = ["cranelift"] +default = [] # 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.toml b/contracts/staking/Cargo.toml index 989823fa74..0bf7f8ae28 100644 --- a/contracts/staking/Cargo.toml +++ b/contracts/staking/Cargo.toml @@ -22,12 +22,10 @@ incremental = false overflow-checks = true [features] -default = ["cranelift"] +default = [] # 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/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 045a13959f..d2e4ae33a9 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-compiler-cranelift"] -singlepass = ["wasmer-compiler-singlepass"] -# default selects which *one* is re-exported in backends/mod.rs (available through eg backends::*) -default-cranelift = ["wasmer-compiler-cranelift"] -default-singlepass = ["wasmer-compiler-singlepass"] +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 @@ -42,8 +36,7 @@ sha2 = "0.9.1" thiserror = "1.0" wasmer = { git = "https://github.com/wasmerio/wasmer", branch = "master" } wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", branch = "master" } -wasmer-compiler-cranelift = { git = "https://github.com/wasmerio/wasmer", branch = "master", optional = true } -wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", branch = "master", optional = true } +wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", branch = "master" } wasmer-engine = { git = "https://github.com/wasmerio/wasmer", branch = "master" } wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", branch = "master" } wasmer-types = { git = "https://github.com/wasmerio/wasmer", branch = "master" } @@ -51,8 +44,7 @@ wasmer-types = { git = "https://github.com/wasmerio/wasmer", branch = "master" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api" } # wasmer-compiler = { path = "../../../wasmer/lib/compiler" } -# wasmer-compiler-cranelift = { path = "../../../wasmer/lib/compiler-cranelift", optional = true } -# wasmer-compiler-singlepass = { path = "../../../wasmer/lib/compiler-singlepass", optional = true } +# wasmer-compiler-singlepass = { path = "../../../wasmer/lib/compiler-singlepass" } # wasmer-engine = { path = "../../../wasmer/lib/engine" } # wasmer-engine-jit = { path = "../../../wasmer/lib/engine-jit" } # wasmer-types = { path = "../../../wasmer/lib/wasmer-types" } diff --git a/packages/vm/README.md b/packages/vm/README.md index 9f81487919..980f8f9789 100644 --- a/packages/vm/README.md +++ b/packages/vm/README.md @@ -29,19 +29,9 @@ docker run --rm -v "$(pwd)":/code \ ## Testing -By default, this repository is built and tested with the singlepass backend. -This requires running Rust nighty: - -```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 ``` ## License diff --git a/packages/vm/src/backends/cranelift.rs b/packages/vm/src/backends/cranelift.rs deleted file mode 100644 index 5fe18b5340..0000000000 --- a/packages/vm/src/backends/cranelift.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![cfg(any(feature = "cranelift", feature = "default-cranelift"))] - -use wasmer::Module; -use wasmer_compiler_cranelift::Cranelift; -use wasmer_engine_jit::JIT; - -use crate::errors::VmResult; - -const FAKE_GAS_AVAILABLE: u64 = 1_000_000; - -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 compiler = Cranelift::default(); - let engine = JIT::new(&mut compiler).engine(); - let store = Store::new(&engine); - let module = Module::new(&store, code)?; - Ok(module) -} - -pub fn backend() -> &'static str { - "cranelift" -} - -/// Set the amount of gas units that can be used in the context. -pub fn set_gas_left(_env: &mut Env, _amount: u64) {} - -/// Get how many more gas units can be used in the context. -pub fn get_gas_left(_env: &Env) -> u64 { - FAKE_GAS_AVAILABLE -} diff --git a/packages/vm/src/backends/mod.rs b/packages/vm/src/backends/mod.rs index aa8e3b3140..3ce73d13d4 100644 --- a/packages/vm/src/backends/mod.rs +++ b/packages/vm/src/backends/mod.rs @@ -1,4 +1,3 @@ -pub mod cranelift; pub mod singlepass; use crate::context::Env; @@ -24,14 +23,9 @@ pub fn decrease_gas_left( } } -#[cfg(feature = "default-cranelift")] -pub use cranelift::{backend, compile, get_gas_left, set_gas_left}; - -#[cfg(feature = "default-singlepass")] pub use singlepass::{backend, compile, get_gas_left, set_gas_left}; #[cfg(test)] -#[cfg(feature = "default-singlepass")] mod test { use super::*; use crate::testing::{MockQuerier, MockStorage}; diff --git a/packages/vm/src/backends/singlepass.rs b/packages/vm/src/backends/singlepass.rs index c744b5a0e4..046bc9f1a0 100644 --- a/packages/vm/src/backends/singlepass.rs +++ b/packages/vm/src/backends/singlepass.rs @@ -1,5 +1,3 @@ -#![cfg(any(feature = "singlepass", feature = "default-singlepass"))] - // use wasmer_middleware_common::metering; use wasmer::{Module, Store}; use wasmer_compiler_singlepass::Singlepass; diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index ad7f0342a3..ec729a59d6 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -407,7 +407,6 @@ mod test { } #[test] - #[cfg(feature = "default-singlepass")] fn resets_gas_when_reusing_instance() { let tmp_dir = TempDir::new().unwrap(); let mut cache = @@ -439,7 +438,6 @@ mod test { } #[test] - #[cfg(feature = "default-singlepass")] fn recovers_from_out_of_gas() { let tmp_dir = TempDir::new().unwrap(); let mut cache = diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 60d114cd3f..eabf46ec3b 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -257,7 +257,6 @@ fn account_for_externally_used_gas( account_for_externally_used_gas_impl(env, amount) } -#[cfg(feature = "default-singlepass")] fn account_for_externally_used_gas_impl( env: &mut Env, used_gas: u64, @@ -289,14 +288,6 @@ fn account_for_externally_used_gas_impl( }) } -#[cfg(feature = "default-cranelift")] -fn account_for_externally_used_gas_impl( - _ctx: &mut Ctx, - _used_gas: u64, -) -> VmResult<()> { - Ok(()) -} - #[cfg(test)] mod test { use super::*; @@ -390,7 +381,6 @@ mod test { } #[test] - #[cfg(feature = "default-singlepass")] fn gas_tracking_works_correctly() { let (mut env, _) = make_instance(); @@ -411,7 +401,6 @@ mod test { } #[test] - #[cfg(feature = "default-singlepass")] fn gas_tracking_works_correctly_with_gas_consumption_in_wasmer() { let (mut env, _) = make_instance(); diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index c1ea986504..f9c3ab1009 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -496,52 +496,14 @@ 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() { + 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() { + fn create_gas_report_works() { const LIMIT: u64 = 7_000_000; let mut instance = mock_instance_with_gas_limit(&CONTRACT, LIMIT); @@ -738,7 +700,6 @@ mod test { } #[cfg(test)] -#[cfg(feature = "default-singlepass")] mod singlepass_test { use cosmwasm_std::{coins, Empty}; diff --git a/packages/vm/src/middleware/deterministic.rs b/packages/vm/src/middleware/deterministic.rs index 0158722c14..981e0d5fdf 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; From 13ddda4de708f30dc60cec028dc54ae164c7f234 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 28 Oct 2020 13:02:41 +0100 Subject: [PATCH 048/110] Organize wasm_backend code --- packages/vm/src/backends/mod.rs | 87 ------------------- packages/vm/src/cache.rs | 2 +- packages/vm/src/context.rs | 6 +- packages/vm/src/errors/vm_error.rs | 2 +- packages/vm/src/imports.rs | 4 +- packages/vm/src/instance.rs | 2 +- packages/vm/src/lib.rs | 2 +- packages/vm/src/modules.rs | 4 +- .../singlepass.rs => wasm_backend/gas.rs} | 75 ++++++++++++---- packages/vm/src/wasm_backend/mod.rs | 5 ++ packages/vm/src/wasm_backend/singlepass.rs | 19 ++++ 11 files changed, 91 insertions(+), 117 deletions(-) delete mode 100644 packages/vm/src/backends/mod.rs rename packages/vm/src/{backends/singlepass.rs => wasm_backend/gas.rs} (68%) create mode 100644 packages/vm/src/wasm_backend/mod.rs create mode 100644 packages/vm/src/wasm_backend/singlepass.rs diff --git a/packages/vm/src/backends/mod.rs b/packages/vm/src/backends/mod.rs deleted file mode 100644 index 3ce73d13d4..0000000000 --- a/packages/vm/src/backends/mod.rs +++ /dev/null @@ -1,87 +0,0 @@ -pub mod singlepass; - -use crate::context::Env; -use crate::traits::{Querier, Storage}; - -#[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: &mut Env, - 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(()) - } -} - -pub use singlepass::{backend, compile, get_gas_left, set_gas_left}; - -#[cfg(test)] -mod test { - use super::*; - use crate::testing::{MockQuerier, MockStorage}; - use std::ptr::NonNull; - use wabt::wat2wasm; - use wasmer::{imports, Instance as WasmerInstance}; - - type MS = MockStorage; - type MQ = MockQuerier; - const GAS_LIMIT: u64 = 5_000_000; - - fn instantiate(code: &[u8]) -> (Env, Box) { - let mut env = Env::new(GAS_LIMIT); - let module = compile(code).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 = wat2wasm("(module)").unwrap(); - let (mut env, _) = instantiate(&wasm); - - let before = get_gas_left(&env); - decrease_gas_left(&mut 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 = wat2wasm("(module)").unwrap(); - let (mut env, _) = instantiate(&wasm); - - let before = get_gas_left(&env); - decrease_gas_left(&mut 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 = wat2wasm("(module)").unwrap(); - let (mut env, _) = instantiate(&wasm); - - let before = get_gas_left(&env); - let result = decrease_gas_left(&mut env, before + 1); - match result.unwrap_err() { - InsufficientGasLeft => {} - } - let after = get_gas_left(&env); - assert_eq!(after, 0); - } -} diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index ec729a59d6..ce39656830 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -4,13 +4,13 @@ use std::io::{Read, Write}; use std::marker::PhantomData; use std::path::PathBuf; -use crate::backends::{backend, compile}; use crate::checksum::Checksum; use crate::compatibility::check_wasm; use crate::errors::{VmError, VmResult}; use crate::instance::Instance; use crate::modules::FileSystemCache; use crate::traits::{Api, Extern, Querier, Storage}; +use crate::wasm_backend::{backend, compile}; const WASM_DIR: &str = "wasm"; const MODULES_DIR: &str = "modules"; diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index eabf46ec3b..0e87c061d2 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -5,10 +5,10 @@ use std::sync::{Arc, RwLock}; use wasmer::{Function, Instance as WasmerInstance, Memory}; -use crate::backends::decrease_gas_left; use crate::errors::{VmError, VmResult}; use crate::ffi::GasInfo; use crate::traits::{Querier, Storage}; +use crate::wasm_backend::{decrease_gas_left, get_gas_left, set_gas_left}; /** context data **/ @@ -261,8 +261,6 @@ fn account_for_externally_used_gas_impl( env: &mut Env, used_gas: u64, ) -> VmResult<()> { - use crate::backends::{get_gas_left, set_gas_left}; - // WFT?! let mut env1 = env.clone(); let env2 = env.clone(); @@ -291,10 +289,10 @@ fn account_for_externally_used_gas_impl( #[cfg(test)] mod test { use super::*; - use crate::backends::{compile, decrease_gas_left, set_gas_left}; use crate::errors::VmError; use crate::testing::{MockQuerier, MockStorage}; use crate::traits::Storage; + use crate::wasm_backend::compile; use cosmwasm_std::{ coins, from_binary, to_vec, AllBalanceResponse, BankQuery, Empty, HumanAddr, QueryRequest, }; diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index f52306c26c..720d9f7eee 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -2,8 +2,8 @@ use std::fmt::{Debug, Display}; use thiserror::Error; use super::communication_error::CommunicationError; -use crate::backends::InsufficientGasLeft; use crate::ffi::FfiError; +use crate::wasm_backend::InsufficientGasLeft; #[derive(Error, Debug)] #[non_exhaustive] diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index bae4eac02d..4b9f843206 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -7,7 +7,6 @@ use std::convert::TryInto; use cosmwasm_std::Order; use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr}; -use crate::backends::get_gas_left; use crate::context::{process_gas_info, Env}; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; @@ -17,6 +16,7 @@ use crate::memory::maybe_read_region; use crate::memory::{read_region, write_region}; use crate::serde::to_vec; use crate::traits::{Api, Querier, Storage}; +use crate::wasm_backend::get_gas_left; /// A kibi (kilo binary) const KI: usize = 1024; @@ -277,10 +277,10 @@ mod test { use std::ptr::NonNull; use wasmer::{imports, Instance as WasmerInstance}; - use crate::backends::compile; use crate::context::move_into_context; use crate::testing::{MockApi, MockQuerier, MockStorage}; use crate::traits::Storage; + use crate::wasm_backend::compile; use crate::FfiError; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index f9c3ab1009..3b703081fd 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -8,7 +8,6 @@ use wasmer::{ }; use wasmer_engine_jit::JIT; -use crate::backends::{compile, get_gas_left, set_gas_left}; use crate::context::{move_into_context, move_out_of_context, Env}; use crate::conversion::to_u32; use crate::errors::{CommunicationError, VmError, VmResult}; @@ -21,6 +20,7 @@ use crate::imports::{ use crate::imports::{native_db_next, native_db_scan}; use crate::memory::{read_region, write_region}; use crate::traits::{Api, Extern, Querier, Storage}; +use crate::wasm_backend::{compile, get_gas_left, set_gas_left}; #[derive(Copy, Clone, Debug)] pub struct GasReport { diff --git a/packages/vm/src/lib.rs b/packages/vm/src/lib.rs index d8f3a23433..20e083bb13 100644 --- a/packages/vm/src/lib.rs +++ b/packages/vm/src/lib.rs @@ -1,4 +1,3 @@ -mod backends; mod cache; mod calls; mod checksum; @@ -16,6 +15,7 @@ mod modules; mod serde; pub mod testing; mod traits; +mod wasm_backend; pub use crate::cache::CosmCache; pub use crate::calls::{ diff --git a/packages/vm/src/modules.rs b/packages/vm/src/modules.rs index b348a7f663..8bf2238682 100644 --- a/packages/vm/src/modules.rs +++ b/packages/vm/src/modules.rs @@ -11,9 +11,9 @@ use std::{ use wasmer::{Module, Store}; use wasmer_engine_jit::JIT; -use crate::backends::backend; use crate::checksum::Checksum; use crate::errors::{VmError, VmResult}; +use crate::wasm_backend::backend; /// Representation of a directory that contains compiled Wasm artifacts. pub struct FileSystemCache { @@ -97,7 +97,7 @@ impl FileSystemCache { #[cfg(test)] mod tests { use super::*; - use crate::backends::compile; + use crate::wasm_backend::compile; use std::env; use wabt::wat2wasm; use wasmer::{imports, Instance as WasmerInstance}; diff --git a/packages/vm/src/backends/singlepass.rs b/packages/vm/src/wasm_backend/gas.rs similarity index 68% rename from packages/vm/src/backends/singlepass.rs rename to packages/vm/src/wasm_backend/gas.rs index 046bc9f1a0..8ac3fa0f00 100644 --- a/packages/vm/src/backends/singlepass.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -1,12 +1,5 @@ -// use wasmer_middleware_common::metering; -use wasmer::{Module, Store}; -use wasmer_compiler_singlepass::Singlepass; -use wasmer_engine_jit::JIT; - use crate::context::Env; -use crate::errors::VmResult; use crate::traits::{Querier, Storage}; -// 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. @@ -17,20 +10,28 @@ use crate::traits::{Querier, Storage}; /// 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 MAX_GAS_LIMIT: u64 = u64::MAX / 2; const FAKE_GAS_AVAILABLE: u64 = 1_000_000; -pub fn compile(code: &[u8]) -> VmResult { - let compiler = Singlepass::default(); - let engine = JIT::new(&compiler).engine(); - let store = Store::new(&engine); - let module = Module::new(&store, code)?; - Ok(module) -} - -pub fn backend() -> &'static str { - "singlepass" +#[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: &mut Env, + 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. @@ -65,6 +66,7 @@ pub fn get_gas_left(_env: &Env) -> u64 { mod test { use super::*; use crate::testing::{MockQuerier, MockStorage}; + use crate::wasm_backend::compile; use std::ptr::NonNull; use wabt::wat2wasm; use wasmer::{imports, Instance as WasmerInstance}; @@ -72,6 +74,7 @@ mod test { type MS = MockStorage; type MQ = MockQuerier; const GAS_LIMIT: u64 = 5_000_000; + const MAX_GAS_LIMIT: u64 = u64::MAX / 2; fn instantiate(code: &[u8]) -> (Env, Box) { let mut env = Env::new(GAS_LIMIT); @@ -85,6 +88,42 @@ mod test { (env, instance) } + #[test] + fn decrease_gas_left_works() { + let wasm = wat2wasm("(module)").unwrap(); + let (mut env, _) = instantiate(&wasm); + + let before = get_gas_left(&env); + decrease_gas_left(&mut 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 = wat2wasm("(module)").unwrap(); + let (mut env, _) = instantiate(&wasm); + + let before = get_gas_left(&env); + decrease_gas_left(&mut 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 = wat2wasm("(module)").unwrap(); + let (mut env, _) = instantiate(&wasm); + + let before = get_gas_left(&env); + let result = decrease_gas_left(&mut 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 = wat2wasm("(module)").unwrap(); diff --git a/packages/vm/src/wasm_backend/mod.rs b/packages/vm/src/wasm_backend/mod.rs new file mode 100644 index 0000000000..adfb8121cd --- /dev/null +++ b/packages/vm/src/wasm_backend/mod.rs @@ -0,0 +1,5 @@ +mod gas; +mod singlepass; + +pub use gas::{decrease_gas_left, get_gas_left, set_gas_left, InsufficientGasLeft}; +pub use singlepass::{backend, compile}; diff --git a/packages/vm/src/wasm_backend/singlepass.rs b/packages/vm/src/wasm_backend/singlepass.rs new file mode 100644 index 0000000000..e9817b8eed --- /dev/null +++ b/packages/vm/src/wasm_backend/singlepass.rs @@ -0,0 +1,19 @@ +// use wasmer_middleware_common::metering; +use wasmer::{Module, Store}; +use wasmer_compiler_singlepass::Singlepass; +use wasmer_engine_jit::JIT; + +use crate::errors::VmResult; +// use crate::middleware::DeterministicMiddleware; + +pub fn compile(code: &[u8]) -> VmResult { + let compiler = Singlepass::default(); + let engine = JIT::new(&compiler).engine(); + let store = Store::new(&engine); + let module = Module::new(&store, code)?; + Ok(module) +} + +pub fn backend() -> &'static str { + "singlepass" +} From cbfa0b5791b5ecd5dd7a6b32f9900e89fe3b20eb Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 28 Oct 2020 14:07:04 +0100 Subject: [PATCH 049/110] Remove backend --- packages/vm/src/cache.rs | 4 ++-- packages/vm/src/modules.rs | 22 +++++++++++++++------- packages/vm/src/wasm_backend/mod.rs | 2 +- packages/vm/src/wasm_backend/singlepass.rs | 4 ---- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index ce39656830..e83a663c96 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -10,7 +10,7 @@ use crate::errors::{VmError, VmResult}; use crate::instance::Instance; use crate::modules::FileSystemCache; use crate::traits::{Api, Extern, Querier, Storage}; -use crate::wasm_backend::{backend, compile}; +use crate::wasm_backend::compile; const WASM_DIR: &str = "wasm"; const MODULES_DIR: &str = "modules"; @@ -104,7 +104,7 @@ where gas_limit: u64, ) -> VmResult> { // try from the module cache - let res = self.modules.load_with_backend(checksum, backend()); + let res = self.modules.load(checksum); if let Ok(module) = res { self.stats.hits_module += 1; return Instance::from_module(&module, deps, gas_limit, self.print_debug); diff --git a/packages/vm/src/modules.rs b/packages/vm/src/modules.rs index 8bf2238682..eddc7aeb73 100644 --- a/packages/vm/src/modules.rs +++ b/packages/vm/src/modules.rs @@ -13,7 +13,15 @@ use wasmer_engine_jit::JIT; use crate::checksum::Checksum; use crate::errors::{VmError, VmResult}; -use crate::wasm_backend::backend; + +/// 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 { @@ -60,12 +68,12 @@ impl FileSystemCache { } pub fn load(&self, checksum: &Checksum) -> VmResult { - self.load_with_backend(checksum, backend()) - } - - pub fn load_with_backend(&self, checksum: &Checksum, backend: &str) -> 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 = File::open(file_path) .map_err(|e| VmError::cache_err(format!("Error opening module file: {}", e)))?; let mmap = unsafe { Mmap::map(&file) } @@ -78,7 +86,7 @@ impl FileSystemCache { } pub fn store(&mut self, checksum: &Checksum, module: Module) -> VmResult<()> { - let modules_dir = self.path.clone().join(backend()); + 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)))?; diff --git a/packages/vm/src/wasm_backend/mod.rs b/packages/vm/src/wasm_backend/mod.rs index adfb8121cd..f5a360554f 100644 --- a/packages/vm/src/wasm_backend/mod.rs +++ b/packages/vm/src/wasm_backend/mod.rs @@ -2,4 +2,4 @@ mod gas; mod singlepass; pub use gas::{decrease_gas_left, get_gas_left, set_gas_left, InsufficientGasLeft}; -pub use singlepass::{backend, compile}; +pub use singlepass::compile; diff --git a/packages/vm/src/wasm_backend/singlepass.rs b/packages/vm/src/wasm_backend/singlepass.rs index e9817b8eed..15f5aef7ad 100644 --- a/packages/vm/src/wasm_backend/singlepass.rs +++ b/packages/vm/src/wasm_backend/singlepass.rs @@ -13,7 +13,3 @@ pub fn compile(code: &[u8]) -> VmResult { let module = Module::new(&store, code)?; Ok(module) } - -pub fn backend() -> &'static str { - "singlepass" -} From 0fdd63a925b6ecfe3c20a084f517791dc2341d60 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 28 Oct 2020 14:25:08 +0100 Subject: [PATCH 050/110] Store store in FileSystemCache --- packages/vm/src/modules.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/vm/src/modules.rs b/packages/vm/src/modules.rs index eddc7aeb73..eff5a9b8f3 100644 --- a/packages/vm/src/modules.rs +++ b/packages/vm/src/modules.rs @@ -25,6 +25,9 @@ const MODULE_SERIALIZATION_VERSION: &str = "v1"; /// Representation of a directory that contains compiled Wasm artifacts. pub struct FileSystemCache { + /// The Wasmer store for deserializing modules. + /// This contains the engine (JIT or native), which is set in the constructor. + store: Store, path: PathBuf, } @@ -37,12 +40,15 @@ impl FileSystemCache { /// This method is unsafe because there's no way to ensure the artifacts /// stored in this cache haven't been corrupted or tampered with. pub unsafe fn new>(path: P) -> io::Result { + let engine = JIT::headless().engine(); + let store = Store::new(&engine); // engine is cloned into the store internally + let path: PathBuf = path.into(); if path.exists() { let metadata = path.metadata()?; if metadata.is_dir() { if !metadata.permissions().readonly() { - Ok(Self { path }) + Ok(Self { store, path }) } else { // This directory is readonly. Err(io::Error::new( @@ -63,7 +69,7 @@ impl FileSystemCache { } else { // Create the directory and any parent directories if they don't yet exist. fs::create_dir_all(&path)?; - Ok(Self { path }) + Ok(Self { store, path }) } } @@ -79,9 +85,7 @@ impl FileSystemCache { let mmap = unsafe { Mmap::map(&file) } .map_err(|e| VmError::cache_err(format!("Mmap error: {}", e)))?; - let engine = JIT::headless().engine(); - let store = Store::new(&engine); - let module = unsafe { Module::deserialize(&store, &mmap[..]) }?; + let module = unsafe { Module::deserialize(&self.store, &mmap[..]) }?; Ok(module) } From 709699cfb675e20e4ef70f25f2b1f3c8a8911ab5 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 28 Oct 2020 14:29:22 +0100 Subject: [PATCH 051/110] Update wasmer --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f3cb00123..9d77a4d22d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1101,7 +1101,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1122,7 +1122,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "enumset", "raw-cpuid", @@ -1139,7 +1139,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1156,7 +1156,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "byteorder", "dynasm", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "backtrace", "bincode", @@ -1193,7 +1193,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1210,7 +1210,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1230,7 +1230,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "object 0.19.0", "thiserror", @@ -1241,7 +1241,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "cranelift-entity", "serde", @@ -1250,7 +1250,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#3663140dadddcf4806102b7c1d027482174ef27b" +source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" dependencies = [ "backtrace", "cc", From 24b34f3c1b07a52af4001177b2df46fdd3bfbce5 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 28 Oct 2020 14:55:47 +0100 Subject: [PATCH 052/110] Add LimitingTunables --- .../vm/src/wasm_backend/limiting_tunables.rs | 171 ++++++++++++++++++ packages/vm/src/wasm_backend/mod.rs | 2 + 2 files changed, 173 insertions(+) create mode 100644 packages/vm/src/wasm_backend/limiting_tunables.rs 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..5c81726dfa --- /dev/null +++ b/packages/vm/src/wasm_backend/limiting_tunables.rs @@ -0,0 +1,171 @@ +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 type as requested by the guest and returns a + /// limited memory type that is ready for processing. + fn adjust_memory(&self, requested: &MemoryType) -> Result { + if requested.minimum > self.limit { + return Err(MemoryError::Generic( + "Minimum of requested memory exceeds the allowed memory limit".to_string(), + )); + } + + if let Some(max) = requested.maximum { + if max > self.limit { + return Err(MemoryError::Generic( + "Maximum of requested memory exceeds the allowed memory limit".to_string(), + )); + } + } + + let mut adjusted = requested.clone(); + // We know that if `requested.maximum` is set, it is less than or equal to `self.limit`. + // So this sets maximum to (pseudo-code) `min(requested.maximum, self.limit)` + adjusted.maximum = Some(requested.maximum.unwrap_or(self.limit)); + Ok(adjusted) + } +} + +impl Tunables for LimitingTunables { + /// Construct a `MemoryStyle` for the provided `MemoryType` + /// + /// Delegated to base. + fn memory_style(&self, memory: &MemoryType) -> MemoryStyle { + self.base.memory_style(memory) + } + + /// 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.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.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).unwrap(); + 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).unwrap(); + assert_eq!(adjusted, MemoryType::new(3, Some(7), true)); + + // Maximum equal to limit + let requested = MemoryType::new(3, Some(12), true); + let adjusted = limiting.adjust_memory(&requested).unwrap(); + assert_eq!(adjusted, MemoryType::new(3, Some(12), true)); + + // Maximum greater than limit + let requested = MemoryType::new(3, Some(20), true); + let result = limiting.adjust_memory(&requested); + match result.unwrap_err() { + MemoryError::Generic(msg) => assert_eq!( + msg, + "Maximum of requested memory exceeds the allowed memory limit" + ), + err => panic!("Unexpected error: {:?}", err), + } + + // Minimum greater than maximum (not our problem) + let requested = MemoryType::new(5, Some(3), true); + let adjusted = limiting.adjust_memory(&requested).unwrap(); + assert_eq!(adjusted, MemoryType::new(5, Some(3), true)); + + // Minimum greater than limit + let requested = MemoryType::new(20, Some(20), true); + let result = limiting.adjust_memory(&requested); + match result.unwrap_err() { + MemoryError::Generic(msg) => assert_eq!( + msg, + "Minimum of requested memory 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 index f5a360554f..cdc76a496a 100644 --- a/packages/vm/src/wasm_backend/mod.rs +++ b/packages/vm/src/wasm_backend/mod.rs @@ -1,5 +1,7 @@ mod gas; +mod limiting_tunables; mod singlepass; pub use gas::{decrease_gas_left, get_gas_left, set_gas_left, InsufficientGasLeft}; +pub use limiting_tunables::LimitingTunables; pub use singlepass::compile; From 57ee49ae0b81f7572776de10104f2712455f30ff Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 28 Oct 2020 17:10:33 +0100 Subject: [PATCH 053/110] Create make_store/make_store_headless and introduce a memory limit --- packages/vm/src/cache.rs | 3 ++- packages/vm/src/context.rs | 3 ++- packages/vm/src/imports.rs | 3 ++- packages/vm/src/instance.rs | 13 +++++----- packages/vm/src/modules.rs | 9 ++++--- packages/vm/src/wasm_backend/compile.rs | 14 +++++++++++ packages/vm/src/wasm_backend/gas.rs | 3 ++- packages/vm/src/wasm_backend/mod.rs | 6 +++-- packages/vm/src/wasm_backend/singlepass.rs | 15 ----------- packages/vm/src/wasm_backend/store.rs | 29 ++++++++++++++++++++++ 10 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 packages/vm/src/wasm_backend/compile.rs delete mode 100644 packages/vm/src/wasm_backend/singlepass.rs create mode 100644 packages/vm/src/wasm_backend/store.rs diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index e83a663c96..75d31c15dd 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -14,6 +14,7 @@ use crate::wasm_backend::compile; const WASM_DIR: &str = "wasm"; const MODULES_DIR: &str = "modules"; +const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB #[derive(Debug, Default, Clone)] struct Stats { @@ -75,7 +76,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, MEMORY_LIMIT)?; self.modules.store(&checksum, module)?; Ok(checksum) } diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 0e87c061d2..55f7fc43d7 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -314,11 +314,12 @@ mod test { const GAS_LIMIT: u64 = 5_000_000; const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000; + const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB fn make_instance() -> (Env, Box) { let mut env = Env::new(GAS_LIMIT); - let module = compile(&CONTRACT).unwrap(); + let module = compile(&CONTRACT, MEMORY_LIMIT).unwrap(); // we need stubs for all required imports let import_obj = imports! { "env" => { diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 4b9f843206..3241f776ff 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -302,11 +302,12 @@ mod test { const INIT_DENOM: &str = "TOKEN"; const GAS_LIMIT: u64 = 5_000_000; + const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB fn make_instance() -> (Env, Box) { let mut env = Env::new(GAS_LIMIT); - let module = compile(&CONTRACT).unwrap(); + let module = compile(&CONTRACT, MEMORY_LIMIT).unwrap(); // we need stubs for all required imports let import_obj = imports! { "env" => { diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 3b703081fd..1f42c5b70a 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -3,10 +3,8 @@ use std::marker::PhantomData; use std::ptr::NonNull; use wasmer::{ - Exports, Function, FunctionType, ImportObject, Instance as WasmerInstance, Module, Store, Type, - Val, + Exports, Function, FunctionType, ImportObject, Instance as WasmerInstance, Module, Type, Val, }; -use wasmer_engine_jit::JIT; use crate::context::{move_into_context, move_out_of_context, Env}; use crate::conversion::to_u32; @@ -20,7 +18,9 @@ use crate::imports::{ use crate::imports::{native_db_next, native_db_scan}; use crate::memory::{read_region, write_region}; use crate::traits::{Api, Extern, Querier, Storage}; -use crate::wasm_backend::{compile, get_gas_left, set_gas_left}; +use crate::wasm_backend::{compile, get_gas_left, make_store_headless, set_gas_left}; + +const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB #[derive(Copy, Clone, Debug)] pub struct GasReport { @@ -62,7 +62,7 @@ where gas_limit: u64, print_debug: bool, ) -> VmResult { - let module = compile(code)?; + let module = compile(code, MEMORY_LIMIT)?; Instance::from_module(&module, deps, gas_limit, print_debug) } @@ -75,8 +75,7 @@ where // copy this so it can be moved into the closures, without pulling in deps let api = deps.api; - let engine = JIT::headless().engine(); - let store = Store::new(&engine); + let store = make_store_headless(MEMORY_LIMIT); let mut env = Env::new(gas_limit); diff --git a/packages/vm/src/modules.rs b/packages/vm/src/modules.rs index eff5a9b8f3..f6d6da1292 100644 --- a/packages/vm/src/modules.rs +++ b/packages/vm/src/modules.rs @@ -9,10 +9,10 @@ use std::{ }; use wasmer::{Module, Store}; -use wasmer_engine_jit::JIT; use crate::checksum::Checksum; use crate::errors::{VmError, VmResult}; +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. @@ -23,6 +23,8 @@ use crate::errors::{VmError, VmResult}; /// of old versions. const MODULE_SERIALIZATION_VERSION: &str = "v1"; +const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + /// Representation of a directory that contains compiled Wasm artifacts. pub struct FileSystemCache { /// The Wasmer store for deserializing modules. @@ -40,8 +42,7 @@ impl FileSystemCache { /// This method is unsafe because there's no way to ensure the artifacts /// stored in this cache haven't been corrupted or tampered with. pub unsafe fn new>(path: P) -> io::Result { - let engine = JIT::headless().engine(); - let store = Store::new(&engine); // engine is cloned into the store internally + let store = make_store_headless(MEMORY_LIMIT); let path: PathBuf = path.into(); if path.exists() { @@ -128,7 +129,7 @@ mod tests { .unwrap(); let checksum = Checksum::generate(&wasm); - let module = compile(&wasm).unwrap(); + let module = compile(&wasm, MEMORY_LIMIT).unwrap(); let cache_dir = env::temp_dir(); let mut fs_cache = unsafe { FileSystemCache::new(cache_dir).unwrap() }; diff --git a/packages/vm/src/wasm_backend/compile.rs b/packages/vm/src/wasm_backend/compile.rs new file mode 100644 index 0000000000..2f92b62ebc --- /dev/null +++ b/packages/vm/src/wasm_backend/compile.rs @@ -0,0 +1,14 @@ +// use wasmer_middleware_common::metering; +use wasmer::Module; + +use super::store::make_store; +use crate::errors::VmResult; +// use crate::middleware::DeterministicMiddleware; + +/// Compiles a given Wasm bytecode into a module. +/// The given memory limit (in Wasm pages) is used when memories are created. +pub fn compile(code: &[u8], memory_limit: u32) -> 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 index 8ac3fa0f00..54f14b0789 100644 --- a/packages/vm/src/wasm_backend/gas.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -75,10 +75,11 @@ mod test { type MQ = MockQuerier; const GAS_LIMIT: u64 = 5_000_000; const MAX_GAS_LIMIT: u64 = u64::MAX / 2; + const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB fn instantiate(code: &[u8]) -> (Env, Box) { let mut env = Env::new(GAS_LIMIT); - let module = compile(code).unwrap(); + let module = compile(code, MEMORY_LIMIT).unwrap(); let import_obj = imports! { "env" => {}, }; let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); diff --git a/packages/vm/src/wasm_backend/mod.rs b/packages/vm/src/wasm_backend/mod.rs index cdc76a496a..f739fc75ee 100644 --- a/packages/vm/src/wasm_backend/mod.rs +++ b/packages/vm/src/wasm_backend/mod.rs @@ -1,7 +1,9 @@ +mod compile; mod gas; mod limiting_tunables; -mod singlepass; +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 singlepass::compile; +pub use store::{make_store, make_store_headless}; diff --git a/packages/vm/src/wasm_backend/singlepass.rs b/packages/vm/src/wasm_backend/singlepass.rs deleted file mode 100644 index 15f5aef7ad..0000000000 --- a/packages/vm/src/wasm_backend/singlepass.rs +++ /dev/null @@ -1,15 +0,0 @@ -// use wasmer_middleware_common::metering; -use wasmer::{Module, Store}; -use wasmer_compiler_singlepass::Singlepass; -use wasmer_engine_jit::JIT; - -use crate::errors::VmResult; -// use crate::middleware::DeterministicMiddleware; - -pub fn compile(code: &[u8]) -> VmResult { - let compiler = Singlepass::default(); - let engine = JIT::new(&compiler).engine(); - let store = Store::new(&engine); - let module = Module::new(&store, code)?; - Ok(module) -} diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs new file mode 100644 index 0000000000..e6c9c2c852 --- /dev/null +++ b/packages/vm/src/wasm_backend/store.rs @@ -0,0 +1,29 @@ +use wasmer::{Pages, Store, Target, Tunables as ReferenceTunables}; +use wasmer_compiler_singlepass::Singlepass; +use wasmer_engine::{Engine, Tunables}; +use wasmer_engine_jit::JIT; + +use super::limiting_tunables::LimitingTunables; + +/// Created a store with the default compiler and the given memory limit (in pages) +pub fn make_store(memory_limit: u32) -> Store { + 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 pages) +pub fn make_store_headless(memory_limit: u32) -> Store { + let engine = JIT::headless().engine(); + make_store_with_engine(&engine, memory_limit) +} + +fn make_store_with_engine(engine: &dyn Engine, memory_limit: u32) -> Store { + let tunables = make_tunables(Pages(memory_limit)); + Store::new_with_tunables(engine, tunables) +} + +fn make_tunables(memory_limit: Pages) -> impl Tunables { + let base = ReferenceTunables::for_target(&Target::default()); + LimitingTunables::new(base, memory_limit) +} From c413bfeb2ca83c3ccce5e1227addc826d01c4497 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 29 Oct 2020 00:25:33 +0100 Subject: [PATCH 054/110] Update wasmer --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d77a4d22d..0a6e59f52f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1101,7 +1101,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1122,7 +1122,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "enumset", "raw-cpuid", @@ -1139,7 +1139,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1156,7 +1156,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "byteorder", "dynasm", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "backtrace", "bincode", @@ -1193,7 +1193,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1210,7 +1210,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1230,7 +1230,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "object 0.19.0", "thiserror", @@ -1241,7 +1241,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "cranelift-entity", "serde", @@ -1250,7 +1250,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#eec90e79409cf444d6299cadaea18dea187523c0" +source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" dependencies = [ "backtrace", "cc", From c52a60a579139ddbc534055b447b972d43bba0bd Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 29 Oct 2020 00:54:58 +0100 Subject: [PATCH 055/110] Split memory adjustment and memory validation --- .../vm/src/wasm_backend/limiting_tunables.rs | 116 +++++++++++++----- 1 file changed, 82 insertions(+), 34 deletions(-) diff --git a/packages/vm/src/wasm_backend/limiting_tunables.rs b/packages/vm/src/wasm_backend/limiting_tunables.rs index 5c81726dfa..44925f6ca1 100644 --- a/packages/vm/src/wasm_backend/limiting_tunables.rs +++ b/packages/vm/src/wasm_backend/limiting_tunables.rs @@ -25,28 +25,38 @@ impl LimitingTunables { Self { limit, base } } - /// Takes in input type as requested by the guest and returns a - /// limited memory type that is ready for processing. - fn adjust_memory(&self, requested: &MemoryType) -> Result { - if requested.minimum > self.limit { + /// 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.clone(); + 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 of requested memory exceeds the allowed memory limit".to_string(), + "Minimum exceeds the allowed memory limit".to_string(), )); } - if let Some(max) = requested.maximum { + if let Some(max) = ty.maximum { if max > self.limit { return Err(MemoryError::Generic( - "Maximum of requested memory exceeds the allowed memory limit".to_string(), + "Maximum exceeds the allowed memory limit".to_string(), )); } + } else { + return Err(MemoryError::Generic("Maximum unset".to_string())); } - let mut adjusted = requested.clone(); - // We know that if `requested.maximum` is set, it is less than or equal to `self.limit`. - // So this sets maximum to (pseudo-code) `min(requested.maximum, self.limit)` - adjusted.maximum = Some(requested.maximum.unwrap_or(self.limit)); - Ok(adjusted) + Ok(()) } } @@ -55,7 +65,8 @@ impl Tunables for LimitingTunables { /// /// Delegated to base. fn memory_style(&self, memory: &MemoryType) -> MemoryStyle { - self.base.memory_style(memory) + let adjusted = self.adjust_memory(memory); + self.base.memory_style(&adjusted) } /// Construct a `TableStyle` for the provided `TableType` @@ -73,7 +84,8 @@ impl Tunables for LimitingTunables { ty: &MemoryType, style: &MemoryStyle, ) -> Result, MemoryError> { - let adjusted = self.adjust_memory(ty)?; + let adjusted = self.adjust_memory(ty); + self.validate_memory(&adjusted)?; self.base.create_host_memory(&adjusted, style) } @@ -86,7 +98,8 @@ impl Tunables for LimitingTunables { style: &MemoryStyle, vm_definition_location: NonNull, ) -> Result, MemoryError> { - let adjusted = self.adjust_memory(ty)?; + let adjusted = self.adjust_memory(ty); + self.validate_memory(&adjusted)?; self.base .create_vm_memory(&adjusted, style, vm_definition_location) } @@ -128,43 +141,78 @@ mod test { // No maximum let requested = MemoryType::new(3, None, true); - let adjusted = limiting.adjust_memory(&requested).unwrap(); + 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).unwrap(); - assert_eq!(adjusted, 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).unwrap(); - assert_eq!(adjusted, 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 result = limiting.adjust_memory(&requested); + 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 of requested memory exceeds the allowed memory limit" - ), + 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 requested = MemoryType::new(5, Some(3), true); - let adjusted = limiting.adjust_memory(&requested).unwrap(); - assert_eq!(adjusted, MemoryType::new(5, Some(3), true)); + let memory = MemoryType::new(5, Some(3), true); + limiting.validate_memory(&memory).unwrap(); // Minimum greater than limit - let requested = MemoryType::new(20, Some(20), true); - let result = limiting.adjust_memory(&requested); + 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 of requested memory exceeds the allowed memory limit" - ), + MemoryError::Generic(msg) => { + assert_eq!(msg, "Minimum exceeds the allowed memory limit") + } err => panic!("Unexpected error: {:?}", err), } } From 3f63c9919b907128c68927a4e729a1165319308b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 29 Oct 2020 11:01:13 +0100 Subject: [PATCH 056/110] Reuse store from Module --- packages/vm/src/instance.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 1f42c5b70a..aaf28d48a2 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -18,7 +18,7 @@ use crate::imports::{ use crate::imports::{native_db_next, native_db_scan}; use crate::memory::{read_region, write_region}; use crate::traits::{Api, Extern, Querier, Storage}; -use crate::wasm_backend::{compile, get_gas_left, make_store_headless, set_gas_left}; +use crate::wasm_backend::{compile, get_gas_left, set_gas_left}; const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB @@ -75,7 +75,7 @@ where // copy this so it can be moved into the closures, without pulling in deps let api = deps.api; - let store = make_store_headless(MEMORY_LIMIT); + let store = module.store(); let mut env = Env::new(gas_limit); @@ -91,14 +91,14 @@ where // Ownership of the value pointer is transferred to the contract. env_imports.insert( "db_read", - Function::new_native_with_env(&store, env.clone(), native_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), + Function::new_native_with_env(store, env.clone(), native_db_write), ); // Removes the value at the given key. Different than writing &[] as future @@ -107,7 +107,7 @@ where // Ownership of both key pointer is not transferred to the host. env_imports.insert( "db_remove", - Function::new_native_with_env(&store, env.clone(), native_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. @@ -116,7 +116,7 @@ where // 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 |mut env, args| { + Function::new_with_env(store, &i32i32_to_i32, env.clone(), move |mut env, args| { let source_ptr = args[0].unwrap_i32() as u32; let destination_ptr = args[1].unwrap_i32() as u32; let ptr = @@ -131,7 +131,7 @@ where // 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 |mut env, args| { + Function::new_with_env(store, &i32i32_to_i32, env.clone(), move |mut env, args| { let source_ptr = args[0].unwrap_i32() as u32; let destination_ptr = args[1].unwrap_i32() as u32; let ptr = @@ -146,7 +146,7 @@ where // Ownership of both input and output pointer is not transferred to the host. env_imports.insert( "debug", - Function::new_with_env(&store, &i32_to_void, env.clone(), move |mut env, args| { + Function::new_with_env(store, &i32_to_void, env.clone(), move |mut env, args| { let message_ptr = args[0].unwrap_i32() as u32; if print_debug { print_debug_message(&mut env, message_ptr)?; @@ -157,7 +157,7 @@ where env_imports.insert( "query_chain", - Function::new_native_with_env(&store, env.clone(), native_query_chain), + Function::new_native_with_env(store, env.clone(), native_query_chain), ); // Creates an iterator that will go from start to end. @@ -169,7 +169,7 @@ where #[cfg(feature = "iterator")] env_imports.insert( "db_scan", - Function::new_native_with_env(&store, env.clone(), native_db_scan), + Function::new_native_with_env(store, env.clone(), native_db_scan), ); // Get next element of iterator with ID `iterator_id`. @@ -180,7 +180,7 @@ where #[cfg(feature = "iterator")] env_imports.insert( "db_next", - Function::new_native_with_env(&store, env.clone(), native_db_next), + Function::new_native_with_env(store, env.clone(), native_db_next), ); import_obj.register("env", env_imports); From b1864f47b1c12039ae0a09607c4ced6c2ed1f53c Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 29 Oct 2020 20:05:34 +0100 Subject: [PATCH 057/110] Add memory_limit to InstanceOptions --- packages/vm/src/cache.rs | 8 ++++++-- packages/vm/src/imports.rs | 4 ++-- packages/vm/src/instance.rs | 6 +++--- packages/vm/src/modules.rs | 24 ++++++++++-------------- packages/vm/src/testing/instance.rs | 3 +++ packages/vm/src/wasm_backend/gas.rs | 4 ++-- 6 files changed, 26 insertions(+), 23 deletions(-) diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 7f172da28c..fd226e98bd 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -14,7 +14,6 @@ use crate::wasm_backend::compile; const WASM_DIR: &str = "wasm"; const MODULES_DIR: &str = "modules"; -const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB #[derive(Debug, Default, Clone)] struct Stats { @@ -73,6 +72,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)?; + const MEMORY_LIMIT: u32 = 256; // Hmm, is this even used? let module = compile(wasm, MEMORY_LIMIT)?; self.modules.store(&checksum, module)?; Ok(checksum) @@ -102,7 +102,7 @@ where options: InstanceOptions, ) -> VmResult> { // try from the module cache - let res = self.modules.load(checksum); + let res = self.modules.load(checksum, options.memory_limit); if let Ok(module) = res { self.stats.hits_module += 1; return Instance::from_module(&module, deps, options.gas_limit, options.print_debug); @@ -166,8 +166,10 @@ mod test { use wabt::wat2wasm; const TESTING_GAS_LIMIT: u64 = 400_000; + const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB const TESTING_OPTIONS: InstanceOptions = InstanceOptions { gas_limit: TESTING_GAS_LIMIT, + memory_limit: TESTING_MEMORY_LIMIT, print_debug: false, }; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); @@ -445,6 +447,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, deps1, options).unwrap(); @@ -463,6 +466,7 @@ mod test { // Init from instance cache let options = InstanceOptions { gas_limit: TESTING_GAS_LIMIT, + memory_limit: TESTING_MEMORY_LIMIT, print_debug: false, }; let mut instance2 = cache.get_instance(&id, deps2, options).unwrap(); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 3241f776ff..32866ac6eb 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -302,12 +302,12 @@ mod test { const INIT_DENOM: &str = "TOKEN"; const GAS_LIMIT: u64 = 5_000_000; - const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB fn make_instance() -> (Env, Box) { let mut env = Env::new(GAS_LIMIT); - let module = compile(&CONTRACT, MEMORY_LIMIT).unwrap(); + let module = compile(&CONTRACT, TESTING_MEMORY_LIMIT).unwrap(); // we need stubs for all required imports let import_obj = imports! { "env" => { diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 440b5fb020..50221d11a6 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -20,8 +20,6 @@ use crate::memory::{read_region, write_region}; use crate::traits::{Api, Extern, Querier, Storage}; use crate::wasm_backend::{compile, get_gas_left, set_gas_left}; -const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB - #[derive(Copy, Clone, Debug)] pub struct GasReport { /// The original limit the instance was created with @@ -38,6 +36,8 @@ pub struct GasReport { #[derive(Copy, Clone, Debug)] pub struct InstanceOptions { pub gas_limit: u64, + /// Memory limit in Wasm pages (64 KiB per page) + pub memory_limit: u32, pub print_debug: bool, } @@ -67,7 +67,7 @@ where deps: Extern, options: InstanceOptions, ) -> VmResult { - let module = compile(code, MEMORY_LIMIT)?; + let module = compile(code, options.memory_limit)?; Instance::from_module(&module, deps, options.gas_limit, options.print_debug) } diff --git a/packages/vm/src/modules.rs b/packages/vm/src/modules.rs index f6d6da1292..8e30114fcd 100644 --- a/packages/vm/src/modules.rs +++ b/packages/vm/src/modules.rs @@ -8,7 +8,7 @@ use std::{ path::PathBuf, }; -use wasmer::{Module, Store}; +use wasmer::Module; use crate::checksum::Checksum; use crate::errors::{VmError, VmResult}; @@ -23,13 +23,8 @@ use crate::wasm_backend::make_store_headless; /// of old versions. const MODULE_SERIALIZATION_VERSION: &str = "v1"; -const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB - /// Representation of a directory that contains compiled Wasm artifacts. pub struct FileSystemCache { - /// The Wasmer store for deserializing modules. - /// This contains the engine (JIT or native), which is set in the constructor. - store: Store, path: PathBuf, } @@ -42,14 +37,12 @@ impl FileSystemCache { /// This method is unsafe because there's no way to ensure the artifacts /// stored in this cache haven't been corrupted or tampered with. pub unsafe fn new>(path: P) -> io::Result { - let store = make_store_headless(MEMORY_LIMIT); - let path: PathBuf = path.into(); if path.exists() { let metadata = path.metadata()?; if metadata.is_dir() { if !metadata.permissions().readonly() { - Ok(Self { store, path }) + Ok(Self { path }) } else { // This directory is readonly. Err(io::Error::new( @@ -70,11 +63,11 @@ impl FileSystemCache { } else { // Create the directory and any parent directories if they don't yet exist. fs::create_dir_all(&path)?; - Ok(Self { store, path }) + Ok(Self { path }) } } - pub fn load(&self, checksum: &Checksum) -> VmResult { + pub fn load(&self, checksum: &Checksum, memory_limit: u32) -> VmResult { let filename = checksum.to_hex(); let file_path = self .path @@ -86,7 +79,8 @@ impl FileSystemCache { let mmap = unsafe { Mmap::map(&file) } .map_err(|e| VmError::cache_err(format!("Mmap error: {}", e)))?; - let module = unsafe { Module::deserialize(&self.store, &mmap[..]) }?; + let store = make_store_headless(memory_limit); + let module = unsafe { Module::deserialize(&store, &mmap[..]) }?; Ok(module) } @@ -115,6 +109,8 @@ mod tests { use wabt::wat2wasm; use wasmer::{imports, Instance as WasmerInstance}; + const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + #[test] fn test_file_system_cache_run() { let wasm = wat2wasm( @@ -129,7 +125,7 @@ mod tests { .unwrap(); let checksum = Checksum::generate(&wasm); - let module = compile(&wasm, MEMORY_LIMIT).unwrap(); + let module = compile(&wasm, TESTING_MEMORY_LIMIT).unwrap(); let cache_dir = env::temp_dir(); let mut fs_cache = unsafe { FileSystemCache::new(cache_dir).unwrap() }; @@ -138,7 +134,7 @@ mod tests { fs_cache.store(&checksum, module.clone()).unwrap(); // load module - let cached_result = fs_cache.load(&checksum); + let cached_result = fs_cache.load(&checksum, TESTING_MEMORY_LIMIT); let cached_module = cached_result.unwrap(); let import_object = imports! {}; diff --git a/packages/vm/src/testing/instance.rs b/packages/vm/src/testing/instance.rs index 862b9f22e6..28cbebc27a 100644 --- a/packages/vm/src/testing/instance.rs +++ b/packages/vm/src/testing/instance.rs @@ -14,6 +14,7 @@ use super::querier::MockQuerier; use super::storage::MockStorage; const DEFAULT_GAS_LIMIT: u64 = 500_000; +const DEFAULT_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB const DEFAULT_PRINT_DEBUG: bool = true; pub fn mock_instance( @@ -131,6 +132,7 @@ pub fn mock_instance_with_options( }; let options = InstanceOptions { gas_limit: options.gas_limit, + memory_limit: DEFAULT_MEMORY_LIMIT, print_debug: options.print_debug, }; Instance::from_code(wasm, deps, options).unwrap() @@ -140,6 +142,7 @@ 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, } } diff --git a/packages/vm/src/wasm_backend/gas.rs b/packages/vm/src/wasm_backend/gas.rs index 54f14b0789..629bb8d6c3 100644 --- a/packages/vm/src/wasm_backend/gas.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -75,11 +75,11 @@ mod test { type MQ = MockQuerier; const GAS_LIMIT: u64 = 5_000_000; const MAX_GAS_LIMIT: u64 = u64::MAX / 2; - const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB fn instantiate(code: &[u8]) -> (Env, Box) { let mut env = Env::new(GAS_LIMIT); - let module = compile(code, MEMORY_LIMIT).unwrap(); + let module = compile(code, TESTING_MEMORY_LIMIT).unwrap(); let import_obj = imports! { "env" => {}, }; let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); From 8821fe90f3f651e1873569166b8ee79155890529 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 29 Oct 2020 20:09:53 +0100 Subject: [PATCH 058/110] Fix linting issues --- packages/vm/src/context.rs | 3 +-- packages/vm/src/instance.rs | 4 ++-- packages/vm/src/wasm_backend/limiting_tunables.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 55f7fc43d7..c7bb965fbe 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -188,8 +188,7 @@ impl Env { .memories() .map(|pair| pair.1.clone()) .collect(); - let memory = memories.pop().unwrap(); - memory + memories.pop().unwrap() }) } } diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 50221d11a6..18e79742e6 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -151,10 +151,10 @@ where // Ownership of both input and output pointer is not transferred to the host. env_imports.insert( "debug", - Function::new_with_env(store, &i32_to_void, env.clone(), move |mut env, args| { + Function::new_with_env(store, &i32_to_void, env.clone(), move |env, args| { let message_ptr = args[0].unwrap_i32() as u32; if print_debug { - print_debug_message(&mut env, message_ptr)?; + print_debug_message(&env, message_ptr)?; } Ok(vec![]) }), diff --git a/packages/vm/src/wasm_backend/limiting_tunables.rs b/packages/vm/src/wasm_backend/limiting_tunables.rs index 44925f6ca1..58cfdb110b 100644 --- a/packages/vm/src/wasm_backend/limiting_tunables.rs +++ b/packages/vm/src/wasm_backend/limiting_tunables.rs @@ -30,7 +30,7 @@ impl LimitingTunables { /// 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.clone(); + let mut adjusted = *requested; if requested.maximum.is_none() { adjusted.maximum = Some(self.limit); } From 88ce88527041b4ac99681da2ea73a27784c34662 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 11 Nov 2020 15:25:16 +0100 Subject: [PATCH 059/110] Add testing script --- devtools/reborn_testing.sh | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 devtools/reborn_testing.sh diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh new file mode 100755 index 0000000000..e22fb494c4 --- /dev/null +++ b/devtools/reborn_testing.sh @@ -0,0 +1,46 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck > /dev/null && shellcheck "$0" + +# Temporary incomplete testing command for development +(cd packages/vm \ + && cargo check --tests \ + && cargo check --features iterator --tests \ + && cargo test --features iterator checksum:: \ + && cargo test --features iterator conversion:: \ + && cargo test --features iterator compatibility \ + && cargo test --features iterator errors:: \ + && cargo test --features iterator features:: \ + && cargo test --features iterator ffi:: \ + && cargo test --features iterator limiting_tunables:: \ + && cargo test --features iterator memory:: \ + && cargo test --features iterator modules:: \ + && cargo test --features iterator testing:: \ + && cargo test --features iterator init_cached_contract \ + && cargo test --features iterator load_wasm_errors_for_non_existent_id \ + && cargo test --features iterator load_wasm_from_disk_works \ + && cargo test --features iterator load_wasm_from_disk_works_in_subfolder \ + && cargo test --features iterator get_instance_finds_cached_module \ + && cargo test --features iterator load_wasm_errors_for_corrupted_wasm \ + && cargo test --features iterator get_instance_finds_cached_instance \ + && cargo test --features iterator load_wasm_works \ + && cargo test --features iterator save_wasm_rejects_invalid_contract \ + && cargo test --features iterator save_wasm_to_disk_fails_on_non_existent_dir \ + && cargo test --features iterator save_wasm_to_disk_works_for_same_data_multiple_times \ + && cargo test --features iterator load_wasm_works_across_multiple_cache_instances \ + && cargo test --features iterator save_wasm_works \ + && cargo test --features iterator run_cached_contract \ + && cargo test --features iterator use_multiple_cached_instances_of_same_contract \ + && cargo test --features iterator save_wasm_allows_saving_multiple_times \ + && cargo test --features iterator call_func_works \ + && cargo test --features iterator required_features_works_for_many_exports \ + && cargo test --features iterator get_memory_size_works \ + && cargo test --features iterator required_features_works \ + && cargo test --features iterator read_memory_errors_when_when_length_is_too_long \ + && cargo test --features iterator with_storage_safe_for_panic \ + && cargo test --features iterator with_querier_works_readonly \ + && cargo test --features iterator with_querier_allows_updating_balances \ + && cargo test --features iterator set_storage_readonly_works \ + && cargo test --features iterator with_storage_works \ + && cargo test --features iterator write_and_read_memory_works \ + && cargo clippy --features iterator -- -D warnings) From 804b2ae5f9a8a34906d918065455750cb45bef80 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 11 Nov 2020 15:39:00 +0100 Subject: [PATCH 060/110] upgrade Wasmer to 1.0.0-alpha5 --- Cargo.lock | 163 ++++++++++++++++++++--------------------- packages/vm/Cargo.toml | 12 +-- 2 files changed, 85 insertions(+), 90 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a6e59f52f..92603f8fd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.21.1", + "object", "rustc-demangle", ] @@ -110,6 +110,12 @@ dependencies = [ "cc", ] +[[package]] +name = "const_fn" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" + [[package]] name = "cosmwasm-schema" version = "0.11.2" @@ -170,18 +176,18 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" +checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" +checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" dependencies = [ "byteorder", "cranelift-bforest", @@ -191,7 +197,6 @@ dependencies = [ "gimli 0.21.0", "log", "regalloc", - "serde", "smallvec", "target-lexicon", "thiserror", @@ -199,9 +204,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" +checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -209,24 +214,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" +checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" [[package]] name = "cranelift-entity" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" +checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" +checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" dependencies = [ "cranelift-codegen", "log", @@ -244,49 +249,49 @@ dependencies = [ ] [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crossbeam-channel" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ - "crossbeam-epoch", + "cfg-if 1.0.0", "crossbeam-utils", - "maybe-uninit", ] [[package]] -name = "crossbeam-epoch" -version = "0.8.2" +name = "crossbeam-deque" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ - "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "crossbeam-epoch", "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", ] [[package]] -name = "crossbeam-queue" -version = "0.2.1" +name = "crossbeam-epoch" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" +checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" dependencies = [ "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "lazy_static", ] @@ -536,12 +541,6 @@ dependencies = [ "libc", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memmap" version = "0.7.0" @@ -554,11 +553,11 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.5.3" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" dependencies = [ - "rustc_version", + "autocfg", ] [[package]] @@ -608,20 +607,14 @@ dependencies = [ [[package]] name = "object" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" dependencies = [ "crc32fast", "indexmap", ] -[[package]] -name = "object" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -736,10 +729,11 @@ dependencies = [ [[package]] name = "rayon" -version = "1.3.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ + "autocfg", "crossbeam-deque", "either", "rayon-core", @@ -747,12 +741,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ + "crossbeam-channel", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils", "lazy_static", "num_cpus", @@ -766,9 +760,9 @@ checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" [[package]] name = "regalloc" -version = "0.0.26" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" +checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" dependencies = [ "log", "rustc-hash", @@ -971,9 +965,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" @@ -1100,8 +1094,8 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1121,8 +1115,8 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ "enumset", "raw-cpuid", @@ -1138,8 +1132,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1147,6 +1141,7 @@ dependencies = [ "more-asserts", "rayon", "serde", + "smallvec", "tracing", "wasmer-compiler", "wasmer-types", @@ -1155,8 +1150,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ "byteorder", "dynasm", @@ -1173,8 +1168,8 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ "backtrace", "bincode", @@ -1192,8 +1187,8 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1209,8 +1204,8 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1229,10 +1224,10 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ - "object 0.19.0", + "object", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1240,8 +1235,8 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ "cranelift-entity", "serde", @@ -1249,8 +1244,8 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha4" -source = "git+https://github.com/wasmerio/wasmer?branch=master#69e0529f44a48515859f1c1a8881664a64c2183f" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" dependencies = [ "backtrace", "cc", @@ -1268,9 +1263,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.57.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" [[package]] name = "wast" diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index d2e4ae33a9..4854fa5aa4 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -34,12 +34,12 @@ serde_json = "1.0" serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", branch = "master" } -wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", branch = "master" } -wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", branch = "master" } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", branch = "master" } -wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", branch = "master" } -wasmer-types = { git = "https://github.com/wasmerio/wasmer", branch = "master" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } +wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } +wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } +wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } +wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api" } From 7dcf3c3e10276abce142139998f0886e8e1c363e Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 24 Nov 2020 15:43:18 +0100 Subject: [PATCH 061/110] Update Wasmer to 92ee6974 --- Cargo.lock | 20 ++++++++++---------- packages/vm/Cargo.toml | 12 ++++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3978d7b0c..fc71388f32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1072,7 +1072,7 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasmer" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1093,7 +1093,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "enumset", "raw-cpuid", @@ -1110,7 +1110,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "byteorder", "dynasm", @@ -1146,7 +1146,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "backtrace", "bincode", @@ -1165,7 +1165,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1182,7 +1182,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1202,7 +1202,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "object", "thiserror", @@ -1213,7 +1213,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "cranelift-entity", "serde", @@ -1222,7 +1222,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-alpha5#90fe6c3aefc488632521600bba5f5ed60577f695" +source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" dependencies = [ "backtrace", "cc", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index a54a26e81b..46977eec9e 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -35,12 +35,12 @@ serde_json = "1.0" serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } -wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } -wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } -wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } -wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-alpha5" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } +wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } +wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } +wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } +wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api" } From 1cea103fa46c8785f3f9dba49c1db20ca8362298 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 24 Nov 2020 16:33:06 +0100 Subject: [PATCH 062/110] Make Env immutable --- packages/vm/src/context.rs | 120 +++++++------- packages/vm/src/imports.rs | 240 ++++++++++++++-------------- packages/vm/src/instance.rs | 19 ++- packages/vm/src/wasm_backend/gas.rs | 32 ++-- 4 files changed, 196 insertions(+), 215 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 583a533e66..c9a8ea5335 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -81,7 +81,7 @@ impl Env { } pub fn with_context_data_mut( - &mut self, + &self, callback: Callback, ) -> CallbackReturn where @@ -101,10 +101,7 @@ impl Env { callback(context_data) } - pub fn with_gas_state_mut( - &mut self, - callback: Callback, - ) -> CallbackReturn + pub fn with_gas_state_mut(&self, callback: Callback) -> CallbackReturn where Callback: FnOnce(&mut GasState) -> CallbackReturn, { @@ -119,7 +116,7 @@ impl Env { } pub fn with_func_from_context( - &mut self, + &self, name: &str, callback: Callback, ) -> VmResult @@ -137,7 +134,7 @@ impl Env { }) } - pub fn with_storage_from_context(&mut self, func: F) -> VmResult + pub fn with_storage_from_context(&self, func: F) -> VmResult where F: FnOnce(&mut S) -> VmResult, { @@ -147,7 +144,7 @@ impl Env { }) } - pub fn with_querier_from_context(&mut self, func: F) -> VmResult + pub fn with_querier_from_context(&self, func: F) -> VmResult where F: FnOnce(&mut Q) -> VmResult, { @@ -158,7 +155,7 @@ impl Env { } /// Creates a back reference from a contact to its partent instance - pub fn set_wasmer_instance(&mut self, wasmer_instance: Option>) { + pub fn set_wasmer_instance(&self, wasmer_instance: Option>) { self.with_context_data_mut(|context_data| { context_data.wasmer_instance = wasmer_instance; }); @@ -169,7 +166,7 @@ impl Env { self.with_context_data(|context_data| context_data.storage_readonly) } - pub fn set_storage_readonly(&mut self, new_value: bool) { + pub fn set_storage_readonly(&self, new_value: bool) { self.with_context_data_mut(|context_data| { context_data.storage_readonly = new_value; }) @@ -216,7 +213,7 @@ impl ContextData { /// 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( - env: &mut Env, + env: &Env, ) -> (Option, Option) { env.with_context_data_mut(|context_data| { (context_data.storage.take(), context_data.querier.take()) @@ -225,21 +222,14 @@ pub(crate) fn move_out_of_context( /// Moves owned instances of storage and querier into the env. /// Should be followed by exactly one call to move_out_of_context when the instance is finished. -pub(crate) fn move_into_context( - env: &mut Env, - storage: S, - querier: Q, -) { +pub(crate) fn move_into_context(env: &Env, 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: &mut Env, - info: GasInfo, -) -> VmResult<()> { +pub fn process_gas_info(env: &Env, info: GasInfo) -> VmResult<()> { decrease_gas_left(env, info.cost)?; account_for_externally_used_gas(env, info.externally_used)?; Ok(()) @@ -249,20 +239,20 @@ pub fn process_gas_info( /// 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: &mut Env, + env: &Env, amount: u64, ) -> VmResult<()> { account_for_externally_used_gas_impl(env, amount) } fn account_for_externally_used_gas_impl( - env: &mut Env, + env: &Env, used_gas: u64, ) -> VmResult<()> { // WFT?! - let mut env1 = env.clone(); + let env1 = env.clone(); let env2 = env.clone(); - let mut env3 = env.clone(); + let env3 = env.clone(); env1.with_context_data_mut(|context_data| { let gas_state = &mut context_data.gas_state; @@ -274,7 +264,7 @@ fn account_for_externally_used_gas_impl( // 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(&mut env3, new_limit); + set_gas_left(&env3, new_limit); if gas_state.externally_used_gas + wasmer_used_gas > gas_state.gas_limit { Err(VmError::GasDepletion) @@ -315,7 +305,7 @@ mod test { const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB fn make_instance() -> (Env, Box) { - let mut env = Env::new(GAS_LIMIT); + let env = Env::new(GAS_LIMIT); let module = compile(&CONTRACT, MEMORY_LIMIT).unwrap(); // we need stubs for all required imports @@ -340,7 +330,7 @@ mod test { (env, instance) } - fn leave_default_data(env: &mut Env) { + fn leave_default_data(env: &Env) { // create some mock data let mut storage = MockStorage::new(); storage @@ -354,16 +344,16 @@ mod test { #[test] fn leave_and_take_context_data() { - let (mut env, _) = make_instance(); + let (env, _) = make_instance(); // empty data on start - let (inits, initq) = move_out_of_context::(&mut env); + let (inits, initq) = move_out_of_context::(&env); assert!(inits.is_none()); assert!(initq.is_none()); // store it on the instance - leave_default_data(&mut env); - let (s, q) = move_out_of_context::(&mut env); + leave_default_data(&env); + let (s, q) = move_out_of_context::(&env); assert!(s.is_some()); assert!(q.is_some()); assert_eq!( @@ -372,26 +362,26 @@ mod test { ); // now is empty again - let (ends, endq) = move_out_of_context::(&mut env); + let (ends, endq) = move_out_of_context::(&env); assert!(ends.is_none()); assert!(endq.is_none()); } #[test] fn gas_tracking_works_correctly() { - let (mut env, _) = make_instance(); + let (env, _) = make_instance(); let gas_limit = 100; - set_gas_left(&mut env, gas_limit); + 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::(&mut env, 70).unwrap(); - account_for_externally_used_gas::(&mut env, 4).unwrap(); - account_for_externally_used_gas::(&mut env, 6).unwrap(); - account_for_externally_used_gas::(&mut env, 20).unwrap(); + 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::(&mut env, 1).unwrap_err() { + match account_for_externally_used_gas::(&env, 1).unwrap_err() { VmError::GasDepletion => {} err => panic!("unexpected error: {:?}", err), } @@ -399,23 +389,23 @@ mod test { #[test] fn gas_tracking_works_correctly_with_gas_consumption_in_wasmer() { - let (mut env, _) = make_instance(); + let (env, _) = make_instance(); let gas_limit = 100; - set_gas_left(&mut env, gas_limit); + 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::(&mut env, 50).unwrap(); - account_for_externally_used_gas::(&mut env, 4).unwrap(); + 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(&mut env, 20).unwrap(); + decrease_gas_left(&env, 20).unwrap(); - account_for_externally_used_gas::(&mut env, 6).unwrap(); - account_for_externally_used_gas::(&mut 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::(&mut env, 1).unwrap_err() { + match account_for_externally_used_gas::(&env, 1).unwrap_err() { VmError::GasDepletion => {} err => panic!("unexpected error: {:?}", err), } @@ -423,16 +413,16 @@ mod test { #[test] fn is_storage_readonly_defaults_to_true() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); assert_eq!(env.is_storage_readonly(), true); } #[test] fn set_storage_readonly_can_change_flag() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); // change env.set_storage_readonly(false); @@ -449,8 +439,8 @@ mod test { #[test] fn with_func_from_context_works() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); let ptr = env .with_func_from_context::<_, _>("allocate", |alloc_func| { @@ -464,8 +454,8 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_instance() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); // Clear context's wasmer_instance env.set_wasmer_instance(None); @@ -481,8 +471,8 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_function() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); let res = env.with_func_from_context::<_, ()>("doesnt_exist", |_func| { panic!("unexpected callback call"); @@ -500,8 +490,8 @@ mod test { #[test] fn with_storage_from_context_set_get() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); let val = env .with_storage_from_context::<_, _>(|store| { @@ -533,8 +523,8 @@ mod test { #[test] #[should_panic(expected = "A panic occurred in the callback.")] fn with_storage_from_context_handles_panics() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); env.with_storage_from_context::<_, ()>(|_store| { panic!("A panic occurred in the callback.") @@ -544,8 +534,8 @@ mod test { #[test] fn with_querier_from_context_works() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); let res = env .with_querier_from_context::<_, _>(|querier| { @@ -567,8 +557,8 @@ mod test { #[test] #[should_panic(expected = "A panic occurred in the callback.")] fn with_querier_from_context_handles_panics() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); env.with_querier_from_context::<_, ()>(|_querier| { panic!("A panic occurred in the callback.") diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 05f976d7e6..897532e267 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -84,7 +84,7 @@ pub fn native_db_next( // /// Reads a storage entry from the VM's storage into Wasm memory -fn do_read(env: &mut Env, key_ptr: u32) -> VmResult { +fn do_read(env: &Env, key_ptr: u32) -> VmResult { let key = read_region(&env.memory(), key_ptr, MAX_LENGTH_DB_KEY)?; let (result, gas_info) = env.with_storage_from_context::<_, _>(|store| Ok(store.get(&key)))?; @@ -99,11 +99,7 @@ fn do_read(env: &mut Env, key_ptr: u32) -> VmResul } /// Writes a storage entry from Wasm memory into the VM's storage -fn do_write( - env: &mut Env, - key_ptr: u32, - value_ptr: u32, -) -> VmResult<()> { +fn do_write(env: &Env, key_ptr: u32, value_ptr: u32) -> VmResult<()> { if env.is_storage_readonly() { return Err(VmError::write_access_denied()); } @@ -119,7 +115,7 @@ fn do_write( Ok(()) } -fn do_remove(env: &mut Env, key_ptr: u32) -> VmResult<()> { +fn do_remove(env: &Env, key_ptr: u32) -> VmResult<()> { if env.is_storage_readonly() { return Err(VmError::write_access_denied()); } @@ -136,7 +132,7 @@ fn do_remove(env: &mut Env, key_ptr: u32) -> VmRes pub fn do_canonicalize_address( api: A, - env: &mut Env, + env: &Env, source_ptr: u32, destination_ptr: u32, ) -> VmResult { @@ -167,7 +163,7 @@ pub fn do_canonicalize_address( pub fn do_humanize_address( api: A, - env: &mut Env, + env: &Env, source_ptr: u32, destination_ptr: u32, ) -> VmResult { @@ -204,7 +200,7 @@ pub fn print_debug_message( } /// Creates a Region in the contract, writes the given data to it and returns the memory location -fn write_to_contract(env: &mut Env, input: &[u8]) -> VmResult { +fn write_to_contract(env: &Env, input: &[u8]) -> VmResult { let target_ptr = env.with_func_from_context::<_, u32>("allocate", |allocate| { let out_size = to_u32(input.len())?; let result = allocate.call(&[out_size.into()])?; @@ -218,7 +214,7 @@ fn write_to_contract(env: &mut Env, input: &[u8]) Ok(target_ptr) } -fn do_query_chain(env: &mut Env, request_ptr: u32) -> VmResult { +fn do_query_chain(env: &Env, request_ptr: u32) -> VmResult { let request = read_region(&env.memory(), request_ptr, MAX_LENGTH_QUERY_CHAIN_REQUEST)?; let gas_remaining = get_gas_left(env); @@ -232,7 +228,7 @@ fn do_query_chain(env: &mut Env, request_ptr: u32) #[cfg(feature = "iterator")] fn do_scan( - env: &mut Env, + env: &Env, start_ptr: u32, end_ptr: u32, order: i32, @@ -252,7 +248,7 @@ fn do_scan( } #[cfg(feature = "iterator")] -fn do_next(env: &mut Env, iterator_id: u32) -> VmResult { +fn do_next(env: &Env, iterator_id: u32) -> VmResult { let (result, gas_info) = env.with_storage_from_context::<_, _>(|store| Ok(store.next(iterator_id)))?; process_gas_info::(env, gas_info)?; @@ -307,7 +303,7 @@ mod test { const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB fn make_instance() -> (Env, Box) { - let mut env = Env::new(GAS_LIMIT); + let env = Env::new(GAS_LIMIT); let module = compile(&CONTRACT, TESTING_MEMORY_LIMIT).unwrap(); // we need stubs for all required imports @@ -333,7 +329,7 @@ mod test { (env, instance) } - fn leave_default_data(env: &mut Env) { + fn leave_default_data(env: &Env) { // create some mock data let mut storage = MockStorage::new(); storage.set(KEY1, VALUE1).0.expect("error setting"); @@ -375,11 +371,11 @@ mod test { #[test] fn do_read_works() { - let (mut env, mut instance) = make_instance(); - leave_default_data(&mut env); + let (env, mut instance) = make_instance(); + leave_default_data(&env); let key_ptr = write_data(&mut instance, KEY1); - let result = do_read::(&mut env, key_ptr); + let result = do_read::(&env, key_ptr); let value_ptr = result.unwrap(); assert!(value_ptr > 0); assert_eq!(force_read(&env, value_ptr as u32), VALUE1); @@ -387,21 +383,21 @@ mod test { #[test] fn do_read_works_for_non_existent_key() { - let (mut env, mut instance) = make_instance(); - leave_default_data(&mut env); + let (env, mut instance) = make_instance(); + leave_default_data(&env); let key_ptr = write_data(&mut instance, b"I do not exist in storage"); - let result = do_read::(&mut env, key_ptr); + let result = do_read::(&env, key_ptr); assert_eq!(result.unwrap(), 0); } #[test] fn do_read_fails_for_large_key() { - let (mut env, mut instance) = make_instance(); - leave_default_data(&mut env); + let (env, mut instance) = make_instance(); + leave_default_data(&env); let key_ptr = write_data(&mut instance, &vec![7u8; 300 * 1024]); - let result = do_read::(&mut env, key_ptr); + let result = do_read::(&env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionLengthTooBig { length, .. }, @@ -412,14 +408,14 @@ mod test { #[test] fn do_write_works() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, b"new storage key"); let value_ptr = write_data(&mut instance, b"new value"); - leave_default_data(&mut env); + leave_default_data(&env); - do_write::(&mut env, key_ptr, value_ptr).unwrap(); + do_write::(&env, key_ptr, value_ptr).unwrap(); let val = env .with_storage_from_context::<_, _>(|store| { @@ -434,14 +430,14 @@ mod test { #[test] fn do_write_can_override() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, KEY1); let value_ptr = write_data(&mut instance, VALUE2); - leave_default_data(&mut env); + leave_default_data(&env); - do_write::(&mut env, key_ptr, value_ptr).unwrap(); + do_write::(&env, key_ptr, value_ptr).unwrap(); let val = env .with_storage_from_context::<_, _>(|store| { @@ -453,14 +449,14 @@ mod test { #[test] fn do_write_works_for_empty_value() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, b"new storage key"); let value_ptr = write_data(&mut instance, b""); - leave_default_data(&mut env); + leave_default_data(&env); - do_write::(&mut env, key_ptr, value_ptr).unwrap(); + do_write::(&env, key_ptr, value_ptr).unwrap(); let val = env .with_storage_from_context::<_, _>(|store| { @@ -475,14 +471,14 @@ mod test { #[test] fn do_write_fails_for_large_key() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, &vec![4u8; 300 * 1024]); let value_ptr = write_data(&mut instance, b"new value"); - leave_default_data(&mut env); + leave_default_data(&env); - let result = do_write::(&mut env, key_ptr, value_ptr); + let result = do_write::(&env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -499,14 +495,14 @@ mod test { #[test] fn do_write_fails_for_large_value() { - let (mut env, mut instance) = make_instance(); + let (env, mut 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]); - leave_default_data(&mut env); + leave_default_data(&env); - let result = do_write::(&mut env, key_ptr, value_ptr); + let result = do_write::(&env, key_ptr, value_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -523,15 +519,15 @@ mod test { #[test] fn do_write_is_prohibited_in_readonly_contexts() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, b"new storage key"); let value_ptr = write_data(&mut instance, b"new value"); - leave_default_data(&mut env); + leave_default_data(&env); env.set_storage_readonly(true); - let result = do_write::(&mut env, key_ptr, value_ptr); + let result = do_write::(&env, key_ptr, value_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -540,14 +536,14 @@ mod test { #[test] fn do_remove_works() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let existing_key = KEY1; let key_ptr = write_data(&mut instance, existing_key); - leave_default_data(&mut env); + leave_default_data(&env); - do_remove::(&mut env, key_ptr).unwrap(); + do_remove::(&env, key_ptr).unwrap(); let value = env .with_storage_from_context::<_, _>(|store| { @@ -559,15 +555,15 @@ mod test { #[test] fn do_remove_works_for_non_existent_key() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let non_existent_key = b"I do not exist"; let key_ptr = write_data(&mut instance, non_existent_key); - leave_default_data(&mut env); + leave_default_data(&env); // Note: right now we cannot differnetiate between an existent and a non-existent key - do_remove::(&mut env, key_ptr).unwrap(); + do_remove::(&env, key_ptr).unwrap(); let value = env .with_storage_from_context::<_, _>(|store| { @@ -579,13 +575,13 @@ mod test { #[test] fn do_remove_fails_for_large_key() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, &vec![26u8; 300 * 1024]); - leave_default_data(&mut env); + leave_default_data(&env); - let result = do_remove::(&mut env, key_ptr); + let result = do_remove::(&env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -602,14 +598,14 @@ mod test { #[test] fn do_remove_is_prohibited_in_readonly_contexts() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let key_ptr = write_data(&mut instance, b"a storage key"); - leave_default_data(&mut env); + leave_default_data(&env); env.set_storage_readonly(true); - let result = do_remove::(&mut env, key_ptr); + let result = do_remove::(&env, key_ptr); match result.unwrap_err() { VmError::WriteAccessDenied { .. } => {} e => panic!("Unexpected error: {:?}", e), @@ -618,46 +614,43 @@ mod test { #[test] fn do_canonicalize_address_works() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let api = MockApi::default(); let source_ptr = write_data(&mut instance, b"foo"); let dest_ptr = create_empty(&mut instance, api.canonical_length as u32); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::default(); - do_canonicalize_address::(api, &mut env, source_ptr, dest_ptr).unwrap(); + 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 env, 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 dest_ptr = create_empty(&mut instance, 8); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::default(); - let res = - do_canonicalize_address::(api, &mut env, 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(&env, res)).unwrap(); assert_eq!(err, "Input is not valid UTF-8"); - let res = - do_canonicalize_address::(api, &mut env, 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(&env, res)).unwrap(); assert_eq!(err, "Input is empty"); - let res = - do_canonicalize_address::(api, &mut env, 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(&env, res)).unwrap(); assert_eq!(err, "Invalid input: human address too long"); @@ -665,15 +658,15 @@ mod test { #[test] fn do_canonicalize_address_fails_for_broken_backend() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, b"foo"); let dest_ptr = create_empty(&mut instance, 7); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::new_failing("Temporarily unavailable"); - let result = do_canonicalize_address::(api, &mut env, 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, .. }, @@ -686,15 +679,15 @@ mod test { #[test] fn do_canonicalize_address_fails_for_large_inputs() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, &vec![61; 100]); let dest_ptr = create_empty(&mut instance, 8); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::default(); - let result = do_canonicalize_address::(api, &mut env, source_ptr, dest_ptr); + let result = do_canonicalize_address::(api, &env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -711,15 +704,15 @@ mod test { #[test] fn do_canonicalize_address_fails_for_small_destination_region() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, b"foo"); let dest_ptr = create_empty(&mut instance, 7); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::default(); - let result = do_canonicalize_address::(api, &mut env, 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, .. }, @@ -733,33 +726,32 @@ mod test { #[test] fn do_humanize_address_works() { - let (mut env, 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 dest_ptr = create_empty(&mut instance, 50); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::default(); - let error_ptr = - do_humanize_address::(api, &mut env, source_ptr, dest_ptr).unwrap(); + let error_ptr = do_humanize_address::(api, &env, source_ptr, dest_ptr).unwrap(); assert_eq!(error_ptr, 0); assert_eq!(force_read(&env, dest_ptr), source_data); } #[test] fn do_humanize_address_reports_invalid_input_back_to_contract() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, b"foo"); // too short let dest_ptr = create_empty(&mut instance, 50); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::default(); - let res = do_humanize_address::(api, &mut env, 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(&env, res)).unwrap(); assert_eq!(err, "Invalid input: canonical address length not correct"); @@ -767,15 +759,15 @@ mod test { #[test] fn do_humanize_address_fails_for_broken_backend() { - let (mut env, 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 dest_ptr = create_empty(&mut instance, 50); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::new_failing("Temporarily unavailable"); - let result = do_humanize_address::(api, &mut env, 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, .. }, @@ -786,15 +778,15 @@ mod test { #[test] fn do_humanize_address_fails_for_input_too_long() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let source_ptr = write_data(&mut instance, &vec![61; 33]); let dest_ptr = create_empty(&mut instance, 50); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::default(); - let result = do_humanize_address::(api, &mut env, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: @@ -811,17 +803,17 @@ mod test { #[test] fn do_humanize_address_fails_for_destination_region_too_small() { - let (mut env, 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 dest_ptr = create_empty(&mut instance, 2); - leave_default_data(&mut env); + leave_default_data(&env); let api = MockApi::default(); - let result = do_humanize_address::(api, &mut env, source_ptr, dest_ptr); + let result = do_humanize_address::(api, &env, source_ptr, dest_ptr); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::RegionTooSmall { size, required, .. }, @@ -835,7 +827,7 @@ mod test { #[test] fn do_query_chain_works() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let request: QueryRequest = QueryRequest::Bank(BankQuery::AllBalances { address: HumanAddr::from(INIT_ADDR), @@ -843,9 +835,9 @@ mod test { let request_data = cosmwasm_std::to_vec(&request).unwrap(); let request_ptr = write_data(&mut instance, &request_data); - leave_default_data(&mut env); + leave_default_data(&env); - let response_ptr = do_query_chain::(&mut env, request_ptr).unwrap(); + let response_ptr = do_query_chain::(&env, request_ptr).unwrap(); let response = force_read(&env, response_ptr); let query_result: cosmwasm_std::QuerierResult = @@ -858,14 +850,14 @@ mod test { #[test] fn do_query_chain_fails_for_broken_request() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let request = b"Not valid JSON for sure"; let request_ptr = write_data(&mut instance, request); - leave_default_data(&mut env); + leave_default_data(&env); - let response_ptr = do_query_chain::(&mut env, request_ptr).unwrap(); + let response_ptr = do_query_chain::(&env, request_ptr).unwrap(); let response = force_read(&env, response_ptr); let query_result: cosmwasm_std::QuerierResult = @@ -881,7 +873,7 @@ mod test { #[test] fn do_query_chain_fails_for_missing_contract() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let request: QueryRequest = QueryRequest::Wasm(WasmQuery::Smart { contract_addr: HumanAddr::from("non-existent"), @@ -890,9 +882,9 @@ mod test { let request_data = cosmwasm_std::to_vec(&request).unwrap(); let request_ptr = write_data(&mut instance, &request_data); - leave_default_data(&mut env); + leave_default_data(&env); - let response_ptr = do_query_chain::(&mut env, request_ptr).unwrap(); + let response_ptr = do_query_chain::(&env, request_ptr).unwrap(); let response = force_read(&env, response_ptr); let query_result: cosmwasm_std::QuerierResult = @@ -909,11 +901,11 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_works() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); // set up iterator over all space - let id = do_scan::(&mut env, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan::(&env, 0, 0, Order::Ascending.into()).unwrap(); assert_eq!(1, id); let item = env @@ -935,11 +927,11 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_descending_works() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); // set up iterator over all space - let id = do_scan::(&mut env, 0, 0, Order::Descending.into()).unwrap(); + let id = do_scan::(&env, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(1, id); let item = env @@ -961,14 +953,14 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_bound_works() { - let (mut env, mut instance) = make_instance(); + let (env, mut instance) = make_instance(); let start = write_data(&mut instance, b"anna"); let end = write_data(&mut instance, b"bert"); - leave_default_data(&mut env); + leave_default_data(&env); - let id = do_scan::(&mut env, start, end, Order::Ascending.into()).unwrap(); + let id = do_scan::(&env, start, end, Order::Ascending.into()).unwrap(); let item = env .with_storage_from_context::<_, _>(|store| Ok(store.next(id))) @@ -984,12 +976,12 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_multiple_iterators() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); // unbounded, ascending and descending - let id1 = do_scan::(&mut env, 0, 0, Order::Ascending.into()).unwrap(); - let id2 = do_scan::(&mut env, 0, 0, Order::Descending.into()).unwrap(); + let id1 = do_scan::(&env, 0, 0, Order::Ascending.into()).unwrap(); + let id2 = do_scan::(&env, 0, 0, Order::Descending.into()).unwrap(); assert_eq!(id1, 1); assert_eq!(id2, 2); @@ -1027,11 +1019,11 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_errors_for_invalid_order_value() { - let (mut env, _) = make_instance(); - leave_default_data(&mut env); + let (env, _) = make_instance(); + leave_default_data(&env); // set up iterator over all space - let result = do_scan::(&mut env, 0, 0, 42); + let result = do_scan::(&env, 0, 0, 42); match result.unwrap_err() { VmError::CommunicationErr { source: CommunicationError::InvalidOrder { .. }, @@ -1043,28 +1035,28 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_next_works() { - let (mut env, _) = make_instance(); + let (env, _) = make_instance(); - leave_default_data(&mut env); + leave_default_data(&env); - let id = do_scan::(&mut env, 0, 0, Order::Ascending.into()).unwrap(); + let id = do_scan::(&env, 0, 0, Order::Ascending.into()).unwrap(); // Entry 1 - let kv_region_ptr = do_next::(&mut env, id).unwrap(); + let kv_region_ptr = do_next::(&env, id).unwrap(); assert_eq!( force_read(&env, kv_region_ptr), [VALUE1, KEY1, b"\0\0\0\x03"].concat() ); // Entry 2 - let kv_region_ptr = do_next::(&mut env, id).unwrap(); + let kv_region_ptr = do_next::(&env, id).unwrap(); assert_eq!( force_read(&env, kv_region_ptr), [VALUE2, KEY2, b"\0\0\0\x04"].concat() ); // End - let kv_region_ptr = do_next::(&mut env, id).unwrap(); + let kv_region_ptr = do_next::(&env, id).unwrap(); assert_eq!(force_read(&env, kv_region_ptr), b"\0\0\0\0"); // API makes no guarantees for value_ptr in this case } @@ -1072,12 +1064,12 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_next_fails_for_non_existent_id() { - let (mut env, _) = make_instance(); + let (env, _) = make_instance(); - leave_default_data(&mut env); + leave_default_data(&env); let non_existent_id = 42u32; - let result = do_next::(&mut env, non_existent_id); + let result = do_next::(&env, non_existent_id); match result.unwrap_err() { VmError::BackendErr { source: BackendError::IteratorDoesNotExist { id, .. }, diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index f8d68147ad..61511f6c26 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -82,7 +82,7 @@ where let store = module.store(); - let mut env = Env::new(gas_limit); + let env = Env::new(gas_limit); let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); let i32i32_to_i32 = FunctionType::new(vec![Type::I32, Type::I32], vec![Type::I32]); @@ -121,11 +121,11 @@ where // 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 |mut env, args| { + Function::new_with_env(store, &i32i32_to_i32, env.clone(), move |env, args| { let source_ptr = args[0].unwrap_i32() as u32; let destination_ptr = args[1].unwrap_i32() as u32; let ptr = - do_canonicalize_address::(api, &mut env, source_ptr, destination_ptr)?; + do_canonicalize_address::(api, &env, source_ptr, destination_ptr)?; Ok(vec![ptr.into()]) }), ); @@ -136,11 +136,10 @@ where // 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 |mut env, args| { + Function::new_with_env(store, &i32i32_to_i32, env.clone(), move |env, args| { let source_ptr = args[0].unwrap_i32() as u32; let destination_ptr = args[1].unwrap_i32() as u32; - let ptr = - do_humanize_address::(api, &mut env, source_ptr, destination_ptr)?; + let ptr = do_humanize_address::(api, &env, source_ptr, destination_ptr)?; Ok(vec![ptr.into()]) }), ); @@ -196,14 +195,14 @@ where }, )?); - set_gas_left(&mut env, 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()); env.set_wasmer_instance(Some(instance_ptr)); - move_into_context(&mut env, backend.storage, backend.querier); + move_into_context(&env, backend.storage, backend.querier); let instance = Instance { inner: wasmer_instance, env, @@ -217,8 +216,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(&mut self.env) { + pub fn recycle(self) -> Option> { + if let (Some(storage), Some(querier)) = move_out_of_context(&self.env) { Some(Backend { storage, api: self.api, diff --git a/packages/vm/src/wasm_backend/gas.rs b/packages/vm/src/wasm_backend/gas.rs index 19355e4b8b..e0dbb5f3ad 100644 --- a/packages/vm/src/wasm_backend/gas.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -21,7 +21,7 @@ pub struct InsufficientGasLeft; /// 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: &mut Env, + env: &Env, amount: u64, ) -> Result<(), InsufficientGasLeft> { let remaining = get_gas_left(env); @@ -35,7 +35,7 @@ pub fn decrease_gas_left( } /// Set the amount of gas units that can be used in the context. -pub fn set_gas_left(_env: &mut Env, _amount: u64) {} +pub fn set_gas_left(_env: &Env, _amount: u64) {} /// Get how many more gas units can be used in the context. pub fn get_gas_left(_env: &Env) -> u64 { @@ -77,7 +77,7 @@ mod test { const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB fn instantiate(code: &[u8]) -> (Env, Box) { - let mut env = Env::new(GAS_LIMIT); + let env = Env::new(GAS_LIMIT); let module = compile(code, TESTING_MEMORY_LIMIT).unwrap(); let import_obj = imports! { "env" => {}, }; let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); @@ -91,10 +91,10 @@ mod test { #[test] fn decrease_gas_left_works() { let wasm = wat::parse_str("(module)").unwrap(); - let (mut env, _) = instantiate(&wasm); + let (env, _) = instantiate(&wasm); let before = get_gas_left(&env); - decrease_gas_left(&mut env, 32).unwrap(); + decrease_gas_left(&env, 32).unwrap(); let after = get_gas_left(&env); assert_eq!(after, before - 32); } @@ -102,10 +102,10 @@ mod test { #[test] fn decrease_gas_left_can_consume_all_gas() { let wasm = wat::parse_str("(module)").unwrap(); - let (mut env, _) = instantiate(&wasm); + let (env, _) = instantiate(&wasm); let before = get_gas_left(&env); - decrease_gas_left(&mut env, before).unwrap(); + decrease_gas_left(&env, before).unwrap(); let after = get_gas_left(&env); assert_eq!(after, 0); } @@ -113,10 +113,10 @@ mod test { #[test] fn decrease_gas_left_errors_for_amount_greater_than_remaining() { let wasm = wat::parse_str("(module)").unwrap(); - let (mut env, _) = instantiate(&wasm); + let (env, _) = instantiate(&wasm); let before = get_gas_left(&env); - let result = decrease_gas_left(&mut env, before + 1); + let result = decrease_gas_left(&env, before + 1); match result.unwrap_err() { InsufficientGasLeft => {} } @@ -135,22 +135,22 @@ mod test { #[test] fn set_gas_left_works() { let wasm = wat::parse_str("(module)").unwrap(); - let (mut env, _) = instantiate(&wasm); + let (env, _) = instantiate(&wasm); let limit = 3456789; - set_gas_left(&mut env, limit); + set_gas_left(&env, limit); assert_eq!(get_gas_left(&env), limit); let limit = 1; - set_gas_left(&mut env, limit); + set_gas_left(&env, limit); assert_eq!(get_gas_left(&env), limit); let limit = 0; - set_gas_left(&mut env, limit); + set_gas_left(&env, limit); assert_eq!(get_gas_left(&env), limit); let limit = MAX_GAS_LIMIT; - set_gas_left(&mut env, limit); + set_gas_left(&env, limit); assert_eq!(get_gas_left(&env), limit); } @@ -160,9 +160,9 @@ mod test { )] fn set_gas_left_panic_for_values_too_large() { let wasm = wat::parse_str("(module)").unwrap(); - let (mut env, _) = instantiate(&wasm); + let (env, _) = instantiate(&wasm); let limit = MAX_GAS_LIMIT + 1; - set_gas_left(&mut env, limit); + set_gas_left(&env, limit); } } From dcac4ae0fbeec6c7af20117e96f0ff20de793c6e Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 24 Nov 2020 16:37:19 +0100 Subject: [PATCH 063/110] Upgrade Wasmer to 92ee6974 --- Cargo.lock | 64 +++++++++++++++++--------------------- packages/vm/Cargo.toml | 12 +++---- packages/vm/src/imports.rs | 15 ++++----- 3 files changed, 41 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc71388f32..3ba5df3abc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" dependencies = [ - "gimli 0.22.0", + "gimli", ] [[package]] @@ -176,25 +176,25 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.21.0", + "gimli", "log", "regalloc", "smallvec", @@ -204,9 +204,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -214,24 +214,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -428,21 +428,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" - [[package]] name = "hashbrown" version = "0.8.1" @@ -754,9 +748,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "regalloc" -version = "0.0.30" +version = "0.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" +checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", @@ -1072,7 +1066,7 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasmer" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1093,7 +1087,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "enumset", "raw-cpuid", @@ -1110,11 +1104,11 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "cranelift-codegen", "cranelift-frontend", - "gimli 0.21.0", + "gimli", "more-asserts", "rayon", "serde", @@ -1128,7 +1122,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "byteorder", "dynasm", @@ -1146,7 +1140,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "backtrace", "bincode", @@ -1165,7 +1159,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1182,7 +1176,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1202,7 +1196,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "object", "thiserror", @@ -1213,7 +1207,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "cranelift-entity", "serde", @@ -1222,7 +1216,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=92ee6974#92ee6974b2af8905a41cbb99a5bc19991f8f6685" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "backtrace", "cc", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 46977eec9e..84f6afa02d 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -35,12 +35,12 @@ serde_json = "1.0" serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] } sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } -wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } -wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } -wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } -wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "92ee6974" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } +wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } +wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } +wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } +wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api" } diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 897532e267..05d5b95b46 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -37,25 +37,25 @@ const MAX_LENGTH_DEBUG: usize = 2 * MI; // 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: &mut Env, key_ptr: u32) -> VmResult { +pub fn native_db_read(env: &Env, key_ptr: u32) -> VmResult { let ptr = do_read::(env, key_ptr)?; Ok(ptr) } pub fn native_db_write( - env: &mut Env, + env: &Env, key_ptr: u32, value_ptr: u32, ) -> VmResult<()> { do_write(env, key_ptr, value_ptr) } -pub fn native_db_remove(env: &mut Env, key_ptr: u32) -> VmResult<()> { +pub fn native_db_remove(env: &Env, key_ptr: u32) -> VmResult<()> { do_remove(env, key_ptr) } pub fn native_query_chain( - env: &mut Env, + env: &Env, request_ptr: u32, ) -> VmResult { do_query_chain(env, request_ptr) @@ -63,7 +63,7 @@ pub fn native_query_chain( #[cfg(feature = "iterator")] pub fn native_db_scan( - env: &mut Env, + env: &Env, start_ptr: u32, end_ptr: u32, order: i32, @@ -72,10 +72,7 @@ pub fn native_db_scan( } #[cfg(feature = "iterator")] -pub fn native_db_next( - env: &mut Env, - iterator_id: u32, -) -> VmResult { +pub fn native_db_next(env: &Env, iterator_id: u32) -> VmResult { do_next(env, iterator_id) } From 34fc958969fc1d87711ebb148c617c981c296511 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 26 Nov 2020 23:15:01 +0100 Subject: [PATCH 064/110] Test contracts as part of reborn_testing --- devtools/reborn_testing.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh index e22fb494c4..2b28bb6ef1 100755 --- a/devtools/reborn_testing.sh +++ b/devtools/reborn_testing.sh @@ -44,3 +44,8 @@ command -v shellcheck > /dev/null && shellcheck "$0" && cargo test --features iterator with_storage_works \ && cargo test --features iterator write_and_read_memory_works \ && cargo clippy --features iterator -- -D warnings) + +# Contracts +for contract_dir in contracts/*/; do + (cd "$contract_dir" && cargo wasm && cargo integration-test) || break; +done From 318f7177391f9f619912d875702a93d629b53ea7 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 26 Nov 2020 23:15:19 +0100 Subject: [PATCH 065/110] Update lockfiles to latest Wasmer crates --- contracts/burner/Cargo.lock | 744 +++++++++++++++++++++++----------- contracts/hackatom/Cargo.lock | 744 +++++++++++++++++++++++----------- contracts/queue/Cargo.lock | 744 +++++++++++++++++++++++----------- contracts/reflect/Cargo.lock | 744 +++++++++++++++++++++++----------- contracts/staking/Cargo.lock | 744 +++++++++++++++++++++++----------- 5 files changed, 2550 insertions(+), 1170 deletions(-) diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index baf5270443..cb5c701987 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 0.22.0", + "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.0" @@ -159,10 +146,12 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-compiler", + "wasmer-compiler-singlepass", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-types", ] [[package]] @@ -173,26 +162,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 +190,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 +200,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" @@ -279,22 +282,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 +322,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 +342,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 +358,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 +401,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 +450,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 +479,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 +492,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 +510,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" @@ -481,16 +539,28 @@ dependencies = [ ] [[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-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", ] [[package]] @@ -504,29 +574,26 @@ dependencies = [ ] [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "object" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] -name = "owning_ref" -version = "0.4.1" +name = "object" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" [[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" @@ -535,27 +602,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "pin-project-lite" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +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 +655,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 +738,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 +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" @@ -756,7 +910,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -773,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" @@ -791,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 = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -815,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" @@ -834,137 +1034,213 @@ 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", - "serde", - "serde-bench", - "serde_bytes", - "serde_derive", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "wat", "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" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "cranelift-codegen", - "log", + "enumset", + "raw-cpuid", + "serde", + "serde_bytes", "smallvec", "target-lexicon", + "thiserror", + "wasmer-types", + "wasmer-vm", + "wasmparser", ] [[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-cranelift" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "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-compiler-singlepass" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "wasmer-runtime-core", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ + "object 0.21.1", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" +dependencies = [ + "wast", +] + +[[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" diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index a5b7c238d3..d7c06a734f 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 0.22.0", + "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.0" @@ -156,10 +143,12 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-compiler", + "wasmer-compiler-singlepass", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-types", ] [[package]] @@ -170,26 +159,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 +187,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 +197,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" @@ -276,22 +279,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 +319,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 +339,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 +355,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 +398,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 +461,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 +490,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 +503,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 +521,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" @@ -492,16 +550,28 @@ dependencies = [ ] [[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-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", ] [[package]] @@ -515,29 +585,26 @@ dependencies = [ ] [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "object" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] -name = "owning_ref" -version = "0.4.1" +name = "object" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" [[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" @@ -546,27 +613,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "pin-project-lite" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +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 +666,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 +749,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 +861,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 +921,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -784,10 +938,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 +956,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 = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -826,6 +994,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 +1045,213 @@ 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", - "serde", - "serde-bench", - "serde_bytes", - "serde_derive", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "wat", "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" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "cranelift-codegen", - "log", + "enumset", + "raw-cpuid", + "serde", + "serde_bytes", "smallvec", "target-lexicon", + "thiserror", + "wasmer-types", + "wasmer-vm", + "wasmparser", ] [[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-cranelift" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "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-compiler-singlepass" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "wasmer-runtime-core", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ + "object 0.21.1", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" +dependencies = [ + "wast", +] + +[[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" diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 2bde21cc63..a4b01e1ffe 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 0.22.0", + "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.0" @@ -148,10 +135,12 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-compiler", + "wasmer-compiler-singlepass", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-types", ] [[package]] @@ -162,26 +151,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 +179,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 +189,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" @@ -268,22 +271,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 +311,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 +331,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 +347,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 +390,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 +439,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 +468,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 +481,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 +499,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,16 +528,28 @@ dependencies = [ ] [[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-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", ] [[package]] @@ -493,29 +563,26 @@ dependencies = [ ] [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "object" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] -name = "owning_ref" -version = "0.4.1" +name = "object" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" [[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" @@ -524,27 +591,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "pin-project-lite" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +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 +655,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 +738,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 +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" @@ -756,7 +910,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -773,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" @@ -791,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 = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -815,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" @@ -834,137 +1034,213 @@ 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", - "serde", - "serde-bench", - "serde_bytes", - "serde_derive", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "wat", "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" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "cranelift-codegen", - "log", + "enumset", + "raw-cpuid", + "serde", + "serde_bytes", "smallvec", "target-lexicon", + "thiserror", + "wasmer-types", + "wasmer-vm", + "wasmparser", ] [[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-cranelift" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "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-compiler-singlepass" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "wasmer-runtime-core", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ + "object 0.21.1", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" +dependencies = [ + "wast", +] + +[[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" diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 5032a9f8a8..5443548f2a 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 0.22.0", + "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.0" @@ -156,10 +143,12 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-compiler", + "wasmer-compiler-singlepass", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-types", ] [[package]] @@ -170,26 +159,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 +187,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 +197,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" @@ -276,22 +279,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 +319,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 +339,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 +355,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 +398,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 +447,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 +476,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 +489,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 +507,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" @@ -478,16 +536,28 @@ dependencies = [ ] [[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-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", ] [[package]] @@ -501,29 +571,26 @@ dependencies = [ ] [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "object" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] -name = "owning_ref" -version = "0.4.1" +name = "object" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" [[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" @@ -532,27 +599,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "pin-project-lite" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +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 +652,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 +748,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 +860,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 +920,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -783,10 +937,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 +955,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 = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -825,6 +993,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 +1044,213 @@ 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", - "serde", - "serde-bench", - "serde_bytes", - "serde_derive", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "wat", "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" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "cranelift-codegen", - "log", + "enumset", + "raw-cpuid", + "serde", + "serde_bytes", "smallvec", "target-lexicon", + "thiserror", + "wasmer-types", + "wasmer-vm", + "wasmparser", ] [[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-cranelift" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "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-compiler-singlepass" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "wasmer-runtime-core", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ + "object 0.21.1", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" +dependencies = [ + "wast", +] + +[[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" diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 9379678f2c..7be3afa80e 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 0.22.0", + "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.0" @@ -156,10 +143,12 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-compiler", + "wasmer-compiler-singlepass", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-types", ] [[package]] @@ -170,26 +159,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 +187,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 +197,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" @@ -276,22 +279,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 +319,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 +330,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 +345,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 +361,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 +404,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 +453,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 +482,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 +495,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 +513,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,16 +542,28 @@ dependencies = [ ] [[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-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", ] [[package]] @@ -507,29 +577,26 @@ dependencies = [ ] [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "object" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] -name = "owning_ref" -version = "0.4.1" +name = "object" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" [[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" @@ -538,27 +605,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d17797de36b94bc5f73edad736fd0a77ce5ab64dd622f809c1eead8c91fa6564" [[package]] -name = "parking_lot" -version = "0.10.2" +name = "pin-project-lite" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +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 +658,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 +741,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 +853,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 +913,7 @@ dependencies = [ "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] @@ -810,10 +964,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 +982,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 = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "tempfile" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", +] [[package]] name = "thiserror" @@ -852,6 +1020,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 +1071,213 @@ 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", - "serde", - "serde-bench", - "serde_bytes", - "serde_derive", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", - "wasmparser", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "wat", "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" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "cranelift-codegen", - "log", + "enumset", + "raw-cpuid", + "serde", + "serde_bytes", "smallvec", "target-lexicon", + "thiserror", + "wasmer-types", + "wasmer-vm", + "wasmparser", ] [[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-cranelift" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "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-compiler-singlepass" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ - "wasmer-runtime-core", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" 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-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" dependencies = [ + "object 0.21.1", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +dependencies = [ + "cranelift-entity", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" +dependencies = [ + "wast", +] + +[[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" From ec4c9bbf784ff993bd9d823d326c808bf2a99060 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 10:01:19 +0100 Subject: [PATCH 066/110] Update Wasmer to 6041c031b9 --- Cargo.lock | 46 ++++++++++++++++++++++++----------- contracts/burner/Cargo.lock | 46 ++++++++++++++++++++--------------- contracts/hackatom/Cargo.lock | 46 ++++++++++++++++++++--------------- contracts/queue/Cargo.lock | 46 ++++++++++++++++++++--------------- contracts/reflect/Cargo.lock | 46 ++++++++++++++++++++--------------- contracts/staking/Cargo.lock | 46 ++++++++++++++++++++--------------- packages/vm/Cargo.toml | 12 ++++----- packages/vm/src/context.rs | 8 +++++- 8 files changed, 175 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ba5df3abc..80eee9c9d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.21.1", "rustc-demangle", ] @@ -598,6 +598,12 @@ name = "object" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" + +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", @@ -924,9 +930,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" +checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" [[package]] name = "stable_deref_trait" @@ -1066,7 +1072,7 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasmer" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1075,6 +1081,7 @@ dependencies = [ "thiserror", "wasmer-compiler", "wasmer-compiler-cranelift", + "wasmer-derive", "wasmer-engine", "wasmer-engine-jit", "wasmer-engine-native", @@ -1087,7 +1094,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "enumset", "raw-cpuid", @@ -1104,7 +1111,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1122,7 +1129,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "byteorder", "dynasm", @@ -1137,10 +1144,21 @@ dependencies = [ "wasmer-vm", ] +[[package]] +name = "wasmer-derive" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "wasmer-engine" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "bincode", @@ -1159,7 +1177,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1176,7 +1194,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1196,9 +1214,9 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ - "object", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1207,7 +1225,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-entity", "serde", @@ -1216,7 +1234,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "cc", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index cb5c701987..6221b4484a 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.22.0", + "object", "rustc-demangle", ] @@ -575,20 +575,14 @@ dependencies = [ [[package]] name = "object" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", ] -[[package]] -name = "object" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -1042,7 +1036,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1051,6 +1045,7 @@ dependencies = [ "thiserror", "wasmer-compiler", "wasmer-compiler-cranelift", + "wasmer-derive", "wasmer-engine", "wasmer-engine-jit", "wasmer-engine-native", @@ -1063,7 +1058,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "enumset", "raw-cpuid", @@ -1080,7 +1075,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1098,7 +1093,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "byteorder", "dynasm", @@ -1113,10 +1108,21 @@ dependencies = [ "wasmer-vm", ] +[[package]] +name = "wasmer-derive" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "wasmer-engine" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "bincode", @@ -1135,7 +1141,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1152,7 +1158,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1172,9 +1178,9 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ - "object 0.21.1", + "object", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1183,7 +1189,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-entity", "serde", @@ -1192,7 +1198,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "cc", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index d7c06a734f..d83830d647 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.22.0", + "object", "rustc-demangle", ] @@ -586,20 +586,14 @@ dependencies = [ [[package]] name = "object" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", ] -[[package]] -name = "object" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -1053,7 +1047,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1062,6 +1056,7 @@ dependencies = [ "thiserror", "wasmer-compiler", "wasmer-compiler-cranelift", + "wasmer-derive", "wasmer-engine", "wasmer-engine-jit", "wasmer-engine-native", @@ -1074,7 +1069,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "enumset", "raw-cpuid", @@ -1091,7 +1086,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1109,7 +1104,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "byteorder", "dynasm", @@ -1124,10 +1119,21 @@ dependencies = [ "wasmer-vm", ] +[[package]] +name = "wasmer-derive" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "wasmer-engine" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "bincode", @@ -1146,7 +1152,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1163,7 +1169,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1183,9 +1189,9 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ - "object 0.21.1", + "object", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1194,7 +1200,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-entity", "serde", @@ -1203,7 +1209,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "cc", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index a4b01e1ffe..70381aa2d1 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.22.0", + "object", "rustc-demangle", ] @@ -564,20 +564,14 @@ dependencies = [ [[package]] name = "object" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", ] -[[package]] -name = "object" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -1042,7 +1036,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1051,6 +1045,7 @@ dependencies = [ "thiserror", "wasmer-compiler", "wasmer-compiler-cranelift", + "wasmer-derive", "wasmer-engine", "wasmer-engine-jit", "wasmer-engine-native", @@ -1063,7 +1058,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "enumset", "raw-cpuid", @@ -1080,7 +1075,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1098,7 +1093,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "byteorder", "dynasm", @@ -1113,10 +1108,21 @@ dependencies = [ "wasmer-vm", ] +[[package]] +name = "wasmer-derive" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "wasmer-engine" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "bincode", @@ -1135,7 +1141,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1152,7 +1158,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1172,9 +1178,9 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ - "object 0.21.1", + "object", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1183,7 +1189,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-entity", "serde", @@ -1192,7 +1198,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "cc", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 5443548f2a..495b3009ae 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.22.0", + "object", "rustc-demangle", ] @@ -572,20 +572,14 @@ dependencies = [ [[package]] name = "object" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", ] -[[package]] -name = "object" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -1052,7 +1046,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1061,6 +1055,7 @@ dependencies = [ "thiserror", "wasmer-compiler", "wasmer-compiler-cranelift", + "wasmer-derive", "wasmer-engine", "wasmer-engine-jit", "wasmer-engine-native", @@ -1073,7 +1068,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "enumset", "raw-cpuid", @@ -1090,7 +1085,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1108,7 +1103,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "byteorder", "dynasm", @@ -1123,10 +1118,21 @@ dependencies = [ "wasmer-vm", ] +[[package]] +name = "wasmer-derive" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "wasmer-engine" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "bincode", @@ -1145,7 +1151,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1162,7 +1168,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1182,9 +1188,9 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ - "object 0.21.1", + "object", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1193,7 +1199,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-entity", "serde", @@ -1202,7 +1208,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "cc", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 7be3afa80e..1f5123ed26 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.22.0", + "object", "rustc-demangle", ] @@ -578,20 +578,14 @@ dependencies = [ [[package]] name = "object" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", ] -[[package]] -name = "object" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -1079,7 +1073,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1088,6 +1082,7 @@ dependencies = [ "thiserror", "wasmer-compiler", "wasmer-compiler-cranelift", + "wasmer-derive", "wasmer-engine", "wasmer-engine-jit", "wasmer-engine-native", @@ -1100,7 +1095,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "enumset", "raw-cpuid", @@ -1117,7 +1112,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1135,7 +1130,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "byteorder", "dynasm", @@ -1150,10 +1145,21 @@ dependencies = [ "wasmer-vm", ] +[[package]] +name = "wasmer-derive" +version = "1.0.0-alpha5" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "wasmer-engine" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "bincode", @@ -1172,7 +1178,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1189,7 +1195,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1209,9 +1215,9 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ - "object 0.21.1", + "object", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1220,7 +1226,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "cranelift-entity", "serde", @@ -1229,7 +1235,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=5e2dc654#5e2dc65463a49b08c14bf9fb48eb45fa7d79d4c2" +source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" dependencies = [ "backtrace", "cc", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 8857622fe0..20aab34b7b 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -35,12 +35,12 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } -wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } -wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } -wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } -wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "5e2dc654" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } +wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } +wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } +wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } +wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api" } diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index c9a8ea5335..e5be7ab95d 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -3,7 +3,7 @@ use std::borrow::{Borrow, BorrowMut}; use std::ptr::NonNull; use std::sync::{Arc, RwLock}; -use wasmer::{Function, Instance as WasmerInstance, Memory}; +use wasmer::{Function, HostEnvInitError, Instance as WasmerInstance, Memory, WasmerEnv}; use crate::backend::{GasInfo, Querier, Storage}; use crate::errors::{VmError, VmResult}; @@ -73,6 +73,12 @@ impl Clone for Env { } } +impl WasmerEnv for Env { + fn init_with_instance(&mut self, _instance: &WasmerInstance) -> Result<(), HostEnvInitError> { + Ok(()) + } +} + impl Env { pub fn new(gas_limit: u64) -> Self { Env { From c541dd539c89001e944de007d1777afc5f538446 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 12:14:25 +0100 Subject: [PATCH 067/110] Test results of call_function --- packages/vm/src/instance.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 61511f6c26..87fe6762c6 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -364,15 +364,23 @@ mod test { let instance = mock_instance(&CONTRACT, &[]); // can call function few times - let _ptr1 = instance + let result = instance .call_function("allocate", &[0u32.into()]) .expect("error calling allocate"); - let _ptr2 = instance + assert_eq!(result.len(), 1); + assert_ne!(result[0].unwrap_i32(), 0); + + let result = instance .call_function("allocate", &[1u32.into()]) .expect("error calling allocate"); - let _ptr3 = instance + assert_eq!(result.len(), 1); + assert_ne!(result[0].unwrap_i32(), 0); + + 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] From 106550a28ab022f9deb67349d118a34d0cd2ff93 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 12:14:06 +0100 Subject: [PATCH 068/110] Add calls tests --- devtools/reborn_testing.sh | 1 + packages/vm/src/calls.rs | 58 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh index 2b28bb6ef1..f5080f29ad 100755 --- a/devtools/reborn_testing.sh +++ b/devtools/reborn_testing.sh @@ -6,6 +6,7 @@ command -v shellcheck > /dev/null && shellcheck "$0" (cd packages/vm \ && cargo check --tests \ && cargo check --features iterator --tests \ + && cargo test --features iterator calls:: \ && cargo test --features iterator checksum:: \ && cargo test --features iterator conversion:: \ && cargo test --features iterator compatibility \ diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs index a651218d48..3e7990fc85 100644 --- a/packages/vm/src/calls.rs +++ b/packages/vm/src/calls.rs @@ -159,3 +159,61 @@ fn call_raw( instance.deallocate(res_region_ptr)?; Ok(data) } + +#[cfg(test)] +mod tests { + use super::*; + use crate::testing::{mock_env, mock_info, mock_instance}; + use cosmwasm_std::{coins, Empty}; + + static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); + + #[test] + fn call_init_works() { + let mut instance = mock_instance(&CONTRACT, &[]); + + // init + 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(); + } + + #[test] + fn call_handle_works() { + let mut instance = mock_instance(&CONTRACT, &[]); + + // init + 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(); + + // handle + let info = mock_info("verifies", &coins(15, "earth")); + let msg = br#"{"release":{}}"#; + call_handle::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg) + .unwrap() + .unwrap(); + } + + #[test] + fn call_query_works() { + let mut instance = mock_instance(&CONTRACT, &[]); + + // init + 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(); + + // query + let msg = r#"{"verifier":{}}"#.as_bytes(); + let contract_result = call_query(&mut instance, &mock_env(), msg).unwrap(); + let query_response = contract_result.unwrap(); + assert_eq!(query_response.as_slice(), b"{\"verifier\":\"verifies\"}"); + } +} From b9b378602e16ad514277041b0fc71a5ed3a14cf5 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 13:08:19 +0100 Subject: [PATCH 069/110] Organize instance and cache testing --- devtools/reborn_testing.sh | 54 ++++++++++++++++++------------------- packages/vm/src/cache.rs | 2 +- packages/vm/src/instance.rs | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh index f5080f29ad..bb19101e4d 100755 --- a/devtools/reborn_testing.sh +++ b/devtools/reborn_testing.sh @@ -17,33 +17,33 @@ command -v shellcheck > /dev/null && shellcheck "$0" && cargo test --features iterator memory:: \ && cargo test --features iterator modules:: \ && cargo test --features iterator testing:: \ - && cargo test --features iterator init_cached_contract \ - && cargo test --features iterator load_wasm_errors_for_non_existent_id \ - && cargo test --features iterator load_wasm_from_disk_works \ - && cargo test --features iterator load_wasm_from_disk_works_in_subfolder \ - && cargo test --features iterator get_instance_finds_cached_module \ - && cargo test --features iterator load_wasm_errors_for_corrupted_wasm \ - && cargo test --features iterator get_instance_finds_cached_instance \ - && cargo test --features iterator load_wasm_works \ - && cargo test --features iterator save_wasm_rejects_invalid_contract \ - && cargo test --features iterator save_wasm_to_disk_fails_on_non_existent_dir \ - && cargo test --features iterator save_wasm_to_disk_works_for_same_data_multiple_times \ - && cargo test --features iterator load_wasm_works_across_multiple_cache_instances \ - && cargo test --features iterator save_wasm_works \ - && cargo test --features iterator run_cached_contract \ - && cargo test --features iterator use_multiple_cached_instances_of_same_contract \ - && cargo test --features iterator save_wasm_allows_saving_multiple_times \ - && cargo test --features iterator call_func_works \ - && cargo test --features iterator required_features_works_for_many_exports \ - && cargo test --features iterator get_memory_size_works \ - && cargo test --features iterator required_features_works \ - && cargo test --features iterator read_memory_errors_when_when_length_is_too_long \ - && cargo test --features iterator with_storage_safe_for_panic \ - && cargo test --features iterator with_querier_works_readonly \ - && cargo test --features iterator with_querier_allows_updating_balances \ - && cargo test --features iterator set_storage_readonly_works \ - && cargo test --features iterator with_storage_works \ - && cargo test --features iterator write_and_read_memory_works \ + && cargo test --features iterator instance::tests::call_func_works \ + && cargo test --features iterator instance::tests::get_memory_size_works \ + && cargo test --features iterator instance::tests::read_memory_errors_when_when_length_is_too_long \ + && cargo test --features iterator instance::tests::required_features_works \ + && cargo test --features iterator instance::tests::required_features_works_for_many_exports \ + && cargo test --features iterator instance::tests::with_storage_works \ + && cargo test --features iterator instance::tests::with_storage_safe_for_panic \ + && cargo test --features iterator instance::tests::with_querier_works_readonly \ + && cargo test --features iterator instance::tests::with_querier_allows_updating_balances \ + && cargo test --features iterator instance::tests::set_storage_readonly_works \ + && cargo test --features iterator instance::tests::write_and_read_memory_works \ + && cargo test --features iterator cache::tests::init_cached_contract \ + && cargo test --features iterator cache::tests::load_wasm_errors_for_non_existent_id \ + && cargo test --features iterator cache::tests::load_wasm_from_disk_works \ + && cargo test --features iterator cache::tests::load_wasm_from_disk_works_in_subfolder \ + && cargo test --features iterator cache::tests::get_instance_finds_cached_module \ + && cargo test --features iterator cache::tests::get_instance_finds_cached_modules_and_stores_to_memory \ + && cargo test --features iterator cache::tests::save_wasm_works \ + && cargo test --features iterator cache::tests::save_wasm_rejects_invalid_contract \ + && cargo test --features iterator cache::tests::save_wasm_to_disk_fails_on_non_existent_dir \ + && cargo test --features iterator cache::tests::save_wasm_to_disk_works_for_same_data_multiple_times \ + && cargo test --features iterator cache::tests::save_wasm_allows_saving_multiple_times \ + && cargo test --features iterator cache::tests::load_wasm_errors_for_corrupted_wasm \ + && cargo test --features iterator cache::tests::load_wasm_works \ + && cargo test --features iterator cache::tests::load_wasm_works_across_multiple_cache_instances \ + && cargo test --features iterator cache::tests::run_cached_contract \ + && cargo test --features iterator cache::tests::use_multiple_cached_instances_of_same_contract \ && cargo clippy --features iterator -- -D warnings) # Contracts diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 996f45db0b..55ac10cf6a 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -178,7 +178,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; diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 87fe6762c6..7154daa8d9 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -308,7 +308,7 @@ where } #[cfg(test)] -mod test { +mod tests { use super::*; use crate::backend::Storage; use crate::errors::VmError; From 837f90dc4f4f7e1bd2f4b52e4c05c3d62d8891c1 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 13:36:40 +0100 Subject: [PATCH 070/110] Convert memory limit to Size and add to MockInstanceOptions --- packages/vm/src/cache.rs | 4 ++-- packages/vm/src/context.rs | 5 +++-- packages/vm/src/imports.rs | 3 ++- packages/vm/src/instance.rs | 5 +++-- packages/vm/src/modules/file_system_cache.rs | 5 +++-- packages/vm/src/modules/in_memory_cache.rs | 2 +- packages/vm/src/testing/instance.rs | 8 ++++++-- packages/vm/src/wasm_backend/compile.rs | 6 ++++-- packages/vm/src/wasm_backend/gas.rs | 3 ++- packages/vm/src/wasm_backend/store.rs | 13 ++++++++----- 10 files changed, 34 insertions(+), 20 deletions(-) diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 55ac10cf6a..3abb1ccac4 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -84,7 +84,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)?; - const MEMORY_LIMIT: u32 = 256; // Hmm, is this even used? + const MEMORY_LIMIT: Size = Size::mebi(16); let module = compile(wasm, MEMORY_LIMIT)?; self.fs_cache.store(&checksum, &module)?; Ok(checksum) @@ -190,7 +190,7 @@ mod tests { use tempfile::TempDir; const TESTING_GAS_LIMIT: u64 = 400_000; - const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); const TESTING_OPTIONS: InstanceOptions = InstanceOptions { gas_limit: TESTING_GAS_LIMIT, memory_limit: TESTING_MEMORY_LIMIT, diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index e5be7ab95d..3d82767ad5 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -285,6 +285,7 @@ mod test { use super::*; use crate::backend::Storage; use crate::errors::VmError; + use crate::size::Size; use crate::testing::{MockQuerier, MockStorage}; use crate::wasm_backend::{compile, decrease_gas_left, set_gas_left}; use cosmwasm_std::{ @@ -308,12 +309,12 @@ mod test { const GAS_LIMIT: u64 = 5_000_000; const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000; - const MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); fn make_instance() -> (Env, Box) { let env = Env::new(GAS_LIMIT); - let module = compile(&CONTRACT, MEMORY_LIMIT).unwrap(); + let module = compile(&CONTRACT, TESTING_MEMORY_LIMIT).unwrap(); // we need stubs for all required imports let import_obj = imports! { "env" => { diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 05d5b95b46..20846a9400 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -275,6 +275,7 @@ mod test { use crate::backend::{BackendError, Storage}; use crate::context::move_into_context; + use crate::size::Size; use crate::testing::{MockApi, MockQuerier, MockStorage}; use crate::wasm_backend::compile; @@ -297,7 +298,7 @@ mod test { const INIT_DENOM: &str = "TOKEN"; const GAS_LIMIT: u64 = 5_000_000; - const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); fn make_instance() -> (Env, Box) { let env = Env::new(GAS_LIMIT); diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 7154daa8d9..6b25b5c8e5 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -18,6 +18,7 @@ use crate::imports::{ #[cfg(feature = "iterator")] 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)] @@ -36,8 +37,8 @@ pub struct GasReport { #[derive(Copy, Clone, Debug)] pub struct InstanceOptions { pub gas_limit: u64, - /// Memory limit in Wasm pages (64 KiB per page) - pub memory_limit: u32, + /// 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, } diff --git a/packages/vm/src/modules/file_system_cache.rs b/packages/vm/src/modules/file_system_cache.rs index 87753f40b3..21c3a5cbb9 100644 --- a/packages/vm/src/modules/file_system_cache.rs +++ b/packages/vm/src/modules/file_system_cache.rs @@ -12,6 +12,7 @@ use wasmer::Module; 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 @@ -67,7 +68,7 @@ impl FileSystemCache { } } - pub fn load(&self, checksum: &Checksum, memory_limit: u32) -> VmResult> { + pub fn load(&self, checksum: &Checksum, memory_limit: Size) -> VmResult> { let filename = checksum.to_hex(); let file_path = self .path @@ -120,7 +121,7 @@ mod tests { use tempfile::TempDir; use wasmer::{imports, Instance as WasmerInstance}; - const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); #[test] fn test_file_system_cache_run() { diff --git a/packages/vm/src/modules/in_memory_cache.rs b/packages/vm/src/modules/in_memory_cache.rs index f2d7724737..38ce2cf378 100644 --- a/packages/vm/src/modules/in_memory_cache.rs +++ b/packages/vm/src/modules/in_memory_cache.rs @@ -36,7 +36,7 @@ mod tests { use crate::wasm_backend::compile; use wasmer::{imports, Instance as WasmerInstance}; - const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); #[test] fn test_in_memory_cache_run() { diff --git a/packages/vm/src/testing/instance.rs b/packages/vm/src/testing/instance.rs index 9e9a13d011..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,7 +15,7 @@ use super::querier::MockQuerier; use super::storage::MockStorage; const DEFAULT_GAS_LIMIT: u64 = 500_000; -const DEFAULT_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB +const DEFAULT_MEMORY_LIMIT: Size = Size::mebi(16); const DEFAULT_PRINT_DEBUG: bool = true; pub fn mock_instance( @@ -84,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<'_> { @@ -98,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, } } } @@ -132,7 +136,7 @@ pub fn mock_instance_with_options( }; let options = InstanceOptions { gas_limit: options.gas_limit, - memory_limit: DEFAULT_MEMORY_LIMIT, + memory_limit: options.memory_limit, print_debug: options.print_debug, }; Instance::from_code(wasm, backend, options).unwrap() diff --git a/packages/vm/src/wasm_backend/compile.rs b/packages/vm/src/wasm_backend/compile.rs index 2f92b62ebc..1d1f021b26 100644 --- a/packages/vm/src/wasm_backend/compile.rs +++ b/packages/vm/src/wasm_backend/compile.rs @@ -1,13 +1,15 @@ // use wasmer_middleware_common::metering; use wasmer::Module; -use super::store::make_store; 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 Wasm pages) is used when memories are created. -pub fn compile(code: &[u8], memory_limit: u32) -> VmResult { +pub fn compile(code: &[u8], memory_limit: Size) -> 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 index e0dbb5f3ad..77000b33a6 100644 --- a/packages/vm/src/wasm_backend/gas.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -65,6 +65,7 @@ pub fn get_gas_left(_env: &Env) -> u64 { #[cfg(test)] mod test { use super::*; + use crate::size::Size; use crate::testing::{MockQuerier, MockStorage}; use crate::wasm_backend::compile; use std::ptr::NonNull; @@ -74,7 +75,7 @@ mod test { type MQ = MockQuerier; const GAS_LIMIT: u64 = 5_000_000; const MAX_GAS_LIMIT: u64 = u64::MAX / 2; - const TESTING_MEMORY_LIMIT: u32 = 256; // 256 pages = 16 MiB + const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); fn instantiate(code: &[u8]) -> (Env, Box) { let env = Env::new(GAS_LIMIT); diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs index e6c9c2c852..47db1e834c 100644 --- a/packages/vm/src/wasm_backend/store.rs +++ b/packages/vm/src/wasm_backend/store.rs @@ -1,25 +1,28 @@ -use wasmer::{Pages, Store, Target, Tunables as ReferenceTunables}; +use wasmer::{Bytes, Pages, Store, Target, Tunables as ReferenceTunables}; use wasmer_compiler_singlepass::Singlepass; use wasmer_engine::{Engine, Tunables}; use wasmer_engine_jit::JIT; +use crate::size::Size; + use super::limiting_tunables::LimitingTunables; /// Created a store with the default compiler and the given memory limit (in pages) -pub fn make_store(memory_limit: u32) -> Store { +pub fn make_store(memory_limit: Size) -> Store { 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 pages) -pub fn make_store_headless(memory_limit: u32) -> Store { +pub fn make_store_headless(memory_limit: Size) -> Store { let engine = JIT::headless().engine(); make_store_with_engine(&engine, memory_limit) } -fn make_store_with_engine(engine: &dyn Engine, memory_limit: u32) -> Store { - let tunables = make_tunables(Pages(memory_limit)); +fn make_store_with_engine(engine: &dyn Engine, memory_limit: Size) -> Store { + let pages = Pages::from(Bytes(memory_limit.0)); + let tunables = make_tunables(pages); Store::new_with_tunables(engine, tunables) } From 343c49df13c093c63295b50cf567ee124bbd1af4 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 13:50:56 +0100 Subject: [PATCH 071/110] Fix and activate test allocate_deallocate_works --- devtools/reborn_testing.sh | 1 + packages/vm/src/instance.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh index bb19101e4d..c8a42c081b 100755 --- a/devtools/reborn_testing.sh +++ b/devtools/reborn_testing.sh @@ -18,6 +18,7 @@ command -v shellcheck > /dev/null && shellcheck "$0" && cargo test --features iterator modules:: \ && cargo test --features iterator testing:: \ && cargo test --features iterator instance::tests::call_func_works \ + && cargo test --features iterator instance::tests::allocate_deallocate_works \ && cargo test --features iterator instance::tests::get_memory_size_works \ && cargo test --features iterator instance::tests::read_memory_errors_when_when_length_is_too_long \ && cargo test --features iterator instance::tests::required_features_works \ diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 6b25b5c8e5..4852d005f9 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -316,6 +316,7 @@ mod tests { 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, + mock_instance_with_options, MockInstanceOptions, }; use crate::{call_init, BackendError}; use cosmwasm_std::{ @@ -386,7 +387,13 @@ mod tests { #[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, From b8dc142b827c159046fc63a78e31c7982eecfe21 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 15:54:43 +0100 Subject: [PATCH 072/110] Ensure instance lives long enough --- packages/vm/src/context.rs | 24 ++++++++++++------------ packages/vm/src/imports.rs | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 3d82767ad5..cb846c56f9 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -351,7 +351,7 @@ mod test { #[test] fn leave_and_take_context_data() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); // empty data on start let (inits, initq) = move_out_of_context::(&env); @@ -376,7 +376,7 @@ mod test { #[test] fn gas_tracking_works_correctly() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); let gas_limit = 100; set_gas_left(&env, gas_limit); @@ -396,7 +396,7 @@ mod test { #[test] fn gas_tracking_works_correctly_with_gas_consumption_in_wasmer() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); let gas_limit = 100; set_gas_left(&env, gas_limit); @@ -420,7 +420,7 @@ mod test { #[test] fn is_storage_readonly_defaults_to_true() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); assert_eq!(env.is_storage_readonly(), true); @@ -428,7 +428,7 @@ mod test { #[test] fn set_storage_readonly_can_change_flag() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); // change @@ -446,7 +446,7 @@ mod test { #[test] fn with_func_from_context_works() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); let ptr = env @@ -461,7 +461,7 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_instance() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); // Clear context's wasmer_instance @@ -478,7 +478,7 @@ mod test { #[test] fn with_func_from_context_fails_for_missing_function() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); let res = env.with_func_from_context::<_, ()>("doesnt_exist", |_func| { @@ -497,7 +497,7 @@ mod test { #[test] fn with_storage_from_context_set_get() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); let val = env @@ -530,7 +530,7 @@ mod test { #[test] #[should_panic(expected = "A panic occurred in the callback.")] fn with_storage_from_context_handles_panics() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); env.with_storage_from_context::<_, ()>(|_store| { @@ -541,7 +541,7 @@ mod test { #[test] fn with_querier_from_context_works() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); let res = env @@ -564,7 +564,7 @@ mod test { #[test] #[should_panic(expected = "A panic occurred in the callback.")] fn with_querier_from_context_handles_panics() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); env.with_querier_from_context::<_, ()>(|_querier| { diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 20846a9400..8fae6e9dc6 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -899,7 +899,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_works() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); // set up iterator over all space @@ -925,7 +925,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_unbound_descending_works() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); // set up iterator over all space @@ -974,7 +974,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_multiple_iterators() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); // unbounded, ascending and descending @@ -1017,7 +1017,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_errors_for_invalid_order_value() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); // set up iterator over all space @@ -1033,7 +1033,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_next_works() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); @@ -1062,7 +1062,7 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_next_fails_for_non_existent_id() { - let (env, _) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); From 6e196606d8e3ce19087475822de6f5e134beb653 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 15:59:11 +0100 Subject: [PATCH 073/110] Fix context:: testing --- devtools/reborn_testing.sh | 1 + packages/vm/Cargo.toml | 1 + packages/vm/src/context.rs | 37 ++++++++++++++++++++++--------------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh index c8a42c081b..ce8492740c 100755 --- a/devtools/reborn_testing.sh +++ b/devtools/reborn_testing.sh @@ -8,6 +8,7 @@ command -v shellcheck > /dev/null && shellcheck "$0" && cargo check --features iterator --tests \ && cargo test --features iterator calls:: \ && cargo test --features iterator checksum:: \ + && cargo test --features iterator context:: \ && cargo test --features iterator conversion:: \ && cargo test --features iterator compatibility \ && cargo test --features iterator errors:: \ diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 20aab34b7b..4e5a36e198 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -22,6 +22,7 @@ backtraces = [] # we keep this optional, to allow possible future integration (or different Cosmos Backends) iterator = ["cosmwasm-std/iterator"] staking = ["cosmwasm-std/staking"] +metering = [] [dependencies] clru = "0.2.0" diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index cb846c56f9..62a5c8e1ad 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -287,11 +287,13 @@ mod test { use crate::errors::VmError; use crate::size::Size; use crate::testing::{MockQuerier, MockStorage}; - use crate::wasm_backend::{compile, decrease_gas_left, set_gas_left}; + #[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; + use wasmer::{imports, Function, FunctionType, Instance as WasmerInstance, Type, Val}; static CONTRACT: &[u8] = include_bytes!("../testdata/contract.wasm"); @@ -315,18 +317,25 @@ mod test { let env = Env::new(GAS_LIMIT); let module = compile(&CONTRACT, 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" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - // "db_write" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| {}), - // "db_remove" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), - // "db_scan" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32, _c: i32| -> u32 { 0 }), - // "db_next" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - // "query_chain" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - // "canonicalize_address" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| -> u32 { 0 }), - // "humanize_address" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| -> u32 { 0 }), - // "debug" => Func::new(|_ctx: &mut Ctx, _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 instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); @@ -395,6 +404,7 @@ mod test { } #[test] + #[cfg(feature = "metering")] fn gas_tracking_works_correctly_with_gas_consumption_in_wasmer() { let (env, _instance) = make_instance(); @@ -486,10 +496,7 @@ mod test { }); match res.unwrap_err() { VmError::ResolveErr { msg, .. } => { - assert_eq!( - msg, - "Wasmer resolve error: ExportNotFound { name: \"doesnt_exist\" }" - ); + assert_eq!(msg, "Could not get export: Missing(\"doesnt_exist\")"); } err => panic!("Unexpected error: {:?}", err), } From 5b0f1ba185b3b3504d305965e1b1898595c23f1c Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 16:04:50 +0100 Subject: [PATCH 074/110] Make all cache:: and instance:: tests pass --- devtools/reborn_testing.sh | 30 ++---------------------------- packages/vm/src/cache.rs | 2 ++ packages/vm/src/instance.rs | 27 +++++++++++++++------------ 3 files changed, 19 insertions(+), 40 deletions(-) diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh index ce8492740c..12f15946dc 100755 --- a/devtools/reborn_testing.sh +++ b/devtools/reborn_testing.sh @@ -18,34 +18,8 @@ command -v shellcheck > /dev/null && shellcheck "$0" && cargo test --features iterator memory:: \ && cargo test --features iterator modules:: \ && cargo test --features iterator testing:: \ - && cargo test --features iterator instance::tests::call_func_works \ - && cargo test --features iterator instance::tests::allocate_deallocate_works \ - && cargo test --features iterator instance::tests::get_memory_size_works \ - && cargo test --features iterator instance::tests::read_memory_errors_when_when_length_is_too_long \ - && cargo test --features iterator instance::tests::required_features_works \ - && cargo test --features iterator instance::tests::required_features_works_for_many_exports \ - && cargo test --features iterator instance::tests::with_storage_works \ - && cargo test --features iterator instance::tests::with_storage_safe_for_panic \ - && cargo test --features iterator instance::tests::with_querier_works_readonly \ - && cargo test --features iterator instance::tests::with_querier_allows_updating_balances \ - && cargo test --features iterator instance::tests::set_storage_readonly_works \ - && cargo test --features iterator instance::tests::write_and_read_memory_works \ - && cargo test --features iterator cache::tests::init_cached_contract \ - && cargo test --features iterator cache::tests::load_wasm_errors_for_non_existent_id \ - && cargo test --features iterator cache::tests::load_wasm_from_disk_works \ - && cargo test --features iterator cache::tests::load_wasm_from_disk_works_in_subfolder \ - && cargo test --features iterator cache::tests::get_instance_finds_cached_module \ - && cargo test --features iterator cache::tests::get_instance_finds_cached_modules_and_stores_to_memory \ - && cargo test --features iterator cache::tests::save_wasm_works \ - && cargo test --features iterator cache::tests::save_wasm_rejects_invalid_contract \ - && cargo test --features iterator cache::tests::save_wasm_to_disk_fails_on_non_existent_dir \ - && cargo test --features iterator cache::tests::save_wasm_to_disk_works_for_same_data_multiple_times \ - && cargo test --features iterator cache::tests::save_wasm_allows_saving_multiple_times \ - && cargo test --features iterator cache::tests::load_wasm_errors_for_corrupted_wasm \ - && cargo test --features iterator cache::tests::load_wasm_works \ - && cargo test --features iterator cache::tests::load_wasm_works_across_multiple_cache_instances \ - && cargo test --features iterator cache::tests::run_cached_contract \ - && cargo test --features iterator cache::tests::use_multiple_cached_instances_of_same_contract \ + && cargo test --features iterator instance:: \ + && cargo test --features iterator cache:: \ && cargo clippy --features iterator -- -D warnings) # Contracts diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 3abb1ccac4..556c4bb660 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -475,6 +475,7 @@ mod tests { } #[test] + #[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(); @@ -506,6 +507,7 @@ mod tests { } #[test] + #[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(); diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 4852d005f9..66fce48f51 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -312,15 +312,19 @@ where mod tests { use super::*; use crate::backend::Storage; + 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, - mock_instance_with_options, MockInstanceOptions, + 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, }; @@ -445,7 +449,7 @@ mod tests { } #[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); @@ -456,13 +460,9 @@ mod tests { 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), } } @@ -513,6 +513,7 @@ mod tests { } #[test] + #[cfg(feature = "metering")] fn set_get_and_gas() { let instance = mock_instance_with_gas_limit(&CONTRACT, 123321); let orig_gas = instance.get_gas_left(); @@ -520,6 +521,7 @@ mod tests { } #[test] + #[cfg(feature = "metering")] fn create_gas_report_works() { const LIMIT: u64 = 7_000_000; let mut instance = mock_instance_with_gas_limit(&CONTRACT, LIMIT); @@ -717,7 +719,8 @@ mod tests { } #[cfg(test)] -mod singlepass_test { +#[cfg(feature = "metering")] +mod singlepass_tests { use cosmwasm_std::{coins, Empty}; use crate::calls::{call_handle, call_init, call_query}; From ec53268799fa68f5a1f26c89c816bab968b5aba3 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 16:05:05 +0100 Subject: [PATCH 075/110] Exclude gas tests without metering --- packages/vm/src/wasm_backend/gas.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vm/src/wasm_backend/gas.rs b/packages/vm/src/wasm_backend/gas.rs index 77000b33a6..51cda568fe 100644 --- a/packages/vm/src/wasm_backend/gas.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -63,7 +63,8 @@ pub fn get_gas_left(_env: &Env) -> u64 { // } #[cfg(test)] -mod test { +#[cfg(feature = "metering")] +mod tests { use super::*; use crate::size::Size; use crate::testing::{MockQuerier, MockStorage}; From 65f804a48d8c36e3ce6a8cadce11a8d320234ea0 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 16:29:32 +0100 Subject: [PATCH 076/110] Fix imports tests --- devtools/reborn_testing.sh | 1 + packages/vm/src/imports.rs | 166 +++++++++++++++++++++---------------- 2 files changed, 94 insertions(+), 73 deletions(-) diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh index 12f15946dc..29aa362cc2 100755 --- a/devtools/reborn_testing.sh +++ b/devtools/reborn_testing.sh @@ -17,6 +17,7 @@ command -v shellcheck > /dev/null && shellcheck "$0" && cargo test --features iterator limiting_tunables:: \ && cargo test --features iterator memory:: \ && cargo test --features iterator modules:: \ + && cargo test --features iterator imports:: \ && cargo test --features iterator testing:: \ && cargo test --features iterator instance:: \ && cargo test --features iterator cache:: \ diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 8fae6e9dc6..5fd9b84ea2 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -271,7 +271,7 @@ mod test { SystemError, SystemResult, WasmQuery, }; use std::ptr::NonNull; - use wasmer::{imports, Instance as WasmerInstance}; + use wasmer::{imports, Function, FunctionType, Instance as WasmerInstance, Type, Val}; use crate::backend::{BackendError, Storage}; use crate::context::move_into_context; @@ -304,18 +304,25 @@ mod test { let env = Env::new(GAS_LIMIT); let module = compile(&CONTRACT, 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" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - // "db_write" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32| {}), - // "db_remove" => Func::new(|_ctx: &mut Ctx, _a: u32| {}), - // "db_scan" => Func::new(|_ctx: &mut Ctx, _a: u32, _b: u32, _c: i32| -> u32 { 0 }), - // "db_next" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - // "query_chain" => Func::new(|_ctx: &mut Ctx, _a: u32| -> u32 { 0 }), - // "canonicalize_address" => Func::new(|_ctx: &mut Ctx, _a: i32, _b: i32| -> u32 { 0 }), - // "humanize_address" => Func::new(|_ctx: &mut Ctx, _a: i32, _b: i32| -> u32 { 0 }), - // "debug" => Func::new(|_ctx: &mut Ctx, _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 instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); @@ -337,16 +344,17 @@ mod test { move_into_context(env, storage, querier); } - fn write_data(wasmer_instance: &mut WasmerInstance, data: &[u8]) -> u32 { - let allocate = wasmer_instance - .exports - .get_function("allocate") - .expect("error getting function"); - let result = allocate - .call(&[(data.len() as u32).into()]) - .expect("error calling allocate"); - let region_ptr = result[0].unwrap_i32() as u32; - // write_region(&mut wasmer_instance, region_ptr, data).expect("error writing"); + fn write_data(env: &Env, 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 = result[0].unwrap_i32() as u32; + Ok(ptr) + }) + .unwrap(); + write_region(&env.memory(), region_ptr, data).expect("error writing"); region_ptr } @@ -369,10 +377,10 @@ mod test { #[test] fn do_read_works() { - let (env, mut instance) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); - let key_ptr = write_data(&mut instance, KEY1); + let key_ptr = write_data(&env, KEY1); let result = do_read::(&env, key_ptr); let value_ptr = result.unwrap(); assert!(value_ptr > 0); @@ -381,20 +389,20 @@ mod test { #[test] fn do_read_works_for_non_existent_key() { - let (env, mut instance) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); - let key_ptr = write_data(&mut instance, b"I do not exist in storage"); + 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 (env, mut instance) = make_instance(); + let (env, _instance) = make_instance(); leave_default_data(&env); - let key_ptr = write_data(&mut instance, &vec![7u8; 300 * 1024]); + let key_ptr = write_data(&env, &vec![7u8; 300 * 1024]); let result = do_read::(&env, key_ptr); match result.unwrap_err() { VmError::CommunicationErr { @@ -406,10 +414,10 @@ mod test { #[test] fn do_write_works() { - let (env, 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"); leave_default_data(&env); @@ -428,10 +436,10 @@ mod test { #[test] fn do_write_can_override() { - let (env, 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); leave_default_data(&env); @@ -447,10 +455,10 @@ mod test { #[test] fn do_write_works_for_empty_value() { - let (env, 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""); leave_default_data(&env); @@ -469,10 +477,10 @@ mod test { #[test] fn do_write_fails_for_large_key() { - let (env, 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"); leave_default_data(&env); @@ -493,10 +501,10 @@ mod test { #[test] fn do_write_fails_for_large_value() { - let (env, 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]); leave_default_data(&env); @@ -517,10 +525,10 @@ mod test { #[test] fn do_write_is_prohibited_in_readonly_contexts() { - let (env, 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"); leave_default_data(&env); env.set_storage_readonly(true); @@ -534,15 +542,27 @@ mod test { #[test] fn do_remove_works() { - let (env, 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); + env.with_storage_from_context::<_, _>(|store| { + println!("{:?}", store); + Ok(()) + }) + .unwrap(); + do_remove::(&env, key_ptr).unwrap(); + 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")) @@ -553,10 +573,10 @@ mod test { #[test] fn do_remove_works_for_non_existent_key() { - let (env, 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); leave_default_data(&env); @@ -573,9 +593,9 @@ mod test { #[test] fn do_remove_fails_for_large_key() { - let (env, 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]); leave_default_data(&env); @@ -596,9 +616,9 @@ mod test { #[test] fn do_remove_is_prohibited_in_readonly_contexts() { - let (env, 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"); leave_default_data(&env); env.set_storage_readonly(true); @@ -615,7 +635,7 @@ mod test { 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); leave_default_data(&env); @@ -630,9 +650,9 @@ mod test { fn do_canonicalize_address_reports_invalid_input_back_to_contract() { 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); leave_default_data(&env); @@ -658,7 +678,7 @@ mod test { fn do_canonicalize_address_fails_for_broken_backend() { 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); leave_default_data(&env); @@ -679,7 +699,7 @@ mod test { fn do_canonicalize_address_fails_for_large_inputs() { 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); leave_default_data(&env); @@ -704,7 +724,7 @@ mod test { fn do_canonicalize_address_fails_for_small_destination_region() { 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); leave_default_data(&env); @@ -728,7 +748,7 @@ mod test { 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); leave_default_data(&env); @@ -743,7 +763,7 @@ mod test { fn do_humanize_address_reports_invalid_input_back_to_contract() { 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); leave_default_data(&env); @@ -759,7 +779,7 @@ mod test { fn do_humanize_address_fails_for_broken_backend() { 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); leave_default_data(&env); @@ -778,7 +798,7 @@ mod test { fn do_humanize_address_fails_for_input_too_long() { 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); leave_default_data(&env); @@ -805,7 +825,7 @@ mod test { 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); leave_default_data(&env); @@ -825,13 +845,13 @@ mod test { #[test] fn do_query_chain_works() { - let (env, 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); leave_default_data(&env); @@ -848,10 +868,10 @@ mod test { #[test] fn do_query_chain_fails_for_broken_request() { - let (env, 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); leave_default_data(&env); @@ -871,14 +891,14 @@ mod test { #[test] fn do_query_chain_fails_for_missing_contract() { - let (env, 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); leave_default_data(&env); @@ -951,10 +971,10 @@ mod test { #[test] #[cfg(feature = "iterator")] fn do_scan_bound_works() { - let (env, 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"); leave_default_data(&env); From ab2383ec61581ae572bb952e2a371d0c61bda4da Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 16:57:00 +0100 Subject: [PATCH 077/110] Run clippy via Rust stable --- .circleci/config.yml | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ff1b3367f5..94c73e597f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -534,23 +534,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" }} @@ -581,21 +569,13 @@ jobs: working_directory: ~/project/packages/storage command: cargo clippy --features iterator -- -D warnings - run: - name: Clippy linting on vm (singlepass; 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) + name: Clippy linting on vm (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 iterator -- -D warnings # # Contracts # From 28801693b591b40df04e3ac9784cde777bc55b4c Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 16:58:47 +0100 Subject: [PATCH 078/110] Remove package_vm_cranelift --- .circleci/config.yml | 36 ++++-------------------------------- .mergify.yml | 3 +-- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 94c73e597f..c0e1f4d392 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,8 +7,7 @@ workflows: - package_schema - package_std - package_storage - - package_vm_cranelift - - package_vm_singlepass + - package_vm - contract_burner - contract_hackatom - contract_hackatom_in_singlepass_vm @@ -144,34 +143,7 @@ jobs: - target/debug/deps key: cargocache-v2-package_storage-rust:1.47.0-{{ checksum "Cargo.lock" }} - package_vm_cranelift: - docker: - - image: rust:1.47.0 - steps: - - checkout - - run: - name: Version information - 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" }} - - run: - name: Build - working_directory: ~/project/packages/vm - command: cargo build --locked --no-default-features --features default-cranelift,iterator - - run: - name: Test - working_directory: ~/project/packages/vm - command: cargo test --locked --no-default-features --features default-cranelift,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" }} - - package_vm_singlepass: + package_vm: docker: - image: rustlang/rust:nightly steps: @@ -181,7 +153,7 @@ 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-rust:nightly-{{ checksum "Cargo.lock" }} - run: name: Build working_directory: ~/project/packages/vm @@ -204,7 +176,7 @@ jobs: - 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-rust:nightly-{{ checksum "Cargo.lock" }} contract_burner: docker: diff --git a/.mergify.yml b/.mergify.yml index 5b59e7e783..bc24d88a16 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -11,8 +11,7 @@ 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_cranelift" - - "status-success=ci/circleci: package_vm_singlepass" + - "status-success=ci/circleci: package_vm" - "status-success=ci/circleci: contract_burner" - "status-success=ci/circleci: contract_hackatom" - "status-success=ci/circleci: contract_hackatom_in_singlepass_vm" From ab26716bff2aba18bac03b69c4a3501766ff589e Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 17:00:16 +0100 Subject: [PATCH 079/110] Use stable Rust in package_vm --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c0e1f4d392..f58fa60817 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -145,7 +145,7 @@ jobs: package_vm: docker: - - image: rustlang/rust:nightly + - image: rust:1.47.0 steps: - checkout - run: @@ -153,7 +153,7 @@ jobs: command: rustc --version; cargo --version; rustup --version; rustup target list --installed - restore_cache: keys: - - cargocache-v2-package_vm-rust:nightly-{{ checksum "Cargo.lock" }} + - cargocache-v2-package_vm-rust:1.47.0-{{ checksum "Cargo.lock" }} - run: name: Build working_directory: ~/project/packages/vm @@ -176,7 +176,7 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: cargocache-v2-package_vm-rust:nightly-{{ checksum "Cargo.lock" }} + key: cargocache-v2-package_vm-rust:1.47.0-{{ checksum "Cargo.lock" }} contract_burner: docker: From 47e464634d752c5a29ea160b50b1986eca1f39f4 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 1 Dec 2020 17:01:08 +0100 Subject: [PATCH 080/110] Remove job contract_hackatom_in_singlepass_vm --- .circleci/config.yml | 36 ------------------------------------ .mergify.yml | 1 - 2 files changed, 37 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f58fa60817..92176ed2d8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,6 @@ workflows: - package_vm - contract_burner - contract_hackatom - - contract_hackatom_in_singlepass_vm - contract_queue - contract_reflect - contract_staking @@ -276,41 +275,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 - 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 diff --git a/.mergify.yml b/.mergify.yml index bc24d88a16..c38410c4f9 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -14,7 +14,6 @@ pull_request_rules: - "status-success=ci/circleci: package_vm" - "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" From c999bcbbe388736389b16943847f1016fa321eda Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 2 Dec 2020 21:38:25 +0100 Subject: [PATCH 081/110] Update Wasmer to 1.0.0-beta1 --- Cargo.lock | 57 ++++++++++++++++++++--------------- contracts/burner/Cargo.lock | 57 ++++++++++++++++++++--------------- contracts/hackatom/Cargo.lock | 57 ++++++++++++++++++++--------------- contracts/queue/Cargo.lock | 57 ++++++++++++++++++++--------------- contracts/reflect/Cargo.lock | 57 ++++++++++++++++++++--------------- contracts/staking/Cargo.lock | 57 ++++++++++++++++++++--------------- packages/vm/Cargo.toml | 12 ++++---- 7 files changed, 204 insertions(+), 150 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80eee9c9d0..b61874bc63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ dependencies = [ "const_fn", "crossbeam-utils", "lazy_static", - "memoffset", + "memoffset 0.5.6", "scopeguard", ] @@ -548,6 +548,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +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" @@ -1071,8 +1080,8 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasmer" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1093,8 +1102,8 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "enumset", "raw-cpuid", @@ -1110,8 +1119,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1128,8 +1137,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "byteorder", "dynasm", @@ -1146,8 +1155,8 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1157,8 +1166,8 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "bincode", @@ -1176,8 +1185,8 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1193,8 +1202,8 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1213,8 +1222,8 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "object 0.22.0", "thiserror", @@ -1224,8 +1233,8 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-entity", "serde", @@ -1233,15 +1242,15 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "cc", "cfg-if 0.1.10", "indexmap", "libc", - "memoffset", + "memoffset 0.6.1", "more-asserts", "region", "serde", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 6221b4484a..7fae0a16db 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -265,7 +265,7 @@ dependencies = [ "const_fn", "crossbeam-utils", "lazy_static", - "memoffset", + "memoffset 0.5.6", "scopeguard", ] @@ -538,6 +538,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +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" @@ -1035,8 +1044,8 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1057,8 +1066,8 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "enumset", "raw-cpuid", @@ -1074,8 +1083,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1092,8 +1101,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "byteorder", "dynasm", @@ -1110,8 +1119,8 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1121,8 +1130,8 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "bincode", @@ -1140,8 +1149,8 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1157,8 +1166,8 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1177,8 +1186,8 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "object", "thiserror", @@ -1188,8 +1197,8 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-entity", "serde", @@ -1197,15 +1206,15 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "cc", "cfg-if 0.1.10", "indexmap", "libc", - "memoffset", + "memoffset 0.6.1", "more-asserts", "region", "serde", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index d83830d647..35e46d514e 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -262,7 +262,7 @@ dependencies = [ "const_fn", "crossbeam-utils", "lazy_static", - "memoffset", + "memoffset 0.5.6", "scopeguard", ] @@ -549,6 +549,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +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" @@ -1046,8 +1055,8 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1068,8 +1077,8 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "enumset", "raw-cpuid", @@ -1085,8 +1094,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1103,8 +1112,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "byteorder", "dynasm", @@ -1121,8 +1130,8 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1132,8 +1141,8 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "bincode", @@ -1151,8 +1160,8 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1168,8 +1177,8 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1188,8 +1197,8 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "object", "thiserror", @@ -1199,8 +1208,8 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-entity", "serde", @@ -1208,15 +1217,15 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "cc", "cfg-if 0.1.10", "indexmap", "libc", - "memoffset", + "memoffset 0.6.1", "more-asserts", "region", "serde", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 70381aa2d1..3c3c44afcc 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -254,7 +254,7 @@ dependencies = [ "const_fn", "crossbeam-utils", "lazy_static", - "memoffset", + "memoffset 0.5.6", "scopeguard", ] @@ -527,6 +527,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +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" @@ -1035,8 +1044,8 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1057,8 +1066,8 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "enumset", "raw-cpuid", @@ -1074,8 +1083,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1092,8 +1101,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "byteorder", "dynasm", @@ -1110,8 +1119,8 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1121,8 +1130,8 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "bincode", @@ -1140,8 +1149,8 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1157,8 +1166,8 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1177,8 +1186,8 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "object", "thiserror", @@ -1188,8 +1197,8 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-entity", "serde", @@ -1197,15 +1206,15 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "cc", "cfg-if 0.1.10", "indexmap", "libc", - "memoffset", + "memoffset 0.6.1", "more-asserts", "region", "serde", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 495b3009ae..934d26098f 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -262,7 +262,7 @@ dependencies = [ "const_fn", "crossbeam-utils", "lazy_static", - "memoffset", + "memoffset 0.5.6", "scopeguard", ] @@ -535,6 +535,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +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" @@ -1045,8 +1054,8 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1067,8 +1076,8 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "enumset", "raw-cpuid", @@ -1084,8 +1093,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1102,8 +1111,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "byteorder", "dynasm", @@ -1120,8 +1129,8 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1131,8 +1140,8 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "bincode", @@ -1150,8 +1159,8 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1167,8 +1176,8 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1187,8 +1196,8 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "object", "thiserror", @@ -1198,8 +1207,8 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "cranelift-entity", "serde", @@ -1207,15 +1216,15 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" dependencies = [ "backtrace", "cc", "cfg-if 0.1.10", "indexmap", "libc", - "memoffset", + "memoffset 0.6.1", "more-asserts", "region", "serde", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 1f5123ed26..5103ec8ed0 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -262,7 +262,7 @@ dependencies = [ "const_fn", "crossbeam-utils", "lazy_static", - "memoffset", + "memoffset 0.5.6", "scopeguard", ] @@ -541,6 +541,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +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" @@ -1072,8 +1081,8 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1094,8 +1103,8 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "enumset", "raw-cpuid", @@ -1111,8 +1120,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1129,8 +1138,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "byteorder", "dynasm", @@ -1147,8 +1156,8 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1158,8 +1167,8 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "backtrace", "bincode", @@ -1177,8 +1186,8 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1194,8 +1203,8 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1214,8 +1223,8 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "object", "thiserror", @@ -1225,8 +1234,8 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "cranelift-entity", "serde", @@ -1234,15 +1243,15 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha5" -source = "git+https://github.com/wasmerio/wasmer?rev=6041c031b9#6041c031b917c7b17748fa3acee3379f8a04faea" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" dependencies = [ "backtrace", "cc", "cfg-if 0.1.10", "indexmap", "libc", - "memoffset", + "memoffset 0.6.1", "more-asserts", "region", "serde", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 4e5a36e198..50951c9676 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -36,12 +36,12 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } -wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } -wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } -wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } -wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "6041c031b9" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } +wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } +wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } +wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } +wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api" } From 9b80705ab95fa80d8482e3f3591121e5bc12e357 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 2 Dec 2020 21:55:33 +0100 Subject: [PATCH 082/110] Remove dependency memoffset 0.5 --- Cargo.lock | 17 ++++------------- contracts/burner/Cargo.lock | 17 ++++------------- contracts/hackatom/Cargo.lock | 17 ++++------------- contracts/queue/Cargo.lock | 17 ++++------------- contracts/reflect/Cargo.lock | 17 ++++------------- contracts/staking/Cargo.lock | 17 ++++------------- 6 files changed, 24 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b61874bc63..5596b157ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -271,15 +271,15 @@ 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", "crossbeam-utils", "lazy_static", - "memoffset 0.5.6", + "memoffset", "scopeguard", ] @@ -539,15 +539,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.6.1" @@ -1250,7 +1241,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", - "memoffset 0.6.1", + "memoffset", "more-asserts", "region", "serde", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 7fae0a16db..c72d078fcc 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -257,15 +257,15 @@ 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", "crossbeam-utils", "lazy_static", - "memoffset 0.5.6", + "memoffset", "scopeguard", ] @@ -529,15 +529,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.6.1" @@ -1214,7 +1205,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", - "memoffset 0.6.1", + "memoffset", "more-asserts", "region", "serde", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 35e46d514e..29135859d7 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -254,15 +254,15 @@ 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", "crossbeam-utils", "lazy_static", - "memoffset 0.5.6", + "memoffset", "scopeguard", ] @@ -540,15 +540,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.6.1" @@ -1225,7 +1216,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", - "memoffset 0.6.1", + "memoffset", "more-asserts", "region", "serde", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 3c3c44afcc..082d6a34e7 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -246,15 +246,15 @@ 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", "crossbeam-utils", "lazy_static", - "memoffset 0.5.6", + "memoffset", "scopeguard", ] @@ -518,15 +518,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.6.1" @@ -1214,7 +1205,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", - "memoffset 0.6.1", + "memoffset", "more-asserts", "region", "serde", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 934d26098f..ceef86d9e4 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -254,15 +254,15 @@ 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", "crossbeam-utils", "lazy_static", - "memoffset 0.5.6", + "memoffset", "scopeguard", ] @@ -526,15 +526,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.6.1" @@ -1224,7 +1215,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", - "memoffset 0.6.1", + "memoffset", "more-asserts", "region", "serde", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 5103ec8ed0..bc94820cee 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -254,15 +254,15 @@ 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", "crossbeam-utils", "lazy_static", - "memoffset 0.5.6", + "memoffset", "scopeguard", ] @@ -532,15 +532,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.6.1" @@ -1251,7 +1242,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", - "memoffset 0.6.1", + "memoffset", "more-asserts", "region", "serde", From d76d490907523a733c3cc2b7006e560913635ffd Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 4 Dec 2020 10:09:26 +0100 Subject: [PATCH 083/110] Remove explicit wasmer-types dependency --- Cargo.lock | 1 - contracts/burner/Cargo.lock | 1 - contracts/hackatom/Cargo.lock | 1 - contracts/queue/Cargo.lock | 1 - contracts/reflect/Cargo.lock | 1 - contracts/staking/Cargo.lock | 1 - packages/vm/Cargo.toml | 2 -- 7 files changed, 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5596b157ac..0a2f8d440d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,7 +164,6 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-engine", "wasmer-engine-jit", - "wasmer-types", "wat", ] diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index c72d078fcc..7610618d25 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -151,7 +151,6 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-engine", "wasmer-engine-jit", - "wasmer-types", ] [[package]] diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 29135859d7..4f5c14d4d2 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -148,7 +148,6 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-engine", "wasmer-engine-jit", - "wasmer-types", ] [[package]] diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 082d6a34e7..cee23b7502 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -140,7 +140,6 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-engine", "wasmer-engine-jit", - "wasmer-types", ] [[package]] diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index ceef86d9e4..f10772d748 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -148,7 +148,6 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-engine", "wasmer-engine-jit", - "wasmer-types", ] [[package]] diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index bc94820cee..372856564c 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -148,7 +148,6 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-engine", "wasmer-engine-jit", - "wasmer-types", ] [[package]] diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 50951c9676..76c996d8e6 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -41,7 +41,6 @@ wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-bet wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } -wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api" } @@ -49,7 +48,6 @@ wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" # wasmer-compiler-singlepass = { path = "../../../wasmer/lib/compiler-singlepass" } # wasmer-engine = { path = "../../../wasmer/lib/engine" } # wasmer-engine-jit = { path = "../../../wasmer/lib/engine-jit" } -# wasmer-types = { path = "../../../wasmer/lib/wasmer-types" } [dev-dependencies] tempfile = "3.1.0" From 971fcc14bb77f3c167817a900297debbb19d70f9 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 4 Dec 2020 10:20:20 +0100 Subject: [PATCH 084/110] Use error types from wasmer --- packages/vm/src/errors/vm_error.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index fd2779acd6..fd1ff85db3 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -141,20 +141,20 @@ impl From for VmError { } } -impl From for VmError { - fn from(original: wasmer_engine::SerializeError) -> Self { +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_engine::DeserializeError) -> Self { +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_engine::RuntimeError) -> Self { +impl From for VmError { + fn from(original: wasmer::RuntimeError) -> Self { VmError::runtime_err(format!("Wasmer runtime error: {:?}", original)) } } @@ -177,10 +177,10 @@ impl From for VmError { } } -impl From for wasmer_engine::RuntimeError { - fn from(original: VmError) -> wasmer_engine::RuntimeError { +impl From for wasmer::RuntimeError { + fn from(original: VmError) -> wasmer::RuntimeError { let msg: String = original.to_string(); - wasmer_engine::RuntimeError::new(msg) + wasmer::RuntimeError::new(msg) } } From 35baeaa2f7758ad4246834514078108893a57515 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 4 Dec 2020 10:28:46 +0100 Subject: [PATCH 085/110] Reduce features and dependencies of wasmer --- Cargo.lock | 120 +--------------------------- contracts/burner/Cargo.lock | 146 +--------------------------------- contracts/hackatom/Cargo.lock | 146 +--------------------------------- contracts/queue/Cargo.lock | 146 +--------------------------------- contracts/reflect/Cargo.lock | 146 +--------------------------------- contracts/staking/Cargo.lock | 146 +--------------------------------- packages/vm/Cargo.toml | 4 +- 7 files changed, 13 insertions(+), 841 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a2f8d440d..37f8a1f238 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,50 +173,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" -[[package]] -name = "cranelift-bforest" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" -dependencies = [ - "byteorder", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli", - "log", - "regalloc", - "smallvec", - "target-lexicon", - "thiserror", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" -dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" - [[package]] name = "cranelift-entity" version = "0.68.0" @@ -226,18 +182,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cranelift-frontend" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - [[package]] name = "crc32fast" version = "1.2.0" @@ -392,12 +336,6 @@ dependencies = [ "syn", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - [[package]] name = "fnv" version = "1.0.7" @@ -430,11 +368,6 @@ name = "gimli" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] [[package]] name = "hashbrown" @@ -510,15 +443,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "mach" version = "0.3.2" @@ -751,17 +675,6 @@ 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" @@ -789,12 +702,6 @@ 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" @@ -933,12 +840,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "strsim" version = "0.9.3" @@ -1079,14 +980,13 @@ dependencies = [ "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", - "wat", "winapi", ] @@ -1107,24 +1007,6 @@ dependencies = [ "wasmparser", ] -[[package]] -name = "wasmer-compiler-cranelift" -version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" -dependencies = [ - "cranelift-codegen", - "cranelift-frontend", - "gimli", - "more-asserts", - "rayon", - "serde", - "smallvec", - "tracing", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 7610618d25..6764f5b060 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli 0.23.0", + "gimli", ] [[package]] @@ -159,50 +159,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" -[[package]] -name = "cranelift-bforest" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" -dependencies = [ - "byteorder", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli 0.22.0", - "log", - "regalloc", - "smallvec", - "target-lexicon", - "thiserror", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" -dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" - [[package]] name = "cranelift-entity" version = "0.68.0" @@ -212,18 +168,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cranelift-frontend" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - [[package]] name = "crc32fast" version = "1.2.1" @@ -378,12 +322,6 @@ dependencies = [ "syn", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - [[package]] name = "fnv" version = "1.0.7" @@ -411,17 +349,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - [[package]] name = "gimli" version = "0.23.0" @@ -500,15 +427,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "mach" version = "0.3.2" @@ -731,17 +649,6 @@ 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" @@ -769,12 +676,6 @@ 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" @@ -913,12 +814,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "strsim" version = "0.9.3" @@ -1043,14 +938,13 @@ dependencies = [ "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", - "wat", "winapi", ] @@ -1071,24 +965,6 @@ dependencies = [ "wasmparser", ] -[[package]] -name = "wasmer-compiler-cranelift" -version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" -dependencies = [ - "cranelift-codegen", - "cranelift-frontend", - "gimli 0.22.0", - "more-asserts", - "rayon", - "serde", - "smallvec", - "tracing", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" @@ -1219,24 +1095,6 @@ version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" -[[package]] -name = "wast" -version = "27.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" -dependencies = [ - "leb128", -] - -[[package]] -name = "wat" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" -dependencies = [ - "wast", -] - [[package]] name = "which" version = "4.0.2" diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 4f5c14d4d2..e89d7a6405 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli 0.23.0", + "gimli", ] [[package]] @@ -156,50 +156,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" -[[package]] -name = "cranelift-bforest" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" -dependencies = [ - "byteorder", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli 0.22.0", - "log", - "regalloc", - "smallvec", - "target-lexicon", - "thiserror", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" -dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" - [[package]] name = "cranelift-entity" version = "0.68.0" @@ -209,18 +165,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cranelift-frontend" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - [[package]] name = "crc32fast" version = "1.2.1" @@ -375,12 +319,6 @@ dependencies = [ "syn", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - [[package]] name = "fnv" version = "1.0.7" @@ -408,17 +346,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - [[package]] name = "gimli" version = "0.23.0" @@ -511,15 +438,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "mach" version = "0.3.2" @@ -742,17 +660,6 @@ 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" @@ -780,12 +687,6 @@ 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" @@ -924,12 +825,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "strsim" version = "0.9.3" @@ -1054,14 +949,13 @@ dependencies = [ "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", - "wat", "winapi", ] @@ -1082,24 +976,6 @@ dependencies = [ "wasmparser", ] -[[package]] -name = "wasmer-compiler-cranelift" -version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" -dependencies = [ - "cranelift-codegen", - "cranelift-frontend", - "gimli 0.22.0", - "more-asserts", - "rayon", - "serde", - "smallvec", - "tracing", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" @@ -1230,24 +1106,6 @@ version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" -[[package]] -name = "wast" -version = "27.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" -dependencies = [ - "leb128", -] - -[[package]] -name = "wat" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" -dependencies = [ - "wast", -] - [[package]] name = "which" version = "4.0.2" diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index cee23b7502..9bf110f3a7 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli 0.23.0", + "gimli", ] [[package]] @@ -148,50 +148,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" -[[package]] -name = "cranelift-bforest" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" -dependencies = [ - "byteorder", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli 0.22.0", - "log", - "regalloc", - "smallvec", - "target-lexicon", - "thiserror", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" -dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" - [[package]] name = "cranelift-entity" version = "0.68.0" @@ -201,18 +157,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cranelift-frontend" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - [[package]] name = "crc32fast" version = "1.2.1" @@ -367,12 +311,6 @@ dependencies = [ "syn", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - [[package]] name = "fnv" version = "1.0.7" @@ -400,17 +338,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - [[package]] name = "gimli" version = "0.23.0" @@ -489,15 +416,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "mach" version = "0.3.2" @@ -731,17 +649,6 @@ 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" @@ -769,12 +676,6 @@ 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" @@ -913,12 +814,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "strsim" version = "0.9.3" @@ -1043,14 +938,13 @@ dependencies = [ "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", - "wat", "winapi", ] @@ -1071,24 +965,6 @@ dependencies = [ "wasmparser", ] -[[package]] -name = "wasmer-compiler-cranelift" -version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" -dependencies = [ - "cranelift-codegen", - "cranelift-frontend", - "gimli 0.22.0", - "more-asserts", - "rayon", - "serde", - "smallvec", - "tracing", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" @@ -1219,24 +1095,6 @@ version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" -[[package]] -name = "wast" -version = "27.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" -dependencies = [ - "leb128", -] - -[[package]] -name = "wat" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" -dependencies = [ - "wast", -] - [[package]] name = "which" version = "4.0.2" diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index f10772d748..8cf3c4b540 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli 0.23.0", + "gimli", ] [[package]] @@ -156,50 +156,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" -[[package]] -name = "cranelift-bforest" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" -dependencies = [ - "byteorder", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli 0.22.0", - "log", - "regalloc", - "smallvec", - "target-lexicon", - "thiserror", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" -dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" - [[package]] name = "cranelift-entity" version = "0.68.0" @@ -209,18 +165,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cranelift-frontend" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - [[package]] name = "crc32fast" version = "1.2.1" @@ -375,12 +319,6 @@ dependencies = [ "syn", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - [[package]] name = "fnv" version = "1.0.7" @@ -408,17 +346,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - [[package]] name = "gimli" version = "0.23.0" @@ -497,15 +424,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "mach" version = "0.3.2" @@ -741,17 +659,6 @@ 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" @@ -779,12 +686,6 @@ 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" @@ -923,12 +824,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "strsim" version = "0.9.3" @@ -1053,14 +948,13 @@ dependencies = [ "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", - "wat", "winapi", ] @@ -1081,24 +975,6 @@ dependencies = [ "wasmparser", ] -[[package]] -name = "wasmer-compiler-cranelift" -version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" -dependencies = [ - "cranelift-codegen", - "cranelift-frontend", - "gimli 0.22.0", - "more-asserts", - "rayon", - "serde", - "smallvec", - "tracing", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" @@ -1229,24 +1105,6 @@ version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" -[[package]] -name = "wast" -version = "27.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" -dependencies = [ - "leb128", -] - -[[package]] -name = "wat" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" -dependencies = [ - "wast", -] - [[package]] name = "which" version = "4.0.2" diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 372856564c..0f63164ea6 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli 0.23.0", + "gimli", ] [[package]] @@ -156,50 +156,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" -[[package]] -name = "cranelift-bforest" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" -dependencies = [ - "byteorder", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli 0.22.0", - "log", - "regalloc", - "smallvec", - "target-lexicon", - "thiserror", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" -dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" - [[package]] name = "cranelift-entity" version = "0.68.0" @@ -209,18 +165,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cranelift-frontend" -version = "0.68.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - [[package]] name = "crc32fast" version = "1.2.1" @@ -381,12 +325,6 @@ dependencies = [ "syn", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - [[package]] name = "fnv" version = "1.0.7" @@ -414,17 +352,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - [[package]] name = "gimli" version = "0.23.0" @@ -503,15 +430,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "mach" version = "0.3.2" @@ -734,17 +652,6 @@ 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" @@ -772,12 +679,6 @@ 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" @@ -937,12 +838,6 @@ dependencies = [ "syn", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "staking" version = "0.0.0" @@ -1080,14 +975,13 @@ dependencies = [ "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", - "wat", "winapi", ] @@ -1108,24 +1002,6 @@ dependencies = [ "wasmparser", ] -[[package]] -name = "wasmer-compiler-cranelift" -version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" -dependencies = [ - "cranelift-codegen", - "cranelift-frontend", - "gimli 0.22.0", - "more-asserts", - "rayon", - "serde", - "smallvec", - "tracing", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" @@ -1256,24 +1132,6 @@ version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" -[[package]] -name = "wast" -version = "27.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" -dependencies = [ - "leb128", -] - -[[package]] -name = "wat" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" -dependencies = [ - "wast", -] - [[package]] name = "which" version = "4.0.2" diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 76c996d8e6..a9fb0014e0 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -36,14 +36,14 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1", default-features = false, features = ["jit", "singlepass"] } wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } # Wasmer local (used for quick local debugging or patching) -# wasmer = { path = "../../../wasmer/lib/api" } +# wasmer = { path = "../../../wasmer/lib/api", default-features = false, features = ["jit", "singlepass"] } # wasmer-compiler = { path = "../../../wasmer/lib/compiler" } # wasmer-compiler-singlepass = { path = "../../../wasmer/lib/compiler-singlepass" } # wasmer-engine = { path = "../../../wasmer/lib/engine" } From 17a54c40563e9277e928cec8b31da0748932a13b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 4 Dec 2020 10:33:54 +0100 Subject: [PATCH 086/110] Use Singlepass and JIT via wasmer crate --- Cargo.lock | 2 -- contracts/burner/Cargo.lock | 2 -- contracts/hackatom/Cargo.lock | 2 -- contracts/queue/Cargo.lock | 2 -- contracts/reflect/Cargo.lock | 2 -- contracts/staking/Cargo.lock | 2 -- packages/vm/Cargo.toml | 4 ---- packages/vm/src/wasm_backend/store.rs | 4 +--- 8 files changed, 1 insertion(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37f8a1f238..734f75981c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,9 +161,7 @@ dependencies = [ "thiserror", "wasmer", "wasmer-compiler", - "wasmer-compiler-singlepass", "wasmer-engine", - "wasmer-engine-jit", "wat", ] diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 6764f5b060..71bb197895 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -148,9 +148,7 @@ dependencies = [ "thiserror", "wasmer", "wasmer-compiler", - "wasmer-compiler-singlepass", "wasmer-engine", - "wasmer-engine-jit", ] [[package]] diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index e89d7a6405..044867fc6d 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -145,9 +145,7 @@ dependencies = [ "thiserror", "wasmer", "wasmer-compiler", - "wasmer-compiler-singlepass", "wasmer-engine", - "wasmer-engine-jit", ] [[package]] diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 9bf110f3a7..916f69b216 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -137,9 +137,7 @@ dependencies = [ "thiserror", "wasmer", "wasmer-compiler", - "wasmer-compiler-singlepass", "wasmer-engine", - "wasmer-engine-jit", ] [[package]] diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 8cf3c4b540..b9071e2c98 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -145,9 +145,7 @@ dependencies = [ "thiserror", "wasmer", "wasmer-compiler", - "wasmer-compiler-singlepass", "wasmer-engine", - "wasmer-engine-jit", ] [[package]] diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 0f63164ea6..42d1e0557c 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -145,9 +145,7 @@ dependencies = [ "thiserror", "wasmer", "wasmer-compiler", - "wasmer-compiler-singlepass", "wasmer-engine", - "wasmer-engine-jit", ] [[package]] diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index a9fb0014e0..39005c3d46 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -38,16 +38,12 @@ sha2 = "0.9.1" thiserror = "1.0" wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1", default-features = false, features = ["jit", "singlepass"] } wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } -wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } -wasmer-engine-jit = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api", default-features = false, features = ["jit", "singlepass"] } # wasmer-compiler = { path = "../../../wasmer/lib/compiler" } -# wasmer-compiler-singlepass = { path = "../../../wasmer/lib/compiler-singlepass" } # wasmer-engine = { path = "../../../wasmer/lib/engine" } -# wasmer-engine-jit = { path = "../../../wasmer/lib/engine-jit" } [dev-dependencies] tempfile = "3.1.0" diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs index 47db1e834c..99d668634b 100644 --- a/packages/vm/src/wasm_backend/store.rs +++ b/packages/vm/src/wasm_backend/store.rs @@ -1,7 +1,5 @@ -use wasmer::{Bytes, Pages, Store, Target, Tunables as ReferenceTunables}; -use wasmer_compiler_singlepass::Singlepass; +use wasmer::{Bytes, Pages, Singlepass, Store, Target, Tunables as ReferenceTunables, JIT}; use wasmer_engine::{Engine, Tunables}; -use wasmer_engine_jit::JIT; use crate::size::Size; From acdcf672fb25bb0cec49304dd437b368c9e5d141 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 4 Dec 2020 10:36:22 +0100 Subject: [PATCH 087/110] Use Engine from wasmer crate and document Tunables problem --- packages/vm/src/wasm_backend/store.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs index 99d668634b..342a175a90 100644 --- a/packages/vm/src/wasm_backend/store.rs +++ b/packages/vm/src/wasm_backend/store.rs @@ -1,5 +1,5 @@ -use wasmer::{Bytes, Pages, Singlepass, Store, Target, Tunables as ReferenceTunables, JIT}; -use wasmer_engine::{Engine, Tunables}; +use wasmer::{Bytes, Engine, Pages, Singlepass, Store, Target, Tunables as ReferenceTunables, JIT}; +use wasmer_engine::Tunables; // See https://github.com/wasmerio/wasmer/issues/1872 use crate::size::Size; From e8efecbac786e4d48ff4df3d2b4618baab45d1f5 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 4 Dec 2020 14:42:31 +0100 Subject: [PATCH 088/110] Update wasmer and remove explicit wasmer-compiler dependency --- Cargo.lock | 21 ++++++++++----------- contracts/burner/Cargo.lock | 21 ++++++++++----------- contracts/hackatom/Cargo.lock | 21 ++++++++++----------- contracts/queue/Cargo.lock | 21 ++++++++++----------- contracts/reflect/Cargo.lock | 21 ++++++++++----------- contracts/staking/Cargo.lock | 21 ++++++++++----------- packages/vm/Cargo.toml | 6 ++---- packages/vm/src/errors/vm_error.rs | 4 ++-- 8 files changed, 64 insertions(+), 72 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 734f75981c..474c7eee1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,7 +160,6 @@ dependencies = [ "tempfile", "thiserror", "wasmer", - "wasmer-compiler", "wasmer-engine", "wat", ] @@ -970,7 +969,7 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -991,7 +990,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "enumset", "raw-cpuid", @@ -1008,7 +1007,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "byteorder", "dynasm", @@ -1026,7 +1025,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1037,7 +1036,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "bincode", @@ -1056,7 +1055,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1073,7 +1072,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1093,7 +1092,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "object 0.22.0", "thiserror", @@ -1104,7 +1103,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cranelift-entity", "serde", @@ -1113,7 +1112,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "cc", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 71bb197895..ec952597a5 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -147,7 +147,6 @@ dependencies = [ "sha2", "thiserror", "wasmer", - "wasmer-compiler", "wasmer-engine", ] @@ -928,7 +927,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -949,7 +948,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "enumset", "raw-cpuid", @@ -966,7 +965,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "byteorder", "dynasm", @@ -984,7 +983,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "proc-macro-error", "proc-macro2", @@ -995,7 +994,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "bincode", @@ -1014,7 +1013,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1031,7 +1030,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1051,7 +1050,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "object", "thiserror", @@ -1062,7 +1061,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cranelift-entity", "serde", @@ -1071,7 +1070,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "cc", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 044867fc6d..1be7d4dcab 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -144,7 +144,6 @@ dependencies = [ "sha2", "thiserror", "wasmer", - "wasmer-compiler", "wasmer-engine", ] @@ -939,7 +938,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -960,7 +959,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "enumset", "raw-cpuid", @@ -977,7 +976,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "byteorder", "dynasm", @@ -995,7 +994,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1006,7 +1005,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "bincode", @@ -1025,7 +1024,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1042,7 +1041,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1062,7 +1061,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "object", "thiserror", @@ -1073,7 +1072,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cranelift-entity", "serde", @@ -1082,7 +1081,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "cc", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 916f69b216..ab6a7ad0ff 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -136,7 +136,6 @@ dependencies = [ "sha2", "thiserror", "wasmer", - "wasmer-compiler", "wasmer-engine", ] @@ -928,7 +927,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -949,7 +948,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "enumset", "raw-cpuid", @@ -966,7 +965,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "byteorder", "dynasm", @@ -984,7 +983,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "proc-macro-error", "proc-macro2", @@ -995,7 +994,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "bincode", @@ -1014,7 +1013,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1031,7 +1030,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1051,7 +1050,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "object", "thiserror", @@ -1062,7 +1061,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cranelift-entity", "serde", @@ -1071,7 +1070,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "cc", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index b9071e2c98..bd87557f82 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -144,7 +144,6 @@ dependencies = [ "sha2", "thiserror", "wasmer", - "wasmer-compiler", "wasmer-engine", ] @@ -938,7 +937,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -959,7 +958,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "enumset", "raw-cpuid", @@ -976,7 +975,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "byteorder", "dynasm", @@ -994,7 +993,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1005,7 +1004,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "bincode", @@ -1024,7 +1023,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1041,7 +1040,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1061,7 +1060,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "object", "thiserror", @@ -1072,7 +1071,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cranelift-entity", "serde", @@ -1081,7 +1080,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#f0a28609fdfbaeb101de8dce8f8bb5c840eb193f" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "cc", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 42d1e0557c..19a36d3754 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -144,7 +144,6 @@ dependencies = [ "sha2", "thiserror", "wasmer", - "wasmer-compiler", "wasmer-engine", ] @@ -965,7 +964,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -986,7 +985,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "enumset", "raw-cpuid", @@ -1003,7 +1002,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "byteorder", "dynasm", @@ -1021,7 +1020,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1032,7 +1031,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "bincode", @@ -1051,7 +1050,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1068,7 +1067,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1088,7 +1087,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "object", "thiserror", @@ -1099,7 +1098,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "cranelift-entity", "serde", @@ -1108,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=1.0.0-beta1#71c0d3423ad7cbe6066d121bc7ed2fc96cca46bf" +source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" dependencies = [ "backtrace", "cc", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 39005c3d46..4e858b400d 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -36,13 +36,11 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1", default-features = false, features = ["jit", "singlepass"] } -wasmer-compiler = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "1.0.0-beta1" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "5937b37064", default-features = false, features = ["jit", "singlepass"] } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "5937b37064" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api", default-features = false, features = ["jit", "singlepass"] } -# wasmer-compiler = { path = "../../../wasmer/lib/compiler" } # wasmer-engine = { path = "../../../wasmer/lib/engine" } [dev-dependencies] diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index fd1ff85db3..32f3ffb93a 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -159,8 +159,8 @@ impl From for VmError { } } -impl From for VmError { - fn from(original: wasmer_compiler::CompileError) -> Self { +impl From for VmError { + fn from(original: wasmer::CompileError) -> Self { VmError::compile_err(format!("Could not compile: {:?}", original)) } } From 7100c865db5873c2ef939b7ef254b7b7f8f2dbf3 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Sun, 6 Dec 2020 13:57:24 +0100 Subject: [PATCH 089/110] Update Wasmer to e9529c2c86 --- Cargo.lock | 20 ++++++++++---------- contracts/burner/Cargo.lock | 20 ++++++++++---------- contracts/hackatom/Cargo.lock | 20 ++++++++++---------- contracts/queue/Cargo.lock | 20 ++++++++++---------- contracts/reflect/Cargo.lock | 20 ++++++++++---------- contracts/staking/Cargo.lock | 20 ++++++++++---------- packages/vm/Cargo.toml | 4 ++-- packages/vm/src/wasm_backend/store.rs | 2 +- 8 files changed, 63 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 474c7eee1d..bb134724d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -969,7 +969,7 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -990,7 +990,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "enumset", "raw-cpuid", @@ -1007,7 +1007,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "byteorder", "dynasm", @@ -1025,7 +1025,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1036,7 +1036,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "bincode", @@ -1055,7 +1055,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1072,7 +1072,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1092,7 +1092,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "object 0.22.0", "thiserror", @@ -1103,7 +1103,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cranelift-entity", "serde", @@ -1112,7 +1112,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "cc", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index ec952597a5..a1f36c5968 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -927,7 +927,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -948,7 +948,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "enumset", "raw-cpuid", @@ -965,7 +965,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "byteorder", "dynasm", @@ -983,7 +983,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "proc-macro-error", "proc-macro2", @@ -994,7 +994,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "bincode", @@ -1013,7 +1013,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1030,7 +1030,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1050,7 +1050,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "object", "thiserror", @@ -1061,7 +1061,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cranelift-entity", "serde", @@ -1070,7 +1070,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "cc", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 1be7d4dcab..131e65f3ae 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -938,7 +938,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -959,7 +959,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "enumset", "raw-cpuid", @@ -976,7 +976,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "byteorder", "dynasm", @@ -994,7 +994,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1005,7 +1005,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "bincode", @@ -1024,7 +1024,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1041,7 +1041,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1061,7 +1061,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "object", "thiserror", @@ -1072,7 +1072,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cranelift-entity", "serde", @@ -1081,7 +1081,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "cc", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index ab6a7ad0ff..5f0913693b 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -927,7 +927,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -948,7 +948,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "enumset", "raw-cpuid", @@ -965,7 +965,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "byteorder", "dynasm", @@ -983,7 +983,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "proc-macro-error", "proc-macro2", @@ -994,7 +994,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "bincode", @@ -1013,7 +1013,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1030,7 +1030,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1050,7 +1050,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "object", "thiserror", @@ -1061,7 +1061,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cranelift-entity", "serde", @@ -1070,7 +1070,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "cc", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index bd87557f82..f2e2c9f88d 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -937,7 +937,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -958,7 +958,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "enumset", "raw-cpuid", @@ -975,7 +975,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "byteorder", "dynasm", @@ -993,7 +993,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1004,7 +1004,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "bincode", @@ -1023,7 +1023,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1040,7 +1040,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1060,7 +1060,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "object", "thiserror", @@ -1071,7 +1071,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cranelift-entity", "serde", @@ -1080,7 +1080,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "cc", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 19a36d3754..61da6a5dc9 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -964,7 +964,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -985,7 +985,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "enumset", "raw-cpuid", @@ -1002,7 +1002,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "byteorder", "dynasm", @@ -1020,7 +1020,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1031,7 +1031,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "bincode", @@ -1050,7 +1050,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1067,7 +1067,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1087,7 +1087,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "object", "thiserror", @@ -1098,7 +1098,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "cranelift-entity", "serde", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=5937b37064#5937b3706445c9ef771afb54f3ae3520c3018653" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" dependencies = [ "backtrace", "cc", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 4e858b400d..1172d5ec00 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -36,8 +36,8 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "5937b37064", default-features = false, features = ["jit", "singlepass"] } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "5937b37064" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "e9529c2c86", default-features = false, features = ["jit", "singlepass"] } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "e9529c2c86" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api", default-features = false, features = ["jit", "singlepass"] } diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs index 342a175a90..deb0fade1f 100644 --- a/packages/vm/src/wasm_backend/store.rs +++ b/packages/vm/src/wasm_backend/store.rs @@ -8,7 +8,7 @@ use super::limiting_tunables::LimitingTunables; /// Created a store with the default compiler and the given memory limit (in pages) pub fn make_store(memory_limit: Size) -> Store { let compiler = Singlepass::default(); - let engine = JIT::new(&compiler).engine(); + let engine = JIT::new(compiler).engine(); make_store_with_engine(&engine, memory_limit) } From def0ff746426ec0e57ab58b3bd022131013c3ca0 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Sun, 6 Dec 2020 14:18:43 +0100 Subject: [PATCH 090/110] Use display representation of Wasmer errors --- packages/vm/src/context.rs | 2 +- packages/vm/src/errors/vm_error.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 62a5c8e1ad..3066a106e9 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -496,7 +496,7 @@ mod test { }); match res.unwrap_err() { VmError::ResolveErr { msg, .. } => { - assert_eq!(msg, "Could not get export: Missing(\"doesnt_exist\")"); + assert_eq!(msg, "Could not get export: Missing export doesnt_exist"); } err => panic!("Unexpected error: {:?}", err), } diff --git a/packages/vm/src/errors/vm_error.rs b/packages/vm/src/errors/vm_error.rs index 32f3ffb93a..89f6c8fdd5 100644 --- a/packages/vm/src/errors/vm_error.rs +++ b/packages/vm/src/errors/vm_error.rs @@ -137,31 +137,31 @@ impl From for VmError { impl From for VmError { fn from(original: wasmer::ExportError) -> Self { - VmError::resolve_err(format!("Could not get export: {:?}", original)) + VmError::resolve_err(format!("Could not get export: {}", original)) } } impl From for VmError { fn from(original: wasmer::SerializeError) -> Self { - VmError::cache_err(format!("Could not serialize module: {:?}", original)) + VmError::cache_err(format!("Could not serialize module: {}", original)) } } impl From for VmError { fn from(original: wasmer::DeserializeError) -> Self { - VmError::cache_err(format!("Could not deserialize module: {:?}", original)) + VmError::cache_err(format!("Could not deserialize module: {}", original)) } } impl From for VmError { fn from(original: wasmer::RuntimeError) -> Self { - VmError::runtime_err(format!("Wasmer runtime error: {:?}", original)) + VmError::runtime_err(format!("Wasmer runtime error: {}", original)) } } impl From for VmError { fn from(original: wasmer::CompileError) -> Self { - VmError::compile_err(format!("Could not compile: {:?}", original)) + VmError::compile_err(format!("Could not compile: {}", original)) } } From a77ee2d5ea09ccc50e9e583d3e878fdc8a25e06a Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 7 Dec 2020 17:49:12 +0100 Subject: [PATCH 091/110] Use Cranelift for integration testing --- .circleci/config.yml | 63 +++++++++++-- .mergify.yml | 1 + Cargo.lock | 118 ++++++++++++++++++++++++ contracts/burner/Cargo.lock | 126 +++++++++++++++++++++++++- contracts/burner/Cargo.toml | 5 +- contracts/hackatom/Cargo.lock | 126 +++++++++++++++++++++++++- contracts/hackatom/Cargo.toml | 5 +- contracts/queue/Cargo.lock | 126 +++++++++++++++++++++++++- contracts/queue/Cargo.toml | 5 +- contracts/reflect/Cargo.lock | 126 +++++++++++++++++++++++++- contracts/reflect/Cargo.toml | 5 +- contracts/staking/Cargo.lock | 126 +++++++++++++++++++++++++- contracts/staking/Cargo.toml | 5 +- devtools/reborn_testing.sh | 7 +- packages/vm/Cargo.toml | 2 + packages/vm/src/wasm_backend/store.rs | 22 ++++- 16 files changed, 847 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 92176ed2d8..f28e4e668f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,6 +8,7 @@ workflows: - package_std - package_storage - package_vm + - package_vm_cranelift - contract_burner - contract_hackatom - contract_queue @@ -177,6 +178,41 @@ jobs: - target/debug/deps key: cargocache-v2-package_vm-rust:1.47.0-{{ checksum "Cargo.lock" }} + package_vm_cranelift: + docker: + - image: rust:1.47.0 + steps: + - checkout + - run: + name: Version information + 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" }} + - run: + name: Build + working_directory: ~/project/packages/vm + command: cargo build --locked --features cranelift + - run: + name: Build with iterator + working_directory: ~/project/packages/vm + command: cargo build --locked --features cranelift,iterator + - run: + name: Test + working_directory: ~/project/packages/vm + command: cargo test --locked --features cranelift + - run: + name: Test with iterator + working_directory: ~/project/packages/vm + 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_cranelift-rust:1.47.0-{{ checksum "Cargo.lock" }} + contract_burner: docker: - image: rust:1.47.0 @@ -201,8 +237,11 @@ jobs: env: RUST_BACKTRACE=1 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 @@ -250,8 +289,11 @@ jobs: env: RUST_BACKTRACE=1 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 @@ -299,8 +341,11 @@ jobs: env: RUST_BACKTRACE=1 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 @@ -348,8 +393,11 @@ jobs: env: RUST_BACKTRACE=1 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 @@ -397,8 +445,11 @@ jobs: env: RUST_BACKTRACE=1 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 @@ -511,7 +562,7 @@ jobs: - run: name: Clippy linting on vm (all feature flags) working_directory: ~/project/packages/vm - command: cargo clippy --features iterator -- -D warnings + command: cargo clippy --features cranelift,iterator -- -D warnings # # Contracts # diff --git a/.mergify.yml b/.mergify.yml index 94598385ae..1542042328 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -12,6 +12,7 @@ pull_request_rules: - "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: contract_burner" - "status-success=ci/circleci: contract_hackatom" - "status-success=ci/circleci: contract_queue" diff --git a/Cargo.lock b/Cargo.lock index bb134724d3..0d39d640d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,6 +170,50 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cranelift-bforest" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +dependencies = [ + "byteorder", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "gimli", + "log", + "regalloc", + "smallvec", + "target-lexicon", + "thiserror", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" +dependencies = [ + "cranelift-codegen-shared", + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" + [[package]] name = "cranelift-entity" version = "0.68.0" @@ -179,6 +223,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-frontend" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + [[package]] name = "crc32fast" version = "1.2.0" @@ -333,6 +389,12 @@ dependencies = [ "syn", ] +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + [[package]] name = "fnv" version = "1.0.7" @@ -365,6 +427,11 @@ name = "gimli" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] [[package]] name = "hashbrown" @@ -440,6 +507,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + [[package]] name = "mach" version = "0.3.2" @@ -672,6 +748,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 = "region" version = "2.2.0" @@ -699,6 +786,12 @@ 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" @@ -837,6 +930,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.9.3" @@ -977,6 +1076,7 @@ dependencies = [ "target-lexicon", "thiserror", "wasmer-compiler", + "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", @@ -1004,6 +1104,24 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +dependencies = [ + "cranelift-codegen", + "cranelift-frontend", + "gimli", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index a1f36c5968..73aec8ceca 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli", + "gimli 0.23.0", ] [[package]] @@ -156,6 +156,50 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cranelift-bforest" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +dependencies = [ + "byteorder", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "gimli 0.22.0", + "log", + "regalloc", + "smallvec", + "target-lexicon", + "thiserror", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" +dependencies = [ + "cranelift-codegen-shared", + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" + [[package]] name = "cranelift-entity" version = "0.68.0" @@ -165,6 +209,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-frontend" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + [[package]] name = "crc32fast" version = "1.2.1" @@ -319,6 +375,12 @@ dependencies = [ "syn", ] +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + [[package]] name = "fnv" version = "1.0.7" @@ -346,6 +408,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "gimli" version = "0.23.0" @@ -424,6 +497,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + [[package]] name = "mach" version = "0.3.2" @@ -646,6 +728,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 = "region" version = "2.2.0" @@ -673,6 +766,12 @@ 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" @@ -811,6 +910,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.9.3" @@ -935,6 +1040,7 @@ dependencies = [ "target-lexicon", "thiserror", "wasmer-compiler", + "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", @@ -962,6 +1068,24 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +dependencies = [ + "cranelift-codegen", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" diff --git a/contracts/burner/Cargo.toml b/contracts/burner/Cargo.toml index 499563953f..1f78e4da8c 100644 --- a/contracts/burner/Cargo.toml +++ b/contracts/burner/Cargo.toml @@ -22,7 +22,10 @@ incremental = false overflow-checks = true [features] -default = [] +# 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"] diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 131e65f3ae..698a609624 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli", + "gimli 0.23.0", ] [[package]] @@ -153,6 +153,50 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cranelift-bforest" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +dependencies = [ + "byteorder", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "gimli 0.22.0", + "log", + "regalloc", + "smallvec", + "target-lexicon", + "thiserror", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" +dependencies = [ + "cranelift-codegen-shared", + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" + [[package]] name = "cranelift-entity" version = "0.68.0" @@ -162,6 +206,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-frontend" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + [[package]] name = "crc32fast" version = "1.2.1" @@ -316,6 +372,12 @@ dependencies = [ "syn", ] +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + [[package]] name = "fnv" version = "1.0.7" @@ -343,6 +405,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "gimli" version = "0.23.0" @@ -435,6 +508,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + [[package]] name = "mach" version = "0.3.2" @@ -657,6 +739,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 = "region" version = "2.2.0" @@ -684,6 +777,12 @@ 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" @@ -822,6 +921,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.9.3" @@ -946,6 +1051,7 @@ dependencies = [ "target-lexicon", "thiserror", "wasmer-compiler", + "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", @@ -973,6 +1079,24 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +dependencies = [ + "cranelift-codegen", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" diff --git a/contracts/hackatom/Cargo.toml b/contracts/hackatom/Cargo.toml index 19e9ac26a7..dd7c422bcf 100644 --- a/contracts/hackatom/Cargo.toml +++ b/contracts/hackatom/Cargo.toml @@ -22,7 +22,10 @@ incremental = false overflow-checks = true [features] -default = [] +# 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"] diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 5f0913693b..d815c5ecf0 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli", + "gimli 0.23.0", ] [[package]] @@ -145,6 +145,50 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cranelift-bforest" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +dependencies = [ + "byteorder", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "gimli 0.22.0", + "log", + "regalloc", + "smallvec", + "target-lexicon", + "thiserror", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" +dependencies = [ + "cranelift-codegen-shared", + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" + [[package]] name = "cranelift-entity" version = "0.68.0" @@ -154,6 +198,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-frontend" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + [[package]] name = "crc32fast" version = "1.2.1" @@ -308,6 +364,12 @@ dependencies = [ "syn", ] +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + [[package]] name = "fnv" version = "1.0.7" @@ -335,6 +397,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "gimli" version = "0.23.0" @@ -413,6 +486,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + [[package]] name = "mach" version = "0.3.2" @@ -646,6 +728,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 = "region" version = "2.2.0" @@ -673,6 +766,12 @@ 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" @@ -811,6 +910,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.9.3" @@ -935,6 +1040,7 @@ dependencies = [ "target-lexicon", "thiserror", "wasmer-compiler", + "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", @@ -962,6 +1068,24 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +dependencies = [ + "cranelift-codegen", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" diff --git a/contracts/queue/Cargo.toml b/contracts/queue/Cargo.toml index 561ceb385b..138007708a 100644 --- a/contracts/queue/Cargo.toml +++ b/contracts/queue/Cargo.toml @@ -22,7 +22,10 @@ incremental = false overflow-checks = true [features] -default = [] +# 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"] diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index f2e2c9f88d..0bb7ea4f72 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli", + "gimli 0.23.0", ] [[package]] @@ -153,6 +153,50 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cranelift-bforest" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +dependencies = [ + "byteorder", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "gimli 0.22.0", + "log", + "regalloc", + "smallvec", + "target-lexicon", + "thiserror", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" +dependencies = [ + "cranelift-codegen-shared", + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" + [[package]] name = "cranelift-entity" version = "0.68.0" @@ -162,6 +206,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-frontend" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + [[package]] name = "crc32fast" version = "1.2.1" @@ -316,6 +372,12 @@ dependencies = [ "syn", ] +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + [[package]] name = "fnv" version = "1.0.7" @@ -343,6 +405,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "gimli" version = "0.23.0" @@ -421,6 +494,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + [[package]] name = "mach" version = "0.3.2" @@ -656,6 +738,17 @@ 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" @@ -683,6 +776,12 @@ 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" @@ -821,6 +920,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.9.3" @@ -945,6 +1050,7 @@ dependencies = [ "target-lexicon", "thiserror", "wasmer-compiler", + "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", @@ -972,6 +1078,24 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +dependencies = [ + "cranelift-codegen", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" diff --git a/contracts/reflect/Cargo.toml b/contracts/reflect/Cargo.toml index 49b620663f..40b374771d 100644 --- a/contracts/reflect/Cargo.toml +++ b/contracts/reflect/Cargo.toml @@ -24,7 +24,10 @@ incremental = false overflow-checks = true [features] -default = [] +# 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"] diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 61da6a5dc9..89f715727f 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" dependencies = [ - "gimli", + "gimli 0.23.0", ] [[package]] @@ -153,6 +153,50 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cranelift-bforest" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +dependencies = [ + "byteorder", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "gimli 0.22.0", + "log", + "regalloc", + "smallvec", + "target-lexicon", + "thiserror", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" +dependencies = [ + "cranelift-codegen-shared", + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" + [[package]] name = "cranelift-entity" version = "0.68.0" @@ -162,6 +206,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-frontend" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + [[package]] name = "crc32fast" version = "1.2.1" @@ -322,6 +378,12 @@ dependencies = [ "syn", ] +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + [[package]] name = "fnv" version = "1.0.7" @@ -349,6 +411,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "gimli" version = "0.23.0" @@ -427,6 +500,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + [[package]] name = "mach" version = "0.3.2" @@ -649,6 +731,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 = "region" version = "2.2.0" @@ -676,6 +769,12 @@ 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" @@ -835,6 +934,12 @@ dependencies = [ "syn", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "staking" version = "0.0.0" @@ -972,6 +1077,7 @@ dependencies = [ "target-lexicon", "thiserror", "wasmer-compiler", + "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", @@ -999,6 +1105,24 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "wasmer-compiler-cranelift" +version = "1.0.0-beta1" +source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +dependencies = [ + "cranelift-codegen", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" diff --git a/contracts/staking/Cargo.toml b/contracts/staking/Cargo.toml index 283a1759b8..9f03f1f02d 100644 --- a/contracts/staking/Cargo.toml +++ b/contracts/staking/Cargo.toml @@ -22,7 +22,10 @@ incremental = false overflow-checks = true [features] -default = [] +# 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"] diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh index 29aa362cc2..2a7c9c9b07 100755 --- a/devtools/reborn_testing.sh +++ b/devtools/reborn_testing.sh @@ -6,6 +6,8 @@ command -v shellcheck > /dev/null && shellcheck "$0" (cd packages/vm \ && cargo check --tests \ && cargo check --features iterator --tests \ + && cargo check --features cranelift --tests \ + && cargo check --features cranelift,iterator --tests \ && cargo test --features iterator calls:: \ && cargo test --features iterator checksum:: \ && cargo test --features iterator context:: \ @@ -25,5 +27,8 @@ command -v shellcheck > /dev/null && shellcheck "$0" # Contracts for contract_dir in contracts/*/; do - (cd "$contract_dir" && cargo wasm && cargo integration-test) || break; + # 1. Build Wasm + # 2. Run in Cranelift + # 3. Run in Singlepass (fails on Windows) + (cd "$contract_dir" && cargo wasm && cargo integration-test && cargo integration-test --no-default-features) || break; done diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 1172d5ec00..d5c1482ce9 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -23,6 +23,8 @@ backtraces = [] 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"] [dependencies] clru = "0.2.0" diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs index deb0fade1f..3fc6757b52 100644 --- a/packages/vm/src/wasm_backend/store.rs +++ b/packages/vm/src/wasm_backend/store.rs @@ -1,4 +1,8 @@ -use wasmer::{Bytes, Engine, Pages, Singlepass, Store, Target, Tunables as ReferenceTunables, JIT}; +#[cfg(feature = "cranelift")] +use wasmer::Cranelift; +#[cfg(not(feature = "cranelift"))] +use wasmer::Singlepass; +use wasmer::{Bytes, Engine, Pages, Store, Target, Tunables as ReferenceTunables, JIT}; use wasmer_engine::Tunables; // See https://github.com/wasmerio/wasmer/issues/1872 use crate::size::Size; @@ -7,9 +11,19 @@ use super::limiting_tunables::LimitingTunables; /// Created a store with the default compiler and the given memory limit (in pages) pub fn make_store(memory_limit: Size) -> Store { - let compiler = Singlepass::default(); - let engine = JIT::new(compiler).engine(); - make_store_with_engine(&engine, memory_limit) + #[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 pages) From 81d281bf10d05a3e7463e3866831f4ba67dcfdfd Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 8 Dec 2020 07:52:54 +0100 Subject: [PATCH 092/110] Update Wasmer to 9fc32dfd0f3 --- Cargo.lock | 22 +++++++++++----------- contracts/burner/Cargo.lock | 22 +++++++++++----------- contracts/hackatom/Cargo.lock | 22 +++++++++++----------- contracts/queue/Cargo.lock | 22 +++++++++++----------- contracts/reflect/Cargo.lock | 22 +++++++++++----------- contracts/staking/Cargo.lock | 22 +++++++++++----------- packages/vm/Cargo.toml | 4 ++-- 7 files changed, 68 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d39d640d0..0041687c54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1068,7 +1068,7 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1090,7 +1090,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "enumset", "raw-cpuid", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1125,7 +1125,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "byteorder", "dynasm", @@ -1143,7 +1143,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "bincode", @@ -1173,7 +1173,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1190,7 +1190,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1210,7 +1210,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "object 0.22.0", "thiserror", @@ -1221,7 +1221,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-entity", "serde", @@ -1230,7 +1230,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "cc", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 73aec8ceca..59bc3aa7e0 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -1032,7 +1032,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1054,7 +1054,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "enumset", "raw-cpuid", @@ -1071,7 +1071,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "byteorder", "dynasm", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1118,7 +1118,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "bincode", @@ -1137,7 +1137,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "object", "thiserror", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-entity", "serde", @@ -1194,7 +1194,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "cc", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 698a609624..5dca2ea16c 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -1043,7 +1043,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1065,7 +1065,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "enumset", "raw-cpuid", @@ -1082,7 +1082,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1100,7 +1100,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "byteorder", "dynasm", @@ -1118,7 +1118,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1129,7 +1129,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "bincode", @@ -1148,7 +1148,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1165,7 +1165,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "object", "thiserror", @@ -1196,7 +1196,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-entity", "serde", @@ -1205,7 +1205,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "cc", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index d815c5ecf0..cc95aac737 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -1032,7 +1032,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1054,7 +1054,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "enumset", "raw-cpuid", @@ -1071,7 +1071,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "byteorder", "dynasm", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1118,7 +1118,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "bincode", @@ -1137,7 +1137,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "object", "thiserror", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-entity", "serde", @@ -1194,7 +1194,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "cc", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 0bb7ea4f72..7f546a89cf 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -1042,7 +1042,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1064,7 +1064,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "enumset", "raw-cpuid", @@ -1081,7 +1081,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1099,7 +1099,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "byteorder", "dynasm", @@ -1117,7 +1117,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "bincode", @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1164,7 +1164,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1184,7 +1184,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "object", "thiserror", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-entity", "serde", @@ -1204,7 +1204,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "cc", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 89f715727f..6fd58e3041 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -1069,7 +1069,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1091,7 +1091,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "enumset", "raw-cpuid", @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1126,7 +1126,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "byteorder", "dynasm", @@ -1144,7 +1144,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1155,7 +1155,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "bincode", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1191,7 +1191,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1211,7 +1211,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "object", "thiserror", @@ -1222,7 +1222,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "cranelift-entity", "serde", @@ -1231,7 +1231,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e9529c2c86#e9529c2c868c6c4d7f39bad2d2194682066a9522" +source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" dependencies = [ "backtrace", "cc", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index d5c1482ce9..1e04f75fab 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -38,8 +38,8 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "e9529c2c86", default-features = false, features = ["jit", "singlepass"] } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "e9529c2c86" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "9fc32dfd0f3", default-features = false, features = ["jit", "singlepass"] } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "9fc32dfd0f3" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api", default-features = false, features = ["jit", "singlepass"] } From 48730f35eef420eda5921cec8e0c4abaf1ec443b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 8 Dec 2020 07:54:35 +0100 Subject: [PATCH 093/110] Run all tests in local testing --- devtools/reborn_testing.sh | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh index 2a7c9c9b07..34522507ac 100755 --- a/devtools/reborn_testing.sh +++ b/devtools/reborn_testing.sh @@ -8,21 +8,7 @@ command -v shellcheck > /dev/null && shellcheck "$0" && cargo check --features iterator --tests \ && cargo check --features cranelift --tests \ && cargo check --features cranelift,iterator --tests \ - && cargo test --features iterator calls:: \ - && cargo test --features iterator checksum:: \ - && cargo test --features iterator context:: \ - && cargo test --features iterator conversion:: \ - && cargo test --features iterator compatibility \ - && cargo test --features iterator errors:: \ - && cargo test --features iterator features:: \ - && cargo test --features iterator ffi:: \ - && cargo test --features iterator limiting_tunables:: \ - && cargo test --features iterator memory:: \ - && cargo test --features iterator modules:: \ - && cargo test --features iterator imports:: \ - && cargo test --features iterator testing:: \ - && cargo test --features iterator instance:: \ - && cargo test --features iterator cache:: \ + && cargo test --features iterator \ && cargo clippy --features iterator -- -D warnings) # Contracts From 63e7207cf67230b0bace1815df50aeca59360cd4 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 8 Dec 2020 07:59:42 +0100 Subject: [PATCH 094/110] Remove usages of Rust nightly --- README.md | 2 +- devtools/set_version.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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 From 1d9dae1fc0ac30bb1ce1d91618ab10b36073e4e3 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 8 Dec 2020 09:07:38 +0100 Subject: [PATCH 095/110] Remove temporary testing script --- devtools/reborn_testing.sh | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100755 devtools/reborn_testing.sh diff --git a/devtools/reborn_testing.sh b/devtools/reborn_testing.sh deleted file mode 100755 index 34522507ac..0000000000 --- a/devtools/reborn_testing.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -set -o errexit -o nounset -o pipefail -command -v shellcheck > /dev/null && shellcheck "$0" - -# Temporary incomplete testing command for development -(cd packages/vm \ - && cargo check --tests \ - && cargo check --features iterator --tests \ - && cargo check --features cranelift --tests \ - && cargo check --features cranelift,iterator --tests \ - && cargo test --features iterator \ - && cargo clippy --features iterator -- -D warnings) - -# Contracts -for contract_dir in contracts/*/; do - # 1. Build Wasm - # 2. Run in Cranelift - # 3. Run in Singlepass (fails on Windows) - (cd "$contract_dir" && cargo wasm && cargo integration-test && cargo integration-test --no-default-features) || break; -done From 10fdde0b1c70a3129f2666e021eeebc5cf92a145 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 8 Dec 2020 09:09:22 +0100 Subject: [PATCH 096/110] Fix cosmwasm-std version after merge conflict --- packages/vm/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 1e04f75fab..c09081eb44 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -29,7 +29,7 @@ cranelift = ["wasmer/cranelift"] [dependencies] clru = "0.2.0" # Uses the path when built locally; uses the given version from crates.io when published -cosmwasm-std = { path = "../std", version = "0.12.0-alpha3" } +cosmwasm-std = { path = "../std", version = "0.12.0" } hex = "0.4" memmap = "0.7" parity-wasm = "0.42" From 6004449d3bfcaebc6daeff00de128b7299e7981b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 8 Dec 2020 09:13:56 +0100 Subject: [PATCH 097/110] Update VM's Testing docs --- packages/vm/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/vm/README.md b/packages/vm/README.md index 5d8f4002d1..93dc7a1c66 100644 --- a/packages/vm/README.md +++ b/packages/vm/README.md @@ -43,9 +43,13 @@ docker run --rm -v "$(pwd)":/code \ ## Testing +By default, this repository is built and tested with the singlepass backend. +You can enable the `cranelift` feature to override the default backend with Cranelift + ```sh cd packages/vm cargo test --features iterator +cargo test --features cranelift,iterator ``` ## License From fde0d3249355d7ac1875c344b411ca04e991a406 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 8 Dec 2020 09:21:32 +0100 Subject: [PATCH 098/110] Avoid double references to Memory --- packages/vm/src/memory.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vm/src/memory.rs b/packages/vm/src/memory.rs index 47165d860d..a689497ff1 100644 --- a/packages/vm/src/memory.rs +++ b/packages/vm/src/memory.rs @@ -37,7 +37,7 @@ pub fn read_region(memory: &wasmer::Memory, ptr: u32, max_length: usize) -> VmRe ); } - match WasmPtr::::new(region.offset).deref(&memory, 0, region.length) { + 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]`: // https://github.com/wasmerio/wasmer/blob/0.13.1/lib/wasi/src/syscalls/mod.rs#L79-L81 @@ -81,7 +81,7 @@ pub fn write_region(memory: &wasmer::Memory, ptr: u32, data: &[u8]) -> VmResult< if data.len() > region_capacity { return Err(CommunicationError::region_too_small(region_capacity, data.len()).into()); } - match WasmPtr::::new(region.offset).deref(&memory, 0, region.capacity) { + 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]`: // https://github.com/wasmerio/wasmer/blob/0.13.1/lib/wasi/src/syscalls/mod.rs#L79-L81 @@ -89,7 +89,7 @@ pub fn write_region(memory: &wasmer::Memory, ptr: u32, data: &[u8]) -> VmResult< cells[i].set(data[i]) } region.length = data.len() as u32; - set_region(&memory, ptr, region)?; + set_region(memory, ptr, region)?; Ok(()) }, None => Err(CommunicationError::deref_err(region.offset, format!( From 0692deb8cf392bd2156e524d8ce16297e3b93c2a Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 9 Dec 2020 11:06:13 +0100 Subject: [PATCH 099/110] Update Wasmer to e1c92737 --- Cargo.lock | 22 +++++++++++----------- contracts/burner/Cargo.lock | 22 +++++++++++----------- contracts/hackatom/Cargo.lock | 22 +++++++++++----------- contracts/queue/Cargo.lock | 22 +++++++++++----------- contracts/reflect/Cargo.lock | 22 +++++++++++----------- contracts/staking/Cargo.lock | 22 +++++++++++----------- packages/vm/Cargo.toml | 4 ++-- 7 files changed, 68 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65982b23f1..9d7d9742c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1068,7 +1068,7 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1090,7 +1090,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "enumset", "raw-cpuid", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1125,7 +1125,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "byteorder", "dynasm", @@ -1143,7 +1143,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "bincode", @@ -1173,7 +1173,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1190,7 +1190,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1210,7 +1210,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "object 0.22.0", "thiserror", @@ -1221,7 +1221,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-entity", "serde", @@ -1230,7 +1230,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "cc", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 4c62e32793..30f31a5f2d 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -1032,7 +1032,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1054,7 +1054,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "enumset", "raw-cpuid", @@ -1071,7 +1071,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "byteorder", "dynasm", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1118,7 +1118,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "bincode", @@ -1137,7 +1137,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "object", "thiserror", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-entity", "serde", @@ -1194,7 +1194,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "cc", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 01822ce124..64baf20efa 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -1043,7 +1043,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1065,7 +1065,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "enumset", "raw-cpuid", @@ -1082,7 +1082,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1100,7 +1100,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "byteorder", "dynasm", @@ -1118,7 +1118,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1129,7 +1129,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "bincode", @@ -1148,7 +1148,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1165,7 +1165,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "object", "thiserror", @@ -1196,7 +1196,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-entity", "serde", @@ -1205,7 +1205,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "cc", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index fa19f00317..a740d7dda9 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -1032,7 +1032,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1054,7 +1054,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "enumset", "raw-cpuid", @@ -1071,7 +1071,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "byteorder", "dynasm", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1118,7 +1118,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "bincode", @@ -1137,7 +1137,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "object", "thiserror", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-entity", "serde", @@ -1194,7 +1194,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "cc", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index d1f8f1aaa8..db694303ea 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -1042,7 +1042,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1064,7 +1064,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "enumset", "raw-cpuid", @@ -1081,7 +1081,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1099,7 +1099,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "byteorder", "dynasm", @@ -1117,7 +1117,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "bincode", @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1164,7 +1164,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1184,7 +1184,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "object", "thiserror", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-entity", "serde", @@ -1204,7 +1204,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "cc", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 76688f6d0b..d2dc5c6a77 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -1069,7 +1069,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1091,7 +1091,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "enumset", "raw-cpuid", @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1126,7 +1126,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "byteorder", "dynasm", @@ -1144,7 +1144,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1155,7 +1155,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "bincode", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1191,7 +1191,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1211,7 +1211,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "object", "thiserror", @@ -1222,7 +1222,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "cranelift-entity", "serde", @@ -1231,7 +1231,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=9fc32dfd0f3#9fc32dfd0f321fc359a7858a49588d1c952e67f8" +source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" dependencies = [ "backtrace", "cc", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 6f5d0df6f6..182b034641 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -38,8 +38,8 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "9fc32dfd0f3", default-features = false, features = ["jit", "singlepass"] } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "9fc32dfd0f3" } +wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "e1c92737", default-features = false, features = ["jit", "singlepass"] } +wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "e1c92737" } # Wasmer local (used for quick local debugging or patching) # wasmer = { path = "../../../wasmer/lib/api", default-features = false, features = ["jit", "singlepass"] } From 707cc880f6966ef63eb20da3ec2c5a39502f390c Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 9 Dec 2020 15:17:51 +0100 Subject: [PATCH 100/110] Fix job name package_vm_singlepass -> package_vm --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b032483cea..a54c75fc4a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,8 +18,8 @@ workflows: - clippy - benchmarking: requires: + - package_vm - package_vm_cranelift - - package_vm_singlepass filters: branches: only: From 3a602a7862c17a770a647fe08d27993ebcad0571 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 9 Dec 2020 15:49:08 +0100 Subject: [PATCH 101/110] Set RUST_BACKTRACE in benchmarking job and fix gas issue in CI --- .circleci/config.yml | 2 ++ packages/vm/benches/main.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a54c75fc4a..8003775578 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -628,6 +628,8 @@ jobs: benchmarking: docker: - image: rust:1.47.0 + environment: + RUST_BACKTRACE: 1 steps: - checkout - run: diff --git a/packages/vm/benches/main.rs b/packages/vm/benches/main.rs index 19403c4fe0..fa4b91f406 100644 --- a/packages/vm/benches/main.rs +++ b/packages/vm/benches/main.rs @@ -38,7 +38,7 @@ 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, + gas_limit: 500_000_000_000, ..DEFAULT_INSTANCE_OPTIONS }; let mut instance = Instance::from_code(CONTRACT, backend, much_gas).unwrap(); @@ -55,7 +55,7 @@ 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, + gas_limit: 500_000_000_000, ..DEFAULT_INSTANCE_OPTIONS }; let mut instance = Instance::from_code(CONTRACT, backend, much_gas).unwrap(); From c74d978b4582b016797d6ba3373ed652c1509427 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 9 Dec 2020 17:44:51 +0100 Subject: [PATCH 102/110] Add ref_to_u32 --- packages/vm/src/conversion.rs | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) 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); From 54dacc9fbb4c3b58a768ddf462af2ca8fb6bf00b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 9 Dec 2020 17:56:58 +0100 Subject: [PATCH 103/110] Use ref_to_u32 for Wasmer's Value --- Cargo.lock | 22 +++++++++++----------- contracts/burner/Cargo.lock | 22 +++++++++++----------- contracts/hackatom/Cargo.lock | 22 +++++++++++----------- contracts/queue/Cargo.lock | 22 +++++++++++----------- contracts/reflect/Cargo.lock | 22 +++++++++++----------- contracts/staking/Cargo.lock | 22 +++++++++++----------- packages/vm/Cargo.toml | 4 ++-- packages/vm/src/calls.rs | 3 ++- packages/vm/src/context.rs | 3 ++- packages/vm/src/imports.rs | 8 ++++---- packages/vm/src/instance.rs | 14 +++++++------- 11 files changed, 83 insertions(+), 81 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a599566f6..ac3dc800e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1357,7 +1357,7 @@ checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1379,7 +1379,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "enumset", "raw-cpuid", @@ -1396,7 +1396,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1414,7 +1414,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "byteorder", "dynasm", @@ -1432,7 +1432,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1443,7 +1443,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "bincode", @@ -1462,7 +1462,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1479,7 +1479,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1499,7 +1499,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "object 0.22.0", "thiserror", @@ -1510,7 +1510,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-entity", "serde", @@ -1519,7 +1519,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "cc", diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 30f31a5f2d..bda9e1ecb4 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -1032,7 +1032,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1054,7 +1054,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "enumset", "raw-cpuid", @@ -1071,7 +1071,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "byteorder", "dynasm", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1118,7 +1118,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "bincode", @@ -1137,7 +1137,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "object", "thiserror", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-entity", "serde", @@ -1194,7 +1194,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "cc", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 64baf20efa..fe166554c7 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -1043,7 +1043,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1065,7 +1065,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "enumset", "raw-cpuid", @@ -1082,7 +1082,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1100,7 +1100,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "byteorder", "dynasm", @@ -1118,7 +1118,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1129,7 +1129,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "bincode", @@ -1148,7 +1148,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1165,7 +1165,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "object", "thiserror", @@ -1196,7 +1196,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-entity", "serde", @@ -1205,7 +1205,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "cc", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index a740d7dda9..75af29e165 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -1032,7 +1032,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1054,7 +1054,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "enumset", "raw-cpuid", @@ -1071,7 +1071,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "byteorder", "dynasm", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1118,7 +1118,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "bincode", @@ -1137,7 +1137,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "object", "thiserror", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-entity", "serde", @@ -1194,7 +1194,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "cc", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index db694303ea..451cc67c0a 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -1042,7 +1042,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1064,7 +1064,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "enumset", "raw-cpuid", @@ -1081,7 +1081,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1099,7 +1099,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "byteorder", "dynasm", @@ -1117,7 +1117,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "bincode", @@ -1147,7 +1147,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1164,7 +1164,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1184,7 +1184,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "object", "thiserror", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-entity", "serde", @@ -1204,7 +1204,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "cc", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index d2dc5c6a77..3a8c7ca2ea 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -1069,7 +1069,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1091,7 +1091,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "enumset", "raw-cpuid", @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1126,7 +1126,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "byteorder", "dynasm", @@ -1144,7 +1144,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1155,7 +1155,7 @@ dependencies = [ [[package]] name = "wasmer-engine" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "bincode", @@ -1174,7 +1174,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1191,7 +1191,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1211,7 +1211,7 @@ dependencies = [ [[package]] name = "wasmer-object" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "object", "thiserror", @@ -1222,7 +1222,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "cranelift-entity", "serde", @@ -1231,7 +1231,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "1.0.0-beta1" -source = "git+https://github.com/wasmerio/wasmer?rev=e1c92737#e1c92737820d9afbd2f1920ed22e958910cbad00" +source = "git+https://github.com/wasmerio/wasmer?rev=df3a21160a9a#df3a21160a9a9353db5913b521b66e9724ab8fef" dependencies = [ "backtrace", "cc", diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 1800c4bae1..078b1eaee0 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -42,8 +42,8 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "e1c92737", default-features = false, features = ["jit", "singlepass"] } -wasmer-engine = { git = "https://github.com/wasmerio/wasmer", rev = "e1c92737" } +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"] } diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs index 3e7990fc85..9fd80a7011 100644 --- a/packages/vm/src/calls.rs +++ b/packages/vm/src/calls.rs @@ -8,6 +8,7 @@ use cosmwasm_std::{ }; use crate::backend::{Api, Querier, Storage}; +use crate::conversion::ref_to_u32; use crate::errors::{VmError, VmResult}; use crate::instance::Instance; use crate::serde::{from_slice, to_vec}; @@ -153,7 +154,7 @@ fn call_raw( arg_region_ptrs.push(region_ptr.into()); } let result = instance.call_function(name, &arg_region_ptrs)?; - let res_region_ptr = result[0].unwrap_i32() as u32; + 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 index 3066a106e9..ba5aa5cb32 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -284,6 +284,7 @@ fn account_for_externally_used_gas_impl( 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}; @@ -462,7 +463,7 @@ mod test { let ptr = env .with_func_from_context::<_, _>("allocate", |alloc_func| { let result = alloc_func.call(&[10u32.into()])?; - let ptr = result[0].unwrap_i32() as u32; + let ptr = ref_to_u32(&result[0])?; Ok(ptr) }) .unwrap(); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 5fd9b84ea2..d117d11b5f 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -9,7 +9,7 @@ use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr}; use crate::backend::{Api, BackendError, Querier, Storage}; use crate::context::{process_gas_info, Env}; -use crate::conversion::to_u32; +use crate::conversion::{ref_to_u32, to_u32}; use crate::errors::{CommunicationError, VmError, VmResult}; #[cfg(feature = "iterator")] use crate::memory::maybe_read_region; @@ -201,7 +201,7 @@ fn write_to_contract(env: &Env, input: &[u8]) -> V let target_ptr = env.with_func_from_context::<_, u32>("allocate", |allocate| { let out_size = to_u32(input.len())?; let result = allocate.call(&[out_size.into()])?; - let ptr = result[0].unwrap_i32() as u32; + let ptr = ref_to_u32(&result[0])?; if ptr == 0 { return Err(CommunicationError::zero_address().into()); } @@ -350,7 +350,7 @@ mod test { let result = alloc_func .call(&[(data.len() as u32).into()]) .expect("error calling allocate"); - let ptr = result[0].unwrap_i32() as u32; + let ptr = ref_to_u32(&result[0])?; Ok(ptr) }) .unwrap(); @@ -366,7 +366,7 @@ mod test { let result = allocate .call(&[capacity.into()]) .expect("error calling allocate"); - let region_ptr = result[0].unwrap_i32() as u32; + let region_ptr = ref_to_u32(&result[0]).expect("error converting result"); region_ptr } diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 66fce48f51..9bc3dfa76c 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -8,7 +8,7 @@ use wasmer::{ use crate::backend::{Api, Backend, Querier, Storage}; use crate::context::{move_into_context, move_out_of_context, Env}; -use crate::conversion::to_u32; +use crate::conversion::{ref_to_u32, to_u32}; use crate::errors::{CommunicationError, VmError, VmResult}; use crate::features::required_features_from_wasmer_instance; use crate::imports::{ @@ -123,8 +123,8 @@ where env_imports.insert( "canonicalize_address", Function::new_with_env(store, &i32i32_to_i32, env.clone(), move |env, args| { - let source_ptr = args[0].unwrap_i32() as u32; - let destination_ptr = args[1].unwrap_i32() as u32; + 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()]) @@ -138,8 +138,8 @@ where env_imports.insert( "humanize_address", Function::new_with_env(store, &i32i32_to_i32, env.clone(), move |env, args| { - let source_ptr = args[0].unwrap_i32() as u32; - let destination_ptr = args[1].unwrap_i32() as u32; + 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()]) }), @@ -152,7 +152,7 @@ where env_imports.insert( "debug", Function::new_with_env(store, &i32_to_void, env.clone(), move |env, args| { - let message_ptr = args[0].unwrap_i32() as u32; + let message_ptr = ref_to_u32(&args[0])?; if print_debug { print_debug_message(&env, message_ptr)?; } @@ -275,7 +275,7 @@ where /// in the Wasm address space to the created Region object. pub(crate) fn allocate(&mut self, size: usize) -> VmResult { let ret = self.call_function("allocate", &[to_u32(size)?.into()])?; - let ptr = ret.as_ref()[0].unwrap_i32() as u32; + let ptr = ref_to_u32(&ret.as_ref()[0])?; if ptr == 0 { return Err(CommunicationError::zero_address().into()); } From 6551573f921eb3a9260a34a6dc49cba86e9e7154 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 10 Dec 2020 15:28:12 +0100 Subject: [PATCH 104/110] Make memory limit optional to avoid the need for a fake limit --- packages/vm/src/cache.rs | 5 ++- packages/vm/src/context.rs | 2 +- packages/vm/src/imports.rs | 2 +- packages/vm/src/instance.rs | 2 +- packages/vm/src/modules/file_system_cache.rs | 4 +-- packages/vm/src/modules/in_memory_cache.rs | 2 +- packages/vm/src/wasm_backend/compile.rs | 4 +-- packages/vm/src/wasm_backend/gas.rs | 2 +- packages/vm/src/wasm_backend/store.rs | 38 ++++++++++++-------- 9 files changed, 34 insertions(+), 27 deletions(-) diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index ff730893c6..2d94d9689b 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -88,8 +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)?; - const MEMORY_LIMIT: Size = Size::mebi(16); - let module = compile(wasm, MEMORY_LIMIT)?; + let module = compile(wasm, None)?; self.fs_cache.store(&checksum, &module)?; Ok(checksum) } @@ -137,7 +136,7 @@ where // Re-compile module from wasm let wasm = self.load_wasm(checksum)?; self.stats.misses += 1; - let module = compile(&wasm, options.memory_limit)?; + 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)?; diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index ba5aa5cb32..a1ad848e92 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -317,7 +317,7 @@ mod test { fn make_instance() -> (Env, Box) { let env = Env::new(GAS_LIMIT); - let module = compile(&CONTRACT, TESTING_MEMORY_LIMIT).unwrap(); + 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]); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index d117d11b5f..07139568f0 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -303,7 +303,7 @@ mod test { fn make_instance() -> (Env, Box) { let env = Env::new(GAS_LIMIT); - let module = compile(&CONTRACT, TESTING_MEMORY_LIMIT).unwrap(); + 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]); diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 9bc3dfa76c..f36327d335 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -68,7 +68,7 @@ where backend: Backend, options: InstanceOptions, ) -> VmResult { - let module = compile(code, options.memory_limit)?; + let module = compile(code, Some(options.memory_limit))?; Instance::from_module(&module, backend, options.gas_limit, options.print_debug) } diff --git a/packages/vm/src/modules/file_system_cache.rs b/packages/vm/src/modules/file_system_cache.rs index 21c3a5cbb9..3a33808df8 100644 --- a/packages/vm/src/modules/file_system_cache.rs +++ b/packages/vm/src/modules/file_system_cache.rs @@ -92,7 +92,7 @@ impl FileSystemCache { let mmap = unsafe { Mmap::map(&file) } .map_err(|e| VmError::cache_err(format!("Mmap error: {}", e)))?; - let store = make_store_headless(memory_limit); + let store = make_store_headless(Some(memory_limit)); let module = unsafe { Module::deserialize(&store, &mmap[..]) }?; Ok(Some(module)) } @@ -140,7 +140,7 @@ mod tests { ) .unwrap(); let checksum = Checksum::generate(&wasm); - let module = compile(&wasm, TESTING_MEMORY_LIMIT).unwrap(); + let module = compile(&wasm, Some(TESTING_MEMORY_LIMIT)).unwrap(); // Module does not exist let cached = cache.load(&checksum, TESTING_MEMORY_LIMIT).unwrap(); diff --git a/packages/vm/src/modules/in_memory_cache.rs b/packages/vm/src/modules/in_memory_cache.rs index 38ce2cf378..967f8c4800 100644 --- a/packages/vm/src/modules/in_memory_cache.rs +++ b/packages/vm/src/modules/in_memory_cache.rs @@ -54,7 +54,7 @@ mod tests { ) .unwrap(); let checksum = Checksum::generate(&wasm); - let module = compile(&wasm, TESTING_MEMORY_LIMIT).unwrap(); + let module = compile(&wasm, Some(TESTING_MEMORY_LIMIT)).unwrap(); // Module does not exist let cached = cache.load(&checksum).unwrap(); diff --git a/packages/vm/src/wasm_backend/compile.rs b/packages/vm/src/wasm_backend/compile.rs index 1d1f021b26..e88526497c 100644 --- a/packages/vm/src/wasm_backend/compile.rs +++ b/packages/vm/src/wasm_backend/compile.rs @@ -8,8 +8,8 @@ use super::store::make_store; // use crate::middleware::DeterministicMiddleware; /// Compiles a given Wasm bytecode into a module. -/// The given memory limit (in Wasm pages) is used when memories are created. -pub fn compile(code: &[u8], memory_limit: Size) -> VmResult { +/// 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 index 51cda568fe..3ab52d0f00 100644 --- a/packages/vm/src/wasm_backend/gas.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -80,7 +80,7 @@ mod tests { fn instantiate(code: &[u8]) -> (Env, Box) { let env = Env::new(GAS_LIMIT); - let module = compile(code, TESTING_MEMORY_LIMIT).unwrap(); + let module = compile(code, Some(TESTING_MEMORY_LIMIT)).unwrap(); let import_obj = imports! { "env" => {}, }; let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs index 3fc6757b52..9db5e12094 100644 --- a/packages/vm/src/wasm_backend/store.rs +++ b/packages/vm/src/wasm_backend/store.rs @@ -2,15 +2,19 @@ use wasmer::Cranelift; #[cfg(not(feature = "cranelift"))] use wasmer::Singlepass; -use wasmer::{Bytes, Engine, Pages, Store, Target, Tunables as ReferenceTunables, JIT}; -use wasmer_engine::Tunables; // See https://github.com/wasmerio/wasmer/issues/1872 +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 pages) -pub fn make_store(memory_limit: Size) -> Store { +/// 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(); @@ -26,19 +30,23 @@ pub fn make_store(memory_limit: Size) -> Store { } } -/// Created a store with no compiler and the given memory limit (in pages) -pub fn make_store_headless(memory_limit: Size) -> Store { +/// Created a store with no compiler and the given memory limit (in bytes) +/// If memory_limit is None, no limit is applied. +pub fn make_store_headless(memory_limit: Option) -> Store { let engine = JIT::headless().engine(); make_store_with_engine(&engine, memory_limit) } -fn make_store_with_engine(engine: &dyn Engine, memory_limit: Size) -> Store { - let pages = Pages::from(Bytes(memory_limit.0)); - let tunables = make_tunables(pages); - Store::new_with_tunables(engine, tunables) -} - -fn make_tunables(memory_limit: Pages) -> impl Tunables { - let base = ReferenceTunables::for_target(&Target::default()); - LimitingTunables::new(base, 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), + } } From 2f8f86dfd7c3e4ad0d31a82d9dfa43b06c0ca5e6 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 10 Dec 2020 15:58:14 +0100 Subject: [PATCH 105/110] Use a single immutable env reference --- packages/vm/src/context.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index a1ad848e92..612d3f79d6 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -255,22 +255,17 @@ fn account_for_externally_used_gas_impl( env: &Env, used_gas: u64, ) -> VmResult<()> { - // WFT?! - let env1 = env.clone(); - let env2 = env.clone(); - let env3 = env.clone(); - - env1.with_context_data_mut(|context_data| { + 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(&env2)); + 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(&env3, new_limit); + set_gas_left(env, new_limit); if gas_state.externally_used_gas + wasmer_used_gas > gas_state.gas_limit { Err(VmError::GasDepletion) From 81381c1c9864afc2e95328d9eee0b23acd5e0bf8 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 10 Dec 2020 15:58:40 +0100 Subject: [PATCH 106/110] Streamline callback and return generic types --- packages/vm/src/context.rs | 39 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/packages/vm/src/context.rs b/packages/vm/src/context.rs index 612d3f79d6..eb0f70ddd9 100644 --- a/packages/vm/src/context.rs +++ b/packages/vm/src/context.rs @@ -86,48 +86,41 @@ impl Env { } } - pub fn with_context_data_mut( - &self, - callback: Callback, - ) -> CallbackReturn + pub fn with_context_data_mut(&self, callback: C) -> R where - Callback: FnOnce(&mut ContextData) -> CallbackReturn, + 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: Callback) -> CallbackReturn + pub fn with_context_data(&self, callback: C) -> R where - Callback: FnOnce(&ContextData) -> CallbackReturn, + 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: Callback) -> CallbackReturn + pub fn with_gas_state_mut(&self, callback: C) -> R where - Callback: FnOnce(&mut GasState) -> CallbackReturn, + 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: Callback) -> CallbackReturn + pub fn with_gas_state(&self, callback: C) -> R where - Callback: FnOnce(&GasState) -> CallbackReturn, + 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: Callback, - ) -> VmResult + pub fn with_func_from_context(&self, name: &str, callback: C) -> VmResult where - Callback: FnOnce(&Function) -> VmResult, + C: FnOnce(&Function) -> VmResult, { self.with_context_data_mut(|context_data| match context_data.wasmer_instance { Some(instance_ptr) => { @@ -140,22 +133,22 @@ impl Env { }) } - pub fn with_storage_from_context(&self, func: F) -> VmResult + pub fn with_storage_from_context(&self, callback: C) -> VmResult where - F: FnOnce(&mut S) -> VmResult, + C: FnOnce(&mut S) -> VmResult, { self.with_context_data_mut(|context_data| match context_data.storage.as_mut() { - Some(data) => func(data), + Some(data) => callback(data), None => Err(VmError::uninitialized_context_data("storage")), }) } - pub fn with_querier_from_context(&self, func: F) -> VmResult + pub fn with_querier_from_context(&self, callback: C) -> VmResult where - F: FnOnce(&mut Q) -> VmResult, + C: FnOnce(&mut Q) -> VmResult, { self.with_context_data_mut(|context_data| match context_data.querier.as_mut() { - Some(querier) => func(querier), + Some(querier) => callback(querier), None => Err(VmError::uninitialized_context_data("querier")), }) } From 8f0815d92af904b91eeacab5d75bc2112cba13aa Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 10 Dec 2020 16:40:38 +0100 Subject: [PATCH 107/110] Rename module context -> environment --- packages/vm/src/{context.rs => environment.rs} | 0 packages/vm/src/imports.rs | 4 ++-- packages/vm/src/instance.rs | 2 +- packages/vm/src/lib.rs | 2 +- packages/vm/src/wasm_backend/gas.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename packages/vm/src/{context.rs => environment.rs} (100%) diff --git a/packages/vm/src/context.rs b/packages/vm/src/environment.rs similarity index 100% rename from packages/vm/src/context.rs rename to packages/vm/src/environment.rs diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 07139568f0..aaa9771e19 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -8,8 +8,8 @@ use cosmwasm_std::Order; use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr}; use crate::backend::{Api, BackendError, Querier, Storage}; -use crate::context::{process_gas_info, Env}; use crate::conversion::{ref_to_u32, to_u32}; +use crate::environment::{process_gas_info, Env}; use crate::errors::{CommunicationError, VmError, VmResult}; #[cfg(feature = "iterator")] use crate::memory::maybe_read_region; @@ -274,7 +274,7 @@ mod test { use wasmer::{imports, Function, FunctionType, Instance as WasmerInstance, Type, Val}; use crate::backend::{BackendError, Storage}; - use crate::context::move_into_context; + use crate::environment::move_into_context; use crate::size::Size; use crate::testing::{MockApi, MockQuerier, MockStorage}; use crate::wasm_backend::compile; diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index f36327d335..8d511cffc2 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -7,8 +7,8 @@ use wasmer::{ }; use crate::backend::{Api, Backend, Querier, Storage}; -use crate::context::{move_into_context, move_out_of_context, Env}; use crate::conversion::{ref_to_u32, to_u32}; +use crate::environment::{move_into_context, move_out_of_context, Env}; use crate::errors::{CommunicationError, VmError, VmResult}; use crate::features::required_features_from_wasmer_instance; use crate::imports::{ diff --git a/packages/vm/src/lib.rs b/packages/vm/src/lib.rs index b2caeb0a8c..d24affcca3 100644 --- a/packages/vm/src/lib.rs +++ b/packages/vm/src/lib.rs @@ -3,8 +3,8 @@ mod cache; mod calls; mod checksum; mod compatibility; -mod context; mod conversion; +mod environment; mod errors; mod features; mod imports; diff --git a/packages/vm/src/wasm_backend/gas.rs b/packages/vm/src/wasm_backend/gas.rs index 3ab52d0f00..88af8e6d8d 100644 --- a/packages/vm/src/wasm_backend/gas.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -1,5 +1,5 @@ use crate::backend::{Querier, Storage}; -use crate::context::Env; +use crate::environment::Env; /// 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. From a5194fdcd20aadc8d25b3fb9bc62201d16409104 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 10 Dec 2020 16:42:27 +0100 Subject: [PATCH 108/110] Rename to move_into_environment/move_out_of_environment --- packages/vm/src/environment.rs | 18 +++++++++++------- packages/vm/src/imports.rs | 4 ++-- packages/vm/src/instance.rs | 6 +++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/vm/src/environment.rs b/packages/vm/src/environment.rs index eb0f70ddd9..5cf9cad397 100644 --- a/packages/vm/src/environment.rs +++ b/packages/vm/src/environment.rs @@ -211,7 +211,7 @@ impl ContextData { /// 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( +pub(crate) fn move_out_of_environment( env: &Env, ) -> (Option, Option) { env.with_context_data_mut(|context_data| { @@ -220,8 +220,12 @@ pub(crate) fn move_out_of_context( } /// Moves owned instances of storage and querier into the env. -/// Should be followed by exactly one call to move_out_of_context when the instance is finished. -pub(crate) fn move_into_context(env: &Env, storage: S, querier: Q) { +/// Should be followed by exactly one call to move_out_of_environment when the instance is finished. +pub(crate) fn move_into_environment( + env: &Env, + storage: S, + querier: Q, +) { env.with_context_data_mut(|context_data| { context_data.storage = Some(storage); context_data.querier = Some(querier); @@ -344,7 +348,7 @@ mod test { .expect("error setting value"); let querier: MockQuerier = MockQuerier::new(&[(&HumanAddr::from(INIT_ADDR), &coins(INIT_AMOUNT, INIT_DENOM))]); - move_into_context(env, storage, querier); + move_into_environment(env, storage, querier); } #[test] @@ -352,13 +356,13 @@ mod test { let (env, _instance) = make_instance(); // empty data on start - let (inits, initq) = move_out_of_context::(&env); + 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_context::(&env); + let (s, q) = move_out_of_environment::(&env); assert!(s.is_some()); assert!(q.is_some()); assert_eq!( @@ -367,7 +371,7 @@ mod test { ); // now is empty again - let (ends, endq) = move_out_of_context::(&env); + let (ends, endq) = move_out_of_environment::(&env); assert!(ends.is_none()); assert!(endq.is_none()); } diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index aaa9771e19..fd4fd94315 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -274,7 +274,7 @@ mod test { use wasmer::{imports, Function, FunctionType, Instance as WasmerInstance, Type, Val}; use crate::backend::{BackendError, Storage}; - use crate::environment::move_into_context; + use crate::environment::move_into_environment; use crate::size::Size; use crate::testing::{MockApi, MockQuerier, MockStorage}; use crate::wasm_backend::compile; @@ -341,7 +341,7 @@ mod test { 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(env, storage, querier); + move_into_environment(env, storage, querier); } fn write_data(env: &Env, data: &[u8]) -> u32 { diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 8d511cffc2..d5db682c0f 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -8,7 +8,7 @@ use wasmer::{ use crate::backend::{Api, Backend, Querier, Storage}; use crate::conversion::{ref_to_u32, to_u32}; -use crate::environment::{move_into_context, move_out_of_context, Env}; +use crate::environment::{move_into_environment, move_out_of_environment, Env}; use crate::errors::{CommunicationError, VmError, VmResult}; use crate::features::required_features_from_wasmer_instance; use crate::imports::{ @@ -203,7 +203,7 @@ where let required_features = required_features_from_wasmer_instance(wasmer_instance.as_ref()); let instance_ptr = NonNull::from(wasmer_instance.as_ref()); env.set_wasmer_instance(Some(instance_ptr)); - move_into_context(&env, backend.storage, backend.querier); + move_into_environment(&env, backend.storage, backend.querier); let instance = Instance { inner: wasmer_instance, env, @@ -218,7 +218,7 @@ where /// Decomposes this instance into its components. /// External dependencies are returned for reuse, the rest is dropped. pub fn recycle(self) -> Option> { - if let (Some(storage), Some(querier)) = move_out_of_context(&self.env) { + if let (Some(storage), Some(querier)) = move_out_of_environment(&self.env) { Some(Backend { storage, api: self.api, From 3f0e17e2f6d8badd9970cd567ce292d5ce3795d6 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 10 Dec 2020 16:47:18 +0100 Subject: [PATCH 109/110] Rename Env -> Environment to avoid conflict with Env in contracts --- packages/vm/src/environment.rs | 36 +++++++++-------- packages/vm/src/imports.rs | 63 +++++++++++++++++++---------- packages/vm/src/instance.rs | 10 ++--- packages/vm/src/wasm_backend/gas.rs | 12 +++--- 4 files changed, 71 insertions(+), 50 deletions(-) diff --git a/packages/vm/src/environment.rs b/packages/vm/src/environment.rs index 5cf9cad397..79286e8e4f 100644 --- a/packages/vm/src/environment.rs +++ b/packages/vm/src/environment.rs @@ -58,30 +58,29 @@ impl GasState { } } -/// A ContextEnv is an env that provides access to the -/// ContextData. The env is clonable but a clone accesses -/// the same underlying data. -pub struct Env { +/// A environment that provides access to the ContextData. +/// The environment is clonable but clones access the same underlying data. +pub struct Environment { data: Arc>>, } -impl Clone for Env { +impl Clone for Environment { fn clone(&self) -> Self { - Env { + Environment { data: self.data.clone(), } } } -impl WasmerEnv for Env { +impl WasmerEnv for Environment { fn init_with_instance(&mut self, _instance: &WasmerInstance) -> Result<(), HostEnvInitError> { Ok(()) } } -impl Env { +impl Environment { pub fn new(gas_limit: u64) -> Self { - Env { + Environment { data: Arc::new(RwLock::new(ContextData::new(gas_limit))), } } @@ -212,7 +211,7 @@ impl ContextData { /// 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: &Env, + env: &Environment, ) -> (Option, Option) { env.with_context_data_mut(|context_data| { (context_data.storage.take(), context_data.querier.take()) @@ -222,7 +221,7 @@ pub(crate) fn move_out_of_environment( /// 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: &Env, + env: &Environment, storage: S, querier: Q, ) { @@ -232,7 +231,10 @@ pub(crate) fn move_into_environment( }); } -pub fn process_gas_info(env: &Env, info: GasInfo) -> VmResult<()> { +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(()) @@ -242,14 +244,14 @@ pub fn process_gas_info(env: &Env, info: GasInfo) /// 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: &Env, + env: &Environment, amount: u64, ) -> VmResult<()> { account_for_externally_used_gas_impl(env, amount) } fn account_for_externally_used_gas_impl( - env: &Env, + env: &Environment, used_gas: u64, ) -> VmResult<()> { env.with_context_data_mut(|context_data| { @@ -306,8 +308,8 @@ mod test { const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000; const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); - fn make_instance() -> (Env, Box) { - let env = Env::new(GAS_LIMIT); + fn make_instance() -> (Environment, Box) { + let env = Environment::new(GAS_LIMIT); let module = compile(&CONTRACT, Some(TESTING_MEMORY_LIMIT)).unwrap(); let store = module.store(); @@ -339,7 +341,7 @@ mod test { (env, instance) } - fn leave_default_data(env: &Env) { + fn leave_default_data(env: &Environment) { // create some mock data let mut storage = MockStorage::new(); storage diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index fd4fd94315..563f2ae901 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -9,7 +9,7 @@ use cosmwasm_std::{Binary, CanonicalAddr, HumanAddr}; use crate::backend::{Api, BackendError, Querier, Storage}; use crate::conversion::{ref_to_u32, to_u32}; -use crate::environment::{process_gas_info, Env}; +use crate::environment::{process_gas_info, Environment}; use crate::errors::{CommunicationError, VmError, VmResult}; #[cfg(feature = "iterator")] use crate::memory::maybe_read_region; @@ -37,25 +37,31 @@ const MAX_LENGTH_DEBUG: usize = 2 * MI; // 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: &Env, key_ptr: u32) -> VmResult { +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: &Env, + env: &Environment, key_ptr: u32, value_ptr: u32, ) -> VmResult<()> { do_write(env, key_ptr, value_ptr) } -pub fn native_db_remove(env: &Env, key_ptr: u32) -> VmResult<()> { +pub fn native_db_remove( + env: &Environment, + key_ptr: u32, +) -> VmResult<()> { do_remove(env, key_ptr) } pub fn native_query_chain( - env: &Env, + env: &Environment, request_ptr: u32, ) -> VmResult { do_query_chain(env, request_ptr) @@ -63,7 +69,7 @@ pub fn native_query_chain( #[cfg(feature = "iterator")] pub fn native_db_scan( - env: &Env, + env: &Environment, start_ptr: u32, end_ptr: u32, order: i32, @@ -72,7 +78,10 @@ pub fn native_db_scan( } #[cfg(feature = "iterator")] -pub fn native_db_next(env: &Env, iterator_id: u32) -> VmResult { +pub fn native_db_next( + env: &Environment, + iterator_id: u32, +) -> VmResult { do_next(env, iterator_id) } @@ -81,7 +90,7 @@ pub fn native_db_next(env: &Env, iterator_id: u32) // /// Reads a storage entry from the VM's storage into Wasm memory -fn do_read(env: &Env, key_ptr: u32) -> VmResult { +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) = env.with_storage_from_context::<_, _>(|store| Ok(store.get(&key)))?; @@ -96,7 +105,11 @@ fn do_read(env: &Env, key_ptr: u32) -> VmResult(env: &Env, key_ptr: u32, value_ptr: u32) -> VmResult<()> { +fn do_write( + env: &Environment, + key_ptr: u32, + value_ptr: u32, +) -> VmResult<()> { if env.is_storage_readonly() { return Err(VmError::write_access_denied()); } @@ -112,7 +125,7 @@ fn do_write(env: &Env, key_ptr: u32, value_ptr: u3 Ok(()) } -fn do_remove(env: &Env, key_ptr: u32) -> VmResult<()> { +fn do_remove(env: &Environment, key_ptr: u32) -> VmResult<()> { if env.is_storage_readonly() { return Err(VmError::write_access_denied()); } @@ -129,7 +142,7 @@ fn do_remove(env: &Env, key_ptr: u32) -> VmResult< pub fn do_canonicalize_address( api: A, - env: &Env, + env: &Environment, source_ptr: u32, destination_ptr: u32, ) -> VmResult { @@ -160,7 +173,7 @@ pub fn do_canonicalize_address( pub fn do_humanize_address( api: A, - env: &Env, + env: &Environment, source_ptr: u32, destination_ptr: u32, ) -> VmResult { @@ -187,7 +200,7 @@ pub fn do_humanize_address( /// 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( - env: &Env, + env: &Environment, message_ptr: u32, ) -> VmResult<()> { let message_data = read_region(&env.memory(), message_ptr, MAX_LENGTH_DEBUG)?; @@ -197,7 +210,10 @@ pub fn print_debug_message( } /// Creates a Region in the contract, writes the given data to it and returns the memory location -fn write_to_contract(env: &Env, input: &[u8]) -> VmResult { +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 result = allocate.call(&[out_size.into()])?; @@ -211,7 +227,10 @@ fn write_to_contract(env: &Env, input: &[u8]) -> V Ok(target_ptr) } -fn do_query_chain(env: &Env, request_ptr: u32) -> VmResult { +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(env); @@ -225,7 +244,7 @@ fn do_query_chain(env: &Env, request_ptr: u32) -> #[cfg(feature = "iterator")] fn do_scan( - env: &Env, + env: &Environment, start_ptr: u32, end_ptr: u32, order: i32, @@ -245,7 +264,7 @@ fn do_scan( } #[cfg(feature = "iterator")] -fn do_next(env: &Env, iterator_id: u32) -> VmResult { +fn do_next(env: &Environment, iterator_id: u32) -> VmResult { let (result, gas_info) = env.with_storage_from_context::<_, _>(|store| Ok(store.next(iterator_id)))?; process_gas_info::(env, gas_info)?; @@ -300,8 +319,8 @@ mod test { const GAS_LIMIT: u64 = 5_000_000; const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); - fn make_instance() -> (Env, Box) { - let env = Env::new(GAS_LIMIT); + fn make_instance() -> (Environment, Box) { + let env = Environment::new(GAS_LIMIT); let module = compile(&CONTRACT, Some(TESTING_MEMORY_LIMIT)).unwrap(); let store = module.store(); @@ -334,7 +353,7 @@ mod test { (env, instance) } - fn leave_default_data(env: &Env) { + fn leave_default_data(env: &Environment) { // create some mock data let mut storage = MockStorage::new(); storage.set(KEY1, VALUE1).0.expect("error setting"); @@ -344,7 +363,7 @@ mod test { move_into_environment(env, storage, querier); } - fn write_data(env: &Env, data: &[u8]) -> u32 { + fn write_data(env: &Environment, data: &[u8]) -> u32 { let region_ptr = env .with_func_from_context::<_, _>("allocate", |alloc_func| { let result = alloc_func @@ -371,7 +390,7 @@ mod test { } /// A Region reader that is just good enough for the tests in this file - fn force_read(env: &Env, region_ptr: u32) -> Vec { + fn force_read(env: &Environment, region_ptr: u32) -> Vec { read_region(&env.memory(), region_ptr, 5000).unwrap() } diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index d5db682c0f..b6a88ab0b9 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -8,7 +8,7 @@ use wasmer::{ use crate::backend::{Api, Backend, Querier, Storage}; use crate::conversion::{ref_to_u32, to_u32}; -use crate::environment::{move_into_environment, move_out_of_environment, Env}; +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::{ @@ -47,7 +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: Env, + env: Environment, pub api: A, pub required_features: HashSet, // This does not store data but only fixes type information @@ -57,9 +57,9 @@ pub struct Instance { impl Instance where - S: Storage + 'static, // 'static is needed here to allow using this in an Env that is cloned into closures + 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 Env that is cloned 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*. @@ -83,7 +83,7 @@ where let store = module.store(); - let env = Env::new(gas_limit); + let env = Environment::new(gas_limit); let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); let i32i32_to_i32 = FunctionType::new(vec![Type::I32, Type::I32], vec![Type::I32]); diff --git a/packages/vm/src/wasm_backend/gas.rs b/packages/vm/src/wasm_backend/gas.rs index 88af8e6d8d..ded35f74ab 100644 --- a/packages/vm/src/wasm_backend/gas.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -1,5 +1,5 @@ use crate::backend::{Querier, Storage}; -use crate::environment::Env; +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. @@ -21,7 +21,7 @@ pub struct InsufficientGasLeft; /// 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: &Env, + env: &Environment, amount: u64, ) -> Result<(), InsufficientGasLeft> { let remaining = get_gas_left(env); @@ -35,10 +35,10 @@ pub fn decrease_gas_left( } /// Set the amount of gas units that can be used in the context. -pub fn set_gas_left(_env: &Env, _amount: u64) {} +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: &Env) -> u64 { +pub fn get_gas_left(_env: &Environment) -> u64 { FAKE_GAS_AVAILABLE } @@ -78,8 +78,8 @@ mod tests { const MAX_GAS_LIMIT: u64 = u64::MAX / 2; const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); - fn instantiate(code: &[u8]) -> (Env, Box) { - let env = Env::new(GAS_LIMIT); + fn instantiate(code: &[u8]) -> (Environment, Box) { + let env = Environment::new(GAS_LIMIT); let module = compile(code, Some(TESTING_MEMORY_LIMIT)).unwrap(); let import_obj = imports! { "env" => {}, }; let instance = Box::from(WasmerInstance::new(&module, &import_obj).unwrap()); From e657e59be66b2c6764eae2c24b1cabeabff45010 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 10 Dec 2020 16:58:45 +0100 Subject: [PATCH 110/110] Add print_debug to Environment --- packages/vm/src/environment.rs | 7 +++++-- packages/vm/src/imports.rs | 28 +++++++++++++++------------- packages/vm/src/instance.rs | 13 +++---------- packages/vm/src/wasm_backend/gas.rs | 2 +- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/packages/vm/src/environment.rs b/packages/vm/src/environment.rs index 79286e8e4f..0fee1f2df5 100644 --- a/packages/vm/src/environment.rs +++ b/packages/vm/src/environment.rs @@ -62,12 +62,14 @@ impl GasState { /// 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, } } } @@ -79,9 +81,10 @@ impl WasmerEnv for Environment { } impl Environment { - pub fn new(gas_limit: u64) -> Self { + pub fn new(gas_limit: u64, print_debug: bool) -> Self { Environment { data: Arc::new(RwLock::new(ContextData::new(gas_limit))), + print_debug, } } @@ -309,7 +312,7 @@ mod test { const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); fn make_instance() -> (Environment, Box) { - let env = Environment::new(GAS_LIMIT); + let env = Environment::new(GAS_LIMIT, false); let module = compile(&CONTRACT, Some(TESTING_MEMORY_LIMIT)).unwrap(); let store = module.store(); diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index 563f2ae901..8ceef0cdb1 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -85,6 +85,20 @@ pub fn native_db_next( 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 // @@ -197,18 +211,6 @@ pub fn do_humanize_address( } } -/// 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( - env: &Environment, - message_ptr: u32, -) -> VmResult<()> { - let message_data = read_region(&env.memory(), message_ptr, MAX_LENGTH_DEBUG)?; - let msg = String::from_utf8_lossy(&message_data); - println!("{}", msg); - Ok(()) -} - /// Creates a Region in the contract, writes the given data to it and returns the memory location fn write_to_contract( env: &Environment, @@ -320,7 +322,7 @@ mod test { const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); fn make_instance() -> (Environment, Box) { - let env = Environment::new(GAS_LIMIT); + let env = Environment::new(GAS_LIMIT, false); let module = compile(&CONTRACT, Some(TESTING_MEMORY_LIMIT)).unwrap(); let store = module.store(); diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index b6a88ab0b9..5e3800457f 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -13,7 +13,7 @@ use crate::errors::{CommunicationError, VmError, VmResult}; use crate::features::required_features_from_wasmer_instance; use crate::imports::{ do_canonicalize_address, do_humanize_address, native_db_read, native_db_remove, - native_db_write, native_query_chain, print_debug_message, + native_db_write, native_debug, native_query_chain, }; #[cfg(feature = "iterator")] use crate::imports::{native_db_next, native_db_scan}; @@ -83,9 +83,8 @@ where let store = module.store(); - let env = Environment::new(gas_limit); + let env = Environment::new(gas_limit, print_debug); - let i32_to_void = FunctionType::new(vec![Type::I32], vec![]); let i32i32_to_i32 = FunctionType::new(vec![Type::I32, Type::I32], vec![Type::I32]); let mut import_obj = ImportObject::new(); @@ -151,13 +150,7 @@ where // Ownership of both input and output pointer is not transferred to the host. env_imports.insert( "debug", - Function::new_with_env(store, &i32_to_void, env.clone(), move |env, args| { - let message_ptr = ref_to_u32(&args[0])?; - if print_debug { - print_debug_message(&env, message_ptr)?; - } - Ok(vec![]) - }), + Function::new_native_with_env(store, env.clone(), native_debug), ); env_imports.insert( diff --git a/packages/vm/src/wasm_backend/gas.rs b/packages/vm/src/wasm_backend/gas.rs index ded35f74ab..8f8fd1dfb5 100644 --- a/packages/vm/src/wasm_backend/gas.rs +++ b/packages/vm/src/wasm_backend/gas.rs @@ -79,7 +79,7 @@ mod tests { const TESTING_MEMORY_LIMIT: Size = Size::mebi(16); fn instantiate(code: &[u8]) -> (Environment, Box) { - let env = Environment::new(GAS_LIMIT); + 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());