Description of steps to follow in order to add RSK merged mining capabilities to a mining pool software.
Add the RSK merged mining information in Bitcoin block as a commitment, the complete steps are as follow:
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.
OP_RETURN
+ Length
+ RSKBLOCK:
+ RskBlockInfo
OP_RETURN:
is0x6a
Length
is 0x29
and represents the length of the information included after the OP_RETURN
opcodeRSKBLOCK:
is the ascii string for0x52534b424c4f434b3a
RskBlockInfo
is the block information in binary format.For example, if RskBlockInfo
is e5aad3b6b9dc71a3eb98a069bd29ca32211aee8b03fd462f4ffbbe97cc75a174
the merged mining information is6a2952534b424c4f434b3ae5aad3b6b9dc71a3eb98a069bd29ca32211aee8b03fd462f4ffbbe97cc75a174
Include as the last output of Bitcoin coinbase transaction.
RskBlockInfo
, up to the end of the coinbase transaction must be lower than or equal to 128 bytes.RSKBLOCK:
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.RSK average block time is 30 seconds which is faster than Bitcoin 10 minutes. This fact triggers the following implementation changes:
mining.notify
message, from stratum protocol, every time a new RSK work is received.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.
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.