-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat: burning cycles programmatically #4690
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This looks good!
Co-authored-by: Luc Blaeser <112870813+luc-blaeser@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the interpreters? Did we just crash on other cycles prims or do we need to adjust?
UPDATE: I checked the code and both interpreters just crash on cycles prims, so this is no worse. No need to fix now.
@@ -5338,7 +5338,7 @@ module Cycles = struct | |||
|
|||
let balance env = | |||
Func.share_code0 Func.Always env "cycle_balance" [I64Type] (fun env -> | |||
Stack.with_words env "dst" 4L (fun get_dst -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch (here and below). I guess we were over stack allocating here ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for the quick implementation!
This adds a new primitive
(prim "cyclesBurn")
and aprim.mo
functioncyclesBurn : <system> Nat -> Nat
. It can be used to burn (some of the) canister's cycles programmatically using the system interfaceic0.cycles_burn128
.