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