Skip to main content

ic_query/ic/
mod.rs

1//! Certified IC state and official Dashboard report models, adapters, builders, and renderers.
2
3mod api_boundary_node;
4#[cfg(feature = "dashboard-host")]
5mod build;
6#[cfg(feature = "dashboard-host")]
7mod live;
8mod model;
9mod node_status;
10#[cfg(feature = "dashboard-host")]
11mod source;
12mod text;
13
14pub use api_boundary_node::{
15    DEFAULT_IC_STATE_SOURCE_ENDPOINT, IC_API_BOUNDARY_NODE_REPORT_SCHEMA_VERSION,
16    IcApiBoundaryNodeReport, IcApiBoundaryNodeRequest, IcApiBoundaryNodeRow,
17    IcCertifiedStateProvenance, MAX_IC_API_BOUNDARY_NODE_ROWS, ic_api_boundary_node_report_text,
18};
19#[cfg(feature = "ic-state-host")]
20pub use api_boundary_node::{
21    IcApiBoundaryNodeHostError, IcApiBoundaryNodeSource, IcApiBoundaryNodeSourceData,
22    IcApiBoundaryNodeSourceRequest, LiveIcStateSource, build_ic_api_boundary_node_report,
23    build_ic_api_boundary_node_report_with_source,
24};
25#[cfg(feature = "dashboard-host")]
26pub use build::{
27    build_ic_boundary_node_data_centers_report,
28    build_ic_boundary_node_data_centers_report_with_source, build_ic_canister_count_report,
29    build_ic_canister_count_report_with_source, build_ic_canister_page_report,
30    build_ic_canister_page_report_with_source, build_ic_daily_stats_report,
31    build_ic_daily_stats_report_with_source, build_ic_metric_report,
32    build_ic_metric_report_with_source, build_ic_node_provider_reward_history_report,
33    build_ic_node_provider_reward_history_report_with_source,
34    build_ic_node_provider_reward_info_report,
35    build_ic_node_provider_reward_info_report_with_source,
36    build_ic_node_provider_reward_list_report,
37    build_ic_node_provider_reward_list_report_with_source, build_ic_node_status_snapshot,
38    build_ic_node_status_snapshot_with_source, build_ic_replica_version_info_report,
39    build_ic_replica_version_info_report_with_source, build_ic_replica_version_list_report,
40    build_ic_replica_version_list_report_with_source, build_icrc_account_info_report,
41    build_icrc_account_info_report_with_source, build_icrc_account_list_report,
42    build_icrc_account_list_report_with_source, build_icrc_holder_list_report,
43    build_icrc_holder_list_report_with_source, build_icrc_indexed_count_report,
44    build_icrc_indexed_count_report_with_source, build_icrc_token_value_report,
45    build_icrc_token_value_report_with_source, build_icrc_total_supply_report,
46    build_icrc_total_supply_report_with_source,
47};
48#[cfg(feature = "dashboard-host")]
49pub use build::{build_ic_canister_report, build_ic_canister_report_with_source};
50#[cfg(feature = "dashboard-host")]
51pub use live::LiveIcSource;
52pub use model::{
53    IcBoundaryNodeDataCenterRow, IcBoundaryNodeDataCentersReport, IcBoundaryNodeDataCentersRequest,
54    IcCanisterCountReport, IcCanisterCountRequest, IcCanisterFilters, IcCanisterPageController,
55    IcCanisterPageReport, IcCanisterPageRequest, IcCanisterPageRow, IcCanisterReport,
56    IcCanisterRequest, IcCanisterUpgrade, IcDailyStatsQuery, IcDailyStatsReport,
57    IcDailyStatsRequest, IcDailyStatsRow, IcDashboardReportProvenance, IcIcrcAccountInfoReport,
58    IcIcrcAccountInfoRequest, IcIcrcAccountListQuery, IcIcrcAccountListReport,
59    IcIcrcAccountListRequest, IcIcrcAccountRow, IcIcrcAccountSort, IcIcrcAnalyticsRequest,
60    IcIcrcHolderListQuery, IcIcrcHolderListReport, IcIcrcHolderListRequest, IcIcrcHolderRow,
61    IcIcrcHolderSort, IcIcrcIndexedCountKind, IcIcrcIndexedCountReport, IcIcrcIndexedCountRequest,
62    IcIcrcTokenValueQuery, IcIcrcTokenValueReport, IcIcrcTokenValueRequest, IcIcrcTokenValueRow,
63    IcIcrcTotalSupplyObservation, IcIcrcTotalSupplyQuery, IcIcrcTotalSupplyReport,
64    IcIcrcTotalSupplyRequest, IcMetricKind, IcMetricObservation, IcMetricQuery, IcMetricReport,
65    IcMetricRequest, IcMetricSeries, IcNodeProviderRewardHistoryObservation,
66    IcNodeProviderRewardHistoryQuery, IcNodeProviderRewardHistoryReport,
67    IcNodeProviderRewardHistoryRequest, IcNodeProviderRewardInfoReport,
68    IcNodeProviderRewardInfoRequest, IcNodeProviderRewardListQuery, IcNodeProviderRewardListReport,
69    IcNodeProviderRewardListRequest, IcNodeProviderRewardRow,
70    IcNodeProviderRewardXdrConversionRate, IcReplicaVersionInfoReport, IcReplicaVersionInfoRequest,
71    IcReplicaVersionListQuery, IcReplicaVersionListReport, IcReplicaVersionListRequest,
72    IcReplicaVersionListRow, IcReplicaVersionStatus, IcReplicaVersionSubnetRollout,
73};
74#[cfg(feature = "dashboard-host")]
75pub use model::{
76    IcBoundaryNodeDataCentersSourceData, IcCanisterCountSourceData, IcCanisterPageSourceData,
77    IcCanisterSourceData, IcDailyStatsSourceData, IcHostError, IcIcrcAccountInfoSourceData,
78    IcIcrcAccountListSourceData, IcIcrcAccountSourceRow, IcIcrcHolderListSourceData,
79    IcIcrcHolderSourceRow, IcIcrcIndexedCountSourceData, IcIcrcTokenValueSourceData,
80    IcIcrcTokenValueSourceRow, IcIcrcTotalSupplySourceData, IcMetricSourceData,
81    IcNodeProviderRewardHistorySourceData, IcNodeProviderRewardInfoSourceData,
82    IcNodeProviderRewardListSourceData, IcReplicaVersionInfoSourceData,
83    IcReplicaVersionListSourceData, IcSourceRequest,
84};
85#[cfg(feature = "dashboard-host")]
86pub(crate) use node_status::canonicalize_node_status_rows_with_policy;
87#[cfg(feature = "dashboard-host")]
88pub(crate) use node_status::node_status_counts;
89pub use node_status::{
90    DEFAULT_IC_NODE_STATUS_REFRESH_LOCK_STALE_SECONDS, DEFAULT_IC_NODE_STATUS_STALE_AFTER_SECONDS,
91    IC_NODE_STATUS_SCHEMA_VERSION, IcNodeAssignmentStatusCounts, IcNodeCountComparison,
92    IcNodeCountComparisonCounts, IcNodeOperationalStatus, IcNodeProviderStatusReport,
93    IcNodeProviderStatusRow, IcNodeStatusCacheEvidence, IcNodeStatusCounts,
94    IcNodeStatusGroupCounts, IcNodeStatusObservation, IcNodeStatusProjectionError,
95    IcNodeStatusReport, IcNodeStatusRow, IcNodeStatusScope, IcNodeStatusSnapshot,
96    IcNodeStatusSnapshotRequest, IcNodeStatusView, IcSubnetStatusReport, IcSubnetStatusRow,
97    MAX_IC_NODE_STATUS_ROWS, ic_node_provider_status_report_from_snapshot,
98    ic_node_provider_status_report_text, ic_node_status_report_from_snapshot,
99    ic_node_status_report_text, ic_subnet_status_report_from_snapshot,
100    ic_subnet_status_report_text,
101};
102#[cfg(feature = "dashboard-host")]
103pub use node_status::{
104    IcNodeStatusCacheRequest, IcNodeStatusHostError, IcNodeStatusReadRequest,
105    IcNodeStatusRefreshReport, IcNodeStatusRefreshRequest, IcNodeStatusSourceData,
106    build_ic_node_provider_status_report, build_ic_node_provider_status_report_with_source,
107    build_ic_node_status_report, build_ic_node_status_report_with_source,
108    build_ic_subnet_status_report, build_ic_subnet_status_report_with_source,
109    ic_node_status_cache_path, ic_node_status_refresh_lock_path,
110    ic_node_status_refresh_report_text, load_cached_ic_node_status_snapshot,
111    load_or_refresh_missing_ic_node_status_snapshot,
112    load_or_refresh_missing_ic_node_status_snapshot_with_source,
113    load_or_refresh_stale_ic_node_status_snapshot,
114    load_or_refresh_stale_ic_node_status_snapshot_with_source, refresh_ic_node_status_snapshot,
115    refresh_ic_node_status_snapshot_with_source,
116};
117#[cfg(feature = "dashboard-host")]
118pub use source::{
119    IcCanisterCollectionSource, IcCanisterSource, IcIcrcAnalyticsSource, IcIcrcIndexSource,
120    IcMetricSource, IcNetworkSource, IcNodeProviderRewardSource, IcNodeStatusSource,
121    IcReplicaVersionSource,
122};
123#[cfg(feature = "dashboard-host")]
124pub(crate) use source::{
125    canonical_request_principal, dashboard_source_request, invalid_source, invalid_source_value,
126    report_provenance, validate_canonical_principal, validate_dashboard_network,
127    validate_provenance,
128};
129pub(crate) use text::dashboard_provenance_lines;
130pub use text::{
131    ic_boundary_node_data_centers_report_text, ic_canister_count_report_text,
132    ic_canister_page_report_text, ic_canister_report_text, ic_daily_stats_report_text,
133    ic_metric_report_text, ic_node_provider_reward_history_report_text,
134    ic_node_provider_reward_info_report_text, ic_node_provider_reward_list_report_text,
135    ic_replica_version_info_report_text, ic_replica_version_list_report_text,
136    icrc_account_info_report_text, icrc_account_list_report_text, icrc_holder_list_report_text,
137    icrc_indexed_count_report_text, icrc_token_value_report_text, icrc_total_supply_report_text,
138};
139
140/// Default base endpoint for the official IC Dashboard API.
141pub const DEFAULT_IC_DASHBOARD_SOURCE_ENDPOINT: &str = "https://ic-api.internetcomputer.org/api/v3";
142
143/// Default base endpoint for official IC Dashboard canister collection queries.
144pub const DEFAULT_IC_DASHBOARD_CANISTER_COLLECTION_SOURCE_ENDPOINT: &str =
145    "https://ic-api.internetcomputer.org/api/v4";
146
147/// Default base endpoint for the official IC Dashboard Metrics API.
148pub const DEFAULT_IC_DASHBOARD_METRICS_SOURCE_ENDPOINT: &str =
149    "https://metrics-api.internetcomputer.org/api/v1";
150
151/// Default base endpoint for the official Dashboard ICRC analytics API.
152pub const DEFAULT_ICRC_ANALYTICS_SOURCE_ENDPOINT: &str =
153    "https://icrc-api.internetcomputer.org/api/v2";
154
155/// Default base endpoint for exact official Dashboard ICRC account queries.
156pub const DEFAULT_ICRC_ACCOUNT_INFO_SOURCE_ENDPOINT: &str =
157    "https://icrc-api.internetcomputer.org/api/v1";
158
159/// Default base endpoint for official boundary-node data-center queries.
160pub const DEFAULT_IC_BOUNDARY_NODE_DATA_CENTERS_SOURCE_ENDPOINT: &str =
161    "https://ic-api.internetcomputer.org/api/v4";
162
163/// Maximum response-body size accepted from an official Dashboard HTTP endpoint.
164pub const MAX_IC_DASHBOARD_RESPONSE_BYTES: u64 = 8 * 1024 * 1024;
165
166/// Default row limit for one official Dashboard canister page.
167pub const DEFAULT_IC_CANISTER_PAGE_LIMIT: u16 = 50;
168
169/// Maximum row limit accepted for one official Dashboard canister page.
170pub const MAX_IC_CANISTER_PAGE_LIMIT: u16 = 100;
171
172/// Default relative window for one Dashboard metric query.
173pub const DEFAULT_IC_METRIC_WINDOW_SECS: u64 = 3_600;
174
175/// Default interval between requested Dashboard metric observations.
176pub const DEFAULT_IC_METRIC_STEP_SECS: u32 = 300;
177
178/// Earliest timestamp accepted by the official Dashboard Metrics API.
179pub const MIN_IC_METRIC_TIMESTAMP: u64 = 1_620_432_000;
180
181/// Largest step accepted by the official Dashboard Metrics API.
182pub const MAX_IC_METRIC_STEP_SECS: u32 = 259_200;
183
184/// Maximum requested observations accepted per metric series.
185pub const MAX_IC_METRIC_OBSERVATIONS_PER_SERIES: u64 = 1_000;
186
187/// Default relative window for one ICRC total-supply analytics query.
188pub const DEFAULT_ICRC_TOTAL_SUPPLY_WINDOW_SECS: u64 = 30 * 24 * 60 * 60;
189
190/// Default interval between ICRC total-supply observations.
191pub const DEFAULT_ICRC_TOTAL_SUPPLY_STEP_SECS: u32 = 86_400;
192
193/// Earliest timestamp accepted by the official Dashboard ICRC analytics API.
194pub const MIN_ICRC_ANALYTICS_TIMESTAMP: u64 = 1_620_328_530;
195
196/// Maximum requested observations accepted for one ICRC analytics series.
197pub const MAX_ICRC_ANALYTICS_OBSERVATIONS: u64 = 1_000;
198
199/// Default relative window for one ICRC token-value analytics query.
200pub const DEFAULT_ICRC_TOKEN_VALUE_WINDOW_SECS: u64 = 24 * 60 * 60;
201
202/// Default row limit for one ICRC token-value analytics query.
203pub const DEFAULT_ICRC_TOKEN_VALUE_LIMIT: u16 = 1_000;
204
205/// Largest time window accepted for one ICRC token-value query.
206pub const MAX_ICRC_TOKEN_VALUE_WINDOW_SECS: u64 = 90 * 24 * 60 * 60;
207
208/// Maximum token-value rows requested or accepted by one report.
209pub const MAX_ICRC_TOKEN_VALUE_ROWS: u16 = 1_000;
210
211/// Maximum rows accepted for one official ICRC account or holder index page.
212pub const MAX_ICRC_INDEX_PAGE_ROWS: u16 = 100;
213
214/// Maximum characters accepted for an opaque official ICRC index cursor or account id.
215pub const MAX_ICRC_INDEX_CURSOR_CHARS: usize = 512;
216
217/// Default relative window for one Dashboard daily-statistics query.
218pub const DEFAULT_IC_DAILY_STATS_WINDOW_SECS: u64 = 7 * 24 * 60 * 60;
219
220/// Earliest timestamp accepted by the official Dashboard daily-statistics API.
221pub const MIN_IC_DAILY_STATS_TIMESTAMP: u64 = 1_620_406_800;
222
223/// Largest time window accepted by one daily-statistics request.
224pub const MAX_IC_DAILY_STATS_WINDOW_SECS: u64 = 366 * 24 * 60 * 60;
225
226/// Maximum daily-statistics rows accepted from one source response.
227pub const MAX_IC_DAILY_STATS_ROWS: usize = 366;
228
229/// Maximum boundary-node data-center rows accepted from one source response.
230pub const MAX_IC_BOUNDARY_NODE_DATA_CENTERS: usize = 1_000;
231
232/// Default row limit for one official Dashboard replica-version page.
233pub const DEFAULT_IC_REPLICA_VERSION_PAGE_LIMIT: u16 = 50;
234
235/// Maximum row limit accepted for one official Dashboard replica-version page.
236pub const MAX_IC_REPLICA_VERSION_PAGE_LIMIT: u16 = 100;
237
238/// Default row limit for one official Dashboard node-provider reward page.
239pub const DEFAULT_IC_NODE_PROVIDER_REWARD_PAGE_LIMIT: u16 = 50;
240
241/// Maximum row limit accepted for one official Dashboard node-provider reward page.
242pub const MAX_IC_NODE_PROVIDER_REWARD_PAGE_LIMIT: u16 = 100;
243
244/// Default relative window for one node-provider reward history query.
245pub const DEFAULT_IC_NODE_PROVIDER_REWARD_HISTORY_WINDOW_SECS: u64 = 365 * 24 * 60 * 60;
246
247/// Default interval between node-provider reward history observations.
248pub const DEFAULT_IC_NODE_PROVIDER_REWARD_HISTORY_STEP_SECS: u32 = 86_400;
249
250/// Smallest step accepted by the official node-provider reward history API.
251pub const MIN_IC_NODE_PROVIDER_REWARD_HISTORY_STEP_SECS: u32 = 60;
252
253/// Largest step accepted by the official node-provider reward history API.
254pub const MAX_IC_NODE_PROVIDER_REWARD_HISTORY_STEP_SECS: u32 = 259_200;
255
256/// Maximum requested observations accepted for one node-provider reward history report.
257pub const MAX_IC_NODE_PROVIDER_REWARD_HISTORY_OBSERVATIONS: u64 = 1_000;
258
259#[cfg(feature = "dashboard-host")]
260pub(crate) const IC_DASHBOARD_REPORT_SCHEMA_VERSION: u32 = 1;
261#[cfg(feature = "dashboard-host")]
262pub(crate) const IC_DASHBOARD_AUTHORITY: &str = "official_ic_dashboard_api";
263#[cfg(feature = "dashboard-host")]
264pub(crate) const IC_DASHBOARD_NETWORK: &str = "ic";
265
266#[cfg(all(test, feature = "dashboard-host"))]
267mod tests;