Blockchain Basics - Mining Job
You might have heard that jobs are sent from the pool to the miner. Or you might have seen that the miner job was accepted inside the miner console. In this article we are going to explain what a mining job is.
What is a mining job?
In short, a mining job is a message that is being sent from the pool to the miner. This message contains pool target difficulty, extranonce1, extranonce2 information and other blockchain specifics that are included in the block.
If you read this article about pool mining, you will learn that a pool must let the miners know what numbers to guess in order to spread out the work among all the workers.
The pool and the workers will always communicate between each other. The pool will send the job data that needs to be solved while the miner or worker will send back the solutions. A mining job is a message that the pool and worker are sending to each other.
If the miner finds a solution to the data provided by the pool, then the miner sends back a mining job solution also known as an accepted share.
What data is included in the mining job?
This depends on the blockchain. Different coins and algorithms use different messages. Below you will find the data that is being included in the mining job:
- Job ID: ID of the job. Miners (workers) use this when submitting a share (solution) generated from this job ID.
- Previous Block Hash: Hash output of the previous block.
- Coinbase1: The miner inserts ExtraNonce1 and ExtraNonce2 after this section of the transaction data.
- Coinbase2: The miner appends this after the first part of the transaction data and the two ExtraNonce values.
- Merkle_Branch: The coinbase transaction is hashed against the Merkle branches to build the final markle root.
- Version: Bitcoin block version
- nBits: Encoded network difficulty
- nTime: Current time
- Clean_Job: When this is true, the miner will stop working on previous jobs and start working on the new job received from the pool.
Example of a mining job sent from pool to the worker
The payloads between the miner and the pool are encoded as JSON-RPC messages.
"id":null,"method":"mining.notify","params":["0000000053c411aa","b87d45785c4cc00150867971b7233c4446dfb4bd0003cb690000000000000000","01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff5103539f0b082f5669614254432f2cfabe6d6d138e19afd289f4e1bcc69389a865ede0bd9d642189026485bd4bde3e062686b3100000000000000012734e8daaaa0f6280bf91","ffffffff03e44e2826000000001976a914536ffa992491508dca0354e52f32a3a7a679a53a88ac00000000000000002b6a2952534b424c4f434b3a51115f17d525a3952237430d78f5f4b2f4bc63148fd82f364f77c5260048d97e0000000000000000266a24aa21a9edfcfe2c5bd8a7df958c20d29cd5457ef6565a30ae10bf137602d4b838288908a500000000",["93cbc2abc1128cc9569a4ecbba4188b25ce7c9c8b5e5c9a2810cf0973d82f717","322139a87a09d3037d340f393a1d89ad34b163a07a9a7012fd58d92ca5e038c5","34cfc928a8bb978ab345d66c4940f566b5a36a1b6f7f5c2a617f68acc4f0a1e8","e4cc101b5df77d48d7abeb9a52d1a4bd8768a5cab4b568f804849d793eb8c432","ef14da7b3a470fdd3074633f711a0dcf003c91f4b6b02074d64e51878aafbd37","5ddd66513381c05cb479bfd062daa043295ee608f7bb22082f7c9c2d7f0aac40","bfc4e8f1e80ae3697bccfea631520e2907c7ad9ae5f5e3385aa4c8472ad39624","e6edd6c37b6924f4d5ab9350b33d5c7912d6df8a77be4d2d432d91134c0e83da","7aac970301559306792b9d017e54012ac3b1711c10d2c147fb9cbc32d1f1c63a","40329f69e3152d4537fa6e84e62e2f0830a18e3089455a78d58a54efd9479005","9a9f5af30e3bbc67e282fda897531337ab7d87e1da95d79f4831e8867b888c92","415bb76a0d8183657e0a5ac2bab8676e6ffa27ee3b2565ba1769af7503e9efad"],"20000000","1707a429","6364e9cf",false]}
The above message seems clumsy for human eyes, so here is a bit easier format to understand the message:
"id":null,"method":"mining.notify","params":["JobID","PreviousBlockHash","Coinbase1","Coinbase2",[MerkleBranch],"Version","nBits","nTime",false]}
Example of a mining job solution sent from the worker to the pool
{"id":15866,"method":"mining.submit","params":["3HJ4xQWjAsKuTwL1QBg4b5875hNcYRrtAr.workerName","0000000053c411aa","0446000000","6364e9cf","75a22825"]}
And explanation of the mining.submit:
{"id":15866,"method":"mining.submit","params":["username","JobID","Extranonce2","nTime","nonce"]}
As you can see, the job IDs on both jobs are the same.