I’ve narrowed down the source of the issue by adding more logs. I found out that the trap is related to new canister creation. Here is just a little more context with logs and code:
let settings = CanisterSettings {
controllers: Some(self.controllers.clone()),
compute_allocation: None,
wasm_memory_threshold: None,
memory_allocation: None,
freezing_threshold: None,
reserved_cycles_limit: Some(Nat::from(self.reserved_cycles)),
log_visibility: Some(LogVisibility::Public),
wasm_memory_limit: None,
};
trace(&format!(
"create_canister: constructed CanisterSettings: {:?}",
settings
));
let args = &CreateCanisterArgs {
settings: Some(settings.clone()),
};
trace("create_canister: calling create_canister with args");
match create_canister_with_extra_cycles(args, self.initial_cycles as u128).await {
Ok(canister) => {
canister_id = canister.canister_id;
trace(&format!(
"create_canister: successfully created new canister: {}",
canister_id
));
}
Err(e) => {
trace(&format!(
"create_canister: failed to create canister after retries: {:?}",
e
));
return Err(NewCanisterError::CreateCanisterError(format!("{e:?}")));
}
}
trace("create_canister: adding new canister to fund manager");
add_canisters_to_fund_manager(
&mut self.fund_manager,
self.funding_config.clone(),
vec![canister_id],
);
trace("create_canister: added canister to fund manager");
And the corresponding logs:
2024-12-13 12:03:00.000000019 UTC: [Canister 7uieb-cx777-77776-qaaaq-cai] create_canister: constructed CanisterSettings: CanisterSettings { controllers: Some([Principal { len: 10, bytes: [255, 255, 255, 255, 255, 208, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, Principal { len: 10, bytes: [255, 255, 255, 255, 255, 208, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }]), compute_allocation: None, memory_allocation: None, freezing_threshold: None, reserved_cycles_limit: Some(Nat(100000000000000000)), log_visibility: Some(Public), wasm_memory_limit: None, wasm_memory_threshold: None }
2024-12-13 12:03:00.000000019 UTC: [Canister 7uieb-cx777-77776-qaaaq-cai] create_canister: calling create_canister with args
2024-12-13 12:03:00.000000019 UTC: [Canister 7uieb-cx777-77776-qaaaq-cai] [ic-cdk-timers] canister_global_timer: CallRejected(CallRejected { raw_reject_code: 5, reject_message: "IC0502: Error from Canister 7uieb-cx777-77776-qaaaq-cai: Canister trapped: unreachable.\nConsider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: https://internetcomputer.org/docs/current/references/execution-errors#trapped" })
test gldt_stake_suite::tests::user_flows::withdraw_flow_test ... FAILED
I also had fixed the canister creation function in our canister, because it appeared that there were also deprecated methods used, so I also replaced them with new ones but it gave nothing:
ic_cdk::api::management_canister::main::create_canister → ic_cdk::management_canister:: create_canister_with_extra_cycles
@AdamS and @peterparker hope this gives more information. Is it possible that I’m doing something wrong or is the error related to the create_canister method?