Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit bed36d9

Browse files
authored
fix: ic0.call_perform spec (#348)
1 parent 8dabf9d commit bed36d9

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

spec/index.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ There must be at most one call to `ic0.call_on_cleanup` between `ic0.call_new` a
17181718

17191719
This deducts `MAX_CYCLES_PER_RESPONSE` cycles from the canister balance and sets them aside for response processing.
17201720

1721-
If the function returns `0` as the `err_code`, the IC was able to enqueue the call. In this case, the call will either be delivered, returned because the destination canister does not exist or returned because of an out of cycles condition. This also means that exactly one of the reply or reject callbacks will be executed.
1721+
If the function returns `0` as the `err_code`, the IC was able to enqueue the call. In this case, the call will either be delivered, returned because the destination canister does not exist, returned due to a lack of resources within the IC, or returned because of an out of cycles condition. This also means that exactly one of the reply or reject callbacks will be executed.
17221722

17231723
If the function returns a non-zero value, the call cannot (and will not be) performed. This can happen due to a lack of resources within the IC, but also if it would reduce the current cycle balance to a level below where the canister would be frozen.
17241724

@@ -7197,23 +7197,21 @@ ic0.call_peform<es>() : ( err_code : i32 ) =
71977197
if es.context ∉ {U, CQ, Ry, Rt, CRy, CRt, T} then Trap {cycles_used = es.cycles_used;}
71987198
if es.pending_call = NoPendingCall then Trap {cycles_used = es.cycles_used;}
71997199

7200-
es.balance := es.balance - MAX_CYCLES_PER_RESPONSE
7201-
7202-
// are we below the freezing threshold?
7203-
// Or maybe the system has other reasons to not perform this
7204-
if liquid_balance(es) < 0 or system_cannot_do_this_call_now()
7200+
// `system_cannot_do_this_call_now` abstracts over resource issues preventing the call from being made
7201+
if liquid_balance(es) < MAX_CYCLES_PER_RESPONSE or system_cannot_do_this_call_now()
72057202
then
72067203
discard_pending_call<es>()
72077204
return <implementation-specific>
72087205
or
7206+
es.balance := es.balance - MAX_CYCLES_PER_RESPONSE
72097207
es.calls := es.calls · es.pending_call
72107208
es.pending_call := NoPendingCall
72117209
return 0
72127210

72137211
// helper function
72147212
discard_pending_call<es>() =
72157213
if es.pending_call ≠ NoPendingCall then
7216-
es.balance := es.balance + MAX_CYCLES_PER_RESPONSE + es.pending_call.transferred_cycles
7214+
es.balance := es.balance + es.pending_call.transferred_cycles
72177215
es.pending_call := NoPendingCall
72187216

72197217
ic0.stable_size<es>() : (page_count : i32) =

0 commit comments

Comments
 (0)