-
Notifications
You must be signed in to change notification settings - Fork 465
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
Add system API endpoints for cycle cost calculation #4110
base: master
Are you sure you want to change the base?
Conversation
🤖 Here's your preview: https://c4y23-xqaaa-aaaam-abayq-cai.icp0.io |
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.
Could you please also add functions into the formal semantics: the actual return value can be abstracted over as arbitrary()
, but the rest should follow, e.g., ic0.canister_cycles_balance128
.
Co-authored-by: mraszyk <31483726+mraszyk@users.noreply.github.com>
Co-authored-by: mraszyk <31483726+mraszyk@users.noreply.github.com>
Co-authored-by: mraszyk <31483726+mraszyk@users.noreply.github.com>
Co-authored-by: mraszyk <31483726+mraszyk@users.noreply.github.com>
Co-authored-by: mraszyk <31483726+mraszyk@users.noreply.github.com>
Co-authored-by: mraszyk <31483726+mraszyk@users.noreply.github.com>
Here's an idea for a different approach:
The advantages as I see them:
The only downside that I see is that the cost of the |
@oggy-dfin thanks for the input. I like that this approach leads to a smaller API surface and covers current and future use cases. The problem I see is with parsing the payload, as you have pointed out yourself: This is cheap and constant effort for the So we would buy extensibility with 1) more complexity in the impl and 2) more costs to the caller. But is extensibility really worth that? I would consider adding a new system API endpoint of an existing type is a small effort already. Although granted, it is less pleasant than an API that just covers it by design. Another downside of simulating a call is that you have to have your payload ready to know the cost. If you have access to the proposed API, where you can just provide some payload lengths, you can make decisions based on costs before deciding on the details of a call. Not sure how interesting this is in reality, but it would suck if people had to compose some dummy data just to predict the cost of a similar call. |
is this benchmark using serde_bytes for decoding Vec?
a dependency on candid already exists in the system-api crate for the sake of routing
this complexity can't be avoided, it can only be pushed to the CDKs |
I measured the instructions on a canister that turns a Vec into a struct using candid::Decode!(). Whether candid uses serde_bytes itself, idk.
Yes. But there, the precise call type is already known without inspecting a blob. |
serde_bytes are used if the type you want to decode contains corresponding serde_bytes annotation. Could you please share the type definition you're decoding to? |
I think what rubs me the wrong way about the current proposal and the problem of possible future extensions is that the couples the System API (which is currently oblivious to the existence of the management canister and all other functionality) with these other special aspects of the system. Obviously my proposal would also couple them, just at the implementation level (by having to understand the payload) instead of the API level, and in some sense it's inevitable if we want to provide a synchronous API. |
While I agree with your analysis, I'd make a different trade-off. Having an API that is agnostic to the details has these disadvantages:
|
Design Doc