Expand description
Image: the smallest unit of program specification.
An Image is content-addressed (its image_id is the hash of
its serialized content). An Instance’s image_hash is the
cumulative chain hash tracking the lineage of set_image /
host_derive_spawn extensions from genesis.
genesis (host_derive_spawn from no source):
image_hash = hash(image)
after set_image(new):
image_hash = hash(prev_chain || hash(new))
after host_derive_spawn(new, cnode) by a spawner:
spawned.image_hash = hash(spawner.image_hash || hash(new))
after MGMT_COPY of a Cap::Instance:
copy.image_hash = source.image_hash (preserved)This module provides the pure data structures + the chain-hash
computations. Image content hashing is done by serializing the
Image canonically and feeding the bytes to H::hash; we provide
a simple deterministic encoder here so the v3 implementation
has one canonical form.
Structs§
- Arena
Page Ref - One non-zero page of a
DataDesc: logical pagepage_indexis backed by the arena windowarena[arena_off .. arena_off + len], zero-padded toPAGE_SIZEwhen materialized.len(1..=PAGE_SIZE) stores only the page’s meaningful prefix — trailing zeros within the page are dropped, so a sub-page-dense region costslenbytes, not a full page. Windows are packed tightly (noarena_offalignment). Pages not named by anyArenaPageRefare the canonical zero page (PageSlot::Empty). - CodeRef
- A slice of the Image
arenaholding the contiguous code region:arena[arena_off .. arena_off + len]are the raw RV+C+custom-0 bytes, mapped RO atcrate::layout::CODE_BASE.lenis the exact (non-page-rounded) code length — the recompiler andalloc_page_aligned_codeiterate exactlylenbytes — while the arena window itself is page-rounded.CodeRef::default()({0, 0}) is a codeless image. - Data
Desc - Page-granular sparse content of a data cap.
sizeis the full logical extent in bytes (aPAGE_SIZEmultiple);pagesnames only the non-zero pages, sorted bypage_index(strictly ascending, unique), each backed by an arena window of its non-zero prefix (zero-padded back toPAGE_SIZEat decode) — seeArenaPageRef. - Endpoint
Def - Endpoint definition: entry PC + register conventions.
- Image
- Image: the program spec (code, endpoints, memory layout, slot declarations, pinned ro caps).
- Image
Builder - Canonical Image assembler. Callers supply logical content (code +
per-slot contiguous bytes + size, exactly as before the arena
redesign);
buildpacks a single page-granulararenadeterministically: code laid contiguously at offset 0, then each data cap (pinned then initial, inKeyorder) page-split with all-zero pages elided and byte-identical pages deduplicated. The packing is a pure function of the logical content, so equal logical Images produce equal arenas and equalimage_content_hashes regardless of builder call order. - Memory
Mapping - One mapped region. The kernel resolves
source(a cnode slot path to aCap::Data) at instance start and lays the bytes at[start, start + size)in the address space. RO vs RW is derived from whether the target slot is inImage.pinned_slots.
Enums§
- Data
Desc Error - Structural faults in a
DataDescrelative to the Image arena, surfaced eagerly at deblob (per the strict-interface rule: fail loud). - Pinned
Cap - Pinned slot content. Only content-addressed cap kinds can be
pinned (Data or Image).
Cap::Databytes are inlined in the Image; a future optimisation can add a hash-only variant for content that lives in σ.data_payloads.
Functions§
- chain_
extend - Extend an image-hash chain with a new image:
result = H(prev_chain || image_content_hash(new_image)). - chain_
genesis - Genesis image-hash chain: a freshly-derived Instance (with no
prior chain) has
image_hash = image_content_hash. - image_
content_ hash - Content hash of an Image: SSZ
hash_tree_root(SHA-256 merkleization of the derived SSZ container). The canonical encoding/merkleization is defined byImage’sssz-deriveimpl.
Type Aliases§
- Initial
Data Cap - Initial
Cap::Datacontent for a non-pinned mutable slot. Used at standalone (root) Instance bootstrap to seed the cnode. A parented Instance receives its slots from the spawner and ignores this field.