Unverified Commit 2bad8079 authored by Sergey Pepyakin's avatar Sergey Pepyakin Committed by GitHub
Browse files

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 <>
parent 4c5cd37d
Pipeline #145967 passed with stages
in 36 minutes and 49 seconds
This diff is collapsed.
......@@ -21,7 +21,7 @@ use sc_executor_common::{
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,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment