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_async, refresh_subnet_catalog, refresh_subnet_catalog_async,
38    refresh_subnet_catalog_with_source, refresh_subnet_catalog_with_source_async,
39    subnet_catalog_path, subnet_catalog_refresh_lock_path,
40};
41#[cfg(feature = "subnet-catalog-host")]
42pub(crate) use host::{subnet_catalog_history_lock_path, subnet_catalog_history_path};
43pub use json::{catalog_to_pretty_json, parse_catalog_json};
44#[cfg(feature = "subnet-catalog-host")]
45pub use model::UncertifiedCatalogCollection;
46#[cfg(feature = "certified-subnet-catalog-host")]
47pub(crate) use model::canonicalize_subnet_catalog_content;
48#[cfg(feature = "subnet-catalog-host")]
49pub(in crate::subnet_catalog) use model::catalog_agreement_digest;
50pub use model::{
51    CANISTER_RANGES_KEY_PREFIX, CLASSIFICATION_SCHEMA_VERSION, CatalogAssurance,
52    CatalogSnapshotAuthorityEvidence, CatalogValidationContext, CertifiedRegistryCatalogEvidence,
53    ClassificationSource, GeographicScope, RESOLVER_SCHEMA_VERSION, ROUTING_TABLE_KEY,
54    RawSubnetCatalog, RoutingRange, SUBNET_LIST_KEY, SUBNET_RECORD_KEY_PREFIX,
55    SubnetCatalogProvenance, SubnetCatalogRegistryRecordEvidence, SubnetCatalogRegistryRecordKind,
56    SubnetCatalogRegistryRecordSubject, SubnetCatalogRegistryValueEncoding,
57    SubnetCatalogRoutingSource, SubnetInfo, SubnetKind, SubnetSpecialization,
58    ValidatedSubnetCatalog,
59};
60pub use principal::canonical_principal_text;
61pub(crate) use principal::{parse_principal, principal_bytes};
62#[cfg(feature = "subnet-catalog-host")]
63pub use report::{
64    CatalogStaleStatus, SubnetCatalogFilters, SubnetCatalogInfoReport, SubnetCatalogInfoRequest,
65    SubnetCatalogListReport, SubnetCatalogListRequest, SubnetCatalogRefreshReport,
66    SubnetCatalogSubnetRow, build_subnet_catalog_info_report,
67    build_subnet_catalog_info_report_with_source, build_subnet_catalog_list_report,
68    build_subnet_catalog_list_report_with_source,
69};
70pub use resolver::{ResolveAs, ResolvedCanisterRoute, ResolvedSubnet, ResolvedSubnetSubject};
71#[cfg(feature = "subnet-catalog-host")]
72pub use text::{
73    subnet_catalog_info_report_text, subnet_catalog_list_report_text,
74    subnet_catalog_list_report_verbose_text, subnet_catalog_refresh_report_text,
75};
76#[cfg(feature = "subnet-catalog-host")]
77pub use time::catalog_stale_status;
78pub(crate) use time::format_utc_timestamp_secs;
79pub(crate) use time::parse_utc_timestamp_secs;
80
81/// Current persisted Subnet Catalog schema identifier; remains `1` before package 1.0.
82pub const CATALOG_SCHEMA_VERSION: u32 = 1;
83/// Network identity used by all mainnet catalog requests and snapshots.
84pub const MAINNET_NETWORK: &str = "ic";
85/// Canonical principal of the mainnet Registry canister.
86pub const MAINNET_REGISTRY_CANISTER_ID: &str = "rwlgt-iiaaa-aaaaa-aaaaa-cai";
87#[cfg(feature = "subnet-catalog-host")]
88/// Maximum future timestamp skew accepted by default during catalog validation.
89pub const DEFAULT_CATALOG_MAX_FUTURE_SKEW_SECONDS: u64 = 5 * 60;
90/// Default snapshot age threshold in seconds for reporting stale catalog data.
91#[cfg(feature = "subnet-catalog-host")]
92pub const DEFAULT_STALE_AFTER_SECONDS: u64 = 7 * 24 * 60 * 60;
93/// Default age in seconds beyond which a catalog refresh lock is stale.
94#[cfg(feature = "subnet-catalog-host")]
95pub const DEFAULT_REFRESH_LOCK_STALE_SECONDS: u64 = 30 * 60;
96/// Default replica endpoint used for live Registry catalog collection.
97#[cfg(feature = "subnet-catalog-host")]
98pub const DEFAULT_SUBNET_CATALOG_SOURCE_ENDPOINT: &str = "https://icp-api.io";
99#[cfg(feature = "subnet-catalog-host")]
100/// Minimum number of independent hosts required for endpoint agreement.
101pub const MIN_SUBNET_CATALOG_AGREEMENT_ENDPOINTS: usize = 2;
102#[cfg(feature = "subnet-catalog-host")]
103/// Maximum number of endpoints accepted by one bounded agreement collection.
104pub const MAX_SUBNET_CATALOG_AGREEMENT_ENDPOINTS: usize = 3;
105#[cfg(feature = "subnet-catalog-host")]
106pub(crate) const SUBNET_CATALOG_LIST_REPORT_SCHEMA_VERSION: u32 = 1;
107#[cfg(feature = "subnet-catalog-host")]
108pub(crate) const SUBNET_CATALOG_INFO_REPORT_SCHEMA_VERSION: u32 = 1;
109#[cfg(feature = "subnet-catalog-host")]
110pub(crate) const SUBNET_CATALOG_REFRESH_REPORT_SCHEMA_VERSION: u32 = 1;
111
112#[cfg(test)]
113mod core_tests;
114#[cfg(all(test, feature = "subnet-catalog-host"))]
115mod tests;