Support running payload formatters via WebAssembly runtime
Why do we need this?
Relying on a well-maintained and audited technology, which will keep improving into the future
Proper sandboxing and security guarantees
Performance - we should profile this, but I believe this would require less resources and less memory on the AS -> higher throughput at scale
Allowing users to write payload formatters in a language of their choice (which compiles to WASM) - e.g. Rust, Go, TypeScript to name just a few, there are many
What is already there? What do you see now?
Dependency on a JavaScript VM with unclear maintenance status (last commit was made over half-a-year ago at the time of writing - not a good sign)
Only JavaScript supported as payload formatter language
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.
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