Taking BTC Layer 2 Rootstock as an example, interpreting the new scenario of inscription applications and merged mining
Author: Gametaverse
Source: PANews
As we all know, the inscription technology is currently mainly used for issuing assets, but recently, while researching the BTC ecosystem, I found that merged mining actually also uses inscriptions. This article will take BTC's second layer, Rootstock (@rootstock_io), as an example to explore the working principle of merged mining.
The Principle of Merged Mining in RSK
Rootstock is also an EVM-compatible sidechain, based on SHA256 POW consensus, with three ecological roles: 1) Miner, sharing miners with BTC to create blocks. 2) Powpeg, responsible for the two-way anchoring of assets with the BTC chain. 3) Node Operator, operating full nodes, broadcasting transactions, and validating blocks. Since it shares the same consensus as BTC, it adopts merged mining.
When I first heard about merged mining, my first impression was that since the same mining algorithm is used, miners (mining machines) would compare mining rewards and mine whichever has higher rewards. However, after careful study, I realized that this idea is incorrect. The real process of merged mining is actually very similar to creating inscriptions: if we say that an inscription NFT is like engraving an image or text into the space on the BTC chain, then merged mining is actually engraving the header information of the RSK blockchain into the space on the BTC chain.
The workflow of merged mining is as follows:
- Preparation Stage:
- The miner creates a Bitcoin block: First, the miner prepares a new Bitcoin block, including transactions, the hash of the previous block, and other standard components.
- Create an RSK block template: At the same time, the miner will also obtain an RSK block template from the RSK network. This template contains pending RSK transactions and other necessary block information.
- Combining Blocks:
- The miner converts the RSK block template into a small data fragment called the "RSK tag" (or merged mining marker). Then, the miner inserts this tag into the coinbase transaction of the Bitcoin block. The coinbase transaction is the first transaction in each block, usually used to reward the miner.
- In this way, the Bitcoin block now contains information about the RSK block, but this does not affect the normal function of the Bitcoin block.
- Mining:
- The miner begins proof-of-work (PoW) mining for the Bitcoin block as usual. Since the Bitcoin block now contains RSK information, the miner is effectively mining for both chains simultaneously.
- Verification and Submission:
- Submit the Bitcoin block: When the miner finds a valid proof of work and successfully mines a new Bitcoin block, they will submit it to the Bitcoin network as usual.
- Submit the RSK block: The miner also needs to extract the RSK tag from the coinbase transaction and use it to construct a complete RSK block. This RSK block is then submitted to the RSK network.
- Verification by the RSK Network:
- After the RSK network receives the new block, it first checks whether it contains a valid reference to the Bitcoin block (through the RSK tag).
- Then, the RSK network verifies the proof of work of the Bitcoin block. This is possible because the RSK network can check whether the hash of the Bitcoin block meets the difficulty requirements of the Bitcoin network.
- If everything is valid, the RSK block is accepted and added to the RSK blockchain. This means that the security of the RSK network is ensured through the Bitcoin PoW mining process without adding extra computation.
From the above discussion, we can see that the difference between merged mining and Ordinal NFTs is slightly as follows:
- Merged mining engraves the RSK tag (which contains relevant data of the RSK block), while Ordinal NFTs generally engrave images or text.
- The data storage location for merged mining is in the script area of a block's coinbase transaction, while the data storage location for Ordinal NFTs is in the Segwit script space.
How Merged Mining Handles Block Asynchronicity
Some may have questions: since it is merged mining, the BTC chain has a block time of 10 minutes, and RSK has a block time of 30 seconds. So, if two RSK blocks were produced in the past minute, how are these two blocks constructed? After all, BTC miners can only construct one block every 10 minutes.
This actually involves handling the differences in block time intervals between different chains in merged mining. The average block time for RSK is about 30 seconds, while the average block time for Bitcoin is about 10 minutes. This indeed means that multiple RSK blocks can be produced during the time it takes to mine one Bitcoin block.
In merged mining, this is handled as follows:
Generation of RSK blocks: Although RSK blocks can be generated approximately every 30 seconds, not all of these blocks are directly "bound" to Bitcoin blocks. RSK uses a mechanism called "commitment" to record RSK block information in the Bitcoin block.
Block "commitment": In the coinbase transaction of the Bitcoin block, miners can include special RSK block information (this is often referred to as "commitment"). However, since the block time for Bitcoin is much longer than that of RSK, this information typically represents the state of multiple RSK blocks. In short, one Bitcoin block may carry information about one or more RSK blocks, but this mainly concerns the latest RSK state or the combined submission of blocks at a specific point in time.
Resolving time differences: Therefore, although multiple RSK blocks may be produced within the time frame of one Bitcoin block, the merged mining process primarily focuses on recording the latest state of the RSK network in the Bitcoin block. Each time a Bitcoin block is mined and contains RSK information, this information will be reflected in the RSK network, allowing RSK blocks to be confirmed.
Confirmation and Security of the RSK Network: Each time a Bitcoin block is successfully mined and contains a reference to RSK blocks, the corresponding RSK blocks will be confirmed by the network. This not only provides additional security for RSK blocks but also allows RSK to leverage the powerful mining capabilities of the Bitcoin network.
Separation of Miners and Full Nodes
In the Bitcoin network, miners typically also run full nodes. This is because, to mine effectively, they need access to the complete blockchain data to validate transactions and prevent invalid blocks from being produced. Therefore, in the Bitcoin ecosystem, the roles of miners and full node operators often overlap, although theoretically, running a full node does not necessarily require participation in mining.
In the RSK network, the situation is slightly different:
1. Miners:
In RSK, miners are also crucial to the security of the network. RSK allows Bitcoin miners to provide security for the RSK network through merged mining, meaning they can mine RSK while mining Bitcoin without requiring additional computational resources. These miners validate and package RSK transactions and maintain the RSK blockchain through the proof-of-work mechanism.
2. Node Operators:
While RSK miners play an important role in the network, full node operators are also very important. Full node operators run complete nodes in the RSK network, meaning they maintain a complete and up-to-date copy of the blockchain. They help the network reach consensus and propagate transactions and blocks. However, unlike Bitcoin, running a full node in RSK does not directly equate to mining. You can run a full node to support the network without participating in merged mining.
Therefore, while miners and full node operators can be different participants in RSK, they can also be the same. The distinction is that although all miners must run full nodes to participate in the mining process, not all individuals running RSK full nodes are involved in mining. This separation exists mainly because merged mining allows Bitcoin miners to increase the security of the RSK network without sacrificing their mining efficiency, while full node operators exist to maintain the health and transparency of the network.
Finally, BTC merged mining miners will receive RBTC as a reward for gas. The governance token of the Rootstock chain is RIF, and the gas fee is represented by 1:1 pegged RBTC. This two-way anchoring is managed by 15 Powpeg (the number may vary). When depositing: Bitcoin is sent to the RSK deposit multi-signature address, waiting for enough block confirmations. After sufficient confirmations, a Solidity contract on the sidechain will detect this transaction and increase the balance of an account controlled by your public key (the public key of the UTXO you deposited). The withdrawal process is also controlled by a smart contract, which communicates with the federation, and the federation will sign the withdrawal transaction to the main chain as instructed by the contract.