Skip to content

chore: migrate tutorials to protocol v0.15#204

Draft
Keinberger wants to merge 10 commits into
mainfrom
kbg/chore/v15-migration
Draft

chore: migrate tutorials to protocol v0.15#204
Keinberger wants to merge 10 commits into
mainfrom
kbg/chore/v15-migration

Conversation

@Keinberger

@Keinberger Keinberger commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Overview

This PR migrates all of the Miden tutorials (rust-client, web-client, and the miden-bank example) from protocol v0.14 to v0.15. The migration itself is complete: everything compiles, the doctests and the miden-bank MockChain tests pass, and all five web-client tutorials run end-to-end live on testnet. It stays a draft because two upstream bugs prevent the native tutorials from running live, and the miden-bank example still depends on an unreleased compiler. See "Status and blockers".

Motivation

v0.15 changed a lot across the stack: AccountStorageMode folded into AccountType, the FungibleFaucet builder + TokenPolicyManager, Felt::new becoming fallible, the fungible-asset vault-key layout, PartialNoteMetadata, the MAST wire format, and the cargo-miden #[component]/#[account]/#[note]/#[tx_script] redesign. Every tutorial needed source-verified updates, not just a version bump.

Changes

rust-client

  • Bumped miden-client / sqlite-store / protocol to 0.15; migrated all 11 src/bin/*.rs (drop .storage_mode(), AccountType::Public, Felt::new_unchecked, the FungibleFaucet + TokenPolicyManager faucet, and so on). cargo build is green.
  • docs/src/rust-client/*.md migrated; cargo test --doc passes (17 run, 0 failed).
  • MASM: note::build_recipient becomes note::compute_and_store_recipient.

web-client

  • Bumped @miden-sdk/* to 0.15.2; migrated lib/* + lib/react/* (faucet type: 0, fresh recipient accounts, the getItem(...) StorageResult handling).
  • All five browser tutorials verified live on testnet via Playwright; see Tests.

miden-bank example

  • The four cargo-miden contracts migrated to the v0.15 compiler model (#[component_storage] + #[component] trait/impl, #[account]/#[note]/#[tx_script]); a new miden-project.toml + .cargo/config.toml per contract. get_balance is renamed to get_depositor_balance (it collided with the built-in ActiveAccount::get_balance the account wrapper generates), and the v0.15 fungible-asset key layout (where asset.key[2] folds in a metadata byte) is handled through a shared balance_key helper.
  • Integration crate migrated: the new cargo_miden::run signature, the now-required InitStorageData seeding of the initialized slot, a build_tx_script_from_package helper (tx-script packages are TransactionScript-kind, not Executable), and a .masp persist step (a workaround for the compiler issue below). All MockChain tests pass (deposit x3, init, withdraw).
  • docs/src/miden-bank/* migrated to match the code.

shared docs

  • miden_node_setup.md node tag v0.14.6 becomes v0.15.0.

Status and blockers

Tutorial Code migrated Verified by Live on testnet
web-client (5 flows) yes Playwright (live) works
rust-client (mint/consume/send, notes) yes cargo build + doctests blocked: 0xMiden/rust-sdk#2289
rust-client (counter deploy/increment/fpi) yes cargo build blocked: stale hardcoded id (ours) + 0xMiden/rust-sdk#2289
rust-client (oracle) yes cargo build blocked: Pragma v0.15 redeploy + 0xMiden/rust-sdk#2289
miden-bank yes MockChain tests blocked: tagged compiler release + 0xMiden/rust-sdk#2289

1. miden-client runtime bug (0xMiden/rust-sdk#2289) blocks live execution of every native tutorial. Any fresh (nonce-0) account whose first transaction reads one of its own StorageMaps fails during local execution with an advice-map miss. This includes a standard FungibleFaucet mint, so it hits the rust-client basics as well as the miden-bank live bins. It is not part2-specific and not a tutorial-usage error: our flow is byte-identical to the SDK's own faucet helper and its endorsed real-node test. The web tutorials are unaffected (the WASM @miden-sdk is a separate, self-consistent line), and the MockChain tests pass (miden-testing serves the witness from the in-memory account).

2. Compiler dependency (miden-bank only). The four contracts pin the compiler by git rev because the part2 sibling-call work (0xMiden/compiler#1180) is merged into next but not in a tagged cargo-miden/miden release yet. The integration crate also copies the compiled .masp into target/miden/<profile> because cargo miden build writes it to target/midenc/miden/... while the FPI #[account] macro searches target/miden/... (0xMiden/compiler#1214, fixed in flight by 0xMiden/compiler#1216). Both workarounds drop once there is a tagged release with the part2 work + #1216 (tracked in 0xMiden/project-template#51). This does not affect rust-client or web-client.

Tests

Open Questions

  1. Compiler release: the contracts pin a git rev until there is a tagged cargo-miden/miden release with the part2 work + fix(cargo-miden): materialize compiled dependency packages on disk compiler#1216. Hold this PR behind feat: migrate to next compiler SDK (protocol v0.15) project-template#51, or merge with the workarounds documented?
  2. Native live bins: keep the rust-client and miden-bank live bins in the repo with the documented Deploying a part2-compiled #[account] component fails at local execution: "value for key … not present in the advice map" (submit_new_transaction, new account) rust-sdk#2289 limitation, or gate them behind a notice until it is fixed?

Keinberger and others added 3 commits June 25, 2026 15:44
The format-markdown job ran `npm install -g prettier` with no version, so it
silently picked up prettier 3.9.0/3.9.1 (published 2026-06-27). 3.9.0 regressed
on `embeddedLanguageFormatting: off`: it reformats the embedded JSX in the
web-client `<CodeSdkTabs example={{...}} />` components, deleting the closing
`}}` and producing invalid, non-idempotent output — so the check could never
pass on 3.9.x without deforming the docs.

Pin to prettier 3.8.4 (the latest release before the regression) so the check is
deterministic and the web-client components stay intact, and apply the
outstanding prettier formatting to the miden-bank docs (table alignment +
emphasis-marker normalization). `prettier@3.8.4 --check "**/*.md"` is clean.

