Skip to main content

image_cap

Function image_cap 

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

Build an ImageCap from the SSZ-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):

  • per-endpoint arg_registers: the calling convention is implicit in the new shape. gas_slots and quota_slots remain image metadata and are carried through unchanged.

Field mappings:

  • Endpoints are stored in a sparse Key -> EndpointDef map (no fixed capacity). stack_top is extracted from the old initial_regs[1] (RISC-V SP convention); arg_cnode_slot defaults to Key::from(0).
  • MemoryMapping.source (a SlotPath) is carried through verbatim; paths that are empty or deeper than MAX_SOURCE_DEPTH error.