soroban_env_host::e2e_invoke

Function invoke_host_function

Source
pub fn invoke_host_function<T: AsRef<[u8]>, I: ExactSizeIterator<Item = T>>(
    budget: &Budget,
    enable_diagnostics: bool,
    encoded_host_fn: T,
    encoded_resources: T,
    encoded_source_account: T,
    encoded_auth_entries: I,
    ledger_info: LedgerInfo,
    encoded_ledger_entries: I,
    encoded_ttl_entries: I,
    base_prng_seed: T,
    diagnostic_events: &mut Vec<DiagnosticEvent>,
) -> Result<InvokeHostFunctionResult, HostError>
Expand description

Invokes a host function within a fresh host instance.

This collects the necessary inputs as encoded XDR and returns the outputs as encoded XDR as well. This is supposed to encapsulate all the metered operations needed to invoke a host function, including the input/output decoding/encoding.

In order to get clean budget metering data, a clean budget has to be provided as an input. It can then be examined immediately after execution in order to get the precise metering data. Budget is not reset in case of errors.

This may only fail when budget is exceeded or if there is an internal error. Host function invocation errors are stored within Ok(InvokeHostFunctionResult).

When diagnostics are enabled, we try to populate diagnostic_events even if the InvokeHostFunctionResult fails for any reason.