0xMiden / 0xMiden/compiler

Rust `#[tx_script]` cannot be executed in 0.15.0 — `.masp` rejected by `exec`, and `--emit masm` output is component-model annotated

Ouverte
#1,349 4 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Rust
Étoiles
115
Forks
84
Merge moyen
1 j 8 h
PR mergées (30 j)
15

Description

### Environment
- toolchain `0.15.0` (`midenup install stable`)
- account component + transaction script both authored in Rust, built with `cargo miden build --release`

### What works
Deploying a Rust account component works end to end:

```
miden client new-account -p my_component.masp -i init.toml --deploy
```

The account is created, and `miden client call :my_proc ` returns exactly the
storage delta I expect. So the component side of the toolchain is fine.

### The problem
`call` only *previews* the delta — it never commits (repeated calls always start from the same
committed state, nonce does not advance). To persist state a transaction script is needed.

I wrote one in Rust:

```rust
#[account(my_pkg::MyIface)]
pub struct NativeAccount;

#[tx_script]
fn run(arg: Word, account: &mut NativeAccount) {
account.my_proc(arg.a);
}
```

It builds successfully into `my_script.masp`.

**1. `exec` rejects the compiled package.**

```
$ miden client exec -a -s target/miden/release/my_script.masp
Error: cli::script_builder_error
x failed to build script: failed to parse transaction script:
source manager is unable to load file
`-> stream did not contain valid UTF-8
```

So `--script-path` wants MASM *source*, not the package.

**2. `--emit masm` produces MASM the script parser cannot accept.**

```
$ cargo miden build --release --emit masm=./masm_out
$ miden client exec -a -s ./masm_out/my_script.masm
Error: cli::script_builder_error
x invalid syntax
,-[my_script.masm:4:14]
3 | @callconv("component-model")
4 | pub proc run(struct { a: struct { inner: felt }, b: struct {
: ^^^|^^
: `-- found a struct here
5 | inner: felt
`----
help: expected ")", or identifier
```

The emitted MASM carries component-model type signatures (`@callconv("component-model")`,
`struct { ... }` parameters), which the transaction-script parser does not understand.

Note: `--emit masm` only produces output when the compiler actually re-runs — with a warm cargo
cache the directory is created but stays empty, which is a little confusing.

### Question
Is there a supported path from a Rust-authored `#[tx_script]` to something `miden client exec`
accepts in 0.15.0?

If transaction scripts must currently be hand-written in plain MASM, they would need to call the
account procedure by MAST root — but I could not find the per-procedure roots exposed anywhere
(`miden client account -s` shows only the Code Commitment, and the `.masp` exposes the export
name `"miden:my_pkg/my_iface@0.1.0#my_proc"` but not its digest). Is there a command to dump
procedure roots from a package?

### Minor, possibly separate
`miden deploy` (top-level alias) fails before parsing any arguments:

```
$ miden deploy
error: unexpected argument '-s' found
Usage: miden client [OPTIONS]
```

`miden simulate` resolves to `miden client exec`, which looks intentional, but `deploy` appears
to inject a stray `-s`.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Look at the compiler's handling of `#[tx_script]` attributes and the MASM emission path (`--emit masm`). The script parser expects plain MASM, but the compiler outputs component-model annotated MASM. Investigate the transaction script builder in the CLI (`miden client exec`) and the package format `.masp`. Check if there's a way to extract procedure MAST roots from a compiled package, or if the toolchain needs a separate compilation target for scripts.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
rust
Domaine
cli, compilers
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Clairement spécifiée
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.