As we all know, inscription technology is currently mainly used to issue assets. However, when I was studying the BTC ecosystem recently, 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.

How RSK merged mining works

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

When I first heard about merged mining, my first impression was that since the same mining algorithm is used, miners (mining machines) will compare mining benefits and mine whoever has the highest benefit, but after careful study, I found that this idea is wrong. The actual process of merged mining is actually very similar to making inscriptions: if the inscription NFT is to engrave a picture or text into the space on the BTC chain, then merged mining is actually to engrave the block header related information of the RSK blockchain into the space on the BTC chain.

The workflow of merged mining is as follows:

  1. Preparation Phase:

    1. Miners create Bitcoin blocks: First, miners prepare a new Bitcoin block, including standard components such as transactions and the hash of the previous block.

    2. Create RSK block template: At the same time, the miner will 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. Combined blocks:

    1. Miners convert the RSK block template into a small piece of data called an "RSK tag" (or merge-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. As a result, the Bitcoin block now contains information about the RSK block, but this does not affect the normal functioning of the Bitcoin block.

  3. Mining:

    1. Miners begin mining for Bitcoin blocks using the Proof of Work (PoW) protocol as usual. Because Bitcoin blocks now include information about RSK, miners are actually mining for both chains simultaneously.

  4. Verify and submit:

    1. Submitting a Bitcoin Block: When a miner finds a valid proof of work and successfully mines a new Bitcoin block, they submit it to the Bitcoin network as usual.

    2. Submitting RSK blocks: Miners also need to extract the RSK tag in the coinbase transaction and use it to build a complete RSK block. This RSK block is then submitted to the RSK network.

  5. Verification of the RSK network:

    1. When the RSK network receives a new block, it first checks whether it contains a reference to a valid Bitcoin block (via the RSK tag).

    2. The RSK network then 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 requirement 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 also guaranteed by Bitcoin’s PoW mining process without adding additional computation.

From the above discussion, we can see that the difference between merged mining and Ordinal NFT is that

  1. Merged mining is engraved with RSK tags (containing relevant data of RSK blocks), while Ordinal NFT is generally engraved with pictures or texts.

  2. Merged mining stores data in the script area of ​​the Coinbase transaction of a block, while Ordinal NFT stores data in the Segwit script space.

How does merged mining handle the asynchrony of blocks?

Some people may have some questions. Since it is merged mining, the BTC chain has one block every 10 minutes, and RSK has one block every 30 seconds. So if RSK has two blocks in the past minute, how will these two blocks be constructed? After all, it takes BTC miner 10 minutes to construct a block.

This actually involves dealing with the difference in the time intervals between blocks of different chains in merged mining. The block time of RSK is about 30 seconds, while the average block time of Bitcoin is about 10 minutes. This does mean that in the time it takes for Bitcoin to mine one block, RSK can produce multiple blocks.

In merged mining, this is how it is handled:

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

2. Block "boxing": In the coinbase transaction of a Bitcoin block, miners can include a special RSK block information (this is often called "boxing" or "committing"). However, since Bitcoin's block time is much longer than RSK, this information usually represents the status of multiple RSK blocks. In short, a Bitcoin block may carry information about one or more RSK blocks, but this is mainly about the latest RSK state or merge commit of blocks at a specific point in time.

3. Solving time discrepancies: Therefore, while multiple RSK blocks may be produced within one Bitcoin block time, the merged mining process is primarily about recording the latest state of the RSK network in a Bitcoin block. Whenever a Bitcoin block is mined and contains information about RSK, this information is reflected on the RSK network, allowing the RSK block 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 strong mining power of the Bitcoin network.

Separation of miners and full nodes

In the Bitcoin network, miners do usually also run full nodes. This is because in order to mine effectively, they need access to the full blockchain data to verify transactions and prevent invalid blocks from being generated. Therefore, in the Bitcoin ecosystem, the roles of miners and full node operators often overlap, although in theory, running a full node does not necessarily require 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, which means that they can mine RSK while mining Bitcoin without the need for additional computing resources. These miners verify 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 full nodes in the RSK network, which means they keep a complete, updated copy of the network's blockchain. They help the network reach consensus and propagate transactions and blocks. However, unlike Bitcoin, running a full node in RSK is not directly equivalent to mining. You can run a full node to support the network without participating in merged mining.

So while miners and full node operators can be different actors in RSK, they can also be the same. The difference is that while all miners must almost certainly run a full node to participate in the mining process, not everyone who runs an RSK full node participates in mining. This separation is mainly because merged mining allows Bitcoin miners to increase security for the RSK network without sacrificing their own mining efficiency, while full node operators exist to maintain the health and transparency of the network.

Finally, miners who merge BTC will receive RBTC as a gas reward. The Rootstock chain governance token is RIF, and the gas fee is 1:1 anchored RBTC. This two-way anchor is managed by 15 Powpegs (the number will change). When making a deposit: send Bitcoin to the RSK deposit multi-signature address and wait for enough block confirmations. After enough confirmations, a Solidity contract on the sidechain will discover the transaction and increase the balance of an account controlled by your public key (the public key of the UTXO you deposited) on the sidechain. The withdrawal process is also controlled by a smart contract, which will communicate with the alliance, and the alliance will sign the main chain withdrawal transaction informed by the contract.