Threaded Virtual Machine
Venom’s virtual machine executes smart contract logic on the blockchain. Similar to the Ethereum Virtual Machine (EVM), Venom utilizes a Turing complete virtual machine for the execution of instructions. The TVM of the Venom network executes smart contracts in the protocol’s masterchain and its workchains. Venom’s workchains may use other virtual machines, for example, the Ethereum Virtual Machine (EVM).
One key differentiator to other virtual machines (such as the EVM) is that TVM utilizes an asynchronous model of communication between smart contracts (i.e. accounts). Doing so enables the simultaneous processing of multiple smart contracts in the Venom ecosystem. This results in significant throughput and performance improvements when compared to other VMs that process smart contracts synchronously (i.e. one at a time).
The actor model – a mathematical model of concurrent computation – is used to organize and structure concurrent processes (i.e. smart contracts in the Venom network. In the example of Venom, a smart contract (account) is an actor with a unique address. The account can send and receive messages, spawn other accounts (initialization), change its state, and change its behavior (upgradability).
Interactions between accounts are handled in the network by Venom's TVM which utilizes the actor model. The following highlights the differences in how transactions are handled between TVM and other EVM-based networks:
EVM | TVM |
Transactions are executed one by one. | Transactions are executed simultaneously. |
Each txn must be completed before the next one can start. | Parallel execution, transactions do not need to be completed |
Smart contracts are united into one state and are considered as a single actor in the system | Smart contracts are not united into one state and are not considered as a single actor in the system |
| |
TVM processes transactions in a more efficient way as the network's smart contracts are not united into one state and are not regarded as a single actor within the system. As a result, high demand from actors (both internal and external) does not lead to delays or cost increases for maintaining the network.
With the help of Venom's asynchronous communication model, a message can be sent to initiate an action on a smart contract (i.e. an account) to (potentially) change its state.
These messages are sent to smart contracts containing information for the contract's execution. To increase efficiency, smart contracts are grouped into shards which are then executed in parallel via Venom's dynamic sharding protocol.