Skip to main content

image_cap

Function image_cap 

Source
pub fn image_cap(
    image: &Image,
    pinned_hashes: &[(SlotIdx, CapHash)],
    initial_hashes: &[(SlotIdx, CapHash)],
) -> Result<ImageCap, ImageConvertError>
Expand description

Build an ImageCap from the SCALE-encoded crate::image::Image shape. The Data content referenced by pinned and initial slots must already be published — pass the resolved (SlotIdx, CapHash) pairs in pinned_hashes and initial_hashes. The builder sorts both lists by slot index.

Lossy fields (intentionally dropped):

  • gas_slots / quota_slots: gas is now tracked on super::instance::InstanceCap::gas_remaining; the v3 cap shape no longer pins gas/quota slots in the Image.
  • per-endpoint arg_registers: the calling convention is implicit in the new shape.

Field mappings:

  • Endpoints are stored in a dense MAX_ENDPOINTS-sized array, indexed by endpoint id. Empty slots use EndpointDef::empty. stack_top is extracted from the old initial_regs[1] (RISC-V SP convention); arg_cnode_slot defaults to SlotIdx(0).
  • MemoryMapping.source: SlotPath becomes source_path: [SlotIdx; MAX_SOURCE_DEPTH] + source_path_len; paths deeper than 8 error.