Skip to main content

canic_core/dto/root_store/
mod.rs

1//! Passive contracts for one Fleet Subnet Root's initial local Wasm Store bootstrap.
2
3use crate::ids::{
4    CanisterRole, ComponentSpecId, ComponentTopologyDigest, FleetSubnetRootReleaseSet,
5    ReleaseBuildId,
6};
7use crate::role_contract::ProtocolProfileDigest;
8use candid::{CandidType, Principal};
9use serde::{Deserialize, Serialize};
10
11/// Maximum canonical root release-set manifest bytes admitted at the runtime boundary.
12pub const ROOT_STORE_RELEASE_SET_MANIFEST_MAX_BYTES: u64 = 16 * 1_024 * 1_024;
13/// Stable template prefix for a chunk-staged canonical root release-set manifest.
14pub const ROOT_STORE_RELEASE_SET_TEMPLATE_PREFIX: &str = "root-release-set:";
15/// Stable template prefix for one chunk-staged application artifact.
16pub const ROOT_STORE_ARTIFACT_TEMPLATE_PREFIX: &str = "component:";
17
18///
19/// RootStoreArtifact
20///
21/// Qualified immutable application artifact carried by one root release-set entry.
22///
23
24#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
25#[serde(deny_unknown_fields)]
26pub struct RootStoreArtifact {
27    pub role: CanisterRole,
28    pub package: String,
29    pub release_build_id: ReleaseBuildId,
30    pub wasm_relative_path: String,
31    pub wasm_size_bytes: u64,
32    pub wasm_sha256_hex: String,
33    pub wasm_gz_relative_path: String,
34    pub wasm_gz_size_bytes: u64,
35    pub wasm_gz_sha256_hex: String,
36    pub candid_sha256: [u8; 32],
37    pub protocol_profile_digest: ProtocolProfileDigest,
38}
39
40///
41/// RootStoreReleaseSetEntryKind
42///
43/// Structural use of one artifact within one exact Component Spec closure.
44///
45
46#[derive(
47    CandidType, Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
48)]
49pub enum RootStoreReleaseSetEntryKind {
50    #[serde(rename = "component")]
51    Component,
52
53    #[serde(rename = "component_child")]
54    ComponentChild,
55}
56
57///
58/// RootStoreReleaseSetEntry
59///
60/// One Spec-scoped artifact authorization from the canonical root release-set manifest.
61///
62
63#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
64#[serde(deny_unknown_fields)]
65pub struct RootStoreReleaseSetEntry {
66    pub component_spec: ComponentSpecId,
67    pub kind: RootStoreReleaseSetEntryKind,
68    pub artifact: RootStoreArtifact,
69}
70
71///
72/// RootStoreReleaseSetManifest
73///
74/// Runtime decoding shape for the host's exact canonical root release-set JSON bytes.
75///
76
77#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
78#[serde(deny_unknown_fields)]
79pub struct RootStoreReleaseSetManifest {
80    pub release_build_id: ReleaseBuildId,
81    pub component_topology_digest: ComponentTopologyDigest,
82    pub entries: Vec<RootStoreReleaseSetEntry>,
83}
84
85///
86/// RootStoreBootstrapRequest
87///
88/// Small bootstrap request referencing an already chunk-staged canonical manifest.
89///
90
91#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
92pub struct RootStoreBootstrapRequest {
93    pub operation_id: [u8; 32],
94    pub manifest_payload_size_bytes: u64,
95}
96
97///
98/// RootStoreCatalogEntry
99///
100/// Exact release-set identity retained after live root-local Store verification.
101///
102
103#[derive(CandidType, Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
104pub struct RootStoreCatalogEntry {
105    pub role: CanisterRole,
106    /// SHA-256 of the raw Wasm qualified by the release set.
107    pub raw_module_hash: [u8; 32],
108    /// SHA-256 of the exact canonical Candid qualified by the release set.
109    pub candid_sha256: [u8; 32],
110    /// Exact profile identity used to select the role binding before the first call.
111    pub protocol_profile_digest: ProtocolProfileDigest,
112    /// SHA-256 of the exact gzip payload retained by the Store.
113    pub payload_hash: [u8; 32],
114    pub payload_size_bytes: u64,
115}
116
117///
118/// RootStoreBootstrapResponse
119///
120/// Exact live Store evidence returned after root-side publication and verification.
121///
122
123#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
124pub struct RootStoreBootstrapResponse {
125    pub fleet_subnet_root: Principal,
126    pub wasm_store: Principal,
127    pub release_set: FleetSubnetRootReleaseSet,
128    pub catalog: Vec<RootStoreCatalogEntry>,
129}