Cycle Cost For Installing Wasm

I have been calculating the amount of cycles required to upgrade the canister using this formulae and if the canister has enough cycles I move to upgrading the canister


pub const BASE_COST_FOR_EXECUTION: u128 = 5_000_000; // 5M cycles
pub const RESERVED_NUMBER_OF_INSTRUCTIONS_FOR_INSTALL_CODE: u128 = 200_000_000_000; //200B instructions


pub fn calculate_required_cycles_for_upgrading(
    idle_cycles_burned_per_day: u128,
    freezing_threshold_in_days: Option<u128>,
) -> u128 {
    let freezing_threshold_cycles = get_cycles_reserved_in_freezing_threshold(
        idle_cycles_burned_per_day,
        freezing_threshold_in_days,
    ) //30*idle_cyles_burned_per_day;
    let cycles_required_for_upgrade_execution = BASE_COST_FOR_EXECUTION
        + (RESERVED_NUMBER_OF_INSTRUCTIONS_FOR_INSTALL_CODE);
    freezing_threshold_cycles + cycles_required_for_upgrade_execution
}

But I have been observing failures in upgrading a canister saying canister does not have enough cycles. what could be the reason? Let me know if did a mistake in calculating

1 Like

The max number of instructions that can be used by an install_code request has been increased to 300B. It seems you are using the older 200B value.

Oh alright. Thanks @dsarlis