Crate soroban_env_host

source ·
Expand description

This crate mainly exists to provide the Soroban Host type, which is the implementation of the Env interface between guest contract code and the host it runs within.

This crate also re-exports all of the content of the soroban_env_common crate for use by host (or contract local-testing) code. Most of the type and module definitions visible here are actually defined in the common crate.

When unit-testing contracts natively (not using wasm), developers may also wish to enable the "testutils" feature, which enables an interface on Host for registering other test contracts by ID.

The Host type provides some facilities above and beyond just the Env trait, including:

  • The budget module which is responsible for measuring and limiting execution costs in terms of CPU and memory.
  • The storage module which is responsible for providing an interface between contracts and their durable storage.

Re-exports§

Modules§

  • Auth conceptual overview
  • This module contains version constants (and other metadata) that are embedded in binaries (especially WASM binaries) compiled against a particular version of this crate. Versioning at this level provides an early diagnostic check for compatibility between a loaded WASM binary and the Env interface provided by the host, rather than a cryptic failure due to a runtime host function signature mismatch.
  • This module contains the Storage type and its supporting types, which provide the Host with access to durable ledger entries.
  • This module primarily provides the Vm type and the necessary name-lookup and runtime-dispatch mechanisms needed to allow WASM modules to call into the Env interface implemented by Host.

Macros§

Structs§

Enums§

  • This is just a distinct enum local to the env interface that is used as an argument to storage functions. It doesn’t correspond to any [Val] types, and is passed by direct marshalling as a u64.
  • Errors related to operations on the SymbolObject and SymbolSmall types.
  • Code values for the 8 tag bits in the bit-packed representation of Val. These don’t coincide with tag numbers in the SCVal XDR but cover all those cases as well as some optimized refinements for special cases (boolean true and false, small-value forms).

Constants§

Traits§

  • This trait is used by macro-generated dispatch and forwarding functions to check arguments being passed to the Env. The default implementations call through to the Env integrity-checking functions.
  • General trait representing the ability to compare two values of some type. Similar to core::cmp::Cmp but with two key differences: the comparison is fallible, and is provided by some external type implementing Compare rather than the compared type itself.
  • General trait representing a the ability of some object to perform a (possibly unsuccessful) conversion between two other types.
  • This trait represents the interface between Host and Guest, used by client contract code and implemented (via Env) by the host. It consists of functions that take or return only 64-bit values such as Val or u64.
  • Base trait extended by the Env trait, providing various special-case functions that do not simply call across cross the guest/host interface.
  • Trait for types that can be fallibly converted to another type V, analogous to the standard Rust type TryFrom, but making use of the provided Env implementation E in order to convert parts of the type that require it. Mainly this exists because Val types that contain object handles need to delegate to the environment to look up and extract the content of those handles.
  • The opposite trait to TryFromVal, analogous to the way that TryInto exists as an opposite to TryFrom. Exists only for convenience of doing conversions via .try_into_val(e) or specifying convertability with a bound like TryIntoVal<E,Other>.
  • This trait is a variant of the Env trait used to define the interface implemented by Host. The wasmi VM dispatch functions (in soroban_env_host::dispatch) call methods on VmCallerEnv, passing a VmCaller that wraps the wasmi Caller context, and then convert any Result::Err(...) return value into a VM trap, halting VM execution.

Type Aliases§