Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Merged Mining Implementation Guide
Description of steps to follow in order to add RSK merged mining capabilities to a mining pool software.
What do you need to do
Add the RSK merged mining information in Bitcoin block as a commitment, the complete steps are as follow:
1. Get the work from RSK node
Use the mnr_getWork method from the RSK node's JSON-RPC API. This method returns the information of the current block for merged mining, the boundary condition to be met ("target") and some other data.
2. Put the information for merged mining in the Bitcoin block
0x29and represents the length of the information included after the
RSKBLOCK:is the ascii string for
RskBlockInfois the block information in binary format.
For example, if
the merged mining information is
Include as the last output of Bitcoin coinbase transaction.
- The number of bytes immediately after
RskBlockInfo, up to the end of the coinbase transaction must be lower than or equal to 128 bytes.
- The trail raw bytes must not contain the binary string
- The probability of the RSK tag to appear by chance is negligible, but pool servers must not rule out the possibility of a rogue Bitcoin address included in the coinbase transaction having this pattern, and being used as an attack to break the validity of merged mining header.
RSKBLOCK:tag may appear by chance or maliciously in the ExtraNonce2 data field that is provided by miners as part of the Stratum protocol. This is not a problem as long as the poolserver adds the RSKBLOCK: tag after the ExtraNonce2 chunk.
3. Notify Miners on a faster pace
RSK average block time is 30 seconds which is faster than Bitcoin 10 minutes. This fact triggers the following implementation changes:
- Retrieve work from RSK node every 2 seconds to be always mining on the last RSK work.
- Sent to miners a
mining.notifymessage, from stratum protocol, every time a new RSK work is received.
4. Mine until work is enough to meet the target received in the work info
5. Submit Solution to RSK node
Use the mnr_submitBitcoinBlockPartialMerkle method from RSK node's JSON-RPC API. That method is the optimal in perfomance and prefered among others available. Other submission methods and information about the pros and cons between them can be found in the Mining JSON-RPC API documentation.
Influence to Bitcoin
As a result of merged mining with RSK, Bitcoin network does not get junked up with merged mining stuff since it will have tiny information stored (only an extra output on the coinbase transaction). Also, no changes are required on Bitcoin node to support merged mining with RSK.