Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Change MaxMemorySize to MaxMemoryPages (#6728)
Browse files Browse the repository at this point in the history
* Change `MaxMemorySize` to `MaxMemoryPages`

We should set the max memory for the executor in pages (64KiB) and not in bytes.
The wasm memory is always a multiple of a page and we should use the
same terminology.

* FMT

* Fix warning
  • Loading branch information
bkchr authored Feb 16, 2023
1 parent ea6fc41 commit 174816c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion node/core/pvf/src/executor_intf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ fn params_to_wasmtime_semantics(par: ExecutorParams) -> Result<Semantics, String
} else {
return Err("No default stack limit set".to_owned())
};

for p in par.iter() {
match p {
ExecutorParam::MaxMemorySize(mms) => sem.max_memory_size = Some(*mms as usize),
ExecutorParam::MaxMemoryPages(mms) => sem.max_memory_size = Some(*mms as usize * 65536),
ExecutorParam::StackLogicalMax(slm) => stack_limit.logical_max = *slm,
ExecutorParam::StackNativeMax(snm) => stack_limit.native_stack_max = *snm,
ExecutorParam::PrecheckingMaxMemory(_) => (), // TODO: Not implemented yet
Expand Down
7 changes: 3 additions & 4 deletions primitives/src/vstaging/executor_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ use polkadot_core_primitives::Hash;
use scale_info::TypeInfo;
use sp_std::{ops::Deref, vec, vec::Vec};

/// A single executor parameter
/// The different executor parameters for changing the execution environment semantics.
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, TypeInfo)]
pub enum ExecutorParam {
/// ## Parameters setting the executuion environment semantics:
/// Max. memory size
MaxMemorySize(u32),
/// Maximum number of memory pages (64KiB bytes per page) the executor can allocate.
MaxMemoryPages(u32),
/// Wasm logical stack size limit (max. number of Wasm values on stack)
StackLogicalMax(u32),
/// Executor machine stack size limit, in bytes
Expand Down

0 comments on commit 174816c

Please sign in to comment.