Skip to main content

Module image

Module image 

Source
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§

EndpointDef
Endpoint definition: entry PC + register conventions.
Image
Image: the program spec (code, endpoints, memory layout, slot declarations, pinned ro caps).
InitialDataCap
Initial Cap::Data content 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.
MemoryMapping
One mapped region. The kernel resolves source at instance start, reads the bytes from the resulting Cap::Data, and lays them at [start, start + size) in the address space. Whether the region is RO or RW is derived from whether source.target() is in Image.pinned_slots.

Enums§

PinnedCap
Pinned slot content. Only content-addressed cap kinds can be pinned (Data or Image). Cap::Data bytes 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 by Image’s ssz-derive impl.