diff --git a/.circleci/config.yml b/.circleci/config.yml index a6a03c635..b6bc9c651 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,16 +4,12 @@ jobs: # All checks on the codebase that can run in parallel to build_library sanity: docker: - # We don't use this Rust version but need an image with a Rust environment - - image: circleci/rust:1.47.0-buster + - image: circleci/rust:1.49.0-buster steps: - checkout - run: name: Install shellcheck command: sudo apt install shellcheck - - run: - name: Setup Rust toolchain from ./rust-toolchain - command: echo "RUSTUP_TOOLCHAIN=$RUSTUP_TOOLCHAIN" && rustup show - run: name: Show version information command: rustc --version; cargo --version; rustup --version @@ -35,13 +31,9 @@ jobs: build_library: docker: - # We don't use this Rust version but need an image with a Rust environment - - image: circleci/rust:1.47.0-buster + - image: circleci/rust:1.49.0-buster steps: - checkout - - run: - name: Setup Rust toolchain from ./rust-toolchain - command: echo "RUSTUP_TOOLCHAIN=$RUSTUP_TOOLCHAIN" && rustup show - run: name: Show version information command: rustc --version; cargo --version; rustup --version @@ -56,7 +48,7 @@ jobs: test: working_directory: /go/src/github.com/CosmWasm/wasmvm docker: - - image: circleci/golang:1.14 + - image: circleci/golang:1.15 environment: GORACE: "halt_on_error=1" BUILD_VERSION: $(echo ${CIRCLE_SHA1} | cut -c 1-10) diff --git a/Cargo.lock b/Cargo.lock index 825e0dee2..1fe56ab2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,25 +1,28 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "ansi_term" -version = "0.11.0" +name = "addr2line" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ - "winapi", + "gimli 0.23.0", ] [[package]] -name = "arrayref" -version = "0.3.6" +name = "adler" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] -name = "arrayvec" -version = "0.5.1" +name = "ansi_term" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] [[package]] name = "atty" @@ -34,21 +37,35 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.0" +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 = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] [[package]] name = "base64" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[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", @@ -60,28 +77,13 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake3" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "423897d97e11b810c9da22458400b28ec866991c711409073662eb34dc44bfff" -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]] @@ -92,9 +94,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cbindgen" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "104ca409bbff8293739438c71820a2606111b5f8f81835536dc673dfd807369e" +checksum = "e6e03a705df2e735cc5486f104a48e25a8f72ae06eaea5b7753a81270ed00859" dependencies = [ "clap", "heck", @@ -110,9 +112,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.54" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" [[package]] name = "cfg-if" @@ -120,30 +122,27 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "clap" -version = "2.33.1" +version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", + "strsim 0.8.0", "textwrap", "unicode-width", "vec_map", ] -[[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" @@ -151,16 +150,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44e10ee132778350b0390b347b47e4bbb098e23f0ee34ded4a03b078cae19024" [[package]] -name = "constant_time_eq" -version = "0.1.5" +name = "const_fn" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" [[package]] name = "cosmwasm-std" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8094ec41a0d81bfad7318da6ca1ac8e207bd4c806cf5529ba743ede0015912ad" +checksum = "9a55b3ed0131c73ecfd4b0f895af4057dcc8a4f54b2691724e37e7a55434143b" dependencies = [ "base64", "schemars", @@ -171,24 +170,21 @@ dependencies = [ [[package]] name = "cosmwasm-vm" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317c3edaab4b597e8dc81f8e8f6aa158e646fde86ad21112d806aeba4f4f1c9c" +checksum = "20eb7b0b1da641204e4b4fafdb83ef6c91d583033406e3fcceb1e7cfb6f5c9e9" dependencies = [ "clru", "cosmwasm-std", "hex", - "memmap", "parity-wasm", "schemars", "serde", "serde_json", "sha2", "thiserror", - "wasmer-clif-backend", - "wasmer-middleware-common", - "wasmer-runtime-core", - "wasmer-singlepass-backend", + "wasmer", + "wasmer-middlewares", ] [[package]] @@ -199,26 +195,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", @@ -226,9 +223,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", @@ -236,91 +233,119 @@ 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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", - "maybe-uninit", ] [[package]] name = "crossbeam-epoch" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ - "autocfg", - "cfg-if", + "cfg-if 1.0.0", + "const_fn", "crossbeam-utils", "lazy_static", - "maybe-uninit", "memoffset", "scopeguard", ] [[package]] -name = "crossbeam-queue" -version = "0.2.1" +name = "crossbeam-utils" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" +checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" dependencies = [ - "cfg-if", - "crossbeam-utils", + "autocfg", + "cfg-if 1.0.0", + "lazy_static", ] [[package]] -name = "crossbeam-utils" -version = "0.7.2" +name = "darling" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" dependencies = [ - "autocfg", - "cfg-if", - "lazy_static", + "darling_core", + "darling_macro", ] [[package]] -name = "crypto-mac" -version = "0.7.0" +name = "darling_core" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ - "generic-array 0.12.3", - "subtle", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.9.3", + "syn", ] [[package]] -name = "digest" -version = "0.8.1" +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]] @@ -329,19 +354,19 @@ 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]] 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", @@ -349,25 +374,48 @@ 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", ] [[package]] name = "either" -version = "1.5.3" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "enumset" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1" +dependencies = [ + "enumset_derive", + "num-traits", +] + +[[package]] +name = "enumset_derive" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] [[package]] name = "errno" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b480f641ccf0faf324e20c1d3e53d81b7484c698b42ea677f6907ae4db195371" +checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" dependencies = [ "errno-dragonfly", "libc", @@ -385,25 +433,28 @@ dependencies = [ ] [[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 = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "generic-array" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60fb4bb6bba52f78a471264d9a3b7d026cc0af47b22cd2cffbc0b787ca003e63" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ "typenum", "version_check", @@ -411,39 +462,52 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.13" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" dependencies = [ "libc", ] @@ -454,21 +518,28 @@ 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.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ "autocfg", + "hashbrown", "serde", ] [[package]] name = "itoa" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "lazy_static" @@ -476,35 +547,45 @@ 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.70" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f" +checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" [[package]] -name = "lock_api" -version = "0.3.4" +name = "libloading" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "e9367bdfa836b7e3cf895867f7a570283444da90562980ec2263d6e1569b16bc" dependencies = [ - "scopeguard", + "cfg-if 1.0.0", + "winapi", ] [[package]] name = "log" -version = "0.4.8" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", ] [[package]] -name = "maybe-uninit" -version = "2.0.0" +name = "mach" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] [[package]] name = "memmap" @@ -516,26 +597,47 @@ dependencies = [ "winapi", ] +[[package]] +name = "memmap2" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e73be3b7d04a0123e933fea1d50d126cc7196bbc0362c0ce426694f777194eee" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" -version = "0.5.4" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" dependencies = [ "autocfg", ] [[package]] -name = "nix" -version = "0.15.0" +name = "miniz_oxide" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ - "bitflags", - "cc", - "cfg-if", - "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]] @@ -549,29 +651,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.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" 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" @@ -580,49 +673,55 @@ 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.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" -dependencies = [ - "lock_api", - "parking_lot_core", -] +checksum = "e36743d754ccdf9954c2e352ce2d4b106e024c814f6499c2dadff80da9a442d8" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] -name = "parking_lot_core" -version = "0.7.2" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +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.8" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] [[package]] name = "proc-macro2" -version = "1.0.17" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1502d12e458c49a4c9cbff560d0fe0060c252bc29799ed94ca2ed4bb665a0101" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ "proc-macro2", ] @@ -670,9 +769,9 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "7.0.3" +version = "7.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" +checksum = "beb71f708fe39b2c5e98076204c3cc094ee5a4c12c4cdb119a2b72dc34164f41" dependencies = [ "bitflags", "cc", @@ -681,10 +780,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", @@ -692,12 +792,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", @@ -705,19 +805,54 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +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.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +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" @@ -729,9 +864,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "schemars" @@ -779,23 +914,13 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.110" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e7b308464d16b56eba9964e4972a3eee817760ab60d88c3f86e1fecb08204c" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" 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" @@ -807,18 +932,18 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf487fbf5c6239d7ea2ff8b10cb6b811cd4b5080d1c2aeed1dec18753c06e10" +checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.110" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ "proc-macro2", "quote", @@ -838,9 +963,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.53" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" dependencies = [ "itoa", "ryu", @@ -849,28 +974,28 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" +checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" dependencies = [ "block-buffer", - "cfg-if", + "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", + "digest", "opaque-debug", ] [[package]] name = "smallvec" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" +checksum = "1a55ca5f3b68e41c979bf8c46a6f1da892ca4db8f94023ce0bd32407573b1ac0" [[package]] name = "stable_deref_trait" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "strsim" @@ -879,16 +1004,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[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" -version = "1.0.24" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f87bc5b2815ebb664de0392fdf1b95b6d10e160f86d9f64ff65e5679841ca06a" +checksum = "4211ce9909eb971f111059df92c45640aad50a619cf55cd76476be803c4c68e6" dependencies = [ "proc-macro2", "quote", @@ -897,9 +1022,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" @@ -907,7 +1032,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "rand", "redox_syscall", @@ -926,18 +1051,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.19" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13f926965ad00595dd129fa12823b04bbf866e9085ab0a5f2b05b850fbfc344" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.19" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "893582086c2f98cde18f906265a65b5030a074b1046c674ae898be6519a7f479" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ "proc-macro2", "quote", @@ -946,13 +1071,45 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] +[[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" @@ -961,21 +1118,21 @@ checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "vec_map" @@ -989,12 +1146,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 = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -1002,135 +1153,220 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "wasmer-clif-backend" -version = "0.17.0" +name = "wasmer" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691ea323652d540a10722066dbf049936f4367bb22a96f8992a262a942a8b11b" +checksum = "94b1ece7c894857344ae93506686ae36ccd867b4ed55819c06d2316d009098d4" dependencies = [ - "byteorder", - "cranelift-codegen", - "cranelift-entity", - "cranelift-native", - "libc", - "nix", - "rayon", + "cfg-if 0.1.10", + "indexmap", + "more-asserts", + "target-lexicon", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-compiler-singlepass", + "wasmer-derive", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "wat", + "winapi", +] + +[[package]] +name = "wasmer-compiler" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc85134b257e5fba5870693441e300b601d08f18833ac4fa6934f0b72afc56d2" +dependencies = [ + "enumset", + "raw-cpuid", "serde", - "serde-bench", "serde_bytes", - "serde_derive", + "smallvec", "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", + "thiserror", + "wasmer-types", + "wasmer-vm", "wasmparser", - "winapi", ] [[package]] -name = "wasmer-clif-fork-frontend" -version = "0.59.0" +name = "wasmer-compiler-cranelift" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a" +checksum = "60d68fb05dbe908724901b680070560944d99d04c52c763e98124aa988ac6dd0" dependencies = [ "cranelift-codegen", - "log", + "cranelift-frontend", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", "smallvec", - "target-lexicon", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-clif-fork-wasm" -version = "0.59.0" +name = "wasmer-compiler-singlepass" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5" +checksum = "81f91c9471113efc731fdd9f54f6fb82fab4c00498281966fcc4a87cdf360ea5" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser", + "byteorder", + "dynasm", + "dynasmrt", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-middleware-common" -version = "0.17.0" +name = "wasmer-derive" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd94068186b25fbe5213442648ffe0fa65ee77389bed020404486fd22056cc87" +checksum = "ca24205ffdf2d3b1a9c01219f4f3f0a1382658680abe73bc5b146f941adeeb8e" dependencies = [ - "wasmer-runtime-core", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "wasmer-runtime-core" -version = "0.17.0" +name = "wasmer-engine" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d4253f097502423d8b19d54cb18745f61b984b9dbce32424cba7945cfef367" +checksum = "d91ed16436a9813d92f434e1d40fdf91b45ca30f351a799f793015359acca86b" dependencies = [ + "backtrace", "bincode", - "blake3", - "cc", - "digest 0.8.1", - "errno", - "hex", - "indexmap", "lazy_static", - "libc", - "nix", - "page_size", - "parking_lot", - "rustc_version", + "memmap2", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1e3ca5e34eacd4ab6d9d32edd41b51d2e39cf3d75453611c9c57cee3a64691" +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" +name = "wasmer-engine-native" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cf84179dd5e92b784f7bc190b237f1184916a6d6d3f87d4dd94ca371a2cc25" +checksum = "6a21d6c5ae0c384ba2f01f598c95b01d4da2eaec3376fb96de2ded38c54143a0" 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-middlewares" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eee5ffe702a61dcbc08d9b2bc899c81f3ccbb77d4e4ef0b65e8913ba582cc6d" +dependencies = [ + "wasmer", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-object" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06e007e73ec7775aecc61045092dabfcff1e9f228129cd129e76a3e6aae26454" +dependencies = [ + "object", + "thiserror", + "wasmer-compiler", + "wasmer-types", ] [[package]] -name = "wasmer-win-exception-handler" -version = "0.17.0" +name = "wasmer-types" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf22ce6dc66d893099aac853d451bf9443fa8f5443f5bf4fc63f3aebd7b592b1" +checksum = "2dbba7a95edb61b40daa43079979fc3212234e1645a15b8c527c36decad59fc6" dependencies = [ + "cranelift-entity", + "serde", + "thiserror", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cd9acd4d53c004a11fcaff17f2a2528ae8f1748c6d5c4aea7d8bed2d9236f0f" +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 = "wasmvm" -version = "0.12.0" +version = "0.13.0" dependencies = [ "cbindgen", "cosmwasm-std", @@ -1142,11 +1378,39 @@ dependencies = [ "thiserror", ] +[[package]] +name = "wast" +version = "30.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b79907b22f740634810e882d8d1d9d0f9563095a8ab94e786e370242bff5cd2" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8279a02835bf12e61ed2b3c3cbc6ecf9918762fd97e036917c11a09ec20ca44" +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" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", diff --git a/Cargo.toml b/Cargo.toml index 0edf0ac0f..85ecf87ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmvm" -version = "0.12.0" +version = "0.13.0" authors = ["Ethan Frey "] edition = "2018" description = "Go bindings for cosmwasm contracts" @@ -25,15 +25,13 @@ circle-ci = { repository = "CosmWasm/wasmvm", branch = "master" } maintenance = { status = "actively-developed" } [features] -default = ["singlepass", "backtraces"] +default = [] # This feature requires Rust nightly because it depends on the unstable backtrace feature. backtraces = [] -singlepass = ["cosmwasm-vm/default-singlepass"] -cranelift = ["cosmwasm-vm/default-cranelift"] [dependencies] -cosmwasm-std = { version = "0.12.0", features = ["iterator"]} -cosmwasm-vm = { version = "0.12.0", features = ["iterator"] } +cosmwasm-std = { version = "0.13.0", features = ["iterator"]} +cosmwasm-vm = { version = "0.13.0", features = ["iterator"] } errno = "0.2" serde_json = "1.0" thiserror = "1.0" diff --git a/Makefile b/Makefile index 38bbb3fcd..6a8e1c66e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: all build build-rust build-go test -BUILDERS_PREFIX := cosmwasm/go-ext-builder:0003 +BUILDERS_PREFIX := cosmwasm/go-ext-builder:0004 USER_ID := $(shell id -u) USER_GROUP = $(shell id -g) @@ -25,14 +25,15 @@ build: build-rust build-go # build-rust: build-rust-release strip build-rust: build-rust-release -# use debug build for quick testing +# Use debug build for quick testing. +# In order to use "--features backtraces" here we need a Rust nightly toolchain, which we don't have by default build-rust-debug: - cargo build --features backtraces + cargo build cp target/debug/libwasmvm.$(DLL_EXT) api # use release build to actually ship - smaller and much faster build-rust-release: - cargo build --release --features backtraces + cargo build --release cp target/release/libwasmvm.$(DLL_EXT) api @ #this pulls out ELF symbols, 80% size reduction! diff --git a/README.md b/README.md index f1f7e4c42..d9d51fe34 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,9 @@ install all this with no problems. ## Toolchain -The Rust toolchain is pinned in the file `rust-toolchain`. It must be in sync with `Dockerfile.cross` -and `Dockerfile.centos7`. -When choosing a version, please use version with clippy, rustfmt and rls available to make Simon happy. +We fix the Rust version in the CI and build containers, so the following should be in sync: -- Mac: https://rust-lang.github.io/rustup-components-history/x86_64-apple-darwin.html -- Linux: https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu.html +- `.circleci/config.yml` +- `builders/Dockerfile.*` + +For development you should be able to use any reasonably up-to-date Rust stable. diff --git a/api/api_test.go b/api/api_test.go index 19efe1bcb..6dd45496e 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -34,7 +34,7 @@ func TestCanonicalAddressFailure(t *testing.T) { // make sure the call doesn't error, but we get a JSON-encoded error result from InitResult igasMeter := GasMeter(gasMeter) - res, _, err := Instantiate(cache, id, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, _, err := Instantiate(cache, id, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var resp types.InitResult err = json.Unmarshal(res, &resp) @@ -67,7 +67,7 @@ func TestHumanAddressFailure(t *testing.T) { // instantiate it normally msg := []byte(`{"verifier": "short", "beneficiary": "bob"}`) igasMeter := GasMeter(gasMeter) - _, _, err = Instantiate(cache, id, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + _, _, err = Instantiate(cache, id, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) // call query which will call canonicalize address @@ -75,7 +75,7 @@ func TestHumanAddressFailure(t *testing.T) { gasMeter3 := NewMockGasMeter(TESTING_GAS_LIMIT) query := []byte(`{"verifier":{}}`) igasMeter3 := GasMeter(gasMeter3) - res, _, err := Query(cache, id, env, query, &igasMeter3, store, badApi, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, _, err := Query(cache, id, env, query, &igasMeter3, store, badApi, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var resp types.QueryResponse err = json.Unmarshal(res, &resp) diff --git a/api/bindings.h b/api/bindings.h index 462d580e8..2574b62ed 100644 --- a/api/bindings.h +++ b/api/bindings.h @@ -1,6 +1,6 @@ /* (c) 2019 Confio UO. Licensed under Apache-2.0 */ -/* Generated with cbindgen:0.14.2 */ +/* Generated with cbindgen:0.14.3 */ /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ @@ -140,6 +140,7 @@ Buffer handle(cache_t *cache, GoApi api, GoQuerier querier, uint64_t gas_limit, + uint32_t memory_limit, bool print_debug, uint64_t *gas_used, Buffer *err); @@ -155,6 +156,7 @@ Buffer instantiate(cache_t *cache, GoApi api, GoQuerier querier, uint64_t gas_limit, + uint32_t memory_limit, bool print_debug, uint64_t *gas_used, Buffer *err); @@ -168,6 +170,7 @@ Buffer migrate(cache_t *cache, GoApi api, GoQuerier querier, uint64_t gas_limit, + uint32_t memory_limit, bool print_debug, uint64_t *gas_used, Buffer *err); @@ -180,6 +183,7 @@ Buffer query(cache_t *cache, GoApi api, GoQuerier querier, uint64_t gas_limit, + uint32_t memory_limit, bool print_debug, uint64_t *gas_used, Buffer *err); diff --git a/api/iterator_test.go b/api/iterator_test.go index a2e9a4d81..f4bdbbc9a 100644 --- a/api/iterator_test.go +++ b/api/iterator_test.go @@ -36,7 +36,7 @@ func setupQueueContractWithData(t *testing.T, cache Cache, values ...int) queueD msg := []byte(`{}`) igasMeter1 := GasMeter(gasMeter1) - res, _, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, _, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) requireOkResponse(t, res, 0) @@ -44,7 +44,7 @@ func setupQueueContractWithData(t *testing.T, cache Cache, values ...int) queueD // push 17 var gasMeter2 GasMeter = NewMockGasMeter(TESTING_GAS_LIMIT) push := []byte(fmt.Sprintf(`{"enqueue":{"value":%d}}`, value)) - res, _, err = Handle(cache, id, env, info, push, &gasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, _, err = Handle(cache, id, env, info, push, &gasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) requireOkResponse(t, res, 0) } @@ -74,7 +74,7 @@ func TestQueueIterator(t *testing.T) { store := setup.Store(gasMeter) query := []byte(`{"sum":{}}`) env := MockEnvBin(t) - data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var qres types.QueryResponse err = json.Unmarshal(data, &qres) @@ -84,7 +84,7 @@ func TestQueueIterator(t *testing.T) { // query reduce (multiple iterators at once) query = []byte(`{"reducer":{}}`) - data, _, err = Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + data, _, err = Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var reduced types.QueryResponse err = json.Unmarshal(data, &reduced) @@ -112,7 +112,7 @@ func TestQueueIteratorRaces(t *testing.T) { // query reduce (multiple iterators at once) query := []byte(`{"reducer":{}}`) - data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var reduced types.QueryResponse err = json.Unmarshal(data, &reduced) diff --git a/api/lib.go b/api/lib.go index 8ee16ba43..7a9523a07 100644 --- a/api/lib.go +++ b/api/lib.go @@ -21,6 +21,7 @@ type cu64 = C.uint64_t type ci8 = C.int8_t type ci32 = C.int32_t type ci64 = C.int64_t + // Pointers type cu8_ptr = *C.uint8_t @@ -81,6 +82,7 @@ func Instantiate( api *GoAPI, querier *Querier, gasLimit uint64, + memoryLimit uint32, printDebug bool, ) ([]byte, uint64, error) { id := sendSlice(code_id) @@ -103,7 +105,7 @@ func Instantiate( var gasUsed cu64 errmsg := C.Buffer{} - res, err := C.instantiate(cache.ptr, id, e, i, m, db, a, q, cu64(gasLimit), cbool(printDebug), &gasUsed, &errmsg) + res, err := C.instantiate(cache.ptr, id, e, i, m, db, a, q, cu64(gasLimit), cu32(memoryLimit), cbool(printDebug), &gasUsed, &errmsg) if err != nil && err.(syscall.Errno) != C.ErrnoValue_Success { // Depending on the nature of the error, `gasUsed` will either have a meaningful value, or just 0. return nil, uint64(gasUsed), errorWithMessage(err, errmsg) @@ -122,6 +124,7 @@ func Handle( api *GoAPI, querier *Querier, gasLimit uint64, + memoryLimit uint32, printDebug bool, ) ([]byte, uint64, error) { id := sendSlice(code_id) @@ -144,7 +147,7 @@ func Handle( var gasUsed cu64 errmsg := C.Buffer{} - res, err := C.handle(cache.ptr, id, e, i, m, db, a, q, cu64(gasLimit), cbool(printDebug), &gasUsed, &errmsg) + res, err := C.handle(cache.ptr, id, e, i, m, db, a, q, cu64(gasLimit), cu32(memoryLimit), cbool(printDebug), &gasUsed, &errmsg) if err != nil && err.(syscall.Errno) != C.ErrnoValue_Success { // Depending on the nature of the error, `gasUsed` will either have a meaningful value, or just 0. return nil, uint64(gasUsed), errorWithMessage(err, errmsg) @@ -163,6 +166,7 @@ func Migrate( api *GoAPI, querier *Querier, gasLimit uint64, + memoryLimit uint32, printDebug bool, ) ([]byte, uint64, error) { id := sendSlice(code_id) @@ -185,7 +189,7 @@ func Migrate( var gasUsed cu64 errmsg := C.Buffer{} - res, err := C.migrate(cache.ptr, id, e, i, m, db, a, q, cu64(gasLimit), cbool(printDebug), &gasUsed, &errmsg) + res, err := C.migrate(cache.ptr, id, e, i, m, db, a, q, cu64(gasLimit), cu32(memoryLimit), cbool(printDebug), &gasUsed, &errmsg) if err != nil && err.(syscall.Errno) != C.ErrnoValue_Success { // Depending on the nature of the error, `gasUsed` will either have a meaningful value, or just 0. return nil, uint64(gasUsed), errorWithMessage(err, errmsg) @@ -203,6 +207,7 @@ func Query( api *GoAPI, querier *Querier, gasLimit uint64, + memoryLimit uint32, printDebug bool, ) ([]byte, uint64, error) { id := sendSlice(code_id) @@ -223,7 +228,7 @@ func Query( var gasUsed cu64 errmsg := C.Buffer{} - res, err := C.query(cache.ptr, id, e, m, db, a, q, cu64(gasLimit), cbool(printDebug), &gasUsed, &errmsg) + res, err := C.query(cache.ptr, id, e, m, db, a, q, cu64(gasLimit), cu32(memoryLimit), cbool(printDebug), &gasUsed, &errmsg) if err != nil && err.(syscall.Errno) != C.ErrnoValue_Success { // Depending on the nature of the error, `gasUsed` will either have a meaningful value, or just 0. return nil, uint64(gasUsed), errorWithMessage(err, errmsg) diff --git a/api/lib_test.go b/api/lib_test.go index 215b48b9a..2b3d6291a 100644 --- a/api/lib_test.go +++ b/api/lib_test.go @@ -16,7 +16,8 @@ import ( const TESTING_FEATURES = "staking" const TESTING_PRINT_DEBUG = false const TESTING_GAS_LIMIT = 100_000_000 -const TESTING_CACHE_SIZE = 100 // MiB +const TESTING_MEMORY_LIMIT = 32 // MiB +const TESTING_CACHE_SIZE = 100 // MiB func TestInitAndReleaseCache(t *testing.T) { dataDir := "/foo" @@ -89,10 +90,10 @@ func TestInstantiate(t *testing.T) { info := MockInfoBin(t, "creator") msg := []byte(`{"verifier": "fred", "beneficiary": "bob"}`) - res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) requireOkResponse(t, res, 0) - assert.Equal(t, uint64(0x13860), cost) + assert.Equal(t, uint64(0x11539), cost) var resp types.InitResult err = json.Unmarshal(res, &resp) @@ -119,11 +120,11 @@ func TestHandle(t *testing.T) { msg := []byte(`{"verifier": "fred", "beneficiary": "bob"}`) start := time.Now() - res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) diff := time.Now().Sub(start) require.NoError(t, err) requireOkResponse(t, res, 0) - assert.Equal(t, uint64(0x13860), cost) + assert.Equal(t, uint64(0x11539), cost) t.Logf("Time (%d gas): %s\n", 0xbb66, diff) // execute with the same store @@ -133,10 +134,10 @@ func TestHandle(t *testing.T) { env = MockEnvBin(t) info = MockInfoBin(t, "fred") start = time.Now() - res, cost, err = Handle(cache, id, env, info, []byte(`{"release":{}}`), &igasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, cost, err = Handle(cache, id, env, info, []byte(`{"release":{}}`), &igasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) diff = time.Now().Sub(start) require.NoError(t, err) - assert.Equal(t, uint64(0x1d663), cost) + assert.Equal(t, uint64(0x1966a), cost) t.Logf("Time (%d gas): %s\n", cost, diff) // make sure it read the balance properly and we got 250 atoms @@ -175,11 +176,11 @@ func TestHandleCpuLoop(t *testing.T) { msg := []byte(`{"verifier": "fred", "beneficiary": "bob"}`) start := time.Now() - res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) diff := time.Now().Sub(start) require.NoError(t, err) requireOkResponse(t, res, 0) - assert.Equal(t, uint64(0x13860), cost) + assert.Equal(t, uint64(0x11539), cost) t.Logf("Time (%d gas): %s\n", 0xbb66, diff) // execute a cpu loop @@ -189,7 +190,7 @@ func TestHandleCpuLoop(t *testing.T) { store.SetGasMeter(gasMeter2) info = MockInfoBin(t, "fred") start = time.Now() - res, cost, err = Handle(cache, id, env, info, []byte(`{"cpu_loop":{}}`), &igasMeter2, store, api, &querier, maxGas, TESTING_PRINT_DEBUG) + res, cost, err = Handle(cache, id, env, info, []byte(`{"cpu_loop":{}}`), &igasMeter2, store, api, &querier, maxGas, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) diff = time.Now().Sub(start) require.Error(t, err) assert.Equal(t, cost, maxGas) @@ -214,7 +215,7 @@ func TestHandleStorageLoop(t *testing.T) { msg := []byte(`{"verifier": "fred", "beneficiary": "bob"}`) - res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, maxGas, TESTING_PRINT_DEBUG) + res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, maxGas, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) requireOkResponse(t, res, 0) @@ -224,7 +225,7 @@ func TestHandleStorageLoop(t *testing.T) { store.SetGasMeter(gasMeter2) info = MockInfoBin(t, "fred") start := time.Now() - res, cost, err = Handle(cache, id, env, info, []byte(`{"storage_loop":{}}`), &igasMeter2, store, api, &querier, maxGas, TESTING_PRINT_DEBUG) + res, cost, err = Handle(cache, id, env, info, []byte(`{"storage_loop":{}}`), &igasMeter2, store, api, &querier, maxGas, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) diff := time.Now().Sub(start) require.Error(t, err) t.Logf("StorageLoop Time (%d gas): %s\n", cost, diff) @@ -253,7 +254,7 @@ func TestHandleUserErrorsInApiCalls(t *testing.T) { defaultApi := NewMockAPI() msg := []byte(`{"verifier": "fred", "beneficiary": "bob"}`) - res, _, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, defaultApi, &querier, maxGas, TESTING_PRINT_DEBUG) + res, _, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, defaultApi, &querier, maxGas, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) requireOkResponse(t, res, 0) @@ -262,7 +263,7 @@ func TestHandleUserErrorsInApiCalls(t *testing.T) { store.SetGasMeter(gasMeter2) info = MockInfoBin(t, "fred") failingApi := NewMockFailureAPI() - res, _, err = Handle(cache, id, env, info, []byte(`{"user_errors_in_api_calls":{}}`), &igasMeter2, store, failingApi, &querier, maxGas, TESTING_PRINT_DEBUG) + res, _, err = Handle(cache, id, env, info, []byte(`{"user_errors_in_api_calls":{}}`), &igasMeter2, store, failingApi, &querier, maxGas, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) requireOkResponse(t, res, 0) } @@ -283,13 +284,13 @@ func TestMigrate(t *testing.T) { info := MockInfoBin(t, "creator") msg := []byte(`{"verifier": "fred", "beneficiary": "bob"}`) - res, _, err := Instantiate(cache, id, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, _, err := Instantiate(cache, id, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) requireOkResponse(t, res, 0) // verifier is fred query := []byte(`{"verifier":{}}`) - data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var qres types.QueryResponse err = json.Unmarshal(data, &qres) @@ -300,11 +301,11 @@ func TestMigrate(t *testing.T) { // migrate to a new verifier - alice // we use the same code blob as we are testing hackatom self-migration info = MockInfoBin(t, "fred") - res, _, err = Migrate(cache, id, env, info, []byte(`{"verifier":"alice"}`), &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, _, err = Migrate(cache, id, env, info, []byte(`{"verifier":"alice"}`), &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) // should update verifier to alice - data, _, err = Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + data, _, err = Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var qres2 types.QueryResponse err = json.Unmarshal(data, &qres2) @@ -327,11 +328,11 @@ func TestMultipleInstances(t *testing.T) { env := MockEnvBin(t) info := MockInfoBin(t, "regen") msg := []byte(`{"verifier": "fred", "beneficiary": "bob"}`) - res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store1, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, cost, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store1, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) requireOkResponse(t, res, 0) // we now count wasm gas charges and db writes - assert.Equal(t, uint64(0x13762), cost) + assert.Equal(t, uint64(0x11461), cost) // instance2 controlled by mary gasMeter2 := NewMockGasMeter(TESTING_GAS_LIMIT) @@ -339,17 +340,17 @@ func TestMultipleInstances(t *testing.T) { store2 := NewLookup(gasMeter2) info = MockInfoBin(t, "chrous") msg = []byte(`{"verifier": "mary", "beneficiary": "sue"}`) - res, cost, err = Instantiate(cache, id, env, info, msg, &igasMeter2, store2, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, cost, err = Instantiate(cache, id, env, info, msg, &igasMeter2, store2, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) requireOkResponse(t, res, 0) - assert.Equal(t, uint64(0x137e1), cost) + assert.Equal(t, uint64(0x114cd), cost) // fail to execute store1 with mary - resp := exec(t, cache, id, "mary", store1, api, querier, 0x11574) + resp := exec(t, cache, id, "mary", store1, api, querier, 0xed43) require.Equal(t, "Unauthorized", resp.Err) // succeed to execute store1 with fred - resp = exec(t, cache, id, "fred", store1, api, querier, 0x1d663) + resp = exec(t, cache, id, "fred", store1, api, querier, 0x1966a) require.Equal(t, "", resp.Err) require.Equal(t, 1, len(resp.Ok.Messages)) attributes := resp.Ok.Attributes @@ -358,7 +359,7 @@ func TestMultipleInstances(t *testing.T) { require.Equal(t, "bob", attributes[1].Value) // succeed to execute store2 with mary - resp = exec(t, cache, id, "mary", store2, api, querier, 0x1d663) + resp = exec(t, cache, id, "mary", store2, api, querier, 0x1966a) require.Equal(t, "", resp.Err) require.Equal(t, 1, len(resp.Ok.Messages)) attributes = resp.Ok.Attributes @@ -401,7 +402,7 @@ func exec(t *testing.T, cache Cache, id []byte, signer types.HumanAddress, store igasMeter := GasMeter(gasMeter) env := MockEnvBin(t) info := MockInfoBin(t, signer) - res, cost, err := Handle(cache, id, env, info, []byte(`{"release":{}}`), &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + res, cost, err := Handle(cache, id, env, info, []byte(`{"release":{}}`), &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) assert.Equal(t, gasExpected, cost) @@ -425,7 +426,7 @@ func TestQuery(t *testing.T) { env := MockEnvBin(t) info := MockInfoBin(t, "creator") msg := []byte(`{"verifier": "fred", "beneficiary": "bob"}`) - _, _, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + _, _, err := Instantiate(cache, id, env, info, msg, &igasMeter1, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) // invalid query @@ -433,7 +434,7 @@ func TestQuery(t *testing.T) { igasMeter2 := GasMeter(gasMeter2) store.SetGasMeter(gasMeter2) query := []byte(`{"Raw":{"val":"config"}}`) - data, _, err := Query(cache, id, env, query, &igasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + data, _, err := Query(cache, id, env, query, &igasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var badResp types.QueryResponse err = json.Unmarshal(data, &badResp) @@ -445,7 +446,7 @@ func TestQuery(t *testing.T) { igasMeter3 := GasMeter(gasMeter3) store.SetGasMeter(gasMeter3) query = []byte(`{"verifier":{}}`) - data, _, err = Query(cache, id, env, query, &igasMeter3, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + data, _, err = Query(cache, id, env, query, &igasMeter3, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var qres types.QueryResponse err = json.Unmarshal(data, &qres) @@ -471,7 +472,7 @@ func TestHackatomQuerier(t *testing.T) { query := []byte(`{"other_balance":{"address":"foobar"}}`) // TODO The query happens before the contract is initialized. How is this legal? env := MockEnvBin(t) - data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var qres types.QueryResponse err = json.Unmarshal(data, &qres) @@ -522,7 +523,7 @@ func TestCustomReflectQuerier(t *testing.T) { query, err := json.Marshal(queryMsg) require.NoError(t, err) env := MockEnvBin(t) - data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG) + data, _, err := Query(cache, id, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_MEMORY_LIMIT, TESTING_PRINT_DEBUG) require.NoError(t, err) var qres types.QueryResponse err = json.Unmarshal(data, &qres) diff --git a/api/mocks.go b/api/mocks.go index 095d10c99..8823901a1 100644 --- a/api/mocks.go +++ b/api/mocks.go @@ -41,16 +41,16 @@ func MockEnvBin(t *testing.T) []byte { func MockInfo(sender types.HumanAddress, funds []types.Coin) types.MessageInfo { return types.MessageInfo{ - Sender: sender, + Sender: sender, SentFunds: funds, } } func MockInfoWithFunds(sender types.HumanAddress) types.MessageInfo { return MockInfo(sender, []types.Coin{{ - Denom: "ATOM", - Amount: "100", - }}) + Denom: "ATOM", + Amount: "100", + }}) } func MockInfoBin(t *testing.T, sender types.HumanAddress) []byte { diff --git a/builders/Dockerfile.alpine b/builders/Dockerfile.alpine index b1d873b0e..6ae04f2fb 100644 --- a/builders/Dockerfile.alpine +++ b/builders/Dockerfile.alpine @@ -1,5 +1,5 @@ # we build with go and rust -FROM golang:1.14-alpine3.12 +FROM golang:1.15-alpine3.12 ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ @@ -15,12 +15,12 @@ RUN set -eux; \ RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init" RUN chmod +x rustup-init -RUN ./rustup-init -y --no-modify-path --default-toolchain nightly-2020-10-24; rm rustup-init +RUN ./rustup-init -y --no-modify-path --default-toolchain 1.49.0; rm rustup-init RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME # needed for # /usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory -ENV LIBRARY_PATH=/usr/local/rustup/toolchains/nightly-2020-10-24-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib:$LIBRARY_PATH +ENV LIBRARY_PATH=/usr/local/rustup/toolchains/1.49.0-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib:$LIBRARY_PATH # prepare go cache dirs RUN mkdir -p /.cache/go-build diff --git a/builders/Dockerfile.centos7 b/builders/Dockerfile.centos7 index 138b2c84b..f66bf5b5d 100644 --- a/builders/Dockerfile.centos7 +++ b/builders/Dockerfile.centos7 @@ -12,7 +12,7 @@ ENV RUSTUP_HOME=/usr/local/rustup \ RUN url="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"; \ wget "$url"; \ chmod +x rustup-init; \ - ./rustup-init -y --no-modify-path --default-toolchain nightly-2020-10-24; \ + ./rustup-init -y --no-modify-path --default-toolchain 1.49.0; \ rm rustup-init; \ chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ rustup --version; \ diff --git a/builders/Dockerfile.cross b/builders/Dockerfile.cross index f36381caa..1a967ba8c 100644 --- a/builders/Dockerfile.cross +++ b/builders/Dockerfile.cross @@ -1,5 +1,4 @@ -# We don't use this Rust version but need an image with a Rust environment -FROM rust:1.47.0-buster +FROM rust:1.49.0-buster # Install build dependencies RUN apt-get update @@ -16,8 +15,7 @@ ENV LLVM_SYS_80_PREFIX=/usr/lib/llvm-8 WORKDIR /opt -# Pin to proper nightly and add macOS Rust target -RUN rustup default nightly-2020-10-24 +# Add macOS Rust target RUN rustup target add x86_64-apple-darwin # Build osxcross diff --git a/builders/Makefile b/builders/Makefile index b8673e196..93a9e4915 100644 --- a/builders/Makefile +++ b/builders/Makefile @@ -1,6 +1,6 @@ # Versioned by a simple counter that is not bound to a specific CosmWasm version # See builders/README.md -BUILDERS_PREFIX := cosmwasm/go-ext-builder:0003 +BUILDERS_PREFIX := cosmwasm/go-ext-builder:0004 .PHONY: docker-image-centos7 docker-image-centos7: diff --git a/builders/README.md b/builders/README.md index 7fa22b610..2110aaf2d 100644 --- a/builders/README.md +++ b/builders/README.md @@ -14,6 +14,11 @@ can do the cross-compilation. ## Changelog +**Version 0004:** + +- Update Rust to 1.49.0. +- Alpine: Update Go to 1.15 + **Version 0003:** - Avoid pre-fetching of dependences to decouple builders from source code. @@ -34,7 +39,7 @@ can do the cross-compilation. Create a local docker image, capable of cross-compling linux and macos dynamic libs: ```sh -cd builders && make docker-images +(cd builders && make docker-images) ``` Then in the repo root, `make release-build` will use the above docker image and diff --git a/builders/guest/build_muslc.sh b/builders/guest/build_muslc.sh index 6a7bf3e2b..47a678a51 100644 --- a/builders/guest/build_muslc.sh +++ b/builders/guest/build_muslc.sh @@ -1,4 +1,4 @@ #!/bin/sh -cargo build --release --features backtraces --example muslc +cargo build --release --example muslc cp /code/target/release/examples/libmuslc.a /code/api/libwasmvm_muslc.a diff --git a/cmd/main.go b/cmd/main.go index d49bd9237..699fa99b5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -9,7 +9,8 @@ import ( const SUPPORTED_FEATURES = "staking" const PRINT_DEBUG = true -const CACHE_SIZE = 100 // MiB +const MEMORY_LIMIT = 32 // MiB +const CACHE_SIZE = 100 // MiB // This is just a demo to ensure we can compile a static go binary func main() { @@ -22,7 +23,7 @@ func main() { fmt.Println("Loaded!") os.MkdirAll("tmp", 0755) - vm, err := wasmvm.NewVM("tmp", SUPPORTED_FEATURES, PRINT_DEBUG, CACHE_SIZE) + vm, err := wasmvm.NewVM("tmp", SUPPORTED_FEATURES, MEMORY_LIMIT, PRINT_DEBUG, CACHE_SIZE) if err != nil { panic(err) } diff --git a/go.mod b/go.mod index 7d6ec1a70..b626b6c68 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/CosmWasm/wasmvm -go 1.14 +go 1.15 require ( github.com/kr/pretty v0.1.0 // indirect diff --git a/lib.go b/lib.go index c5144de88..6e4f3f384 100644 --- a/lib.go +++ b/lib.go @@ -30,22 +30,24 @@ type GasMeter = api.GasMeter // You should create an instance with its own subdirectory to manage state inside, // and call it for all cosmwasm code related actions. type VM struct { - cache api.Cache - printDebug bool + cache api.Cache + memoryLimit uint32 // memory limit of each contract execution (in MiB) + printDebug bool } // NewVM creates a new VM. // // `dataDir` is a base directory for Wasm blobs and various caches. // `supportedFeatures` is a comma separated list of features suppored by the chain. +// `memoryLimit` is the memory limit of each contract execution (in MiB) // `printDebug` is a flag to enable/disable printing debug logs from the contract to STDOUT. This should be false in production environments. // `cacheSize` sets the size in MiB of an in-memory cache for e.g. module caching. Set to 0 to disable. -func NewVM(dataDir string, supportedFeatures string, printDebug bool, cacheSize uint32) (*VM, error) { +func NewVM(dataDir string, supportedFeatures string, memoryLimit uint32, printDebug bool, cacheSize uint32) (*VM, error) { cache, err := api.InitCache(dataDir, supportedFeatures, cacheSize) if err != nil { return nil, err } - return &VM{cache: cache, printDebug: printDebug}, nil + return &VM{cache: cache, memoryLimit: memoryLimit, printDebug: printDebug}, nil } // Cleanup should be called when no longer using this to free resources on the rust-side @@ -105,7 +107,7 @@ func (vm *VM) Instantiate( if err != nil { return nil, 0, err } - data, gasUsed, err := api.Instantiate(vm.cache, code, envBin, infoBin, initMsg, &gasMeter, store, &goapi, &querier, gasLimit, vm.printDebug) + data, gasUsed, err := api.Instantiate(vm.cache, code, envBin, infoBin, initMsg, &gasMeter, store, &goapi, &querier, gasLimit, vm.memoryLimit, vm.printDebug) if err != nil { return nil, gasUsed, err } @@ -146,7 +148,7 @@ func (vm *VM) Execute( if err != nil { return nil, 0, err } - data, gasUsed, err := api.Handle(vm.cache, code, envBin, infoBin, executeMsg, &gasMeter, store, &goapi, &querier, gasLimit, vm.printDebug) + data, gasUsed, err := api.Handle(vm.cache, code, envBin, infoBin, executeMsg, &gasMeter, store, &goapi, &querier, gasLimit, vm.memoryLimit, vm.printDebug) if err != nil { return nil, gasUsed, err } @@ -179,7 +181,7 @@ func (vm *VM) Query( if err != nil { return nil, 0, err } - data, gasUsed, err := api.Query(vm.cache, code, envBin, queryMsg, &gasMeter, store, &goapi, &querier, gasLimit, vm.printDebug) + data, gasUsed, err := api.Query(vm.cache, code, envBin, queryMsg, &gasMeter, store, &goapi, &querier, gasLimit, vm.memoryLimit, vm.printDebug) if err != nil { return nil, gasUsed, err } @@ -220,7 +222,7 @@ func (vm *VM) Migrate( if err != nil { return nil, 0, err } - data, gasUsed, err := api.Migrate(vm.cache, code, envBin, infoBin, migrateMsg, &gasMeter, store, &goapi, &querier, gasLimit, vm.printDebug) + data, gasUsed, err := api.Migrate(vm.cache, code, envBin, infoBin, migrateMsg, &gasMeter, store, &goapi, &querier, gasLimit, vm.memoryLimit, vm.printDebug) if err != nil { return nil, gasUsed, err } diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index ba1ea0f2b..000000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly-2020-10-24 diff --git a/src/cache.rs b/src/cache.rs index ff0c54304..99c9c756f 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -14,11 +14,11 @@ use crate::storage::GoStorage; #[repr(C)] pub struct cache_t {} -pub fn to_cache(ptr: *mut cache_t) -> Option<&'static mut Cache> { +pub fn to_cache(ptr: *mut cache_t) -> Option<&'static mut Cache> { if ptr.is_null() { None } else { - let c = unsafe { &mut *(ptr as *mut Cache) }; + let c = unsafe { &mut *(ptr as *mut Cache) }; Some(c) } } @@ -48,7 +48,7 @@ pub fn do_init_cache( data_dir: Buffer, supported_features: Buffer, cache_size: u32, -) -> Result<*mut Cache, Error> { +) -> Result<*mut Cache, Error> { let dir = unsafe { data_dir.read() }.ok_or_else(|| Error::empty_arg(DATA_DIR_ARG))?; let dir_str = String::from_utf8(dir.to_vec())?; // parse the supported features diff --git a/src/error/rust.rs b/src/error/rust.rs index ef6a95c07..7d518949a 100644 --- a/src/error/rust.rs +++ b/src/error/rust.rs @@ -82,7 +82,7 @@ impl RustError { impl From for RustError { fn from(source: VmError) -> Self { match source { - VmError::GasDepletion => RustError::out_of_gas(), + VmError::GasDepletion { .. } => RustError::out_of_gas(), _ => RustError::vm_err(source), } } diff --git a/src/lib.rs b/src/lib.rs index 8034d6725..c87b4e44a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,17 +23,17 @@ use std::panic::{catch_unwind, AssertUnwindSafe}; use cosmwasm_vm::{ call_handle_raw, call_init_raw, call_migrate_raw, call_query_raw, Backend, Cache, Checksum, - InstanceOptions, + InstanceOptions, Size, }; use crate::args::{CACHE_ARG, CODE_ID_ARG, ENV_ARG, GAS_USED_ARG, INFO_ARG, MSG_ARG, WASM_ARG}; use crate::cache::{cache_t, to_cache}; use crate::error::{handle_c_error, Error}; -fn into_backend(db: DB, api: GoApi, querier: GoQuerier) -> Backend { +fn into_backend(db: DB, api: GoApi, querier: GoQuerier) -> Backend { Backend { - storage: GoStorage::new(db), api, + storage: GoStorage::new(db), querier, } } @@ -48,7 +48,7 @@ fn into_backend(db: DB, api: GoApi, querier: GoQuerier) -> Backend) }; + let _ = unsafe { Box::from_raw(cache as *mut Cache) }; } } @@ -64,7 +64,7 @@ pub extern "C" fn create(cache: *mut cache_t, wasm: Buffer, err: Option<&mut Buf } fn do_create( - cache: &mut Cache, + cache: &mut Cache, wasm: Buffer, ) -> Result { let wasm = unsafe { wasm.read() }.ok_or_else(|| Error::empty_arg(WASM_ARG))?; @@ -84,7 +84,7 @@ pub extern "C" fn get_code(cache: *mut cache_t, id: Buffer, err: Option<&mut Buf } fn do_get_code( - cache: &mut Cache, + cache: &mut Cache, id: Buffer, ) -> Result, Error> { let id: Checksum = unsafe { id.read() } @@ -105,10 +105,16 @@ pub extern "C" fn instantiate( api: GoApi, querier: GoQuerier, gas_limit: u64, + memory_limit: u32, // in MiB print_debug: bool, gas_used: Option<&mut u64>, err: Option<&mut Buffer>, ) -> Buffer { + let memory_limit = Size::mebi( + memory_limit + .try_into() + .expect("Cannot convert u32 to usize. What kind of system is this?"), + ); let r = match to_cache(cache) { Some(c) => catch_unwind(AssertUnwindSafe(move || { do_init( @@ -121,6 +127,7 @@ pub extern "C" fn instantiate( api, querier, gas_limit, + memory_limit, print_debug, gas_used, ) @@ -133,7 +140,7 @@ pub extern "C" fn instantiate( } fn do_init( - cache: &mut Cache, + cache: &mut Cache, code_id: Buffer, env: Buffer, info: Buffer, @@ -142,6 +149,7 @@ fn do_init( api: GoApi, querier: GoQuerier, gas_limit: u64, + memory_limit: Size, print_debug: bool, gas_used: Option<&mut u64>, ) -> Result, Error> { @@ -156,6 +164,7 @@ fn do_init( let backend = into_backend(db, api, querier); let options = InstanceOptions { gas_limit, + memory_limit, print_debug, }; let mut instance = cache.get_instance(&code_id, backend, options)?; @@ -177,10 +186,16 @@ pub extern "C" fn handle( api: GoApi, querier: GoQuerier, gas_limit: u64, + memory_limit: u32, // in MiB print_debug: bool, gas_used: Option<&mut u64>, err: Option<&mut Buffer>, ) -> Buffer { + let memory_limit = Size::mebi( + memory_limit + .try_into() + .expect("Cannot convert u32 to usize. What kind of system is this?"), + ); let r = match to_cache(cache) { Some(c) => catch_unwind(AssertUnwindSafe(move || { do_handle( @@ -193,6 +208,7 @@ pub extern "C" fn handle( api, querier, gas_limit, + memory_limit, print_debug, gas_used, ) @@ -205,7 +221,7 @@ pub extern "C" fn handle( } fn do_handle( - cache: &mut Cache, + cache: &mut Cache, code_id: Buffer, env: Buffer, info: Buffer, @@ -214,6 +230,7 @@ fn do_handle( api: GoApi, querier: GoQuerier, gas_limit: u64, + memory_limit: Size, print_debug: bool, gas_used: Option<&mut u64>, ) -> Result, Error> { @@ -228,6 +245,7 @@ fn do_handle( let backend = into_backend(db, api, querier); let options = InstanceOptions { gas_limit, + memory_limit, print_debug, }; let mut instance = cache.get_instance(&code_id, backend, options)?; @@ -249,10 +267,16 @@ pub extern "C" fn migrate( api: GoApi, querier: GoQuerier, gas_limit: u64, + memory_limit: u32, // in MiB print_debug: bool, gas_used: Option<&mut u64>, err: Option<&mut Buffer>, ) -> Buffer { + let memory_limit = Size::mebi( + memory_limit + .try_into() + .expect("Cannot convert u32 to usize. What kind of system is this?"), + ); let r = match to_cache(cache) { Some(c) => catch_unwind(AssertUnwindSafe(move || { do_migrate( @@ -265,6 +289,7 @@ pub extern "C" fn migrate( api, querier, gas_limit, + memory_limit, print_debug, gas_used, ) @@ -277,7 +302,7 @@ pub extern "C" fn migrate( } fn do_migrate( - cache: &mut Cache, + cache: &mut Cache, code_id: Buffer, env: Buffer, info: Buffer, @@ -286,6 +311,7 @@ fn do_migrate( api: GoApi, querier: GoQuerier, gas_limit: u64, + memory_limit: Size, print_debug: bool, gas_used: Option<&mut u64>, ) -> Result, Error> { @@ -300,6 +326,7 @@ fn do_migrate( let backend = into_backend(db, api, querier); let options = InstanceOptions { gas_limit, + memory_limit, print_debug, }; let mut instance = cache.get_instance(&code_id, backend, options)?; @@ -320,10 +347,16 @@ pub extern "C" fn query( api: GoApi, querier: GoQuerier, gas_limit: u64, + memory_limit: u32, // in MiB print_debug: bool, gas_used: Option<&mut u64>, err: Option<&mut Buffer>, ) -> Buffer { + let memory_limit = Size::mebi( + memory_limit + .try_into() + .expect("Cannot convert u32 to usize. What kind of system is this?"), + ); let r = match to_cache(cache) { Some(c) => catch_unwind(AssertUnwindSafe(move || { do_query( @@ -335,6 +368,7 @@ pub extern "C" fn query( api, querier, gas_limit, + memory_limit, print_debug, gas_used, ) @@ -347,7 +381,7 @@ pub extern "C" fn query( } fn do_query( - cache: &mut Cache, + cache: &mut Cache, code_id: Buffer, env: Buffer, msg: Buffer, @@ -355,6 +389,7 @@ fn do_query( api: GoApi, querier: GoQuerier, gas_limit: u64, + memory_limit: Size, print_debug: bool, gas_used: Option<&mut u64>, ) -> Result, Error> { @@ -368,6 +403,7 @@ fn do_query( let backend = into_backend(db, api, querier); let options = InstanceOptions { gas_limit, + memory_limit, print_debug, }; let mut instance = cache.get_instance(&code_id, backend, options)?; diff --git a/src/tests.rs b/src/tests.rs index feff0f209..a9cadc080 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -13,6 +13,7 @@ use cosmwasm_vm::{ static CONTRACT: &[u8] = include_bytes!("../api/testdata/hackatom.wasm"); const PRINT_DEBUG: bool = false; const MEMORY_CACHE_SIZE: Size = Size::mebi(200); +const MEMORY_LIMIT: Size = Size::mebi(32); #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct InitMsg { @@ -45,6 +46,7 @@ fn handle_cpu_loop_with_cache() { let options = InstanceOptions { gas_limit: 2_000_000, + memory_limit: MEMORY_LIMIT, print_debug: PRINT_DEBUG, };