Skip to content

feat(network-monitor): compile counter program and note script at build time#2066

Open
Ollie202 wants to merge 3 commits into0xMiden:nextfrom
Ollie202:fix/monitor-build-time-masm
Open

feat(network-monitor): compile counter program and note script at build time#2066
Ollie202 wants to merge 3 commits into0xMiden:nextfrom
Ollie202:fix/monitor-build-time-masm

Conversation

@Ollie202
Copy link
Copy Markdown

@Ollie202 Ollie202 commented May 9, 2026

Summary

Closes #1831.

Replaces runtime MASM compilation (CodeBuilder + include_str!) with build-time compilation via build.rs, following the same pattern used by production components in miden-standards.

  • build.rs compiles counter_program.masm to a .masl library and increment_counter.masm to a serialized NoteScript binary
  • Both artifacts are embedded via include_bytes! and loaded once via LazyLock
  • deploy/counter.rs now exposes a CounterComponent Rust struct with From<CounterComponent> for AccountComponent, mirroring how AuthSingleSig, BasicWallet, etc. are structured in miden-standards
  • counter.rs loads the pre-compiled note script from OUT_DIR instead of compiling at startup
  • Protocol breakage now surfaces as a cargo build failure, caught by CI rather than silently at runtime

Test plan

  • cargo build -p miden-network-monitor compiles without errors (verifies build-time MASM compilation succeeds)
  • cargo +nightly fmt --all --check passes
  • cargo clippy -p miden-network-monitor passes

…ld time

Replaces runtime MASM compilation (CodeBuilder + include_str!) with
build-time compilation via build.rs. The counter program is compiled to
a .masl library and the increment note script to a serialized NoteScript
binary, both embedded via include_bytes!. This catches protocol breakage
at cargo build time rather than silently at startup.

Closes 0xMiden#1831.
@Ollie202 Ollie202 force-pushed the fix/monitor-build-time-masm branch from 387ba09 to 9c17311 Compare May 9, 2026 08:49
Copy link
Copy Markdown
Collaborator

@SantiagoPittella SantiagoPittella left a comment

Choose a reason for hiding this comment

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

As @Mirko-von-Leipzig said previously:

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.

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.

Consider writing monitor transaction/note scripts in Rust

2 participants