Error: The certificate contains a delegation that does not include the canister aaaaa-aa in the canister_ranges field

Thanks @marc0olo.

I was able to reproduce the issue by cloning the repo and running the script locally. After debugging, I managed to isolate the problem and find a solution.

The code fails when calling provisional_create_canister_with_cycles if no canister ID is provided. This happens because the canisterId parameter is mapped to the effectiveCanisterId through the specified_id and transform function I mentionned earlier. That’s why providing one works, and leaving it empty does not.

If I supply a canister ID (for example, the one I use by default in Juno’s Docker setup), the script runs successfully and the canister is created.

const result = await this.management.provisionalCreateCanisterWithCycles({
  amount: cyclesToUse,
  canisterId: Principal.fromText('jx5yt-yyaaa-aaaal-abzbq-cai') // <----- 👀
});

Canister created successfully with provisional function!
Canister ID: jx5yt-yyaaa-aaaal-abzbq-cai

:tada: SUCCESS! Canister created successfully!

@Huygon764 can you give this a try specifying a canister ID?

@mraszyk @ilbert given the above, should we go ahead and implement the fix you suggested today or other ideas?

An alternative would to be to default to the effective canister ID provided in PocketIC topology record. Actually maybe that’s better after all.

Do you mean in the ic-management JS library? Not against sure, what’s the default or how can it be retrieved?

I mean in pic-js when creating a canister.

Ah gotcha. @ilbert WDYT?

Though OP is not using pic-js I think, probably rather DFX/PocketIC directly.

Makes sense! I’ve opened an issue for this: Pass the canister id when calling `provisionalCreateCanisterWithCycles` · Issue #189 · dfinity/pic-js · GitHub.

I had the problem on my local machine as well.

provisionalCreateCanisterWithCycles:

The certificate contains a delegation that does not include the canister aaaaa-aa in the canister_ranges field

59 | */
60 | get isCertified() {
61 | return this.code.isCertified;
62 | }
63 | constructor(code, kind) {
64 | super(code.toString());
^
TrustError: The certificate contains a delegation that does not include the canister aaaaa-aa in the canister_ranges field. Subnet ID: gnkm6-o3f2j-s4j4o-tn4cp-ebkfd-46tuv-xaitz-fv54k-u7b2d-ejijp-vqe
cause: {
code: [Object …],
kind: “Trust”,
},

similarly

createCanister/installCode

Canister aaaaa-aa does not belong to any subnet.