Skip to main content

ic_query/subnet_catalog/
mod.rs

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