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
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 2 additions & 0 deletions apps/wallet/src/generated/control-panel/control_panel.did
Original file line number Diff line number Diff line change
Expand Up @@ -668,4 +668,6 @@ service : () -> {
can_deploy_station : () -> (CanDeployStationResult) query;
// HTTP Protocol interface.
http_request : (HttpRequest) -> (HttpResponse) query;
// no-op endpoint to refresh cycles balance in metrics
ping : () -> ();
};
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export interface _SERVICE {
[NextWasmModuleVersionInput],
NextWasmModuleVersionResult
>,
'ping' : ActorMethod<[], undefined>,
'register_user' : ActorMethod<[RegisterUserInput], RegisterUserResult>,
'search_registry' : ActorMethod<[SearchRegistryInput], SearchRegistryResult>,
'set_user_active' : ActorMethod<[], SetUserActiveResult>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export const idlFactory = ({ IDL }) => {
[NextWasmModuleVersionResult],
['query'],
),
'ping' : IDL.Func([], [], []),
'register_user' : IDL.Func([RegisterUserInput], [RegisterUserResult], []),
'search_registry' : IDL.Func(
[SearchRegistryInput],
Expand Down
2 changes: 2 additions & 0 deletions apps/wallet/src/generated/station/station.did
Original file line number Diff line number Diff line change
Expand Up @@ -2565,4 +2565,6 @@ service : (opt SystemInstall) -> {
http_request : (HttpRequest) -> (HttpResponse) query;
// Internal endpoint used by the upgrader canister to notify the station about a failed station upgrade request.
notify_failed_station_upgrade : (NotifyFailedStationUpgradeInput) -> (NotifyFailedStationUpgradeResult);
// no-op endpoint to refresh cycles balance in metrics
ping : () -> ();
};
1 change: 1 addition & 0 deletions apps/wallet/src/generated/station/station.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,7 @@ export interface _SERVICE {
[NotifyFailedStationUpgradeInput],
NotifyFailedStationUpgradeResult
>,
'ping' : ActorMethod<[], undefined>,
'submit_request_approval' : ActorMethod<
[SubmitRequestApprovalInput],
SubmitRequestApprovalResult
Expand Down
1 change: 1 addition & 0 deletions apps/wallet/src/generated/station/station.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,7 @@ export const idlFactory = ({ IDL }) => {
[NotifyFailedStationUpgradeResult],
[],
),
'ping' : IDL.Func([], [], []),
'submit_request_approval' : IDL.Func(
[SubmitRequestApprovalInput],
[SubmitRequestApprovalResult],
Expand Down
2 changes: 2 additions & 0 deletions core/control-panel/api/spec.did
Original file line number Diff line number Diff line change
Expand Up @@ -668,4 +668,6 @@ service : () -> {
can_deploy_station : () -> (CanDeployStationResult) query;
// HTTP Protocol interface.
http_request : (HttpRequest) -> (HttpResponse) query;
// no-op endpoint to refresh cycles balance in metrics
ping : () -> ();
};
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