You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use the Miden package (i.e. account) as a dependency in a Rust project (i.e. note script), we need to store the WIT binary in the Miden package so that cargo-miden could generate the WIT file(s) for the Rust project (i.e. note script) compilation.
How
The WIT binary is stored in the custom section of the core Wasm binary. When the cargo-component generates a Wasm component, it strips the custom section from the core Wasm binary so that Wasm component binary parsed by the frontend does not have it anymore and instead encoded as component imports and exports.
Option 1
Re-create the WIT binary from the component imports and exports using the wit-component crate. This implemented in the wasm-tools component wasm [WASM_COMPONENT_FILE] command at https://github.com/bytecodealliance/wasm-tools/blob/main/src/bin/wasm-tools/component.rs#L824-L835
The difficulty with this approach is that wit-component needs a lot more than parsed component imports/exports, but since we plan to revamp the Wasm component parsing to avoid the inlining phase we might end up having all needed pieces in place.
I lean towards Option 1. After revamping the frontend to get rid of the inlining phase, we can assess what's missing for the Option 1 and go with Option 2 if needed.
The text was updated successfully, but these errors were encountered:
Why
To use the Miden package (i.e. account) as a dependency in a Rust project (i.e. note script), we need to store the WIT binary in the Miden package so that
cargo-miden
could generate the WIT file(s) for the Rust project (i.e. note script) compilation.How
The WIT binary is stored in the custom section of the core Wasm binary. When the
cargo-component
generates a Wasm component, it strips the custom section from the core Wasm binary so that Wasm component binary parsed by the frontend does not have it anymore and instead encoded as component imports and exports.Option 1
Re-create the WIT binary from the component imports and exports using the
wit-component
crate. This implemented in thewasm-tools component wasm [WASM_COMPONENT_FILE]
command at https://github.com/bytecodealliance/wasm-tools/blob/main/src/bin/wasm-tools/component.rs#L824-L835The difficulty with this approach is that
wit-component
needs a lot more than parsed component imports/exports, but since we plan to revamp the Wasm component parsing to avoid the inlining phase we might end up having all needed pieces in place.Option 2
Parse the Wasm component binary with
wit-parser
to get everything needed for thewit-component
to re-create the WIT binary. This implemented in thewasm-tools component wasm [WASM_COMPONENT_FILE]
command at https://github.com/bytecodealliance/wasm-tools/blob/main/src/bin/wasm-tools/component.rs#L684-L725The downside of this approach is that we parse the Wasm component binary twice.
I lean towards Option 1. After revamping the frontend to get rid of the inlining phase, we can assess what's missing for the Option 1 and go with Option 2 if needed.
The text was updated successfully, but these errors were encountered: