Skip to content

Migrate to VM v0.22 and protocol v0.14#995

Draft
greenhat wants to merge 49 commits intonextfrom
pr/migrate-to-v0.21.1
Draft

Migrate to VM v0.22 and protocol v0.14#995
greenhat wants to merge 49 commits intonextfrom
pr/migrate-to-v0.21.1

Conversation

@greenhat
Copy link
Contributor

@greenhat greenhat commented Mar 4, 2026

Close #970

This PR migrates the compiler and SDK stack to the newer Miden VM/runtime APIs, centered around miden-vm 0.22 and the corresponding protocol/base updates.

On the compiler side, this updates wasm lowering/codegen to match the new VM conventions, including the generalized sign-extension op, corrected little-endian limb handling for 64-bit values, and removal of legacy intrinsics in favor of the newer core/stdlib entry points.

The Miden SDK public API changes in this PR are:

  • Asset changes from a single-word layout (inner: Word) to a two-word layout (key: Word, value: Word), and Asset::new now takes (key, value).
  • asset::build_fungible_asset / asset::build_non_fungible_asset are renamed to asset::create_fungible_asset / asset::create_non_fungible_asset.
  • active_note::get_inputs() is renamed to active_note::get_storage().
  • input_note::get_inputs_info() is renamed to input_note::get_storage_info(), and InputNoteInputsInfo becomes InputNoteStorageInfo { commitment, num_storage_items }.
  • active_account gains get_asset and get_initial_asset for direct vault lookups by asset key.
  • AccountId, Tag, NoteIdx, and NoteType now convert to/from Word, and StorageSlotId adds to_suffix_prefix().
  • The top-level SDK re-export Felt and Word from miden_field(miden-core).

Triggered by the migration changes in this PR:

  • Generalize wasm sign-extension lowering/codegen and add explicit coverage for the new i32/i64 sign-extension cases.
  • Fix 64-bit limb ordering in MASM memory/int codegen and related evaluation/codegen tests.
  • Add the missing cabi_realloc runtime export required by generated component bindings when values are passed indirectly (Triggered by the Asset becoming two word size).

This PR is quite large. I suggest reviewing it on a per-commit basis, skipping not-important commits.

TODO:

miden-clien migration PR - 0xMiden/miden-client#1891

@greenhat
Copy link
Contributor Author

The integration tests are to be migrated after 0xMiden/miden-client#1891 is ready/merged.

@greenhat
Copy link
Contributor Author

@bitwalker @mooori I'm mostly finished with this PR. I'm combing through it to do some cleanups and I'm waiting for the client/node PR updated with released protocol crates.
With these cautions, I think you can review it.

I suggest to review it on a per-commit basis, skipping non-important commits.

@greenhat greenhat requested review from bitwalker and mooori March 24, 2026 14:25
@greenhat greenhat changed the title Migrate to VM v0.21 and protocol v0.14 Migrate to VM v0.22 and protocol v0.14 Mar 25, 2026
@greenhat greenhat force-pushed the pr/migrate-to-v0.21.1 branch from 0183581 to 9999250 Compare March 25, 2026 13:06
djolertrk and others added 12 commits March 25, 2026 15:13
Migrate the compiler workspace from miden-vm v0.20 (crates.io) to
v0.21.1 (local checkout) and miden-base v0.13 to v0.14.

Key breaking changes addressed:
- Remove FieldElement/StarkField traits (now inherent methods on Felt)
- .as_int() -> .as_canonical_u64() across all crates
- miden_core::Program -> miden_core::program::Program
- miden_core::AdviceMap -> miden_core::advice::AdviceMap
- miden_core::utils::{Serializable,Deserializable} -> miden_core::serde::*
- miden_assembly::utils::Deserializable -> miden_assembly::serde::*
- Felt::ELEMENT_BYTES/read_from_bytes/elements_as_bytes removed
- Felt::inv() -> Field::try_inverse()
- StackOutputs::get_stack_item() -> get_element()
- miden_processor::AdviceInputs -> miden_processor::advice::AdviceInputs
- MASM: u32overflowing_mul -> u32widening_mul
- MASM: u32overflowing_madd -> u32widening_madd
- Breakpoint instruction removed (mapped to Nop)
- NoteInputs -> NoteStorage in miden-protocol v0.14
- Felt::from(bool) removed
- SmtLeaf::to_elements() now returns iterator (needs .collect())
use re-exported trait from the `miden-field`.
greenhat added 29 commits March 25, 2026 15:13
through the Wasm CM boundary, triggered by the `Asset` growth (to 2 words)
@greenhat greenhat force-pushed the pr/migrate-to-v0.21.1 branch from 9999250 to 95ef09a Compare March 25, 2026 13:17
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.

Migrate to VM v0.21

2 participants