Virtual Machine Compile & Execute

← All Topics

Compile Stage

Mainly for smart contract development and publishing, it has two features:

  • Contract Pack. Pack smart contracts using webpack. It will pack all javascript source codes in the project and install all dependencies, making IOST V8VM easy to develop large projects. Besides, IOST V8VM shares almost all features of Node.js, so developers will feel familiar.
  • Contract Snapshot. With the snapshot technology, compilation increases the performance of creating an isolate and contexts — an anti-serialization of the snapshot will achieve the result in runtime, and tremendously increase loading and execution speed of JavaScript.

Execute Stage

Mainly for execution of on-chain contracts, it has two features, too:

  • LoadVM. Completes initialization of VM, including the generation of Chrome V8 object, setting system execution parameters, importing relevant JavaScript class libraries, etc. Some JavaScript class libraries include:
Class LibraryFeatures
BlockchainNode.js-like modular system, including module caching, pre-compilation, cycle calls, etc.
EventRead/write of JavaScript with State Library, and rollback when contracts encounter errors.
NativeModuleBlockchain-related functions including transfer, withdraw and obtaining information on current block and Tx.
StorageImplementation of events. JavaScript contracts internal events can receive callbacks after going on-chain.
  • Execute. Finally executes JavaScript smart contract. IOST V8VM will run the contract on a standalone thread, monitor the status of the run, and will Terminate the current run when there is an error, insufficient resource, or timeout, and return abnormal results.

The smart contract engine of IOST consists of three parts: monitor, VM, host. Monitor is the global control unit that gateways ABI calls to the right VM. VM is a virtual machine implementation of smart contracts. Host packs the runtime environments and makes sure the contracts run in the right context.

Previous Virtual Machine Basics
Next Virtual Machine Sandbox