Sigil documentation
ReferenceRust referencesigil-wasm

sigil-wasm · engine

Source declarations, signatures and documentation for engine.

Source: sigil/node/sigil-wasm/src/engine.rs. SHA-256: 800562ea44fce59e1b716202a68d3edda14bccf1a90d4655f153da1234221611.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

engine::MAX_CODE_SIZE

Hard upper bound on a contract's bytecode size, in bytes. Larger blobs are rejected at compile time to keep the on-chain code-blob store small. 2 MiB matches the common deployed-module limit on other chains and is generous for handwritten + simple agent contracts.

pub const MAX_CODE_SIZE: usize;

Source line: 15.

engine::MAX_MEMORY_PAGES

Hard upper bound on guest linear-memory pages (64 KiB each). 16 pages = 1 MiB. The guest may grow up to this limit; growing beyond traps with MemoryOutOfBounds.

pub const MAX_MEMORY_PAGES: u32;

Source line: 20.

engine::MAX_IO_BYTES

Hard upper bound on host-supplied call args / return blob, in bytes.

pub const MAX_IO_BYTES: usize;

Source line: 23.

engine::GAS_PER_FUEL

Wasmtime fuel-units per gas-unit. Each consumed fuel unit corresponds to one consumed gas unit; the conversion is 1:1 to keep gas accounting simple and deterministic.

pub const GAS_PER_FUEL: u64;

Source line: 28.

engine::ModuleCacheConfig

Process-local compiled-module cache limits. Both max_modules and max_bytes are enforced; the first limit reached triggers LRU eviction.

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ModuleCacheConfig {
pub max_modules: usize,
pub max_bytes: usize,
pub ttl: Duration
}

Source line: 40.

engine::ModuleCacheStats

Snapshot of the process-local compiled-module cache.

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct ModuleCacheStats {
pub entries: usize,
pub estimated_bytes: usize,
pub hits: u64,
pub misses: u64,
pub evictions: u64,
pub expired: u64
}

Source line: 58.

engine::WasmEngine

A configured wasmtime engine suitable for deterministic contract execution. Construct one per node and clone into per-call Stores.

#[derive(Clone)]
pub struct WasmEngine {

}

Source line: 261.

engine::WasmEngine::deterministic

Build a deterministic engine. Configuration:

  • consume_fuel: on (mandatory for gas metering)
  • wasm_threads: off (no concurrency from guest)
  • wasm_simd: off (NaN canonicalisation across platforms is not free; we ban SIMD for determinism)
  • wasm_relaxed_simd: off
  • wasm_reference_types: off
  • wasm_multi_memory: off
  • wasm_memory64: off
  • wasm_bulk_memory: on (deterministic; required by most toolchains)
  • wasm_multi_value: on (deterministic)
  • nan_canonicalization: on (forces canonical NaN bits; eliminates platform-specific NaN drift)
  • cranelift_pcc: off (proof-carrying-code is OK to leave default)
  • async_support: off
  • parallel_compilation: off (deterministic compile order)
pub fn deterministic() -> Result<Self, WasmError>;

Source line: 285.

engine::WasmEngine::compile

Compile contract bytecode. Bytecode size is bounded by MAX_CODE_SIZE; oversized blobs are rejected.

pub fn compile(&self, bytes: &[u8]) -> Result<Module, WasmError>;

Source line: 296.

engine::WasmEngine::compile_cached

Compile contract bytecode through the process-global LRU cache.

The cache is keyed by content hash and is performance-only: hash mismatch fails before lookup, and eviction/expiry can only force recompilation of the exact same bytes.

pub fn compile_cached(&self, code_hash: &SigilHash, bytes: &[u8]) -> Result<Module, WasmError>;

Source line: 313.

engine::WasmEngine::configure_module_cache

Reconfigure the process-global module cache and clear its contents. Intended for node startup configuration and tests.

pub fn configure_module_cache(config: ModuleCacheConfig) -> Result<(), WasmError>;

Source line: 340.

engine::WasmEngine::clear_module_cache

Clear the process-global module cache while retaining its limits.

pub fn clear_module_cache() -> Result<(), WasmError>;

Source line: 349.

engine::WasmEngine::module_cache_stats

Return current process-global module cache counters.

pub fn module_cache_stats() -> Result<ModuleCacheStats, WasmError>;

Source line: 358.

On this page