Skip to content

feat(network-monitor): inline .masm scripts as Rust string constants#2059

Closed
Ollie202 wants to merge 2 commits into0xMiden:mainfrom
Ollie202:fix/monitor-rust-scripts
Closed

feat(network-monitor): inline .masm scripts as Rust string constants#2059
Ollie202 wants to merge 2 commits into0xMiden:mainfrom
Ollie202:fix/monitor-rust-scripts

Conversation

@Ollie202
Copy link
Copy Markdown

@Ollie202 Ollie202 commented May 7, 2026

Summary

Closes #1831

  • Inlines counter_program.masm as COUNTER_PROGRAM_CODE: &str constant in deploy/counter.rs
  • Introduces CounterComponent struct following the IncrNonceAuthComponent pattern from miden-standards, with a LazyLock-compiled Library and a From impl
  • Inlines increment_counter.masm as INCREMENT_NOTE_SCRIPT: &str constant in counter.rs
  • Deletes the two .masm asset files

The MASM logic is unchanged — only the delivery mechanism changes from external files to Rust constants, improving maintainability and reducing the risk of protocol changes slipping through unnoticed.

Test plan

  • CI build and lint pass
  • Network monitor boots and counter increments as expected

Ollie202 added 2 commits May 7, 2026 08:29
Replace the counter_program.masm and increment_counter.masm asset files
with inline Rust string constants. Introduce CounterComponent following
the IncrNonceAuthComponent pattern from miden-standards, backed by a
LazyLock-compiled Library with a From impl. The note script is similarly
inlined as INCREMENT_NOTE_SCRIPT in counter.rs.

Closes 0xMiden#1831
Copy link
Copy Markdown
Collaborator

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

This just inlines the masm as a string.

The intent of the issue is to write the accounts in rust and then use the Miden rust compiler to compile this to masm.

@Ollie202
Copy link
Copy Markdown
Author

Ollie202 commented May 7, 2026

Closing — misunderstood the intent. Will reimplement using the Miden Rust compiler to compile Rust account code to MASM rather than just inlining the existing MASM as strings.

@Ollie202 Ollie202 closed this May 7, 2026
@Ollie202
Copy link
Copy Markdown
Author

Ollie202 commented May 7, 2026

Thanks for the clarification. I dug into the #[component] proc macro approach from the miden crate (the 0xMiden/project-template shows the pattern nicely), where you compile Rust to MASM via cargo miden build and load it with AccountComponent::from_package().

The issue I ran into is that AccountComponent::from_package() doesn't seem to exist in miden-protocol v0.14, which is what this repo currently depends on. It looks like it lives in the miden-client stack rather than here.

So I wanted to check before going further:

  1. Does this need the new toolchain (miden crate, cargo-miden, from_package API) integrated into the node's dependencies first?
  2. Or is there a different approach you had in mind that works within the current dependency set?

Happy to go whichever route makes sense.

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