#[non_exhaustive]pub struct WasmLimits {
pub initial_memory_limit_pages: Option<u32>,
pub table_size_limit_elements: Option<u32>,
pub max_imports: Option<usize>,
pub max_functions: Option<usize>,
pub max_function_params: Option<usize>,
pub max_total_function_params: Option<usize>,
pub max_function_results: Option<usize>,
}
Expand description
Limits for static validation of Wasm files. These are checked before storing the Wasm file. All limits are optional because they are coming from the Go-side and have default values.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.initial_memory_limit_pages: Option<u32>
Maximum number of memory pages that a module can request.
Every Wasm memory has an initial size and an optional maximum size, both measured in Wasm pages. This limit applies to the initial size.
table_size_limit_elements: Option<u32>
The upper limit for the max
value of each table. CosmWasm contracts have
initial=max for 1 table. See
$ wasm-objdump --section=table -x packages/vm/testdata/hackatom.wasm
Section Details:
Table[1]:
- table[0] type=funcref initial=161 max=161
max_imports: Option<usize>
If the contract has more than this amount of imports, it will be rejected during static validation before even looking into the imports.
max_functions: Option<usize>
The maximum number of functions a contract can have. Any contract with more functions than this will be rejected during static validation.
max_function_params: Option<usize>
The maximum number of parameters a Wasm function can have.
max_total_function_params: Option<usize>
The maximum total number of parameters of all functions in the Wasm. For each function in the Wasm, take the number of parameters and sum all of these up. If that sum exceeds this limit, the Wasm will be rejected during static validation.
Be careful when adjusting this limit, as it prevents an attack where a small Wasm file explodes in size when compiled.
max_function_results: Option<usize>
The maximum number of results a Wasm function type can have.
Implementations§
Source§impl WasmLimits
impl WasmLimits
pub fn initial_memory_limit_pages(&self) -> u32
pub fn table_size_limit_elements(&self) -> u32
pub fn max_imports(&self) -> usize
pub fn max_functions(&self) -> usize
pub fn max_function_params(&self) -> usize
pub fn max_total_function_params(&self) -> usize
pub fn max_function_results(&self) -> usize
Trait Implementations§
Source§impl Clone for WasmLimits
impl Clone for WasmLimits
Source§fn clone(&self) -> WasmLimits
fn clone(&self) -> WasmLimits
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for WasmLimits
impl Debug for WasmLimits
Source§impl Default for WasmLimits
impl Default for WasmLimits
Source§fn default() -> WasmLimits
fn default() -> WasmLimits
Source§impl<'de> Deserialize<'de> for WasmLimits
impl<'de> Deserialize<'de> for WasmLimits
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for WasmLimits
impl RefUnwindSafe for WasmLimits
impl Send for WasmLimits
impl Sync for WasmLimits
impl Unpin for WasmLimits
impl UnwindSafe for WasmLimits
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.