Life: A secure, blazing-fast, cross-platform WebAssembly VM in Go.
By Kenta Iwasaki
11 - 14 minutes
WebAssembly is a high-level instruction set enabling developers to easily design computationally heavy programs that may be securely run on web browsers.
For many developers, it is a no-brainer that such a secure, high-level, yet performant instruction set has use cases in so many more places outside of the browser.
Imagine writing blazing-fast WebAssembly programs running on your smart TVs/fridges, mobile phones, or even your gaming laptops.
You could have smart devices all around the world securely training machine learning models, hosting up databases, or even hosting up blogs/online retail stores 24/7.
With that comes the reason we at Perlin are thrilled to unveil to the open-source community our new project Life.
P.S. check out our previous open-source project Noiseif you haven’t already.
Life is a secure, blazing-fast, cross-platform, and modular WebAssembly VM written in Go, built for running computationally heavy code on practically any device you can imagine.
At Perlin, we developed Life to be:
Fast — Life uses a wide range of optimization techniques and is far more performant than quite a number of different WebAssembly implementations we’ve tested (such as go-interpreter/wagon and paritytech/wasmi).
Correct — Life was built from the WebAssembly reference manual, and thus passes most of the official test suite (66/72 passed, none of the failures are related to the execution semantics).
Secure — User code executed on Life is fully sandboxed. A WebAssembly module’s access to resources (instruction cycles, memory usage) may easily be controlled to the very finest detail.
Pure — Life does not rely on any native dependencies, and may easily be cross-compiled for running WebAssembly modules on practically any platform (Windows/Linux/Mac/Android/iOS/etc).
Practical — Life makes full use of the minimal nature of WebAssembly to write code once and run anywhere. Every single part of Life may be modularized and used for whatever interests developers may have in mind.
With that being said, we seek for Life to be a tool that any project may easily integrate into their applications for the sake of running WebAssembly code anywhere with ease.
With the particular compiler above, let’s try compile the factorial (`fact`) example WebAssembly program in the compiler and hit Compile.
The Wat section will output the program in WAT (WebAssembly human-readable text) format. You should a line resembling:
(export "_Z4facti" (func $_Z4facti))
Keep note of the text _Z4facti, or whatever else it may be. _Z4facti is the name of the function we compiled; we’ll need the function name so that we may execute the function from our module in Go via. Life.
Make sure to also download the module in *.wasm format by clicking Download.
First, let's read the raw byte contents of our *.wasm module (we’ll call it factorial.wasm for this article).
You’ve successfully executed a function in your WebAssembly module with a full-blown embeddable WebAssembly VM which you can incorporate in any of your projects.
Feel free to link it up to your Android app, desktop app, Raspberry Pi micro-controller; there are an endless amount of possibilities 😄.
We’ve stress-tested Life alongside other WebAssembly implementations on three different tasks and noticed Life to significantly outperform the others.
Life was made for the purpose of being the execution environment for all smart contracts and computational tasks in Perlin.
We’ve already tested Life out with complicated programs, and even created a new backend to the open-source deep learning model compiler TVM which allows users to compile PyTorch, Tensorflow, Keras, MXNet, and Caffe models down to WebAssembly*.
What does this all mean?
Well, that means Perlin bootstrapped w/ Life now supports any computational task you can imagine. In terms of development progress, one can already run their tasks via. Perlin on the hundreds of millions of idle smart devices out there 😉.
I just want to remind though, that Life isn’t something we’re tailoring to for solely the purposes of just Perlin.
We want to empower other decentralized projects in the space by giving access to the utilities which we’ve built that have empowered ours.
In that process, we realized that a standardized, optimized WebAssembly runtime implementation is something that would significantly benefit both projects from the decentralized space and developer space.
On behalf of the tech team at Perlin, we’re always more than happy to share our work for the sake of bridging the cryptocurrency space and technology space closer together.
To those who really believe in our mission and would love to get to work with us, we are hiring!
To grab our attention, look in the contribution guidelines on our Github, or even feel free to reach out and chat with us on Discord 😄.