Skip to main content

ic_query/subnet_catalog/
mod.rs

1//! Cached NNS subnet catalog models, resolution helpers, builders.
2
3mod error;
4#[cfg(feature = "subnet-catalog-host")]
5mod host;
6mod json;
7mod model;
8mod principal;
9#[cfg(feature = "subnet-catalog-host")]
10mod report;
11mod resolver;
12#[cfg(feature = "subnet-catalog-host")]
13mod time;
14
15#[cfg(feature = "subnet-catalog-host")]
16pub use crate::ic_registry::RegistryHistoryCacheDisposition;
17#[cfg(feature = "subnet-catalog-host")]
18pub use crate::ic_registry::{SubnetCatalogProgress, SubnetCatalogProgressPhase};
19pub use error::CatalogError;
20#[cfg(feature = "subnet-catalog-host")]
21pub(crate) use host::subject_from_catalog_error;
22#[cfg(feature = "subnet-catalog-host")]
23pub use host::{
24    CacheDisposition, CatalogLoadOutcome, CatalogReadPolicy, CatalogSourceSelection,
25    LiveSubnetCatalogSource, SubnetCatalogCacheRequest, SubnetCatalogDetailedSourceFuture,
26    SubnetCatalogErrorCategory, SubnetCatalogErrorCode, SubnetCatalogFailureCacheDisposition,
27    SubnetCatalogFailureEvidence, SubnetCatalogField, SubnetCatalogHostError,
28    SubnetCatalogLoadFailure, SubnetCatalogLoadFailureRequest, SubnetCatalogLoadRequest,
29    SubnetCatalogLoadStage, SubnetCatalogRefreshRequest, SubnetCatalogRefreshTrigger,
30    SubnetCatalogRemediation, SubnetCatalogRetryability, SubnetCatalogSource,
31    SubnetCatalogSourceFailure, SubnetCatalogSourceFuture, SubnetCatalogSubject,
32    SubnetCatalogUnknownRetryReason, fetch_subnet_catalog_async, load_cached_subnet_catalog,
33    load_subnet_catalog, load_subnet_catalog_with_source,
34    load_subnet_catalog_with_source_and_progress, refresh_subnet_catalog,
35    refresh_subnet_catalog_with_source, subnet_catalog_path, subnet_catalog_refresh_lock_path,
36};
37#[cfg(feature = "subnet-catalog-host")]
38pub(crate) use host::{subnet_catalog_history_lock_path, subnet_catalog_history_path};
39
40pub use json::{catalog_to_pretty_json, parse_catalog_json};
41#[cfg(feature = "subnet-catalog-host")]
42pub use model::UncertifiedCatalogCollection;
43#[cfg(feature = "subnet-catalog-host")]
44pub(in crate::subnet_catalog) use model::catalog_agreement_digest;
45pub use model::{
46    CANISTER_RANGES_KEY_PREFIX, CLASSIFICATION_SCHEMA_VERSION, CatalogAssurance,
47    CatalogSnapshotAuthorityEvidence, CatalogValidationContext, ClassificationSource,
48    GeographicScope, RESOLVER_SCHEMA_VERSION, ROUTING_TABLE_KEY, RawSubnetCatalog, RoutingRange,
49    SUBNET_LIST_KEY, SUBNET_RECORD_KEY_PREFIX, SubnetCatalogProvenance,
50    SubnetCatalogRegistryRecordEvidence, SubnetCatalogRegistryRecordKind,
51    SubnetCatalogRegistryRecordSubject, SubnetCatalogRegistryValueEncoding,
52    SubnetCatalogRoutingSource, SubnetClassification, SubnetInfo, SubnetKind, SubnetSpecialization,
53    ValidatedSubnetCatalog,
54};
55pub use principal::canonical_principal_text;
56pub(crate) use principal::{parse_principal, principal_bytes};
57#[cfg(feature = "subnet-catalog-host")]
58pub use report::{
59    CatalogStaleStatus, SubnetCatalogFilters, SubnetCatalogInfoReport, SubnetCatalogInfoRequest,
60    SubnetCatalogListReport, SubnetCatalogListRequest, SubnetCatalogRefreshReport,
61    SubnetCatalogReportMetadata, SubnetCatalogSubnetRow, build_subnet_catalog_info_report,
62    build_subnet_catalog_info_report_with_source_and_progress, build_subnet_catalog_list_report,
63    build_subnet_catalog_list_report_with_source_and_progress,
64};
65pub use resolver::{ResolveAs, ResolvedCanisterRoute, ResolvedSubnet, ResolvedSubnetSubject};
66#[cfg(feature = "subnet-catalog-host")]
67pub use time::catalog_stale_status;
68
69/// Current persisted Subnet Catalog schema identifier; remains `1` before package 1.0.
70pub const CATALOG_SCHEMA_VERSION: u32 = 1;
71/// Network identity used by all mainnet catalog requests and snapshots.
72pub const MAINNET_NETWORK: &str = "ic";
73/// Canonical principal of the mainnet Registry canister.
74pub const MAINNET_REGISTRY_CANISTER_ID: &str = "rwlgt-iiaaa-aaaaa-aaaaa-cai";
75#[cfg(feature = "subnet-catalog-host")]
76/// Maximum future timestamp skew accepted by default during catalog validation.
77pub const DEFAULT_CATALOG_MAX_FUTURE_SKEW_SECONDS: u64 = 5 * 60;
78/// Default snapshot age threshold in seconds for reporting stale catalog data.
79#[cfg(feature = "subnet-catalog-host")]
80pub const DEFAULT_STALE_AFTER_SECONDS: u64 = 7 * 24 * 60 * 60;
81/// Default replica endpoint used for live Registry catalog collection.
82#[cfg(feature = "subnet-catalog-host")]
83pub const DEFAULT_SUBNET_CATALOG_SOURCE_ENDPOINT: &str = "https://icp-api.io";
84#[cfg(feature = "subnet-catalog-host")]
85/// Minimum number of independent hosts required for endpoint agreement.
86pub const MIN_SUBNET_CATALOG_AGREEMENT_ENDPOINTS: usize = 2;
87#[cfg(feature = "subnet-catalog-host")]
88/// Maximum number of endpoints accepted by one bounded agreement collection.
89pub const MAX_SUBNET_CATALOG_AGREEMENT_ENDPOINTS: usize = 3;
90#[cfg(feature = "subnet-catalog-host")]
91pub(crate) const SUBNET_CATALOG_LIST_REPORT_SCHEMA_VERSION: u32 = 1;
92#[cfg(feature = "subnet-catalog-host")]
93pub(crate) const SUBNET_CATALOG_INFO_REPORT_SCHEMA_VERSION: u32 = 1;
94#[cfg(feature = "subnet-catalog-host")]
95pub(crate) const SUBNET_CATALOG_REFRESH_REPORT_SCHEMA_VERSION: u32 = 1;
96
97#[cfg(test)]
98mod tests;