Trait unc_vm_runner::VM
source · pub trait VM {
// Required methods
fn run(
&self,
code: &ContractCode,
method_name: &str,
ext: &mut dyn External,
context: VMContext,
fees_config: &RuntimeFeesConfig,
promise_results: &[PromiseResult],
cache: Option<&dyn CompiledContractCache>
) -> Result<VMOutcome, VMRunnerError>;
fn precompile(
&self,
code: &ContractCode,
cache: &dyn CompiledContractCache
) -> Result<Result<ContractPrecompilatonResult, CompilationError>, CacheError>;
}
Required Methods§
sourcefn run(
&self,
code: &ContractCode,
method_name: &str,
ext: &mut dyn External,
context: VMContext,
fees_config: &RuntimeFeesConfig,
promise_results: &[PromiseResult],
cache: Option<&dyn CompiledContractCache>
) -> Result<VMOutcome, VMRunnerError>
fn run( &self, code: &ContractCode, method_name: &str, ext: &mut dyn External, context: VMContext, fees_config: &RuntimeFeesConfig, promise_results: &[PromiseResult], cache: Option<&dyn CompiledContractCache> ) -> Result<VMOutcome, VMRunnerError>
Validate and run the specified contract.
This is the entry point for executing a UNC protocol contract. Before
the entry point (as specified by the method_name
argument) of the
contract code is executed, the contract will be validated (see
crate::prepare::prepare_contract
), instrumented (e.g. for gas
accounting), and linked with the externs specified via the ext
argument.
VMContext::input
will be passed to the contract entrypoint as an
argument.
The gas cost for contract preparation will be subtracted by the VM implementation.
sourcefn precompile(
&self,
code: &ContractCode,
cache: &dyn CompiledContractCache
) -> Result<Result<ContractPrecompilatonResult, CompilationError>, CacheError>
fn precompile( &self, code: &ContractCode, cache: &dyn CompiledContractCache ) -> Result<Result<ContractPrecompilatonResult, CompilationError>, CacheError>
Precompile a WASM contract to a VM specific format and store the result
into the cache
.
Further calls to Self::run
or Self::precompile
with the same
code
, cache
and Config
may reuse the results of this
precompilation step.