diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 0f271f807a753bdc10b9c85537203afabb45bd57..6326d1ffdf60c3e94ed16da4d2193104e99040cd 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -1185,16 +1185,18 @@ checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" [[package]] name = "cranelift-bforest" -version = "0.92.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91b18cf92869a6ae85cde3af4bc4beb6154efa8adef03b18db2ad413d5bce3a2" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.92.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567d9f6e919bac076f39b902a072686eaf9e6d015baa34d10a61b85105b7af59" dependencies = [ "arrayvec 0.7.2", "bumpalo", @@ -1213,29 +1215,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.92.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e72b2d5ec8917b2971fe83850187373d0a186db4748a7c23a5f48691b8d92bb" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.92.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3461c0e0c2ebbeb92533aacb27e219289f60dc84134ef34fbf2d77c9eddf07ef" [[package]] name = "cranelift-entity" -version = "0.92.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af684f7f7b01427b1942c7102673322a51b9d6f261e9663dc5e5595786775531" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.92.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d361ed0373cf5f086b49c499aa72227b646a64f899f32e34312f97c0fadff75" dependencies = [ "cranelift-codegen", "log", @@ -1245,13 +1251,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.92.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cef4f8f3984d772c199a48896d2fb766f96301bf71b371e03a2b99f4f3b7b931" [[package]] name = "cranelift-native" -version = "0.92.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98e4e99a353703475d5acb402b9c13482d41d8a4008b352559bd560afb90363" dependencies = [ "cranelift-codegen", "libc", @@ -1260,8 +1268,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.92.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e3f4f0779a1b0f286a6ef19835d8665f88326e656a6d7d84fa9a39fa38ca32" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -11951,9 +11960,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.96.0" +version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adde01ade41ab9a5d10ec8ed0bb954238cf8625b5cd5a13093d6de2ad9c2be1a" +checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4" dependencies = [ "indexmap", "url", @@ -11970,8 +11979,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9010891d0b8e367c3be94ca35d7bc25c1de3240463bb1d61bcfc8c2233c4e0d0" dependencies = [ "anyhow", "bincode", @@ -11997,16 +12007,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65805c663eaa8257b910666f6d4b056b5c7329750da754ba5df54f3af7dbf35c" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2049ddfc1b10efc3c5591d0e84b9570ca50478f8818f3bfabb1a467918f53fb4" dependencies = [ "anyhow", "base64 0.13.1", @@ -12024,8 +12036,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9065cad6a724fa838ec8497567e0b23acc26417bb2449f8d9d2021925c72f2" dependencies = [ "anyhow", "cranelift-codegen", @@ -12044,8 +12057,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f964bb0b91fa021b8d1b488c62cc77b346c1dae6e3ebd010050b57c1f2ca657" dependencies = [ "anyhow", "cranelift-entity", @@ -12062,8 +12076,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7a1d06f5d109539e0168fc74fa65e3948ac8dac3bb8cdbd08b62b36a0ae27b8" dependencies = [ "addr2line 0.17.0", "anyhow", @@ -12085,8 +12100,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f76ef2e410329aaf8555ac6571d6fe07711be0646dcdf7ff3ab750a42ed2e583" dependencies = [ "object 0.29.0", "once_cell", @@ -12095,8 +12111,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec1fd0f0dd79e7cc0f55b102e320d7c77ab76cd272008a8fd98e25b5777e2636" dependencies = [ "cfg-if", "libc", @@ -12105,8 +12122,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271aef9b4ca2e953a866293683f2db33cda46f6933c5e431e68d8373723d4ab6" dependencies = [ "anyhow", "cc", @@ -12128,8 +12146,9 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "5.0.0" -source = "git+https://github.com/paritytech/wasmtime.git?branch=v5.0.0_lto_fix#8a02705ad378108e43abe23c538688adf73f3b71" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b18144b0e45479a830ac9fcebfc71a16d90dc72d8ebd5679700eb3bfe974d7df" dependencies = [ "cranelift-entity", "serde", diff --git a/substrate/client/executor/wasmtime/Cargo.toml b/substrate/client/executor/wasmtime/Cargo.toml index e29a1952776811d0c43a240468ca2bda5d6a6e12..ca7daa970207d7a3d60d6c69fe8fed0382976d03 100644 --- a/substrate/client/executor/wasmtime/Cargo.toml +++ b/substrate/client/executor/wasmtime/Cargo.toml @@ -19,13 +19,13 @@ log = "0.4.17" # When bumping wasmtime do not forget to also bump rustix # to exactly the same version as used by wasmtime! -wasmtime = { version = "5.0.0", default-features = false, features = [ +wasmtime = { version = "6.0.0", default-features = false, features = [ "cache", "cranelift", "jitdump", "parallel-compilation", "pooling-allocator" -], git = "https://github.com/paritytech/wasmtime.git", branch = "v5.0.0_lto_fix" } +] } anyhow = "1.0.68" sc-allocator = { version = "4.1.0-dev", path = "../../allocator" } sc-executor-common = { version = "0.10.0-dev", path = "../common" } @@ -38,7 +38,7 @@ sp-wasm-interface = { version = "7.0.0", path = "../../../primitives/wasm-interf # By default rustix directly calls the appropriate syscalls completely bypassing libc; # this doesn't have any actual benefits for us besides making it harder to debug memory # problems (since then `mmap` etc. cannot be easily hooked into). -rustix = { version = "0.36.0", default-features = false, features = ["std", "mm", "fs", "param", "use-libc"] } +rustix = { version = "0.36.7", default-features = false, features = ["std", "mm", "fs", "param", "use-libc"] } once_cell = "1.12.0" [dev-dependencies] diff --git a/substrate/client/executor/wasmtime/src/instance_wrapper.rs b/substrate/client/executor/wasmtime/src/instance_wrapper.rs index f80c7b70d1f28b3ccbad14e502bdf10e62d76daa..2fb27180fcc760c5f6fed985a73c02ac15fac6c4 100644 --- a/substrate/client/executor/wasmtime/src/instance_wrapper.rs +++ b/substrate/client/executor/wasmtime/src/instance_wrapper.rs @@ -402,8 +402,7 @@ fn decommit_works() { let code = wat::parse_str("(module (memory (export \"memory\") 1 4))").unwrap(); let module = wasmtime::Module::new(&engine, code).unwrap(); let linker = wasmtime::Linker::new(&engine); - let mut store = create_store(&engine, None); - let instance_pre = linker.instantiate_pre(&mut store, &module).unwrap(); + let instance_pre = linker.instantiate_pre(&module).unwrap(); let mut wrapper = InstanceWrapper::new(&engine, &instance_pre, None).unwrap(); unsafe { *wrapper.memory.data_ptr(&wrapper.store) = 42 }; assert_eq!(unsafe { *wrapper.memory.data_ptr(&wrapper.store) }, 42); diff --git a/substrate/client/executor/wasmtime/src/runtime.rs b/substrate/client/executor/wasmtime/src/runtime.rs index 1728feeee5a8729e1b88da1962e8a2f534304a3f..ce3f889fc9a75137af709ac3d209c25adc782723 100644 --- a/substrate/client/executor/wasmtime/src/runtime.rs +++ b/substrate/client/executor/wasmtime/src/runtime.rs @@ -298,6 +298,11 @@ fn common_config(semantics: &Semantics) -> std::result::Result<wasmtime::Config, config.cranelift_opt_level(wasmtime::OptLevel::SpeedAndSize); config.cranelift_nan_canonicalization(semantics.canonicalize_nans); + // Since wasmtime 6.0.0 the default for this is `true`, but that heavily regresses + // the contracts pallet's performance, so disable it for now. + #[allow(deprecated)] + config.cranelift_use_egraphs(false); + let profiler = match std::env::var_os("WASMTIME_PROFILING_STRATEGY") { Some(os_string) if os_string == "jitdump" => wasmtime::ProfilingStrategy::JitDump, None => wasmtime::ProfilingStrategy::None, @@ -368,7 +373,7 @@ fn common_config(semantics: &Semantics) -> std::result::Result<wasmtime::Config, let mut pooling_config = wasmtime::PoolingAllocationConfig::default(); pooling_config - .strategy(wasmtime::PoolingAllocationStrategy::ReuseAffinity) + .max_unused_warm_slots(4) // Pooling needs a bunch of hard limits to be set; if we go over // any of these then the instantiation will fail. // @@ -680,10 +685,8 @@ where let mut linker = wasmtime::Linker::new(&engine); crate::imports::prepare_imports::<H>(&mut linker, &module, config.allow_missing_func_imports)?; - let mut store = - crate::instance_wrapper::create_store(module.engine(), config.semantics.max_memory_size); let instance_pre = linker - .instantiate_pre(&mut store, &module) + .instantiate_pre(&module) .map_err(|e| WasmError::Other(format!("cannot preinstantiate module: {:#}", e)))?; Ok(WasmtimeRuntime { diff --git a/substrate/primitives/wasm-interface/Cargo.toml b/substrate/primitives/wasm-interface/Cargo.toml index 21b0bb4329ed716c92d5c6ab9ddc8cc8a8fd066d..65c4ae42f044eea287e49ba53a05bc62700b0576 100644 --- a/substrate/primitives/wasm-interface/Cargo.toml +++ b/substrate/primitives/wasm-interface/Cargo.toml @@ -18,7 +18,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", default-features = impl-trait-for-tuples = "0.2.2" log = { version = "0.4.17", optional = true } wasmi = { version = "0.13", optional = true } -wasmtime = { version = "5.0.0", default-features = false, optional = true, git = "https://github.com/paritytech/wasmtime.git", branch = "v5.0.0_lto_fix" } +wasmtime = { version = "6.0.0", default-features = false, optional = true } anyhow = { version = "1.0.68", optional = true } sp-std = { version = "5.0.0", default-features = false, path = "../std" }