Skip to content

sgns::runtime::binaryen::RuntimeManager

RuntimeManager is a mechanism to prepare environment for launching execute() function of runtime APIs. It supports in-memory cache to reuse existing environments, avoid hi-load operations.

#include <runtime_manager.hpp>

Public Types

Name
enum class Error

Public Functions

Name
RuntimeManager(std::shared_ptr< extensions::ExtensionFactory > extension_factory, std::shared_ptr< WasmModuleFactory > module_factory, std::shared_ptr< TrieStorageProvider > storage_provider, std::shared_ptr< crypto::Hasher > hasher)
outcome::result< RuntimeEnvironment > createPersistentRuntimeEnvironment(const base::Buffer & state_code)
outcome::result< RuntimeEnvironment > createEphemeralRuntimeEnvironment(const base::Buffer & state_code)
outcome::result< RuntimeEnvironment > createPersistentRuntimeEnvironmentAt(const base::Buffer & state_code, const base::Hash256 & state_root)
outcome::result< RuntimeEnvironment > createEphemeralRuntimeEnvironmentAt(const base::Buffer & state_code, const base::Hash256 & state_root)

Public Types Documentation

enum Error

Enumerator Value Description
EMPTY_STATE_CODE 1

Public Functions Documentation

function RuntimeManager

RuntimeManager(
    std::shared_ptr< extensions::ExtensionFactory > extension_factory,
    std::shared_ptr< WasmModuleFactory > module_factory,
    std::shared_ptr< TrieStorageProvider > storage_provider,
    std::shared_ptr< crypto::Hasher > hasher
)

function createPersistentRuntimeEnvironment

outcome::result< RuntimeEnvironment > createPersistentRuntimeEnvironment(
    const base::Buffer & state_code
)

function createEphemeralRuntimeEnvironment

outcome::result< RuntimeEnvironment > createEphemeralRuntimeEnvironment(
    const base::Buffer & state_code
)

function createPersistentRuntimeEnvironmentAt

outcome::result< RuntimeEnvironment > createPersistentRuntimeEnvironmentAt(
    const base::Buffer & state_code,
    const base::Hash256 & state_root
)

Warning: calling this with an

  • state_root older than the current root will reset the storage to an older state once changes are committed

function createEphemeralRuntimeEnvironmentAt

outcome::result< RuntimeEnvironment > createEphemeralRuntimeEnvironmentAt(
    const base::Buffer & state_code,
    const base::Hash256 & state_root
)

Updated on 2026-03-04 at 13:10:43 -0800