0xPolygonMiden / compiler

Compiler from MidenIR to Miden Assembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Miden SDK as a plain Rust dependencies

greenhat opened this issue · comments

Goals

Following https://discord.com/channels/893151281848406016/1148602585431953450/1207070272478380032

Implement Miden stdlib and base(tx kernel API) as plain Rust dependencies, using extern stubs in the Rust crate that use a naming convention recognized by the Miden compiler to look up the signature for that function in its builtin set of "well known" functions and do the proper lowering.

Implementation details

The Rust API of tx kernel should closely follow the WIT interface signatures explored in #119 to allow later switching to the WIT interface for stdlib and tx kernel without braking the user code too much. Also, the adapter function generation techniques drafted in #119 (see in docs) can be used for lowering the extern stubs.

The base types Felt and Word (described in #118) along with other types needed in these crates (Asset, Recipient, etc.) will be later used in re-mapping using wit-bindgen (to be implemented in #116) in the WIT interface used in the account and note scripts.

The MAST root hashes of the lowered functions should be encoded in the function names (extern stubs) to avoid the need for hard coding them in the Miden compiler.

Tasks

Eventually, these crates might be moved to their own repos. For now, I'd like to keep them here due to high coupling to the compiler, so my workflow as I imagine it would be:

  1. Tweak bindings in the Rust crate;
  2. See what we have in Wasm and IR;
  3. Tweak lowering in the compiler;
  4. Check the resulted MASM;
  5. "Rinse and repeat".