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

Companion: Limit the maximum number of wasm memory pages a runtime can have (#3449)



* Add `max_memory_pages`

* update Substrate
Co-authored-by: Shawn Tabrizi's avatarShawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: parity-processbot <>
parent 2dad5023
Pipeline #150691 passed with stages
in 46 minutes and 6 seconds
This diff is collapsed.
......@@ -26,8 +26,24 @@ use sp_wasm_interface::HostFunctions as _;
use std::any::{Any, TypeId};
const CONFIG: Config = Config {
// TODO: Make sure we don't use more than 1GB: https://github.com/paritytech/polkadot/issues/699
// Memory configuration
//
// When Substrate Runtime is instantiated, a number of wasm pages are mounted for the Substrate
// Runtime instance. The number of pages is specified by `heap_pages`.
//
// Besides `heap_pages` linear memory requests an initial number of pages. Those pages are
// typically used for placing the so-called shadow stack and the data section.
//
// By default, rustc (or lld specifically) allocates 1 MiB for the shadow stack. That is, 16
// wasm pages.
//
// Data section for runtimes are typically rather small and can fit in a single digit number of
// wasm pages.
//
// Thus let's assume that 32 pages or 2 MiB are used for these needs.
max_memory_pages: Some(2048 + 32),
heap_pages: 2048,
allow_missing_func_imports: true,
cache_path: None,
semantics: Semantics {
......
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