Skip to content
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: new system API to retrieve liquid cycle balance of a canister #4255

Merged
merged 4 commits into from
Mar 7, 2025

Conversation

mraszyk
Copy link
Contributor

@mraszyk mraszyk commented Mar 6, 2025

This PR implements a new system API ic0.canister_liquid_cycle_balance128 returning the current amount of cycles that is available for spending in calls and execution without getting frozen. This way, canisters can bound the amount of cycles attached to a call to prevent spurious traps when calling ic0.call_cycles_add or ic0.call_cycles_add128.

@github-actions github-actions bot added the feat label Mar 6, 2025
@mraszyk mraszyk marked this pull request as ready for review March 6, 2025 13:13
@mraszyk mraszyk requested a review from a team as a code owner March 6, 2025 13:13
Copy link
Contributor

@berestovskyy berestovskyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a big PR, and I don't have a single comment! Well done, Martin!

@mraszyk
Copy link
Contributor Author

mraszyk commented Mar 6, 2025

@berestovskyy I realized that I had to fix the universal canister in this commit: the binary length of the representation of an inter-canister call's payload in the input to the universal canister might not match the binary length of the actual payload (because the actual payload is only assembled at runtime by the universal canister from its input) and thus I've replaced the operation CallCyclesAddMax by the operation CallDataAppendCyclesAddMax which combines assembling the actual payload and attaching the maximum amount of cycles (knowing the actual paylod's length from the previous step and taking the method name length from an additional input to this operation).

@mraszyk mraszyk added this pull request to the merge queue Mar 7, 2025
Merged via the queue into master with commit 62f408b Mar 7, 2025
19 checks passed
@mraszyk mraszyk deleted the mraszyk/ic0-canister-liquid-cycle-balance128 branch March 7, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants