Two relevant kinds of system calls for Wetware:
Cluster syscalls are handled through Wetware's Host
capability.
Host
capability int the WASM process?The main constraint here is efficiency. We should avoid copying data between the host and guest environment.
The most promising avenue would be to wrap api.Memory
in a type that satisfies capnp's rpc.Transport
interface. This would allow the host to read/write directly to/from the WASM runtime, at the cost of requiring guest code to have a functioning capnp RPC implementation (if it wants to make cluster syscalls).
(This is stream-of-consciousness; don't worry if it doesn't make sense)
At some point, I'd like to have native support for BEAM-like immutable data with generational GC. The idea is that the WASM process's memory would hold the ref until it is shared with another process, at which point custody of the underlying memory-[]byte
would be trasnferred to the host runtime. In other words, we would just hand off to the main Go GC.
Obviously, different languages are going to have different data representations, so we should use capnp as a standard encoding. Of course, this means most languages would require some indirection to map their native types onto Wetware data-types. We can probably get away with making such indirection an application concern.
Ultimately, we can add support for something like CapML, which would be able to compute over capnp datatypes (including capabilities!!) natively.
OS syscalls are about interacting with the host OS (e.g. linux). As a general rule, we want to avoid this for two reasons:
What is the smallest set of syscalls we can/should support? How far can we go in restricting the runtime environment? The browser might be a good model to bear in mind, here.
Should we be able to run web servers in Wetware procs (probably yes)? How can we provide capability-oriented security in such cases? Sandstorm is a good model for this. It seems like we might be able to use WASI in conjunction with requiring the caller to pass in binder
/conn
capabilities, or something similar.
WASI is the de facto standard for the OS syscall interface. It's basically "syscalls for WASM".
Bottom Line: WASI provides standard interfaces for a bunch of syscalls, some of which we probably want (
crypto/rand
,time
, …). However, we probably don't want to support most of them.
rand
time
fopen
Wazero gives us a reference implementation, which we can modify to suit our needs. It seems like most (all?) implementations can be modified through the sysCtx
.
Key changes might include:
proc_exit
?