`miden client exec` cannot take a compiled transaction script package
- Lingua principale
- Rust
- Stelle
- 78
- Fork
- 129
- Merge medio
- 4g 14h
- PR unite (30g)
- 52
Descrizione
Reporting here per bitwalker's suggestion in 0xMiden/compiler#1349.
`exec` only accepts MASM source. `--script-path` is read and handed to `CodeBuilder::compile_tx_script`, so passing the `.masp` that `cargo miden build` produces fails with `stream did not contain valid UTF-8` rather than anything about packages. There is no flag for a compiled script on 0.15.0, and `ExecCmd` on `main` still carries a single `script_path`.
The conversion is available in the protocol crate, and I verified it on a package built from a Rust `#[tx_script]`:
```rust
let package = Package::read_from_bytes(&fs::read(path)?)?;
let entrypoint: QualifiedProcedureName =
r#"::"miden:base/transaction-script@1.0.0"::run"#.parse()?;
let tx_script = TransactionScript::from_package(&package.make_executable(&entrypoint)?)?;
```
`TransactionScript::from_package` alone is not enough today, since it turns down a package whose kind is `transaction-script`; `make_executable` is what gets it accepted. That half is 0xMiden/protocol#3769.
So `exec` could dispatch on the file it is given: a `.masp` through the path above, anything else through `compile_tx_script` as now. I am happy to put up a PR, but I would rather not guess between overloading `--script-path` and adding a separate `--package` flag, so say which you would prefer.
I checked the conversion only, not execution of the resulting script against an account.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Look at the `exec` command in the CLI code, likely in `src/cli/commands/exec.rs`. The `ExecCmd` struct currently has a `script_path`. You need to add logic to detect a `.masp` file extension and use `Package::read_from_bytes` and `TransactionScript::from_package` via `make_executable`. Check how `CodeBuilder::compile_tx_script` is called to understand the current flow. Test by building a transaction script package with `cargo miden build` and running `miden client exec` with the resulting `.masp` file.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- cli
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 65/100