pub struct Limits {Show 13 fields
pub stack_height: Option<u32>,
pub globals: u32,
pub locals: u32,
pub parameters: u32,
pub memory_pages: u16,
pub table_size: u32,
pub table_number: u32,
pub br_table_size: u32,
pub subject_len: u32,
pub call_depth: u32,
pub payload_len: u32,
pub code_len: u32,
pub data_segments_amount: u32,
}
Expand description
Describes the upper limits on various metrics.
§Note
The values in this struct should never be decreased. The reason is that decreasing those values will break existing programs which are above the new limits when a re-instrumentation is triggered.
Fields§
§stack_height: Option<u32>
Maximum allowed stack height in number of elements.
See https://wiki.parity.io/WebAssembly-StackHeight to find out how the stack frame cost is calculated. Each element can be of one of the wasm value types. This means the maximum size per element is 64bit.
§Note
It is safe to disable (pass None
) the stack_height
when the execution engine
is part of the runtime and hence there can be no indeterminism between different
client resident execution engines.
globals: u32
Maximum number of globals a module is allowed to declare.
Globals are not limited through the linear memory limit memory_pages
.
locals: u32
Maximum number of locals a function can have.
As wasm engine initializes each of the local, we need to limit their number to confine execution costs.
parameters: u32
Maximum numbers of parameters a function can have.
Those need to be limited to prevent a potentially exploitable interaction with the stack height instrumentation: The costs of executing the stack height instrumentation for an indirectly called function scales linearly with the amount of parameters of this function. Because the stack height instrumentation itself is is not weight metered its costs must be static (via this limit) and included in the costs of the instructions that cause them (call, call_indirect).
memory_pages: u16
Maximum number of memory pages allowed for a program.
table_size: u32
Maximum number of elements allowed in a table.
Currently, the only type of element that is allowed in a table is funcref.
table_number: u32
Maximum number of tables allowed for a program.
The same limit also imposed by wasmparser
,
see https://github.com/bytecodealliance/wasm-tools/blob/main/crates/wasmparser/src/limits.rs
br_table_size: u32
Maximum number of elements that can appear as immediate value to the br_table instruction.
subject_len: u32
The maximum length of a subject in bytes used for PRNG generation.
call_depth: u32
The maximum nesting level of the call stack.
payload_len: u32
The maximum size of a message payload in bytes.
code_len: u32
The maximum length of a program code in bytes. This limit applies to the instrumented
version of the code. Therefore instantiate_with_code
can fail even when supplying
a wasm binary below this maximum size.
data_segments_amount: u32
The maximum number of wasm data segments allowed for a program.