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 technology is currently mainly used for asset issuance. However, 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 (PoW) consensus. There are three roles in the ecosystem: 1) Miner, who shares miners with BTC to create blocks. 2) Powpeg, responsible for bidirectional anchoring of assets between the BTC chain and RSK. 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 first 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 Proof of Work (PoW). 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 if it contains a valid reference to the 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 if 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 the security of the RSK network is ensured through the Bitcoin PoW mining process without additional computation.

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

  1. Merged mining engraves RSK tags (containing relevant data of RSK blocks), while Ordinal 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 Ordinal 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 RSK (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 take 10 minutes to construct a block.

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 multiple RSK blocks can be produced within the time it takes for a Bitcoin block to be mined.

In merged mining, the following steps are taken:

  1. Generation of RSK blocks: Although RSK blocks are generated on average every 30 seconds, not all of these blocks are directly "linked" to Bitcoin blocks. RSK uses a mechanism called "commitment" to record information about RSK blocks in Bitcoin blocks.

  2. Block "commitment": Miners can include special RSK block information (usually referred to as "commitment") in the coinbase transaction of the Bitcoin block. 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 commitment of blocks at a specific point in time.

  3. Resolving time differences: Therefore, although multiple RSK blocks may be produced within the 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 information about RSK, 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.

  2. Node Operators:
    Although RSK miners play an important role in the network, full node operators are also essential. 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 reach 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 all miners almost always have to 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 receive RBTC as gas rewards. The governance token of the Rootstock chain is RIF, and RBTC, which is anchored at a 1:1 ratio, acts as gas fees. 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.