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: wallet_call_with_max_cycles #170

Merged
merged 14 commits into from
Apr 10, 2024
Merged

Conversation

sesi200
Copy link
Contributor

@sesi200 sesi200 commented Apr 2, 2024

When the wallet is used to withdraw as many cycles as possible from a canister that will be deleted shortly, one wants to withdraw whatever is available. With this function it's no longer necessary to use heuristics to guesstimate how many cycles can be withdrawn.

Bumping the Rust version because

error: failed to compile `ic-wasm v0.7.1`, intermediate artifacts can be found at `/tmp/cargo-installLIevpn`

Caused by:
  package `clap_builder v4.5.2` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.70.0

@lwshang
Copy link
Contributor

lwshang commented Apr 2, 2024

Could you add a test?

@sesi200 sesi200 marked this pull request as draft April 8, 2024 13:10
@sesi200 sesi200 marked this pull request as ready for review April 9, 2024 09:17
Copy link
Contributor

@lwshang lwshang left a comment

Choose a reason for hiding this comment

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

LGTM.
Just a couple minor suggestions.

@@ -949,11 +949,15 @@ mod wallet {
)]
async fn call_with_max_cycles(args: CallWithMaxCyclesArgs) -> Result<CallResult, String> {
let available_cycles = ic_cdk::api::canister_balance128();
// If no margin is used then the call either fails locally with `Couldn't send message` or processing the response traps with `Canister out of cycles`.
// On the local network the margin needs to be ~1.7B cycles. (Experimentally determined in August 2024)
Copy link
Contributor

Choose a reason for hiding this comment

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

August 2024

Time travel ¯_(ツ)_/¯

@@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
node-version: [12.x]
rust: ['1.70.0']
rust: ['1.74.1']
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove the rust: ['1.74.1'] and the following "Install Rust" step from workflow files.

GitHub Action runners default to have Rust. And rust-toolchain.toml will automatically take effect.

Therefore, we will only need the Rust version in rust-toolchain.toml which is more maintainable.

@sesi200 sesi200 merged commit 98a8db8 into main Apr 10, 2024
22 checks passed
@sesi200 sesi200 deleted the severin/wallet_call_with_max_cycles branch April 10, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants