2

I'm working on building a mining pool from scratch and it'd be really helpful if someone explained the steps to generate a job for miners. Let's say I have 10 miners connected to my pool, what are the steps to generate a job for each of the miners.

I know that the first step is to get the block_hashing_blob from the monerod RPC.

1

Your pool first calls get_block_template and reserving some space by making use of the reserve_size parameter.

You then take the returned blocktemplate_blob, convert the hex data into binary, and modify the data at the offset provided by the returned reserved_offset parameter. This is where you will write your per miner, miner ID for example. So assume you asked for 4 bytes of reserved space, you have 4 bytes you can change at this reserved offset.

Now you have to create a hashing blob for the miner from this data. To do this, you need to make use of two Monero functions: parse_and_validate_block_from_blob and get_block_hashing_blob. The former converts your binary data to a C block structure and the later gets a hashing blob of the block. To use these functions you have to be in a C/C++ environment as they are not exposed via the RPC. Alternatively, you would have to re-implement them in your chosen language.

get_block_hashing_blob is the notable function here and what it does is return the binary data (a blockhashing_blob) of:

  • The blocks header data
  • Appended with the blocks merkle tree root hash
  • Appended with the tx count

Lastly, once you have your binary blockhashing_blob, you convert it to a hex string and send to the miner.

  • Tell me if this is correct( obtained this info from a pool source code) 1. Get block_template_blob and include extraNonce and Instance Id in it 2. Convert it to block_hashing_blob (hex encoded) 3. compute hex encoded "target" What is the purpose of extraNonce and Instance Id – Teja May 30 at 10:20
  • 1
    extranonce and instanceid are unique data added to the reserved space (as I detailed above). It is up to the pool implementation to decide what to add here. In nodejs-pool, extranonce is a unique miner id and instanceid is like a random pool thread id. But again, it's up to your pool implementation to decide what you stuff in your reserved space. – jtgrassie May 30 at 10:58
  • why are they used? what's their purpose – Teja May 30 at 12:10
  • 1
    You are asking now about a specifics pools use of the reserved space. The point is, the reserved space allows you to make the hashing blob unique for each miner. Otherwise they would all be hashing the exact same data which would be pointless. The work needs to be unique for each miner. You can put whatever you like in the reserved space, based on the needs of your specific pool. The nodejs-pool is making each hashing blob unique by increment a variable (extraNonce) and adding a coin specific random ID (instanceId), every time a hashing blob is created. Therefore, each hashing blob is unique – jtgrassie May 30 at 14:50
  • Thanks, makes sense now – Teja May 30 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.