0xMiden / 0xMiden/compiler

Call faucet `mint_and_send` from a tx script

Aperta
#1,138 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
115
Fork
84
Merge medio
1g 8h
PR unite (30g)
15

Descrizione

In the context of https://github.com/0xMiden/faucet/pull/204, I need to compile a tx script that executes the `mint_and_send` procedure of the `BasicFungibleFaucet` component. The Rust code follows this structure:
```rust
use crate::bindings::Account;

#[tx_script]
fn run(arg: Word, account: Account) {
...
account.mint_and_send(amount, tag, note_type, recipient);
}
```
The problem is that this requires the bindings of the component defined in miden-standards. Since the procedure is written in MASM, there's no Rust source to get the WIT from. Is it possible to manually reconstruct that WIT bindings? Is this approach correct, or should I do it differently?

Alternatives I already tried:
1. Avoid going through an account procedure, and instead call the `faucet::mint` kernel syscall directly from the script. This fails with `account procedure with procedure root … is not in the account procedure index map`. I think this is because the kernel restricts `faucet::mint` to invocations whose caller is an account procedure.
2. Using a thin wrapper account component that internally calls `faucet::mint`. This avoids the error above and works, but it would require that the node implemented this account component so that the faucet on the genesis is built with it.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

The issue involves calling a MASM procedure from a Rust tx script, requiring WIT bindings for the `BasicFungibleFaucet` component. Start by examining the `crate::bindings::Account` module and the `mint_and_send` procedure signature. Look at the miden-standards repository to understand the component interface. Determine if manual WIT reconstruction is possible or if a different approach, like modifying the kernel syscall restrictions, is needed. Check the linked faucet PR #204 for context.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.