How to understand AVM: A Turing-complete virtual machine that enables BTC to implement a dynamic state machine?

half a month ago
This article is approximately 851 words,and reading the entire article takes about 2 minutes
A beneficial and proactive exploration based on the BTC mainnet script extension

Original author: Haotian

How to understand AVM: A Turing-complete virtual machine that enables BTC to implement a dynamic state machine?

How to understand the AVM virtual machine white paper recently released by @atomicalsxyz? In simple terms: it is a way to simulate the Bitcoin virtual machine, so that the originally stateless Bitcoin main network can realize the ability to carry a smart contract system, and then complete the state recording and processing capabilities of more complex assets other than BTC assets, similar to Turing complete smart contracts. Next, share my understanding:

1) Bitcoin was originally designed as a peer-to-peer electronic cash system with a certain script data storage capability, some basic OP Codes, and a set of asset verification logic based on UTXO time locks and spending conditions.

Therefore, the Bitcoin network can achieve stateless asset management when recording and transmitting BTC assets. Due to the limitations of the UTXO minimalist model and predefined state conversion rules, this stateless model can only handle limited management of a single BTC asset.

If you try to add new assets to the Bitcoin network, such as BRC 20, ARC 20, Runes, etc., you will need a more complex dynamic state machine model to record the storage, transactions, state changes, etc. of these assets. How to achieve this?

One way is to use external protocols and layer 2 solutions to build a state machine model off-chain to extend processing. Current excellent layer 2 extension solutions such as @NervosNetwork @RoochNetwork, and even Native solutions such as RGB and Lightning Network belong to this category.

Another way is to directly expand the functionality of the Script to add new operations or storage space to handle the creation and transfer of complex assets. Solutions like Covenant and OP_CAT that rely on BIP proposal standards to be passed belong to this category.

The above two methods are either too active and difficult to reach consensus in a short period of time, or too passive and have great uncertainty. The AVM virtual machine provides a special processing solution that is between the two and directly builds a virtual machine execution environment on the Bitcoin mainnet.

2) How to do it? The main working principle of AVM includes three parts:

1. Bitcoin script simulation is actually the Bitcoin instruction set, which achieves Turing completeness through a dual-stack PDA (Pushable Storage Automaton);

2. Sandbox operating environment: the entire simulator is in a controlled, isolated environment, so that execution in the sandbox does not interfere with execution outside the sandbox;

3. State hashing allows participants to verify whether the state of their indexer is correctly synchronized, preventing potential attacks due to inconsistent state.

Simply put: AVM directly utilizes the current limited storage space of BTC and the OP Codes processing framework by introducing a special encoding and decoding method (sandbox environment) in each BTC mainnet transaction.

This sandbox comes with an indexer, sandbox parser (instruction set), global database, etc., and can independently complete the storage of a complete set of assets, transaction status records and other management. It is equivalent to building a dynamic state machine into the BTC main network, which can then realize complex smart contract processing as well as status synchronization and verification.

3) With the AVM virtual machine, the Bitcoin mainnet can theoretically have basic smart contract operation functions, allowing Bitcoin to manage multiple complex assets and the possibility of landing complex state logic DApps, which is equivalent to giving the Bitcoin network a certain self-built ecological function.

This is certainly a great progress, at least the same level of BTC expansion innovation as RGB, Lightning Network and various excellent second-layer protocol processing solutions. It is even better than other solutions in terms of Native.

However, AVM relies on Bitcoin Script for code storage and OP Codes for transaction execution, so it is generally limited by the performance of BTCs main network, such as block storage space size, output speed, etc.

Imagine a DeFi project built on AVM that can only process 7 transactions per minute and needs to wait ten minutes between two state transitions. Even if such a smart contract is theoretically complete, it is still restricted. Moreover, relying on the Bitcoin Script script instruction set to develop complex contract functions is more complicated and difficult than developing smart contracts in languages such as Ethereum Solidity.

Moreover, the AVM white paper only clarifies a way to execute Make Senses built-in virtual machine. How it will actually be deployed online in the application environment and how it will run stably are still unknown.


In general, I tend to view the development and implementation of AVM as a beneficial and proactive exploration based on the extension of the BTC mainnet Script script. It can indeed drive the implementation of some simpler smart contracts on the BTC mainnet. At the same time, the Bitcoin mainnet can play a greater role and value in the construction of the second-layer ecosystem and the on-chain and off-chain combined ecosystems such as BitVM.

However, like other BTC expansion solutions, AVM also has advantages and disadvantages. It also depends on the ecological construction after landing to expand its orthodoxy appeal. It is recommended to maintain a rational, cautious and optimistic attitude.

Original article, author:链上观。Reprint/Content Collaboration/For Reporting, Please Contact;Illegal reprinting must be punished by law.

ODAILY reminds readers to establish correct monetary and investment concepts, rationally view blockchain, and effectively improve risk awareness; We can actively report and report any illegal or criminal clues discovered to relevant departments.

Recommended Reading
Editor’s Picks