Rust `#[tx_script]` cannot be executed in 0.15.0 — `.masp` rejected by `exec`, and `--emit masm` output is component-model annotated
- 主要語言
- Rust
- 星號
- 115
- 分支
- 84
- 平均合併
- 1 天 8 小時
- 30 天內合併 PR
- 15
描述
### 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`.
貢獻指南
研究方向
查看編譯器對 `#[tx_script]` 屬性的處理以及 MASM 輸出路徑 (`--emit masm`)。腳本解析器期望的是純 MASM,但編譯器輸出的是帶有元件模型註解的 MASM。調查 CLI 中的交易腳本建構器 (`miden client exec`) 和套件格式 `.masp`。檢查是否有方法可以從已編譯的套件中提取程序 MAST 根,或者工具鏈是否需要為腳本設定單獨的編譯目標。
由索引模型根據 Issue 內容生成。
評估
- 領域
- cli, compilers
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 活躍
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100