Struct sc_executor_wasmtime::RuntimeBlob
source · pub struct RuntimeBlob(/* private fields */);
Expand description
A program blob containing a Substrate runtime.
Implementations§
source§impl RuntimeBlob
impl RuntimeBlob
sourcepub fn uncompress_if_needed(wasm_code: &[u8]) -> Result<RuntimeBlob, WasmError>
pub fn uncompress_if_needed(wasm_code: &[u8]) -> Result<RuntimeBlob, WasmError>
Create RuntimeBlob
from the given WASM or PolkaVM compressed program blob.
See sp_maybe_compressed_blob
for details about decompression.
sourcepub fn new(raw_blob: &[u8]) -> Result<RuntimeBlob, WasmError>
pub fn new(raw_blob: &[u8]) -> Result<RuntimeBlob, WasmError>
Create RuntimeBlob
from the given WASM or PolkaVM program blob.
Returns Err
if the blob cannot be deserialized.
Will only accept a PolkaVM program if the SUBSTRATE_ENABLE_POLKAVM
environment
variable is set to 1
.
sourcepub fn inject_stack_depth_metering(
self,
stack_depth_limit: u32,
) -> Result<RuntimeBlob, WasmError>
pub fn inject_stack_depth_metering( self, stack_depth_limit: u32, ) -> Result<RuntimeBlob, WasmError>
Run a pass that instrument this module so as to introduce a deterministic stack height limit.
It will introduce a global mutable counter. The instrumentation will increase the counter
according to the “cost” of the callee. If the cost exceeds the stack_depth_limit
constant,
the instrumentation will trap. The counter will be decreased as soon as the the callee
returns.
The stack cost of a function is computed based on how much locals there are and the maximum depth of the wasm operand stack.
Only valid for WASM programs; will return an error if the blob is a PolkaVM program.
sourcepub fn convert_memory_import_into_export(&mut self) -> Result<(), WasmError>
pub fn convert_memory_import_into_export(&mut self) -> Result<(), WasmError>
Converts a WASM memory import into a memory section and exports it.
Does nothing if there’s no memory import.
May return an error in case the WASM module is invalid.
Only valid for WASM programs; will return an error if the blob is a PolkaVM program.
sourcepub fn setup_memory_according_to_heap_alloc_strategy(
&mut self,
heap_alloc_strategy: HeapAllocStrategy,
) -> Result<(), WasmError>
pub fn setup_memory_according_to_heap_alloc_strategy( &mut self, heap_alloc_strategy: HeapAllocStrategy, ) -> Result<(), WasmError>
Modifies the blob’s memory section according to the given heap_alloc_strategy
.
Will return an error in case there is no memory section present, or if the memory section is empty.
Only valid for WASM programs; will return an error if the blob is a PolkaVM program.
sourcepub fn custom_section_contents(&self, section_name: &str) -> Option<&[u8]>
pub fn custom_section_contents(&self, section_name: &str) -> Option<&[u8]>
Scans the wasm blob for the first section with the name that matches the given. Returns the
contents of the custom section if found or None
otherwise.
Only valid for WASM programs; will return an error if the blob is a PolkaVM program.
sourcepub fn as_polkavm_blob(&self) -> Option<&ProgramBlob<'_>>
pub fn as_polkavm_blob(&self) -> Option<&ProgramBlob<'_>>
Gets a reference to the inner PolkaVM program blob, if this is a PolkaVM program.
Trait Implementations§
source§impl Clone for RuntimeBlob
impl Clone for RuntimeBlob
source§fn clone(&self) -> RuntimeBlob
fn clone(&self) -> RuntimeBlob
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for RuntimeBlob
impl RefUnwindSafe for RuntimeBlob
impl Send for RuntimeBlob
impl Sync for RuntimeBlob
impl Unpin for RuntimeBlob
impl UnwindSafe for RuntimeBlob
Blanket Implementations§
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> 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, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.