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