Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: questionstorm on December 19, 2012, 04:08:11 PM



Title: Merged mining - How does it really work?
Post by: questionstorm on December 19, 2012, 04:08:11 PM

Hi,

Thanks to the help of those guys in this forum
  https://bitcointalk.org/index.php?topic=120960.msg1327491
now I understand how basic mining works (getwork, stupid-endian
correction, probing the nonces, hashing, etc.)

What I now want to ask is how merged mining works exactly.
There's an explanation here:
  http://dot-bit.org/Merged_Mining
that doesn't really make any sense to me.  How can a "mined"
solution for one block chain be also a solution for another?? The
same nonce can't be good (I mean it can accidetally, but that
is very-very unlikely).  The data that the miner has to hash
is at least slightly different with the different chains, and
cryptographic hashes were designed in a way that small changes
in the input produces huge changes in the output value, so
it seems to me far fetched that it can be used without some
kind of connection between the chains.  (The dot.bit.org site
linked above says that there's no connection between the
two chains, namely bitcoin and namecoin in this case.)

Could someone please explain me how merged mining works
in more technical terms - or send me a link about it?


Title: Re: Merged mining - How does it really work?
Post by: maqifrnswa on December 19, 2012, 05:19:16 PM
Cartoon picture:

The miner inserts a 0 value transaction into the block. That 0 value transaction contains the hash of the namecoin block (or whatever alt system you're merge mining). Now find the hash of the bitcoin block normally.

If bitcoin difficulty > namecoin difficulty, one of 3 things can happen:

Case 1:
the block hash is < required bitcoin and namecoin difficulty
Result:
nothing happens, increment the bitcoin nonce and find the next hash

Case 2:
the block hash is < required bitcoin difficulty but > required namecoin difficulty
Result:
namecoin network accepts the block (since it contains the hash of the namecoin block and is the required difficulty, so you know that it is valid), but you still need to find a bitcoin block
The accepted block is actually both the namecoin block and the bitcoin block header that verifies that enough work was done to accept the namecoin block.

Case 3:
block hash is > both required bitcoin and namecoind difficulty
Result:
both networks accept the block (why you see a correlation between a namecoin and bitcoin block being found around the same time)


the namecoin transaction hash is bumped whenever you change the namecoin block (new transactions or new block found)


Title: Re: Merged mining - How does it really work?
Post by: Mike Hearn on December 19, 2012, 05:19:26 PM
Maybe this page helps:

https://en.bitcoin.it/wiki/Alternative_Chains