pub struct Nub { /* private fields */ }Expand description
Uniform handle to the nub microkernel.
Implementations§
Source§impl Nub
impl Nub
Sourcepub fn new_hyperlight() -> Result<Self>
pub fn new_hyperlight() -> Result<Self>
Construct a Nub backed by a fresh Hyperlight sandbox loaded
from the nub-arch-x86 guest blob.
Sourcepub fn invoke(
&mut self,
target: InstanceRef,
endpoint: u16,
args: &[u8],
opts: InvokeOptions,
) -> Result<InvokeOutcome>
pub fn invoke( &mut self, target: InstanceRef, endpoint: u16, args: &[u8], opts: InvokeOptions, ) -> Result<InvokeOutcome>
Invoke endpoint on target with args. Kernel-style entry
point — currently a skeleton returning 42 from both backends.
Sourcepub fn state_root(&self) -> CapHash
pub fn state_root(&self) -> CapHash
Current state root.
Sourcepub fn put_cap(&mut self, cap: &Cap) -> Result<AbiCapHash>
pub fn put_cap(&mut self, cap: &Cap) -> Result<AbiCapHash>
Put a caller-built Cap into the active cache. Computes
the cap’s content hash and either clones the cap on first put or
bumps refcount on idempotent re-put. Returns the cap’s content hash.
Sourcepub fn put_cap_with_hash(&mut self, hash: AbiCapHash, cap: &Cap) -> Result<()>
pub fn put_cap_with_hash(&mut self, hash: AbiCapHash, cap: &Cap) -> Result<()>
Pre-hashed variant. Caller computed ssz::hash_tree_root(cap)
at warmup and passes it explicitly; on the hot idempotent
path this lets both backends skip the SSZ merkleize entirely.
Debug-asserts the claimed hash matches the cap; release trusts
the caller.
Hyperlight backend: short-circuits to a host-side
GuestCacheReader::contains(hash) check against the guest’s
heap-resident CacheDirectory (mapped at the host’s matching
VA via the snapshot mapping). On a hit, no RPC roundtrip and
no guest-side merkle walk — the typical bench / replay
workload re-publishes the same cap graph every iteration and
pays only one host-side HashMap::contains_key.
Sourcepub fn invoke_cached(
&mut self,
instance_hash: AbiCapHash,
endpoint_idx: u8,
args: [u64; 4],
initial_gas: u64,
) -> Result<InvocationResult>
pub fn invoke_cached( &mut self, instance_hash: AbiCapHash, endpoint_idx: u8, args: [u64; 4], initial_gas: u64, ) -> Result<InvocationResult>
Invoke a previously-published Cap::Instance by hash. V0 args
are 4 u64s laid into φ[7..=10] on top of the published
endpoint’s initial_regs baseline.