-
Notifications
You must be signed in to change notification settings - Fork 112
feat: implement system cost primitives #5001
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
base: master
Are you sure you want to change the base?
feat: implement system cost primitives #5001
Conversation
test/run-drun/test-cost.mo
Outdated
print(debug_show(before0) # " -- Cycles.balance() before0"); | ||
print(debug_show(before1) # " -- Cycles.balance() before1"); | ||
print(debug_show(after) # " -- Cycles.balance() after"); | ||
print(debug_show (before1 - after : Nat) # " -- Cycles.balance() diff"); |
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.
Output from --playground
client: 500_000_000_000 -- create canister cost
client: created canister id: 7gngh-jqaaa-aaaab-qacvq-cai
client: 593_554_306_953 -- Cycles.balance() before0
client: 593_554_306_953 -- Cycles.balance() before1
client: 593_548_861_792 -- Cycles.balance() after
client: 5_445_161 -- Cycles.balance() diff
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.
500B is the documented cost, but why is the actual cost around 5M instead?
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.
- Why the reported canister cost is different than the actual amount?
- Why
(with cycles = )
was not needed here? Cycles were automatically deducted from the balance.
Whereas on the local replica this call was failing with not enough available cycles.
test/run-drun/test-cost.mo
Outdated
|
||
// let before = Cycles.balance(); | ||
printCycles(); | ||
let { canister_id } = await (with cycles = 500_000_000_000) ic00.create_canister({ settings = null }); |
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.
Output from the local replica:
38_461_538_461 -- create canister cost
already topped up; balance = 3_058_376_185_964
Cycles.balance() = 3_058_376_185_964
Cycles.available() = 0
Cycles.refunded() = 0
created canister id: be2us-64aaa-aaaaa-qaabq-cai
Cycles.balance() = 2_558_375_756_574
Cycles.available() = 0
Cycles.refunded() = 0
- The actual create canister cost is 38_461_538_461, which is smaller than the documented 500M, but this is probably a good sign
(with cycles = )
is required for the call to succeed. Why does it not deduct from the balance automatically?- Extra cycles are not refunded, is this expected? Are they lost?
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.
I think both 2 and 3 are expected:
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.
Not sure about 1 though....
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.
Ad 3.
All cycles on this call are now the canister's initial cycles.
Ok, so this might explain why cycles are not returned 👍
Ad 1. @alexandru-uta found the answer: The actual cost on a local replica is 1/13 of the documented value
Also Ad 2. My question was: Why (with cycles = )
were not needed for the drun test? It might be because what Alex found - that drun test run as a system subnet 🤷
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.
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.
Took a quick pass (not a review) and it looks like you are doing all the right things... Nice!
…at-tracks-how-much-certain-operations-cost
- Updated the `msg_cycles_accept128` function import to use the correct type. - Introduced a new `cost_call` function in the `Cost` module to handle cycle costs for calls. - Refactored existing cost functions for better clarity and organization.
// 1_603_066_000 -- http cost request | ||
// 1_603_060_000 -- http cost request (with requestSize = 0) | ||
// 1_603_260_000 -- http cost request (with requestSize = 500) | ||
// 1_603_660_000 -- http cost request (with requestSize = 1500) | ||
// 2_003_060_000 -- http cost request (with requestSize = 1_000_000) |
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.
not really accurate...
No description provided.