Merged Mining and Multi-Mining

This segment is in a pre-alpha phase. None of what you read below is guaranteed to be correct in any way or be a part of the final product. Read with extreme caution or come back later.
Merged mining is a technique that allows a primary PoW chain (typically a small chain) to piggyback on the mining efforts of an auxiliary chain (typically a large chain, most commonly Bitcoin). The idea is to accept attempts at mining the auxiliary chain as valid headers to the main chain. Since auxiliary miners are already doing this work anyway, they get to participate in the main chain "for free". This benefits both chains, as mining the main chain becomes more profitable.
On paper, this seems like a great idea, but in practice, it has limitations and even risks.

Merged mining was first introduced by Namecoin, a project that launched in 2011 to create a decentralized database of maintainable, consistent cryptographic identities. While the utility of Namecoin is worthy of a discussion, it seems that the most impactful observation they made is that the same work can secure two chains. It is very simple, on a technical level, to use byproducts of Bitcoin mining as valid Namecoin work. However, this decision arguably played a significant role in Namecoin's decline, as the network's security is overly reliant on an external source, which also had consequences for decentralization.
Future incarnations of merged mining proposed a more holistic approach called multi-mining, allowing the same chain to be mined in several different ways, limiting the consequences of merged mining.
In this section, after explaining in more detail how merged mining works, we consider its consequences for the main chain.
Bitcoin AuxPoW in Namecoin
We start with the simplest form of merged mining: Namecoin's original approach. We need a way for the main chain to accept work from auxiliary chain miners without interfering with their auxiliary chain mining. Such a form of mining is often called auxiliary-proof-of-work (AuxPoW).
Following the reasoning for how regular PoW works, we find some issues that need to be considered:
The difficulty target in the header comes from the aux chain (so we call it ), but we need to maintain a separate difficulty target for the primary chain .
The Merkle transaction root couples the header to the auxiliary block data. We also need to couple it to the main chain data somehow.
That's not hard to accomplish, but it requires some attention to detail. Working through this is a good exercise in applying the principles we learned so far. I will explain specifically how Namecoin's AuxPoW is implemented. Most forms of AuxPoW are slight variations, adapted to the fine structure of the primary and auxiliary chain as needed.
Merkle Tree Huggers
Recall that to couple the block data to the block header, Bitcoin headers contain a Merkle transaction root (MTR). This Merkle root seems to be a solution to all our problems: you can couple any arbitrary data to the block header by adding a new leaf with the value , and attach the corresponding Merkle proof to the data. When validating the data , add a step for checking that the Merkle proof goes through with respect to MTR.
This all sounds like simple stuff, until we realize that we can't add leaves to the transaction Merkle tree. If we try to, we make the block invalid! Recall that one step of validating a Bitcoin block is recomputing the MTR from the transaction and checking that it matches the MTR written in the header. But if we added additional leaves, then we modified the MTR!
Fortunately, there's a standard solution for that: embed the information you need inside a transaction. That way, the standard MTR computation automatically couples the header to your data. But what transaction should we use? In Bitcoin, the first transaction in each block is a special transaction called the coinbase transaction, which miners use to claim the block rewards and fees. Since miners must create a coinbase transaction (or relinquish their reward) anyway, it makes sense to embed the data in it.
The Bitcoin AuxPoW Recipe
The previous section gives us enough to put together a recipe for converting any PoW chain into a Bitcoin AuxPoW chain. There are other recipes, but they are all very similar to this one.
Consider a standard PoW chain. A new incoming block is comprised of two parts: and . We keep the standard structural assumptions: validating the validity of the chain only requires examining the headers, and given , we can validate that it indeed contains the data expected by . In particular, we expect to contain a difficulty target . We don't particularly care how the chain works. We only presume that it follows this general structure.
To convert it into a Bitcoin AuxPoW, we redefine the header to be an appropriately cooked-up Bitcoin header, and attach the original header to the block data, along with some useful auxiliary data. Let's flesh it out.
The AuxPoW header is a Bitcoin header , with a payload in its coinbase transaction. The AuxPoW block data contains the following information:
The original data and the original header
The coinbase transaction (which has embedded into it)
A Merkle proof for the Bitcoin coinbase transaction
When validating a block, we check:
has the semantics of a valid Bitcoin header. By "semantics," I mean that we check it has the expected structure, but skip any contextual texts. For example, we check that the header has a pointer to a parent block, but we don't check if that block actually exists. We check that the header has an MTR, but we don't retrieve the Bitcoin block.
. Note that we use the primary chain difficulty target on the auxiliary chain header
The validity of , using the coinbase Merkle proof
Any remaining validity test from the original chain
Last updated