In which subnet does IC.create_canister create a canister?

The IC chooses an appropriate canister id (referred to as CanisterId) and subnet id (referred to as SubnetId, SubnetId ∈ Subnets, where Subnets is the under-specified set of subnet ids on the IC).

So, what is the practical criterion of selection of a subnet by IC.create_canister (where IC is the management canister)?

I expect that it is created on a random subnet if IC.create_canister is called through HTTPS gateway (not by a canister) and the same subnet as the calling canister if called from a canister, except if the current subnet is too full, in which case it would use a random canister.

Does this my expectation match reality?

What to do with nonexistent description in the docs in which subnet IC.create_canister creates the canister? Should I refrain from use IC.create_canister and instead use Ledger.create_canister (where Ledger is a ledger canister)?

Yes, if no subnet is specified, the IC chooses a random subnet.

I am confused by your follow-up questions about deploying different canisters from other canisters.

Remember that ICP provides additional functionality, such as canister and user management. This functionality is exposed to external users and canisters via the IC management canister. However, IC management canister is not a canister but more of a facade.

I mean that I call IC.create_canister from an already deployed canister (let’s call it “calling canister”). Is in this case the deployed canister also on a random subnet? Or does it prefer to add it to the same canister as the calling canister?

It is not possible to call aaaaa-aa:create_canister as an ingress message. The call to the management canister requires you to attach cycles, which is impossible if you do it from anywhere other than a canister. If you call it through a canister, the new canister will always be created on the same subnet as that canister already lives on. If it is full and won’t accept new canisters, then the call fails.

The other way to create canisters is through the CMC, either with notify_create_canister, or create_canister. There you can specify a subnet. If you don’t specify a subnet, then the CMC has a list of subnets on which anyone can create canisters and picks a random one of these.

1 Like