$19112.51
-0.46%
$1331.96
-0.11%
$0.0607
-0.55%
$0.0288
-1.14%
$0.0196
+2.37%
Published by: 20:42, 19 June 2019

Aergo Virtual Machine (AVM)

Smart Contracts at the Aergo Blockchard are written in programming language Lua. Virtual machine Aergo (AVM), modified version Luajit, Reads and translates the smart contract code written in Lua after compiling and deploying. This means that Lua Smart Contracts can be performed on any computer on which Aergo Virtual Machine is installed - AVM.

Virtual machine Aergo

We present the translation of the article Sung-Jae Woo - Making Virtual Machine Integrity Checks Efficient

Aergo - AVM virtual machine is constantly being improved by our virtual machine developers. From time to time the group checks whether any of the new modifications entered in AVM, any errors in the system. Until recently, the only way to do it was complete network synchronization.

Since Aergo network has been working for more than two months, our blockchain has already exceeded 4.5 million blocks. Now for complete synchronization of the new node from block 0 (Genesis Block) is required on average 5 hours. This means that a simple check of the integrity of the virtual machine takes more than 5 hours! It's like using a sledgehammer to break the nut. Five hours is too long.

After discussions and testing, our team found out how we can optimize the process of assessing the integrity of the virtual machine using a simple code setting. This article describes the work done by us.

Virtual Machine Aergo AVM Smart Contracts
Photo: shutterstock

Synchronization blocks

First, let's look at what happens during block synchronization and which slows down this process. Roughly speaking, block synchronization occurs as follows:

  1. The unit is transmitted from the network in Chain Service¹ (CS) via P2P Service².
  2. CS checks it along with its transactions included in its composition, and then if everything is true, saves it to the storage device (disk).
  3. Transactions made.
  4. The results are checked with the corresponding block header fields.
  5. All results are transmitted to the storage device.

Prefix Tree (TRIE) writes all changes made when performing each block. As soon as the node is included in TRIE, it is never deleted. Each modification in the prefix tree inevitably affects the contents of the root node, which, in turn, changes the state of the root hash. In addition, the state of execution of each transaction in the block is also saved as a receipt. From the receipts of each block, the Merkle tree is built, and its corresponding hash (root hash Merkle) is then placed in the block title.

Thus, the results of step 4 (which is described above) are as follows:

  • State Root Hash (SRH)
  • Receipts Merkle Root Hash (RMRH)

Both of these hash are included in the block title when creating a block.

Each virtual machine must produce the same SRH and RMRH as the results of the execution for the block. If two virtual machines generate different SRH (or RMRH), it means that one of the virtual machines did not follow the protocol. Thus, only the 3rd and 4th items are required to verify the integrity of AVM. However, in fact most of the time other phases occupy.

Why? Because they include slow tasks, such as enter / output disk, requests and answers over the network, IPC between different modules and t.D. For example, to synchronize one block, at least 1 reader (from a remote node) and 2 recording discs (on the current node) are started, even if I / O itself is considered only.³ Among them is not needed to check the disk input / output to check the integrity of the Aergo virtual machine.

So what should we do to get a quick check of the integrity of the virtual machine? We must do what we really need: execution (3rd phase) and verification (4th phase).

Effective AVM virtual machine integrity check

To check the integrity of the virtual machine, we need a blockchain, which is fully synchronized with the main network. Consequently, I / O operations are inevitable. But this does not mean that we have to do this while checking the integrity of the virtual machine. Virtual machine integrity checks are held from time to time, and only if necessary.

If we run a full node at normal time, we can miss these long, dragging operations. For this you do not need to encode anything. We remain the following actions:

  1. Consider each block from block 1.
  2. Perform action.
  3. Check the obtained SRH and RMRH compared to those that are in the block title without writing to disk.
  4. Repeat the steps described above from 1 to 3 to the end.

This last part is actual AVM integrity check. This can be performed for fully synchronized blockchain data obtained in the process of developing a new function. Thus, we can completely eliminate slow processes, including network connections and disk recording operations, from the integrity check process of the Aergo virtual machine.

Summary

So, how to check? Synchronization itself is completed in less than 6 hours. After this action, checking the integrity of the Aergo virtual machine, for pre-synchronized blockchain data, takes only about 8 minutes. This is only 2.7% of the total synchronization time. Now we can work much more efficient :-) Moreover, since this feature allows you to quickly play and check the block chain, it can be used even to detect data fakes.

¹ This software level responsible for controlling the blockchain.

² This is a program level responsible for the connection of P2P with other nodes.

³ Actual I / O operations are greater, since the input-output for each block is accompanied by I / O operations for some of the metadata associated with them.

More information about the Aergo project you can find on the project site or on Pages of our site.

Ctrl
Enter
Noticed a mistakeS
Highlight the text and press Ctrl+Enter
Discuss (0)
Related links:
Other column materials:
Eth
Cryptocurrencies
Eth
05 April 2021
0
BTC
Cryptocurrencies
BTC
05 April 2021
0
BNB
Cryptocurrencies
BNB
04 April 2021
0
XRP
Cryptocurrencies
XRP
03 April 2021
0
IOTX
Cryptocurrencies
02 December 2020
1
Binance
Exchanges
14 April 2021
0
Bitfinex
Exchanges
11 April 2021
0
USDT
Cryptocurrencies
02 April 2021
0
Этот сайт использует cookie для хранения данных. Продолжая использовать сайт, Вы даете свое согласие на работу с этими файлами.