Skip to main content

KernelAssist

Trait KernelAssist 

Source
pub trait KernelAssist {
    // Required methods
    fn gas_meter_get(&self, meter_id: MeterId) -> u64;
    fn gas_meter_set(&mut self, meter_id: MeterId, value: u64) -> u64;
    fn storage_quota_get(&self, quota_id: QuotaId) -> u64;
    fn storage_quota_set(&mut self, quota_id: QuotaId, value: u64) -> u64;
    fn yield_catcher_markers(&self, catcher_hash: CapHash) -> Vec<CapHash> ;
    fn yield_catcher_add(
        &mut self,
        catcher_hash: CapHash,
        marker_instance_hash: CapHash,
    );
    fn yield_catcher_remove(
        &mut self,
        catcher_hash: CapHash,
        marker_instance_hash: CapHash,
    );
    fn yield_catcher_new(&mut self) -> CapHash;

    // Provided methods
    fn host_open(&mut self, _file_id: u64) -> Option<CapHashOrRef> { ... }
    fn host_save(
        &mut self,
        _data: CapHashOrRef,
        _quota_id: u64,
        _size: u64,
    ) -> Option<u64> { ... }
}
Expand description

The integration point for kernel-assisted Instances.

Stage 3 wires the Vm to call these methods at:

  • per-instruction gas debit (gas_meter_*),
  • host_yield routing (yield_catcher_*),
  • host_mint_data_cap quota debit (storage_quota_*),
  • host_open / host_save resolved via cache references.

Methods on &self are reads; methods on &mut self are state mutations. Atomic semantics where the spec requires it (*_set returns the previous value).

Required Methods§

Source

fn gas_meter_get(&self, meter_id: MeterId) -> u64

Read the remaining gas for meter_id. Missing entry → 0.

Source

fn gas_meter_set(&mut self, meter_id: MeterId, value: u64) -> u64

Atomically GasMeter[meter_id] := value; return previous value (or 0 if no entry existed).

Source

fn storage_quota_get(&self, quota_id: QuotaId) -> u64

Source

fn storage_quota_set(&mut self, quota_id: QuotaId, value: u64) -> u64

Source

fn yield_catcher_markers(&self, catcher_hash: CapHash) -> Vec<CapHash>

Read the marker list for a YieldCatcher instance identified by catcher_hash. Order matters: routing walks the list and takes the first match.

Source

fn yield_catcher_add( &mut self, catcher_hash: CapHash, marker_instance_hash: CapHash, )

Add a marker template to the catcher’s list.

Source

fn yield_catcher_remove( &mut self, catcher_hash: CapHash, marker_instance_hash: CapHash, )

Remove a marker template. No-op if absent.

Source

fn yield_catcher_new(&mut self) -> CapHash

Mint a fresh empty YieldCatcher. Returns its content hash (which the caller stores as a Cap::Instance[YieldCatcher]).

Provided Methods§

Source

fn host_open(&mut self, _file_id: u64) -> Option<CapHashOrRef>

Materialize a σ-resident file as a cache reference (typically a CapHashOrRef::Hash of a published Cap::Data). None if the file_id isn’t registered.

Source

fn host_save( &mut self, _data: CapHashOrRef, _quota_id: u64, _size: u64, ) -> Option<u64>

Mint a new file from the cache reference data after debiting quota_id by the resolved DataCap size. Returns the new file_id. Default returns None (no file registry).

Implementors§