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
16pub use error::CatalogError;
17#[cfg(feature = "subnet-catalog-host")]
18pub(crate) use host::subject_from_catalog_error;
19#[cfg(feature = "subnet-catalog-host")]
20pub use host::{
21    CacheDisposition, CatalogAuthorityEvidence, CatalogLoadOutcome, CatalogReadPolicy,
22    CatalogSourceSelection, SubnetCatalogCacheRequest, SubnetCatalogDetailedSourceFuture,
23    SubnetCatalogErrorCategory, SubnetCatalogErrorCode, SubnetCatalogFailureCacheDisposition,
24    SubnetCatalogField, SubnetCatalogHostError, SubnetCatalogLoadFailure,
25    SubnetCatalogLoadFailureRequest, SubnetCatalogLoadRequest, SubnetCatalogLoadStage,
26    SubnetCatalogRefreshRequest, SubnetCatalogRefreshTrigger, SubnetCatalogRemediation,
27    SubnetCatalogRetryability, SubnetCatalogSource, SubnetCatalogSourceFailure,
28    SubnetCatalogSourceFuture, SubnetCatalogSubject, SubnetCatalogUnknownRetryReason,
29    fetch_subnet_catalog_async, load_cached_subnet_catalog, load_cached_subnet_catalog_detailed,
30    load_subnet_catalog, load_subnet_catalog_async, load_subnet_catalog_detailed,
31    load_subnet_catalog_detailed_async, load_subnet_catalog_detailed_with_source,
32    load_subnet_catalog_detailed_with_source_async, load_subnet_catalog_with_source,
33    load_subnet_catalog_with_source_async, refresh_subnet_catalog, refresh_subnet_catalog_async,
34    refresh_subnet_catalog_with_source, refresh_subnet_catalog_with_source_async,
35    subnet_catalog_path, subnet_catalog_refresh_lock_path,
36};
37pub use json::{catalog_to_pretty_json, parse_catalog_json};
38#[cfg(feature = "subnet-catalog-host")]
39pub use model::UncertifiedCatalogCollection;
40#[cfg(feature = "certified-subnet-catalog-host")]
41pub(crate) use model::canonicalize_subnet_catalog_content;
42#[cfg(feature = "subnet-catalog-host")]
43pub(in crate::subnet_catalog) use model::catalog_agreement_digest;
44pub use model::{
45    CANISTER_RANGES_KEY_PREFIX, CLASSIFICATION_SCHEMA_VERSION, CatalogAssurance,
46    CatalogValidationContext, CertifiedRegistryCatalogEvidence, ClassificationSource,
47    GeographicScope, RESOLVER_SCHEMA_VERSION, ROUTING_TABLE_KEY, RawSubnetCatalog, RoutingRange,
48    SUBNET_LIST_KEY, SUBNET_RECORD_KEY_PREFIX, SubnetCatalogProvenance,
49    SubnetCatalogRegistryRecordEvidence, SubnetCatalogRegistryRecordKind,
50    SubnetCatalogRegistryRecordSubject, SubnetCatalogRegistryValueEncoding,
51    SubnetCatalogRoutingSource, SubnetInfo, SubnetKind, SubnetSpecialization,
52    ValidatedSubnetCatalog,
53};
54pub use principal::canonical_principal_text;
55pub(crate) use principal::{parse_principal, principal_bytes};
56#[cfg(feature = "subnet-catalog-host")]
57pub use report::{
58    CatalogStaleStatus, SubnetCatalogFilters, SubnetCatalogInfoReport, SubnetCatalogInfoRequest,
59    SubnetCatalogListReport, SubnetCatalogListRequest, SubnetCatalogRefreshReport,
60    SubnetCatalogSubnetRow, build_subnet_catalog_info_report,
61    build_subnet_catalog_info_report_with_source, build_subnet_catalog_list_report,
62    build_subnet_catalog_list_report_with_source,
63};
64pub use resolver::{ResolveAs, ResolvedCanisterRoute, ResolvedSubnet, ResolvedSubnetSubject};
65#[cfg(feature = "subnet-catalog-host")]
66pub use text::{
67    subnet_catalog_info_report_text, subnet_catalog_list_report_text,
68    subnet_catalog_list_report_verbose_text, subnet_catalog_refresh_report_text,
69};
70#[cfg(feature = "subnet-catalog-host")]
71pub use time::catalog_stale_status;
72pub(crate) use time::format_utc_timestamp_secs;
73#[cfg(any(
74    feature = "dashboard-host",
75    feature = "icrc-host",
76    feature = "sns-host",
77    feature = "subnet-catalog-host"
78))]
79pub(crate) use time::parse_utc_timestamp_secs;
80
81pub const CATALOG_SCHEMA_VERSION: u32 = 1;
82pub const MAINNET_NETWORK: &str = "ic";
83pub const MAINNET_REGISTRY_CANISTER_ID: &str = "rwlgt-iiaaa-aaaaa-aaaaa-cai";
84#[cfg(feature = "subnet-catalog-host")]
85/// Maximum future timestamp skew accepted by default during catalog validation.
86pub const DEFAULT_CATALOG_MAX_FUTURE_SKEW_SECONDS: u64 = 5 * 60;
87#[cfg(feature = "subnet-catalog-host")]
88pub const DEFAULT_STALE_AFTER_SECONDS: u64 = 7 * 24 * 60 * 60;
89#[cfg(feature = "subnet-catalog-host")]
90pub const DEFAULT_REFRESH_LOCK_STALE_SECONDS: u64 = 30 * 60;
91#[cfg(feature = "subnet-catalog-host")]
92pub const DEFAULT_SUBNET_CATALOG_SOURCE_ENDPOINT: &str = "https://icp-api.io";
93#[cfg(feature = "subnet-catalog-host")]
94/// Minimum number of independent hosts required for endpoint agreement.
95pub const MIN_SUBNET_CATALOG_AGREEMENT_ENDPOINTS: usize = 2;
96#[cfg(feature = "subnet-catalog-host")]
97/// Maximum number of endpoints accepted by one bounded agreement collection.
98pub const MAX_SUBNET_CATALOG_AGREEMENT_ENDPOINTS: usize = 3;
99#[cfg(feature = "subnet-catalog-host")]
100pub(crate) const SUBNET_CATALOG_LIST_REPORT_SCHEMA_VERSION: u32 = 1;
101#[cfg(feature = "subnet-catalog-host")]
102pub(crate) const SUBNET_CATALOG_INFO_REPORT_SCHEMA_VERSION: u32 = 1;
103#[cfg(feature = "subnet-catalog-host")]
104pub(crate) const SUBNET_CATALOG_REFRESH_REPORT_SCHEMA_VERSION: u32 = 1;
105
106#[cfg(test)]
107mod core_tests;
108#[cfg(all(test, feature = "subnet-catalog-host"))]
109mod tests;