Expand description
CNodeCap — CNode cap: a sparse, Key-addressed key→cap map.
A CNode is a direct map from logical Key byte strings to
CapHashOrRef slot targets. There is no fixed capacity bound — a
CNode is bounded by storage quota, not a compile-time slot count.
A slot is named by a Key (a short byte string); CNodeCap::get
/ CNodeCap::set / CNodeCap::take operate on that logical key
directly. The V1 ABI uses single-byte keys (Key::from(b)), but the map
admits arbitrary-length keys natively (the same get/set/take
surface), so a future ABI can key e.g. address -> Cap::Instance with no
structural change. The raw &[u8] convenience form is exposed via
CNodeCap::get_key / CNodeCap::set_key / CNodeCap::take_key.
The hash-keyed radix tree is a commitment/proof representation, not the
runtime storage model. HashTreeRoot derives that
view on demand by hashing each logical key into a 32-byte radix path; normal
kernel execution never hashes a CNode key just to read or mutate a slot.
The leaf value is always a cap (CapHashOrRef), never raw data —
this is what lets a CNode model e.g. address -> Cap::Instance for
native contracts. A Missing(h) placeholder substitutes losslessly for
the materialized value whose hash_tree_root equals h, the
load-bearing property for cold-loading a CNode by hash.
§The O (owned-payload) parameter
CNodeCap<O> is generic over the inline CapHashOrRef::Owned(O) payload.
The default O = Box<Cap> is the wire/content-addressed form: the cnode
inside a serialised Cap (Cap::CNode, InstanceCap.root_cnode) is
always CNodeCap<Box<Cap>>, so the wire type is unaffected by this
parameter. An engine that needs to attach engine-private state to a
resident instance instantiates the running frame’s cnode with a richer
payload (e.g. Box<CachedCap> in the recompiler) — that payload is
deliberately not wire-serialisable, so a cache-carrying cnode cannot
cross the host/guest boundary or be content-hashed (a compile error, not
a runtime panic). See CapHashOrRef for the gate.
Structs§
- ArchivedC
Node Cap - An archived
CNodeCap - ArchivedC
Node Slots - An archived
CNodeSlots - CNode
Cap - CNode cap: a sparse, direct
Key -> CapHashOrRef<O>map. - CNode
CapResolver - The resolver for an archived
CNodeCap - CNode
Slots - Direct runtime slot map backing a CNode:
Key -> CapHashOrRef<O>. - CNode
Slots Resolver - The resolver for an archived
CNodeSlots
Constants§
- CNODE_
COMMITMENT_ KEY_ BYTES - Commitment radix-key width: a 32-byte digest of the logical key.