Bump the pin once the 3.9.x embeddedLanguageFormatting regression is fixed upstream.
@BrianSeong99

Copy link
Copy Markdown
Contributor

Added a simple fix to the markdown formatter, the latest release of prettier tool seems to have conflict with some of our existing docs. So spinning the prettier tool to previous versions that we used and can work on adapting the prettier tool to the latest version after v15 migration.

…branch

The four contract crates and the integration crate pinned the `miden`/`cargo-miden`
git dependency to `branch = "i697-acc-sibling-call-part2"`. That branch was merged
into `next` and deleted, so a fresh checkout can no longer resolve it.

Pin to the exact commit the lockfiles already reference
(97eb019ded3a2d1f29d77639190bad5d3f0f099b) via `rev` instead. It's the commit this
PR was built and tested against, and it's a clean ancestor of `next` (next is 6
commits ahead, 0 behind), so cargo can still fetch it. The resolved compiler is
unchanged — only the lock source strings flip `branch=` → `rev=` (same SHA).

A moving branch ref (`next`) is intentionally avoided. Swap `rev` for a tagged
compiler release once one exists for the v0.15-aligned (SDK 0.13) line.
@BrianSeong99 BrianSeong99 self-requested a review June 29, 2026 04:04
BrianSeong99 and others added 4 commits June 29, 2026 14:53
Follow-ups from the v0.15 migration review:
- The miden-bank tutorial Cargo.toml snippets (and two prose lines) still showed
  the deleted `branch = "i697-acc-sibling-call-part2"`; update them to the
  `rev = "97eb019…"` pin the real manifests now use, so copy-pasted snippets resolve.
- web-client unauthenticated_note_how_to: the React consume() snippet passed the
  Account `alice`; the lib passes `alice.id().toString()` (a string). Match the lib.

(The react_wallet custom-signer `accountType: "RegularAccountImmutableCode"` was
verified valid against @miden-sdk/react 0.15.2's SignerAccountType union — no change.)
The v0.15 migration replaced the tutorials' hardcoded recipient addresses with freshly-created accounts, changing what each tutorial demonstrates (the SDK still accepts a bech32 string for the recipient). Revert to hardcoded recipients using fresh valid v0.15 testnet ids so the migration stays version-only. Docs mirror the source.
…ents

balance_key was extracted into a helper during migration (a non-forced refactor) and the v0.14 pedagogical comments were trimmed. Inline the key-derivation (behavior-identical: same [prefix, suffix, key[3], key[2]] word) and restore the doc-comments, keeping the change migration-only. MockChain tests pass (deposit x3, init, withdraw).
Part 4's deposit_test snippet had drifted (faucet supply 10_000_000, sender 1000); align with the source test and Part 3 (faucet 1000, sender 100).
Audit fidelity fixes: replace the removed balance_key helper references in Parts 3/7 with the inline key derivation the contract uses, correct Part 4's false 'init deferred / guard commented out' claims (the shipped deposit_test.rs initializes and require_initialized() is active), and tighten the asset.key[2]/[3] + metadata-byte wording in the contract and withdraw test. Comments and docs only; MockChain tests pass.
…geMode API

SignerAccountConfig.storageMode is typed AccountStorageMode (a class), so use AccountStorageMode.public() (imported from @miden-sdk/react/lazy) instead of the StorageMode string union, and drop the deprecated accountType field.
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