The Elrond Virtual Machine - Smart Contracts At Internet Scale.

Beniamin Mincu
·
Dec 04, 2020
·
3 min read

The 15,000 TPS metric measures how many “transferBalance” transactions can be executed on the Elrond network in one second and mostly indicates the efficiency of our protocol and its Secure Proof-of-Stake consensus mechanism.

Such simple payment operations are set to revolutionize the remittances market which is worth hundreds of Billions of dollars each year, but that’s only a fraction of the hundreds of Trillions of dollars managed by global financial systems.

Evolving the world’s economy through decentralization will require smart contract platforms to execute complex operations with low latency, and to be able to continue doing so throughout imminent periods of exponential growth.

This was the design goal of our virtual machine architecture - to create a dependable execution environment whose speed and costs remain constant under heavy load, and which is able to scale with demand.

Security and Scalability with WebAssembly

The Elrond VM is based on WebAssembly (WASM), an open-standard portable binary-code format that matches CPU architectures, allowing Rust, C, C++, Go, TypeScript & many others to compile to it unchanged.

In addition to the many languages supported, the WASM specification has several important properties:

  • Memory-safe, sandboxed, and platform-independent
  • 64 and 32-bit integer operation support that maps one-to-one with CPU instructions
  • Easily made deterministic by removing floating-point operations
  • Continuously developed by the likes of Google, Apple, Microsoft, Mozilla, and Facebook

Although WASM was not initially created with decentralized ledgers in mind, it has all the right attributes for creating an efficient blockchain VM, which explains the rising popularity that has made it the choice for projects such as EOS, Polkadot, and Ethereum 2.0.

Blockchain VM performance comparison

Our own implementation focuses on security, stability, and performance. We also considered aspects that are essential to usability and adoption:

  • Smart contracts that are easy to read write and test
  • Troubleshooting with debugging, linters, etc
  • Modularity and code reusability
  • Tooling support
  • Intuitive APIs

Introducing the Arwen WASM VM

The virtual machine is the most important component of a smart contracts execution platform and ours was thus named accordingly - in Lord of the Rings, Arwen is the daughter of Elrond.

Arwen has seen a lot of iterations throughout the development of the Elrond project, and it has been one of the fastest virtual machines in the blockchain space since more than one year ago, thanks to a series of design choices and unique implementations.

Stability & Security - Arwen uses Wasmer and a streaming WASM compiler backend called SinglePass, which protects against panics, JIT (just-in-time compiling) bombs, and memory corruption. It is also built to avoid denial-of-service issues, such as infinite loops during compilation, and is overall simpler and more extensible.

Performance - We have implemented “Ahead-of-Time Compilation” for smart contracts, which keeps x64_86 byte code already compiled in the storage and cache. This makes smart contract execution much faster, as it removes the compilation time from the overall execution duration.

Stateless execution - Arwen will execute the entire series of operations before committing individual results to the blockchain storage - like in transactional databases. This allows for atomic execution - all or nothing - removing the need to revert transactions in case of a failure.

Composability - Smart contracts can make asynchronous calls to one another, maintaining composability even across different shards. This is an essential achievement for sharded architectures and removes any barriers for complex DeFi products using imbricated smart contracts.

Predictability - there are 400+ unique opcodes, each with its own gas requirement. The cost of operations is deterministic and can be precisely known before their execution. Gas consumption during execution is computed per basic instruction block, rather than per individual instruction, making gas metering a lot more efficient.

It’s time to build

Through its design and implementation, Arwen lays the foundation for a new solution space in which the barriers to what’s possible are no longer technical. The googles and amazons of tomorrow are perhaps one smart contract away - will you be the one that writes it?


For more information, please visit us:


#technical

Written by
Beniamin Mincu
CEO, Elrond Network