-
Notifications
You must be signed in to change notification settings - Fork 165
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 Interface Notes #18
Labels
Comments
This is really interesting! I didn't have time to really looking into this, it is awesome to start working on this again now. The ideal would be, be able to compile the current resolvers into this language (or whatever candidate language) at some point, so no need to write the GO/JS parser. |
The libc on eWASM (soon to be uploaded) can be reused for this to compile C snippets. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Webassembly DAG interfaces
related
ipld/specs#35
ipld/specs#38
Overview
This note presents an initial Webassembly interface for generic Merkle DAGs. There are two interfaces proposed here.
These interfaces are low level and should allow for upper layers to be implemented on top of them.
glossary
Rational
It would be conducive to implement Selectors and Transforms in webassembly so that
Challenges
API Overview
Data types
We define the following Webassembly data types:
i32
: same asi32
in Webassemblyi32ptr
: same asi32
in Webassembly, but treated as a pointer to a Webassembly memory offseti32ref
: same asi32
in Webassembly, but treated as an opaque reference and should be replaced with an opaque reference after it has been specified in Webassemblyi64
: same asi64
in WebAssemblyTables
A table named 'callback' must be exported if any callbacks are used. All callbacks functions have a parameter of a single i32 which will contain the error code of the orginal operation. If there where no errors then the return value will be 0 other wise it will be 1. All operation that involve state look ups are asynchronous
Translator API
A translators maps some given data into method that can be consumed by the underlining IPFS implementations.
the Webassembly binary MUST export the following methods to be compatible DAG service. Like wise the host environment must also provided the following API to wasm binary that are intended to be translators. The translator's imports MUST use the namespace "translator".
createVertex
Creates a mutable vertex reference
Returns
vertexRefence
i32refcreateEdge
Given a link and some metadata this creates an edge.
Parameters
link
metaDataOffset
i32ptrmetaDatalength
i32Returns
edgeReference
i32refaddEdge
Adds an edge to a vertex given an edge reference and a label
Parameters
Selector API
Selectors traverses the graph and selects some subset of vertices. The Selector's imports MUST use the namespace "selector".
select
Adds a vertex reference to the array of reference to be returned
parameters
vertexReference
i32refroot
the root vertex of the DAG we are operating on
Returns
result
i32ref an opaque reference to the root vertexresolve
Given an edge reference returns a vertex reference
Parameters
link
i32ref a reference to a merkle linkcallBackIndex
i32 an index of the callback functionCallback Signature
error
i32 reserved for error codevertex
i32ref a reference to the resolved vertexgetEdge
Gets an edge reference given the edge name
Parameters
namePtr
i32prtlength
i32return
edgeReferance
i32refgetEdgeDataLength
Gets the metadata attached from to an edge
Parameters
edgeReference
i32ref an opaque reference to the edgereturn
length
i32 the length of the an edgegetEdgeData
Gets the data from an edge and writes it to memory
Parameters
edgeReference
i32ref an opaque reference to the edgewriteOffset
i32ptr the memory location to write the datagetLink
Unwrap a link from an edge
returns
link
i32ferisNullLink
checks if a link is null or not
Parameters
linkReference
i32ref an opaque reference to a linkreturns
isNull
i32Iterator API
This enables iteration of a vertex's edges
edges
Return
edgeIterator
i32ref a reference to an edge iteratornext
Advances the iterator
Parameters
edgeItr
i32refgetEdgeName
Parameters
edgeItr
i32refwriteOffset
i32ptrgetEdgeNameLength
Parameters
edgeItr
i32refReturn
length
i32The text was updated successfully, but these errors were encountered: