Miner Development - Stratum Block Header Assembly

Discussion in 'Proof-of-work Mining' started by semtexzv, Apr 18, 2017.

  1. 2017/12/15 - Decred v1.1.2 released! → Release Notes  → Downloads
  1. semtexzv

    semtexzv New Member

    Apr 18, 2017
    Hello, I am developing multi coin miner, and I would like to add decred support.

    I have some problems figuring block header assembly.

    So far I used official block header specification (https://docs.decred.org/advanced/block-header-specifications/) , and gominer source code to find out how to assemble block. I used
    stratum+tcp://yiimp.ccminer.org:4252 as job source.

    So far I figured out how to assemple most of the block header from stratum data.

    Version in LE(sent in job notification from stratum ) = 4 bytes,
    prevhash as int[8] in BE, I need to reverse each int to LittleEndian,
    coinbase1 - 112 bytes, assembled by pool, contains everything up to "Extra Data" from header specification, and also contains 8 bytes of this extra data.

    Now, I have 32 bytes left (ExtraData - 8 bytes, specified in coinbase1).

    I presume this data is up to client to make up. part of this data is probably extranonce1 + extranonce2.

    Stratum subscription responds with 12 bytes of extranonce1 and extranonce2_len of 12.
    so that is 24 bytes, and I have 8 bytes left. This 8 bytes is the problem , I am not sure what it is. Is it my nonce space ?

    Also, how do extranonce1, extranonce2 fit into block header ?

    My current idea is:

    Block Header :
    version from job : 4 bytes in LE, stays in LE,
    prevhash : 32 bytes, needs to be byteswapped per 4 bytes,
    coinbase1: 112 bytes, from pool, no modification,
    extranonce1: 12 bytes, from pool, no modification,
    extranonce2: 12 bytes, length specified by pool, generated by miner, sent as little-endian hex string.
    nonce : 8 bytes - rolling counter, sent in job notification as little-endian hexadecimal string.

    Block header is then hashed, I currently have no idea about endiannes of this has, and whether last N bytes or First N bytes are checked against target.

    Any miner developers here willing to help ? thank you.

Share This Page