pub struct Nub { /* private fields */ }Expand description
Uniform handle to the nub microkernel.
Implementations§
Source§impl Nub
impl Nub
Sourcepub fn hyperlight() -> Result<HyperlightNubGuard>
pub fn hyperlight() -> Result<HyperlightNubGuard>
Borrow the process-wide Hyperlight-backed Nub loaded from the
nub-arch-x86 guest blob.
pub fn hyperlight_with_options( options: NubOptions, ) -> Result<HyperlightNubGuard>
Sourcepub fn state_root(&self) -> CapHash
pub fn state_root(&self) -> CapHash
Current state root.
Sourcepub fn evict_jit_all(&self) -> Result<()>
pub fn evict_jit_all(&self) -> Result<()>
Bench-only: clear the guest’s JIT compile cache so the next
invoke_cached pays a full recompile. No-op on the Local
backend (which uses the interpreter and has no JIT cache).
Sourcepub fn put_cap(&self, cap: &Cap) -> Result<AbiCapHash>
pub fn put_cap(&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(&self, hash: AbiCapHash, cap: &Cap) -> Result<()>
pub fn put_cap_with_hash(&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 on a host-side set of blob
hashes this sandbox has already published. 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 HashSet::contains. (The host does
not read the guest’s CacheDirectory directly: it is a hashbrown
table built with a different SIMD Group width than the host’s,
so a cross-binary deref is unsound — see
nub-host-kvm::MultiUseSandbox::published_blobs.)
Sourcepub fn submit_invoke(&self, request: InvokeRequest) -> Result<InvokeJob>
pub fn submit_invoke(&self, request: InvokeRequest) -> Result<InvokeJob>
Submit an invocation to the singleton Nub and return a job handle. Jobs are queued onto a fixed Nub-owned host executor; Hyperlight execution then runs on the sandbox’s fixed vCPU worker lanes.
Sourcepub fn invoke_cached(
&self,
instance_hash: AbiCapHash,
endpoint_idx: u8,
args: [u64; 4],
initial_gas: u64,
) -> Result<InvocationResult>
pub fn invoke_cached( &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.