We believe a good implementation of virtual machine needs to be both elegantly designed, easy to use, and secure. After comparing the pros and cons of EVM, EOS, C Lua and V8, we have fundamentally resolved unreasonable designs of EVM and EOS. We have managed to build the IOST VM based on V8 due to on the its high performance on Chrome.
1. IOST V8VM sturcture and designs
VMManager is at the core of V8VM. It has three main features:
- VM Entrance. It interfaces external requests from other modules, including RPC requests, block validation, Tx validation, etc. The work is handed off to VMWorker after preprocessing and formatting.
- Management of interface with State database. This ensures atomicity of each IOST transaction, denying the entire transaction when there is an error of insufficient funds. At the same time, two-level cache is achieved in the State database, before being flushed to RocksDB.
2. Sandbox core design
Mainly for smart contract development and publishing, it has two features:
Mainly for execution of on-chain contracts, it has two features, too:
|Blockchain||Node.js-like modular system, including module caching, pre-compilation, cycle calls, etc.|
|NativeModule||Blockchain-related functions including transfer, withdraw and obtaining information on current block and Tx.|
Terminatethe current run when there is an error, insufficient resource, or timeout, and return abnormal results.