CaptainZ

CaptainZ

Prompt Engineer. Focusing on AI, ZKP and Onchain Game. 每周一篇严肃/深度长文。专注于AI,零知识证明,全链游戏,还有心理学。
twitter

New Application Scenario for Inscriptions: Merged Mining

As we all know, Markdown syntax is mainly used for asset issuance, but recently, while researching the BTC ecosystem, I discovered that merged mining also uses Markdown. This article will use Rootstock (@rootstock_io) as an example to discuss the working principle of merged mining in the BTC Layer 2.

The Principle of Merged Mining in RSK#

Rootstock is also a sidechain compatible with EVM, based on the SHA256 proof-of-work consensus. There are three roles in the ecosystem: 1) Miner, who shares miners with BTC to create blocks. 2) Powpeg, responsible for two-way anchoring of assets between the BTC chain. 3) Node Operator, who operates a full node, broadcasts transactions, and verifies blocks. Because it shares the same consensus as BTC, merged mining is adopted.

When I first heard about merged mining, my initial impression was that since the same mining algorithm is used, miners would choose the chain with higher mining rewards. However, after careful research, I realized that this idea was wrong. The actual process of merged mining is very similar to creating Markdown: if NFT is like engraving an image or text on the BTC chain, then merged mining is like engraving the block header information of the RSK blockchain on the BTC chain.

The workflow of merged mining is as follows:

  1. Preparation stage:
    1. Miners create a Bitcoin block: First, miners prepare a new Bitcoin block, including transactions, the hash of the previous block, and other standard components.
    2. Create an RSK block template: At the same time, miners also obtain an RSK block template from the RSK network. This template contains the RSK transactions to be processed and other necessary block information.
  2. Block composition:
    1. Miners convert the RSK block template into a small data fragment called "RSK tag" (or merged mining tag). Then, miners insert this tag into the coinbase transaction of the Bitcoin block. The coinbase transaction is the first transaction in each block and is usually used to reward miners.
    2. 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.
  3. Mining:
    1. Miners start mining the Bitcoin block as usual using the proof-of-work (PoW) mechanism. Because the Bitcoin block now contains information about RSK, miners are actually mining for both chains at the same time.
  4. Verification and submission:
    1. Submit the Bitcoin block: When miners find a valid proof-of-work and successfully mine a new Bitcoin block, they submit it to the Bitcoin network as usual.
    2. Submit the RSK block: Miners also need to extract the RSK tag from the coinbase transaction and use it to construct a complete RSK block. Then, this RSK block is submitted to the RSK network.
  5. Verification in the RSK network:
    1. After receiving a new block, the RSK network first checks whether it contains a valid reference to a Bitcoin block (through the RSK tag).
    2. 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 value of the Bitcoin block meets the difficulty requirements of the Bitcoin network.
    3. If everything is valid, the RSK block is accepted and added to the RSK blockchain. This means that by using the Bitcoin PoW mining process without additional computation, the security of the RSK network is ensured.

From the above discussion, we can see that merged mining is slightly different from ordinary NFT in two aspects:

  1. Merged mining engraves RSK tags (containing relevant data of RSK blocks), while ordinary NFT usually engraves images or text.
  2. The storage location of merged mining data is in the script area of the coinbase transaction in a block, while the storage location of ordinary NFT data is in the Segwit script space.

How Merged Mining Handles Block Asynchrony#

Some people may have questions about how merged mining handles the difference in block time intervals between the BTC chain (10 minutes per block) and the RSK chain (30 seconds per block). For example, if RSK produces two blocks 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 difference in block time intervals between different chains in merged mining. The average block time of RSK is about 30 seconds, while the average block time of Bitcoin is about 10 minutes. This does mean that RSK can produce multiple blocks within the time it takes for Bitcoin to mine one block.

In merged mining, the process is as follows:

  1. Generation of RSK blocks: Although RSK can produce an average of one block every 30 seconds, not all of these blocks are directly "linked" to Bitcoin blocks. RSK uses a mechanism called "commitment" to record the information of RSK blocks in Bitcoin blocks.

  2. Block "commitment": In the coinbase transaction of the Bitcoin block, miners can include special RSK block information (usually referred to as "commitment"). However, since the block time of Bitcoin is much longer than that of RSK, this information usually represents the state of multiple RSK blocks. In short, a Bitcoin block may carry the information of one or more RSK blocks, but this mainly depends on the latest RSK state or the merged submission of blocks at a specific time.

  3. Resolving time differences: Therefore, although multiple RSK blocks may be produced within the block time of a Bitcoin block, the merged mining process mainly involves recording the latest state of the RSK network in the Bitcoin block. Whenever a Bitcoin block is mined and contains RSK information, this information is reflected in the RSK network, allowing RSK blocks to be confirmed.

  4. Confirmation and security of the RSK network: Whenever a Bitcoin block is successfully mined and contains a reference to an RSK block, the corresponding RSK block is 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 usually also run full nodes. This is because to mine effectively, they need access to the complete blockchain data to verify transactions and prevent the production of invalid blocks. 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 participating in mining.

In the RSK network, the situation is slightly different:

  1. Miners:

In RSK, miners are also crucial for the security of the network. RSK allows Bitcoin miners to provide security to the RSK network through merged mining, which means they can mine RSK while mining Bitcoin without additional computational resources. These miners validate and package RSK transactions and maintain the RSK blockchain through the proof-of-work mechanism.

  1. Node Operators:

Although RSK miners play an important role in the network, full node operators are also essential. Full node operators run full nodes in the RSK network, which means they maintain a complete and updated copy of the blockchain. They help the network achieve consensus, 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, although miners and full node operators can be different participants in the RSK network, they can also be the same. The difference is that while almost all miners must run full nodes to participate in the mining process, not everyone running an RSK full node participates in mining. This separation is 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, miners of BTC merged mining will receive RBTC as a gas reward. The governance token of the Rootstock chain is RIF, and the gas fee is anchored 1:1 with RBTC. This bidirectional anchoring is managed by 15 Powpegs (the number may vary). When depositing, send Bitcoin to the deposit multisig address of RSK and wait for enough block confirmations. After enough confirmations, a Solidity contract on the sidechain will discover 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. The federation will sign the withdrawal transaction on the main chain as instructed by the contract.

This article is originally written by @hicaptainz.

Like before reading, earning millions of dollars a year.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.