pub trait Host: BaseHost {
// Required methods
fn get_mast_forest(
&self,
node_digest: &Word,
) -> impl FutureMaybeSend<Option<LoadedMastForest>>;
fn on_event(
&mut self,
process: &ProcessorState<'_>,
) -> impl FutureMaybeSend<Result<Vec<AdviceMutation>, EventError>>;
// Provided method
fn on_trace(
&mut self,
_process: &ProcessorState<'_>,
) -> impl FutureMaybeSend<Result<(), TraceError>> { ... }
}Expand description
Defines an async interface by which the VM can interact with the host during execution.
This mirrors the historic async host surface while allowing the sync-first core to depend on
BaseHost.
Required Methods§
Sourcefn get_mast_forest(
&self,
node_digest: &Word,
) -> impl FutureMaybeSend<Option<LoadedMastForest>>
fn get_mast_forest( &self, node_digest: &Word, ) -> impl FutureMaybeSend<Option<LoadedMastForest>>
Returns MAST forest corresponding to the specified digest, or None if the MAST forest for this digest could not be found in this host.
Sourcefn on_event(
&mut self,
process: &ProcessorState<'_>,
) -> impl FutureMaybeSend<Result<Vec<AdviceMutation>, EventError>>
fn on_event( &mut self, process: &ProcessorState<'_>, ) -> impl FutureMaybeSend<Result<Vec<AdviceMutation>, EventError>>
Handles the event emitted from the VM and provides advice mutations to be applied to the advice provider.
The event ID is available at the top of the stack (position 0) when this handler is called. This allows the handler to access both the event ID and any additional context data that may have been pushed onto the stack prior to the emit operation.
§Implementation notes
- Extract the event ID via
EventId::from_felt(process.get_stack_item(0)) - Return errors without event names or IDs - the caller will enrich them via
BaseHost::resolve_event() - System events are handled by the VM before and don’t call this method
Provided Methods§
Sourcefn on_trace(
&mut self,
_process: &ProcessorState<'_>,
) -> impl FutureMaybeSend<Result<(), TraceError>>
fn on_trace( &mut self, _process: &ProcessorState<'_>, ) -> impl FutureMaybeSend<Result<(), TraceError>>
Handles a trace event emitted from the VM.
Trace events are optional, read-only events. SystemEvent::TraceEvent is at stack
position 0 and the user trace event ID is at position 1 when this handler is called. The
handler cannot mutate the advice provider. Hosts that do not care about trace events can use
this default no-op implementation. Hosts are expected to nat raise an error on encountering
a trace event for which no handler is registered.
Return errors without event names or IDs - the caller will enrich them via
BaseHost::resolve_trace().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".