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

Haotian
2024-05-29 09:11:08
Collection
AVM is a beneficial proactive exploration based on the BTC mainnet Script extension, which can drive some simpler smart contracts to land on the BTC mainnet.

Author: Haotian

How to understand the latest released AVM virtual machine white paper by @atomicalsxyz? In simple terms: it is a way to enable the originally "stateless" Bitcoin mainnet to support smart contract systems by simulating the Bitcoin virtual machine, thus allowing for the state recording and processing capabilities of more complex assets beyond BTC, similar to Turing-complete smart contracts. Next, I will 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 validation 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 transformation rules, this stateless model can only handle limited management of a single BTC asset.

If we try to add new assets on the Bitcoin network, such as BRC20, ARC20, Runes, etc., a more complex dynamic "state machine" model is needed to record the storage, transactions, state changes, etc., of these assets. How can this be achieved?

One way is to use external protocols and layer 2 solutions to build a "state machine" model off-chain for extended processing, like the currently excellent layer 2 scaling solutions such as @NervosNetwork and @RoochNetwork, or even native solutions like RGB and the Lightning Network;

Another way is to directly extend the functionality of the Script to add new operations or storage space to handle the creation and transfer of complex assets, such as Covenant and OP_CAT, which rely on BIP proposal standards that have been approved;

Both of these methods are either too "active," making it difficult to reach a consensus in a short time, or too "passive," leading to significant uncertainty. The AVM virtual machine offers a special processing solution that lies between the two, directly building a virtual machine execution environment on the Bitcoin mainnet.

2) How does it work? The main working principles of AVM consist of three parts:

  1. Bitcoin script simulation, which is essentially the Bitcoin instruction set, achieving Turing completeness through a dual-stack PDA (Pushdown Automaton);

  2. Sandbox execution environment, where the entire simulator operates in a controlled isolated environment, ensuring that execution within the sandbox does not interfere with execution outside;

  3. State hash, which allows participants to verify whether their indexer's state is correctly synchronized, preventing potential attacks from state inconsistencies.

In simple terms: AVM directly utilizes the limited storage space and OP Codes processing framework of current BTC 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 a full set of asset storage, transaction state recording, and management, equivalent to embedding a dynamic "state machine" within the BTC mainnet, thereby enabling complex smart contract processing as well as state synchronization and verification.

3) With the AVM virtual machine, it theoretically allows the Bitcoin mainnet to have basic smart contract operation capabilities, enabling Bitcoin to manage multiple complex assets and the possibility of complex state logic DApps, effectively giving the Bitcoin network a certain self-constructing ecological function.

This is certainly a significant advancement, at least on par with the innovative BTC scaling capabilities of RGB, the Lightning Network, and various excellent layer 2 protocol solutions. It may even outperform other solutions in the native aspect.

However, the AVM relies on Bitcoin Script for encoding storage and on OP Codes for transaction execution, thus it is overall limited by the performance of the BTC mainnet, such as block storage size, transaction speed, etc.

Imagine a DeFi project built on AVM that can only process 7 transactions per minute, with a ten-minute wait between two state transitions; such a smart contract, even if theoretically complete, is still constrained. Moreover, developing complex contract functions relying on the Bitcoin Script instruction set is more complicated and challenging than developing smart contracts in languages like Ethereum's Solidity.

Furthermore, the AVM white paper merely clarifies a sensible built-in virtual machine execution method; how it will actually deploy and operate in an application environment remains uncertain.

The End

Overall, I tend to view the development and implementation of AVM as a beneficial proactive exploration based on the BTC mainnet Script extension, which can indeed facilitate some simpler smart contracts landing on the BTC mainnet, while also allowing the Bitcoin mainnet to play a larger role and value in building layer 2 ecosystems and in on-chain and off-chain combinations like BitVM.

However, like other BTC scaling solutions, AVM also has its pros and cons, and it must rely on the ecological construction situation after implementation to enhance its "orthodoxy" appeal. A rational and cautiously optimistic attitude is recommended.

ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
ChainCatcher Building the Web3 world with innovators