Skip to main content

SyncHost

Trait SyncHost 

Source
pub trait SyncHost: BaseHost {
    // Required methods
    fn get_mast_forest(&self, node_digest: &Word) -> Option<Arc<MastForest>>;
    fn on_event(
        &mut self,
        process: &ProcessorState<'_>,
    ) -> Result<Vec<AdviceMutation>, Box<dyn Error + Sync + Send>>;
}
Expand description

Defines a synchronous interface by which the VM can interact with the host during execution.

Required Methods§

Source

fn get_mast_forest(&self, node_digest: &Word) -> Option<Arc<MastForest>>

Returns MAST forest corresponding to the specified digest, or None if the MAST forest for this digest could not be found in this host.

Source

fn on_event( &mut self, process: &ProcessorState<'_>, ) -> Result<Vec<AdviceMutation>, Box<dyn Error + Sync + Send>>

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 (IDs 0-255) are handled by the VM before calling this method

Implementors§

Source§

impl<D, S> SyncHost for DefaultHost<D, S>
where D: DebugHandler, S: SourceManager,

Source§

impl<S> SyncHost for TestHost<S>
where S: SourceManagerSync,