DFINITY is rolling out a feature that simplifies canister migration across subnets, offering developers more control over their projects. The move ensures that canisters can transition between subnets with specific features, such as the European subnet or the fiduciary subnet, which caters to particular replication needs. This upgrade is a step towards optimising the Internet Computer for efficiency and scalability.
Canister migration retains state, cycles, and canister ID while excluding transient state elements like logs and metrics. The process requires stopping the canister to avoid open call contexts before migration. While the transient state is not maintained, the fundamental structure remains intact, ensuring a smooth transition for developers.
The process follows three key steps: migrating canister state, transferring cycles, and reassigning canister IDs. Canister state migration works through a snapshot mechanism, where the existing canister is replicated onto a new canister in the target subnet. Initially, the migrated canister has a temporary ID, but this is later reassigned to match the original. The approach involves expanding the management canister API to allow snapshot reading, writing, and storage, enabling more seamless data movement.
DFINITY is also introducing new dfx commands for downloading and uploading snapshots. These will function both off-chain, where developers can store snapshots on disk, and on-chain, where a new snapshot migration canister ensures data integrity. The on-chain method provides independent verification, bolstering security and reliability.
Beyond migration, these enhancements also enable multiple backups, disaster recovery, and testing in environments that mirror the mainnet. Developers can maintain various snapshots instead of relying on a single one per canister, as is currently the case.
For cycle transfers, DFINITY is leveraging the existing cycles wallet mechanism. Once a snapshot is taken, developers can deploy a wallet to the original canister and shift cycles to the new one using dfx commands. This ensures a smooth financial transition between subnets without disrupting canister operations.
The final step is canister ID migration, which is crucial for maintaining continuity. Once a canister has been duplicated onto a new subnet, the original ID remains attached to the old canister. To resolve this, a dedicated NNS canister manages ID migration by renaming the new canister to match the original ID. This ensures that applications and services referencing the canister remain unaffected.
A principal controlling both canisters initiates the process by adding the NNS canister as a controller and executing the migration call. DFINITY is introducing a new dfx command to simplify this step. If the process is interrupted, developers can restore the original canister from its snapshot without data loss.
These enhancements reflect an ongoing effort to streamline Internet Computer functionality, making it more adaptable to developer needs. By enabling canister migration with minimal disruption, DFINITY is ensuring that projects remain flexible, efficient, and scalable. Feedback is welcomed as the feature continues to be refined.