Analyzing AVM: Bitcoin smart contracts based on simulated virtual machines
Original title: "AVM: Bitcoin Smart Contracts Based on Simulated Virtual Machines"
Original source: Bitcoin Square
Just this week, @atomicalsxyz released the latest AVM virtual machine white paper. I believe everyone still remembers last year's $ATOM and $quark and other ARC-20 tokens during the New Year's Eve. What exactly does the Atomicals protocol's AVM white paper talk about this time, and what impact will it have on the subsequent Bitcoin ecosystem? Let's analyze the contents of the protocol and white paper.
1. Background
With the development of the Bitcoin ecosystem, the update and launch of technologies such as Segwit, Taproot, Schnorr, MAST and Taproot Scripts have prompted the emergence of new applications. On this basis, many Bitcoin token issuance methods were born, which also promoted the continuous development of the Bitcoin ecosystem.
The birth of the Ordinals protocol is closely related to the concept of satoshi on the Bitcoin network. The protocol introduces the concepts of ordinals and inscriptions. Ordinals assign a unique number to each satoshi in the order in which it is mined. No matter how the satoshi is transferred between different wallets, its ordinal identification remains unchanged. Inscriptions are achieved by burning information on the satoshi. Combined with SegWit and Taproot, the Ordinals protocol allows a file of less than 4 MB, i.e., inscriptions, to be burned on the Bitcoin blockchain for each satoshi. With the development of the Bitcoin ecosystem, Casey, the founder of Ordinals, suggested using Runes as an alternative to BRC-20. Compared with BRC-20, Runes reduces the server consensus layer and becomes simpler. At the same time, it does not rely on off-chain data and does not require native tokens, which is very suitable for Bitcoin's native UTXO model.
The birth of the Atomicals protocol we are going to introduce was also a coincidence. At the beginning, the founder Arthur wanted to develop a DID project based on the Ordinals protocol when it was first released, but found some limitations in the process. Then in May 2023, he could not send a tweet about the concept of the protocol on Twitter, and then it was officially launched in September last year. As for the ARC-20 concept in Atomicals, it is actually not an inscription protocol as many people understand. It is more like a colored coin. It uses the smallest unit of Bitcoin, sat, as the basic "atom". Its uniqueness lies in that each token unit is supported by at least one satoshi unit and operates according to the same rules of sending and receiving Bitcoin using the unspent transaction output UTXO architecture.
When tracking historical transaction records and calculating the current ARC-20 asset balance, people only need to check the Bitcoin UTXO associated with the ARC-20 token, without retrieving additional data from the off-chain storage module. This is the main difference between the ARC-20 and BRC-20 protocols, as the BRC-20 protocol usually relies on off-chain indexers and off-chain storage layers. The ARC-20 protocol significantly reduces the cost of index servers and improves decentralization. Its transfer security relies on the BTC network, does not generate redundant transactions, and maintains the same atomicity as BTC, making it suitable for the development of a variety of native applications. The Atomicals protocol is not just about issuing assets, but how to provide assets with richer usage scenarios to enhance their liquidity and expand their functionality.
2. What is AVM
Bitcoin was originally designed as a peer-to-peer electronic cash system with certain Script script data storage capabilities and basic OP Codes operation codes. To date, all overlay protocols on Bitcoin are based on fixed or predefined state machines. All overlay protocols basically share two state machines: one for signaling to create digital assets, and the other for managing the transfer of these digital assets. The state machine rules are essentially unchangeable and hard-coded in the respective overlay protocol indexers-application developers cannot customize the behavior of digital assets.
However, due to the limitations of the UTXO model and predefined state transition rules, this stateless model can only handle limited management of BTC single assets. In order to add new assets such as BRC20, ARC20, Runes, etc. to the Bitcoin network, a more complex dynamic "state machine" model is needed to record the storage, transactions, and state changes of these assets. One of the methods is to use external protocols and Layer 2 solutions, such as Nervos Network, RGB, Lightning Network, etc. mentioned in our previous article, which is to build a "state machine" model off-chain; the other method is to directly expand the Script script function and add new opcodes or storage space, such as BIP proposals such as Covenant and OP_CAT. However, the problem is that it is difficult to reach a consensus in a short period of time with the first method, and there is uncertainty in the second method.
The AVM virtual machine provides a solution between the two, directly building a virtual machine execution environment on the Bitcoin mainnet, realizing the creation and transfer of complex assets in a special processing method, and allowing application developers to fully customize and define arbitrary rules for their digital assets. The basic idea is to allow developers to place smart contract code in the data segment of the transaction so that all relevant parties can execute it. By storing the code on the blockchain, different relevant parties can easily synchronize the state by executing the logic in the same way.
III. Working Principle
We all know that smart contract programming languages should have at least the following key properties: predictable running time, Turing completeness, and the ability to execute efficiently on resource-constrained systems. From the above requirements, Bitcoin Script is very suitable as an instruction set that defines the rules for creating and transferring digital assets. Smart contract program codes are stored in Bitcoin transactions, and the overlay protocol indexer executes these codes to make various method calls and state transitions. All parties involved execute the same logic and reach the same state transitions, forming a spontaneous consensus.
Smart contracts covering various digital assets are created and executed by simulating the Bitcoin virtual machine and its script interpreter. The Bitcoin blockchain acts as a timestamp and data provider, storing smart contract programs on the chain, but the execution of these programs is performed by the overlay protocol indexer in the sandbox runtime. The overlay protocol indexer nodes are jointly operated by application developers, service providers and users, forming an emerging consensus:
1. Bitcoin script simulation: Bitcoin instruction set, which achieves Turing completeness through dual-stack PDA;
2. Sandbox operating environment: The entire simulator is in a controlled isolation environment, so that execution in the sandbox and execution outside the sandbox do not interfere with each other;
3. State hashing: It allows participants to verify whether the state of their indexer is correctly synchronized, preventing potential attacks due to inconsistent state.
In simple terms, AVM directly utilizes the current limited storage space of BTC and the OP Codes processing framework, and introduces a special encoding and decoding method in each BTC mainnet transaction, that is, the sandbox environment. This sandbox is a streamlined version of the Bitcoin script interpreter with some significant differences, such as directly accepting the execution of locking scripts (scriptPubKey) and unlocking scripts (scriptSig), as well as various other data such as token status and protected memory snapshots. This environment can independently complete the storage and transaction records of a whole set of assets, and then realize complex smart contract processing and state synchronization and verification.
Fourth, Future Development
What are the possible developments of AVM in the future? It provides an advanced execution environment capable of handling smart contracts and dApps, equipped with a custom instruction set for enhanced performance, while reducing Gas fees, optimizing state transition functions to increase parallel processing capabilities, thereby improving throughput and scalability. At the same time, AVM achieves interoperability and cross-chain communication. Simply put, AVM enables the Atomicals protocol to perform various tasks, not just the simple token issuance mechanism. Only after meeting the basic needs of issuing assets and managing assets can the Bitcoin ecosystem be truly developed, and more large-scale applications and system architectures can be realized.
Although AVM has many limitations, such as only being able to operate ARC20 assets, and the availability of a layer of smart contracts at the mainnet block speed and rate is still unknown, and although the Bitcoin scripting language is designed for resource-constrained environments, complex smart contracts may still consume a lot of computing resources, and there are still doubts about execution efficiency. But its emergence is still exciting, and we look forward to further technological innovation breakthroughs.
Original link
欢迎加入律动 BlockBeats 官方社群:
Telegram 订阅群: https://t.me/theblockbeats
Telegram 交流群: https://t.me/BlockBeats_App
Twitter 官方账号: https://twitter.com/BlockBeatsAsia
Disclaimer: The content of this article solely reflects the author's opinion and does not represent the platform in any capacity. This article is not intended to serve as a reference for making investment decisions.
You may also like
VeChain Revolutionizes NFT Access with Free PofP Badge Tool
21Shares Polkadot Trust Hints at ETF Possibilities for Investors
ETH breaks through $3,400
Flockerz Vote-to-Earn ICO Raises $7.4 Million – Next 25x Crypto Gem?