Skip to content

feat!: next generation of Rust CDK #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
279de07
feat: struct Call to support best effort responses (#496)
lwshang Jun 18, 2024
36c837b
Merge branch 'main' into next
lwshang Sep 3, 2024
107fa7d
feat!: ic0 handles 32/64-bit system API (#514)
lwshang Sep 3, 2024
1d99280
Merge branch 'main' into next
lwshang Sep 18, 2024
b10be57
Merge branch 'main' into next
lwshang Oct 4, 2024
3d06c9e
non-beta dfx in examples.yml
lwshang Oct 4, 2024
7a64c21
refactor!: crates architecture (#522)
lwshang Oct 9, 2024
69a459d
bump crates to alpha.1 (#524)
lwshang Oct 11, 2024
69d98b0
fix: update/query macro could not handle function arguments with the …
lwshang Oct 11, 2024
907b7d9
Merge branch 'main' into next
lwshang Nov 12, 2024
a061429
move back management_canister mod (#533)
lwshang Dec 4, 2024
605abca
Merge branch 'main' into next
lwshang Dec 4, 2024
9f9c0f7
feat: root call mod with new CallError (#535)
lwshang Dec 11, 2024
d98a6ff
feat: no more tuples in Call (#539)
lwshang Dec 16, 2024
0ab2864
feat: root management canister mod with new bindings (#538)
lwshang Dec 18, 2024
65443f9
refactor: api module overhaul (#540)
lwshang Dec 19, 2024
921c858
Merge branch 'main' into next
lwshang Dec 19, 2024
e2bbc39
chore: e2e wasm64 (#534)
lwshang Dec 20, 2024
c2ba198
chore: deprecate old call API (#542)
lwshang Dec 20, 2024
14e10db
chore: deprecate other APIs in api/call.rs (#543)
lwshang Jan 3, 2025
3184c9c
feat: macros that decoding arguments can set custom decoder using dec…
lwshang Jan 10, 2025
5fb07f5
feat: safe binding for msg_deadline (#545)
lwshang Jan 13, 2025
710fc59
chore: deprecate remaining items in api/call.rs (#546)
lwshang Jan 15, 2025
68f98ce
feat: CallError redesign (#548)
lwshang Jan 16, 2025
4e287ce
chore: call module followup (#549)
lwshang Jan 17, 2025
7349253
refactor: type crates (#550)
lwshang Jan 22, 2025
d823cb5
feat: simplify Call implementation and enable retry logic (#551)
lwshang Jan 24, 2025
b8f9b27
feat: executor v3 (#555)
adamspofford-dfinity Feb 12, 2025
d31d821
feat: management canister types v0.2.0 which ensures Candid equality …
michael-weigelt Feb 18, 2025
2255afa
feat: finalize call api (#557)
lwshang Feb 21, 2025
fc8959a
feat: add _with_cycles postfix to management canister methods that re…
lwshang Feb 25, 2025
fb24332
docs: version guide for v0.18 (#561)
lwshang Feb 26, 2025
5563c31
chore: MSRV back to 1.75.0 (#564)
lwshang Feb 28, 2025
8e806ee
feat: Add types for fetching canister logs (#563)
michael-weigelt Feb 28, 2025
9a45b5c
feat: update/query can set custom result encoder (#565)
lwshang Feb 28, 2025
dfca4bd
fix: set the executor context when invoking functions via canister ti…
hpeebles Mar 3, 2025
bb1e805
test: update pocket-ic and simplify server caching (#568)
lwshang Mar 4, 2025
b2596b5
fix: only call `call_cycles_add128` if cycles amount > 0 (#567)
hpeebles Mar 5, 2025
4a1fe68
feat: call bitcoin canisters (#569)
lwshang Mar 5, 2025
be90d32
feat!: switch RejectCode to ic-error-types and deprecate ic-response-…
lwshang Mar 5, 2025
37cd64f
feat: add cost_* System API and methods that calculate cycles cost un…
lwshang Mar 10, 2025
f3edbd4
feat: select (un)bounded_wait for management functions (#575)
lwshang Mar 11, 2025
995abe5
feat: subnet_self in ic0 and api (#576)
lwshang Mar 11, 2025
d0f4607
perf: bounded_wait default to 300s timeout (#577)
lwshang Mar 17, 2025
f6c7cd2
feat!: update management types (#578)
lwshang Mar 17, 2025
6929b2f
feat: canister_liquid_cycle_balance (#579)
lwshang Mar 19, 2025
3a1b608
chore: release v0.18.0-alpha.2 (#580)
lwshang Mar 19, 2025
586b943
fix: custom decoder/encoder should be blob in Candid (#581)
lwshang Mar 26, 2025
e9a4633
fix: run user destructors outside refcell context (#582)
adamspofford-dfinity Apr 1, 2025
3cc18cc
flock pocketic tag file (#584)
adamspofford-dfinity Apr 1, 2025
7e8e7f2
Add paragraph to documentation about background traps (#585)
adamspofford-dfinity Apr 1, 2025
f27d678
ci: fix pocket-ic server download (#587)
lwshang Apr 4, 2025
eb937a9
temp link of pocket-ic that supports root_key
lwshang Apr 4, 2025
69a2730
Revert "temp link of pocket-ic that supports root_key"
lwshang Apr 4, 2025
7a5c0d5
Merge branch 'main' into next
lwshang Apr 11, 2025
0be0735
feat: add a public Constructor for CallRejected (#592)
lwshang Apr 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions e2e-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ path = "canisters/management_caller.rs"
name = "chunk"
path = "canisters/chunk.rs"

[[bin]]
name = "call_struct"
path = "canisters/call_struct.rs"

[dev-dependencies]
hex.workspace = true
pocket-ic = "4"
17 changes: 17 additions & 0 deletions e2e-tests/canisters/call_struct.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use candid::Principal;
use ic_cdk::api::management_canister::main::{CanisterIdRecord, CreateCanisterArgument};
use ic_cdk::prelude::*;

#[update]
async fn create_canister_via_struct() -> Principal {
let res: (CanisterIdRecord,) = Call::new(Principal::management_canister(), "create_canister")
.with_args((CreateCanisterArgument::default(),))
.with_cycles(200_000_000_000)
.with_guaranteed_response()
.call()
.await
.unwrap();
res.0.canister_id
}

fn main() {}
11 changes: 11 additions & 0 deletions e2e-tests/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,3 +642,14 @@ fn test_chunk() {
)
.expect("Error calling call_install_chunked_code");
}

#[test]
fn call_struct() {
let pic = PocketIc::new();
let wasm = cargo_build_canister("call_struct");
let canister_id = pic.create_canister();
pic.add_cycles(canister_id, 100_000_000_000_000);
pic.install_canister(canister_id, wasm, vec![], None);
let _: (Principal,) = call_candid(&pic, canister_id, "create_canister_via_struct", ())
.expect("Error calling execute_main_methods");
}
1 change: 1 addition & 0 deletions examples/counter/tests/basic.bats
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load ../../bats/bats-support/load.bash
load ../../bats/bats-assert/load.bash

# Executed before each test.
Expand Down
1 change: 1 addition & 0 deletions examples/profile/tests/basic.bats
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load ../../bats/bats-support/load.bash
load ../../bats/bats-assert/load.bash

# Executed before each test.
Expand Down
126 changes: 55 additions & 71 deletions ic0.txt
Original file line number Diff line number Diff line change
@@ -1,71 +1,55 @@
ic0.msg_arg_data_size : () -> i32; // I U Q CQ Ry CRy F
ic0.msg_arg_data_copy : (dst : i32, offset : i32, size : i32) -> (); // I U Q CQ Ry CRy F
ic0.msg_caller_size : () -> i32; // *
ic0.msg_caller_copy : (dst : i32, offset: i32, size : i32) -> (); // *
ic0.msg_reject_code : () -> i32; // Ry Rt CRy CRt
ic0.msg_reject_msg_size : () -> i32; // Rt CRt
ic0.msg_reject_msg_copy : (dst : i32, offset : i32, size : i32) -> (); // Rt CRt

ic0.msg_reply_data_append : (src : i32, size : i32) -> (); // U Q CQ Ry Rt CRy CRt
ic0.msg_reply : () -> (); // U Q CQ Ry Rt CRy CRt
ic0.msg_reject : (src : i32, size : i32) -> (); // U Q CQ Ry Rt CRy CRt

ic0.msg_cycles_available : () -> i64; // U Rt Ry
ic0.msg_cycles_available128 : (dst : i32) -> (); // U Rt Ry
ic0.msg_cycles_refunded : () -> i64; // Rt Ry
ic0.msg_cycles_refunded128 : (dst : i32) -> (); // Rt Ry
ic0.msg_cycles_accept : (max_amount : i64) -> (amount : i64); // U Rt Ry
ic0.msg_cycles_accept128 : (max_amount_high : i64, max_amount_low: i64, dst : i32)
-> (); // U Rt Ry

ic0.cycles_burn128 : (amount_high : i64, amount_low : i64, dst : i32) -> (); // I G U Ry Rt C T

ic0.canister_self_size : () -> i32; // *
ic0.canister_self_copy : (dst : i32, offset : i32, size : i32) -> (); // *
ic0.canister_cycle_balance : () -> i64; // *
ic0.canister_cycle_balance128 : (dst : i32) -> (); // *
ic0.canister_status : () -> i32; // *
ic0.canister_version : () -> i64; // *

ic0.msg_method_name_size : () -> i32; // F
ic0.msg_method_name_copy : (dst : i32, offset : i32, size : i32) -> (); // F
ic0.accept_message : () -> (); // F

ic0.call_new : // U CQ Ry Rt CRy CRt T
( callee_src : i32,
callee_size : i32,
name_src : i32,
name_size : i32,
reply_fun : i32,
reply_env : i32,
reject_fun : i32,
reject_env : i32
) -> ();
ic0.call_on_cleanup : (fun : i32, env : i32) -> (); // U CQ Ry Rt CRy CRt T
ic0.call_data_append : (src : i32, size : i32) -> (); // U CQ Ry Rt CRy CRt T
ic0.call_cycles_add : (amount : i64) -> (); // U Ry Rt T
ic0.call_cycles_add128 : (amount_high : i64, amount_low: i64) -> (); // U Ry Rt T
ic0.call_perform : () -> ( err_code : i32 ); // U CQ Ry Rt CRy CRt T

ic0.stable_size : () -> (page_count : i32); // * s
ic0.stable_grow : (new_pages : i32) -> (old_page_count : i32); // * s
ic0.stable_write : (offset : i32, src : i32, size : i32) -> (); // * s
ic0.stable_read : (dst : i32, offset : i32, size : i32) -> (); // * s
ic0.stable64_size : () -> (page_count : i64); // * s
ic0.stable64_grow : (new_pages : i64) -> (old_page_count : i64); // * s
ic0.stable64_write : (offset : i64, src : i64, size : i64) -> (); // * s
ic0.stable64_read : (dst : i64, offset : i64, size : i64) -> (); // * s

ic0.certified_data_set : (src: i32, size: i32) -> (); // I G U Ry Rt T
ic0.data_certificate_present : () -> i32; // *
ic0.data_certificate_size : () -> i32; // Q CQ
ic0.data_certificate_copy : (dst: i32, offset: i32, size: i32) -> (); // Q CQ

ic0.time : () -> (timestamp : i64); // *
ic0.global_timer_set : (timestamp : i64) -> i64; // I G U Ry Rt C T
ic0.performance_counter : (counter_type : i32) -> (counter : i64); // * s
ic0.is_controller: (src: i32, size: i32) -> ( result: i32); // * s
ic0.in_replicated_execution: () -> (result: i32); // * s

ic0.debug_print : (src : i32, size : i32) -> (); // * s
ic0.trap : (src : i32, size : i32) -> (); // * s
ic0.msg_arg_data_size : () -> I; // I U RQ NRQ CQ Ry CRy F
ic0.msg_arg_data_copy : (dst : I, offset : I, size : I) -> (); // I U RQ NRQ CQ Ry CRy F
ic0.msg_caller_size : () -> I; // *
ic0.msg_caller_copy : (dst : I, offset : I, size : I) -> (); // *
ic0.msg_reject_code : () -> i32; // Ry Rt CRy CRt
ic0.msg_reject_msg_size : () -> I ; // Rt CRt
ic0.msg_reject_msg_copy : (dst : I, offset : I, size : I) -> (); // Rt CRt
ic0.msg_deadline : () -> i64; // U Q CQ Ry Rt CRy CRt
ic0.msg_reply_data_append : (src : I, size : I) -> (); // U RQ NRQ CQ Ry Rt CRy CRt
ic0.msg_reply : () -> (); // U RQ NRQ CQ Ry Rt CRy CRt
ic0.msg_reject : (src : I, size : I) -> (); // U RQ NRQ CQ Ry Rt CRy CRt
ic0.msg_cycles_available128 : (dst : I) -> (); // U Rt Ry
ic0.msg_cycles_refunded128 : (dst : I) -> (); // Rt Ry
ic0.msg_cycles_accept128 : (max_amount_high : i64, max_amount_low: i64, dst : I)
-> (); // U Rt Ry
ic0.cycles_burn128 : (amount_high : i64, amount_low : i64, dst : I)
-> (); // I G U Ry Rt C T
ic0.canister_self_size : () -> I; // *
ic0.canister_self_copy : (dst : I, offset : I, size : I) -> (); // *
ic0.canister_cycle_balance128 : (dst : I) -> (); // *
ic0.canister_status : () -> i32; // *
ic0.canister_version : () -> i64; // *
ic0.msg_method_name_size : () -> I; // F
ic0.msg_method_name_copy : (dst : I, offset : I, size : I) -> (); // F
ic0.accept_message : () -> (); // F
ic0.call_new :
( callee_src : I,
callee_size : I,
name_src : I,
name_size : I,
reply_fun : I,
reply_env : I,
reject_fun : I,
reject_env : I
) -> (); // U CQ Ry Rt CRy CRt T
ic0.call_on_cleanup : (fun : I, env : I) -> (); // U CQ Ry Rt CRy CRt T
ic0.call_data_append : (src : I, size : I) -> (); // U CQ Ry Rt CRy CRt T
ic0.call_with_best_effort_response : (timeout_seconds : i32) -> (); // U CQ Ry Rt CRy CRt T
ic0.call_cycles_add128 : (amount_high : i64, amount_low: i64) -> (); // U Ry Rt T
ic0.call_perform : () -> ( err_code : i32 ); // U CQ Ry Rt CRy CRt T
ic0.stable64_size : () -> (page_count : i64); // * s
ic0.stable64_grow : (new_pages : i64) -> (old_page_count : i64); // * s
ic0.stable64_write : (offset : i64, src : i64, size : i64) -> (); // * s
ic0.stable64_read : (dst : i64, offset : i64, size : i64) -> (); // * s
ic0.certified_data_set : (src : I, size : I) -> (); // I G U Ry Rt T
ic0.data_certificate_present : () -> i32; // *
ic0.data_certificate_size : () -> I; // NRQ CQ
ic0.data_certificate_copy : (dst : I, offset : I, size : I) -> (); // NRQ CQ
ic0.time : () -> (timestamp : i64); // *
ic0.global_timer_set : (timestamp : i64) -> i64; // I G U Ry Rt C T
ic0.performance_counter : (counter_type : i32) -> (counter : i64); // * s
ic0.is_controller: (src : I, size : I) -> ( result: i32); // * s
ic0.in_replicated_execution: () -> (result: i32); // * s
ic0.debug_print : (src : I, size : I) -> (); // * s
ic0.trap : (src : I, size : I) -> (); // * s
2 changes: 2 additions & 0 deletions src/candid-extractor/ic_mock.wat
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
(func (export "msg_reject_code") (result i32) i32.const 0)
(func (export "msg_reject_msg_size") (result i32) i32.const 0)
(func (export "msg_reject_msg_copy") (param i32 i32 i32) )
(func (export "msg_deadline") (result i64) i64.const 0)
(func (export "msg_reply_data_append") (param i32 i32) )
(func (export "msg_reply") )
(func (export "msg_reject") (param i32 i32) )
Expand All @@ -30,6 +31,7 @@
(func (export "call_new") (param i32 i32 i32 i32 i32 i32 i32 i32) )
(func (export "call_on_cleanup") (param i32 i32) )
(func (export "call_data_append") (param i32 i32) )
(func (export "call_with_best_effort_response") (param i32) )
(func (export "call_cycles_add") (param i64) )
(func (export "call_cycles_add128") (param i64 i64) )
(func (export "call_perform") (result i32) i32.const 0)
Expand Down
3 changes: 2 additions & 1 deletion src/ic-cdk-timers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ extern "C" fn global_timer() {
| RejectionCode::DestinationInvalid
| RejectionCode::CanisterReject
| RejectionCode::CanisterError
| RejectionCode::SysUnknown
| RejectionCode::Unknown => {}
}
}
Expand Down Expand Up @@ -254,7 +255,7 @@ fn update_ic0_timer() {
};
if should_change {
// SAFETY: ic0::global_timer_set is always a safe call
unsafe { ic0::global_timer_set(soonest_timer.unwrap() as i64) };
unsafe { ic0::global_timer_set(soonest_timer.unwrap()) };
MOST_RECENT.with(|recent| recent.set(soonest_timer));
}
});
Expand Down
Loading
Loading