From 0a5ec215913a1cd66ea1c414f459f9b3b0dc6022 Mon Sep 17 00:00:00 2001 From: BenJilks Date: Mon, 13 Jun 2022 05:07:59 +0000 Subject: [PATCH 1/2] Use lasted version of wasmer (2.2.1 -> 2.3.0) The current verion doesn't support certain architectures. For example armv7, the platform I was trying to compile for. The latest version works fine. --- Cargo.lock | 201 +++++++++++++++------ packages/profiler/Cargo.toml | 8 +- packages/profiler/src/operators.rs | 36 +++- packages/vm/Cargo.toml | 4 +- packages/vm/src/wasm_backend/gatekeeper.rs | 20 +- 5 files changed, 202 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3b81566731..9427440197 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,7 +8,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ - "gimli 0.26.1", + "gimli", ] [[package]] @@ -240,6 +240,19 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "corosensei" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab4b310cff9117ec16d05970743c20df3eaddafd461829f2758e76a8de2863a9" +dependencies = [ + "autocfg", + "cfg-if", + "libc", + "scopeguard", + "windows-sys", +] + [[package]] name = "cosmwasm-crypto" version = "1.0.0" @@ -354,24 +367,24 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "38faa2a16616c8e78a18d37b4726b98bfd2de192f2fdc8a39ddf568a408a0f75" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "26f192472a3ba23860afd07d2b0217dc628f21fcc72617aa1336d98e1671f33b" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.25.0", + "gimli", "log", "regalloc", "smallvec", @@ -380,31 +393,30 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "0f32ddb89e9b89d3d9b36a5b7d7ea3261c98235a76ac95ba46826b8ec40b1a24" dependencies = [ "cranelift-codegen-shared", - "cranelift-entity", ] [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" +checksum = "01fd0d9f288cc1b42d9333b7a776b17e278fc888c28e6a0f09b5573d45a150bc" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "9e3bfe172b83167604601faf9dc60453e0d0a93415b57a9c4d1a7ae6849185cf" [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "a006e3e32d80ce0e4ba7f1f9ddf66066d052a8c884a110b91d05404d6ce26dce" dependencies = [ "cranelift-codegen", "log", @@ -818,21 +830,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.25.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" dependencies = [ "fallible-iterator", "indexmap", "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" - [[package]] name = "group" version = "0.11.0" @@ -1353,9 +1359,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.31" +version = "0.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" +checksum = "62446b1d3ebf980bdc68837700af1d77b37bc430e524bf95319c6eada2a4cc02" dependencies = [ "log", "rustc-hash", @@ -1947,9 +1953,9 @@ checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" [[package]] name = "wasmer" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f727a39e7161f7438ddb8eafe571b67c576a8c2fb459f666d9053b5bba4afdea" +checksum = "ea8d8361c9d006ea3d7797de7bd6b1492ffd0f91a22430cfda6c1658ad57bedf" dependencies = [ "cfg-if", "indexmap", @@ -1959,6 +1965,7 @@ dependencies = [ "target-lexicon", "thiserror", "wasm-bindgen", + "wasmer-artifact", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass", @@ -1972,11 +1979,24 @@ dependencies = [ "winapi", ] +[[package]] +name = "wasmer-artifact" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aaf9428c29c1d8ad2ac0e45889ba8a568a835e33fd058964e5e500f2f7ce325" +dependencies = [ + "enumset", + "loupe", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + [[package]] name = "wasmer-compiler" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9951599222eb12bd13d4d91bcded0a880e4c22c2dfdabdf5dc7e5e803b7bf3" +checksum = "e67a6cd866aed456656db2cfea96c18baabbd33f676578482b85c51e1ee19d2c" dependencies = [ "enumset", "loupe", @@ -1987,20 +2007,19 @@ dependencies = [ "target-lexicon", "thiserror", "wasmer-types", - "wasmer-vm", - "wasmparser 0.78.2", + "wasmparser 0.83.0", ] [[package]] name = "wasmer-compiler-cranelift" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c83273bce44e668f3a2b9ccb7f1193db918b1d6806f64acc5ff71f6ece5f20" +checksum = "48be2f9f6495f08649e4f8b946a2cbbe119faf5a654aa1457f9504a99d23dae0" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "gimli 0.25.0", + "gimli", "loupe", "more-asserts", "rayon", @@ -2009,18 +2028,18 @@ dependencies = [ "tracing", "wasmer-compiler", "wasmer-types", - "wasmer-vm", ] [[package]] name = "wasmer-compiler-singlepass" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5432e993840cdb8e6875ddc8c9eea64e7a129579b4706bd91b8eb474d9c4a860" +checksum = "29ca2a35204d8befa85062bc7aac259a8db8070b801b8a783770ba58231d729e" dependencies = [ "byteorder", "dynasm", "dynasmrt", + "gimli", "lazy_static", "loupe", "more-asserts", @@ -2028,14 +2047,13 @@ dependencies = [ "smallvec", "wasmer-compiler", "wasmer-types", - "wasmer-vm", ] [[package]] name = "wasmer-derive" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458dbd9718a837e6dbc52003aef84487d79eedef5fa28c7d28b6784be98ac08e" +checksum = "00e50405cc2a2f74ff574584710a5f2c1d5c93744acce2ca0866084739284b51" dependencies = [ "proc-macro-error", "proc-macro2", @@ -2045,9 +2063,9 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed603a6d037ebbb14014d7f739ae996a78455a4b86c41cfa4e81c590a1253b9" +checksum = "3f98f010978c244db431b392aeab0661df7ea0822343334f8f2a920763548e45" dependencies = [ "backtrace", "enumset", @@ -2060,6 +2078,7 @@ dependencies = [ "serde_bytes", "target-lexicon", "thiserror", + "wasmer-artifact", "wasmer-compiler", "wasmer-types", "wasmer-vm", @@ -2067,9 +2086,9 @@ dependencies = [ [[package]] name = "wasmer-engine-dylib" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd7fdc60e252a795c849b3f78a81a134783051407e7e279c10b7019139ef8dc" +checksum = "ad0358af9c154724587731175553805648d9acb8f6657880d165e378672b7e53" dependencies = [ "cfg-if", "enum-iterator", @@ -2082,6 +2101,7 @@ dependencies = [ "serde", "tempfile", "tracing", + "wasmer-artifact", "wasmer-compiler", "wasmer-engine", "wasmer-object", @@ -2092,12 +2112,11 @@ dependencies = [ [[package]] name = "wasmer-engine-universal" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcff0cd2c01a8de6009fd863b14ea883132a468a24f2d2ee59dc34453d3a31b5" +checksum = "440dc3d93c9ca47865a4f4edd037ea81bf983b5796b59b3d712d844b32dbef15" dependencies = [ "cfg-if", - "enum-iterator", "enumset", "leb128", "loupe", @@ -2105,16 +2124,33 @@ dependencies = [ "rkyv", "wasmer-compiler", "wasmer-engine", + "wasmer-engine-universal-artifact", "wasmer-types", "wasmer-vm", "winapi", ] +[[package]] +name = "wasmer-engine-universal-artifact" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f1db3f54152657eb6e86c44b66525ff7801dad8328fe677da48dd06af9ad41" +dependencies = [ + "enum-iterator", + "enumset", + "loupe", + "rkyv", + "thiserror", + "wasmer-artifact", + "wasmer-compiler", + "wasmer-types", +] + [[package]] name = "wasmer-middlewares" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "659775db15684f4674c3a8967409682c2eb44f63cc21121fa3dcd975c03ab887" +checksum = "d7812438ed2f37203a37007cdb5332b8475cb2b16e15d51299b2647894e9ed3a" dependencies = [ "loupe", "wasmer", @@ -2124,9 +2160,9 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ce18ac2877050e59580d27ee1a88f3192d7a31e77fbba0852abc7888d6e0b5" +checksum = "8d831335ff3a44ecf451303f6f891175c642488036b92ceceb24ac8623a8fa8b" dependencies = [ "object", "thiserror", @@ -2136,12 +2172,15 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "659fa3dd6c76f62630deff4ac8c7657b07f0b1e4d7e0f8243a552b9d9b448e24" +checksum = "39df01ea05dc0a9bab67e054c7cb01521e53b35a7bb90bd02eca564ed0b2667f" dependencies = [ + "backtrace", + "enum-iterator", "indexmap", "loupe", + "more-asserts", "rkyv", "serde", "thiserror", @@ -2149,23 +2188,28 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afdc46158517c2769f9938bc222a7d41b3bb330824196279d8aa2d667cd40641" +checksum = "30d965fa61f4dc4cdb35a54daaf7ecec3563fbb94154a6c35433f879466247dd" dependencies = [ "backtrace", "cc", "cfg-if", + "corosensei", "enum-iterator", "indexmap", + "lazy_static", "libc", "loupe", + "mach", "memoffset", "more-asserts", "region", "rkyv", + "scopeguard", "serde", "thiserror", + "wasmer-artifact", "wasmer-types", "winapi", ] @@ -2178,9 +2222,9 @@ checksum = "b35c86d22e720a07d954ebbed772d01180501afe7d03d464f413bb5f8914a8d6" [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.83.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" [[package]] name = "wast" @@ -2254,6 +2298,49 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43dbb096663629518eb1dfa72d80243ca5a6aca764cae62a2df70af760a9be75" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" + +[[package]] +name = "windows_i686_gnu" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" + +[[package]] +name = "windows_i686_msvc" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" + [[package]] name = "zeroize" version = "1.5.5" diff --git a/packages/profiler/Cargo.toml b/packages/profiler/Cargo.toml index 51bb8d2792..4c611faaf5 100644 --- a/packages/profiler/Cargo.toml +++ b/packages/profiler/Cargo.toml @@ -14,9 +14,9 @@ cosmwasm-vm = { path = "../vm" } cosmwasm-std = { path = "../std" } loupe = "0.1.3" walrus = "0.19.0" -wasmer = { version = "=2.2.1", default-features = false, features = ["compiler"] } -wasmer-types = "=2.2.1" -wasmer-vm = "=2.2.1" +wasmer = { version = "=2.3.0", default-features = false, features = ["compiler"] } +wasmer-types = "=2.3.0" +wasmer-vm = "=2.3.0" # wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "877ce1f7c44fad853c", default-features = false, features = ["compiler"] } # wasmer-types = { git = "https://github.com/wasmerio/wasmer", rev = "877ce1f7c44fad853c" } # wasmer-vm = { git = "https://github.com/wasmerio/wasmer", rev = "877ce1f7c44fad853c" } @@ -24,5 +24,5 @@ hackatom = { path = "../../contracts/hackatom", default-features = false } csv = "1.1.6" [dev-dependencies] -wasmer = { version = "=2.2.1", features = ["compiler"] } +wasmer = { version = "=2.3.0", features = ["compiler"] } # wasmer = { git = "https://github.com/wasmerio/wasmer", rev = "877ce1f7c44fad853c", features = ["compiler"] } diff --git a/packages/profiler/src/operators.rs b/packages/profiler/src/operators.rs index 60345baf87..6fc1fd56b6 100644 --- a/packages/profiler/src/operators.rs +++ b/packages/profiler/src/operators.rs @@ -15,7 +15,6 @@ pub enum OperatorSymbol { Catch, Throw, Rethrow, - Unwind, End, Br, BrIf, @@ -530,6 +529,23 @@ pub enum OperatorSymbol { F64x2ConvertLowI32x4U, F32x4DemoteF64x2Zero, F64x2PromoteLowF32x4, + I8x16RelaxedSwizzle, + I32x4RelaxedTruncSatF32x4S, + I32x4RelaxedTruncSatF32x4U, + I32x4RelaxedTruncSatF64x2SZero, + I32x4RelaxedTruncSatF64x2UZero, + F32x4Fma, + F32x4Fms, + F64x2Fma, + F64x2Fms, + I8x16LaneSelect, + I16x8LaneSelect, + I32x4LaneSelect, + I64x2LaneSelect, + F32x4RelaxedMin, + F32x4RelaxedMax, + F64x2RelaxedMin, + F64x2RelaxedMax, } impl From<&Operator<'_>> for OperatorSymbol { @@ -545,7 +561,6 @@ impl From<&Operator<'_>> for OperatorSymbol { Operator::Catch { .. } => OperatorSymbol::Catch, Operator::Throw { .. } => OperatorSymbol::Throw, Operator::Rethrow { .. } => OperatorSymbol::Rethrow, - Operator::Unwind => OperatorSymbol::Unwind, Operator::End => OperatorSymbol::End, Operator::Br { .. } => OperatorSymbol::Br, Operator::BrIf { .. } => OperatorSymbol::BrIf, @@ -1060,6 +1075,23 @@ impl From<&Operator<'_>> for OperatorSymbol { Operator::F64x2ConvertLowI32x4U => OperatorSymbol::F64x2ConvertLowI32x4U, Operator::F32x4DemoteF64x2Zero => OperatorSymbol::F32x4DemoteF64x2Zero, Operator::F64x2PromoteLowF32x4 => OperatorSymbol::F64x2PromoteLowF32x4, + Operator::I8x16RelaxedSwizzle => OperatorSymbol::I8x16RelaxedSwizzle, + Operator::I32x4RelaxedTruncSatF32x4S => OperatorSymbol::I32x4RelaxedTruncSatF32x4S, + Operator::I32x4RelaxedTruncSatF32x4U => OperatorSymbol::I32x4RelaxedTruncSatF32x4U, + Operator::I32x4RelaxedTruncSatF64x2SZero => OperatorSymbol::I32x4RelaxedTruncSatF64x2SZero, + Operator::I32x4RelaxedTruncSatF64x2UZero => OperatorSymbol::I32x4RelaxedTruncSatF64x2UZero, + Operator::F32x4Fma => OperatorSymbol::F32x4Fma, + Operator::F32x4Fms => OperatorSymbol::F32x4Fms, + Operator::F64x2Fma => OperatorSymbol::F64x2Fma, + Operator::F64x2Fms => OperatorSymbol::F64x2Fms, + Operator::I8x16LaneSelect => OperatorSymbol::I8x16LaneSelect, + Operator::I16x8LaneSelect => OperatorSymbol::I16x8LaneSelect, + Operator::I32x4LaneSelect => OperatorSymbol::I32x4LaneSelect, + Operator::I64x2LaneSelect => OperatorSymbol::I64x2LaneSelect, + Operator::F32x4RelaxedMin => OperatorSymbol::F32x4RelaxedMin, + Operator::F32x4RelaxedMax => OperatorSymbol::F32x4RelaxedMax, + Operator::F64x2RelaxedMin => OperatorSymbol::F64x2RelaxedMin, + Operator::F64x2RelaxedMax => OperatorSymbol::F64x2RelaxedMax, } } } diff --git a/packages/vm/Cargo.toml b/packages/vm/Cargo.toml index 42d8f8a92d..6caf057ee1 100644 --- a/packages/vm/Cargo.toml +++ b/packages/vm/Cargo.toml @@ -50,8 +50,8 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0" sha2 = "0.9.1" thiserror = "1.0" -wasmer = { version = "=2.2.1", default-features = false, features = ["cranelift", "universal", "singlepass"] } -wasmer-middlewares = "=2.2.1" +wasmer = { version = "=2.3.0", default-features = false, features = ["cranelift", "universal", "singlepass"] } +wasmer-middlewares = "=2.3.0" loupe = "0.1.3" # Wasmer git/local (used for quick local debugging or patching) diff --git a/packages/vm/src/wasm_backend/gatekeeper.rs b/packages/vm/src/wasm_backend/gatekeeper.rs index 7d5f625a06..20f8f41170 100644 --- a/packages/vm/src/wasm_backend/gatekeeper.rs +++ b/packages/vm/src/wasm_backend/gatekeeper.rs @@ -485,7 +485,24 @@ impl FunctionMiddleware for FunctionGatekeeper { | Operator::F64x2ConvertLowI32x4S | Operator::F64x2ConvertLowI32x4U | Operator::F32x4DemoteF64x2Zero - | Operator::F64x2PromoteLowF32x4 => { + | Operator::F64x2PromoteLowF32x4 + | Operator::I8x16RelaxedSwizzle + | Operator::I32x4RelaxedTruncSatF32x4S + | Operator::I32x4RelaxedTruncSatF32x4U + | Operator::I32x4RelaxedTruncSatF64x2SZero + | Operator::I32x4RelaxedTruncSatF64x2UZero + | Operator::F32x4Fma + | Operator::F32x4Fms + | Operator::F64x2Fma + | Operator::F64x2Fms + | Operator::I8x16LaneSelect + | Operator::I16x8LaneSelect + | Operator::I32x4LaneSelect + | Operator::I64x2LaneSelect + | Operator::F32x4RelaxedMin + | Operator::F32x4RelaxedMax + | Operator::F64x2RelaxedMin + | Operator::F64x2RelaxedMax => { if self.config.allow_feature_simd { state.push_operator(operator); Ok(()) @@ -656,7 +673,6 @@ impl FunctionMiddleware for FunctionGatekeeper { | Operator::Catch { .. } | Operator::Throw { .. } | Operator::Rethrow { .. } - | Operator::Unwind { .. } | Operator::Delegate { .. } | Operator::CatchAll => { if self.config.allow_feature_exception_handling { From d2d54891179db1bcd65813883709dc3fe303c716 Mon Sep 17 00:00:00 2001 From: BenJilks Date: Mon, 13 Jun 2022 08:17:01 +0100 Subject: [PATCH 2/2] MAX_WASM_MEMORY off by one error. Since we're indexing from 0, this value should be one less. Using u32::MAX also allows us to compile on 32bit systems without and overflow error. The tests have also been updated to reflect this. --- packages/vm/src/wasm_backend/store.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vm/src/wasm_backend/store.rs b/packages/vm/src/wasm_backend/store.rs index aebe33b1cf..3428a2e4fd 100644 --- a/packages/vm/src/wasm_backend/store.rs +++ b/packages/vm/src/wasm_backend/store.rs @@ -18,7 +18,7 @@ use super::limiting_tunables::LimitingTunables; /// is 65536 (2^16) bytes. In WebAssembly version 1, a linear memory can have at /// most 65536 pages, for a total of 2^32 bytes (4 gibibytes). /// https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md -const MAX_WASM_MEMORY: usize = 4 * 1024 * 1024 * 1024; +const MAX_WASM_MEMORY: usize = u32::MAX as usize; fn cost(_operator: &Operator) -> u64 { // A flat fee for each operation @@ -115,8 +115,8 @@ mod tests { assert_eq!(limit_to_pages(Size::kibi(65)), Pages(1)); // caps at 4 GiB assert_eq!(limit_to_pages(Size::gibi(3)), Pages(49152)); - assert_eq!(limit_to_pages(Size::gibi(4)), Pages(65536)); - assert_eq!(limit_to_pages(Size::gibi(5)), Pages(65536)); + assert_eq!(limit_to_pages(Size::gibi(4)), Pages(65535)); + assert_eq!(limit_to_pages(Size::gibi(5)), Pages(65535)); } #[test]