-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Miden SDK proof-of-concept using Wasm component model #79
Conversation
fb08550
to
764f858
Compare
792c360
to
7c8f390
Compare
…llet with p2id note
…related functions and use one of them in the p2id-note
…s Wasm resource type
…asic wallet suite
7c8f390
to
4711d61
Compare
@bitwalker Following our discussion, I removed the component with the account's helper functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple small notes, but I think this looks good so far!
We discussed the following on our compiler call today, but just to document the decisions somewhere relevant:
1.) The need to avoid resource
at the moment is due to missing features in the VM, for which we have an outstanding proposal that may or may not enable the use of resource
in the future - but for the time being it can't be used.
2.) As you noted, all public exports of a component should be call
ed, and we formalized that decision today (though it isn't final if we decide to revisit that in the future for some reason).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Close #72
This PR adds a WIT implementation of Miden SDK and a basic wallet test using the Wasm component model.
Design decisions
Marking
call
-able functions (account type)I chose to mark the whole Wasm component as having
call
-able functions. The benefits vs. marking individual functions ascall
-able are:account
interface defined inmiden.wit
(SDK) and used inbasic-wallet.wit
). Alternatively, we can use metadata in the Cargo.toml where will define some properties of the Miden component anyway.Wasm components are limited to one exported world, so we cannot have both
call
-able andexec
-able functions in the same component with this approach. That is the drawback of this approach.The helper function are expected to be linked as a regular Rust crate to avoid the CanonicalABI overhead when called.
Wasm
resource
does not play well withcall
, so we should not use itI found a problem that I believe prevents us from using the
resource
for our types. As an experiment, I madeAsset
aresource
and since the implementation is opaque (see) and not on the WIT "level" (see) there is no knowledge of the size of theAsset
instance in the compiled Wasm component. Theresource
handle is a pointer to the instance. Thus making it impossible to pass theresource
value via acall
.As I understood from the generated code, the
resource
is passed as a pointer to the instance, and since its methods are implemented in the Wasm component where theresource
instance "resides," they can access its memory directly no matter from what component they were called.Use "library" Wasm component for note instead of a "command"
When using "command" Wasm component the runtime is quite sizable and pulls in arg parsing and thread-related setup that we don't need. So I decided to use a "library" Wasm component instead that is implementing a
note
interface (see).