Skip to content

Migrate to the VM v0.20.0#2158

Merged
bobbinth merged 21 commits intonextfrom
andrew-migrate-to-v20-vm
Dec 20, 2025
Merged

Migrate to the VM v0.20.0#2158
bobbinth merged 21 commits intonextfrom
andrew-migrate-to-v20-vm

Conversation

@Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Dec 10, 2025

This PR updates the code to work with miden-vm v0.20.0 and miden-crypto v0.19.2.

Specifically these changes were applied:

  • Account components now created using the name if their files: user will be able to call specific component procedure using its name (e.g. call.::rpo_falcon_512_multisig::update_signers_and_threshold)
    • As a consequence file names in the miden-lib/asm/account_components were updated.
  • Any mentions of the stdlib were changed to core lib.
  • in_debug_mode parameter was removed from the CodeBuilder and build_send_notes_script method of the AccountInterface.

Open questions and follow ups:

  • Should the AccountComponent::get_procedure_root_by_name method be renamed to get_procedure_root_by_path, following Library refactoring?
  • Remove SMT_PEEK_EVENT from asset_valut: Remove the SMT_PEEK_EVENT event #2115.

Migration guide

  • MASM syntax

    const.A -> const A
    export.foo -> pub proc foo
    proc.bar -> proc bar
    use.miden::<*> -> use miden::<*>
    export.miden::foo::bar -> pub use miden::foo::bar (re-export case)
    
  • Stdlib

    Standard library was renamed, so instead of StdLibrary now the CoreLibrary should be used. It has the same API, so just simple renaming should work. Its MASM usage also changes, so now instead of std:: the miden::core:: should be used.
  • Debug mode

    in_debug_mode parameter was removed from CodeBuilder and related methods. Simple removing the parameter or method call will work.
  • LibraryPath

    LibraryPath was removed, now you can use Path instead (notice that now there are two paths: from std and from miden_assembly). compile_and_statically_link_from_dir assembler method was updated to work with paths, so to get the same final library you can provide relevant Path or even just a the static string. For example:
    // Old version. Parameters are "$kernel" and "asm/shared_utils"
    assembler.compile_and_statically_link_from_dir(kernel_namespace.clone(), &shared_utils_path)?;
    
    // New version. Parameters are "asm/shared_utils" and "::$kernel"
    assembler.compile_and_statically_link_from_dir(
        &shared_utils_path,
        miden_assembly::Path::kernel_path(),
    )?;
  • Account Components

    get_procedure_root_by_name() method was renamed to get_procedure_root_by_path() to match the Library API. In most cases no further changes are required, but notice that the procedure path should include the module name, i.e. "basic_fungible_faucet::distribute".

@Fumuran Fumuran marked this pull request as draft December 10, 2025 21:01
@Fumuran Fumuran marked this pull request as ready for review December 15, 2025 15:57
@mmagician mmagician requested a review from Copilot December 15, 2025 18:05

This comment was marked as resolved.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you! I left some questions/comments inline - but most of these can be addressed in follow-up PRs.

Overall, in terms of follow-ups, I think we have:

  • Remove the SMT_PEEK_EVENT from asset vault (we have an issue for this).
  • Change hperm and hmerge to rpo256::permute and rpo256::merge everywhere.
  • Rename RpoFalcon512 to Falcon512Rpo everywhere.
  • Figure out if we can still search for procedures by name in account components.
  • Export/import constants directly (instead of having wrapper functions) - I think we might have an issue for this as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not for this PR, but we should rename RpoFalcon512 to Falcon512rpo to be consistent with naming everywhere.

proc_name: impl TryInto<QualifiedProcedureName>,
) -> Option<Word> {
self.code.as_library().get_procedure_root_by_name(proc_name)
pub fn get_procedure_root_by_name(&self, proc_name: impl AsRef<Path>) -> Option<Word> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should probably rename this to keep things consistent.

Ideally, we'd actually be able to find procedures by name, but for this we'd need to make sure all procedures in a component are uniquely named - and this will probably require some re-work. Let's create an issue for this.

Comment on lines +75 to +76
const DISTRIBUTE_PROC_NAME: &str = "network_fungible_faucet::distribute";
const BURN_PROC_NAME: &str = "network_fungible_faucet::burn";
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: could we assemble things differently so that these remain just as names rather than pats (or maybe a path with a single component)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is potentially possible, but will make creating procedure digests with procedure_digest! macro a bit less convenient (because AFAICS this is the only place where we use there constants).

To load a proc digest from some library we need to have a full path of this procedure. So we can change the names back to have just a procedure name, but we will have to additionally supply the library name to the macro to build an absolute path of this procedure.

This problem is actually the same to being able to search for the procedure in the account component using just the proc name.

Copy link
Contributor

@PhilippGackstatter PhilippGackstatter left a comment

Choose a reason for hiding this comment

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

Looks good to me!

// add the shared util modules to the kernel lib under the ::$kernel::util namespace
assembler.compile_and_statically_link_from_dir(
&shared_utils_path,
miden_assembly::Path::kernel_path(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I would import Path directly. Applies to more occurrences in this file.

@mmagician
Copy link
Collaborator

Note: as discussed in the client sync: not to be merged until @igamigo's follow-up to storage slots refactoring is in; the reason is that we'd like to migrate miden-client repo to use named storage slots first, so as to minimize the migration surface. A second migration to miden-client would follow after this PR is in.

@bobbinth
Copy link
Contributor

Note: as discussed in the client sync: not to be merged until @igamigo's follow-up to storage slots refactoring is in; the reason is that we'd like to migrate miden-client repo to use named storage slots first, so as to minimize the migration surface. A second migration to miden-client would follow after this PR is in.

This also means that PRs which are likely to contain significant changes should be built on top of this PR.

@PhilippGackstatter
Copy link
Contributor

PhilippGackstatter commented Dec 17, 2025

@huitseeker Do you have a suggestion for resolving this cargo deny error?

error[duplicate]: found 2 duplicate entries for crate 'syn'
    ┌─ /home/runner/work/miden-base/miden-base/Cargo.lock:259:1
    │  
259 │ ╭ syn 1.0.109 registry+https://github.com/rust-lang/crates.io-index
260 │ │ syn 2.0.111 registry+https://github.com/rust-lang/crates.io-index
    │ ╰─────────────────────────────────────────────────────────────────┘ lock entries
    │  

https://github.com/0xMiden/miden-base/actions/runs/20288516906/job/58267639301#step:4:21

It seems like most things in the dependency tree use syn = 2 but Miden VM uses syn = 1. Maybe that can be updated to 2?

But also, since this is a build dependency, I think we can just allow duplicate versions.

Edit: Even when allowing syn duplicates, there are more cargo deny errors after that.

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

This LGTM. @PhilippGackstatter I pushed the setting that allows syn duplicates as the last commit of this PR. It seems to have fixed CI.

@bobbinth bobbinth merged commit b9aea90 into next Dec 20, 2025
18 checks passed
@bobbinth bobbinth deleted the andrew-migrate-to-v20-vm branch December 20, 2025 07:51
afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Jan 15, 2026
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.

6 participants