Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(station): serve metrics as properly certified HTTP asset #341

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
33 changes: 23 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ hex = "0.4"
# The ic-agent matches the one sed by bthe
ic-agent = { git = "https://github.com/dfinity/agent-rs.git", rev = "be929fd7967249c879f48f2f494cbfc5805a7d98" }
ic-asset = { git = "https://github.com/dfinity/sdk.git", rev = "75c080ebae22a70578c06ddf1eda0b18ef091845" }
ic-certification = { git = "https://github.com/dfinity/response-verification", rev = "da70db93832f88ecc556ae082612aedec47d3816" }
ic-asset-certification = { git = "https://github.com/dfinity/response-verification", rev = "eefc99e2a0041ae46873864e6e2f7aa8506a361f" }
ic-certification = { git = "https://github.com/dfinity/response-verification", rev = "eefc99e2a0041ae46873864e6e2f7aa8506a361f" }
ic-certified-assets = { git = "https://github.com/dfinity/sdk.git", rev = "75c080ebae22a70578c06ddf1eda0b18ef091845" }
ic-http-certification = { git = "https://github.com/dfinity/response-verification", rev = "da70db93832f88ecc556ae082612aedec47d3816" }
ic-representation-independent-hash = { git = "https://github.com/dfinity/response-verification", rev = "da70db93832f88ecc556ae082612aedec47d3816" }
ic-http-certification = { git = "https://github.com/dfinity/response-verification", rev = "eefc99e2a0041ae46873864e6e2f7aa8506a361f" }
ic-cdk = "0.13.2"
ic-cdk-macros = "0.9"
ic-cdk-timers = "0.7.0"
Expand Down
1 change: 1 addition & 0 deletions core/control-panel/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ hex = { workspace = true }
ic-cdk = { workspace = true }
ic-cdk-macros = { workspace = true }
ic-cdk-timers = { workspace = true }
ic-http-certification = { workspace = true }
ic-stable-structures = { workspace = true }
lazy_static = { workspace = true }
serde = { workspace = true, features = ['derive'] }
Expand Down
14 changes: 6 additions & 8 deletions core/control-panel/impl/src/controllers/canister.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! Canister lifecycle hooks.
use super::AVAILABLE_TOKENS_USER_REGISTRATION;
use crate::core::ic_cdk::{api::set_certified_data, spawn};
use crate::controllers::http::certify_metrics;
use crate::core::ic_cdk::spawn;
use crate::core::metrics::recompute_all_metrics;
use crate::services::CANISTER_SERVICE;
use control_panel_api::UploadCanisterModulesInput;
use ic_cdk_macros::{init, post_upgrade};
use ic_cdk_timers::{set_timer, set_timer_interval};
use orbit_essentials::api::ApiResult;
use orbit_essentials::cdk::update;
use orbit_essentials::http::certified_data_for_skip_certification;
use std::time::Duration;

pub const MINUTE: u64 = 60;
Expand All @@ -23,10 +23,6 @@ async fn upload_canister_modules(input: UploadCanisterModulesInput) -> ApiResult
CANISTER_SERVICE.upload_canister_modules(input).await
}

fn set_certified_data_for_skip_certification() {
set_certified_data(&certified_data_for_skip_certification());
}

fn init_timers_fn() {
async fn initialize_rng_timer() {
use orbit_essentials::utils::initialize_rng;
Expand Down Expand Up @@ -58,23 +54,25 @@ fn init_timers_fn() {

#[init]
async fn initialize() {
set_certified_data_for_skip_certification();
init_timers_fn();

CANISTER_SERVICE
.init_canister()
.await
.expect("failed to initialize canister");

certify_metrics();
}

#[post_upgrade]
async fn post_upgrade() {
set_certified_data_for_skip_certification();
recompute_all_metrics();
init_timers_fn();

CANISTER_SERVICE
.init_canister()
.await
.expect("failed to upgrade canister");

certify_metrics();
}
Loading
Loading