From 17c9c7db3bbb499dd76c09c1ed0f4eff5d9e7188 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 5 Jan 2021 11:50:38 -0800 Subject: [PATCH 01/50] initial add wasmer 1.0 and features --- Cargo.lock | 459 ++++++++++++++++++++++++++++-- runtime/near-vm-runner/Cargo.toml | 3 + 2 files changed, 437 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7cd7049d86b..4790344b6b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -542,7 +542,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "which", + "which 3.1.1", ] [[package]] @@ -872,7 +872,7 @@ checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" dependencies = [ "glob 0.3.0", "libc", - "libloading", + "libloading 0.5.2", ] [[package]] @@ -1026,7 +1026,16 @@ version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" dependencies = [ - "cranelift-entity", + "cranelift-entity 0.67.0", +] + +[[package]] +name = "cranelift-bforest" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +dependencies = [ + "cranelift-entity 0.68.0", ] [[package]] @@ -1036,27 +1045,56 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" dependencies = [ "byteorder", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", + "cranelift-bforest 0.67.0", + "cranelift-codegen-meta 0.67.0", + "cranelift-codegen-shared 0.67.0", + "cranelift-entity 0.67.0", "gimli 0.21.0", "log", - "regalloc", + "regalloc 0.0.30", "serde", "smallvec 1.5.1", "target-lexicon 0.11.1", "thiserror", ] +[[package]] +name = "cranelift-codegen" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +dependencies = [ + "byteorder", + "cranelift-bforest 0.68.0", + "cranelift-codegen-meta 0.68.0", + "cranelift-codegen-shared 0.68.0", + "cranelift-entity 0.68.0", + "gimli 0.22.0", + "log", + "regalloc 0.0.31", + "smallvec 1.5.1", + "target-lexicon 0.11.1", + "thiserror", +] + [[package]] name = "cranelift-codegen-meta" version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", + "cranelift-codegen-shared 0.67.0", + "cranelift-entity 0.67.0", +] + +[[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 0.68.0", + "cranelift-entity 0.68.0", ] [[package]] @@ -1065,6 +1103,12 @@ version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" +[[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.67.0" @@ -1074,13 +1118,34 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-entity" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] + [[package]] name = "cranelift-frontend" version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" dependencies = [ - "cranelift-codegen", + "cranelift-codegen 0.67.0", + "log", + "smallvec 1.5.1", + "target-lexicon 0.11.1", +] + +[[package]] +name = "cranelift-frontend" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" +dependencies = [ + "cranelift-codegen 0.68.0", "log", "smallvec 1.5.1", "target-lexicon 0.11.1", @@ -1092,7 +1157,7 @@ version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7054533ae1fc2048c1a6110bdf8f4314b77c60329ec6a7df79d2cfb84e3dcc1c" dependencies = [ - "cranelift-codegen", + "cranelift-codegen 0.67.0", "raw-cpuid", "target-lexicon 0.11.1", ] @@ -1103,9 +1168,9 @@ version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7aee0e0b68eba99f99a4923212d97aca9e44655ca8246f07fffe11236109b0d0" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", + "cranelift-codegen 0.67.0", + "cranelift-entity 0.67.0", + "cranelift-frontend 0.67.0", "log", "serde", "thiserror", @@ -1249,6 +1314,41 @@ dependencies = [ "zeroize", ] +[[package]] +name = "darling" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2 1.0.24", + "quote 1.0.7", + "strsim 0.9.3", + "syn 1.0.54", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote 1.0.7", + "syn 1.0.54", +] + [[package]] name = "delay-detector" version = "0.1.0" @@ -1492,6 +1592,28 @@ dependencies = [ "syn 1.0.54", ] +[[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 = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" +dependencies = [ + "darling", + "proc-macro2 1.0.24", + "quote 1.0.7", + "syn 1.0.54", +] + [[package]] name = "env_logger" version = "0.7.1" @@ -1959,6 +2081,17 @@ dependencies = [ "stable_deref_trait", ] +[[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" @@ -2234,6 +2367,12 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.1.5" @@ -2572,6 +2711,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "libloading" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9367bdfa836b7e3cf895867f7a570283444da90562980ec2263d6e1569b16bc" +dependencies = [ + "cfg-if 1.0.0", + "winapi 0.3.9", +] + [[package]] name = "librocksdb-sys" version = "6.10.2" @@ -2606,7 +2755,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b3ef22989d6e83232ef628dc739c0a3f39a556c4b53d1943e6731bc35b7eea9" dependencies = [ "capstone", - "cranelift-codegen", + "cranelift-codegen 0.67.0", "derive_more", "dynasm 0.5.2", "dynasmrt 0.5.2", @@ -2764,6 +2913,15 @@ dependencies = [ "winapi 0.3.9", ] +[[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.6" @@ -3454,6 +3612,7 @@ dependencies = [ "parity-wasm", "pwasm-utils", "wabt", + "wasmer", "wasmer-runtime-core-near", "wasmer-runtime-near", "wasmtime", @@ -3727,6 +3886,10 @@ name = "object" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] name = "once_cell" @@ -4500,6 +4663,17 @@ dependencies = [ "smallvec 1.5.1", ] +[[package]] +name = "regalloc" +version = "0.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" +dependencies = [ + "log", + "rustc-hash", + "smallvec 1.5.1", +] + [[package]] name = "regex" version = "1.4.2" @@ -5133,6 +5307,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" + [[package]] name = "strsim" version = "0.10.0" @@ -6009,6 +6189,170 @@ dependencies = [ "quote 1.0.7", ] +[[package]] +name = "wasmer" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94b1ece7c894857344ae93506686ae36ccd867b4ed55819c06d2316d009098d4" +dependencies = [ + "cfg-if 0.1.10", + "indexmap", + "more-asserts", + "target-lexicon 0.11.1", + "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 0.3.9", +] + +[[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_bytes", + "smallvec 1.5.1", + "target-lexicon 0.11.1", + "thiserror", + "wasmer-types", + "wasmer-vm", + "wasmparser 0.65.0", +] + +[[package]] +name = "wasmer-compiler-cranelift" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60d68fb05dbe908724901b680070560944d99d04c52c763e98124aa988ac6dd0" +dependencies = [ + "cranelift-codegen 0.68.0", + "cranelift-frontend 0.68.0", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec 1.5.1", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-compiler-singlepass" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81f91c9471113efc731fdd9f54f6fb82fab4c00498281966fcc4a87cdf360ea5" +dependencies = [ + "byteorder", + "dynasm 1.0.0", + "dynasmrt 1.0.0", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec 1.5.1", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-derive" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca24205ffdf2d3b1a9c01219f4f3f0a1382658680abe73bc5b146f941adeeb8e" +dependencies = [ + "proc-macro-error", + "proc-macro2 1.0.24", + "quote 1.0.7", + "syn 1.0.54", +] + +[[package]] +name = "wasmer-engine" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed16436a9813d92f434e1d40fdf91b45ca30f351a799f793015359acca86b" +dependencies = [ + "backtrace", + "bincode", + "lazy_static", + "memmap2", + "more-asserts", + "rustc-demangle", + "serde", + "serde_bytes", + "target-lexicon 0.11.1", + "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 0.3.9", +] + +[[package]] +name = "wasmer-engine-native" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a21d6c5ae0c384ba2f01f598c95b01d4da2eaec3376fb96de2ded38c54143a0" +dependencies = [ + "bincode", + "cfg-if 0.1.10", + "leb128", + "libloading 0.6.6", + "serde", + "tempfile", + "tracing", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-types", + "wasmer-vm", + "which 4.0.2", +] + +[[package]] +name = "wasmer-object" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06e007e73ec7775aecc61045092dabfcff1e9f228129cd129e76a3e6aae26454" +dependencies = [ + "object 0.22.0", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + [[package]] name = "wasmer-runtime-core-near" version = "0.17.1" @@ -6071,6 +6415,37 @@ dependencies = [ "wasmer-runtime-core-near", ] +[[package]] +name = "wasmer-types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dbba7a95edb61b40daa43079979fc3212234e1645a15b8c527c36decad59fc6" +dependencies = [ + "cranelift-entity 0.68.0", + "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", + "memoffset 0.6.1", + "more-asserts", + "region", + "serde", + "thiserror", + "wasmer-types", + "winapi 0.3.9", +] + [[package]] name = "wasmparser" version = "0.51.4" @@ -6089,6 +6464,12 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a950e6a618f62147fd514ff445b2a0b53120d382751960797f85f058c7eda9b9" +[[package]] +name = "wasmparser" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + [[package]] name = "wasmtime" version = "0.20.0" @@ -6121,9 +6502,9 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c01df908e54d40bed80326ade122825d464888991beafd950d186f1be309c2" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", + "cranelift-codegen 0.67.0", + "cranelift-entity 0.67.0", + "cranelift-frontend 0.67.0", "cranelift-wasm", "wasmtime-environ", ] @@ -6152,8 +6533,8 @@ checksum = "9c0d7401bf253b7b1f426afd70d285bb23ea9a1c7605d6af788c95db5084edf5" dependencies = [ "anyhow", "cfg-if 0.1.10", - "cranelift-codegen", - "cranelift-entity", + "cranelift-codegen 0.67.0", + "cranelift-entity 0.67.0", "cranelift-wasm", "gimli 0.21.0", "indexmap", @@ -6172,9 +6553,9 @@ checksum = "8c838a108318e7c5a2201addb3d3b27a6ef3d142f0eb0addc815b9c2541e5db5" dependencies = [ "anyhow", "cfg-if 0.1.10", - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", + "cranelift-codegen 0.67.0", + "cranelift-entity 0.67.0", + "cranelift-frontend 0.67.0", "cranelift-native", "cranelift-wasm", "gimli 0.21.0", @@ -6202,7 +6583,7 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9db30040e0c99999706b4baf7d49b9e0e793672c4e988f5855194d08ac2dbd52" dependencies = [ - "cranelift-codegen", + "cranelift-codegen 0.67.0", "lightbeam", "wasmparser 0.59.0", "wasmtime-environ", @@ -6259,6 +6640,24 @@ dependencies = [ "winapi 0.3.9", ] +[[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 = "web-sys" version = "0.3.46" @@ -6297,6 +6696,16 @@ dependencies = [ "libc", ] +[[package]] +name = "which" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +dependencies = [ + "libc", + "thiserror", +] + [[package]] name = "widestring" version = "0.4.3" diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index eb65c7aaa0d..fb48dd04f07 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -16,6 +16,7 @@ This crate implements the specification of the interface that Near blockchain ex borsh = "0.7.1" wasmer-runtime = { version="0.17.1", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near" } wasmer-runtime-core = {version = "0.17.1", package = "wasmer-runtime-core-near" } +wasmer = { version = "1.0.0", features = ["singlepass"], optional = true } pwasm-utils = "0.12" parity-wasm = "0.41" wasmtime = { version = "0.20.0", default-features = false, optional = true } @@ -35,9 +36,11 @@ bencher = "^0.1.5" [features] default = [ "wasmer_default" ] wasmtime_vm = [ "wasmtime", "anyhow"] +wasmer1_vm = [ "wasmer" ] lightbeam = ["wasmtime/lightbeam"] wasmer_default = [] wasmtime_default = ["wasmtime_vm"] +wasmer1_default = [ "wasmer1_vm" ] no_cpu_compatibility_checks = [] protocol_feature_evm = ["near-runtime-fees/protocol_feature_evm", "near-evm-runner/protocol_feature_evm"] From bef831c6a497472cc2fc8568e81d5c98cd44ed87 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 5 Jan 2021 12:15:24 -0800 Subject: [PATCH 02/50] wasmtime neard compiles --- neard/Cargo.toml | 1 + runtime/runtime/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/neard/Cargo.toml b/neard/Cargo.toml index 0338c3f909d..88042c2e40e 100644 --- a/neard/Cargo.toml +++ b/neard/Cargo.toml @@ -66,6 +66,7 @@ protocol_feature_rectify_inflation = ["near-epoch-manager/protocol_feature_recti protocol_feature_evm = ["near-primitives/protocol_feature_evm", "node-runtime/protocol_feature_evm", "near-chain-configs/protocol_feature_evm", "near-chain/protocol_feature_evm"] nightly_protocol_features = ["nightly_protocol", "near-primitives/nightly_protocol_features", "near-client/nightly_protocol_features", "near-epoch-manager/nightly_protocol_features", "near-store/nightly_protocol_features", "protocol_feature_forward_chunk_parts", "protocol_feature_rectify_inflation", "protocol_feature_evm"] nightly_protocol = ["near-primitives/nightly_protocol", "near-jsonrpc/nightly_protocol"] +wasmtime_vm = ["node-runtime/wasmtime_vm"] [[bin]] path = "src/main.rs" diff --git a/runtime/runtime/Cargo.toml b/runtime/runtime/Cargo.toml index 078c7c23569..33ccf24a9ce 100644 --- a/runtime/runtime/Cargo.toml +++ b/runtime/runtime/Cargo.toml @@ -36,6 +36,7 @@ near-evm-runner = { path = "../../runtime/near-evm-runner", optional = true } default = [] dump_errors_schema = ["near-vm-errors/dump_errors_schema"] protocol_feature_evm = ["near-evm-runner/protocol_feature_evm", "near-primitives/protocol_feature_evm", "near-runtime-fees/protocol_feature_evm", "near-vm-runner/protocol_feature_evm"] +wasmtime_vm = ["near-vm-runner/wasmtime_vm"] # Use this feature to enable counting of fees and costs applied. costs_counting = ["near-vm-logic/costs_counting", "near-vm-runner/costs_counting"] From 22a3610f7a3f32fbb2acebdd579ad51fe0c59f1a Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 5 Jan 2021 12:19:29 -0800 Subject: [PATCH 03/50] wasmtime neard compiles --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 28254ec33f7..339b654de59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,3 +114,4 @@ protocol_feature_forward_chunk_parts = ["neard/protocol_feature_forward_chunk_pa nightly_protocol = ["near-primitives/nightly_protocol", "near-jsonrpc/nightly_protocol"] nightly_protocol_features = ["nightly_protocol", "neard/nightly_protocol_features", "protocol_feature_evm"] protocol_feature_evm = ["neard/protocol_feature_evm", "testlib/protocol_feature_evm", "near-runtime-standalone/protocol_feature_evm", "runtime-params-estimator/protocol_feature_evm"] +wasmtime_vm = ["neard/wasmtime_vm"] \ No newline at end of file From d24873310f6d8599c3e54ddbf32f46f5821121e4 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 5 Jan 2021 13:12:40 -0800 Subject: [PATCH 04/50] all driver code --- runtime/near-vm-runner/src/wasmer1_runner.rs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 runtime/near-vm-runner/src/wasmer1_runner.rs diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs new file mode 100644 index 00000000000..76ff87b2958 --- /dev/null +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -0,0 +1,2 @@ +fn run_wasmer1() {} +fn compile_module() {} From 4408a0ee8cd41020204c1ef57a3890636b1e6092 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 5 Jan 2021 18:33:29 -0800 Subject: [PATCH 05/50] wip wasmer 1.0 --- Cargo.toml | 3 +- neard/Cargo.toml | 1 + runtime/near-vm-logic/Cargo.toml | 2 +- runtime/near-vm-logic/src/config.rs | 15 ++- runtime/near-vm-runner-standalone/Cargo.toml | 2 +- runtime/near-vm-runner-standalone/src/main.rs | 1 + runtime/near-vm-runner/Cargo.toml | 2 +- runtime/near-vm-runner/src/imports.rs | 43 +++++++ runtime/near-vm-runner/src/lib.rs | 5 + runtime/near-vm-runner/src/runner.rs | 48 +++++++ runtime/near-vm-runner/src/wasmer1_runner.rs | 121 +++++++++++++++++- .../near-vm-runner/tests/test_error_cases.rs | 3 + runtime/runtime/Cargo.toml | 1 + 13 files changed, 239 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 339b654de59..c99869075b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,4 +114,5 @@ protocol_feature_forward_chunk_parts = ["neard/protocol_feature_forward_chunk_pa nightly_protocol = ["near-primitives/nightly_protocol", "near-jsonrpc/nightly_protocol"] nightly_protocol_features = ["nightly_protocol", "neard/nightly_protocol_features", "protocol_feature_evm"] protocol_feature_evm = ["neard/protocol_feature_evm", "testlib/protocol_feature_evm", "near-runtime-standalone/protocol_feature_evm", "runtime-params-estimator/protocol_feature_evm"] -wasmtime_vm = ["neard/wasmtime_vm"] \ No newline at end of file +wasmtime_vm = ["neard/wasmtime_vm"] +wasmer1_vm = ["neard/wasmer1_vm"] \ No newline at end of file diff --git a/neard/Cargo.toml b/neard/Cargo.toml index 88042c2e40e..ebe3c1a6fc8 100644 --- a/neard/Cargo.toml +++ b/neard/Cargo.toml @@ -67,6 +67,7 @@ protocol_feature_evm = ["near-primitives/protocol_feature_evm", "node-runtime/pr nightly_protocol_features = ["nightly_protocol", "near-primitives/nightly_protocol_features", "near-client/nightly_protocol_features", "near-epoch-manager/nightly_protocol_features", "near-store/nightly_protocol_features", "protocol_feature_forward_chunk_parts", "protocol_feature_rectify_inflation", "protocol_feature_evm"] nightly_protocol = ["near-primitives/nightly_protocol", "near-jsonrpc/nightly_protocol"] wasmtime_vm = ["node-runtime/wasmtime_vm"] +wasmer1_vm = ["node-runtime/wasmer1_vm"] [[bin]] path = "src/main.rs" diff --git a/runtime/near-vm-logic/Cargo.toml b/runtime/near-vm-logic/Cargo.toml index f95e70c9840..8dddc92d349 100644 --- a/runtime/near-vm-logic/Cargo.toml +++ b/runtime/near-vm-logic/Cargo.toml @@ -32,7 +32,7 @@ serde_json = {version= "1", features= ["preserve_order"]} default = ["costs_counting"] protocol_feature_evm = ["near-runtime-fees/protocol_feature_evm"] wasmtime_default = [] - +wasmer1_default = [] # Use this feature to enable counting of fees and costs applied. costs_counting = [] diff --git a/runtime/near-vm-logic/src/config.rs b/runtime/near-vm-logic/src/config.rs index 09a71777bd9..8863f9960fa 100644 --- a/runtime/near-vm-logic/src/config.rs +++ b/runtime/near-vm-logic/src/config.rs @@ -7,10 +7,12 @@ use std::hash::{Hash, Hasher}; #[derive(Clone, Copy, Debug, Hash, Serialize, Deserialize, BorshSerialize, BorshDeserialize)] pub enum VMKind { - /// Wasmer VM. + /// Wasmer 0.17.x VM. Wasmer, /// Wasmtime VM. Wasmtime, + /// Wasmer 1.x VM. + Wasmer1, } impl Default for VMKind { @@ -19,12 +21,21 @@ impl Default for VMKind { VMKind::Wasmer } + #[cfg(feature = "wasmer1_default")] + fn default() -> Self { + VMKind::Wasmer1 + } + #[cfg(feature = "wasmtime_default")] fn default() -> Self { VMKind::Wasmtime } - #[cfg(all(not(feature = "wasmer_default"), not(feature = "wasmtime_default")))] + #[cfg(all( + not(feature = "wasmer_default"), + not(feature = "wasmer1_default"), + not(feature = "wasmtime_default") + ))] fn default() -> Self { VMKind::Wasmer } diff --git a/runtime/near-vm-runner-standalone/Cargo.toml b/runtime/near-vm-runner-standalone/Cargo.toml index 9b6e9e812b4..e2bd1f72042 100644 --- a/runtime/near-vm-runner-standalone/Cargo.toml +++ b/runtime/near-vm-runner-standalone/Cargo.toml @@ -26,7 +26,7 @@ strum = "0.18" num-rational = { version = "0.2.4" } near-vm-logic = { path = "../near-vm-logic", version = "2.3.0", features = ["costs_counting"]} -near-vm-runner = { path = "../near-vm-runner", version = "2.3.0", features = ["wasmtime_vm"] } +near-vm-runner = { path = "../near-vm-runner", version = "2.3.0", features = ["wasmtime_vm", "wasmer1_vm"] } near-runtime-fees = { path = "../near-runtime-fees", version = "2.3.0" } [features] diff --git a/runtime/near-vm-runner-standalone/src/main.rs b/runtime/near-vm-runner-standalone/src/main.rs index 18f9062d73b..6f30af7cb56 100644 --- a/runtime/near-vm-runner-standalone/src/main.rs +++ b/runtime/near-vm-runner-standalone/src/main.rs @@ -187,6 +187,7 @@ fn main() { Some(value) => match value { "wasmtime" => VMKind::Wasmtime, "wasmer" => VMKind::Wasmer, + "wasmer1" => VMKind::Wasmer1, _ => VMKind::default(), }, None => VMKind::default(), diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index fb48dd04f07..3a32ec85cd1 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -34,7 +34,7 @@ wabt = "0.9" bencher = "^0.1.5" [features] -default = [ "wasmer_default" ] +default = [ "wasmer_default", "wasmer" ] wasmtime_vm = [ "wasmtime", "anyhow"] wasmer1_vm = [ "wasmer" ] lightbeam = ["wasmtime/lightbeam"] diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 8290c125ae6..a0783b1c3e8 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -36,6 +36,30 @@ macro_rules! wrapped_imports { logic.$func( $( $arg_name, )* ) } )* + + } + pub mode wasmer1_ext { + use near_vm_logic::VMLogic; + use wasmer::{WasmerEnv, LazyInit}; + #[derive(WasmerEnv, Clone, Default)] + struct MyEnv { + #[wasmer(export)] + memory: LazyInit, + } + let env = MyEnv::default(); + + type VMResult = ::std::result::Result; + $( + #[allow(unused_parens)] + pub fn $func( env: &mut MyEnv, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { + // TODO: ctx does not exist in wasmer 1.0, either save logic in MyEnv, or + // as global consts in imports! macro (import! was only able to import functions + // and have a import_with_state syntax, but now it can import globals, and doesn't + // support import_with_state) + let logic: &mut VMLogic<'_> = unsafe { &mut *(ctx.data as *mut VMLogic<'_>) }; + logic.$func( $( $arg_name, )* ) + } + )* } #[cfg(feature = "wasmtime_vm")] @@ -94,6 +118,25 @@ macro_rules! wrapped_imports { } } + #[cfg(feature = "wasmer1_vm")] + pub(crate) fn build_wasmer1(memory: wasmer::Memory, logic: &mut VMLogic<'_>) -> + wasmer::ImportObject { + let raw_ptr = logic as *mut _ as *mut c_void; + let import_reference = ImportReference(raw_ptr); + wasmer::imports! { + move || { + let dtor = (|_: *mut c_void| {}) as fn(*mut c_void); + (import_reference.0, dtor) + }, + "env" => { + "memory" => memory, + $( + stringify!($func) => wasmer::Function::new_with_native_env(wasmer_ext::$func), + )* + }, + } + } + #[cfg(feature = "wasmtime_vm")] pub(crate) fn link_wasmtime( linker: &mut wasmtime::Linker, diff --git a/runtime/near-vm-runner/src/lib.rs b/runtime/near-vm-runner/src/lib.rs index 490d08f6258..3eb451cb23f 100644 --- a/runtime/near-vm-runner/src/lib.rs +++ b/runtime/near-vm-runner/src/lib.rs @@ -5,8 +5,13 @@ mod memory; pub mod prepare; mod runner; mod wasmer_runner; + #[cfg(feature = "wasmtime_vm")] mod wasmtime_runner; + +#[cfg(feature = "wasmer1_vm")] +mod wasmer1_runner; + pub use near_vm_errors::VMError; pub use runner::compile_module; pub use runner::run; diff --git a/runtime/near-vm-runner/src/runner.rs b/runtime/near-vm-runner/src/runner.rs index b3cc9283eec..c6158cd7896 100644 --- a/runtime/near-vm-runner/src/runner.rs +++ b/runtime/near-vm-runner/src/runner.rs @@ -56,8 +56,13 @@ pub fn run_vm<'a>( cache: Option<&'a dyn CompiledContractCache>, ) -> (Option, Option) { use crate::wasmer_runner::run_wasmer; + #[cfg(feature = "wasmtime_vm")] use crate::wasmtime_runner::wasmtime_runner::run_wasmtime; + + #[cfg(feature = "wasmer1_vm")] + use crate::wasmer1_runner::run_wasmer1; + match vm_kind { VMKind::Wasmer => run_wasmer( code_hash, @@ -90,6 +95,22 @@ pub fn run_vm<'a>( VMKind::Wasmtime => { panic!("Wasmtime is not supported, compile with '--features wasmtime_vm'") } + #[cfg(feature = "wasmer1_vm")] + VMKind::Wasmer1 => run_wasmer1( + code_hash, + code, + method_name, + ext, + context, + wasm_config, + fees_config, + promise_results, + None, + current_protocol_version, + cache, + ), + #[cfg(not(feature = "wasmer1_vm"))] + VMKind::Wasmer1 => panic!("Wasmer1 is not supported, compile with '--features wasmer1_vm'"), } } @@ -142,13 +163,33 @@ pub fn run_vm_profiled<'a>( VMKind::Wasmtime => { panic!("Wasmtime is not supported, compile with '--features wasmtime_vm'") } + #[cfg(feature = "wasmer1_vm")] + VMKind::Wasmer1 => run_wasm1( + code_hash, + code, + method_name, + ext, + context, + wasm_config, + fees_config, + promise_results, + Some(profile), + current_protocol_version, + cache, + ), + #[cfg(not(feature = "wasmer1_vm"))] + VMKind::Wasmer1 => panic!("Wasmer1 is not supported, compile with '--features wasmer1_vm'"), } } pub fn with_vm_variants(runner: fn(VMKind) -> ()) { runner(VMKind::Wasmer); + #[cfg(feature = "wasmtime_vm")] runner(VMKind::Wasmtime); + + #[cfg(feature = "wasmer1_vm")] + runner(VMKind::Wasmer1); } /// Used for testing cost of compiling a module @@ -167,6 +208,13 @@ pub fn compile_module(vm_kind: VMKind, code: &Vec) -> bool { VMKind::Wasmtime => { panic!("Wasmtime is not supported, compile with '--features wasmtime_vm'") } + #[cfg(feature = "wasmer1_vm")] + VMKind::Wasmer1 => { + use crate::wasmer1_runner::compile_module; + compile_module(code) + } + #[cfg(not(feature = "wasmer1_vm"))] + VMKind::Wasmer1 => panic!("Wasmer1 is not supported, compile with '--features wasm1_vm'"), }; false } diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 76ff87b2958..1b0c36fa056 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -1,2 +1,119 @@ -fn run_wasmer1() {} -fn compile_module() {} +use near_vm_errors::{FunctionCallError, MethodResolveError, VMError, VMLogicError}; +use wasmer::{Memory, MemoryType, Module, Pages, Singlepass, Store, JIT}; + +pub struct Wasmer1Memory(Memory); + +impl Wasmer1Memory { + pub fn new( + store: &Store, + initial_memory_pages: u32, + max_memory_pages: u32, + ) -> Result { + Ok(Wasmer1Memory( + Memory::new( + &store, + MemoryType::new(Pages(initial_memory_pages), Some(Pages(max_memory_pages)), false) + .unwrap(), + ) + .expect("TODO creating memory cannot fail"), + )) + } + + pub fn clone(&self) -> Memory { + self.0.clone() + } +} + +impl MemoryLike for Wasmer1Memory { + fn fits_memory(&self, offset: u64, len: u64) -> bool { + match offset.checked_add(len) { + None => false, + Some(end) => self.0.size().bytes() >= Bytes(end as usize), + } + } + + fn read_memory(&self, offset: u64, buffer: &mut [u8]) { + let offset = offset as usize; + for (i, cell) in self.0.view()[offset..(offset + buffer.len())].iter().enumerate() { + buffer[i] = cell.get(); + } + } + + fn read_memory_u8(&self, offset: u64) -> u8 { + self.0.view()[offset as usize].get() + } + + fn write_memory(&mut self, offset: u64, buffer: &[u8]) { + let offset = offset as usize; + self.0.view()[offset..(offset + buffer.len())] + .iter() + .zip(buffer.iter()) + .for_each(|(cell, v)| cell.set(*v)); + } +} + +pub fn run_wasmer<'a>( + code_hash: Vec, + code: &[u8], + method_name: &[u8], + ext: &mut dyn External, + context: VMContext, + wasm_config: &'a VMConfig, + fees_config: &'a RuntimeFeesConfig, + promise_results: &'a [PromiseResult], + profile: Option, + current_protocol_version: ProtocolVersion, + cache: Option<&'a dyn CompiledContractCache>, +) -> (Option, Option) { + if method_name.is_empty() { + return ( + None, + Some(VMError::FunctionCallError(FunctionCallError::MethodResolveError( + MethodResolveError::MethodEmptyName, + ))), + ); + } + + let engine = JIT::new(Singlepass::default()).engine(); + let store = Store::new(&engine); + let module = match Module::new(&store, code) { + Ok(x) => x, + Err(err) => return (None, Some(err)), + }; + + let mut memory = WasmerMemory::new( + wasm_config.limit_config.initial_memory_pages, + wasm_config.limit_config.max_memory_pages, + ) + .expect("Cannot create memory for a contract call"); + // Note that we don't clone the actual backing memory, just increase the RC. + let memory_copy = memory.clone(); + + let mut logic = VMLogic::new_with_protocol_version( + ext, + context, + wasm_config, + fees_config, + promise_results, + &mut memory, + profile, + current_protocol_version, + ); + + if logic.add_contract_compile_fee(code.len() as u64).is_err() { + return ( + Some(logic.outcome()), + Some(VMError::FunctionCallError(FunctionCallError::HostError( + near_vm_errors::HostError::GasExceeded, + ))), + ); + } + + let import_object = imports::build_wasmer1(memory_copy, &mut logic); +} + +pub fn compile_module(code: &[u8]) -> bool { + let engine = JIT::new(Singlepass::default()).engine(); + let store = Store::new(&engine); + Module::new(&store, code).is_ok() +} diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index de75d8c14e3..e22d50e3134 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -286,6 +286,8 @@ fn test_stack_overflow() { Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) ) ); + + // TODO add a Wasmer1 test? } fn memory_grow() -> Vec { @@ -389,6 +391,7 @@ fn test_bad_import_3() { let msg = match vm_kind { VMKind::Wasmer => "link error: Incorrect import type, namespace: env, name: input, expected type: global, found type: function", VMKind::Wasmtime => "\"incompatible import type for `env::input` specified\\ndesired signature was: Global(GlobalType { content: I32, mutability: Const })\\nsignatures available:\\n\\n * Func(FuncType { params: [I64], results: [] })\\n\"", + VMKind::Wasmer1 => "TODO: FILL ME" }.to_string(); assert_eq!( make_simple_contract_call_vm(&bad_import_global("env"), b"hello", vm_kind), diff --git a/runtime/runtime/Cargo.toml b/runtime/runtime/Cargo.toml index 33ccf24a9ce..1983a55cfbe 100644 --- a/runtime/runtime/Cargo.toml +++ b/runtime/runtime/Cargo.toml @@ -37,6 +37,7 @@ default = [] dump_errors_schema = ["near-vm-errors/dump_errors_schema"] protocol_feature_evm = ["near-evm-runner/protocol_feature_evm", "near-primitives/protocol_feature_evm", "near-runtime-fees/protocol_feature_evm", "near-vm-runner/protocol_feature_evm"] wasmtime_vm = ["near-vm-runner/wasmtime_vm"] +wasmer1_vm = ["near-vm-runner/wasmer1_vm"] # Use this feature to enable counting of fees and costs applied. costs_counting = ["near-vm-logic/costs_counting", "near-vm-runner/costs_counting"] From ee61fbc089ea4e6efed2a86f5ba31298b19576ba Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 6 Jan 2021 17:13:14 -0800 Subject: [PATCH 06/50] translate unsafe wasmer 0.17 ctx.data as safe 1.0 myEnv.logic --- runtime/near-vm-runner/src/imports.rs | 20 +++------ runtime/near-vm-runner/src/wasmer1_runner.rs | 47 +++++++++++++++++++- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index a0783b1c3e8..3a162b23d09 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -38,25 +38,22 @@ macro_rules! wrapped_imports { )* } - pub mode wasmer1_ext { + pub mod wasmer1_ext { use near_vm_logic::VMLogic; use wasmer::{WasmerEnv, LazyInit}; #[derive(WasmerEnv, Clone, Default)] struct MyEnv { #[wasmer(export)] memory: LazyInit, + #[wasmer(export)] + logic: LazyInit, } - let env = MyEnv::default(); type VMResult = ::std::result::Result; $( #[allow(unused_parens)] pub fn $func( env: &mut MyEnv, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { - // TODO: ctx does not exist in wasmer 1.0, either save logic in MyEnv, or - // as global consts in imports! macro (import! was only able to import functions - // and have a import_with_state syntax, but now it can import globals, and doesn't - // support import_with_state) - let logic: &mut VMLogic<'_> = unsafe { &mut *(ctx.data as *mut VMLogic<'_>) }; + let logic: &mut VMLogic<'_> = env.logic_ref()?; logic.$func( $( $arg_name, )* ) } )* @@ -121,17 +118,12 @@ macro_rules! wrapped_imports { #[cfg(feature = "wasmer1_vm")] pub(crate) fn build_wasmer1(memory: wasmer::Memory, logic: &mut VMLogic<'_>) -> wasmer::ImportObject { - let raw_ptr = logic as *mut _ as *mut c_void; - let import_reference = ImportReference(raw_ptr); + let env = MyEnv {logic, memory: wasmer::LazyInit::new(memory.clone())}; wasmer::imports! { - move || { - let dtor = (|_: *mut c_void| {}) as fn(*mut c_void); - (import_reference.0, dtor) - }, "env" => { "memory" => memory, $( - stringify!($func) => wasmer::Function::new_with_native_env(wasmer_ext::$func), + stringify!($func) => wasmer::Function::new_with_native_env(&store, env.clone(), wasmer_ext::$func), )* }, } diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 1b0c36fa056..704f2e1d658 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -52,7 +52,27 @@ impl MemoryLike for Wasmer1Memory { } } -pub fn run_wasmer<'a>( +fn check_method(module: &Module, method_name: &str) -> Result<(), VMError> { + let info = module.info(); + use wasmer_types::{ExportIndex, Function}; + if let Some(ExportIndex(Function(index))) = info.exports.get(method_name) { + let func = info.signatures.get(index.clone()).unwrap(); + let sig = info.signatures.get(func.clone()).unwrap(); + if sig.params().is_empty() && sig.returns().is_empty() { + Ok(()) + } else { + Err(VMError::FunctionCallError(FunctionCallError::MethodResolveError( + MethodResolveError::MethodInvalidSignature, + ))) + } + } else { + Err(VMError::FunctionCallError(FunctionCallError::MethodResolveError( + MethodResolveError::MethodNotFound, + ))) + } +} + +pub fn run_wasmer1<'a>( code_hash: Vec, code: &[u8], method_name: &[u8], @@ -108,8 +128,31 @@ pub fn run_wasmer<'a>( ))), ); } - let import_object = imports::build_wasmer1(memory_copy, &mut logic); + + let method_name = match std::str::from_utf8(method_name) { + Ok(x) => x, + Err(_) => { + return ( + None, + Some(VMError::FunctionCallError(FunctionCallError::MethodResolveError( + MethodResolveError::MethodUTF8Error, + ))), + ) + } + }; + + if let Err(e) = check_method(&module, method_name) { + return (None, Some(e)); + } + + match Instance::new(&module, &import_object) { + Ok(instance) => match instance.call(&method_name, &[]) { + Ok(_) => (Some(logic.outcome()), None), + Err(err) => (Some(logic.outcome()), Some(err.into_vm_error())), + }, + Err(err) => (Some(logic.outcome()), Some(err.into_vm_error())), + } } pub fn compile_module(code: &[u8]) -> bool { From 7b82b8d3f06500c9ab150ea91e89aa566f0da50b Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 6 Jan 2021 17:58:34 -0800 Subject: [PATCH 07/50] fix most compile errors except wasmer error conversion --- Cargo.lock | 1 + runtime/near-vm-logic/src/logic.rs | 3 +++ runtime/near-vm-runner/Cargo.toml | 5 +++-- runtime/near-vm-runner/src/imports.rs | 15 ++++++++------- runtime/near-vm-runner/src/runner.rs | 6 +++++- runtime/near-vm-runner/src/wasmer1_runner.rs | 16 +++++++++++----- 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4790344b6b2..6b5b62231a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3615,6 +3615,7 @@ dependencies = [ "wasmer", "wasmer-runtime-core-near", "wasmer-runtime-near", + "wasmer-types", "wasmtime", ] diff --git a/runtime/near-vm-logic/src/logic.rs b/runtime/near-vm-logic/src/logic.rs index f190ac2bc24..89f2adf1d32 100644 --- a/runtime/near-vm-logic/src/logic.rs +++ b/runtime/near-vm-logic/src/logic.rs @@ -68,6 +68,9 @@ pub struct VMLogic<'a> { current_protocol_version: ProtocolVersion, } +unsafe impl<'a> Send for VMLogic<'a> {} +unsafe impl<'a> Sync for VMLogic<'a> {} + /// Promises API allows to create a DAG-structure that defines dependencies between smart contract /// calls. A single promise can be created with zero or several dependencies on other promises. /// * If a promise was created from a receipt (using `promise_create` or `promise_then`) it's a diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index 3a32ec85cd1..cb3a4384d8b 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -17,6 +17,7 @@ borsh = "0.7.1" wasmer-runtime = { version="0.17.1", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near" } wasmer-runtime-core = {version = "0.17.1", package = "wasmer-runtime-core-near" } wasmer = { version = "1.0.0", features = ["singlepass"], optional = true } +wasmer-types = { version = "1.0.0", optional = true} pwasm-utils = "0.12" parity-wasm = "0.41" wasmtime = { version = "0.20.0", default-features = false, optional = true } @@ -34,9 +35,9 @@ wabt = "0.9" bencher = "^0.1.5" [features] -default = [ "wasmer_default", "wasmer" ] +default = [ "wasmer_default", "wasmer", "wasmer-types" ] wasmtime_vm = [ "wasmtime", "anyhow"] -wasmer1_vm = [ "wasmer" ] +wasmer1_vm = [ "wasmer", "wasmer-types" ] lightbeam = ["wasmtime/lightbeam"] wasmer_default = [] wasmtime_default = ["wasmtime_vm"] diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 3a162b23d09..18ca9db065a 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -36,17 +36,18 @@ macro_rules! wrapped_imports { logic.$func( $( $arg_name, )* ) } )* - } + + #[cfg(feature = "wasmer1_vm")] pub mod wasmer1_ext { use near_vm_logic::VMLogic; - use wasmer::{WasmerEnv, LazyInit}; + use wasmer::{WasmerEnv, LazyInit, Memory}; #[derive(WasmerEnv, Clone, Default)] - struct MyEnv { + pub struct MyEnv<'a> { #[wasmer(export)] - memory: LazyInit, + pub memory: LazyInit, #[wasmer(export)] - logic: LazyInit, + pub logic: LazyInit>, } type VMResult = ::std::result::Result; @@ -116,9 +117,9 @@ macro_rules! wrapped_imports { } #[cfg(feature = "wasmer1_vm")] - pub(crate) fn build_wasmer1(memory: wasmer::Memory, logic: &mut VMLogic<'_>) -> + pub(crate) fn build_wasmer1(store: &wasmer::Store, memory: wasmer::Memory, logic: &mut VMLogic<'_>) -> wasmer::ImportObject { - let env = MyEnv {logic, memory: wasmer::LazyInit::new(memory.clone())}; + let env = wasmer1_ext::MyEnv {logic, memory: wasmer::LazyInit::new(memory.clone())}; wasmer::imports! { "env" => { "memory" => memory, diff --git a/runtime/near-vm-runner/src/runner.rs b/runtime/near-vm-runner/src/runner.rs index c6158cd7896..35531a866d9 100644 --- a/runtime/near-vm-runner/src/runner.rs +++ b/runtime/near-vm-runner/src/runner.rs @@ -129,8 +129,12 @@ pub fn run_vm_profiled<'a>( cache: Option<&'a dyn CompiledContractCache>, ) -> (Option, Option) { use crate::wasmer_runner::run_wasmer; + #[cfg(feature = "wasmtime_vm")] use crate::wasmtime_runner::wasmtime_runner::run_wasmtime; + + #[cfg(feature = "wasmer1_vm")] + use crate::wasmer1_runner::run_wasmer1; match vm_kind { VMKind::Wasmer => run_wasmer( code_hash, @@ -164,7 +168,7 @@ pub fn run_vm_profiled<'a>( panic!("Wasmtime is not supported, compile with '--features wasmtime_vm'") } #[cfg(feature = "wasmer1_vm")] - VMKind::Wasmer1 => run_wasm1( + VMKind::Wasmer1 => run_wasmer1( code_hash, code, method_name, diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 704f2e1d658..e29eecc1b04 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -1,5 +1,10 @@ +use crate::imports; +use near_primitives::types::CompiledContractCache; +use near_runtime_fees::RuntimeFeesConfig; use near_vm_errors::{FunctionCallError, MethodResolveError, VMError, VMLogicError}; -use wasmer::{Memory, MemoryType, Module, Pages, Singlepass, Store, JIT}; +use near_vm_logic::types::{ProfileData, PromiseResult, ProtocolVersion}; +use near_vm_logic::{External, MemoryLike, VMConfig, VMContext, VMLogic, VMOutcome}; +use wasmer::{Bytes, Instance, Memory, MemoryType, Module, Pages, Singlepass, Store, JIT}; pub struct Wasmer1Memory(Memory); @@ -54,8 +59,8 @@ impl MemoryLike for Wasmer1Memory { fn check_method(module: &Module, method_name: &str) -> Result<(), VMError> { let info = module.info(); - use wasmer_types::{ExportIndex, Function}; - if let Some(ExportIndex(Function(index))) = info.exports.get(method_name) { + use wasmer_types::ExportIndex::Function; + if let Some(Function(index)) = info.exports.get(method_name) { let func = info.signatures.get(index.clone()).unwrap(); let sig = info.signatures.get(func.clone()).unwrap(); if sig.params().is_empty() && sig.returns().is_empty() { @@ -101,7 +106,8 @@ pub fn run_wasmer1<'a>( Err(err) => return (None, Some(err)), }; - let mut memory = WasmerMemory::new( + let mut memory = Wasmer1Memory::new( + store, wasm_config.limit_config.initial_memory_pages, wasm_config.limit_config.max_memory_pages, ) @@ -128,7 +134,7 @@ pub fn run_wasmer1<'a>( ))), ); } - let import_object = imports::build_wasmer1(memory_copy, &mut logic); + let import_object = imports::build_wasmer1(store, memory_copy, &mut logic); let method_name = match std::str::from_utf8(method_name) { Ok(x) => x, From cac1740f251c48b4e8cc9accd48eb776a91eaf15 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 8 Jan 2021 16:32:34 -0800 Subject: [PATCH 08/50] fix more errors, stuck in wasmer 1.0 cannot import native func return Result --- runtime/near-vm-logic/src/logic.rs | 3 --- runtime/near-vm-runner/src/imports.rs | 25 ++++++++++++-------- runtime/near-vm-runner/src/wasmer1_runner.rs | 5 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/runtime/near-vm-logic/src/logic.rs b/runtime/near-vm-logic/src/logic.rs index 89f2adf1d32..f190ac2bc24 100644 --- a/runtime/near-vm-logic/src/logic.rs +++ b/runtime/near-vm-logic/src/logic.rs @@ -68,9 +68,6 @@ pub struct VMLogic<'a> { current_protocol_version: ProtocolVersion, } -unsafe impl<'a> Send for VMLogic<'a> {} -unsafe impl<'a> Sync for VMLogic<'a> {} - /// Promises API allows to create a DAG-structure that defines dependencies between smart contract /// calls. A single promise can be created with zero or several dependencies on other promises. /// * If a promise was created from a receipt (using `promise_create` or `promise_then`) it's a diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 18ca9db065a..5fd570b37ed 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -1,4 +1,5 @@ use near_vm_logic::VMLogic; +use std::sync::Arc; use std::ffi::c_void; @@ -6,6 +7,11 @@ struct ImportReference(*mut c_void); unsafe impl Send for ImportReference {} unsafe impl Sync for ImportReference {} +#[derive(Clone)] +struct VMLogicReference<'a>(Arc>); +unsafe impl Send for VMLogicReference<'_> {} +unsafe impl Sync for VMLogicReference<'_> {} + // Wasm has only i32/i64 types, so Wasmtime 0.17 only accepts // external functions taking i32/i64 type. // Remove, once using version with https://github.com/bytecodealliance/wasmtime/issues/1829 @@ -42,19 +48,18 @@ macro_rules! wrapped_imports { pub mod wasmer1_ext { use near_vm_logic::VMLogic; use wasmer::{WasmerEnv, LazyInit, Memory}; - #[derive(WasmerEnv, Clone, Default)] + use crate::imports::VMLogicReference; + #[derive(WasmerEnv, Clone)] pub struct MyEnv<'a> { - #[wasmer(export)] - pub memory: LazyInit, - #[wasmer(export)] - pub logic: LazyInit>, + pub memory: Memory, + pub logic: VMLogicReference<'a>, } type VMResult = ::std::result::Result; $( #[allow(unused_parens)] - pub fn $func( env: &mut MyEnv, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { - let logic: &mut VMLogic<'_> = env.logic_ref()?; + pub fn $func<'a>( env: &MyEnv<'a>, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { + let logic: &mut VMLogic<'_> = &mut env.logic.borrow_mut().unwrap().0; logic.$func( $( $arg_name, )* ) } )* @@ -117,14 +122,14 @@ macro_rules! wrapped_imports { } #[cfg(feature = "wasmer1_vm")] - pub(crate) fn build_wasmer1(store: &wasmer::Store, memory: wasmer::Memory, logic: &mut VMLogic<'_>) -> + pub(crate) fn build_wasmer1(store: &wasmer::Store, memory: wasmer::Memory, logic: VMLogic<'_>) -> wasmer::ImportObject { - let env = wasmer1_ext::MyEnv {logic, memory: wasmer::LazyInit::new(memory.clone())}; + let env = wasmer1_ext::MyEnv {logic: VMLogicReference(Arc::new(logic)), memory: memory.clone()}; wasmer::imports! { "env" => { "memory" => memory, $( - stringify!($func) => wasmer::Function::new_with_native_env(&store, env.clone(), wasmer_ext::$func), + stringify!($func) => wasmer::Function::new_native_with_env(&store, env.clone(), wasmer1_ext::$func), )* }, } diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index e29eecc1b04..282c0b24aa0 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -17,8 +17,7 @@ impl Wasmer1Memory { Ok(Wasmer1Memory( Memory::new( &store, - MemoryType::new(Pages(initial_memory_pages), Some(Pages(max_memory_pages)), false) - .unwrap(), + MemoryType::new(Pages(initial_memory_pages), Some(Pages(max_memory_pages)), false), ) .expect("TODO creating memory cannot fail"), )) @@ -61,7 +60,7 @@ fn check_method(module: &Module, method_name: &str) -> Result<(), VMError> { let info = module.info(); use wasmer_types::ExportIndex::Function; if let Some(Function(index)) = info.exports.get(method_name) { - let func = info.signatures.get(index.clone()).unwrap(); + let func = info.functions.get(index.clone()).unwrap(); let sig = info.signatures.get(func.clone()).unwrap(); if sig.params().is_empty() && sig.returns().is_empty() { Ok(()) From 3e52892549c8c444940072b3bc0b912957472a6a Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 8 Jan 2021 17:53:18 -0800 Subject: [PATCH 09/50] fix HostFunction trait not implemented issue --- runtime/near-vm-errors/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/near-vm-errors/src/lib.rs b/runtime/near-vm-errors/src/lib.rs index bed8ead86f6..0b3a77b965c 100644 --- a/runtime/near-vm-errors/src/lib.rs +++ b/runtime/near-vm-errors/src/lib.rs @@ -272,6 +272,8 @@ pub enum VMLogicError { EvmError(EvmError), } +impl std::error::Error for VMLogicError {} + /// An error that is caused by an operation on an inconsistent state. /// E.g. a deserialization error or an integer overflow. #[derive(Debug, Clone, PartialEq, Eq, BorshDeserialize, BorshSerialize, Deserialize, Serialize)] From e064e6a47a32e390ad2f66841ba36cad88ad77e2 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 8 Jan 2021 18:17:48 -0800 Subject: [PATCH 10/50] fix HostFunction trait not implemented issue --- runtime/near-vm-runner/src/imports.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 5fd570b37ed..a1ab7741bd3 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -59,7 +59,7 @@ macro_rules! wrapped_imports { $( #[allow(unused_parens)] pub fn $func<'a>( env: &MyEnv<'a>, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { - let logic: &mut VMLogic<'_> = &mut env.logic.borrow_mut().unwrap().0; + let logic: &mut VMLogic<'_> = &mut env.logic.0.borrow_mut().unwrap(); logic.$func( $( $arg_name, )* ) } )* From cd5d29100ae26b7f3d47640eccb1e1428c841290 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 8 Jan 2021 18:35:35 -0800 Subject: [PATCH 11/50] fix compilation errors --- runtime/near-vm-runner/src/imports.rs | 2 +- runtime/near-vm-runner/src/wasmer1_runner.rs | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index a1ab7741bd3..0fe76eb5bb1 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -59,7 +59,7 @@ macro_rules! wrapped_imports { $( #[allow(unused_parens)] pub fn $func<'a>( env: &MyEnv<'a>, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { - let logic: &mut VMLogic<'_> = &mut env.logic.0.borrow_mut().unwrap(); + let logic: &mut VMLogic<'a> = &mut env.logic.0.borrow_mut().unwrap(); logic.$func( $( $arg_name, )* ) } )* diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 282c0b24aa0..39b72f121f6 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -62,7 +62,7 @@ fn check_method(module: &Module, method_name: &str) -> Result<(), VMError> { if let Some(Function(index)) = info.exports.get(method_name) { let func = info.functions.get(index.clone()).unwrap(); let sig = info.signatures.get(func.clone()).unwrap(); - if sig.params().is_empty() && sig.returns().is_empty() { + if sig.params().is_empty() && sig.results().is_empty() { Ok(()) } else { Err(VMError::FunctionCallError(FunctionCallError::MethodResolveError( @@ -102,11 +102,11 @@ pub fn run_wasmer1<'a>( let store = Store::new(&engine); let module = match Module::new(&store, code) { Ok(x) => x, - Err(err) => return (None, Some(err)), + Err(err) => return (None, Some(err.into_vm_error())), }; let mut memory = Wasmer1Memory::new( - store, + &store, wasm_config.limit_config.initial_memory_pages, wasm_config.limit_config.max_memory_pages, ) @@ -133,7 +133,7 @@ pub fn run_wasmer1<'a>( ))), ); } - let import_object = imports::build_wasmer1(store, memory_copy, &mut logic); + let import_object = imports::build_wasmer1(&store, memory_copy, logic); let method_name = match std::str::from_utf8(method_name) { Ok(x) => x, @@ -152,7 +152,7 @@ pub fn run_wasmer1<'a>( } match Instance::new(&module, &import_object) { - Ok(instance) => match instance.call(&method_name, &[]) { + Ok(instance) => match call(instance, &method_name) { Ok(_) => (Some(logic.outcome()), None), Err(err) => (Some(logic.outcome()), Some(err.into_vm_error())), }, @@ -160,6 +160,10 @@ pub fn run_wasmer1<'a>( } } +fn call(instance: wasmer::Instance, method_name: &str) -> Result<(), VMError> { + instance.exports.get_function(&method_name)?.native::<(), ()>()?.call(&[])? +} + pub fn compile_module(code: &[u8]) -> bool { let engine = JIT::new(Singlepass::default()).engine(); let store = Store::new(&engine); From 746ea2b6c1c872e9f906e47f42d41ea1aaf72cf2 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 11 Jan 2021 11:25:35 -0800 Subject: [PATCH 12/50] fix vmlogic inject --- runtime/near-vm-runner/src/imports.rs | 21 ++++++++++---------- runtime/near-vm-runner/src/wasmer1_runner.rs | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 0fe76eb5bb1..5be3fd6c50b 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -1,5 +1,4 @@ use near_vm_logic::VMLogic; -use std::sync::Arc; use std::ffi::c_void; @@ -8,9 +7,9 @@ unsafe impl Send for ImportReference {} unsafe impl Sync for ImportReference {} #[derive(Clone)] -struct VMLogicReference<'a>(Arc>); -unsafe impl Send for VMLogicReference<'_> {} -unsafe impl Sync for VMLogicReference<'_> {} +struct VMLogicReference(*mut c_void); +unsafe impl Send for VMLogicReference {} +unsafe impl Sync for VMLogicReference {} // Wasm has only i32/i64 types, so Wasmtime 0.17 only accepts // external functions taking i32/i64 type. @@ -47,19 +46,19 @@ macro_rules! wrapped_imports { #[cfg(feature = "wasmer1_vm")] pub mod wasmer1_ext { use near_vm_logic::VMLogic; - use wasmer::{WasmerEnv, LazyInit, Memory}; + use wasmer::{WasmerEnv, Memory}; use crate::imports::VMLogicReference; #[derive(WasmerEnv, Clone)] - pub struct MyEnv<'a> { + pub struct MyEnv { pub memory: Memory, - pub logic: VMLogicReference<'a>, + pub logic: VMLogicReference, } type VMResult = ::std::result::Result; $( #[allow(unused_parens)] - pub fn $func<'a>( env: &MyEnv<'a>, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { - let logic: &mut VMLogic<'a> = &mut env.logic.0.borrow_mut().unwrap(); + pub fn $func(env: &MyEnv, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { + let logic: &mut VMLogic = unsafe { &mut *(env.logic.0 as *mut VMLogic<'_>) }; logic.$func( $( $arg_name, )* ) } )* @@ -122,9 +121,9 @@ macro_rules! wrapped_imports { } #[cfg(feature = "wasmer1_vm")] - pub(crate) fn build_wasmer1(store: &wasmer::Store, memory: wasmer::Memory, logic: VMLogic<'_>) -> + pub(crate) fn build_wasmer1(store: &wasmer::Store, memory: wasmer::Memory, logic: &mut VMLogic<'_>) -> wasmer::ImportObject { - let env = wasmer1_ext::MyEnv {logic: VMLogicReference(Arc::new(logic)), memory: memory.clone()}; + let env = wasmer1_ext::MyEnv {logic: VMLogicReference(logic as * mut _ as * mut c_void), memory: memory.clone()}; wasmer::imports! { "env" => { "memory" => memory, diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 39b72f121f6..d45938aab79 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -1,7 +1,7 @@ use crate::imports; use near_primitives::types::CompiledContractCache; use near_runtime_fees::RuntimeFeesConfig; -use near_vm_errors::{FunctionCallError, MethodResolveError, VMError, VMLogicError}; +use near_vm_errors::{FunctionCallError, MethodResolveError, VMError}; use near_vm_logic::types::{ProfileData, PromiseResult, ProtocolVersion}; use near_vm_logic::{External, MemoryLike, VMConfig, VMContext, VMLogic, VMOutcome}; use wasmer::{Bytes, Instance, Memory, MemoryType, Module, Pages, Singlepass, Store, JIT}; @@ -133,7 +133,7 @@ pub fn run_wasmer1<'a>( ))), ); } - let import_object = imports::build_wasmer1(&store, memory_copy, logic); + let import_object = imports::build_wasmer1(&store, memory_copy, &mut logic); let method_name = match std::str::from_utf8(method_name) { Ok(x) => x, From a63ec4abda2af9eadcdd3355c7055893ee50dd6b Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 11 Jan 2021 17:46:45 -0800 Subject: [PATCH 13/50] adding all into_vm_errors, fixed some tests --- runtime/near-vm-errors/src/lib.rs | 6 ++ runtime/near-vm-runner/src/imports.rs | 2 +- runtime/near-vm-runner/src/wasmer1_runner.rs | 61 ++++++++++++++++--- .../near-vm-runner/tests/test_error_cases.rs | 3 +- 4 files changed, 62 insertions(+), 10 deletions(-) diff --git a/runtime/near-vm-errors/src/lib.rs b/runtime/near-vm-errors/src/lib.rs index 0b3a77b965c..14ea3444131 100644 --- a/runtime/near-vm-errors/src/lib.rs +++ b/runtime/near-vm-errors/src/lib.rs @@ -36,6 +36,11 @@ pub enum FunctionCallError { WasmUnknownError, HostError(HostError), EvmError(EvmError), + /// An error message when wasmer 1.0 returns a wasmer::RuntimeError + /// In wasmer 1.0 the internal of runtime error is not pub, so we cannot tell it's a UserError + /// or Trap, and which kind of Trap. The pub thing we have is a error message returns by wasmer, + /// Indicate the reason of RuntimeError, and if it's a Trap what kind of trap it is. + WasmerRuntimeError(String), } #[derive( Debug, Clone, PartialEq, Eq, BorshDeserialize, BorshSerialize, Deserialize, Serialize, RpcError, @@ -338,6 +343,7 @@ impl fmt::Display for FunctionCallError { write!(f, "Unknown error during Wasm contract execution") } FunctionCallError::EvmError(e) => write!(f, "EVM: {:?}", e), + FunctionCallError::WasmerRuntimeError(e) => write!(f, "Wasmer Runtime: {}", e), } } } diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 5be3fd6c50b..95d1083de66 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -7,7 +7,7 @@ unsafe impl Send for ImportReference {} unsafe impl Sync for ImportReference {} #[derive(Clone)] -struct VMLogicReference(*mut c_void); +pub struct VMLogicReference(pub *mut c_void); unsafe impl Send for VMLogicReference {} unsafe impl Sync for VMLogicReference {} diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index d45938aab79..39a53bf6eb7 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -1,7 +1,10 @@ +use crate::errors::IntoVMError; use crate::imports; use near_primitives::types::CompiledContractCache; use near_runtime_fees::RuntimeFeesConfig; -use near_vm_errors::{FunctionCallError, MethodResolveError, VMError}; +use near_vm_errors::{ + CompilationError, FunctionCallError, MethodResolveError, PrepareError, VMError, +}; use near_vm_logic::types::{ProfileData, PromiseResult, ProtocolVersion}; use near_vm_logic::{External, MemoryLike, VMConfig, VMContext, VMLogic, VMOutcome}; use wasmer::{Bytes, Instance, Memory, MemoryType, Module, Pages, Singlepass, Store, JIT}; @@ -56,6 +59,46 @@ impl MemoryLike for Wasmer1Memory { } } +impl IntoVMError for wasmer::CompileError { + fn into_vm_error(self) -> VMError { + VMError::FunctionCallError(FunctionCallError::CompilationError( + CompilationError::WasmerCompileError { msg: self.to_string() }, + )) + } +} + +impl IntoVMError for wasmer::InstantiationError { + fn into_vm_error(self) -> VMError { + match self { + wasmer::InstantiationError::Link(e) => { + VMError::FunctionCallError(FunctionCallError::LinkError { msg: e.to_string() }) + } + _ => VMError::FunctionCallError(FunctionCallError::CompilationError( + CompilationError::PrepareError(PrepareError::Instantiate), + )), + } + } +} + +impl IntoVMError for wasmer::RuntimeError { + fn into_vm_error(self) -> VMError { + VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError(self.message())) + } +} + +impl IntoVMError for wasmer::ExportError { + fn into_vm_error(self) -> VMError { + match self { + wasmer::ExportError::IncompatibleType => VMError::FunctionCallError( + FunctionCallError::MethodResolveError(MethodResolveError::MethodInvalidSignature), + ), + wasmer::ExportError::Missing(_) => VMError::FunctionCallError( + FunctionCallError::MethodResolveError(MethodResolveError::MethodNotFound), + ), + } + } +} + fn check_method(module: &Module, method_name: &str) -> Result<(), VMError> { let info = module.info(); use wasmer_types::ExportIndex::Function; @@ -152,18 +195,20 @@ pub fn run_wasmer1<'a>( } match Instance::new(&module, &import_object) { - Ok(instance) => match call(instance, &method_name) { - Ok(_) => (Some(logic.outcome()), None), - Err(err) => (Some(logic.outcome()), Some(err.into_vm_error())), + Ok(instance) => match instance.exports.get_function(&method_name) { + Ok(f) => match f.native::<(), ()>() { + Ok(f) => match f.call() { + Ok(_) => (Some(logic.outcome()), None), + Err(e) => (Some(logic.outcome()), Some(e.into_vm_error())), + }, + Err(e) => (Some(logic.outcome()), Some(e.into_vm_error())), + }, + Err(e) => (Some(logic.outcome()), Some(e.into_vm_error())), }, Err(err) => (Some(logic.outcome()), Some(err.into_vm_error())), } } -fn call(instance: wasmer::Instance, method_name: &str) -> Result<(), VMError> { - instance.exports.get_function(&method_name)?.native::<(), ()>()?.call(&[])? -} - pub fn compile_module(code: &[u8]) -> bool { let engine = JIT::new(Singlepass::default()).engine(); let store = Store::new(&engine); diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index e22d50e3134..8ba0bddf3af 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -391,7 +391,7 @@ fn test_bad_import_3() { let msg = match vm_kind { VMKind::Wasmer => "link error: Incorrect import type, namespace: env, name: input, expected type: global, found type: function", VMKind::Wasmtime => "\"incompatible import type for `env::input` specified\\ndesired signature was: Global(GlobalType { content: I32, mutability: Const })\\nsignatures available:\\n\\n * Func(FuncType { params: [I64], results: [] })\\n\"", - VMKind::Wasmer1 => "TODO: FILL ME" + VMKind::Wasmer1 => "Error while importing \"env\".\"wtf\": unknown import. Expected Function(FunctionType { params: [], results: [] })" }.to_string(); assert_eq!( make_simple_contract_call_vm(&bad_import_global("env"), b"hello", vm_kind), @@ -409,6 +409,7 @@ fn test_bad_import_4() { let msg = match vm_kind { VMKind::Wasmer => "link error: Import not found, namespace: env, name: wtf", VMKind::Wasmtime => "\"unknown import: `env::wtf` has not been defined\"", + VMKind::Wasmer1 => "Error while importing \"env\".\"wtf\": unknown import. Expected Function(FunctionType { params: [], results: [] })", } .to_string(); assert_eq!( From a83d0abe0d8ae986bdeccf9ec1221b5842b5a307 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 11 Jan 2021 18:05:07 -0800 Subject: [PATCH 14/50] avx check and no nan check needed now --- runtime/near-vm-runner/src/wasmer1_runner.rs | 10 ++++++++++ runtime/near-vm-runner/tests/test_error_cases.rs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 39a53bf6eb7..146203f5730 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -132,6 +132,16 @@ pub fn run_wasmer1<'a>( current_protocol_version: ProtocolVersion, cache: Option<&'a dyn CompiledContractCache>, ) -> (Option, Option) { + // NaN behavior is deterministic as of now: https://github.com/wasmerio/wasmer/issues/1269 + // So doesn't require x86. However, when it is on x86, AVX is required: + // https://github.com/wasmerio/wasmer/issues/1567 + #[cfg(not(feature = "no_cpu_compatibility_checks"))] + if (cfg!(target_arch = "x86") || !cfg!(target_arch = "x86_64")) + && !is_x86_feature_detected!("avx") + { + panic!("AVX support is required in order to run Wasmer VM Singlepass backend."); + } + if method_name.is_empty() { return ( None, diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index 8ba0bddf3af..db2c3b2e739 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -391,7 +391,7 @@ fn test_bad_import_3() { let msg = match vm_kind { VMKind::Wasmer => "link error: Incorrect import type, namespace: env, name: input, expected type: global, found type: function", VMKind::Wasmtime => "\"incompatible import type for `env::input` specified\\ndesired signature was: Global(GlobalType { content: I32, mutability: Const })\\nsignatures available:\\n\\n * Func(FuncType { params: [I64], results: [] })\\n\"", - VMKind::Wasmer1 => "Error while importing \"env\".\"wtf\": unknown import. Expected Function(FunctionType { params: [], results: [] })" + VMKind::Wasmer1 => "Error while importing \"env\".\"input\": incompatible import type. Expected Global(GlobalType { ty: I32, mutability: Const }) but received Function(FunctionType { params: [I64], results: [] })" }.to_string(); assert_eq!( make_simple_contract_call_vm(&bad_import_global("env"), b"hello", vm_kind), From e563ad3f853b769acb4cee08bc8907fbf97377e3 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 11 Jan 2021 18:28:47 -0800 Subject: [PATCH 15/50] fix two more tests --- .../near-vm-runner/tests/test_error_cases.rs | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index db2c3b2e739..162ef8c7434 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -358,22 +358,33 @@ fn bad_import_func(env: &str) -> Vec { // Invalid import from "env" -> LinkError fn test_bad_import_1() { with_vm_variants(|vm_kind: VMKind| { - assert_eq!( - make_simple_contract_call_vm(&bad_import_global("wtf"), b"hello", vm_kind), - ( - None, - Some(VMError::FunctionCallError(FunctionCallError::CompilationError( - CompilationError::PrepareError(PrepareError::Instantiate) - ))) - ) - ); + match vm_kind { + VMKind::Wasmer => assert_eq!( + make_simple_contract_call_vm(&bad_import_global("wtf"), b"hello", vm_kind), + ( + None, + Some(VMError::FunctionCallError(FunctionCallError::CompilationError( + CompilationError::PrepareError(PrepareError::Instantiate) + ))) + ) + ), + VMKind::Wasmer1 => assert_eq!( + make_simple_contract_call_vm(&bad_import_global("wtf"), b"hello", vm_kind), + ( + Some(vm_outcome_with_gas(46500213)), + Some(VMError::FunctionCallError(FunctionCallError::LinkError { msg: "Error while importing \"wtf\".\"input\": unknown import. Expected Global(GlobalType { ty: I32, mutability: Const })".to_string() })) + ) + ), + VMKind::Wasmtime => {} + } }); } #[test] fn test_bad_import_2() { with_vm_variants(|vm_kind: VMKind| { - assert_eq!( + match vm_kind { + VMKind::Wasmer => assert_eq!( make_simple_contract_call_vm(&bad_import_func("wtf"), b"hello", vm_kind), ( None, @@ -381,7 +392,16 @@ fn test_bad_import_2() { CompilationError::PrepareError(PrepareError::Instantiate) ))) ) - ); + ), + VMKind::Wasmer1 => { + assert_eq!(make_simple_contract_call_vm(&bad_import_func("wtf"), b"hello", vm_kind), + ( + Some(vm_outcome_with_gas(45849963)), + Some(VMError::FunctionCallError(FunctionCallError::LinkError { msg: "Error while importing \"wtf\".\"wtf\": unknown import. Expected Function(FunctionType { params: [], results: [] })".to_string() }))) + ) + } + VMKind::Wasmtime => {} + } }); } From 2d1c129f9e5b858fed57aa62d5f456f2c99f393a Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 14 Jan 2021 14:33:16 -0800 Subject: [PATCH 16/50] fix runner stuck infinite --- runtime/near-vm-runner/src/wasmer1_runner.rs | 33 ++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 146203f5730..ef1ec8a650a 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -1,12 +1,13 @@ use crate::errors::IntoVMError; use crate::imports; +use crate::prepare; use near_primitives::types::CompiledContractCache; use near_runtime_fees::RuntimeFeesConfig; use near_vm_errors::{ CompilationError, FunctionCallError, MethodResolveError, PrepareError, VMError, }; use near_vm_logic::types::{ProfileData, PromiseResult, ProtocolVersion}; -use near_vm_logic::{External, MemoryLike, VMConfig, VMContext, VMLogic, VMOutcome}; +use near_vm_logic::{External, MemoryLike, VMConfig, VMContext, VMLogic, VMLogicError, VMOutcome}; use wasmer::{Bytes, Instance, Memory, MemoryType, Module, Pages, Singlepass, Store, JIT}; pub struct Wasmer1Memory(Memory); @@ -82,7 +83,29 @@ impl IntoVMError for wasmer::InstantiationError { impl IntoVMError for wasmer::RuntimeError { fn into_vm_error(self) -> VMError { - VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError(self.message())) + match self.clone().downcast::() { + Ok(e) => { + println!("aaaaaa"); + + match e { + VMLogicError::HostError(h) => { + VMError::FunctionCallError(FunctionCallError::HostError(h.clone())) + } + VMLogicError::ExternalError(s) => VMError::ExternalError(s.clone()), + VMLogicError::InconsistentStateError(e) => { + VMError::InconsistentStateError(e.clone()) + } + VMLogicError::EvmError(_) => unreachable!("Wasm can't return EVM error"), + } + } + // Either a Trap or Generic error of wasmer::RuntimeError + // We only know it's message + _ => { + println!("bbbbbb"); + + VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError(self.message())) + } + } } } @@ -153,7 +176,11 @@ pub fn run_wasmer1<'a>( let engine = JIT::new(Singlepass::default()).engine(); let store = Store::new(&engine); - let module = match Module::new(&store, code) { + let prepared_code = match prepare::prepare_contract(code, wasm_config) { + Ok(code) => code, + Err(e) => return (None, Some(e.into())), + }; + let module = match Module::new(&store, prepared_code) { Ok(x) => x, Err(err) => return (None, Some(err.into_vm_error())), }; From 6c7ad15e2a0c14a69e81a1a6e37708ea3aa7ebb3 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 14 Jan 2021 15:25:47 -0800 Subject: [PATCH 17/50] fix runtime error downcast error --- runtime/near-vm-runner/src/wasmer1_runner.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index ef1ec8a650a..62ea6eb16b4 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -83,7 +83,8 @@ impl IntoVMError for wasmer::InstantiationError { impl IntoVMError for wasmer::RuntimeError { fn into_vm_error(self) -> VMError { - match self.clone().downcast::() { + let error_msg = self.message(); + match self.downcast::() { Ok(e) => { println!("aaaaaa"); @@ -103,7 +104,7 @@ impl IntoVMError for wasmer::RuntimeError { _ => { println!("bbbbbb"); - VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError(self.message())) + VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError(error_msg)) } } } From 6e064f60cafc696d4b46265bbce574d1020fe2db Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 14 Jan 2021 15:38:46 -0800 Subject: [PATCH 18/50] refactor vmlogicerror into vmerror --- runtime/near-vm-runner/src/errors.rs | 16 +++++++++++-- runtime/near-vm-runner/src/wasmer1_runner.rs | 25 ++++---------------- runtime/near-vm-runner/src/wasmer_runner.rs | 11 +-------- 3 files changed, 19 insertions(+), 33 deletions(-) diff --git a/runtime/near-vm-runner/src/errors.rs b/runtime/near-vm-runner/src/errors.rs index e1541154050..fc138c2d6f1 100644 --- a/runtime/near-vm-runner/src/errors.rs +++ b/runtime/near-vm-runner/src/errors.rs @@ -1,5 +1,17 @@ -use near_vm_errors::VMError; - +use near_vm_errors::{FunctionCallError, VMError, VMLogicError}; pub trait IntoVMError { fn into_vm_error(self) -> VMError; } + +impl IntoVMError for &VMLogicError { + fn into_vm_error(self) -> VMError { + match self { + VMLogicError::HostError(h) => { + VMError::FunctionCallError(FunctionCallError::HostError(h.clone())) + } + VMLogicError::ExternalError(s) => VMError::ExternalError(s.clone()), + VMLogicError::InconsistentStateError(e) => VMError::InconsistentStateError(e.clone()), + VMLogicError::EvmError(_) => unreachable!("Wasm can't return EVM error"), + } + } +} diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 62ea6eb16b4..9a22772c554 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -85,27 +85,10 @@ impl IntoVMError for wasmer::RuntimeError { fn into_vm_error(self) -> VMError { let error_msg = self.message(); match self.downcast::() { - Ok(e) => { - println!("aaaaaa"); - - match e { - VMLogicError::HostError(h) => { - VMError::FunctionCallError(FunctionCallError::HostError(h.clone())) - } - VMLogicError::ExternalError(s) => VMError::ExternalError(s.clone()), - VMLogicError::InconsistentStateError(e) => { - VMError::InconsistentStateError(e.clone()) - } - VMLogicError::EvmError(_) => unreachable!("Wasm can't return EVM error"), - } - } + Ok(e) => e.into_vm_error(), // Either a Trap or Generic error of wasmer::RuntimeError // We only know it's message - _ => { - println!("bbbbbb"); - - VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError(error_msg)) - } + _ => VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError(error_msg)), } } } @@ -144,7 +127,7 @@ fn check_method(module: &Module, method_name: &str) -> Result<(), VMError> { } pub fn run_wasmer1<'a>( - code_hash: Vec, + _code_hash: Vec, code: &[u8], method_name: &[u8], ext: &mut dyn External, @@ -154,7 +137,7 @@ pub fn run_wasmer1<'a>( promise_results: &'a [PromiseResult], profile: Option, current_protocol_version: ProtocolVersion, - cache: Option<&'a dyn CompiledContractCache>, + _cache: Option<&'a dyn CompiledContractCache>, ) -> (Option, Option) { // NaN behavior is deterministic as of now: https://github.com/wasmerio/wasmer/issues/1269 // So doesn't require x86. However, when it is on x86, AVX is required: diff --git a/runtime/near-vm-runner/src/wasmer_runner.rs b/runtime/near-vm-runner/src/wasmer_runner.rs index 9047ab2b480..c3e48c0a68c 100644 --- a/runtime/near-vm-runner/src/wasmer_runner.rs +++ b/runtime/near-vm-runner/src/wasmer_runner.rs @@ -153,16 +153,7 @@ impl IntoVMError for wasmer_runtime::error::RuntimeError { } RuntimeError::User(data) => { if let Some(err) = data.downcast_ref::() { - match err { - VMLogicError::HostError(h) => { - VMError::FunctionCallError(FunctionCallError::HostError(h.clone())) - } - VMLogicError::ExternalError(s) => VMError::ExternalError(s.clone()), - VMLogicError::InconsistentStateError(e) => { - VMError::InconsistentStateError(e.clone()) - } - VMLogicError::EvmError(_) => unreachable!("Wasm can't return EVM error"), - } + err.into_vm_error() } else { panic!( "Bad error case! Output is non-deterministic {:?} {:?}", From 11be303e84e9de3e02e1c8b17eb6b17050adbe79 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 14 Jan 2021 15:49:05 -0800 Subject: [PATCH 19/50] fix runtime error on call initializer --- runtime/near-vm-runner/src/wasmer1_runner.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 9a22772c554..f0513972371 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -74,9 +74,12 @@ impl IntoVMError for wasmer::InstantiationError { wasmer::InstantiationError::Link(e) => { VMError::FunctionCallError(FunctionCallError::LinkError { msg: e.to_string() }) } - _ => VMError::FunctionCallError(FunctionCallError::CompilationError( - CompilationError::PrepareError(PrepareError::Instantiate), - )), + wasmer::InstantiationError::Start(e) => e.into_vm_error(), + wasmer::InstantiationError::HostEnvInitialization(_) => { + VMError::FunctionCallError(FunctionCallError::CompilationError( + CompilationError::PrepareError(PrepareError::Instantiate), + )) + } } } } From beccd74b19943a9ee21d9d0149c9575762239c4a Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 14 Jan 2021 15:56:29 -0800 Subject: [PATCH 20/50] fix all vm error test --- .../near-vm-runner/tests/test_error_cases.rs | 42 +++++-------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index 162ef8c7434..9baf9ea1955 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -358,33 +358,22 @@ fn bad_import_func(env: &str) -> Vec { // Invalid import from "env" -> LinkError fn test_bad_import_1() { with_vm_variants(|vm_kind: VMKind| { - match vm_kind { - VMKind::Wasmer => assert_eq!( - make_simple_contract_call_vm(&bad_import_global("wtf"), b"hello", vm_kind), - ( - None, - Some(VMError::FunctionCallError(FunctionCallError::CompilationError( - CompilationError::PrepareError(PrepareError::Instantiate) - ))) - ) - ), - VMKind::Wasmer1 => assert_eq!( - make_simple_contract_call_vm(&bad_import_global("wtf"), b"hello", vm_kind), - ( - Some(vm_outcome_with_gas(46500213)), - Some(VMError::FunctionCallError(FunctionCallError::LinkError { msg: "Error while importing \"wtf\".\"input\": unknown import. Expected Global(GlobalType { ty: I32, mutability: Const })".to_string() })) - ) - ), - VMKind::Wasmtime => {} - } + assert_eq!( + make_simple_contract_call_vm(&bad_import_global("wtf"), b"hello", vm_kind), + ( + None, + Some(VMError::FunctionCallError(FunctionCallError::CompilationError( + CompilationError::PrepareError(PrepareError::Instantiate) + ))) + ) + ) }); } #[test] fn test_bad_import_2() { with_vm_variants(|vm_kind: VMKind| { - match vm_kind { - VMKind::Wasmer => assert_eq!( + assert_eq!( make_simple_contract_call_vm(&bad_import_func("wtf"), b"hello", vm_kind), ( None, @@ -392,16 +381,7 @@ fn test_bad_import_2() { CompilationError::PrepareError(PrepareError::Instantiate) ))) ) - ), - VMKind::Wasmer1 => { - assert_eq!(make_simple_contract_call_vm(&bad_import_func("wtf"), b"hello", vm_kind), - ( - Some(vm_outcome_with_gas(45849963)), - Some(VMError::FunctionCallError(FunctionCallError::LinkError { msg: "Error while importing \"wtf\".\"wtf\": unknown import. Expected Function(FunctionType { params: [], results: [] })".to_string() }))) - ) - } - VMKind::Wasmtime => {} - } + ); }); } From fc4aca9471da97e7c45300d4976c42b1fd40ca1d Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 14 Jan 2021 16:11:18 -0800 Subject: [PATCH 21/50] rename VMKind::Wasmer to Wasmer0 --- runtime/near-vm-logic/src/config.rs | 6 +++--- runtime/near-vm-runner-standalone/src/main.rs | 2 +- runtime/near-vm-runner/src/cache.rs | 2 +- runtime/near-vm-runner/src/runner.rs | 8 ++++---- runtime/near-vm-runner/tests/test_error_cases.rs | 14 +++++++------- runtime/near-vm-runner/tests/test_rs_contract.rs | 2 +- runtime/runtime-params-estimator/src/main.rs | 4 ++-- .../runtime-params-estimator/src/vm_estimator.rs | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/runtime/near-vm-logic/src/config.rs b/runtime/near-vm-logic/src/config.rs index 8863f9960fa..360dbd367ec 100644 --- a/runtime/near-vm-logic/src/config.rs +++ b/runtime/near-vm-logic/src/config.rs @@ -8,7 +8,7 @@ use std::hash::{Hash, Hasher}; #[derive(Clone, Copy, Debug, Hash, Serialize, Deserialize, BorshSerialize, BorshDeserialize)] pub enum VMKind { /// Wasmer 0.17.x VM. - Wasmer, + Wasmer0, /// Wasmtime VM. Wasmtime, /// Wasmer 1.x VM. @@ -18,7 +18,7 @@ pub enum VMKind { impl Default for VMKind { #[cfg(feature = "wasmer_default")] fn default() -> Self { - VMKind::Wasmer + VMKind::Wasmer0 } #[cfg(feature = "wasmer1_default")] @@ -37,7 +37,7 @@ impl Default for VMKind { not(feature = "wasmtime_default") ))] fn default() -> Self { - VMKind::Wasmer + VMKind::Wasmer0 } } diff --git a/runtime/near-vm-runner-standalone/src/main.rs b/runtime/near-vm-runner-standalone/src/main.rs index 6f30af7cb56..dd733c0c299 100644 --- a/runtime/near-vm-runner-standalone/src/main.rs +++ b/runtime/near-vm-runner-standalone/src/main.rs @@ -186,7 +186,7 @@ fn main() { let vm_kind: VMKind = match matches.value_of("vm-kind") { Some(value) => match value { "wasmtime" => VMKind::Wasmtime, - "wasmer" => VMKind::Wasmer, + "wasmer" => VMKind::Wasmer0, "wasmer1" => VMKind::Wasmer1, _ => VMKind::default(), }, diff --git a/runtime/near-vm-runner/src/cache.rs b/runtime/near-vm-runner/src/cache.rs index 853655d0bba..ba8959445ca 100644 --- a/runtime/near-vm-runner/src/cache.rs +++ b/runtime/near-vm-runner/src/cache.rs @@ -102,7 +102,7 @@ pub(crate) fn compile_module_cached_wasmer( if cache.is_none() { return compile_module(wasm_code, config); } - let key = get_key(wasm_code_hash, wasm_code, VMKind::Wasmer, config); + let key = get_key(wasm_code_hash, wasm_code, VMKind::Wasmer0, config); let cache = cache.unwrap(); match cache.get(&(key.0).0) { Ok(serialized) => match serialized { diff --git a/runtime/near-vm-runner/src/runner.rs b/runtime/near-vm-runner/src/runner.rs index 35531a866d9..6b13506e02c 100644 --- a/runtime/near-vm-runner/src/runner.rs +++ b/runtime/near-vm-runner/src/runner.rs @@ -64,7 +64,7 @@ pub fn run_vm<'a>( use crate::wasmer1_runner::run_wasmer1; match vm_kind { - VMKind::Wasmer => run_wasmer( + VMKind::Wasmer0 => run_wasmer( code_hash, code, method_name, @@ -136,7 +136,7 @@ pub fn run_vm_profiled<'a>( #[cfg(feature = "wasmer1_vm")] use crate::wasmer1_runner::run_wasmer1; match vm_kind { - VMKind::Wasmer => run_wasmer( + VMKind::Wasmer0 => run_wasmer( code_hash, code, method_name, @@ -187,7 +187,7 @@ pub fn run_vm_profiled<'a>( } pub fn with_vm_variants(runner: fn(VMKind) -> ()) { - runner(VMKind::Wasmer); + runner(VMKind::Wasmer0); #[cfg(feature = "wasmtime_vm")] runner(VMKind::Wasmtime); @@ -199,7 +199,7 @@ pub fn with_vm_variants(runner: fn(VMKind) -> ()) { /// Used for testing cost of compiling a module pub fn compile_module(vm_kind: VMKind, code: &Vec) -> bool { match vm_kind { - VMKind::Wasmer => { + VMKind::Wasmer0 => { use crate::wasmer_runner::compile_module; compile_module(code) } diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index 9baf9ea1955..061a46968a9 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -149,7 +149,7 @@ fn trap_contract() -> Vec { fn test_trap_contract() { // See the comment is test_stack_overflow. assert_eq!( - make_simple_contract_call_vm(&trap_contract(), b"hello", VMKind::Wasmer), + make_simple_contract_call_vm(&trap_contract(), b"hello", VMKind::Wasmer0), ( Some(vm_outcome_with_gas(47105334)), Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) @@ -174,7 +174,7 @@ fn trap_initializer() -> Vec { fn test_trap_initializer() { // See the comment is test_stack_overflow. assert_eq!( - make_simple_contract_call_vm(&trap_initializer(), b"hello", VMKind::Wasmer), + make_simple_contract_call_vm(&trap_initializer(), b"hello", VMKind::Wasmer0), ( Some(vm_outcome_with_gas(47755584)), Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) @@ -280,7 +280,7 @@ fn test_stack_overflow() { // We only test trapping tests on Wasmer, as of version 0.17, when tests executed in parallel, // Wasmer signal handlers may catch signals thrown from the Wasmtime, and produce fake failing tests. assert_eq!( - make_simple_contract_call_vm(&stack_overflow(), b"hello", VMKind::Wasmer), + make_simple_contract_call_vm(&stack_overflow(), b"hello", VMKind::Wasmer0), ( Some(vm_outcome_with_gas(63226248177)), Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) @@ -389,7 +389,7 @@ fn test_bad_import_2() { fn test_bad_import_3() { with_vm_variants(|vm_kind: VMKind| { let msg = match vm_kind { - VMKind::Wasmer => "link error: Incorrect import type, namespace: env, name: input, expected type: global, found type: function", + VMKind::Wasmer0 => "link error: Incorrect import type, namespace: env, name: input, expected type: global, found type: function", VMKind::Wasmtime => "\"incompatible import type for `env::input` specified\\ndesired signature was: Global(GlobalType { content: I32, mutability: Const })\\nsignatures available:\\n\\n * Func(FuncType { params: [I64], results: [] })\\n\"", VMKind::Wasmer1 => "Error while importing \"env\".\"input\": incompatible import type. Expected Global(GlobalType { ty: I32, mutability: Const }) but received Function(FunctionType { params: [I64], results: [] })" }.to_string(); @@ -407,7 +407,7 @@ fn test_bad_import_3() { fn test_bad_import_4() { with_vm_variants(|vm_kind: VMKind| { let msg = match vm_kind { - VMKind::Wasmer => "link error: Import not found, namespace: env, name: wtf", + VMKind::Wasmer0 => "link error: Import not found, namespace: env, name: wtf", VMKind::Wasmtime => "\"unknown import: `env::wtf` has not been defined\"", VMKind::Wasmer1 => "Error while importing \"env\".\"wtf\": unknown import. Expected Function(FunctionType { params: [], results: [] })", } @@ -541,9 +541,9 @@ fn test_contract_error_caching() { let terragas = 1000000000000u64; assert_eq!(cache.store.lock().unwrap().len(), 0); let err1 = - make_cached_contract_call_vm(&mut cache, &code, b"method_name1", terragas, VMKind::Wasmer); + make_cached_contract_call_vm(&mut cache, &code, b"method_name1", terragas, VMKind::Wasmer0); assert_eq!(cache.store.lock().unwrap().len(), 1); let err2 = - make_cached_contract_call_vm(&mut cache, &code, b"method_name2", terragas, VMKind::Wasmer); + make_cached_contract_call_vm(&mut cache, &code, b"method_name2", terragas, VMKind::Wasmer0); assert_eq!(err1, err2); } diff --git a/runtime/near-vm-runner/tests/test_rs_contract.rs b/runtime/near-vm-runner/tests/test_rs_contract.rs index 6017b1c8fc0..7b58981eec4 100644 --- a/runtime/near-vm-runner/tests/test_rs_contract.rs +++ b/runtime/near-vm-runner/tests/test_rs_contract.rs @@ -241,7 +241,7 @@ pub fn test_out_of_memory() { &config, &fees, &promise_results, - VMKind::Wasmer, + VMKind::Wasmer0, LATEST_PROTOCOL_VERSION, None, ); diff --git a/runtime/runtime-params-estimator/src/main.rs b/runtime/runtime-params-estimator/src/main.rs index 49e13a4aa96..e1ba27af81e 100644 --- a/runtime/runtime-params-estimator/src/main.rs +++ b/runtime/runtime-params-estimator/src/main.rs @@ -92,9 +92,9 @@ fn main() { other => panic!("Unknown metric {}", other), }; let vm_kind = match matches.value_of("vm-kind") { - Some("wasmer") => VMKind::Wasmer, + Some("wasmer") => VMKind::Wasmer0, Some("wasmtime") => VMKind::Wasmtime, - _ => VMKind::Wasmer, + _ => VMKind::Wasmer0, }; let disable_measure_action_creation = matches.is_present("action-creation"); let disable_measure_transaction = matches.is_present("transaction"); diff --git a/runtime/runtime-params-estimator/src/vm_estimator.rs b/runtime/runtime-params-estimator/src/vm_estimator.rs index 9e8f1dd2877..9d6a8ffff42 100644 --- a/runtime/runtime-params-estimator/src/vm_estimator.rs +++ b/runtime/runtime-params-estimator/src/vm_estimator.rs @@ -158,7 +158,7 @@ pub fn cost_to_compile( println!( "About to compile {}", match vm_kind { - VMKind::Wasmer => "wasmer", + VMKind::Wasmer0 => "wasmer", VMKind::Wasmtime => { if USING_LIGHTBEAM { "wasmtime-lightbeam" From b3264ee9bc4638c2088bfc4dfa2c8cd696e26e31 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 14 Jan 2021 16:29:07 -0800 Subject: [PATCH 22/50] add cranelift-frontend to cargo deny --- deny.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deny.toml b/deny.toml index 7b4b513bfc9..e801eb5e0ab 100644 --- a/deny.toml +++ b/deny.toml @@ -130,5 +130,8 @@ skip = [ { name = "actix-codec", version = "=0.3.0"}, # actix-connect via actix-http and actix-server - { name = "actix-utils", version = "=1.0.6" } + { name = "actix-utils", version = "=1.0.6" }, + + # wasmer 1.0 use some newer version of crates than wasmer 0.17 & wasmtime, old ones are skipped here + { name = "cranelift-frontend", version = "=0.67.0" } ] From cbd5169017f63400435c12ccfdae7bb10235c62b Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 14 Jan 2021 16:47:05 -0800 Subject: [PATCH 23/50] fix cargo deny --- deny.toml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/deny.toml b/deny.toml index 8107f758b1c..f203f69420a 100644 --- a/deny.toml +++ b/deny.toml @@ -138,5 +138,16 @@ skip = [ { name = "parking_lot", version = "=0.9.0" }, # wasmer 1.0 use some newer version of crates than wasmer 0.17 & wasmtime, old ones are skipped here - { name = "cranelift-frontend", version = "=0.67.0" } + { name = "cranelift-bforest", version = "=0.67.0" }, + { name = "cranelift-codegen", version = "=0.67.0" }, + { name = "cranelift-codegen-meta", version = "=0.67.0" }, + { name = "cranelift-codegen-shared", version = "=0.67.0" }, + { name = "cranelift-entity", version = "=0.67.0" }, + { name = "cranelift-frontend", version = "=0.67.0" }, + { name = "gimli", version = "=0.21.0" }, + { name = "libloading", version = "=0.5.2" }, + { name = "regalloc", version = "=0.0.30" }, + { name = "strsim", version = "=0.8.0" }, + { name = "wasmparser", version = "=0.57.0" }, + { name = "which", version = "=3.1.1" }, ] From 69a77e031b0fa3c5d4d682ae045d6e61111ea5f8 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 14 Jan 2021 17:27:11 -0800 Subject: [PATCH 24/50] fix test workspace --- runtime/runtime-params-estimator/src/vm_estimator.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/runtime-params-estimator/src/vm_estimator.rs b/runtime/runtime-params-estimator/src/vm_estimator.rs index 0f7d93a2ac7..fd676b716b9 100644 --- a/runtime/runtime-params-estimator/src/vm_estimator.rs +++ b/runtime/runtime-params-estimator/src/vm_estimator.rs @@ -167,6 +167,7 @@ pub fn cost_to_compile( "wasmtime" } } + VMKind::Wasmer1 => "wasmer1", } ); }; From 43fb8a391e4ebc1969d2260e6b9cc0888e137b50 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 15 Jan 2021 10:38:46 -0800 Subject: [PATCH 25/50] workaround all-features --- runtime/near-vm-logic/Cargo.toml | 3 ++- runtime/near-vm-logic/src/config.rs | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/runtime/near-vm-logic/Cargo.toml b/runtime/near-vm-logic/Cargo.toml index 67b6c3e5b74..8da20a37f03 100644 --- a/runtime/near-vm-logic/Cargo.toml +++ b/runtime/near-vm-logic/Cargo.toml @@ -30,8 +30,9 @@ num-rational = { version = "0.2.4" } serde_json = {version= "1", features= ["preserve_order"]} [features] -default = ["costs_counting"] +default = ["costs_counting", "wasmer_default"] protocol_feature_evm = ["near-runtime-fees/protocol_feature_evm"] +wasmer_default = [] wasmtime_default = [] wasmer1_default = [] diff --git a/runtime/near-vm-logic/src/config.rs b/runtime/near-vm-logic/src/config.rs index 360dbd367ec..b42a51f211e 100644 --- a/runtime/near-vm-logic/src/config.rs +++ b/runtime/near-vm-logic/src/config.rs @@ -16,17 +16,29 @@ pub enum VMKind { } impl Default for VMKind { - #[cfg(feature = "wasmer_default")] + #[cfg(all( + feature = "wasmer_default", + not(feature = "wasmer1_default"), + not(feature = "wasmtime_default") + ))] fn default() -> Self { VMKind::Wasmer0 } - #[cfg(feature = "wasmer1_default")] + #[cfg(all( + not(feature = "wasmer_default"), + feature = "wasmer1_default", + not(feature = "wasmtime_default") + ))] fn default() -> Self { VMKind::Wasmer1 } - #[cfg(feature = "wasmtime_default")] + #[cfg(all( + not(feature = "wasmer_default"), + not(feature = "wasmer1_default"), + feature = "wasmtime_default" + ))] fn default() -> Self { VMKind::Wasmtime } @@ -39,6 +51,16 @@ impl Default for VMKind { fn default() -> Self { VMKind::Wasmer0 } + + // These features should be mutually exclusive, but implement this to --all-features + #[cfg(all( + feature = "wasmer_default", + feature = "wasmer1_default", + feature = "wasmtime_default" + ))] + fn default() -> Self { + VMKind::Wasmer0 + } } #[derive(Clone, Debug, Hash, Serialize, Deserialize, PartialEq, Eq)] From 20dbb3f0edb5c95ea0744d5cd5dc89bc20a2e393 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 15 Jan 2021 11:00:05 -0800 Subject: [PATCH 26/50] reuse import reference to vmlogicreference --- runtime/near-vm-runner/src/imports.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 95d1083de66..3df775d2d6f 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -2,14 +2,17 @@ use near_vm_logic::VMLogic; use std::ffi::c_void; -struct ImportReference(*mut c_void); +#[derive(Clone)] +pub struct ImportReference(pub *mut c_void); unsafe impl Send for ImportReference {} unsafe impl Sync for ImportReference {} -#[derive(Clone)] -pub struct VMLogicReference(pub *mut c_void); -unsafe impl Send for VMLogicReference {} -unsafe impl Sync for VMLogicReference {} +use wasmer::{Memory, WasmerEnv}; +#[derive(WasmerEnv, Clone)] +pub struct MyEnv { + pub memory: Memory, + pub logic: ImportReference, +} // Wasm has only i32/i64 types, so Wasmtime 0.17 only accepts // external functions taking i32/i64 type. @@ -46,13 +49,7 @@ macro_rules! wrapped_imports { #[cfg(feature = "wasmer1_vm")] pub mod wasmer1_ext { use near_vm_logic::VMLogic; - use wasmer::{WasmerEnv, Memory}; - use crate::imports::VMLogicReference; - #[derive(WasmerEnv, Clone)] - pub struct MyEnv { - pub memory: Memory, - pub logic: VMLogicReference, - } + use crate::imports::MyEnv; type VMResult = ::std::result::Result; $( @@ -123,7 +120,7 @@ macro_rules! wrapped_imports { #[cfg(feature = "wasmer1_vm")] pub(crate) fn build_wasmer1(store: &wasmer::Store, memory: wasmer::Memory, logic: &mut VMLogic<'_>) -> wasmer::ImportObject { - let env = wasmer1_ext::MyEnv {logic: VMLogicReference(logic as * mut _ as * mut c_void), memory: memory.clone()}; + let env = MyEnv {logic: ImportReference(logic as * mut _ as * mut c_void), memory: memory.clone()}; wasmer::imports! { "env" => { "memory" => memory, From d3f2ad244be7a7374177172103486f9542ede27d Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 15 Jan 2021 11:09:59 -0800 Subject: [PATCH 27/50] test_stack_overflow for wasmer1 --- .../near-vm-runner/tests/test_error_cases.rs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index 061a46968a9..1144ec7744e 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -277,17 +277,20 @@ fn stack_overflow() -> Vec { #[test] fn test_stack_overflow() { - // We only test trapping tests on Wasmer, as of version 0.17, when tests executed in parallel, - // Wasmer signal handlers may catch signals thrown from the Wasmtime, and produce fake failing tests. - assert_eq!( - make_simple_contract_call_vm(&stack_overflow(), b"hello", VMKind::Wasmer0), - ( - Some(vm_outcome_with_gas(63226248177)), - Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) - ) - ); - - // TODO add a Wasmer1 test? + with_vm_variants(|vm_kind: VMKind| { + // We only test trapping tests on Wasmer, as of version 0.17, when tests executed in parallel, + // Wasmer signal handlers may catch signals thrown from the Wasmtime, and produce fake failing tests. + match vm_kind { + VMKind::Wasmer0 | VMKind::Wasmer1 => assert_eq!( + make_simple_contract_call_vm(&stack_overflow(), b"hello", VMKind::Wasmer0), + ( + Some(vm_outcome_with_gas(63226248177)), + Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) + ) + ), + _ => {} + } + }); } fn memory_grow() -> Vec { From 1a2c8455d4cb979d7e03c7d0baad6cbfbfdbf253 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 15 Jan 2021 15:53:45 -0800 Subject: [PATCH 28/50] fix test_stack_overflow for wasmer1 --- runtime/near-vm-runner/tests/test_error_cases.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index 1144ec7744e..3df17a0c3b3 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -281,13 +281,22 @@ fn test_stack_overflow() { // We only test trapping tests on Wasmer, as of version 0.17, when tests executed in parallel, // Wasmer signal handlers may catch signals thrown from the Wasmtime, and produce fake failing tests. match vm_kind { - VMKind::Wasmer0 | VMKind::Wasmer1 => assert_eq!( - make_simple_contract_call_vm(&stack_overflow(), b"hello", VMKind::Wasmer0), + VMKind::Wasmer0 => assert_eq!( + make_simple_contract_call_vm(&stack_overflow(), b"hello", vm_kind), ( Some(vm_outcome_with_gas(63226248177)), Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) ) ), + VMKind::Wasmer1 => assert_eq!( + make_simple_contract_call_vm(&stack_overflow(), b"hello", vm_kind), + ( + Some(vm_outcome_with_gas(63226248177)), + Some(VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError( + "unreachable".to_string() + ))) + ) + ), _ => {} } }); From b802df20304177b7a82c3933f6b291613101cd7d Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 15 Jan 2021 17:18:22 -0800 Subject: [PATCH 29/50] upgrade to git wasmer to get internal of RuntimeError --- Cargo.lock | 269 ++++++++++++------- runtime/near-vm-errors/src/lib.rs | 3 - runtime/near-vm-runner/Cargo.toml | 7 +- runtime/near-vm-runner/src/wasmer1_runner.rs | 3 +- tools/indexer/example/Cargo.toml | 2 +- 5 files changed, 174 insertions(+), 110 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86fbbf76f7b..0dce169b890 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,11 +18,36 @@ dependencies = [ "log", "parking_lot 0.10.2", "pin-project 0.4.27", - "smallvec 1.5.1", + "smallvec 1.6.1", "tokio", "tokio-util 0.2.0", - "trust-dns-proto", - "trust-dns-resolver", + "trust-dns-proto 0.18.0-alpha.2", + "trust-dns-resolver 0.18.0-alpha.2", +] + +[[package]] +name = "actix" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be241f88f3b1e7e9a3fbe3b5a8a0f6915b5a1d7ee0d9a248d3376d01068cc60" +dependencies = [ + "actix-rt", + "actix_derive", + "bitflags", + "bytes", + "crossbeam-channel 0.4.4", + "derive_more", + "futures-channel", + "futures-util", + "log", + "once_cell", + "parking_lot 0.11.1", + "pin-project 0.4.27", + "smallvec 1.6.1", + "tokio", + "tokio-util 0.3.1", + "trust-dns-proto 0.19.6", + "trust-dns-resolver 0.19.6", ] [[package]] @@ -73,8 +98,8 @@ dependencies = [ "log", "openssl", "tokio-openssl", - "trust-dns-proto", - "trust-dns-resolver", + "trust-dns-proto 0.18.0-alpha.2", + "trust-dns-resolver 0.18.0-alpha.2", ] [[package]] @@ -171,7 +196,7 @@ dependencies = [ "copyless", "futures-channel", "futures-util", - "smallvec 1.5.1", + "smallvec 1.6.1", "tokio", ] @@ -1062,7 +1087,7 @@ dependencies = [ "log", "regalloc 0.0.30", "serde", - "smallvec 1.5.1", + "smallvec 1.6.1", "target-lexicon 0.11.1", "thiserror", ] @@ -1081,7 +1106,7 @@ dependencies = [ "gimli 0.22.0", "log", "regalloc 0.0.31", - "smallvec 1.5.1", + "smallvec 1.6.1", "target-lexicon 0.11.1", "thiserror", ] @@ -1144,7 +1169,7 @@ checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" dependencies = [ "cranelift-codegen 0.67.0", "log", - "smallvec 1.5.1", + "smallvec 1.6.1", "target-lexicon 0.11.1", ] @@ -1156,7 +1181,7 @@ checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen 0.68.0", "log", - "smallvec 1.5.1", + "smallvec 1.6.1", "target-lexicon 0.11.1", ] @@ -1637,28 +1662,6 @@ dependencies = [ "syn 1.0.57", ] -[[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 = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" -dependencies = [ - "darling", - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", -] - [[package]] name = "env_logger" version = "0.7.1" @@ -2482,7 +2485,7 @@ dependencies = [ name = "indexer-example" version = "0.1.0" dependencies = [ - "actix", + "actix 0.10.0", "clap 3.0.0-beta.2", "near-indexer", "openssl-probe", @@ -2804,7 +2807,7 @@ dependencies = [ "itertools 0.8.2", "memoffset 0.5.6", "more-asserts", - "smallvec 1.5.1", + "smallvec 1.6.1", "staticvec", "thiserror", "typemap", @@ -3140,7 +3143,7 @@ dependencies = [ name = "near-actix-utils" version = "0.1.0" dependencies = [ - "actix", + "actix 0.9.0", ] [[package]] @@ -3193,7 +3196,7 @@ dependencies = [ name = "near-chunks" version = "0.1.0" dependencies = [ - "actix", + "actix 0.9.0", "borsh", "cached", "chrono", @@ -3215,7 +3218,7 @@ dependencies = [ name = "near-client" version = "0.1.0" dependencies = [ - "actix", + "actix 0.9.0", "ansi_term 0.11.0", "borsh", "cached", @@ -3339,7 +3342,7 @@ dependencies = [ name = "near-indexer" version = "0.7.0" dependencies = [ - "actix", + "actix 0.9.0", "futures", "near-client", "near-crypto", @@ -3355,7 +3358,7 @@ dependencies = [ name = "near-jsonrpc" version = "0.2.0" dependencies = [ - "actix", + "actix 0.9.0", "actix-cors", "actix-web", "borsh", @@ -3395,7 +3398,7 @@ dependencies = [ name = "near-jsonrpc-test-utils" version = "0.1.0" dependencies = [ - "actix", + "actix 0.9.0", "lazy_static", "near-chain-configs", "near-client", @@ -3425,7 +3428,7 @@ dependencies = [ name = "near-network" version = "0.1.0" dependencies = [ - "actix", + "actix 0.9.0", "bencher", "borsh", "byteorder", @@ -3461,7 +3464,7 @@ dependencies = [ name = "near-performance-metrics" version = "0.1.0" dependencies = [ - "actix", + "actix 0.9.0", "actix-rt", "futures", "log", @@ -3522,7 +3525,7 @@ dependencies = [ name = "near-rosetta-rpc" version = "0.1.1" dependencies = [ - "actix", + "actix 0.9.0", "actix-cors", "actix-web", "derive_more", @@ -3620,7 +3623,7 @@ dependencies = [ name = "near-telemetry" version = "0.1.0" dependencies = [ - "actix", + "actix 0.9.0", "actix-web", "futures", "near-performance-metrics", @@ -3678,6 +3681,7 @@ dependencies = [ "pwasm-utils", "wabt", "wasmer", + "wasmer-compiler-singlepass", "wasmer-runtime-core-near", "wasmer-runtime-near", "wasmer-types", @@ -3703,7 +3707,7 @@ dependencies = [ name = "nearcore" version = "0.1.0" dependencies = [ - "actix", + "actix 0.9.0", "actix-rt", "futures", "lazy_static", @@ -3730,7 +3734,7 @@ dependencies = [ name = "neard" version = "1.2.0" dependencies = [ - "actix", + "actix 0.9.0", "actix-web", "borsh", "byteorder", @@ -4162,7 +4166,7 @@ dependencies = [ "ethereum-types", "malloc_size_of_derive", "parking_lot 0.9.0", - "smallvec 1.5.1", + "smallvec 1.6.1", "winapi 0.3.9", ] @@ -4229,7 +4233,7 @@ dependencies = [ "cloudabi", "libc", "redox_syscall", - "smallvec 1.5.1", + "smallvec 1.6.1", "winapi 0.3.9", ] @@ -4243,7 +4247,7 @@ dependencies = [ "instant", "libc", "redox_syscall", - "smallvec 1.5.1", + "smallvec 1.6.1", "winapi 0.3.9", ] @@ -4733,7 +4737,7 @@ version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a415a013dd7c5d4221382329a5a3482566da675737494935cbbbcdec04662f9d" dependencies = [ - "smallvec 1.5.1", + "smallvec 1.6.1", ] [[package]] @@ -4744,7 +4748,7 @@ checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" dependencies = [ "log", "rustc-hash", - "smallvec 1.5.1", + "smallvec 1.6.1", ] [[package]] @@ -4755,7 +4759,7 @@ checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", - "smallvec 1.5.1", + "smallvec 1.6.1", ] [[package]] @@ -4858,6 +4862,16 @@ dependencies = [ "quick-error", ] +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + [[package]] name = "restaked" version = "0.1.0" @@ -5301,9 +5315,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.5.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "smart-default" @@ -5561,7 +5575,7 @@ dependencies = [ name = "testlib" version = "0.1.0" dependencies = [ - "actix", + "actix 0.9.0", "assert_matches", "borsh", "byteorder", @@ -5785,6 +5799,7 @@ checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ "bytes", "futures-core", + "futures-io", "futures-sink", "log", "pin-project-lite 0.1.11", @@ -5884,7 +5899,7 @@ dependencies = [ "serde", "serde_json", "sharded-slab", - "smallvec 1.5.1", + "smallvec 1.6.1", "thread_local", "tracing", "tracing-core", @@ -5908,7 +5923,7 @@ dependencies = [ "hashbrown 0.6.3", "log", "rand 0.6.5", - "smallvec 1.5.1", + "smallvec 1.6.1", ] [[package]] @@ -5925,12 +5940,32 @@ dependencies = [ "lazy_static", "log", "rand 0.7.3", - "smallvec 1.5.1", + "smallvec 1.6.1", "socket2", "tokio", "url 2.2.0", ] +[[package]] +name = "trust-dns-proto" +version = "0.19.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53861fcb288a166aae4c508ae558ed18b53838db728d4d310aad08270a7d4c2b" +dependencies = [ + "async-trait", + "backtrace", + "enum-as-inner", + "futures", + "idna 0.2.0", + "lazy_static", + "log", + "rand 0.7.3", + "smallvec 1.6.1", + "thiserror", + "tokio", + "url 2.2.0", +] + [[package]] name = "trust-dns-resolver" version = "0.18.0-alpha.2" @@ -5944,10 +5979,30 @@ dependencies = [ "lazy_static", "log", "lru-cache", - "resolv-conf", - "smallvec 1.5.1", + "resolv-conf 0.6.3", + "smallvec 1.6.1", "tokio", - "trust-dns-proto", + "trust-dns-proto 0.18.0-alpha.2", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.19.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759e8efc40465547b0dfce9500d733c65f969a4cbbfbe3ccf68daaa46ef179e" +dependencies = [ + "backtrace", + "cfg-if 0.1.10", + "futures", + "ipconfig", + "lazy_static", + "log", + "lru-cache", + "resolv-conf 0.7.0", + "smallvec 1.6.1", + "thiserror", + "tokio", + "trust-dns-proto 0.19.6", ] [[package]] @@ -6330,9 +6385,8 @@ dependencies = [ [[package]] name = "wasmer" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b1ece7c894857344ae93506686ae36ccd867b4ed55819c06d2316d009098d4" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -6341,7 +6395,6 @@ dependencies = [ "thiserror", "wasmer-compiler", "wasmer-compiler-cranelift", - "wasmer-compiler-singlepass", "wasmer-derive", "wasmer-engine", "wasmer-engine-jit", @@ -6354,27 +6407,25 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc85134b257e5fba5870693441e300b601d08f18833ac4fa6934f0b72afc56d2" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ - "enumset", "raw-cpuid", "serde", "serde_bytes", - "smallvec 1.5.1", + "smallvec 1.6.1", "target-lexicon 0.11.1", "thiserror", "wasmer-types", "wasmer-vm", + "wasmer_enumset", "wasmparser 0.65.0", ] [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60d68fb05dbe908724901b680070560944d99d04c52c763e98124aa988ac6dd0" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "cranelift-codegen 0.68.0", "cranelift-frontend 0.68.0", @@ -6382,7 +6433,7 @@ dependencies = [ "more-asserts", "rayon", "serde", - "smallvec 1.5.1", + "smallvec 1.6.1", "tracing", "wasmer-compiler", "wasmer-types", @@ -6391,9 +6442,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81f91c9471113efc731fdd9f54f6fb82fab4c00498281966fcc4a87cdf360ea5" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "byteorder", "dynasm 1.0.0", @@ -6402,7 +6452,7 @@ dependencies = [ "more-asserts", "rayon", "serde", - "smallvec 1.5.1", + "smallvec 1.6.1", "wasmer-compiler", "wasmer-types", "wasmer-vm", @@ -6410,9 +6460,8 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca24205ffdf2d3b1a9c01219f4f3f0a1382658680abe73bc5b146f941adeeb8e" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "proc-macro-error", "proc-macro2 1.0.24", @@ -6422,9 +6471,8 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed16436a9813d92f434e1d40fdf91b45ca30f351a799f793015359acca86b" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "backtrace", "bincode", @@ -6443,9 +6491,8 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1e3ca5e34eacd4ab6d9d32edd41b51d2e39cf3d75453611c9c57cee3a64691" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -6461,9 +6508,8 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a21d6c5ae0c384ba2f01f598c95b01d4da2eaec3376fb96de2ded38c54143a0" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -6482,9 +6528,8 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e007e73ec7775aecc61045092dabfcff1e9f228129cd129e76a3e6aae26454" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "object 0.22.0", "thiserror", @@ -6515,7 +6560,7 @@ dependencies = [ "serde-bench", "serde_bytes", "serde_derive", - "smallvec 1.5.1", + "smallvec 1.6.1", "target-lexicon 0.10.0", "wasmparser 0.51.4", "winapi 0.3.9", @@ -6550,15 +6595,14 @@ dependencies = [ "nix", "serde", "serde_derive", - "smallvec 1.5.1", + "smallvec 1.6.1", "wasmer-runtime-core-near", ] [[package]] name = "wasmer-types" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dbba7a95edb61b40daa43079979fc3212234e1645a15b8c527c36decad59fc6" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "cranelift-entity 0.68.0", "serde", @@ -6567,9 +6611,8 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cd9acd4d53c004a11fcaff17f2a2528ae8f1748c6d5c4aea7d8bed2d9236f0f" +version = "1.0.1" +source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" dependencies = [ "backtrace", "cc", @@ -6585,6 +6628,28 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wasmer_enumset" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf088cc1f7d247fd96dff0df46fb1bbb747d8a69ae1ecd71aed55c55e354b2d8" +dependencies = [ + "num-traits", + "wasmer_enumset_derive", +] + +[[package]] +name = "wasmer_enumset_derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1b32d98e11194200baf6d3f85eb2d6cfe56f6d9af0dd617f90ca48f958a88" +dependencies = [ + "darling", + "proc-macro2 1.0.24", + "quote 1.0.7", + "syn 1.0.57", +] + [[package]] name = "wasmparser" version = "0.51.4" @@ -6625,7 +6690,7 @@ dependencies = [ "region", "rustc-demangle", "serde", - "smallvec 1.5.1", + "smallvec 1.6.1", "target-lexicon 0.11.1", "wasmparser 0.59.0", "wasmtime-environ", diff --git a/runtime/near-vm-errors/src/lib.rs b/runtime/near-vm-errors/src/lib.rs index c1a9118fece..081a80c9126 100644 --- a/runtime/near-vm-errors/src/lib.rs +++ b/runtime/near-vm-errors/src/lib.rs @@ -37,9 +37,6 @@ pub enum FunctionCallError { HostError(HostError), EvmError(EvmError), /// An error message when wasmer 1.0 returns a wasmer::RuntimeError - /// In wasmer 1.0 the internal of runtime error is not pub, so we cannot tell it's a UserError - /// or Trap, and which kind of Trap. The pub thing we have is a error message returns by wasmer, - /// Indicate the reason of RuntimeError, and if it's a Trap what kind of trap it is. WasmerRuntimeError(String), } #[derive( diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index cb3a4384d8b..725702f3fce 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -16,8 +16,9 @@ This crate implements the specification of the interface that Near blockchain ex borsh = "0.7.1" wasmer-runtime = { version="0.17.1", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near" } wasmer-runtime-core = {version = "0.17.1", package = "wasmer-runtime-core-near" } -wasmer = { version = "1.0.0", features = ["singlepass"], optional = true } -wasmer-types = { version = "1.0.0", optional = true} +wasmer = { git = "https://github.com/wasmerio/wasmer", rev="b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb", optional = true } +wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev="b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb", optional = true } +wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev="b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb", optional = true } pwasm-utils = "0.12" parity-wasm = "0.41" wasmtime = { version = "0.20.0", default-features = false, optional = true } @@ -37,7 +38,7 @@ bencher = "^0.1.5" [features] default = [ "wasmer_default", "wasmer", "wasmer-types" ] wasmtime_vm = [ "wasmtime", "anyhow"] -wasmer1_vm = [ "wasmer", "wasmer-types" ] +wasmer1_vm = [ "wasmer", "wasmer-types", "wasmer-compiler-singlepass" ] lightbeam = ["wasmtime/lightbeam"] wasmer_default = [] wasmtime_default = ["wasmtime_vm"] diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index f0513972371..0fc0667626b 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -8,7 +8,8 @@ use near_vm_errors::{ }; use near_vm_logic::types::{ProfileData, PromiseResult, ProtocolVersion}; use near_vm_logic::{External, MemoryLike, VMConfig, VMContext, VMLogic, VMLogicError, VMOutcome}; -use wasmer::{Bytes, Instance, Memory, MemoryType, Module, Pages, Singlepass, Store, JIT}; +use wasmer::{Bytes, Instance, Memory, MemoryType, Module, Pages, Store, JIT}; +use wasmer_compiler_singlepass::Singlepass; pub struct Wasmer1Memory(Memory); diff --git a/tools/indexer/example/Cargo.toml b/tools/indexer/example/Cargo.toml index 8aab6ab6157..6b4cee03a87 100644 --- a/tools/indexer/example/Cargo.toml +++ b/tools/indexer/example/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Near Inc "] edition = "2018" [dependencies] -actix = "0.9" +actix = "0.10" clap = "3.0.0-beta.1" openssl-probe = { version = "0.1.2" } serde_json = "1.0.55" From 5061b4ca5b3d0190f8ea61c5771e384f7b372d68 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 15 Jan 2021 18:00:11 -0800 Subject: [PATCH 30/50] test wasmer trap and user error --- runtime/near-vm-errors/src/lib.rs | 5 +++++ runtime/near-vm-runner/src/wasmer1_runner.rs | 17 ++++++++++++++--- .../near-vm-runner/tests/test_error_cases.rs | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/runtime/near-vm-errors/src/lib.rs b/runtime/near-vm-errors/src/lib.rs index 081a80c9126..d9d1b876ac6 100644 --- a/runtime/near-vm-errors/src/lib.rs +++ b/runtime/near-vm-errors/src/lib.rs @@ -38,6 +38,10 @@ pub enum FunctionCallError { EvmError(EvmError), /// An error message when wasmer 1.0 returns a wasmer::RuntimeError WasmerRuntimeError(String), + /// A trap in Wasmer 1.0, not same as WasmTrap above, String is a machine readable form like "stk_ovf" + /// String is used instead of wasmer internal enum is because of BorshSerializable. + /// It can be convert back by wasmer_vm::TrapCode::from_str + Wasmer1Trap(String), } #[derive( Debug, Clone, PartialEq, Eq, BorshDeserialize, BorshSerialize, Deserialize, Serialize, RpcError, @@ -347,6 +351,7 @@ impl fmt::Display for FunctionCallError { } FunctionCallError::EvmError(e) => write!(f, "EVM: {:?}", e), FunctionCallError::WasmerRuntimeError(e) => write!(f, "Wasmer Runtime: {}", e), + FunctionCallError::Wasmer1Trap(e) => write!(f, "Wasmer 1.0 trap: {}", e), } } } diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 0fc0667626b..2930097cdc2 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -87,12 +87,23 @@ impl IntoVMError for wasmer::InstantiationError { impl IntoVMError for wasmer::RuntimeError { fn into_vm_error(self) -> VMError { + // These vars are not used in every cases, however, downcast below use Arc::try_unwrap + // so we cannot clone self let error_msg = self.message(); + let trap_code = self.clone().to_trap(); match self.downcast::() { Ok(e) => e.into_vm_error(), - // Either a Trap or Generic error of wasmer::RuntimeError - // We only know it's message - _ => VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError(error_msg)), + _ => { + if let Some(trap_code) = trap_code { + // A trap + VMError::FunctionCallError(FunctionCallError::Wasmer1Trap( + trap_code.to_string(), + )) + } else { + // A general error + VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError(error_msg)) + } + } } } } diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index 3df17a0c3b3..7173d552dc7 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -292,7 +292,7 @@ fn test_stack_overflow() { make_simple_contract_call_vm(&stack_overflow(), b"hello", vm_kind), ( Some(vm_outcome_with_gas(63226248177)), - Some(VMError::FunctionCallError(FunctionCallError::WasmerRuntimeError( + Some(VMError::FunctionCallError(FunctionCallError::Wasmer1Trap( "unreachable".to_string() ))) ) From 841482df610cd16e68fa40574da1e4c0c97411fe Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 20 Jan 2021 10:49:32 -0800 Subject: [PATCH 31/50] rename --- runtime/near-vm-runner/src/imports.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 3df775d2d6f..1941ed981ca 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -9,7 +9,7 @@ unsafe impl Sync for ImportReference {} use wasmer::{Memory, WasmerEnv}; #[derive(WasmerEnv, Clone)] -pub struct MyEnv { +pub struct NearWasmerEnv { pub memory: Memory, pub logic: ImportReference, } @@ -49,12 +49,12 @@ macro_rules! wrapped_imports { #[cfg(feature = "wasmer1_vm")] pub mod wasmer1_ext { use near_vm_logic::VMLogic; - use crate::imports::MyEnv; + use crate::imports::NearWasmerEnv; type VMResult = ::std::result::Result; $( #[allow(unused_parens)] - pub fn $func(env: &MyEnv, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { + pub fn $func(env: &NearWasmerEnv, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { let logic: &mut VMLogic = unsafe { &mut *(env.logic.0 as *mut VMLogic<'_>) }; logic.$func( $( $arg_name, )* ) } @@ -120,7 +120,7 @@ macro_rules! wrapped_imports { #[cfg(feature = "wasmer1_vm")] pub(crate) fn build_wasmer1(store: &wasmer::Store, memory: wasmer::Memory, logic: &mut VMLogic<'_>) -> wasmer::ImportObject { - let env = MyEnv {logic: ImportReference(logic as * mut _ as * mut c_void), memory: memory.clone()}; + let env = NearWasmerEnv {logic: ImportReference(logic as * mut _ as * mut c_void), memory: memory.clone()}; wasmer::imports! { "env" => { "memory" => memory, From 163898786a9a7a9505aeabc63bb7616a859fc749 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 1 Feb 2021 15:50:38 -0800 Subject: [PATCH 32/50] fix a compilation error from merge --- runtime/near-vm-runner/src/runner.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/near-vm-runner/src/runner.rs b/runtime/near-vm-runner/src/runner.rs index c6719af6995..9dd3d72a5ff 100644 --- a/runtime/near-vm-runner/src/runner.rs +++ b/runtime/near-vm-runner/src/runner.rs @@ -237,10 +237,15 @@ pub fn precompile<'a>( ) -> Option { use crate::cache::compile_and_serialize_wasmer; match vm_kind { - VMKind::Wasmer => { + VMKind::Wasmer0 => { let result = compile_and_serialize_wasmer(code, wasm_config, code_hash, cache); result.err() } + VMKind::Wasmer1 => Some(VMError::FunctionCallError(FunctionCallError::CompilationError( + CompilationError::UnsupportedCompiler { + msg: "Precompilation not supported in Wasmer 1.x yet".to_string(), + }, + ))), VMKind::Wasmtime => Some(VMError::FunctionCallError(FunctionCallError::CompilationError( CompilationError::UnsupportedCompiler { msg: "Precompilation not supported in Wasmtime yet".to_string(), From 82f69a8549e97518b7767b1fe123c106c261c84d Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 1 Feb 2021 16:03:51 -0800 Subject: [PATCH 33/50] actix 0.9 also works, so undo it --- Cargo.lock | 116 ++++++------------------------- tools/indexer/example/Cargo.toml | 2 +- 2 files changed, 21 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3508ecbe48d..8ace0493034 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,33 +21,8 @@ dependencies = [ "smallvec 1.6.1", "tokio", "tokio-util 0.2.0", - "trust-dns-proto 0.18.0-alpha.2", - "trust-dns-resolver 0.18.0-alpha.2", -] - -[[package]] -name = "actix" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be241f88f3b1e7e9a3fbe3b5a8a0f6915b5a1d7ee0d9a248d3376d01068cc60" -dependencies = [ - "actix-rt", - "actix_derive", - "bitflags", - "bytes", - "crossbeam-channel 0.4.4", - "derive_more", - "futures-channel", - "futures-util", - "log", - "once_cell", - "parking_lot 0.11.1", - "pin-project 0.4.27", - "smallvec 1.6.1", - "tokio", - "tokio-util 0.3.1", - "trust-dns-proto 0.19.6", - "trust-dns-resolver 0.19.6", + "trust-dns-proto", + "trust-dns-resolver", ] [[package]] @@ -98,8 +73,8 @@ dependencies = [ "log", "openssl", "tokio-openssl", - "trust-dns-proto 0.18.0-alpha.2", - "trust-dns-resolver 0.18.0-alpha.2", + "trust-dns-proto", + "trust-dns-resolver", ] [[package]] @@ -2491,7 +2466,7 @@ dependencies = [ name = "indexer-example" version = "0.1.0" dependencies = [ - "actix 0.10.0", + "actix", "clap 3.0.0-beta.2", "near-indexer", "openssl-probe", @@ -3161,7 +3136,7 @@ dependencies = [ name = "near-actix-utils" version = "0.1.0" dependencies = [ - "actix 0.9.0", + "actix", ] [[package]] @@ -3214,7 +3189,7 @@ dependencies = [ name = "near-chunks" version = "0.1.0" dependencies = [ - "actix 0.9.0", + "actix", "borsh", "cached", "chrono", @@ -3236,7 +3211,7 @@ dependencies = [ name = "near-client" version = "0.1.0" dependencies = [ - "actix 0.9.0", + "actix", "ansi_term 0.11.0", "borsh", "cached", @@ -3360,7 +3335,7 @@ dependencies = [ name = "near-indexer" version = "0.7.0" dependencies = [ - "actix 0.9.0", + "actix", "futures", "near-client", "near-crypto", @@ -3376,7 +3351,7 @@ dependencies = [ name = "near-jsonrpc" version = "0.2.0" dependencies = [ - "actix 0.9.0", + "actix", "actix-cors", "actix-web", "borsh", @@ -3416,7 +3391,7 @@ dependencies = [ name = "near-jsonrpc-test-utils" version = "0.1.0" dependencies = [ - "actix 0.9.0", + "actix", "lazy_static", "near-chain-configs", "near-client", @@ -3446,7 +3421,7 @@ dependencies = [ name = "near-network" version = "0.1.0" dependencies = [ - "actix 0.9.0", + "actix", "bencher", "borsh", "byteorder", @@ -3482,7 +3457,7 @@ dependencies = [ name = "near-performance-metrics" version = "0.1.0" dependencies = [ - "actix 0.9.0", + "actix", "actix-rt", "futures", "log", @@ -3543,7 +3518,7 @@ dependencies = [ name = "near-rosetta-rpc" version = "0.1.1" dependencies = [ - "actix 0.9.0", + "actix", "actix-cors", "actix-web", "derive_more", @@ -3641,7 +3616,7 @@ dependencies = [ name = "near-telemetry" version = "0.1.0" dependencies = [ - "actix 0.9.0", + "actix", "actix-web", "futures", "near-performance-metrics", @@ -3726,7 +3701,7 @@ dependencies = [ name = "nearcore" version = "0.1.0" dependencies = [ - "actix 0.9.0", + "actix", "actix-rt", "futures", "lazy_static", @@ -3753,7 +3728,7 @@ dependencies = [ name = "neard" version = "1.2.0" dependencies = [ - "actix 0.9.0", + "actix", "actix-web", "borsh", "byteorder", @@ -4881,16 +4856,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "resolv-conf" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" -dependencies = [ - "hostname", - "quick-error", -] - [[package]] name = "restaked" version = "0.1.0" @@ -5606,7 +5571,7 @@ dependencies = [ name = "testlib" version = "0.1.0" dependencies = [ - "actix 0.9.0", + "actix", "assert_matches", "borsh", "byteorder", @@ -5830,7 +5795,6 @@ checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ "bytes", "futures-core", - "futures-io", "futures-sink", "log", "pin-project-lite 0.1.11", @@ -5977,26 +5941,6 @@ dependencies = [ "url 2.2.0", ] -[[package]] -name = "trust-dns-proto" -version = "0.19.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53861fcb288a166aae4c508ae558ed18b53838db728d4d310aad08270a7d4c2b" -dependencies = [ - "async-trait", - "backtrace", - "enum-as-inner", - "futures", - "idna 0.2.0", - "lazy_static", - "log", - "rand 0.7.3", - "smallvec 1.6.1", - "thiserror", - "tokio", - "url 2.2.0", -] - [[package]] name = "trust-dns-resolver" version = "0.18.0-alpha.2" @@ -6010,30 +5954,10 @@ dependencies = [ "lazy_static", "log", "lru-cache", - "resolv-conf 0.6.3", + "resolv-conf", "smallvec 1.6.1", "tokio", - "trust-dns-proto 0.18.0-alpha.2", -] - -[[package]] -name = "trust-dns-resolver" -version = "0.19.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6759e8efc40465547b0dfce9500d733c65f969a4cbbfbe3ccf68daaa46ef179e" -dependencies = [ - "backtrace", - "cfg-if 0.1.10", - "futures", - "ipconfig", - "lazy_static", - "log", - "lru-cache", - "resolv-conf 0.7.0", - "smallvec 1.6.1", - "thiserror", - "tokio", - "trust-dns-proto 0.19.6", + "trust-dns-proto", ] [[package]] diff --git a/tools/indexer/example/Cargo.toml b/tools/indexer/example/Cargo.toml index 6b4cee03a87..8aab6ab6157 100644 --- a/tools/indexer/example/Cargo.toml +++ b/tools/indexer/example/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Near Inc "] edition = "2018" [dependencies] -actix = "0.10" +actix = "0.9" clap = "3.0.0-beta.1" openssl-probe = { version = "0.1.2" } serde_json = "1.0.55" From d0f377b31cc123d9f1b3788e67d7b6acb8912292 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 3 Feb 2021 15:39:02 -0800 Subject: [PATCH 34/50] enable ability to build neard with wasmer 1.0 --- Cargo.lock | 1 + Cargo.toml | 3 +-- neard/Cargo.toml | 2 -- runtime/near-vm-logic/Cargo.toml | 2 +- runtime/near-vm-runner/Cargo.toml | 6 ++---- runtime/near-vm-runner/src/imports.rs | 2 ++ runtime/runtime/Cargo.toml | 3 +-- tools/delay_detector/src/lib.rs | 2 +- 8 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e5b3b9bba0..84d59909891 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3731,6 +3731,7 @@ dependencies = [ "bencher", "borsh", "cached", + "delay-detector", "log", "near-evm-runner", "near-primitives", diff --git a/Cargo.toml b/Cargo.toml index ab0edbce21e..df4a907806b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,8 +116,7 @@ delay_detector = ["neard/delay_detector"] rosetta_rpc = ["neard/rosetta_rpc"] protocol_feature_forward_chunk_parts = ["neard/protocol_feature_forward_chunk_parts"] nightly_protocol = ["near-primitives/nightly_protocol", "near-jsonrpc/nightly_protocol"] -wasmtime_vm = ["neard/wasmtime_vm"] -wasmer1_vm = ["neard/wasmer1_vm"] +wasmer1_default = ["node-runtime/wasmer1_default"] nightly_protocol_features = ["nightly_protocol", "neard/nightly_protocol_features", "protocol_feature_evm", "protocol_feature_block_header_v3"] protocol_feature_evm = ["neard/protocol_feature_evm", "testlib/protocol_feature_evm", "runtime-params-estimator/protocol_feature_evm"] protocol_feature_block_header_v3 = ["near-primitives/protocol_feature_block_header_v3", "near-chain/protocol_feature_block_header_v3", "neard/protocol_feature_block_header_v3"] diff --git a/neard/Cargo.toml b/neard/Cargo.toml index 3ec66b12269..66eaa8598a5 100644 --- a/neard/Cargo.toml +++ b/neard/Cargo.toml @@ -70,8 +70,6 @@ protocol_feature_evm = ["near-primitives/protocol_feature_evm", "node-runtime/pr protocol_feature_block_header_v3 = ["near-primitives/protocol_feature_block_header_v3", "near-chain/protocol_feature_block_header_v3", "near-client/protocol_feature_block_header_v3"] nightly_protocol_features = ["nightly_protocol", "near-primitives/nightly_protocol_features", "near-client/nightly_protocol_features", "near-epoch-manager/nightly_protocol_features", "near-store/nightly_protocol_features", "protocol_feature_forward_chunk_parts", "protocol_feature_rectify_inflation", "protocol_feature_evm", "protocol_feature_block_header_v3"] nightly_protocol = ["near-primitives/nightly_protocol", "near-jsonrpc/nightly_protocol"] -wasmtime_vm = ["node-runtime/wasmtime_vm"] -wasmer1_vm = ["node-runtime/wasmer1_vm"] costs_counting = ["node-runtime/costs_counting"] [[bin]] diff --git a/runtime/near-vm-logic/Cargo.toml b/runtime/near-vm-logic/Cargo.toml index 8da20a37f03..730a561d5d4 100644 --- a/runtime/near-vm-logic/Cargo.toml +++ b/runtime/near-vm-logic/Cargo.toml @@ -30,7 +30,7 @@ num-rational = { version = "0.2.4" } serde_json = {version= "1", features= ["preserve_order"]} [features] -default = ["costs_counting", "wasmer_default"] +default = ["costs_counting"] protocol_feature_evm = ["near-runtime-fees/protocol_feature_evm"] wasmer_default = [] wasmtime_default = [] diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index 1b6dab2a526..7cd67351ef2 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -30,6 +30,7 @@ near-primitives = { path = "../../core/primitives" } log = "0.4" near-evm-runner = { path = "../near-evm-runner", version = "2.3.0", optional = true} cached = "0.12.0" +delay-detector = { path = "../../tools/delay_detector" } [dev-dependencies] assert_matches = "1.3" @@ -37,13 +38,10 @@ wabt = "0.9" bencher = "^0.1.5" [features] -default = [ "wasmer_default", "wasmer", "wasmer-types" ] +default = [] wasmtime_vm = [ "wasmtime", "anyhow"] wasmer1_vm = [ "wasmer", "wasmer-types", "wasmer-compiler-singlepass" ] lightbeam = ["wasmtime/lightbeam"] -wasmer_default = [] -wasmtime_default = ["wasmtime_vm"] -wasmer1_default = [ "wasmer1_vm" ] no_cpu_compatibility_checks = [] protocol_feature_evm = ["near-runtime-fees/protocol_feature_evm", "near-evm-runner/protocol_feature_evm"] diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index ca782ab8906..e019bb1c556 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -8,8 +8,10 @@ pub struct ImportReference(pub *mut c_void); unsafe impl Send for ImportReference {} unsafe impl Sync for ImportReference {} +#[cfg(feature = "wasmer1_vm")] use wasmer::{Memory, WasmerEnv}; #[derive(WasmerEnv, Clone)] +#[cfg(feature = "wasmer1_vm")] pub struct NearWasmerEnv { pub memory: Memory, pub logic: ImportReference, diff --git a/runtime/runtime/Cargo.toml b/runtime/runtime/Cargo.toml index 1983a55cfbe..6ec3d0ad1a9 100644 --- a/runtime/runtime/Cargo.toml +++ b/runtime/runtime/Cargo.toml @@ -36,8 +36,7 @@ near-evm-runner = { path = "../../runtime/near-evm-runner", optional = true } default = [] dump_errors_schema = ["near-vm-errors/dump_errors_schema"] protocol_feature_evm = ["near-evm-runner/protocol_feature_evm", "near-primitives/protocol_feature_evm", "near-runtime-fees/protocol_feature_evm", "near-vm-runner/protocol_feature_evm"] -wasmtime_vm = ["near-vm-runner/wasmtime_vm"] -wasmer1_vm = ["near-vm-runner/wasmer1_vm"] +wasmer1_default = ["near-vm-runner/wasmer1_vm", "near-vm-logic/wasmer1_default"] # Use this feature to enable counting of fees and costs applied. costs_counting = ["near-vm-logic/costs_counting", "near-vm-runner/costs_counting"] diff --git a/tools/delay_detector/src/lib.rs b/tools/delay_detector/src/lib.rs index 0088f85dc33..d55fb87b513 100644 --- a/tools/delay_detector/src/lib.rs +++ b/tools/delay_detector/src/lib.rs @@ -26,7 +26,7 @@ impl<'a> DelayDetector<'a> { impl<'a> Drop for DelayDetector<'a> { fn drop(&mut self) { let elapsed = Instant::now() - self.started; - if elapsed > Duration::from_millis(50) && elapsed <= Duration::from_millis(500) { + if elapsed > Duration::from_millis(5) && elapsed <= Duration::from_millis(500) { info!(target: "delay_detector", "Took {:?} processing {}", elapsed, self.msg); } if elapsed > Duration::from_millis(500) { From f452f9df313300ca4570142feeb7902f277d3e32 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 3 Feb 2021 18:22:25 -0800 Subject: [PATCH 35/50] cache in wasmer1 --- runtime/near-vm-runner/src/cache.rs | 76 ++++++++++++++++++++ runtime/near-vm-runner/src/wasmer1_runner.rs | 11 ++- tools/delay_detector/src/lib.rs | 2 +- 3 files changed, 82 insertions(+), 7 deletions(-) diff --git a/runtime/near-vm-runner/src/cache.rs b/runtime/near-vm-runner/src/cache.rs index 9d654edb749..b1ff2efed30 100644 --- a/runtime/near-vm-runner/src/cache.rs +++ b/runtime/near-vm-runner/src/cache.rs @@ -12,6 +12,7 @@ use std::convert::TryFrom; use wasmer_runtime::{compiler_for_backend, Backend}; use wasmer_runtime_core::cache::Artifact; use wasmer_runtime_core::load_cache_with; +use delay_detector::DelayDetector; pub(crate) fn compile_module( code: &[u8], @@ -148,3 +149,78 @@ pub(crate) fn compile_module_cached_wasmer( #[cfg(feature = "no_cache")] return compile_module_cached_wasmer_impl(key, wasm_code, config, cache); } + +#[cfg(feature = "wasmer1_vm")] +pub(crate) fn compile_module_cached_wasmer1( + wasm_code_hash: &[u8], + wasm_code: &[u8], + config: &VMConfig, + cache: Option<&dyn CompiledContractCache>, + store: &wasmer::Store, +) -> Result { + let key = get_key(wasm_code_hash, wasm_code, VMKind::Wasmer1, config); + return compile_module_cached_wasmer1_impl(key, wasm_code, cache, store); +} + +#[cfg(feature = "wasmer1_vm")] +fn compile_module_wasmer1(prepared_code: &[u8], store: &wasmer::Store) -> Result { + wasmer::Module::new(&store, prepared_code).map_err(|err| err.into_vm_error()) +} + +#[cfg(feature = "wasmer1_vm")] +pub(crate) fn compile_and_serialize_wasmer1( + wasm_code: &[u8], + key: &CryptoHash, + cache: &dyn CompiledContractCache, + store: &wasmer::Store, +) -> Result { + let mut d = DelayDetector::new("enter compile_and_serialize_wasmer1".into()); + let module = compile_module_wasmer1(wasm_code, store).map_err(|e| cache_error(e, &key, cache))?; + let code = module.serialize().map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; + let serialized = CacheRecord::Code(code).try_to_vec().unwrap(); + cache.put(key.as_ref(), &serialized).map_err(|_e| VMError::CacheError(WriteError))?; + d.snapshot("finish compile_and_serialize_wasmer1"); + Ok(module) +} + +#[cfg(feature = "wasmer1_vm")] +fn deserialize_wasmer1( + serialized: &[u8], + store: &wasmer::Store +) -> Result, CacheError> { + let mut d = DelayDetector::new("enter deserialize_wasmer1".into()); + let record = CacheRecord::try_from_slice(serialized).map_err(|_e| DeserializationError)?; + let serialized_module = match record { + CacheRecord::Error(err) => return Ok(Err(err)), + CacheRecord::Code(code) => code, + }; + let r = unsafe { + Ok(Ok(wasmer::Module::deserialize(store, serialized_module.as_slice()) + .map_err(|_e| CacheError::DeserializationError)?)) + }; + d.snapshot("leave deserialize_wasmer1"); + r +} + +#[cfg(feature = "wasmer1_vm")] +fn compile_module_cached_wasmer1_impl( + key: CryptoHash, + wasm_code: &[u8], + cache: Option<&dyn CompiledContractCache>, + store: &wasmer::Store +) -> Result { + if cache.is_none() { + return compile_module_wasmer1(wasm_code, store); + } + + let cache = cache.unwrap(); + match cache.get(&(key.0).0) { + Ok(serialized) => match serialized { + Some(serialized) => { + deserialize_wasmer1(serialized.as_slice(), store).map_err(VMError::CacheError)? + } + None => compile_and_serialize_wasmer1(wasm_code, &key, cache, store), + }, + Err(_) => Err(VMError::CacheError(ReadError)), + } +} \ No newline at end of file diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 2930097cdc2..ce10008120a 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -1,6 +1,5 @@ use crate::errors::IntoVMError; -use crate::imports; -use crate::prepare; +use crate::{cache, imports, prepare}; use near_primitives::types::CompiledContractCache; use near_runtime_fees::RuntimeFeesConfig; use near_vm_errors::{ @@ -142,7 +141,7 @@ fn check_method(module: &Module, method_name: &str) -> Result<(), VMError> { } pub fn run_wasmer1<'a>( - _code_hash: Vec, + code_hash: Vec, code: &[u8], method_name: &[u8], ext: &mut dyn External, @@ -152,7 +151,7 @@ pub fn run_wasmer1<'a>( promise_results: &'a [PromiseResult], profile: Option, current_protocol_version: ProtocolVersion, - _cache: Option<&'a dyn CompiledContractCache>, + cache: Option<&'a dyn CompiledContractCache>, ) -> (Option, Option) { // NaN behavior is deterministic as of now: https://github.com/wasmerio/wasmer/issues/1269 // So doesn't require x86. However, when it is on x86, AVX is required: @@ -179,9 +178,9 @@ pub fn run_wasmer1<'a>( Ok(code) => code, Err(e) => return (None, Some(e.into())), }; - let module = match Module::new(&store, prepared_code) { + let module = match cache::compile_module_cached_wasmer1(&code_hash, &prepared_code, wasm_config, cache, &store) { Ok(x) => x, - Err(err) => return (None, Some(err.into_vm_error())), + Err(err) => return (None, Some(err)), }; let mut memory = Wasmer1Memory::new( diff --git a/tools/delay_detector/src/lib.rs b/tools/delay_detector/src/lib.rs index d55fb87b513..1aa7ccd76b8 100644 --- a/tools/delay_detector/src/lib.rs +++ b/tools/delay_detector/src/lib.rs @@ -26,7 +26,7 @@ impl<'a> DelayDetector<'a> { impl<'a> Drop for DelayDetector<'a> { fn drop(&mut self) { let elapsed = Instant::now() - self.started; - if elapsed > Duration::from_millis(5) && elapsed <= Duration::from_millis(500) { + if elapsed > Duration::from_millis(1) && elapsed <= Duration::from_millis(500) { info!(target: "delay_detector", "Took {:?} processing {}", elapsed, self.msg); } if elapsed > Duration::from_millis(500) { From afa9b25a039e2a432232d375b9232fc70c530bc2 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 4 Feb 2021 17:11:12 -0800 Subject: [PATCH 36/50] remove delay detector --- Cargo.lock | 1 - runtime/near-vm-runner/Cargo.toml | 1 - runtime/near-vm-runner/src/cache.rs | 28 ++++++++++---------- runtime/near-vm-runner/src/wasmer1_runner.rs | 8 +++++- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84d59909891..5e5b3b9bba0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3731,7 +3731,6 @@ dependencies = [ "bencher", "borsh", "cached", - "delay-detector", "log", "near-evm-runner", "near-primitives", diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index 7cd67351ef2..0eaf6acf7e3 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -30,7 +30,6 @@ near-primitives = { path = "../../core/primitives" } log = "0.4" near-evm-runner = { path = "../near-evm-runner", version = "2.3.0", optional = true} cached = "0.12.0" -delay-detector = { path = "../../tools/delay_detector" } [dev-dependencies] assert_matches = "1.3" diff --git a/runtime/near-vm-runner/src/cache.rs b/runtime/near-vm-runner/src/cache.rs index b1ff2efed30..5c8a9459f09 100644 --- a/runtime/near-vm-runner/src/cache.rs +++ b/runtime/near-vm-runner/src/cache.rs @@ -12,7 +12,6 @@ use std::convert::TryFrom; use wasmer_runtime::{compiler_for_backend, Backend}; use wasmer_runtime_core::cache::Artifact; use wasmer_runtime_core::load_cache_with; -use delay_detector::DelayDetector; pub(crate) fn compile_module( code: &[u8], @@ -163,7 +162,10 @@ pub(crate) fn compile_module_cached_wasmer1( } #[cfg(feature = "wasmer1_vm")] -fn compile_module_wasmer1(prepared_code: &[u8], store: &wasmer::Store) -> Result { +fn compile_module_wasmer1( + prepared_code: &[u8], + store: &wasmer::Store, +) -> Result { wasmer::Module::new(&store, prepared_code).map_err(|err| err.into_vm_error()) } @@ -174,32 +176,30 @@ pub(crate) fn compile_and_serialize_wasmer1( cache: &dyn CompiledContractCache, store: &wasmer::Store, ) -> Result { - let mut d = DelayDetector::new("enter compile_and_serialize_wasmer1".into()); - let module = compile_module_wasmer1(wasm_code, store).map_err(|e| cache_error(e, &key, cache))?; - let code = module.serialize().map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; + let module = + compile_module_wasmer1(wasm_code, store).map_err(|e| cache_error(e, &key, cache))?; + let code = module + .serialize() + .map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; let serialized = CacheRecord::Code(code).try_to_vec().unwrap(); cache.put(key.as_ref(), &serialized).map_err(|_e| VMError::CacheError(WriteError))?; - d.snapshot("finish compile_and_serialize_wasmer1"); Ok(module) } #[cfg(feature = "wasmer1_vm")] fn deserialize_wasmer1( serialized: &[u8], - store: &wasmer::Store + store: &wasmer::Store, ) -> Result, CacheError> { - let mut d = DelayDetector::new("enter deserialize_wasmer1".into()); let record = CacheRecord::try_from_slice(serialized).map_err(|_e| DeserializationError)?; let serialized_module = match record { CacheRecord::Error(err) => return Ok(Err(err)), CacheRecord::Code(code) => code, }; - let r = unsafe { + unsafe { Ok(Ok(wasmer::Module::deserialize(store, serialized_module.as_slice()) .map_err(|_e| CacheError::DeserializationError)?)) - }; - d.snapshot("leave deserialize_wasmer1"); - r + } } #[cfg(feature = "wasmer1_vm")] @@ -207,7 +207,7 @@ fn compile_module_cached_wasmer1_impl( key: CryptoHash, wasm_code: &[u8], cache: Option<&dyn CompiledContractCache>, - store: &wasmer::Store + store: &wasmer::Store, ) -> Result { if cache.is_none() { return compile_module_wasmer1(wasm_code, store); @@ -223,4 +223,4 @@ fn compile_module_cached_wasmer1_impl( }, Err(_) => Err(VMError::CacheError(ReadError)), } -} \ No newline at end of file +} diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index ce10008120a..cf1e879416d 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -178,7 +178,13 @@ pub fn run_wasmer1<'a>( Ok(code) => code, Err(e) => return (None, Some(e.into())), }; - let module = match cache::compile_module_cached_wasmer1(&code_hash, &prepared_code, wasm_config, cache, &store) { + let module = match cache::compile_module_cached_wasmer1( + &code_hash, + &prepared_code, + wasm_config, + cache, + &store, + ) { Ok(x) => x, Err(err) => return (None, Some(err)), }; From df0b5bfd563bbe344abe19bd120e4f44ff0b6632 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 4 Feb 2021 17:17:50 -0800 Subject: [PATCH 37/50] fix feature set for ci --- Cargo.toml | 5 +++++ runtime/runtime/Cargo.toml | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index df4a907806b..83c1c54dced 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,7 +116,12 @@ delay_detector = ["neard/delay_detector"] rosetta_rpc = ["neard/rosetta_rpc"] protocol_feature_forward_chunk_parts = ["neard/protocol_feature_forward_chunk_parts"] nightly_protocol = ["near-primitives/nightly_protocol", "near-jsonrpc/nightly_protocol"] +# enable this to build neard with wasmer 1.0 runner wasmer1_default = ["node-runtime/wasmer1_default"] +# enable these two to run runtime tests with wasmer 1.0 and wasmtime vm enabled +# but neard would still use wasmer 0.x runner +wasmer1_vm = ["node-runtime/wasmer1_vm"] +wasmtime_vm = ["node-runtime/wasmtime_vm"] nightly_protocol_features = ["nightly_protocol", "neard/nightly_protocol_features", "protocol_feature_evm", "protocol_feature_block_header_v3"] protocol_feature_evm = ["neard/protocol_feature_evm", "testlib/protocol_feature_evm", "runtime-params-estimator/protocol_feature_evm"] protocol_feature_block_header_v3 = ["near-primitives/protocol_feature_block_header_v3", "near-chain/protocol_feature_block_header_v3", "neard/protocol_feature_block_header_v3"] diff --git a/runtime/runtime/Cargo.toml b/runtime/runtime/Cargo.toml index 6ec3d0ad1a9..30188657da4 100644 --- a/runtime/runtime/Cargo.toml +++ b/runtime/runtime/Cargo.toml @@ -36,7 +36,9 @@ near-evm-runner = { path = "../../runtime/near-evm-runner", optional = true } default = [] dump_errors_schema = ["near-vm-errors/dump_errors_schema"] protocol_feature_evm = ["near-evm-runner/protocol_feature_evm", "near-primitives/protocol_feature_evm", "near-runtime-fees/protocol_feature_evm", "near-vm-runner/protocol_feature_evm"] -wasmer1_default = ["near-vm-runner/wasmer1_vm", "near-vm-logic/wasmer1_default"] +wasmer1_vm = ["near-vm-runner/wasmer1_vm"] +wasmtime_vm = ["near-vm-runner/wasmtime_vm"] +wasmer1_default = ["wasmer1_vm", "near-vm-logic/wasmer1_default"] # Use this feature to enable counting of fees and costs applied. costs_counting = ["near-vm-logic/costs_counting", "near-vm-runner/costs_counting"] From 1848478b24d731a0163997b57c1505f4164244e3 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 4 Feb 2021 17:25:47 -0800 Subject: [PATCH 38/50] use fork released wasmer --- Cargo.lock | 191 ++++++++++++++++-------------- runtime/near-vm-runner/Cargo.toml | 6 +- 2 files changed, 104 insertions(+), 93 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e5b3b9bba0..4db667347b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3740,11 +3740,11 @@ dependencies = [ "parity-wasm", "pwasm-utils", "wabt", - "wasmer", - "wasmer-compiler-singlepass", + "wasmer-compiler-singlepass-near", + "wasmer-near", "wasmer-runtime-core-near", "wasmer-runtime-near", - "wasmer-types", + "wasmer-types-near", "wasmtime", ] @@ -6396,31 +6396,29 @@ dependencies = [ ] [[package]] -name = "wasmer" +name = "wasmer-compiler-cranelift-near" version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de6b657ad3ede318777e0dfe82be83b098e7be7d82c9e4a00cc10bd5503e016" dependencies = [ - "cfg-if 0.1.10", - "indexmap", + "cranelift-codegen 0.68.0", + "cranelift-frontend 0.68.0", + "gimli 0.22.0", "more-asserts", - "target-lexicon 0.11.1", - "thiserror", - "wasmer-compiler", - "wasmer-compiler-cranelift", - "wasmer-derive", - "wasmer-engine", - "wasmer-engine-jit", - "wasmer-engine-native", - "wasmer-types", - "wasmer-vm", - "wat", - "winapi 0.3.9", + "rayon", + "serde", + "smallvec 1.6.1", + "tracing", + "wasmer-compiler-near", + "wasmer-types-near", + "wasmer-vm-near", ] [[package]] -name = "wasmer-compiler" +name = "wasmer-compiler-near" version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c001e01ea85a43cc2ebeb709596622ee8c97fed68605027a86b4b4a15098e0a" dependencies = [ "raw-cpuid", "serde", @@ -6428,34 +6426,17 @@ dependencies = [ "smallvec 1.6.1", "target-lexicon 0.11.1", "thiserror", - "wasmer-types", - "wasmer-vm", + "wasmer-types-near", + "wasmer-vm-near", "wasmer_enumset", "wasmparser 0.65.0", ] [[package]] -name = "wasmer-compiler-cranelift" -version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" -dependencies = [ - "cranelift-codegen 0.68.0", - "cranelift-frontend 0.68.0", - "gimli 0.22.0", - "more-asserts", - "rayon", - "serde", - "smallvec 1.6.1", - "tracing", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-compiler-singlepass" +name = "wasmer-compiler-singlepass-near" version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ca932f5f20d9eebeec519b7a9e7ec5d49197405bb9a3f0c13f2ce2cba7cbd6" dependencies = [ "byteorder", "dynasm 1.0.0", @@ -6465,15 +6446,16 @@ dependencies = [ "rayon", "serde", "smallvec 1.6.1", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", + "wasmer-compiler-near", + "wasmer-types-near", + "wasmer-vm-near", ] [[package]] -name = "wasmer-derive" +name = "wasmer-derive-near" version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5c253a3c8836848b12e251395afa1bb156a70cf19dd6603b69ec9f922a891a" dependencies = [ "proc-macro-error", "proc-macro2 1.0.24", @@ -6482,46 +6464,28 @@ dependencies = [ ] [[package]] -name = "wasmer-engine" +name = "wasmer-engine-jit-near" version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" -dependencies = [ - "backtrace", - "bincode", - "lazy_static", - "memmap2", - "more-asserts", - "rustc-demangle", - "serde", - "serde_bytes", - "target-lexicon 0.11.1", - "thiserror", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-engine-jit" -version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f5c2d5544188afce627f7e8a8e9b542bbd8ffe98ee2a6a33d2f21c9e7f16f2a" dependencies = [ "bincode", "cfg-if 0.1.10", "region", "serde", "serde_bytes", - "wasmer-compiler", - "wasmer-engine", - "wasmer-types", - "wasmer-vm", + "wasmer-compiler-near", + "wasmer-engine-near", + "wasmer-types-near", + "wasmer-vm-near", "winapi 0.3.9", ] [[package]] -name = "wasmer-engine-native" +name = "wasmer-engine-native-near" version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d30ff20935a3337937838a919e6c98c9ea206ba1c43680d426092c06ceb3a7d" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -6530,23 +6494,68 @@ dependencies = [ "serde", "tempfile", "tracing", - "wasmer-compiler", - "wasmer-engine", - "wasmer-object", - "wasmer-types", - "wasmer-vm", + "wasmer-compiler-near", + "wasmer-engine-near", + "wasmer-object-near", + "wasmer-types-near", + "wasmer-vm-near", "which 4.0.2", ] [[package]] -name = "wasmer-object" +name = "wasmer-engine-near" version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22f523e2b3b25ce7fdabc6285fee718921a5ebad1ae4ce5653fe5423962fb952" +dependencies = [ + "backtrace", + "bincode", + "lazy_static", + "memmap2", + "more-asserts", + "rustc-demangle", + "serde", + "serde_bytes", + "target-lexicon 0.11.1", + "thiserror", + "wasmer-compiler-near", + "wasmer-types-near", + "wasmer-vm-near", +] + +[[package]] +name = "wasmer-near" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc66f9e8eab70dc797e2c1eaf2688745be9315e55ee6aa49b3e1a174cec32e6" +dependencies = [ + "cfg-if 0.1.10", + "indexmap", + "more-asserts", + "target-lexicon 0.11.1", + "thiserror", + "wasmer-compiler-cranelift-near", + "wasmer-compiler-near", + "wasmer-derive-near", + "wasmer-engine-jit-near", + "wasmer-engine-native-near", + "wasmer-engine-near", + "wasmer-types-near", + "wasmer-vm-near", + "wat", + "winapi 0.3.9", +] + +[[package]] +name = "wasmer-object-near" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "684cb3a6938d890bd30a48bed14cfd6ed49713cd11857ea0f17413857680167c" dependencies = [ "object 0.22.0", "thiserror", - "wasmer-compiler", - "wasmer-types", + "wasmer-compiler-near", + "wasmer-types-near", ] [[package]] @@ -6612,9 +6621,10 @@ dependencies = [ ] [[package]] -name = "wasmer-types" +name = "wasmer-types-near" version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9975bdb09799bdfa8a68c22de7229335644c93a6585cfeb560c67ab3e992cd60" dependencies = [ "cranelift-entity 0.68.0", "serde", @@ -6622,9 +6632,10 @@ dependencies = [ ] [[package]] -name = "wasmer-vm" +name = "wasmer-vm-near" version = "1.0.1" -source = "git+https://github.com/wasmerio/wasmer?rev=b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb#b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fffccc529aad5ae715eac4b57c12019b610eec4ffd80dd6c214b3bcc3fa7c89" dependencies = [ "backtrace", "cc", @@ -6636,7 +6647,7 @@ dependencies = [ "region", "serde", "thiserror", - "wasmer-types", + "wasmer-types-near", "winapi 0.3.9", ] diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index 0eaf6acf7e3..79c2f7cf016 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -16,9 +16,9 @@ This crate implements the specification of the interface that Near blockchain ex borsh = "0.7.1" wasmer-runtime = { version="0.17.1", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near" } wasmer-runtime-core = {version = "0.17.1", package = "wasmer-runtime-core-near" } -wasmer = { git = "https://github.com/wasmerio/wasmer", rev="b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb", optional = true } -wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev="b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb", optional = true } -wasmer-compiler-singlepass = { git = "https://github.com/wasmerio/wasmer", rev="b4d2d8ee804a45850af2b3e012fdbbbdcb1185cb", optional = true } +wasmer = { version = "1.0.1", package = "wasmer-near", optional = true } +wasmer-types = { version = "1.0.1", package = "wasmer-types-near", optional = true } +wasmer-compiler-singlepass = { version = "1.0.1", package = "wasmer-compiler-singlepass-near", optional = true } pwasm-utils = "0.12" parity-wasm = "0.41" wasmtime = { version = "0.20.0", default-features = false, optional = true } From 6f32f4e20546e1adca37871b9bf5b80421e20584 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Thu, 4 Feb 2021 17:36:22 -0800 Subject: [PATCH 39/50] resolve conflict in Cargo.lock --- Cargo.lock | 848 ++++++++++++++++++++++++++--------------------------- 1 file changed, 415 insertions(+), 433 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 98e56b57623..07f8f866317 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ dependencies = [ "actix-rt", "actix_derive", "bitflags", - "bytes 1.0.1", + "bytes", "crossbeam-channel", "derive_more", "futures-core", @@ -34,7 +34,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90673465c6187bd0829116b02be465dc0195a74d7719f76ffff0effef934a92e" dependencies = [ "bitflags", - "bytes 1.0.1", + "bytes", "futures-core", "futures-sink", "log", @@ -71,8 +71,8 @@ dependencies = [ "base64 0.13.0", "bitflags", "brotli2", - "bytes 1.0.1", - "bytestring 1.0.0", + "bytes", + "bytestring", "cookie", "copyless", "derive_more", @@ -93,7 +93,7 @@ dependencies = [ "log", "mime", "percent-encoding", - "pin-project 1.0.2", + "pin-project 1.0.5", "rand 0.8.3", "regex", "serde", @@ -110,8 +110,8 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ca8ce00b267af8ccebbd647de0d61e0674b6e61185cc7a592ff88772bed655" dependencies = [ - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -120,17 +120,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbcb2b608f0accc2f5bcf3dd872194ce13d94ee45b571487035864cf966b04ef" dependencies = [ - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "actix-router" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd1f7dbda1645bf7da33554db60891755f6c01c1b2169e2f4c492098d30c235" +checksum = "b8be584b3b6c705a18eabc11c4059cf83b255bdd8511673d1d569f4ce40c69de" dependencies = [ - "bytestring 0.1.5", + "bytestring", "http", "log", "regex", @@ -167,9 +167,9 @@ dependencies = [ [[package]] name = "actix-service" -version = "2.0.0-beta.4" +version = "2.0.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca9756f4d32984ac454ae3155a276f6be69b424197bd3f0ca3c87cde72f41d63" +checksum = "6659eb09fcd1e57104269682c78d31965f3a087437e140c2ecbb3cd47042d671" dependencies = [ "futures-core", "pin-project-lite", @@ -245,7 +245,7 @@ dependencies = [ "actix-web-codegen", "ahash 0.6.3", "awc", - "bytes 1.0.1", + "bytes", "derive_more", "encoding_rs", "futures-core", @@ -253,7 +253,7 @@ dependencies = [ "log", "mime", "openssl", - "pin-project 1.0.2", + "pin-project 1.0.5", "regex", "serde", "serde_json", @@ -271,8 +271,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad26f77093333e0e7c6ffe54ebe3582d908a104e448723eec6d43d08b07143fb" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -282,15 +282,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b95aceadaf327f18f0df5962fedc1bde2f870566a0b9f65c89508a3b1f79334c" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "addr2line" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ "gimli 0.23.0", ] @@ -347,9 +347,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.35" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0df63cb2955042487fad3aefd2c6e3ae7389ac5dc1beb28921de0b69f779d4" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" [[package]] name = "arr_macro" @@ -368,8 +368,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0609c78bd572f4edc74310dfb63a01f5609d53fa8b4dd7c4d98aef3b3e8d72d1" dependencies = [ "proc-macro-hack", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -406,8 +406,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -444,7 +444,7 @@ dependencies = [ "actix-rt", "actix-service", "base64 0.13.0", - "bytes 1.0.1", + "bytes", "cfg-if 1.0.0", "derive_more", "futures-core", @@ -460,15 +460,15 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ "addr2line", "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.22.0", + "object 0.23.0", "rustc-demangle", ] @@ -523,7 +523,7 @@ dependencies = [ "log", "peeking_take_while", "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "regex", "rustc-hash", "shlex", @@ -670,7 +670,7 @@ dependencies = [ "borsh-schema-derive-internal", "proc-macro-crate", "proc-macro2 1.0.24", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -680,8 +680,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d813fa25eb0bed78c36492cff4415f38c760d6de833d255ba9095bd8ebb7d725" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -691,8 +691,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf78ee4a98c8cb9eba1bac3d3e2a1ea3d7673c719ce691e67b5cbafc472d3b7" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -735,9 +735,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" [[package]] name = "byte-slice-cast" @@ -753,15 +753,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.5.6" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "bytes" @@ -769,22 +763,13 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" -[[package]] -name = "bytestring" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7c05fa5172da78a62d9949d662d2ac89d4cc7355d7b49adee5163f1fb3f363" -dependencies = [ - "bytes 0.5.6", -] - [[package]] name = "bytestring" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" dependencies = [ - "bytes 1.0.1", + "bytes", ] [[package]] @@ -821,8 +806,8 @@ dependencies = [ "async-mutex", "cached_proc_macro_types", "darling", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -898,7 +883,7 @@ dependencies = [ "num-integer", "num-traits", "serde", - "time 0.1.44", + "time 0.1.43", "winapi", ] @@ -965,8 +950,8 @@ dependencies = [ "heck", "proc-macro-error", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -995,23 +980,9 @@ checksum = "2ae45936bbf9bddd6a0268c0ea5d3814a72403f4b69a1c318aae2ce90444ad55" [[package]] name = "console" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0b1aacfaffdbff75be81c15a399b4bedf78aaefe840e8af1d299ac2ade885d2" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "terminal_size", - "termios", - "winapi", -] - -[[package]] -name = "console" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50aab2529019abfabfa93f1e6c41ef392f91fbf179b347a7e96abb524884a08" +checksum = "7cc80946b3480f421c2f17ed1cb841753a371c7c5104f51d507e13f532c856aa" dependencies = [ "encode_unicode", "lazy_static", @@ -1020,14 +991,13 @@ dependencies = [ "terminal_size", "unicode-width", "winapi", - "winapi-util", ] [[package]] name = "const_fn" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" [[package]] name = "constant_time_eq" @@ -1242,16 +1212,16 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70daa7ceec6cf143990669a04c7df13391d55fb27bd4079d252fca774ba244d8" +checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" dependencies = [ "atty", "cast", "clap 2.33.3", "criterion-plot", "csv", - "itertools 0.9.0", + "itertools 0.10.0", "lazy_static", "num-traits", "oorandom", @@ -1345,7 +1315,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.4", - "subtle 2.3.0", + "subtle 2.4.0", ] [[package]] @@ -1372,14 +1342,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.0.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8492de420e9e60bc9a1d66e2dbb91825390b738a388606600663fc529b4b307" +checksum = "f627126b946c25a4638eec0ea634fc52506dea98db118aae985118ce7c3d723f" dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", - "subtle 2.3.0", + "subtle 2.4.0", "zeroize", ] @@ -1402,9 +1372,9 @@ dependencies = [ "fnv", "ident_case", "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "strsim 0.9.3", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -1414,8 +1384,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -1433,13 +1403,13 @@ dependencies = [ [[package]] name = "derivative" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -1449,27 +1419,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "derive_utils" -version = "0.11.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64196eb9f551916167225134f1e8a90f0b5774331d3c900d6328fd94bafe3544" +checksum = "532b4c15dccee12c7044f1fcad956e98410860b22231e44a3b827464797ca7bf" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] -[[package]] -name = "difference" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" - [[package]] name = "digest" version = "0.8.1" @@ -1522,9 +1486,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dtoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" +checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" [[package]] name = "dynasm" @@ -1537,23 +1501,23 @@ dependencies = [ "lazy_static", "owning_ref", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "dynasm" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62a59fbab09460c1569eeea9b5e4cf62f13f5198b1c2ba0e5196dd7fdd17cd42" +checksum = "3d7d1242462849390bb2ad38aeed769499f1afc7383affa2ab0c1baa894c0200" dependencies = [ "bitflags", "byteorder", "lazy_static", "proc-macro-error", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -1568,23 +1532,23 @@ dependencies = [ [[package]] name = "dynasmrt" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bec3edae2841d37b1c3dc7f3fd403c9061f26e9ffeeee97a3ea909b1bb2ef1" +checksum = "c1dd4d1d5ca12258cef339a57a7643e8b233a42dea9bb849630ddd9dd7726aa9" dependencies = [ "byteorder", - "dynasm 1.0.0", - "memmap", + "dynasm 1.0.1", + "memmap2", ] [[package]] name = "easy-ext" -version = "0.2.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73bb6373ab18cda357d060e1cc36ca2f3fc2783a81b033087a55ac2829cfa737" +checksum = "80581ee1c96b68c603eee514af47f075b39829304bde1a04381c826f3e06a9b4" dependencies = [ - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -1606,7 +1570,7 @@ dependencies = [ "ed25519", "rand 0.7.3", "serde", - "sha2 0.9.2", + "sha2 0.9.3", "zeroize", ] @@ -1648,8 +1612,8 @@ checksum = "7c5f0096a91d210159eceb2ff5e1c4da18388a170e1e3ce948aac9c8fdbbf595" dependencies = [ "heck", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -1659,8 +1623,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f52288f9a7ebb08959188872b58e7eaa12af9cb47da8e94158e16da7e143340" dependencies = [ "num-traits", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -1742,8 +1706,8 @@ dependencies = [ "ethabi", "heck", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -1838,8 +1802,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", "synstructure", ] @@ -1869,9 +1833,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" dependencies = [ "cfg-if 1.0.0", "crc32fast", @@ -1924,9 +1888,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0" +checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" dependencies = [ "futures-channel", "futures-core", @@ -1939,9 +1903,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" +checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" dependencies = [ "futures-core", "futures-sink", @@ -1949,15 +1913,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" +checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" [[package]] name = "futures-executor" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65" +checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" dependencies = [ "futures-core", "futures-task", @@ -1966,42 +1930,42 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb" +checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" [[package]] name = "futures-macro" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" +checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" dependencies = [ "proc-macro-hack", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "futures-sink" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" +checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" [[package]] name = "futures-task" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" +checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" dependencies = [ "once_cell", ] [[package]] name = "futures-util" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" +checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" dependencies = [ "futures-channel", "futures-core", @@ -2010,7 +1974,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project 1.0.2", + "pin-project-lite", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -2032,19 +1996,6 @@ version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -[[package]] -name = "generator" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cdc09201b2e8ca1b19290cf7e65de2246b8e91fb6874279722189c4de7b94dc" -dependencies = [ - "cc", - "libc", - "log", - "rustc_version", - "winapi", -] - [[package]] name = "generic-array" version = "0.12.3" @@ -2108,11 +2059,11 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -2125,7 +2076,7 @@ checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -2174,8 +2125,8 @@ checksum = "34a97a52fdee1870a34fa6e4b77570cba531b27d1838874fef4429a791a3d657" dependencies = [ "proc-macro-hack", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -2205,7 +2156,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" dependencies = [ - "bytes 1.0.1", + "bytes", "fnv", "futures-core", "futures-sink", @@ -2221,9 +2172,9 @@ dependencies = [ [[package]] name = "half" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177" +checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" [[package]] name = "hash-db" @@ -2251,18 +2202,18 @@ dependencies = [ [[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.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] @@ -2330,7 +2281,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" dependencies = [ - "bytes 1.0.1", + "bytes", "fnv", "itoa", ] @@ -2341,15 +2292,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" dependencies = [ - "bytes 1.0.1", + "bytes", "http", ] [[package]] name = "httparse" -version = "1.3.4" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "615caabe2c3160b313d52ccc905335f4ed5f10881dd63dc5699d47e90be85691" [[package]] name = "httpdate" @@ -2378,7 +2329,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe" dependencies = [ - "bytes 1.0.1", + "bytes", "futures-channel", "futures-core", "futures-util", @@ -2388,7 +2339,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project 1.0.2", + "pin-project 1.0.5", "socket2", "tokio", "tower-service", @@ -2417,7 +2368,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes 1.0.1", + "bytes", "hyper", "native-tls", "tokio", @@ -2481,8 +2432,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f65a8ecf74feeacdab8d38cb129e550ca871cccaa7d1921d8636ecd75534903" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -2501,9 +2452,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ "autocfg 1.0.1", "hashbrown", @@ -2516,7 +2467,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8572bccfb0665e70b7faf44ee28841b8e0823450cd4ad562a76b5a3c4bf48487" dependencies = [ - "console 0.13.0", + "console", "lazy_static", "number_prefix", "rayon", @@ -2529,7 +2480,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7baab56125e25686df467fe470785512329883aab42696d661247aca2a2896e4" dependencies = [ - "console 0.13.0", + "console", "lazy_static", "number_prefix", "regex", @@ -2537,16 +2488,17 @@ dependencies = [ [[package]] name = "insta" -version = "1.3.0" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "863bf97e7130bf788f29a99bc4073735af6b8ecc3da6a39c23b3a688d2d3109a" +checksum = "f62fca340815e6190f0ab60fd2729d297a55bcf9863025e5a8a4ce68f50066c4" dependencies = [ - "console 0.12.0", - "difference", + "console", "lazy_static", "serde", "serde_json", "serde_yaml", + "similar", + "uuid", ] [[package]] @@ -2578,13 +2530,13 @@ checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" [[package]] name = "iter-enum" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86a94bc12a53bf84b705acee29eb8697a5ea7b4587d836152499e5db0a6d52b9" +checksum = "cad34f24d3b48ceffdff38af2df5ce1b7d1d9cc113e503d8e86fe8cdb889c871" dependencies = [ "derive_utils", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -2616,9 +2568,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "jemalloc-sys" @@ -2652,9 +2604,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" dependencies = [ "wasm-bindgen", ] @@ -2709,7 +2661,7 @@ checksum = "4c942ea960c2d8678d32cb14aa56d5c37f21107b54aa281c944e4d03690c55d1" dependencies = [ "lazy_static", "slash-formatter", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -2735,9 +2687,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.81" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" +checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" [[package]] name = "libloading" @@ -2751,9 +2703,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9367bdfa836b7e3cf895867f7a570283444da90562980ec2263d6e1569b16bc" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ "cfg-if 1.0.0", "winapi", @@ -2782,7 +2734,7 @@ dependencies = [ "hmac-drbg", "rand 0.7.3", "sha2 0.8.2", - "subtle 2.3.0", + "subtle 2.4.0", "typenum", ] @@ -2810,9 +2762,9 @@ dependencies = [ [[package]] name = "linked-hash-map" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "loadtester" @@ -2861,11 +2813,11 @@ dependencies = [ [[package]] name = "log" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", ] [[package]] @@ -2891,24 +2843,11 @@ dependencies = [ "utf8-ranges", ] -[[package]] -name = "loom" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0e8460f2f2121162705187214720353c517b97bdfb3494c0b1e33d83ebe4bed" -dependencies = [ - "cfg-if 0.1.10", - "generator", - "scoped-tls", - "serde", - "serde_json", -] - [[package]] name = "lru" -version = "0.6.4" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe2382d8ed3918ea4ba70d98d5b74e47a168e0331965f3f17cdbc748bdebc5a3" +checksum = "3aae342b73d57ad0b8b364bd12584819f2c1fe9114285dfcf8b0722607671635" dependencies = [ "hashbrown", ] @@ -3060,9 +2999,9 @@ checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" [[package]] name = "native-tls" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fcc7939b5edc4e4f86b1b4a04bb1498afaaf871b1a6691838ed06fcb48d3a3f" +checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" dependencies = [ "lazy_static", "libc", @@ -3118,7 +3057,7 @@ dependencies = [ "num-rational", "serde", "serde_json", - "sha2 0.9.2", + "sha2 0.9.3", "smart-default", ] @@ -3230,8 +3169,8 @@ dependencies = [ "rand_core 0.5.1", "serde", "serde_json", - "sha2 0.9.2", - "subtle 2.3.0", + "sha2 0.9.3", + "subtle 2.4.0", "thiserror", ] @@ -3291,7 +3230,7 @@ dependencies = [ "rlp", "serde", "serde_json", - "sha2 0.9.2", + "sha2 0.9.3", "sha3", "vm", ] @@ -3406,7 +3345,7 @@ dependencies = [ "bencher", "borsh", "byteorder", - "bytes 1.0.1", + "bytes", "cached", "chrono", "delay-detector", @@ -3453,8 +3392,8 @@ dependencies = [ name = "near-performance-metrics-macros" version = "0.1.0" dependencies = [ - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -3492,7 +3431,7 @@ dependencies = [ "regex", "serde", "serde_json", - "sha2 0.9.2", + "sha2 0.9.3", "smart-default", "validator", ] @@ -3528,10 +3467,10 @@ name = "near-rpc-error-core" version = "0.1.0" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "serde", "serde_json", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -3540,10 +3479,10 @@ version = "0.1.0" dependencies = [ "near-rpc-error-core", "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "serde", "serde_json", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -3650,7 +3589,7 @@ dependencies = [ "num-rational", "serde", "serde_json", - "sha2 0.9.2", + "sha2 0.9.3", "sha3", ] @@ -3913,6 +3852,12 @@ dependencies = [ "indexmap", ] +[[package]] +name = "object" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" + [[package]] name = "once_cell" version = "1.5.2" @@ -3959,9 +3904,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-src" -version = "111.12.0+1.1.1h" +version = "111.13.0+1.1.1i" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "858a4132194f8570a7ee9eb8629e85b23cbc4565f2d4a162e87556e5956abf61" +checksum = "045e4dc48af57aad93d665885789b43222ae26f4886494da12d1ed58d309dcb6" dependencies = [ "cc", ] @@ -4017,7 +3962,7 @@ dependencies = [ "paperclip-core", "paperclip-macros", "parking_lot 0.11.1", - "semver 0.10.0", + "semver 0.11.0", "serde", "serde_derive", "serde_json", @@ -4051,7 +3996,7 @@ dependencies = [ "once_cell", "paperclip-macros", "parking_lot 0.11.1", - "pin-project 1.0.2", + "pin-project 1.0.5", "regex", "serde", "serde_json", @@ -4070,10 +4015,10 @@ dependencies = [ "mime", "proc-macro-error", "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "strum", "strum_macros", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -4131,7 +4076,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ "proc-macro2 1.0.24", - "syn 1.0.57", + "syn 1.0.60", "synstructure", ] @@ -4159,7 +4104,7 @@ checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", "lock_api 0.4.2", - "parking_lot_core 0.8.1", + "parking_lot_core 0.8.2", ] [[package]] @@ -4171,21 +4116,21 @@ dependencies = [ "cfg-if 0.1.10", "cloudabi", "libc", - "redox_syscall", + "redox_syscall 0.1.57", "smallvec", "winapi", ] [[package]] name = "parking_lot_core" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0" +checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall", + "redox_syscall 0.1.57", "smallvec", "winapi", ] @@ -4216,6 +4161,15 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "pin-project" version = "0.4.27" @@ -4227,11 +4181,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" +checksum = "96fa8ebb90271c4477f144354485b8068bd8f6b78b428b01ba892ca26caf0b63" dependencies = [ - "pin-project-internal 1.0.2", + "pin-project-internal 1.0.5", ] [[package]] @@ -4241,26 +4195,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "pin-project-internal" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" +checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "pin-project-lite" -version = "0.2.0" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" [[package]] name = "pin-utils" @@ -4285,16 +4239,32 @@ dependencies = [ [[package]] name = "plotters" -version = "0.2.15" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d1685fbe7beba33de0330629da9d955ac75bd54f33d7b79f9a895590124f6bb" +checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" dependencies = [ - "js-sys", "num-traits", + "plotters-backend", + "plotters-svg", "wasm-bindgen", "web-sys", ] +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" + +[[package]] +name = "plotters-svg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +dependencies = [ + "plotters-backend", +] + [[package]] name = "ppv-lite86" version = "0.2.10" @@ -4331,8 +4301,8 @@ checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", "version_check", ] @@ -4343,7 +4313,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "version_check", ] @@ -4355,9 +4325,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" @@ -4394,9 +4364,9 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.18.1" +version = "2.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da78e04bc0e40f36df43ecc6575e4f4b180e8156c4efd73f13d5619479b05696" +checksum = "86473d5f16580f10b131a0bf0afb68f8e029d1835d33a00f37281b05694e5312" [[package]] name = "pwasm-utils" @@ -4426,9 +4396,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ "proc-macro2 1.0.24", ] @@ -4463,7 +4433,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom 0.1.15", + "getrandom 0.1.16", "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", @@ -4533,7 +4503,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.15", + "getrandom 0.1.16", ] [[package]] @@ -4622,9 +4592,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", @@ -4662,14 +4632,23 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_syscall" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom 0.1.15", - "redox_syscall", + "getrandom 0.1.16", + "redox_syscall 0.1.57", "rust-argon2", ] @@ -4706,9 +4685,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", @@ -4728,9 +4707,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "region" @@ -4760,7 +4739,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd281b1030aa675fb90aa994d07187645bb3c8fc756ca766e7c3070b439de9de" dependencies = [ "base64 0.13.0", - "bytes 1.0.1", + "bytes", "encoding_rs", "futures-core", "futures-util", @@ -4818,9 +4797,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.19" +version = "0.16.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "024a1e66fea74c66c66624ee5622a7ff0e4b73a13b4f5c326ddb50c708944226" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ "cc", "libc", @@ -4848,7 +4827,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e54369147e3e7796c9b885c7304db87ca3d09a0a98f72843d532868675bbfba8" dependencies = [ - "bytes 1.0.1", + "bytes", "rustc-hex 2.1.0", ] @@ -4989,12 +4968,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scopeguard" version = "1.1.0" @@ -5040,16 +5013,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser", + "semver-parser 0.7.0", ] [[package]] name = "semver" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "394cec28fa623e00903caf7ba4fa6fb9a0e260280bb8cdbbba029611108a0190" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "semver-parser", + "semver-parser 0.10.2", ] [[package]] @@ -5058,11 +5031,20 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" -version = "1.0.118" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" dependencies = [ "serde_derive", ] @@ -5098,20 +5080,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.118" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "serde_json" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" dependencies = [ "indexmap", "itoa", @@ -5133,9 +5115,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.14" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7baae0a99f1a324984bcdc5f0718384c1f69775f1c7eec8b859b71b443e3fd7" +checksum = "bdd2af560da3c1fdc02cb80965289254fc35dff869810061e2d8290ee48848ae" dependencies = [ "dtoa", "linked-hash-map", @@ -5176,9 +5158,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" +checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", @@ -5201,12 +5183,11 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4921be914e16899a80adefb821f8ddb7974e3f1250223575a44ed994882127" +checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" dependencies = [ "lazy_static", - "loom", ] [[package]] @@ -5217,18 +5198,24 @@ checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" [[package]] name = "signal-hook-registry" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" dependencies = [ "libc", ] [[package]] name = "signature" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" +checksum = "0f0242b8e50dd9accdd56170e94ca1ebd223b098eb9c83539a6e367d0f36ae68" + +[[package]] +name = "similar" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c2c5334976f6000d0c36cf95a0b70ff4daa310b935aa4ce190d02f1012c81d0" [[package]] name = "slab" @@ -5258,19 +5245,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "socket2" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall", "winapi", ] @@ -5348,10 +5334,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "serde", "serde_derive", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -5362,12 +5348,12 @@ checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" dependencies = [ "base-x", "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "serde", "serde_derive", "serde_json", "sha1", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -5428,8 +5414,8 @@ checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149" dependencies = [ "heck", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -5440,9 +5426,9 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" @@ -5457,12 +5443,12 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.57" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4211ce9909eb971f111059df92c45640aad50a619cf55cd76476be803c4c68e6" +checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "unicode-xid 0.2.1", ] @@ -5473,8 +5459,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", "unicode-xid 0.2.1", ] @@ -5512,14 +5498,14 @@ checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" [[package]] name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "rand 0.7.3", - "redox_syscall", + "rand 0.8.3", + "redox_syscall 0.2.4", "remove_dir_all", "winapi", ] @@ -5535,23 +5521,14 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd2d183bd3fac5f5fe38ddbeb4dc9aec4a39a9d7d59e7491d900302da01cbe1" +checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406" dependencies = [ "libc", "winapi", ] -[[package]] -name = "termios" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" -dependencies = [ - "libc", -] - [[package]] name = "testlib" version = "0.1.0" @@ -5610,31 +5587,31 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "d8208a331e1cb318dd5bd76951d2b8fc48ca38a69f5f4e4af1b6a9f8c6236915" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -5648,12 +5625,11 @@ dependencies = [ [[package]] name = "time" -version = "0.1.44" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "wasi 0.10.0+wasi-snapshot-preview1", "winapi", ] @@ -5690,9 +5666,9 @@ checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" dependencies = [ "proc-macro-hack", "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "standback", - "syn 1.0.57", + "syn 1.0.60", ] [[package]] @@ -5716,9 +5692,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" dependencies = [ "tinyvec_macros", ] @@ -5736,7 +5712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6714d663090b6b0acb0fa85841c6d66233d150cdb2602c8f9b8abb03370beb3f" dependencies = [ "autocfg 1.0.1", - "bytes 1.0.1", + "bytes", "libc", "memchr", "mio", @@ -5756,8 +5732,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42517d2975ca3114b22a16192634e8241dc5cc1f130be194645970cc1c371494" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -5778,7 +5754,7 @@ checksum = "ac1bec5c0a4aa71e3459802c7a12e8912c2091ce2151004f9ce95cc5d1c6124e" dependencies = [ "futures", "openssl", - "pin-project 1.0.2", + "pin-project 1.0.5", "tokio", ] @@ -5810,7 +5786,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebb7cb2f00c5ae8df755b252306272cd1790d39728363936e01827e11f0b017b" dependencies = [ - "bytes 1.0.1", + "bytes", "futures-core", "futures-io", "futures-sink", @@ -5840,9 +5816,9 @@ dependencies = [ [[package]] name = "tower-service" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" @@ -5863,8 +5839,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -6013,6 +5989,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "uint" version = "0.9.0" @@ -6102,11 +6084,11 @@ checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" [[package]] name = "uuid" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "rand 0.7.3", + "getrandom 0.2.2", ] [[package]] @@ -6133,9 +6115,9 @@ checksum = "ad9680608df133af2c1ddd5eaf1ddce91d60d61b6bc51494ef326458365a470a" [[package]] name = "vcpkg" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" +checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" [[package]] name = "vec_map" @@ -6224,8 +6206,8 @@ checksum = "d7c2bb690b44cb1b0fdcc54d4998d21f8bdaf706b93775425e440b174f39ad16" dependencies = [ "heck", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -6246,15 +6228,15 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" dependencies = [ "cfg-if 1.0.0", "serde", @@ -6264,24 +6246,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" dependencies = [ "bumpalo", "lazy_static", "log", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe9756085a84584ee9457a002b7cdfe0bfff169f45d2591d8be1345a6780e35" +checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -6291,32 +6273,32 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" dependencies = [ - "quote 1.0.7", + "quote 1.0.8", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" +checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" [[package]] name = "wasmer-compiler-cranelift-near" @@ -6362,8 +6344,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73ca932f5f20d9eebeec519b7a9e7ec5d49197405bb9a3f0c13f2ce2cba7cbd6" dependencies = [ "byteorder", - "dynasm 1.0.0", - "dynasmrt 1.0.0", + "dynasm 1.0.1", + "dynasmrt 1.0.1", "lazy_static", "more-asserts", "rayon", @@ -6382,8 +6364,8 @@ checksum = "ef5c253a3c8836848b12e251395afa1bb156a70cf19dd6603b69ec9f922a891a" dependencies = [ "proc-macro-error", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -6413,7 +6395,7 @@ dependencies = [ "bincode", "cfg-if 0.1.10", "leb128", - "libloading 0.6.6", + "libloading 0.6.7", "serde", "tempfile", "tracing", @@ -6532,8 +6514,8 @@ checksum = "d3f23543ef8f59667be4945c22eb4b1a50a79ff340555f6f23354223d2695541" dependencies = [ "bincode", "byteorder", - "dynasm 1.0.0", - "dynasmrt 1.0.0", + "dynasm 1.0.1", + "dynasmrt 1.0.1", "lazy_static", "libc", "nix", @@ -6592,8 +6574,8 @@ checksum = "a8d1b32d98e11194200baf6d3f85eb2d6cfe56f6d9af0dd617f90ca48f958a88" dependencies = [ "darling", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -6792,27 +6774,27 @@ dependencies = [ [[package]] name = "wast" -version = "30.0.0" +version = "33.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b79907b22f740634810e882d8d1d9d0f9563095a8ab94e786e370242bff5cd2" +checksum = "1d04fe175c7f78214971293e7d8875673804e736092206a3a4544dbc12811c1b" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.31" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8279a02835bf12e61ed2b3c3cbc6ecf9918762fd97e036917c11a09ec20ca44" +checksum = "7ec9c6ee01ae07a26adadcdfed22c7a97e0b8cbee9c06e0e96076ece5aeb5cfe" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" dependencies = [ "js-sys", "wasm-bindgen", @@ -6919,18 +6901,18 @@ checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" [[package]] name = "yaml-rust" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ "linked-hash-map", ] [[package]] name = "zeroize" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f33972566adbd2d3588b0491eb94b98b43695c4ef897903470ede4f3f5a28a" +checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" dependencies = [ "zeroize_derive", ] @@ -6942,7 +6924,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.57", + "quote 1.0.8", + "syn 1.0.60", "synstructure", ] From bae0e08a7a9dc6bb90f9a6cfe07caccd1f8f4f88 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 5 Feb 2021 11:11:14 -0800 Subject: [PATCH 40/50] cargo deny --- deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deny.toml b/deny.toml index 5c9211824f6..6861b6e815c 100644 --- a/deny.toml +++ b/deny.toml @@ -140,6 +140,8 @@ skip = [ { name = "strsim", version = "=0.8.0" }, { name = "wasmparser", version = "=0.57.0" }, { name = "which", version = "=3.1.1" }, + { name = "object", version = "=0.23.0" }, + # hashbrown uses an older version { name = "ahash", version = "=0.4.7" }, ] From 7fc2454d004c82164c39a83f003be521b19f3d00 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 5 Feb 2021 11:18:12 -0800 Subject: [PATCH 41/50] wasmer 1.0.2 --- Cargo.lock | 248 +++++++++++++++--------------- runtime/near-vm-runner/Cargo.toml | 6 +- 2 files changed, 126 insertions(+), 128 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07f8f866317..3026b4b31af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1627,6 +1627,27 @@ dependencies = [ "syn 1.0.60", ] +[[package]] +name = "enumset" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e97cdfe38fa12fc11118af2979cc4c4b243d475e4daf691dcf5687d90efd28c" +dependencies = [ + "enumset_derive", +] + +[[package]] +name = "enumset_derive" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3946e239d2862f82f1d105d2193f8026c2c5215cc68b3cebd18c37c4c1b5035" +dependencies = [ + "darling", + "proc-macro2 1.0.24", + "quote 1.0.8", + "syn 1.0.60", +] + [[package]] name = "env_logger" version = "0.7.1" @@ -3611,11 +3632,11 @@ dependencies = [ "parity-wasm", "pwasm-utils", "wabt", - "wasmer-compiler-singlepass-near", - "wasmer-near", + "wasmer", + "wasmer-compiler-singlepass", "wasmer-runtime-core-near", "wasmer-runtime-near", - "wasmer-types-near", + "wasmer-types", "wasmtime", ] @@ -6301,47 +6322,69 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" [[package]] -name = "wasmer-compiler-cranelift-near" -version = "1.0.1" +name = "wasmer" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de6b657ad3ede318777e0dfe82be83b098e7be7d82c9e4a00cc10bd5503e016" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ - "cranelift-codegen 0.68.0", - "cranelift-frontend 0.68.0", - "gimli 0.22.0", + "cfg-if 0.1.10", + "indexmap", "more-asserts", - "rayon", - "serde", - "smallvec", - "tracing", - "wasmer-compiler-near", - "wasmer-types-near", - "wasmer-vm-near", + "target-lexicon 0.11.1", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-derive", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "wat", + "winapi", ] [[package]] -name = "wasmer-compiler-near" -version = "1.0.1" +name = "wasmer-compiler" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c001e01ea85a43cc2ebeb709596622ee8c97fed68605027a86b4b4a15098e0a" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ - "raw-cpuid", + "enumset", "serde", "serde_bytes", "smallvec", "target-lexicon 0.11.1", "thiserror", - "wasmer-types-near", - "wasmer-vm-near", - "wasmer_enumset", + "wasmer-types", + "wasmer-vm", "wasmparser 0.65.0", ] [[package]] -name = "wasmer-compiler-singlepass-near" -version = "1.0.1" +name = "wasmer-compiler-cranelift" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ca932f5f20d9eebeec519b7a9e7ec5d49197405bb9a3f0c13f2ce2cba7cbd6" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" +dependencies = [ + "cranelift-codegen 0.68.0", + "cranelift-frontend 0.68.0", + "gimli 0.22.0", + "more-asserts", + "rayon", + "serde", + "smallvec", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-compiler-singlepass" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm 1.0.1", @@ -6351,16 +6394,16 @@ dependencies = [ "rayon", "serde", "smallvec", - "wasmer-compiler-near", - "wasmer-types-near", - "wasmer-vm-near", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", ] [[package]] -name = "wasmer-derive-near" -version = "1.0.1" +name = "wasmer-derive" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5c253a3c8836848b12e251395afa1bb156a70cf19dd6603b69ec9f922a891a" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ "proc-macro-error", "proc-macro2 1.0.24", @@ -6369,28 +6412,49 @@ dependencies = [ ] [[package]] -name = "wasmer-engine-jit-near" -version = "1.0.1" +name = "wasmer-engine" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" +dependencies = [ + "backtrace", + "bincode", + "lazy_static", + "memmap2", + "more-asserts", + "rustc-demangle", + "serde", + "serde_bytes", + "target-lexicon 0.11.1", + "thiserror", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine-jit" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f5c2d5544188afce627f7e8a8e9b542bbd8ffe98ee2a6a33d2f21c9e7f16f2a" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ "bincode", "cfg-if 0.1.10", "region", "serde", "serde_bytes", - "wasmer-compiler-near", - "wasmer-engine-near", - "wasmer-types-near", - "wasmer-vm-near", + "wasmer-compiler", + "wasmer-engine", + "wasmer-types", + "wasmer-vm", "winapi", ] [[package]] -name = "wasmer-engine-native-near" -version = "1.0.1" +name = "wasmer-engine-native" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d30ff20935a3337937838a919e6c98c9ea206ba1c43680d426092c06ceb3a7d" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -6399,68 +6463,24 @@ dependencies = [ "serde", "tempfile", "tracing", - "wasmer-compiler-near", - "wasmer-engine-near", - "wasmer-object-near", - "wasmer-types-near", - "wasmer-vm-near", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-types", + "wasmer-vm", "which 4.0.2", ] [[package]] -name = "wasmer-engine-near" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22f523e2b3b25ce7fdabc6285fee718921a5ebad1ae4ce5653fe5423962fb952" -dependencies = [ - "backtrace", - "bincode", - "lazy_static", - "memmap2", - "more-asserts", - "rustc-demangle", - "serde", - "serde_bytes", - "target-lexicon 0.11.1", - "thiserror", - "wasmer-compiler-near", - "wasmer-types-near", - "wasmer-vm-near", -] - -[[package]] -name = "wasmer-near" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dc66f9e8eab70dc797e2c1eaf2688745be9315e55ee6aa49b3e1a174cec32e6" -dependencies = [ - "cfg-if 0.1.10", - "indexmap", - "more-asserts", - "target-lexicon 0.11.1", - "thiserror", - "wasmer-compiler-cranelift-near", - "wasmer-compiler-near", - "wasmer-derive-near", - "wasmer-engine-jit-near", - "wasmer-engine-native-near", - "wasmer-engine-near", - "wasmer-types-near", - "wasmer-vm-near", - "wat", - "winapi", -] - -[[package]] -name = "wasmer-object-near" -version = "1.0.1" +name = "wasmer-object" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684cb3a6938d890bd30a48bed14cfd6ed49713cd11857ea0f17413857680167c" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ "object 0.22.0", "thiserror", - "wasmer-compiler-near", - "wasmer-types-near", + "wasmer-compiler", + "wasmer-types", ] [[package]] @@ -6526,10 +6546,10 @@ dependencies = [ ] [[package]] -name = "wasmer-types-near" -version = "1.0.1" +name = "wasmer-types" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9975bdb09799bdfa8a68c22de7229335644c93a6585cfeb560c67ab3e992cd60" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ "cranelift-entity 0.68.0", "serde", @@ -6537,10 +6557,10 @@ dependencies = [ ] [[package]] -name = "wasmer-vm-near" -version = "1.0.1" +name = "wasmer-vm" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fffccc529aad5ae715eac4b57c12019b610eec4ffd80dd6c214b3bcc3fa7c89" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", @@ -6552,32 +6572,10 @@ dependencies = [ "region", "serde", "thiserror", - "wasmer-types-near", + "wasmer-types", "winapi", ] -[[package]] -name = "wasmer_enumset" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf088cc1f7d247fd96dff0df46fb1bbb747d8a69ae1ecd71aed55c55e354b2d8" -dependencies = [ - "num-traits", - "wasmer_enumset_derive", -] - -[[package]] -name = "wasmer_enumset_derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1b32d98e11194200baf6d3f85eb2d6cfe56f6d9af0dd617f90ca48f958a88" -dependencies = [ - "darling", - "proc-macro2 1.0.24", - "quote 1.0.8", - "syn 1.0.60", -] - [[package]] name = "wasmparser" version = "0.51.4" diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index b9f8ef9d7cb..72a2888e303 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -16,9 +16,9 @@ This crate implements the specification of the interface that Near blockchain ex borsh = "0.8.1" wasmer-runtime = { version="0.17.1", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near" } wasmer-runtime-core = {version = "0.17.1", package = "wasmer-runtime-core-near" } -wasmer = { version = "1.0.1", package = "wasmer-near", optional = true } -wasmer-types = { version = "1.0.1", package = "wasmer-types-near", optional = true } -wasmer-compiler-singlepass = { version = "1.0.1", package = "wasmer-compiler-singlepass-near", optional = true } +wasmer = { version = "1.0.2", optional = true } +wasmer-types = { version = "1.0.2", optional = true } +wasmer-compiler-singlepass = { version = "1.0.2", optional = true } pwasm-utils = "0.12" parity-wasm = "0.41" wasmtime = { version = "0.20.0", default-features = false, optional = true } From 9ca118e50f0a42fdbd30cdd5ae0aa83b8c97a415 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 12 Feb 2021 10:39:01 -0800 Subject: [PATCH 42/50] error into --- runtime/near-vm-errors/src/lib.rs | 13 +++++++++++++ runtime/near-vm-runner/src/errors.rs | 15 +-------------- runtime/near-vm-runner/src/wasmer1_runner.rs | 2 +- runtime/near-vm-runner/src/wasmer_runner.rs | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/runtime/near-vm-errors/src/lib.rs b/runtime/near-vm-errors/src/lib.rs index 75f3a26f220..eb182fbf47c 100644 --- a/runtime/near-vm-errors/src/lib.rs +++ b/runtime/near-vm-errors/src/lib.rs @@ -314,6 +314,19 @@ impl From for VMError { } } +impl From<&VMLogicError> for VMError { + fn from(err: &VMLogicError) -> Self { + match err { + VMLogicError::HostError(h) => { + VMError::FunctionCallError(FunctionCallError::HostError(h.clone())) + } + VMLogicError::ExternalError(s) => VMError::ExternalError(s.clone()), + VMLogicError::InconsistentStateError(e) => VMError::InconsistentStateError(e.clone()), + VMLogicError::EvmError(_) => unreachable!("Wasm can't return EVM error"), + } + } +} + impl fmt::Display for VMLogicError { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { write!(f, "{:?}", self) diff --git a/runtime/near-vm-runner/src/errors.rs b/runtime/near-vm-runner/src/errors.rs index fc138c2d6f1..97017b059ad 100644 --- a/runtime/near-vm-runner/src/errors.rs +++ b/runtime/near-vm-runner/src/errors.rs @@ -1,17 +1,4 @@ -use near_vm_errors::{FunctionCallError, VMError, VMLogicError}; +use near_vm_errors::{VMError}; pub trait IntoVMError { fn into_vm_error(self) -> VMError; } - -impl IntoVMError for &VMLogicError { - fn into_vm_error(self) -> VMError { - match self { - VMLogicError::HostError(h) => { - VMError::FunctionCallError(FunctionCallError::HostError(h.clone())) - } - VMLogicError::ExternalError(s) => VMError::ExternalError(s.clone()), - VMLogicError::InconsistentStateError(e) => VMError::InconsistentStateError(e.clone()), - VMLogicError::EvmError(_) => unreachable!("Wasm can't return EVM error"), - } - } -} diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index cf1e879416d..836873fcc2d 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -91,7 +91,7 @@ impl IntoVMError for wasmer::RuntimeError { let error_msg = self.message(); let trap_code = self.clone().to_trap(); match self.downcast::() { - Ok(e) => e.into_vm_error(), + Ok(e) => (&e).into(), _ => { if let Some(trap_code) = trap_code { // A trap diff --git a/runtime/near-vm-runner/src/wasmer_runner.rs b/runtime/near-vm-runner/src/wasmer_runner.rs index da5330dc9f0..7cda58288de 100644 --- a/runtime/near-vm-runner/src/wasmer_runner.rs +++ b/runtime/near-vm-runner/src/wasmer_runner.rs @@ -153,7 +153,7 @@ impl IntoVMError for wasmer_runtime::error::RuntimeError { } RuntimeError::User(data) => { if let Some(err) = data.downcast_ref::() { - err.into_vm_error() + err.into() } else { panic!( "Bad error case! Output is non-deterministic {:?} {:?}", From 56e3786ed1f7560d6d074715836bef961e367f3c Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 12 Feb 2021 10:40:02 -0800 Subject: [PATCH 43/50] typo --- runtime/near-vm-runner/src/runner.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/near-vm-runner/src/runner.rs b/runtime/near-vm-runner/src/runner.rs index 75feedd7e65..07dbe931462 100644 --- a/runtime/near-vm-runner/src/runner.rs +++ b/runtime/near-vm-runner/src/runner.rs @@ -272,7 +272,7 @@ pub fn compile_module(vm_kind: VMKind, code: &Vec) -> bool { compile_module(code) } #[cfg(not(feature = "wasmer1_vm"))] - VMKind::Wasmer1 => panic!("Wasmer1 is not supported, compile with '--features wasm1_vm'"), + VMKind::Wasmer1 => panic!("Wasmer1 is not supported, compile with '--features wasmer1_vm'"), }; false } From 51ffe38b5e08b080ab432d19cc6617181334748f Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 12 Feb 2021 10:54:14 -0800 Subject: [PATCH 44/50] precompile wasmer1 --- runtime/near-vm-runner/src/runner.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/runtime/near-vm-runner/src/runner.rs b/runtime/near-vm-runner/src/runner.rs index 07dbe931462..cf887d779f5 100644 --- a/runtime/near-vm-runner/src/runner.rs +++ b/runtime/near-vm-runner/src/runner.rs @@ -4,6 +4,7 @@ use near_runtime_fees::RuntimeFeesConfig; use near_vm_errors::{CompilationError, FunctionCallError, VMError}; use near_vm_logic::types::{ProfileData, PromiseResult, ProtocolVersion}; use near_vm_logic::{External, VMConfig, VMContext, VMKind, VMOutcome}; +use crate::cache::compile_and_serialize_wasmer1; /// `run` does the following: /// - deserializes and validate the `code` binary (see `prepare::prepare_contract`) @@ -227,11 +228,15 @@ pub fn precompile<'a>( let result = compile_and_serialize_wasmer(code, wasm_config, code_hash, cache); result.err() } - VMKind::Wasmer1 => Some(VMError::FunctionCallError(FunctionCallError::CompilationError( - CompilationError::UnsupportedCompiler { - msg: "Precompilation not supported in Wasmer 1.x yet".to_string(), - }, - ))), + #[cfg(feature = "wasmer1_vm")] + VMKind::Wasmer1 => { + let engine = wasmer::JIT::new(wasmer_compiler_singlepass::Singlepass::default()).engine(); + let store = wasmer::Store::new(&engine); + let result = compile_and_serialize_wasmer1(code, code_hash, cache, &store); + result.err() + } + #[cfg(not(feature = "wasmer1_vm"))] + VMKind::Wasmer1 => panic!("Wasmer1 is not supported, compile with '--features wasmer1_vm'"), VMKind::Wasmtime => Some(VMError::FunctionCallError(FunctionCallError::CompilationError( CompilationError::UnsupportedCompiler { msg: "Precompilation not supported in Wasmtime yet".to_string(), From cc338ff949dcde8f2308d1b2778ee4ec6f8ba9e0 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 12 Feb 2021 16:39:24 -0800 Subject: [PATCH 45/50] wasmer1 by default, optional wasmer 0 --- Cargo.toml | 8 +- runtime/near-vm-logic/Cargo.toml | 2 +- runtime/near-vm-logic/src/config.rs | 16 +- runtime/near-vm-runner/Cargo.toml | 4 +- runtime/near-vm-runner/src/cache.rs | 313 ++++++++++--------- runtime/near-vm-runner/src/imports.rs | 3 + runtime/near-vm-runner/src/lib.rs | 4 + runtime/near-vm-runner/src/runner.rs | 20 +- runtime/near-vm-runner/src/wasmer1_runner.rs | 4 +- runtime/near-vm-runner/src/wasmer_runner.rs | 2 +- runtime/runtime/Cargo.toml | 3 + 11 files changed, 206 insertions(+), 173 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c95d4540d5b..128b7ece7f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,10 +109,14 @@ rosetta_rpc = ["neard/rosetta_rpc"] protocol_feature_forward_chunk_parts = ["neard/protocol_feature_forward_chunk_parts"] nightly_protocol = ["near-primitives/nightly_protocol", "near-jsonrpc/nightly_protocol"] # enable this to build neard with wasmer 1.0 runner +# now if none of wasmer0_default, wasmer1_default or wasmtime_default is enabled, wasmer1 would be default wasmer1_default = ["node-runtime/wasmer1_default"] -# enable these two to run runtime tests with wasmer 1.0 and wasmtime vm enabled -# but neard would still use wasmer 0.x runner +wasmer0_default = ["node-runtime/wasmer0_default"] +wasmtime_default = ["node-runtime/wasmtime_default"] +# enable some of these to run runtime tests with wasmer 1.0, 0.x and wasmtime vm enabled +# but would not change default runner used by neard wasmer1_vm = ["node-runtime/wasmer1_vm"] +wasmer0_vm = ["node-runtime/wasmer0_vm"] wasmtime_vm = ["node-runtime/wasmtime_vm"] nightly_protocol_features = ["nightly_protocol", "neard/nightly_protocol_features", "protocol_feature_evm", "protocol_feature_block_header_v3"] protocol_feature_evm = ["neard/protocol_feature_evm", "testlib/protocol_feature_evm", "runtime-params-estimator/protocol_feature_evm"] diff --git a/runtime/near-vm-logic/Cargo.toml b/runtime/near-vm-logic/Cargo.toml index ee907726219..3cb03168025 100644 --- a/runtime/near-vm-logic/Cargo.toml +++ b/runtime/near-vm-logic/Cargo.toml @@ -32,7 +32,7 @@ serde_json = {version= "1", features= ["preserve_order"]} [features] default = ["costs_counting"] protocol_feature_evm = ["near-runtime-fees/protocol_feature_evm"] -wasmer_default = [] +wasmer0_default = [] wasmtime_default = [] wasmer1_default = [] diff --git a/runtime/near-vm-logic/src/config.rs b/runtime/near-vm-logic/src/config.rs index b42a51f211e..5012f4e2ba3 100644 --- a/runtime/near-vm-logic/src/config.rs +++ b/runtime/near-vm-logic/src/config.rs @@ -17,7 +17,7 @@ pub enum VMKind { impl Default for VMKind { #[cfg(all( - feature = "wasmer_default", + feature = "wasmer0_default", not(feature = "wasmer1_default"), not(feature = "wasmtime_default") ))] @@ -26,7 +26,7 @@ impl Default for VMKind { } #[cfg(all( - not(feature = "wasmer_default"), + not(feature = "wasmer0_default"), feature = "wasmer1_default", not(feature = "wasmtime_default") ))] @@ -35,7 +35,7 @@ impl Default for VMKind { } #[cfg(all( - not(feature = "wasmer_default"), + not(feature = "wasmer0_default"), not(feature = "wasmer1_default"), feature = "wasmtime_default" ))] @@ -44,22 +44,22 @@ impl Default for VMKind { } #[cfg(all( - not(feature = "wasmer_default"), + not(feature = "wasmer0_default"), not(feature = "wasmer1_default"), not(feature = "wasmtime_default") ))] fn default() -> Self { - VMKind::Wasmer0 + VMKind::Wasmer1 } - // These features should be mutually exclusive, but implement this to --all-features + // These features should be mutually exclusive, but implement this for cargo test --all-features #[cfg(all( - feature = "wasmer_default", + feature = "wasmer0_default", feature = "wasmer1_default", feature = "wasmtime_default" ))] fn default() -> Self { - VMKind::Wasmer0 + VMKind::Wasmer1 } } diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index 72a2888e303..1cbb3417e77 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -14,7 +14,8 @@ This crate implements the specification of the interface that Near blockchain ex [dependencies] borsh = "0.8.1" -wasmer-runtime = { version="0.17.1", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near" } +wasmer-runtime = { version="0.17.1", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near", optional = true } +# Always used even for wasmer 1.0 for validating wasm, will be replaced when refactor prepare.rs wasmer-runtime-core = {version = "0.17.1", package = "wasmer-runtime-core-near" } wasmer = { version = "1.0.2", optional = true } wasmer-types = { version = "1.0.2", optional = true } @@ -38,6 +39,7 @@ bencher = "^0.1.5" [features] default = [] +wasmer0_vm = [ "wasmer-runtime" ] wasmtime_vm = [ "wasmtime", "anyhow"] wasmer1_vm = [ "wasmer", "wasmer-types", "wasmer-compiler-singlepass" ] lightbeam = ["wasmtime/lightbeam"] diff --git a/runtime/near-vm-runner/src/cache.rs b/runtime/near-vm-runner/src/cache.rs index 5c8a9459f09..efee44a288e 100644 --- a/runtime/near-vm-runner/src/cache.rs +++ b/runtime/near-vm-runner/src/cache.rs @@ -9,17 +9,6 @@ use near_vm_errors::CacheError::{DeserializationError, ReadError, SerializationE use near_vm_errors::{CacheError, VMError}; use near_vm_logic::{VMConfig, VMKind}; use std::convert::TryFrom; -use wasmer_runtime::{compiler_for_backend, Backend}; -use wasmer_runtime_core::cache::Artifact; -use wasmer_runtime_core::load_cache_with; - -pub(crate) fn compile_module( - code: &[u8], - config: &VMConfig, -) -> Result { - let prepared_code = prepare::prepare_contract(code, config)?; - wasmer_runtime::compile(&prepared_code).map_err(|err| err.into_vm_error()) -} #[derive(Debug, Clone, BorshDeserialize, BorshSerialize)] enum ContractCacheKey { @@ -55,172 +44,188 @@ fn cache_error(error: VMError, key: &CryptoHash, cache: &dyn CompiledContractCac } } -pub(crate) fn compile_and_serialize_wasmer( - wasm_code: &[u8], - config: &VMConfig, - key: &CryptoHash, - cache: &dyn CompiledContractCache, -) -> Result { - let module = compile_module(wasm_code, config).map_err(|e| cache_error(e, &key, cache))?; - let artifact = - module.cache().map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; - let code = artifact - .serialize() - .map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; - let serialized = CacheRecord::Code(code).try_to_vec().unwrap(); - cache.put(key.as_ref(), &serialized).map_err(|_e| VMError::CacheError(WriteError))?; - Ok(module) -} +#[cfg(feature = "wasmer0_vm")] +pub mod wasmer0_cache { + use wasmer_runtime::{compiler_for_backend, Backend}; + use wasmer_runtime_core::cache::Artifact; + use wasmer_runtime_core::load_cache_with; + use super::*; -/// Deserializes contract or error from the binary data. Signature means that we could either -/// return module or cached error, which both considered to be `Ok()`, or encounter an error during -/// the deserialization process. -fn deserialize_wasmer( - serialized: &[u8], -) -> Result, CacheError> { - let record = CacheRecord::try_from_slice(serialized).map_err(|_e| DeserializationError)?; - let serialized_artifact = match record { - CacheRecord::Error(err) => return Ok(Err(err)), - CacheRecord::Code(code) => code, - }; - let artifact = Artifact::deserialize(serialized_artifact.as_slice()) - .map_err(|_e| CacheError::DeserializationError)?; - unsafe { - let compiler = compiler_for_backend(Backend::Singlepass).unwrap(); - match load_cache_with(artifact, compiler.as_ref()) { - Ok(module) => Ok(Ok(module)), - Err(_) => Err(CacheError::DeserializationError), - } + pub(crate) fn compile_module( + code: &[u8], + config: &VMConfig, + ) -> Result { + let prepared_code = prepare::prepare_contract(code, config)?; + wasmer_runtime::compile(&prepared_code).map_err(|err| err.into_vm_error()) } -} -fn compile_module_cached_wasmer_impl( - key: CryptoHash, - wasm_code: &[u8], - config: &VMConfig, - cache: Option<&dyn CompiledContractCache>, -) -> Result { - if cache.is_none() { - return compile_module(wasm_code, config); + pub(crate) fn compile_and_serialize_wasmer( + wasm_code: &[u8], + config: &VMConfig, + key: &CryptoHash, + cache: &dyn CompiledContractCache, + ) -> Result { + let module = compile_module(wasm_code, config).map_err(|e| cache_error(e, &key, cache))?; + let artifact = + module.cache().map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; + let code = artifact + .serialize() + .map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; + let serialized = CacheRecord::Code(code).try_to_vec().unwrap(); + cache.put(key.as_ref(), &serialized).map_err(|_e| VMError::CacheError(WriteError))?; + Ok(module) } - let cache = cache.unwrap(); - match cache.get(&(key.0).0) { - Ok(serialized) => match serialized { - Some(serialized) => { - deserialize_wasmer(serialized.as_slice()).map_err(VMError::CacheError)? + /// Deserializes contract or error from the binary data. Signature means that we could either + /// return module or cached error, which both considered to be `Ok()`, or encounter an error during + /// the deserialization process. + fn deserialize_wasmer( + serialized: &[u8], + ) -> Result, CacheError> { + let record = CacheRecord::try_from_slice(serialized).map_err(|_e| DeserializationError)?; + let serialized_artifact = match record { + CacheRecord::Error(err) => return Ok(Err(err)), + CacheRecord::Code(code) => code, + }; + let artifact = Artifact::deserialize(serialized_artifact.as_slice()) + .map_err(|_e| CacheError::DeserializationError)?; + unsafe { + let compiler = compiler_for_backend(Backend::Singlepass).unwrap(); + match load_cache_with(artifact, compiler.as_ref()) { + Ok(module) => Ok(Ok(module)), + Err(_) => Err(CacheError::DeserializationError), } - None => compile_and_serialize_wasmer(wasm_code, config, &key, cache), - }, - Err(_) => Err(VMError::CacheError(ReadError)), + } } -} - -#[cfg(not(feature = "no_cache"))] -const CACHE_SIZE: usize = 128; -#[cfg(not(feature = "no_cache"))] -cached_key! { - MODULES: SizedCache> - = SizedCache::with_size(CACHE_SIZE); - Key = { - key - }; - - fn memcache_compile_module_cached_wasmer( + fn compile_module_cached_wasmer_impl( key: CryptoHash, wasm_code: &[u8], config: &VMConfig, - cache: Option<&dyn CompiledContractCache>) -> Result = { - compile_module_cached_wasmer_impl(key, wasm_code, config, cache) + cache: Option<&dyn CompiledContractCache>, + ) -> Result { + if cache.is_none() { + return compile_module(wasm_code, config); + } + + let cache = cache.unwrap(); + match cache.get(&(key.0).0) { + Ok(serialized) => match serialized { + Some(serialized) => { + deserialize_wasmer(serialized.as_slice()).map_err(VMError::CacheError)? + } + None => compile_and_serialize_wasmer(wasm_code, config, &key, cache), + }, + Err(_) => Err(VMError::CacheError(ReadError)), + } } -} -pub(crate) fn compile_module_cached_wasmer( - wasm_code_hash: &[u8], - wasm_code: &[u8], - config: &VMConfig, - cache: Option<&dyn CompiledContractCache>, -) -> Result { - let key = get_key(wasm_code_hash, wasm_code, VMKind::Wasmer0, config); #[cfg(not(feature = "no_cache"))] - return memcache_compile_module_cached_wasmer(key, wasm_code, config, cache); - #[cfg(feature = "no_cache")] - return compile_module_cached_wasmer_impl(key, wasm_code, config, cache); -} + const CACHE_SIZE: usize = 128; -#[cfg(feature = "wasmer1_vm")] -pub(crate) fn compile_module_cached_wasmer1( - wasm_code_hash: &[u8], - wasm_code: &[u8], - config: &VMConfig, - cache: Option<&dyn CompiledContractCache>, - store: &wasmer::Store, -) -> Result { - let key = get_key(wasm_code_hash, wasm_code, VMKind::Wasmer1, config); - return compile_module_cached_wasmer1_impl(key, wasm_code, cache, store); -} + #[cfg(not(feature = "no_cache"))] + cached_key! { + MODULES: SizedCache> + = SizedCache::with_size(CACHE_SIZE); + Key = { + key + }; + + fn memcache_compile_module_cached_wasmer( + key: CryptoHash, + wasm_code: &[u8], + config: &VMConfig, + cache: Option<&dyn CompiledContractCache>) -> Result = { + compile_module_cached_wasmer_impl(key, wasm_code, config, cache) + } + } -#[cfg(feature = "wasmer1_vm")] -fn compile_module_wasmer1( - prepared_code: &[u8], - store: &wasmer::Store, -) -> Result { - wasmer::Module::new(&store, prepared_code).map_err(|err| err.into_vm_error()) + pub(crate) fn compile_module_cached_wasmer( + wasm_code_hash: &[u8], + wasm_code: &[u8], + config: &VMConfig, + cache: Option<&dyn CompiledContractCache>, + ) -> Result { + let key = get_key(wasm_code_hash, wasm_code, VMKind::Wasmer0, config); + #[cfg(not(feature = "no_cache"))] + return memcache_compile_module_cached_wasmer(key, wasm_code, config, cache); + #[cfg(feature = "no_cache")] + return compile_module_cached_wasmer_impl(key, wasm_code, config, cache); + } } #[cfg(feature = "wasmer1_vm")] -pub(crate) fn compile_and_serialize_wasmer1( - wasm_code: &[u8], - key: &CryptoHash, - cache: &dyn CompiledContractCache, - store: &wasmer::Store, -) -> Result { - let module = - compile_module_wasmer1(wasm_code, store).map_err(|e| cache_error(e, &key, cache))?; - let code = module - .serialize() - .map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; - let serialized = CacheRecord::Code(code).try_to_vec().unwrap(); - cache.put(key.as_ref(), &serialized).map_err(|_e| VMError::CacheError(WriteError))?; - Ok(module) -} +pub mod wasmer1_cache { + use super::*; -#[cfg(feature = "wasmer1_vm")] -fn deserialize_wasmer1( - serialized: &[u8], - store: &wasmer::Store, -) -> Result, CacheError> { - let record = CacheRecord::try_from_slice(serialized).map_err(|_e| DeserializationError)?; - let serialized_module = match record { - CacheRecord::Error(err) => return Ok(Err(err)), - CacheRecord::Code(code) => code, - }; - unsafe { - Ok(Ok(wasmer::Module::deserialize(store, serialized_module.as_slice()) - .map_err(|_e| CacheError::DeserializationError)?)) + pub(crate) fn compile_module_cached_wasmer1( + wasm_code_hash: &[u8], + wasm_code: &[u8], + config: &VMConfig, + cache: Option<&dyn CompiledContractCache>, + store: &wasmer::Store, + ) -> Result { + let key = get_key(wasm_code_hash, wasm_code, VMKind::Wasmer1, config); + return compile_module_cached_wasmer1_impl(key, wasm_code, cache, store); } -} -#[cfg(feature = "wasmer1_vm")] -fn compile_module_cached_wasmer1_impl( - key: CryptoHash, - wasm_code: &[u8], - cache: Option<&dyn CompiledContractCache>, - store: &wasmer::Store, -) -> Result { - if cache.is_none() { - return compile_module_wasmer1(wasm_code, store); + fn compile_module_wasmer1( + prepared_code: &[u8], + store: &wasmer::Store, + ) -> Result { + wasmer::Module::new(&store, prepared_code).map_err(|err| err.into_vm_error()) } - let cache = cache.unwrap(); - match cache.get(&(key.0).0) { - Ok(serialized) => match serialized { - Some(serialized) => { - deserialize_wasmer1(serialized.as_slice(), store).map_err(VMError::CacheError)? - } - None => compile_and_serialize_wasmer1(wasm_code, &key, cache, store), - }, - Err(_) => Err(VMError::CacheError(ReadError)), + pub(crate) fn compile_and_serialize_wasmer1( + wasm_code: &[u8], + key: &CryptoHash, + cache: &dyn CompiledContractCache, + store: &wasmer::Store, + ) -> Result { + let module = + compile_module_wasmer1(wasm_code, store).map_err(|e| cache_error(e, &key, cache))?; + let code = module + .serialize() + .map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; + let serialized = CacheRecord::Code(code).try_to_vec().unwrap(); + cache.put(key.as_ref(), &serialized).map_err(|_e| VMError::CacheError(WriteError))?; + Ok(module) + } + + fn deserialize_wasmer1( + serialized: &[u8], + store: &wasmer::Store, + ) -> Result, CacheError> { + let record = CacheRecord::try_from_slice(serialized).map_err(|_e| DeserializationError)?; + let serialized_module = match record { + CacheRecord::Error(err) => return Ok(Err(err)), + CacheRecord::Code(code) => code, + }; + unsafe { + Ok(Ok(wasmer::Module::deserialize(store, serialized_module.as_slice()) + .map_err(|_e| CacheError::DeserializationError)?)) + } + } + + fn compile_module_cached_wasmer1_impl( + key: CryptoHash, + wasm_code: &[u8], + cache: Option<&dyn CompiledContractCache>, + store: &wasmer::Store, + ) -> Result { + if cache.is_none() { + return compile_module_wasmer1(wasm_code, store); + } + + let cache = cache.unwrap(); + match cache.get(&(key.0).0) { + Ok(serialized) => match serialized { + Some(serialized) => { + deserialize_wasmer1(serialized.as_slice(), store).map_err(VMError::CacheError)? + } + None => compile_and_serialize_wasmer1(wasm_code, &key, cache, store), + }, + Err(_) => Err(VMError::CacheError(ReadError)), + } } } diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index e019bb1c556..5649fd2e69a 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -36,6 +36,7 @@ macro_rules! rust2wasm { macro_rules! wrapped_imports { ( $($(#[$feature_name:tt, $feature:ident])* $func:ident < [ $( $arg_name:ident : $arg_type:ident ),* ] -> [ $( $returns:ident ),* ] >, )* ) => { + #[cfg(feature = "wasmer0_vm")] pub mod wasmer_ext { use near_vm_logic::VMLogic; use wasmer_runtime::Ctx; @@ -58,6 +59,7 @@ macro_rules! wrapped_imports { type VMResult = ::std::result::Result; $( #[allow(unused_parens)] + $(#[cfg(feature = $feature_name)])* pub fn $func(env: &NearWasmerEnv, $( $arg_name: $arg_type ),* ) -> VMResult<($( $returns ),*)> { let logic: &mut VMLogic = unsafe { &mut *(env.logic.0 as *mut VMLogic<'_>) }; logic.$func( $( $arg_name, )* ) @@ -104,6 +106,7 @@ macro_rules! wrapped_imports { } #[allow(unused_variables)] + #[cfg(feature = "wasmer0_vm")] pub(crate) fn build_wasmer( memory: wasmer_runtime::memory::Memory, logic: &mut VMLogic<'_>, diff --git a/runtime/near-vm-runner/src/lib.rs b/runtime/near-vm-runner/src/lib.rs index 3eb451cb23f..0d336c21dc3 100644 --- a/runtime/near-vm-runner/src/lib.rs +++ b/runtime/near-vm-runner/src/lib.rs @@ -1,9 +1,13 @@ mod cache; mod errors; mod imports; +#[cfg(feature = "wasmer0_vm")] mod memory; + pub mod prepare; mod runner; + +#[cfg(feature = "wasmer0_vm")] mod wasmer_runner; #[cfg(feature = "wasmtime_vm")] diff --git a/runtime/near-vm-runner/src/runner.rs b/runtime/near-vm-runner/src/runner.rs index cf887d779f5..c3bce362481 100644 --- a/runtime/near-vm-runner/src/runner.rs +++ b/runtime/near-vm-runner/src/runner.rs @@ -4,7 +4,6 @@ use near_runtime_fees::RuntimeFeesConfig; use near_vm_errors::{CompilationError, FunctionCallError, VMError}; use near_vm_logic::types::{ProfileData, PromiseResult, ProtocolVersion}; use near_vm_logic::{External, VMConfig, VMContext, VMKind, VMOutcome}; -use crate::cache::compile_and_serialize_wasmer1; /// `run` does the following: /// - deserializes and validate the `code` binary (see `prepare::prepare_contract`) @@ -75,6 +74,7 @@ pub fn run_vm<'a>( current_protocol_version: ProtocolVersion, cache: Option<&'a dyn CompiledContractCache>, ) -> (Option, Option) { + #[cfg(feature = "wasmer0_vm")] use crate::wasmer_runner::run_wasmer; #[cfg(feature = "wasmtime_vm")] @@ -84,6 +84,7 @@ pub fn run_vm<'a>( use crate::wasmer1_runner::run_wasmer1; match vm_kind { + #[cfg(feature = "wasmer0_vm")] VMKind::Wasmer0 => run_wasmer( code_hash, code, @@ -97,6 +98,8 @@ pub fn run_vm<'a>( current_protocol_version, cache, ), + #[cfg(not(feature = "wasmer0_vm"))] + VMKind::Wasmer0 => panic!("Wasmer0 is not supported, compile with '--features wasmer0_vm'"), #[cfg(feature = "wasmtime_vm")] VMKind::Wasmtime => run_wasmtime( code_hash, @@ -148,6 +151,7 @@ pub fn run_vm_profiled<'a>( current_protocol_version: ProtocolVersion, cache: Option<&'a dyn CompiledContractCache>, ) -> (Option, Option) { + #[cfg(feature = "wasmer0_vm")] use crate::wasmer_runner::run_wasmer; #[cfg(feature = "wasmtime_vm")] @@ -156,6 +160,7 @@ pub fn run_vm_profiled<'a>( #[cfg(feature = "wasmer1_vm")] use crate::wasmer1_runner::run_wasmer1; let (outcome, error) = match vm_kind { + #[cfg(feature = "wasmer0_vm")] VMKind::Wasmer0 => run_wasmer( code_hash, code, @@ -169,6 +174,8 @@ pub fn run_vm_profiled<'a>( current_protocol_version, cache, ), + #[cfg(not(feature = "wasmer0_vm"))] + VMKind::Wasmer0 => panic!("Wasmer0 is not supported, compile with '--features wasmer0_vm'"), #[cfg(feature = "wasmtime_vm")] VMKind::Wasmtime => run_wasmtime( code_hash, @@ -222,17 +229,19 @@ pub fn precompile<'a>( cache: &'a dyn CompiledContractCache, vm_kind: VMKind, ) -> Option { - use crate::cache::compile_and_serialize_wasmer; match vm_kind { + #[cfg(not(feature = "wasmer0_vm"))] + VMKind::Wasmer0 => panic!("Wasmer0 is not supported, compile with '--features wasmer0_vm'"), + #[cfg(feature = "wasmer0_vm")] VMKind::Wasmer0 => { - let result = compile_and_serialize_wasmer(code, wasm_config, code_hash, cache); + let result = crate::cache::wasmer0_cache::compile_and_serialize_wasmer(code, wasm_config, code_hash, cache); result.err() } #[cfg(feature = "wasmer1_vm")] VMKind::Wasmer1 => { let engine = wasmer::JIT::new(wasmer_compiler_singlepass::Singlepass::default()).engine(); let store = wasmer::Store::new(&engine); - let result = compile_and_serialize_wasmer1(code, code_hash, cache, &store); + let result = crate::cache::wasmer1_cache::compile_and_serialize_wasmer1(code, code_hash, cache, &store); result.err() } #[cfg(not(feature = "wasmer1_vm"))] @@ -258,10 +267,13 @@ pub fn with_vm_variants(runner: fn(VMKind) -> ()) { /// Used for testing cost of compiling a module pub fn compile_module(vm_kind: VMKind, code: &Vec) -> bool { match vm_kind { + #[cfg(feature = "wasmer0_vm")] VMKind::Wasmer0 => { use crate::wasmer_runner::compile_module; compile_module(code) } + #[cfg(not(feature = "wasmer0_vm"))] + VMKind::Wasmer0 => panic!("Wasmer0 is not supported, compile with '--features wasmer0_vm'"), #[cfg(feature = "wasmtime_vm")] VMKind::Wasmtime => { use crate::wasmtime_runner::compile_module; diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index 836873fcc2d..a20a89d3b40 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -178,7 +178,7 @@ pub fn run_wasmer1<'a>( Ok(code) => code, Err(e) => return (None, Some(e.into())), }; - let module = match cache::compile_module_cached_wasmer1( + let module = match cache::wasmer1_cache::compile_module_cached_wasmer1( &code_hash, &prepared_code, wasm_config, @@ -246,7 +246,7 @@ pub fn run_wasmer1<'a>( }, Err(e) => (Some(logic.outcome()), Some(e.into_vm_error())), }, - Err(err) => (Some(logic.outcome()), Some(err.into_vm_error())), + Err(e) => (Some(logic.outcome()), Some(e.into_vm_error())), } } diff --git a/runtime/near-vm-runner/src/wasmer_runner.rs b/runtime/near-vm-runner/src/wasmer_runner.rs index 7cda58288de..3e84e7f697a 100644 --- a/runtime/near-vm-runner/src/wasmer_runner.rs +++ b/runtime/near-vm-runner/src/wasmer_runner.rs @@ -199,7 +199,7 @@ pub fn run_wasmer<'a>( } // TODO: consider using get_module() here, once we'll go via deployment path. - let module = match cache::compile_module_cached_wasmer(&code_hash, code, wasm_config, cache) { + let module = match cache::wasmer0_cache::compile_module_cached_wasmer(&code_hash, code, wasm_config, cache) { Ok(x) => x, Err(err) => return (None, Some(err)), }; diff --git a/runtime/runtime/Cargo.toml b/runtime/runtime/Cargo.toml index 270cb5b30cb..5bf80015d25 100644 --- a/runtime/runtime/Cargo.toml +++ b/runtime/runtime/Cargo.toml @@ -37,8 +37,11 @@ default = [] dump_errors_schema = ["near-vm-errors/dump_errors_schema"] protocol_feature_evm = ["near-evm-runner/protocol_feature_evm", "near-primitives/protocol_feature_evm", "near-runtime-fees/protocol_feature_evm", "near-vm-runner/protocol_feature_evm"] wasmer1_vm = ["near-vm-runner/wasmer1_vm"] +wasmer0_vm = ["near-vm-runner/wasmer0_vm"] wasmtime_vm = ["near-vm-runner/wasmtime_vm"] wasmer1_default = ["wasmer1_vm", "near-vm-logic/wasmer1_default"] +wasmer0_default = ["wasmer0_vm", "near-vm-logic/wasmer0_default"] +wasmtime_default = ["wasmtime_vm", "near-vm-logic/wasmtime_default"] # Use this feature to enable counting of fees and costs applied. costs_counting = ["near-vm-logic/costs_counting", "near-vm-runner/costs_counting"] From b1fb114a14ba74ae92375de4ca79feba462537bd Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 12 Feb 2021 17:09:17 -0800 Subject: [PATCH 46/50] test pass again --- runtime/near-vm-runner/src/imports.rs | 19 ++++--- runtime/near-vm-runner/src/runner.rs | 1 + .../near-vm-runner/tests/test_rs_contract.rs | 53 +++++++++++-------- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 5649fd2e69a..abe168be1a1 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -136,14 +136,17 @@ macro_rules! wrapped_imports { pub(crate) fn build_wasmer1(store: &wasmer::Store, memory: wasmer::Memory, logic: &mut VMLogic<'_>) -> wasmer::ImportObject { let env = NearWasmerEnv {logic: ImportReference(logic as * mut _ as * mut c_void), memory: memory.clone()}; - wasmer::imports! { - "env" => { - "memory" => memory, - $( - stringify!($func) => wasmer::Function::new_native_with_env(&store, env.clone(), wasmer1_ext::$func), - )* - }, - } + let mut import_object = wasmer::ImportObject::new(); + let mut namespace = wasmer::Exports::new(); + namespace.insert("memory", memory); + $({ + $(#[cfg(feature = $feature_name)])* + if true $(&& near_primitives::checked_feature!($feature_name, $feature, protocol_version))* { + namespace.insert(stringify!($func), wasmer::Function::new_native_with_env(&store, env.clone(), wasmer1_ext::$func)); + } + })* + import_object.register("env", namespace); + import_object } #[cfg(feature = "wasmtime_vm")] diff --git a/runtime/near-vm-runner/src/runner.rs b/runtime/near-vm-runner/src/runner.rs index c3bce362481..96be5e9a185 100644 --- a/runtime/near-vm-runner/src/runner.rs +++ b/runtime/near-vm-runner/src/runner.rs @@ -255,6 +255,7 @@ pub fn precompile<'a>( } pub fn with_vm_variants(runner: fn(VMKind) -> ()) { + #[cfg(feature = "wasmer0_vm")] runner(VMKind::Wasmer0); #[cfg(feature = "wasmtime_vm")] diff --git a/runtime/near-vm-runner/tests/test_rs_contract.rs b/runtime/near-vm-runner/tests/test_rs_contract.rs index 7b58981eec4..2421a2d35f4 100644 --- a/runtime/near-vm-runner/tests/test_rs_contract.rs +++ b/runtime/near-vm-runner/tests/test_rs_contract.rs @@ -223,27 +223,38 @@ def_test_ext!( #[test] pub fn test_out_of_memory() { - // TODO: currently we only run this test on Wasmer. - let code = &TEST_CONTRACT; - let mut fake_external = MockedExternal::new(); + with_vm_variants(|vm_kind: VMKind| { + // TODO: currently we only run this test on Wasmer. + match vm_kind { + VMKind::Wasmtime => return, + _ => {} + } - let context = create_context(&[]); - let config = VMConfig::free(); - let fees = RuntimeFeesConfig::free(); + let code = &TEST_CONTRACT; + let mut fake_external = MockedExternal::new(); - let promise_results = vec![]; - let result = run_vm( - vec![], - &code, - b"out_of_memory", - &mut fake_external, - context, - &config, - &fees, - &promise_results, - VMKind::Wasmer0, - LATEST_PROTOCOL_VERSION, - None, - ); - assert_eq!(result.1, Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError))); + let context = create_context(&[]); + let config = VMConfig::free(); + let fees = RuntimeFeesConfig::free(); + + let promise_results = vec![]; + let result = run_vm( + vec![], + &code, + b"out_of_memory", + &mut fake_external, + context, + &config, + &fees, + &promise_results, + vm_kind, + LATEST_PROTOCOL_VERSION, + None, + ); + assert_eq!(result.1, match vm_kind { + VMKind::Wasmer0 => Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)), + VMKind::Wasmer1 => Some(VMError::FunctionCallError(FunctionCallError::Wasmer1Trap("unreachable".to_string()))), + _ => unreachable!(), + }); + }) } From 365ccbfffc27b6d81624fe99746b48fd0620bac6 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Tue, 16 Feb 2021 17:42:23 -0800 Subject: [PATCH 47/50] fix all tests --- runtime/near-vm-runner/Cargo.toml | 2 +- runtime/near-vm-runner/src/cache.rs | 16 ++-- runtime/near-vm-runner/src/runner.rs | 6 +- runtime/near-vm-runner/src/wasmer1_runner.rs | 8 +- .../near-vm-runner/tests/test_error_cases.rs | 80 +++++++++++++------ 5 files changed, 74 insertions(+), 38 deletions(-) diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index 3bb34e37ebe..e27551a7b41 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -37,7 +37,7 @@ wabt = "0.9" bencher = "^0.1.5" [features] -default = [] +default = ["wasmer1_vm"] wasmer0_vm = [ "wasmer-runtime" ] wasmtime_vm = [ "wasmtime", "anyhow"] wasmer1_vm = [ "wasmer", "wasmer-types", "wasmer-compiler-singlepass" ] diff --git a/runtime/near-vm-runner/src/cache.rs b/runtime/near-vm-runner/src/cache.rs index 617c0054f19..bcecfc40e22 100644 --- a/runtime/near-vm-runner/src/cache.rs +++ b/runtime/near-vm-runner/src/cache.rs @@ -167,24 +167,27 @@ pub mod wasmer1_cache { store: &wasmer::Store, ) -> Result { let key = get_key(wasm_code_hash, wasm_code, VMKind::Wasmer1, config); - return compile_module_cached_wasmer1_impl(key, wasm_code, cache, store); + return compile_module_cached_wasmer1_impl(key, wasm_code, config, cache, store); } fn compile_module_wasmer1( - prepared_code: &[u8], + code: &[u8], + config: &VMConfig, store: &wasmer::Store, ) -> Result { + let prepared_code = prepare::prepare_contract(code, config)?; wasmer::Module::new(&store, prepared_code).map_err(|err| err.into_vm_error()) } pub(crate) fn compile_and_serialize_wasmer1( wasm_code: &[u8], key: &CryptoHash, + config: &VMConfig, cache: &dyn CompiledContractCache, store: &wasmer::Store, ) -> Result { - let module = - compile_module_wasmer1(wasm_code, store).map_err(|e| cache_error(e, &key, cache))?; + let module = compile_module_wasmer1(wasm_code, config, store) + .map_err(|e| cache_error(e, &key, cache))?; let code = module .serialize() .map_err(|_e| VMError::CacheError(SerializationError { hash: (key.0).0 }))?; @@ -211,11 +214,12 @@ pub mod wasmer1_cache { fn compile_module_cached_wasmer1_impl( key: CryptoHash, wasm_code: &[u8], + config: &VMConfig, cache: Option<&dyn CompiledContractCache>, store: &wasmer::Store, ) -> Result { if cache.is_none() { - return compile_module_wasmer1(wasm_code, store); + return compile_module_wasmer1(wasm_code, config, store); } let cache = cache.unwrap(); @@ -223,7 +227,7 @@ pub mod wasmer1_cache { Ok(serialized) => match serialized { Some(serialized) => deserialize_wasmer1(serialized.as_slice(), store) .map_err(VMError::CacheError)?, - None => compile_and_serialize_wasmer1(wasm_code, &key, cache, store), + None => compile_and_serialize_wasmer1(wasm_code, &key, config, cache, store), }, Err(_) => Err(VMError::CacheError(ReadError)), } diff --git a/runtime/near-vm-runner/src/runner.rs b/runtime/near-vm-runner/src/runner.rs index e633658d5a2..aacee847c8f 100644 --- a/runtime/near-vm-runner/src/runner.rs +++ b/runtime/near-vm-runner/src/runner.rs @@ -250,7 +250,11 @@ pub fn precompile<'a>( wasmer::JIT::new(wasmer_compiler_singlepass::Singlepass::default()).engine(); let store = wasmer::Store::new(&engine); let result = crate::cache::wasmer1_cache::compile_and_serialize_wasmer1( - code, code_hash, cache, &store, + code, + code_hash, + wasm_config, + cache, + &store, ); result.err() } diff --git a/runtime/near-vm-runner/src/wasmer1_runner.rs b/runtime/near-vm-runner/src/wasmer1_runner.rs index d9fc77ae689..b76b36f8679 100644 --- a/runtime/near-vm-runner/src/wasmer1_runner.rs +++ b/runtime/near-vm-runner/src/wasmer1_runner.rs @@ -1,5 +1,5 @@ use crate::errors::IntoVMError; -use crate::{cache, imports, prepare}; +use crate::{cache, imports}; use near_primitives::runtime::fees::RuntimeFeesConfig; use near_primitives::{profile::ProfileData, types::CompiledContractCache}; use near_vm_errors::{ @@ -174,13 +174,9 @@ pub fn run_wasmer1<'a>( let engine = JIT::new(Singlepass::default()).engine(); let store = Store::new(&engine); - let prepared_code = match prepare::prepare_contract(code, wasm_config) { - Ok(code) => code, - Err(e) => return (None, Some(e.into())), - }; let module = match cache::wasmer1_cache::compile_module_cached_wasmer1( &code_hash, - &prepared_code, + &code, wasm_config, cache, &store, diff --git a/runtime/near-vm-runner/tests/test_error_cases.rs b/runtime/near-vm-runner/tests/test_error_cases.rs index 3a360707dc6..b753acd0b87 100644 --- a/runtime/near-vm-runner/tests/test_error_cases.rs +++ b/runtime/near-vm-runner/tests/test_error_cases.rs @@ -150,13 +150,25 @@ fn trap_contract() -> Vec { #[test] fn test_trap_contract() { // See the comment is test_stack_overflow. - assert_eq!( - make_simple_contract_call_vm(&trap_contract(), b"hello", VMKind::Wasmer0), - ( - Some(vm_outcome_with_gas(47105334)), - Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) - ) - ); + with_vm_variants(|vm_kind: VMKind| match vm_kind { + VMKind::Wasmtime => return, + VMKind::Wasmer0 => assert_eq!( + make_simple_contract_call_vm(&trap_contract(), b"hello", vm_kind), + ( + Some(vm_outcome_with_gas(47105334)), + Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) + ) + ), + VMKind::Wasmer1 => assert_eq!( + make_simple_contract_call_vm(&trap_contract(), b"hello", vm_kind), + ( + Some(vm_outcome_with_gas(47105334)), + Some(VMError::FunctionCallError(FunctionCallError::Wasmer1Trap( + "unreachable".to_string() + ))) + ) + ), + }) } fn trap_initializer() -> Vec { @@ -175,13 +187,25 @@ fn trap_initializer() -> Vec { #[test] fn test_trap_initializer() { // See the comment is test_stack_overflow. - assert_eq!( - make_simple_contract_call_vm(&trap_initializer(), b"hello", VMKind::Wasmer0), - ( - Some(vm_outcome_with_gas(47755584)), - Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) - ) - ); + with_vm_variants(|vm_kind: VMKind| match vm_kind { + VMKind::Wasmtime => return, + VMKind::Wasmer0 => assert_eq!( + make_simple_contract_call_vm(&trap_initializer(), b"hello", vm_kind), + ( + Some(vm_outcome_with_gas(47755584)), + Some(VMError::FunctionCallError(FunctionCallError::WasmUnknownError)) + ) + ), + VMKind::Wasmer1 => assert_eq!( + make_simple_contract_call_vm(&trap_initializer(), b"hello", vm_kind), + ( + Some(vm_outcome_with_gas(47755584)), + Some(VMError::FunctionCallError(FunctionCallError::Wasmer1Trap( + "unreachable".to_string() + ))) + ) + ), + }); } fn wrong_signature_contract() -> Vec { @@ -548,16 +572,24 @@ fn test_external_call_error() { ); }); } + #[test] fn test_contract_error_caching() { - let mut cache = MockCompiledContractCache { store: Arc::new(Mutex::new(HashMap::new())) }; - let code = [42; 1000]; - let terragas = 1000000000000u64; - assert_eq!(cache.store.lock().unwrap().len(), 0); - let err1 = - make_cached_contract_call_vm(&mut cache, &code, b"method_name1", terragas, VMKind::Wasmer0); - assert_eq!(cache.store.lock().unwrap().len(), 1); - let err2 = - make_cached_contract_call_vm(&mut cache, &code, b"method_name2", terragas, VMKind::Wasmer0); - assert_eq!(err1, err2); + with_vm_variants(|vm_kind: VMKind| { + match vm_kind { + VMKind::Wasmtime => return, + _ => {} + } + let mut cache = MockCompiledContractCache { store: Arc::new(Mutex::new(HashMap::new())) }; + let code = [42; 1000]; + let terragas = 1000000000000u64; + assert_eq!(cache.store.lock().unwrap().len(), 0); + let err1 = + make_cached_contract_call_vm(&mut cache, &code, b"method_name1", terragas, vm_kind); + println!("{:?}", cache.store.lock().unwrap()); + assert_eq!(cache.store.lock().unwrap().len(), 1); + let err2 = + make_cached_contract_call_vm(&mut cache, &code, b"method_name2", terragas, vm_kind); + assert_eq!(err1, err2); + }) } From ee1b5eaeaba410b5d06e20394bb267d644e5d105 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 17 Feb 2021 13:19:14 -0800 Subject: [PATCH 48/50] wasmer0 as default, all vm enabled in tests --- runtime/near-vm-logic/src/config.rs | 12 +----------- runtime/near-vm-runner/Cargo.toml | 3 ++- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/runtime/near-vm-logic/src/config.rs b/runtime/near-vm-logic/src/config.rs index 156a1981644..658110b363a 100644 --- a/runtime/near-vm-logic/src/config.rs +++ b/runtime/near-vm-logic/src/config.rs @@ -46,16 +46,6 @@ impl Default for VMKind { not(feature = "wasmtime_default") ))] fn default() -> Self { - VMKind::Wasmer1 - } - - // These features should be mutually exclusive, but implement this for cargo test --all-features - #[cfg(all( - feature = "wasmer0_default", - feature = "wasmer1_default", - feature = "wasmtime_default" - ))] - fn default() -> Self { - VMKind::Wasmer1 + VMKind::Wasmer0 } } diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index e27551a7b41..57c7ef03d43 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -37,7 +37,8 @@ wabt = "0.9" bencher = "^0.1.5" [features] -default = ["wasmer1_vm"] +# all vms enabled for tests, but only one default vm, specified by runtime crate +default = ["wasmer0_vm", "wasmtime_vm", "wasmer1_vm"] wasmer0_vm = [ "wasmer-runtime" ] wasmtime_vm = [ "wasmtime", "anyhow"] wasmer1_vm = [ "wasmer", "wasmer-types", "wasmer-compiler-singlepass" ] From 61b8514a9120f6726c437380e83e108a5ea5bb29 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Wed, 17 Feb 2021 15:07:22 -0800 Subject: [PATCH 49/50] fix cargo check all features --- runtime/near-vm-logic/src/config.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/runtime/near-vm-logic/src/config.rs b/runtime/near-vm-logic/src/config.rs index 658110b363a..90f07944389 100644 --- a/runtime/near-vm-logic/src/config.rs +++ b/runtime/near-vm-logic/src/config.rs @@ -48,4 +48,14 @@ impl Default for VMKind { fn default() -> Self { VMKind::Wasmer0 } + + // These features should be mutually exclusive, but implement this to work around CI cargo check --all-features + #[cfg(all( + feature = "wasmer0_default", + feature = "wasmer1_default", + feature = "wasmtime_default" + ))] + fn default() -> Self { + VMKind::Wasmer0 + } } From d7e2e1c3b452a19054b3b2f36e1d71d1760c6057 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 22 Feb 2021 16:25:21 -0800 Subject: [PATCH 50/50] nit --- runtime/near-vm-runner/src/errors.rs | 1 + runtime/near-vm-runner/src/imports.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/runtime/near-vm-runner/src/errors.rs b/runtime/near-vm-runner/src/errors.rs index 41f5d2255b4..e1541154050 100644 --- a/runtime/near-vm-runner/src/errors.rs +++ b/runtime/near-vm-runner/src/errors.rs @@ -1,4 +1,5 @@ use near_vm_errors::VMError; + pub trait IntoVMError { fn into_vm_error(self) -> VMError; } diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index abe168be1a1..d3d95ecfa9d 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -10,6 +10,7 @@ unsafe impl Sync for ImportReference {} #[cfg(feature = "wasmer1_vm")] use wasmer::{Memory, WasmerEnv}; + #[derive(WasmerEnv, Clone)] #[cfg(feature = "wasmer1_vm")] pub struct NearWasmerEnv {