Ontology first to support four smart contract platforms including the Ethereum Virtual Machine, providing faster block production speeds and lower handling fees.
At the start of 2021, Ontology’s technical team began developing the Ontology Ethereum Virtual Machine (EVM). In addition to NeoVM, Native (Ontology) VM and WasmVM, we are adding support for the EVM. The goal is to establish seamless interoperability between Ontology and the Ethereum platform, and offer an inclusive experience to developers and users.
On the third anniversary of Ontology’s MainNet launch, we announced that the development of Ontology EVM had been completed. The existing version adds the Ethereum account system, Ethereum transaction types, and Web 3 APIs. At the same time, the virtual machine layer and transaction pool are optimized and enhanced, and the blockchain browser is synchronized.
Below, we describe the design and development details.
EVM: General Introduction
Ethereum describes the Ethereum Virtual Machine (EVM) as a ‘single entity maintained by thousands of connected computers running an Ethereum client.’
It goes on to state:
The Ethereum protocol itself exists solely for the purpose of keeping the continuous, uninterrupted, and immutable operation of this special state machine; It’s the environment in which all Ethereum accounts and smart contracts live. At any given block in the chain, Ethereum has one and only one ‘canonical’ state, and the EVM is what defines the rules for computing a new valid state from block to block.
Ontology’s EVM: Introduction
The EVM developed by Ontology is a virtual machine compatible with the Ethereum ecosystem. It uses ONG as the gas fee for on-chain services and requires relatively low gas fee consumption. Our goal is to ensure that Ontology’s EVM is fully compatible with the Ethereum ecosystem.
Ontology’s smart contract system adopts the multi virtual machine scheme and supports three kinds of contracts; Native contracts, NeoVM contracts, and Wasm contracts. Thanks to Ethereum’s strong community and ecosystem, adding EVM support for Ontology can facilitate more existing Ethereum ecosystem developers to use Ontology.
Our aim is to ensure frictionless interoperability between Ontology and Ethereum to reduce migration costs of developers, and at the same time, avoid significant changes to the existing platforms to ensure the continuity of the ecosystem development.
Development Process and Results
Our development process lasted over one month, with one iteration. Upon completion, Ontology and Ethereum can interoperate seamlessly with a high level of compatibility. Specific features: updated browser, supported Ethereum account system, infrastructure, RPC (remote procedure call), and additional Web 3 interfaces.
1) Account System at the Ledger Level
The underlying ledger status of Ontology only stores contract data; account data is stored in various contract storage areas, including native ONT and ONG contracts. However, Ethereum ledger status consists of two layers of MPT. The first layer is the account status, including the Nonce (Number only used once), the Ethereum balance and the status root of the account data. The second layer is the key value pair data of the contract account. Due to the huge gap, adopting an Ethereum solution would lead to a large number of destructive updates to Ontology. Therefore, we opened up a storage space to store the Nonce and contract codes of accounts related to Ethereum transactions. The key value pair data of the contract account is consistent with Ontology, which not only takes into account the function of Ethereum, but also ensures the compatibility of Ontology itself.
2) Virtual Machine (VM)
Based on its existing multi-VM system, Ontology can easily add EVM support. Most of the instructions are exactly the same as those on the Ethereum platform, with a few EVM instructions suitable only for Ethereum, such as COINBASE and DIFFICULTY, which use default values on Ontology. Because they are rarely used in dApps, most contracts can be seamlessly migrated in practical applications. We provide support for Ontology EVM calls from existing NeoVM and Wasm virtual machines to facilitate the interaction between existing contract applications and EVM applications. At the same time, in order to avoid the expansion and bifurcation of EVM, we do not currently provide support for EVM cross virtual machine calls.
3) Transaction Structure
Ontology’s transaction structure is scalable and supports several transaction types on demand. We support Ethereum EIP-155 transactions on the basis of existing transaction types, so that the transactions issued by existing Ethereum ecosystem wallets are compatible with Ontology EVM.
4）Transaction Pool Updated
The order of Ethereum’s transaction record must be increased according to the Nonce value of the account. To ensure this feature, we maintain a list of EIP-155 transactions in the transaction pool. Only transactions meeting the conditions can be packaged into blocks.
5）Web 3 API
At present, Ontology EVM provides rich interfaces such as RESTful, JSON-RPC, and WebSocket. Since contract development tools, wallets and dApps in the Ethereum ecosystem all use Web 3 API, we developed an additional interface adaptation layer to support Web 3 API, ensuring contract development tools and wallets such as Truffle, Remix, and MetaMask, can be directly used for dApp development on Ontology.
With the launch of the Ontology EVM, users can access Ethereum applications and wallets in one place.
Developers can use contract development tools such as Truffle and Remix to realize seamless connections between two chains and experience a more compatible blockchain ecosystem .
Ontology contracts development has the following advantages:
- Contracts supported: industry-leading VM support; multi-VM includes four kinds of contracts (NeoVM, Native, Wasm, EVM).
- Fees and Velocity: Users can experience the Ethereum ecosystem on Ontology blockchain, with lower gas fees and faster block production.
- Wasm support: Wasm has performed excellently since its launch two years ago.
When Multi-VM launched in 2020, the Ontology Technical team said:
In the field of blockchain, the goal of virtual machine (VM) technology is to create a smart contract execution environment suitable for all transactions. However, from a technical point of view, the efficiency of contract execution, the complexity of supported transactions and the ability of cross-system cooperation are all key factors. In this process, different VMs have different application scopes. Ontology Multi-VM is committed to meeting a wider range of transaction requirements, bringing higher execution efficiency and lower gas fees. The design and launch of Ontology EVM is an important aspect of this goal, which will bring more transaction scenarios.
On the basis of the underlying completed functions, more compatibility tests and enhancements of the Ethereum tool chain will be carried out in the future to further satisfy the requirements of trusted data interactions and bring more convenient and efficient experiences for developers and users.