Hey Everyone,
I have been working on Canisters Management for All Waterway Labs Projects where all of our project canisters can be managed by the WWL admins in one app itself (Will post a detailed forum on this too). As part of management, Deletion of canister too is a feature considering to retrieve as much cycles possible back to our manager canister (wwl_canister_manager). After going through tons of other forums and difinity docs. I finally came up with the approach which is usable and viable for most of the projects out there on ICP.
So let me break it down for you on how we implemented:
- We will be re-installing the canister to be deleted with an actor class which has just a single public function to transfer back cycles.
- And update the compute_allocation to 0 and freeze_threshold to 3600 sec (to make sure cycles aren’t being held back).
- We then proceed to call the transfer function in the canister to be deleted to get back the cycles.
- After which the wwl_canister_manager can call the management to delete the canister.
How much cycles can I get back?
- After going through a list of forums and discussing with people. In this process we can save any excess over 150B cycles (we can still improve it but this is the best bet for our WWL projects right now).
- The 150B cycles headroom is kept so that we are able to run the prior steps successfully before deletion of the canister.
Here is the coded implementation in motoko.
Below are the resources referred for the cost computation.
gas-cost
freeze-threshold
compute-allocation