Could we deploy a canister on a specified subnet?

I consider this a bug (or missing feature): If I create a new canister through a wallet, and the subnet with that wallet is already full, or generally more busy than some other subnet, then I would expect the new canister to be transparently be installed on that subnet (echoing @saikatdas0790’s sentiments). At least “create that canister wherever possible” should be the default, and “create that canister on the same subnet as canister X” or “create this canister on a subnet other than canister X, Y, Z (for load balancing)” or “create this canister on a subnet with at least n nodes” or other subnet indications an optional setting. And I hope we aim for such declarative settings, and not just a blunt and inflexible “create on subnet X”.

1 Like

:wave: hey all! Just wanted to check the status of this.

Good question. Let me ping internally as well.

1 Like

We have a proposed feature to allow the caller to specify a subnetwork on which to install a newly created canister. The feature would also require to expose via the dashboard a variety of attributes of subnetworks (like replication factor, availability of threshold ECDSA on that subnetwork, subnetwork load etc), which should allow for a somewhat informed decision.

3 Likes

Wonderful, would I be able to use this feature on chain? For me this is critical.

Also, is there a timeline associated with this or is it just proposed?

3 Likes

Yes, canisters should be able to make such canister creation requests – however in the first iteration it is likely that a canister would not be able read up-to-date subnetwork info so that may need to be fed “manually”. In the long term, we should expose subnetwork info on chain (there’s more than one usecase for this).
There is no timeline unfortunately at the moment.

2 Likes

I want some extra information for this, im unable to check wallet_create_canister method in motoko , do you have some example for that, already tried to use it according to docs, getting some error…
if you could help with that :
Blog for error

Just wanted to check the status of this.

1 Like

In case if it helps, we can create new canisters in the subnet of an already existing canister. Meaning, you can use management canisters create_canister method from an already existing canister, and new canisters will get created in the same subnet.

No specific subnet is possible (yet?), but you can choose the subnet type with dfx ledger create-canister --subnet-type <type>

To see available options, use dfx ledger --network ic show-subnet-types. No option means application

4 Likes

Thank you very much. I am amazed. But it is not the best for me.

@Severin
Should I do create-canister and then deploy-wallet?
If I do dfx deploy, will it deploy to the same subnet as the one the wallet was deployed to?

dfx identity --network ic deploy-wallet

Only if you want your cycles wallet to be on that subnet as well. It’s a little bit more expensive, but I don’t think that’s a reason not to.

  • If the canisters are already created, it will deploy to the already created ones, no matter which subnet they are on.
  • If the canisters don’t exist yet, it will create them on the same subnet as your default wallet
  • If the canisters don’t exist yet, and you use dfx deploy --wallet <some wallet id> it will create the canisters on the same subnet as <some wallet id> is located in

@Severin
Thank you for your reploy. I understood.
Do you think the following way is also possible?

dfx ledger create-canister --subnet-type fiduciary
I secure a CanisterID with the above. I run dfx deploy using the Application Subnet wallet, specifying the CanisterID in canister_ids.json. The new canister is deployed to the fiduciary.

Is the CanisterID unique across all subnets?

1 Like

Yes, this works exactly the way you described

Yes

1 Like

is there a way to create canister on different subnet programmatically using ic-cdk?

Yes, you can use the CMC’s create_canister function. If you specify no subnet_selection field then you land on a random subnet, otherwise you can either choose the type or target a specific one

3 Likes

Thanks for the quick response. We want to create canisters on different subnet using our one main platform_orchestrator. I will try using CMC canister to create canister on different subnet from platform_orchestrator. Is there a way to locally test this scenario using pocket-ic?

I think I found a way looking at the documentation. To test the scenario I would have to load CMC canister using pocket ic and then test my functions as shown in the example. Correct me if I am wrong here

let ledger_canister_id = Principal::from_text("ryjl3-tyaaa-aaaaa-aaaba-cai").unwrap();
pic.create_canister_with_id(..., ledger_canister_id).unwrap();
pic.install_canister(ledger_canister_id, ...);

You’re not wrong that you can install NNS canisters like this, but they are really annoying to set up properly. And I don’t know myself how you properly set up the real CMC to target different subnets and I also don’t know if it works properly on pocket ic. What I would suggest is that you use the fake CMC in this repository and use this to check if you make the right calls. (It’s not part of the releases right now, but I need it to be added there myself so I should get around to that this week)

1 Like