Crate arb_stylus

Crate arb_stylus 

Source
Expand description

Stylus WASM smart contract runtime.

Provides the execution pipeline for Stylus programs: WASM compilation and caching, ink metering, host I/O functions, and EVM interop.

Re-exports§

pub use cache::InitCache;
pub use config::CompileConfig;
pub use config::StylusConfig;
pub use error::MaybeEscape;
pub use error::StylusError;
pub use evm_api::EvmApi;
pub use evm_api_impl::StylusEvmApi;
pub use ink::Gas;
pub use ink::Ink;
pub use meter::MachineMeter;
pub use meter::MeteredMachine;
pub use meter::STYLUS_ENTRY_POINT;
pub use native::NativeInstance;
pub use native::compile_module;
pub use run::RunProgram;

Modules§

cache
config
env
error
Error types raised by the Stylus runtime.
evm_api
evm_api_impl
host
ink
meter
middleware
multi_gas
Per-host-call multi-gas dimension assignment for Stylus execution: each host op contributes the same per-dimension gas as the equivalent EVM opcode. Framework gas (host ink, the EVM-API surcharge, the per-call storage cache) is left undimensioned here and falls into the WasmComputation residual.
native
pricing
run
trace
Host-I/O trace buffer for debug_traceTransaction on Stylus programs.

Structs§

StylusRoot
A parsed Stylus root program. The on-chain layout is [0xEF, 0xF0, 0x02, dict, decompressed_len(4, big-endian), addr×20...], where each 20-byte address points to a fragment holding part of the compressed WASM.

Constants§

STYLUS_DISCRIMINANT
Prefix bytes that identify a Stylus WASM program in contract bytecode.
STYLUS_FRAGMENT_DISCRIMINANT
Fragment prefix: [0xEF, 0xF0, 0x01].
STYLUS_ROOT_DISCRIMINANT
Root Stylus program prefix: [0xEF, 0xF0, 0x02].

Functions§

activate_program
Activate a Stylus program.
compress_classic_program_code
Compress raw WASM into classic Stylus contract bytecode.
decompress_wasm
Decompress a Stylus WASM program from its contract bytecode.
fragment_read_gas
Gas charged for reading one fragment of code_size bytes during activation, matching fragmentReadGasCost: a cold (or warm) account access plus the per-word copy cost. The fragment-read charger uses this for both the preflight affordability check (against the max code size) and the actual per-fragment charge.
get_wasm_from_root
Reconstruct the WASM of a root Stylus program: read each fragment’s deployed bytecode via read_code, strip its prefix, concatenate the compressed payloads, and decompress with the root’s dictionary. When enforce is set (i.e. activation), the decompressed-length and fragment-count limits are applied; reads otherwise only reconstruct the program.
is_stylus_classic
Returns true if the bytecode is a classic Stylus program ([0xEF, 0xF0, 0x00, ...]).
is_stylus_component
Returns true if the bytecode is a deployable Stylus component: a classic or root program, or (at the contract-limit version) a fragment. Used to permit storing such code despite its 0xEF prefix, mirroring IsStylusComponentPrefix.
is_stylus_deployable
Returns true if the bytecode is a deployable Stylus program.
is_stylus_fragment
Returns true if the bytecode is a Stylus fragment ([0xEF, 0xF0, 0x01, ...]).
is_stylus_program
Returns true if the bytecode is a Stylus WASM program.
is_stylus_root
Returns true if the bytecode is a Stylus root program ([0xEF, 0xF0, 0x02, ...]).
is_stylus_runnable
Returns true if the bytecode is a runnable Stylus program: a classic or a root program (a fragment is not runnable on its own). Root code can only have been deployed at the contract-limit version, so no version gate is needed here.
strip_stylus_prefix
Strips the 4-byte Stylus prefix from contract bytecode.