Skip to content

chore: DEFI-2304 remove deprecated ic-cdk imports in ic-ledger-canister-core#10317

Draft
gregorydemay wants to merge 4 commits into
masterfrom
gdemay/DEFI-2304-ledger-canister-core
Draft

chore: DEFI-2304 remove deprecated ic-cdk imports in ic-ledger-canister-core#10317
gregorydemay wants to merge 4 commits into
masterfrom
gdemay/DEFI-2304-ledger-canister-core

Conversation

@gregorydemay
Copy link
Copy Markdown
Contributor

@gregorydemay gregorydemay commented May 27, 2026

Summary

Extends DEFI-2304 — removing the file-level #![allow(deprecated)] attributes introduced in #6264 when ic-cdk was upgraded to 0.18.

This PR handles ic-ledger-canister-core:

  • ic_cdk::api::call::call_with_paymentic_cdk::call::Call::unbounded_wait(...).with_args(&args).with_cycles(...) + Response::candid_tuple for the argument/return tuples.
  • ic_cdk::api::id()ic_cdk::api::canister_self().
  • ic_cdk::api::printic_cdk::api::debug_print.

The Runtime trait signature is unchanged. The CdkRuntime::call impl preserves the existing (i32, String) error shape by forwarding the raw reject code as an i32. No behavior change.

Follows the pattern set by #6755 (ic-btc-checker), #6761 (ic-ckbtc-minter), #10289, #10290, and #10291.

…er-core

Migrate `CdkRuntime` off `ic_cdk::api::call::call_with_payment`,
`ic_cdk::api::id` and `ic_cdk::api::print` (all deprecated in #6264),
and drop the file-level `#![allow(deprecated)]`. The `Runtime` trait
signature is unchanged; the `CdkRuntime` impl now uses the
`ic_cdk::call::Call` builder, `ic_cdk::api::canister_self` and
`ic_cdk::api::debug_print`. Reject codes are forwarded as raw `u32` →
`i32` to preserve the existing `(i32, String)` error shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues DEFI-2304 by removing file-level #![allow(deprecated)] usage in ic-ledger-canister-core and migrating the remaining deprecated ic-cdk calls in the runtime layer to the ic_cdk::call::Call builder API.

Changes:

  • Replaces ic_cdk::api::id() with ic_cdk::api::canister_self() in Runtime::id().
  • Replaces ic_cdk::api::print with ic_cdk::api::debug_print in Runtime::print().
  • Rewrites Runtime::call() from call_with_payment to Call::unbounded_wait(...).with_args(...).with_cycles(...).await and decodes via Response::candid_tuple.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +65 to +75
.map_err(|err| match err {
ic_cdk::call::CallFailed::CallRejected(rejected) => (
rejected.raw_reject_code() as i32,
rejected.reject_message().to_string(),
),
ic_cdk::call::CallFailed::InsufficientLiquidCycleBalance(e) => (1, e.to_string()),
ic_cdk::call::CallFailed::CallPerformFailed(e) => (1, e.to_string()),
})?;
response
.candid_tuple::<Out>()
.map_err(|err| (5, err.to_string()))
gregorydemay and others added 3 commits May 27, 2026 08:16
Per Copilot review on #10317: the previous hard-coded 1/5 sentinels for
`InsufficientLiquidCycleBalance`, `CallPerformFailed` and `CandidDecodeFailed`
collided with real `RejectCode` values (1 = SysFatal, 5 = CanisterError).
Switch to `-1` so callers can reliably distinguish IC reject codes (≥0) from
local failures. Mirrors the convention already used in
`rs/nervous_system/clients/src/exchange_rate_canister_client.rs:206-229`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The runtime migration in `ic-ledger-canister-core` (this PR) replaces
`ic_cdk::api::call::call_with_payment` with the `ic_cdk::call::Call` builder
in `CdkRuntime::call`. That helper is what the icrc1 ledger uses to talk to
its archive canister during post_upgrade / upgrade, so the canbench scopes
covering that path shift by a few percent:

- u64 ledger: `bench_icrc1_transfers::post_upgrade` ‑2.56% (342.21M ins)
- u256 ledger: `bench_icrc1_transfers::post_upgrade` +2.63% (351.36M ins),
  `bench_icrc1_transfers::upgrade` +2.05% (501.34M ins)

Regenerated by running `bazel run //rs/ledger_suite/icrc1/ledger:canbench_u64_update`
and `:canbench_u256_update`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants