Cannot delete canisters anymore

Ah…just came up with these problem, a lot of canisters that are needed to delete

Okay, how about retry logic that slowly gives more margin? It’s not ideal as I’d rather calculate this directly from parameters, but the interface doesn’t expose enough information, especially not for subnets of different types. PR here

What exactly is the margin needed for? There need to be cycles so that the canister can call the management canister to delete itself? Or which call is the margin for?

Crossposting one of the recent answer of @Severin when I started a new thread about this Minimal cycles to delete canister - #3 by Severin since the thread I originally started is active today.

If I can share my two cents as a developer of dapps on the IC again about this topic: anything else that a single clear data provided by IC that tells me how much cycles I should retain before deleting a canister is development pain.

Don’t misunderstand me, I don’t say it is faisable nor easy to implement such thing on the IC, definitely not, but once again as a developer, anything else is a hussle.

The margin is there because a canister may not actively perform any operation that would leave it in a frozen state - if you transfer out all cycles it won’t have any left, therefore it’ll be frozen. So you have to transfer cycles balance - some delta, which is hard to exactly pin-point.

So the problem doesn’t come from the freezing threshold because even if freezing threshold was 0 we would still have the problem of predicting the cycle balance in the future. A first call can determine the cycle balance but that is only a snapshot in time. To make the second call that sends cycles out we have to estimate the balance at the time of the second call. So the calculation of the difference depends on the size of the wallet canister (memory) and the time between the first and second call.

tried this version 0.12.2-beta.0 but failed anyway

1 Like

The retry logic is not in any beta release yet because the PR is still in review.

me too

…why
…why
…why

// “Couldn’t send message” when deleting a canister: increase WITHDRAWAL_COST
const WITHDRAWAL_COST: u128 = 10_303_000_000; /

Why can’t dynamic modification?

That’s what I just implemented:

Thanks for reply Severin.That is the actual error message , the dfx command response.

While using
dfx canister --network=ic stop {CANISTER_ID}
and
dfx canister --network=ic delete {CANISTER_ID}

The error still:

Error: Failed to delete canister '{CANISTER_ID}'.
Caused by: Failed to delete canister '{CANISTER_ID}'.
  Failed to deposit {CYCLES_NUMBER} cycles into {CANISTER_ID}.
    Failed to call update function 'deposit_cycles' regarding canister '{CANISTER_ID}'.
      Update call using wallet failed.
        The invocation to the wallet call forward method failed with the error: An error happened during the call: 2: Couldn't send message
1 Like

@neeboo have you tried with a version from master? It looks like this error is from a version before the fix got merged

@Severin
hello, i have upgrade the version to 0.12.2-beta.0 , but still has the same error with version 0.9.0.

dfx canister --network ic delete ${myCanisterId} --withdraw-cycles-to-dank-principal   ${myPrincipal}

error message:

WARN: The default identity is not stored securely. Do not use it to control a lot of cycles/ICP. Create a new identity with `dfx identity new` and use it in mainnet-facing commands with the `--identity` flag
Beginning withdrawal of cycles to canister aanaa-xaaaa-aaaah-aaeiq-cai; on failure try --no-wallet --no-withdrawal.
Setting the controller to identity princpal.
Installing temporary wallet in canister ${myCanisterId} to enable transfer of cycles.
Transfering 108924991440 cycles to dank principal ${myPrincipal} 
Error: Failed to delete canister '${myCanisterId} '.
Caused by: Failed to delete canister '${myCanisterId} '.
  Failed mint call.
    The invocation to the wallet call forward method failed with the error: An error happened during the call: 2: Couldn't send message

As I said, the fix didn’t make it into a beta version yet. Have you tried with a version from master?

How can I get the latest version from the master branch.

I update the dfx version using this command:

DFX_VERSION=${curVersion} sh -ci "$(curl -fsSL https://smartcontracts.org/install.sh)"

it seems the last release version is 0.12.2-beta.0

For master you have to git clone and cargo build. Instructions are here

I use master branch code and it gives me

Attempting to transfer {AMOUNT} cycles to canister {CANISTER_ID}
Not enough margin. Trying again with more margin.

<REPEATING ABOVE>

It seems to find correct amount of cycles, and after a few tries.

Successfully withdrew {AMOUNT} cycles.
Deleting canister {CANISTER_ID}, with canister_id {CANISTER_ID}

It’s a bit slow and dumb because it retries about 8 times when deleting one canister
But at least the problem is fixed.
Can we make it smarter to calculate the “margin” better?

2 Likes

I wish we could, but I don’t have any good ideas. If anyone has a good idea, I’m all ears!