chore: DEFI-2304 remove deprecated ic-cdk imports in ic-ledger-canister-core#10317
Draft
gregorydemay wants to merge 4 commits into
Draft
chore: DEFI-2304 remove deprecated ic-cdk imports in ic-ledger-canister-core#10317gregorydemay wants to merge 4 commits into
gregorydemay wants to merge 4 commits into
Conversation
…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>
Contributor
There was a problem hiding this comment.
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()withic_cdk::api::canister_self()inRuntime::id(). - Replaces
ic_cdk::api::printwithic_cdk::api::debug_printinRuntime::print(). - Rewrites
Runtime::call()fromcall_with_paymenttoCall::unbounded_wait(...).with_args(...).with_cycles(...).awaitand decodes viaResponse::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())) |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends DEFI-2304 — removing the file-level
#![allow(deprecated)]attributes introduced in #6264 whenic-cdkwas upgraded to 0.18.This PR handles
ic-ledger-canister-core:ic_cdk::api::call::call_with_payment→ic_cdk::call::Call::unbounded_wait(...).with_args(&args).with_cycles(...)+Response::candid_tuplefor the argument/return tuples.ic_cdk::api::id()→ic_cdk::api::canister_self().ic_cdk::api::print→ic_cdk::api::debug_print.The
Runtimetrait signature is unchanged. TheCdkRuntime::callimpl preserves the existing(i32, String)error shape by forwarding the raw reject code as ani32. No behavior change.Follows the pattern set by #6755 (
ic-btc-checker), #6761 (ic-ckbtc-minter), #10289, #10290, and #10291.