gear_core::gas_metering

Struct Limits

Source
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.

Trait Implementations§

Source§

impl Clone for Limits

Source§

fn clone(&self) -> Limits

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Limits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Limits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Limits

§

impl RefUnwindSafe for Limits

§

impl Send for Limits

§

impl Sync for Limits

§

impl Unpin for Limits

§

impl UnwindSafe for Limits

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> JsonSchemaMaybe for T