Ethereum virtual machines

In the sixties, when computers had just been invented, coding was in a lower level language, for instance an assembly language (assembler). For example, an assembler code line, ADD R1 R2 R3, is an instruction to add the contents of register 1 and register 2 with the result being placed in the third register, R3. A register is a temporary storage area built into a CPU. With a 32-bit CPU, a register is 32 bits long.

The code in an assembly language is then converted to a machine language in 0 and 1 sequences, which is machine-executable. Coding in a low-level language is tedious and time-consuming. When high-level languages such as ALGOL or BASIC were invented, coding time was greatly reduced. However, the underlying process remained the same: compiling the code into a machine executable language in 0 and 1 sequences. Java, Python, JavaScript and C++ are currently popular high-level languages.

While the compiling approach works well, it does have one inconvenience: lack of portability. A piece of code that is compiled on a computer is machine-dependent. In other words, it is not portable. To address this issue, the concept of the virtual machine was introduced. A virtual machine (VM) is an emulation of a computer system. There are two types of virtual machine: system virtual machine (also called full virtualization), which provide a substitute for a real machine, and process virtual machines, which are for executing computer programs in a platform-independent environment. It is the process of VM that we refer to in our preceding discussion.

A program written in a high-level language is compiled into VM-executable code. As long as a computer supports such a VM, the compiled code can run on it without the need to be recompiled. For example, JVM is a well-known Java VM that enables a computer to run Java programs compiled into Java bytecode.

In the case of Ethereum, smart contracts are written in a high-level language, mostly solidity. A smart contract is compiled to opcodes, which are executable on a VM built specifically for Ethereum, the EVM. The EVM brings portability along with robustness, since EVM performs runtime checks to prevent crashes. These types of checks do have a performance penalty though.

Since Ethereum contracts can be written in any one of the four languages: solidity, serpent, LLL, and Mutan, there are four compilers to convert each of the four languages' coded smart contracts into opcodes for running on the EVM. Another relevant concept is the Ethereum client, which refers to a collection of software being installed on a node for parsing and verifying blockchain transactions, smart contracts, and everything related. The Ethereum client is implemented in one of eight languages: Python, C++, Go, JavaScript, Java, Haskell, Ruby, and Rust. Implemented EVMs are an essential part of the Ethereum client. As a result, opcodes can run on any one of the eight client implementations. EVM was originally designed for currency transactions and later extended to other digital assets. As a result, there are restrictions on supporting certain features. Developers face some severe restrictions (for instance, the use of string or local registers).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.86.60