pub mod attestation;
pub mod auth;
pub mod cycles;
pub mod install;
pub mod intent;
pub mod log;
mod nonroot;
mod root;
pub mod timer;
use crate::{
InternalError, InternalErrorOrigin,
ops::runtime::{env::EnvOps, memory::MemoryRegistryOps},
workflow::{self, prelude::*},
};
pub use nonroot::{init_nonroot_canister, post_upgrade_nonroot_canister_after_memory_init};
pub use root::{init_root_canister, post_upgrade_root_canister_after_memory_init};
pub struct RuntimeWorkflow;
impl RuntimeWorkflow {
pub fn start_all() {
workflow::runtime::log::LogRetentionWorkflow::start();
workflow::runtime::cycles::CycleTrackerWorkflow::start();
}
pub fn start_all_with_role_attestation_refresh() {
workflow::runtime::attestation::RoleAttestationKeyRefreshWorkflow::start();
Self::start_all();
}
pub fn start_all_root() -> Result<(), InternalError> {
EnvOps::require_root().map_err(|err| {
InternalError::invariant(
InternalErrorOrigin::Workflow,
format!("root context required: {err}"),
)
})?;
workflow::runtime::log::LogRetentionWorkflow::start();
workflow::runtime::cycles::CycleTrackerWorkflow::start_standard_only();
workflow::pool::scheduler::PoolSchedulerWorkflow::start();
Ok(())
}
}
pub(super) fn log_memory_summary() {
crate::log!(Topic::Memory, Info, "💾 memory.registry: bootstrapped");
}
fn init_post_upgrade_memory_registry() -> Result<(), InternalError> {
MemoryRegistryOps::bootstrap_registry().map_err(|err| {
InternalError::invariant(
InternalErrorOrigin::Workflow,
format!("memory init failed: {err}"),
)
})
}
pub fn init_memory_registry_post_upgrade() -> Result<(), InternalError> {
init_post_upgrade_memory_registry()
}