Skip to content

chore: migrate rust/low_wasm_memory to icp-cli#1393

Merged
marc0olo merged 14 commits into
masterfrom
chore/migrate-rust-low-wasm-memory-to-icp-cli
Jun 19, 2026
Merged

chore: migrate rust/low_wasm_memory to icp-cli#1393
marc0olo merged 14 commits into
masterfrom
chore/migrate-rust-low-wasm-memory-to-icp-cli

Conversation

@marc0olo

@marc0olo marc0olo commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Migrates rust/low_wasm_memory from dfx to icp-cli, aligned with motoko/low_wasm_memory. Also converts the Motoko example's Makefile to a bash script for consistency.

Removed: dfx.json, both Makefile files, old rust-low_wasm_memory-example.yml

Changed:

  • icp.yaml (Rust): replaces dfx.json; uses @dfinity/rust@v3.3.0
  • backend/lib.rs: source moved from src/low_wasm_memory_hook/; package renamed to backend; attribute macros updated to modern ic_cdk:: proc-macro style
  • rust-toolchain.toml: added with wasm32-unknown-unknown target
  • Memory limits (wasm_memory_limit: 8mib, wasm_memory_threshold: 2mib) moved from test scripts into icp.yaml settings for both Rust and Motoko — applied at deploy time, no separate configure step needed
  • rust/low_wasm_memory/test.sh (replaces Makefile): polls get_executed_functions_order up to 60s for OnLowWasmMemory
  • motoko/low_wasm_memory/test.sh (replaces Makefile): same structure, Motoko naming (getExecutedFunctionsOrder / onLowWasmMemory)
  • README.md (both): updated to bash test.sh; documents the configured limits
  • CI: low_wasm_memory.yml — both jobs use bash test.sh; images icp-dev-env-rust:1.0.1 and icp-dev-env-motoko:1.0.1

Alignment with motoko/low_wasm_memory: Both examples use identical memory limits and the same polling test structure. Naming differences are idiomatic per language (snake_case Rust vs camelCase Motoko).

Test plan

  • icp network start -d && icp deploy && bash test.sh passes locally (Rust)
  • icp network start -d && icp deploy && bash test.sh passes locally (Motoko)
  • CI jobs rust-low_wasm_memory and motoko-low_wasm_memory pass

🤖 Generated with Claude Code

@marc0olo marc0olo marked this pull request as ready for review June 17, 2026 14:13
@marc0olo marc0olo requested review from a team as code owners June 17, 2026 14:13
Comment thread rust/low_wasm_memory/README.md Outdated
@marc0olo

Copy link
Copy Markdown
Member Author

@michael-weigelt switched to bash for the test scripts now.

marc0olo and others added 7 commits June 19, 2026 12:07
Replaces dfx.json with icp.yaml, moves canister source from src/low_wasm_memory_hook/ to backend/, adds Makefile with configure+test targets using icp-cli, updates CI to use icp-dev-env-rust:1.0.0, and removes the legacy dfx-based workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
candid-extractor 0.1.4 (in 1.0.0) fails on ic-cdk 0.20 WASMs that
import ic0::cost_call. Fixed in 1.0.1 (candid-extractor 0.1.6).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Aligns with the canonical layout used in rust/backend_only and other
migrated examples (path = "lib.rs" directly in backend/).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…patibility

Convert the Makefile configure+test targets into a single test.sh bash
script. No logic changes — same memory limit config and 60s polling loop.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ompatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo reopened this Jun 19, 2026
marc0olo and others added 7 commits June 19, 2026 12:10
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…st script

Move wasm_memory_limit (5mib) and wasm_memory_threshold (2mib) from
the icp canister settings update call in test.sh into icp.yaml settings,
so the canister is deployed with the correct limits from the start.
This makes the configuration self-documenting and removes the separate
configure step from both Motoko and Rust test scripts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both READMEs previously described test.sh as configuring memory limits.
Now the limits are in icp.yaml (applied at deploy time), so the README
explains that, and test.sh is described as just polling.
Also adds missing Node.js prerequisite to the Rust README.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… configure step

The Motoko runtime temporarily peaks above 5 MiB during canister
installation (GC has not yet run), so wasm_memory_limit: 5mib in
icp.yaml causes installation to fail with IC0539.

The Rust canister starts at ~1.5 MiB and works fine with icp.yaml settings.
For Motoko, the settings must be applied post-deployment via
icp canister settings update, once memory has settled to ~2.3 MiB.

README updated to explain this difference.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… highlight runtime difference

Motoko's GC/heap temporarily peaks at ~5.3 MiB during installation,
requiring wasm_memory_limit: 8mib (vs 5mib for Rust). Both examples
now configure memory limits entirely in icp.yaml; test.sh is a pure
polling script.

Both READMEs note the difference: Rust starts at ~1.5 MiB (5 MiB
limit works), Motoko starts at ~5.3 MiB peak during init (needs 8 MiB).
This is a genuine educational insight about the two runtimes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both examples now use wasm_memory_limit: 8mib and wasm_memory_threshold: 2mib.
Removed approximations about starting memory sizes from READMEs and
test.sh comments — only state what is known for certain from icp.yaml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo merged commit 41ddee2 into master Jun 19, 2026
7 checks passed
@marc0olo marc0olo deleted the chore/migrate-rust-low-wasm-memory-to-icp-cli branch June 19, 2026 11:10
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.

3 participants