TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
996 stars 309 forks source link

Run payload formatters via WebAssembly runtime #2707

Open rvolosatovs opened 4 years ago

rvolosatovs commented 4 years ago

Summary

Support running payload formatters via WebAssembly runtime

Why do we need this?

What is already there? What do you see now?

What is missing? What do you want to see?

Embedded WASM runtime, which would run WASM modules.

How do you propose to implement this?

Unfortunately, it is not possible to compile JavaScript down to WASM at this point of time. We would need to both have a JavaScript VM and WASM runtime working alongside for this. Long term, however, given the simplicity of the formatters, we could parse them and convert to TypeScript, which can, in turn, be compiled to WASM.

At the time of writing there are 2 well-supported runtimes with Go bindings: https://github.com/bytecodealliance/wasmtime-go (wasmtime) https://github.com/wasmerio/go-ext-wasm (wasmer)

As well as less-mature pure-Go runtimes: https://github.com/perlin-network/life https://github.com/mathetake/gasm

Perhaps at a later point of time it will be possible to completely get rid of JS VM and compile JS down to WASM and run it in a WASM runtime.

How do you propose to test this?

Integration testing, existing unit tests

Can you do this yourself and submit a Pull Request?

yes

rvolosatovs commented 4 years ago

Regarding JS: https://github.com/WebAssembly/design/issues/219