pvf: Enable stack depth metering & NaN canonicalization (#3373)

* Add `canonicalize_nans` and enable `stack_depth_metering`

* Update to the latest change in the substrate PR

* Explain why the numbers are what they are.

* Update Substrate to the latest master

Co-authored-by: parity-processbot <>
This commit is contained in:
Sergei Shulepov
2021-07-07 12:55:00 +03:00
committed by GitHub
parent b7b2276555
commit 8d77738cfd
2 changed files with 171 additions and 215 deletions
+153 -213
View File
File diff suppressed because it is too large Load Diff
+18 -2
View File
@@ -21,7 +21,7 @@ use sc_executor_common::{
runtime_blob::RuntimeBlob,
wasm_runtime::{InvokeMethod, WasmModule as _},
};
use sc_executor_wasmtime::{Config, Semantics};
use sc_executor_wasmtime::{Config, Semantics, DeterministicStackLimit};
use sp_core::{
storage::{ChildInfo, TrackedStorageKey},
};
@@ -34,7 +34,23 @@ const CONFIG: Config = Config {
cache_path: None,
semantics: Semantics {
fast_instance_reuse: false,
stack_depth_metering: false,
// Enable determinstic stack limit to pin down the exact number of items the wasmtime stack
// can contain before it traps with stack overflow.
//
// Here is how the values below were chosen.
//
// At the moment of writing, the default native stack size limit is 1 MiB. Assuming a logical item
// (see the docs about the field and the instrumentation algorithm) is 8 bytes, 1 MiB can
// fit 2x 65536 logical items.
//
// Since reaching the native stack limit is undesirable, we halven the logical item limit and
// also increase the native 256x. This hopefully should preclude wasm code from reaching
// the stack limit set by the wasmtime.
deterministic_stack_limit: Some(DeterministicStackLimit {
logical_max: 65536,
native_stack_max: 256 * 1024 * 1024,
}),
canonicalize_nans: true,
},
};