-
Notifications
You must be signed in to change notification settings - Fork 4
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
Webassembly API #7
Comments
option b) is nice, but I would like to have still have somethings in the API be object oriented. |
updated ideascreateChannel(memloc i32)creates a channel and writes to port referances to memory. Ideal if wasm had multiple return values we would use bindPort(index: i32, portRef: i32)assigns a index to a port and starts to listen for incoming messages on it unbindPort(index: i32)stops listening to a port and removes its index getPortRef(index: i32) -> i32given a port index return the portRef. If there is no port at the index return -1. This maybe need to be async, and the resulting index return to a callback. The port array will be merklized and we can expect light clients to load the proof on demand. createMessage(offset: i32, len: i32, numOfRefs: i32) -> msgRef: i32Messages can contain data which is read from memory starting at the addRefToMessage(msgRef:i32, index: i32, portRef: i32)Add a port ref to a message at the given index. If getMessageDataLen() -> i32get the number of bytes contain in the message's data payload loadMessageData(writeOffset: i32, offset: i32, len: i32)loads the message's data into memory getMessageRefLen() -> i32get the number of referances contained in the message loadMessagePortRef(index: i32) -> i32loads a port ref from the message sendMessage(portRef: i32, msgRef: i32)sends a message on a given port createInstance(msgRef: i32)creates a new instance of a wasm contract (program). The data in the message is assumed to be the new contract's code isvalidRef(ref: i32) -> i32test is an i32 is a valid ref or not deleteRef(ref: i32)deletes port or message refs |
That is not the direct API since it can only instantiate wasm containers. The API allows to instantiate anything. |
Rigth, maybe a more extensible api would be something like |
Option 2 for createMessage
|
Sample "Unicornscript" implementation: https://hackmd.io/BwMxBMFMAZkhaAbAdgMYCZ4BZwENjzDgBGI86WyiWAnCMuMMsEA=?edit |
And a more implicit version of createChannel would be |
clarification is needed on bindPort. should it throw if index already has a port bound to it? |
We had several iterations of what kind of API should be exposed to Wasm, the most comprehensive one was: https://hackmd.io/CYVghsxgpgTAtNAzAY2PALARlugHBgOyHxIBmAnAAyRZkBs9SeQA
This is slightly different to what the hypervisor has in terms of instantiation and messaging.
There are two basic options:
a) expose the hypervisor's API as-is
b) take the above API from hackmd
Option a) makes the wasm-container operate 100% like the other containers, with all the ups and downs, including being very specific to this Javascript implementation of Primea.
Option b) makes the wasm-container operate on an API set which should be fairly easy to support in other implementations.
The downside of option b) is that a new layer must be introduced which translates between code
storageRef
and container type and actual code path.The text was updated successfully, but these errors were encountered: