Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 59 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions client/executor/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions client/executor/wasmtime/src/instance_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions client/executor/wasmtime/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion primitives/wasm-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down