Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.
kenshirothefist edited this page May 31, 2016 · 4 revisions

Decred mining with NiceHash support

revision of this document: R1

  1. Introduction & Concept
  2. Specifications (RFC)
  3. Contact

Introduction & Concept

Following block header is used in Decred:

0x01, 0x00, 0x00, 0x00, // Version 1
0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, // PrevBlock
0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f,
0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c,
0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3b, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2, // MerkleRoot
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
0x3b, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2, // StakeRoot
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
0x00, 0x00, // VoteBits
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // FinalState
0x00, 0x00, // Voters
0x00, // FreshStake
0x00, // Revocations
0x00, 0x00, 0x00, 0x00, //Poolsize
0xff, 0xff, 0x00, 0x1d, // Bits
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SBits
0x00, 0x00, 0x00, 0x00, // Height
0x00, 0x00, 0x00, 0x00, // Size
0x29, 0xab, 0x5f, 0x49, // Timestamp
0xf3, 0xe0, 0x01, 0x00, // Nonce
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ExtraData
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00

There are 36 bytes in ExtraData field that can be used for random user- defined data.

First up to 8 bytes of data is used for ExtraNonce1 in standard stratum mining protocol. ExtraNonce1 is set for each miner by the pool and no two miners shall have same ExtraNonce1. Pool makes sure that no two miners ever perform same work.

Following X bytes of ExtraNonce1 inside ExtraData are up to 8 bytes used for ExtraNonce2. Size of ExtraNonce2 is defined by the pool (just like in standard stratum protocol). ExtraNonce2 is an extension for miner's nonce, because miner may run out of nonce range, thus it can increase ExtraNonce2 to be able to hash unique work again.

If pool chooses to use 4 bytes for ExtraNonce1 and 8 bytes for ExtraNonce2, then block header would look like:

...
0x29, 0xab, 0x5f, 0x49, // Timestamp
0xf3, 0xe0, 0x01, 0x00, // Nonce
0x00, 0x00, 0x00, 0x00, // ExtraNonce1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ExtraNonce2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // remaining ExtraData
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

Remaining ExtraData must always be padded with nulls!

When pool sends out the job (mining.notify), it should set following parameters:
params[0] = Job ID.
params[1] = PrevBlock (32 bytes).
params[2] = MerkleRoot, StakeRoot,... Height, Size (together 100 bytes).
params[3] = Unused. Set to "".
params[4][] = Unused. Set to [].
params[5] = Version.
params[6] = Unused. Set to "".
params[7] = Timestamp (miner can roll this value as fast as time goes)
params[8] = Clean Jobs.

Miner generates work for hashing by combining:
Version (params[5]) + PrevBlock (params[1]) + MerkleRoot, StakeRoot,...
Height, Size (params[2]) + Timestamp (params[7] + Nonce (selected by miner) + ExtraNonce1 (send by the pool at start) + ExtraNonce2 (selected by miner)

Specifications (RFC)

Standard stratum protocol is used with adjustments explained in 1.

Miners should support extranonce.subscribe for optimal performance when mining on NiceHash.

Contact

www.nicehash.com
[email protected]

Clone this wiki locally