<p>The pool's mining server gives each miner a template to use for generating blocks. When the server wants to update which transactions are included or which block to build upon it will push a new template to each miner.</p>

<p>To generate work for itself the miner is allowed to change the nonce, the timestamp and the extranonce.</p>

<p>The nonce is just a 32-bit number with no special meaning. All possible nonce values are quickly scanned by modern bitcoin ASIC hardware, so with the same timestamp and extranonce you only have a tiny amount of work.</p>

<p>The extranonce is part of the generation transaction, the transaction that generates new coins, which is the first transaction in the block. The extranonce has no special meaning.</p>

<p>The server must never send out the same block template twice, to ensure that the same work is not done multiple times. In the stratum protocol the extranonce is split in extranonce 1 and extranonce 2. Extranonce 1 belongs to the server and is in a part of the block template that the miner is not allowed to modify. To prevent sending the same work twice the server must never reuse the same extranonce 1 value unless something else (that is not modifiable by the miner) in the template has changed. For example the other (non-generation) transactions, or the previous block (the block we are building upon). As part of the template the server will tell the miner how large the extranonce 2 should be, usually 4 bytes. When the miner has tried all possible nonce values it can generate new work by changing the extranonce 2 value.</p>

<p>The timestamp (known as ntime) can also be useful to generate work. This can reduce the work load on a slow controller feeding work to fast ASIC chips. The controller only has to generate enough work to keep the ASICs busy for 1 second, using different extranonce 2 values. After that the ntime can be incremented by 1 every second and the same extranonce 2 values reused. This is known as "roll ntime" or "roll time", as the ntime field of the block is rolled forward. The ntime value can also be incremented every second for the purpose of more exact timestamps on blocks without reusing extranonce 2 values.</p>

<p>In this way the server and client cooperate to generate work and the same block is never hashed twice.</p>

CC BY-SA 3.0
2015-05-08T11:18:52.477Z
Thanks for your answer! One thing is still not clear to me: "In this way the server and client cooperate to generate work and the same block is never hashed twice." - By "the same block", do you mean _the same block header hash_ or do you mean _another valid child block_ with a different hash is never created? Because in the case of a forking between a selfish and an honest subchain, there's a chance of forking on the honest pool's subchain, isn't it?
Aliakbar Ahmadi
CC BY-SA 3.0
2015-05-09T10:48:13.553Z
You never want to hash the same block twice (redo the same work), so you must always change some part of the block either in the header or in the set of transactions.
Dr.Haribo
CC BY-SA 3.0
2015-05-08T09:07:56.453Z
2015-05-08T09:07:56.453Z
Dr.Haribo
<p>To clarify this first, header <code>h</code> which is hashed by miners using double SHA256 is a summation of version <code>v</code>, previous block's hash <code>pb</code> root hashof <code>r</code>, time <code>t</code>, bits <code>b</code> which is the target (difficulty) in addition to a <code>nonce</code>. <br>
Keep in mind that the <code>nonce</code> is not a really big number. In fact a fast ASIC miner can test all different values in a <code>nonce</code>. But there are other dynamic attributes like <code>t</code> which gives a new set of possibilities for a nonce every second and also root hash <code>r</code> which is the hash of all transactions in merkle root. Depending on how you sort the transactions it makes different roots. <br> 
Depending on the pool, the pool organizer should try not to waste its miners effort by making the most out of it efficiently. So by changing the position of transactions, pool organizer can make different <code>r</code> which can also make different works for its miners. Additionally transactions that are added every second can also change <code>r</code>.</p>

CC BY-SA 3.0
2015-05-07T14:08:39.560Z
I was under the impression that updating extraNonce was the more common way for pool operators to alter the merkle root— see [this SE answer](http://bitcoin.stackexchange.com/questions/5048/what-is-the-extranonce/5049#5049).
Christopher Gurnee
CC BY-SA 3.0
2015-05-07T10:09:11.710Z
2015-05-07T10:22:44.017Z
2015-05-07T10:22:44.017Z
abeikverdi
<p>How is work distributed among members of a pool?</p>

<p>Regarding the block hashing algorithm and valid hashes of a new node, how is the set of solutions for nonces "distributed" among miners?<br/>Is a nonce, for example, tried out multiple times by different miners in the pool? Or do miners split the space of solutions among each other, each working with a limited and mutually exclusive range of nonces?</p>

CC BY-SA 3.0
2015-05-07T10:50:49.300Z
In general the work is distributed such that the same work is never done twice, as that would simply be a waste. Note however that it can be done as a way to check the honesty of the miner: send him some work that the pool operator already knows should have a solution very quickly and check that the miner actually responds with that solution.
Jannes
CC BY-SA 3.0
2015-05-08T08:25:04.210Z
@Jannes: checking honesty this way doesn't really work anymore since work distribution is now done by giving the miner a template for work (stratum and getblocktemplate protocols). The miner is no longer given specific work (as with the old getwork protocol).
Dr.Haribo
<mining-pools><hash><getblocktemplate>
Work distribution in a mining pool
Aliakbar Ahmadi
# Work distribution in a mining pool

(Asked by: username_0 on 2015-05-07)

How is work distributed among members of a pool?

Regarding the block hashing algorithm and valid hashes of a new node, how is the set of solutions for nonces "distributed" among miners?  
Is a nonce, for example, tried out multiple times by different miners in the pool? Or do miners split the space of solutions among each other, each working with a limited and mutually exclusive range of nonces?

**Tags:** mining-pools, hash, getblocktemplate

> **Comments:**
> **username_1**: In general the work is distributed such that the same work is never done twice, as that would simply be a waste. Note however that it can be done as a way to check the honesty of the miner: send him some work that the pool operator already knows should have a solution very quickly and check that the miner actually responds with that solution.  
> **username_2**: @username_1: checking honesty this way doesn't really work anymore since work distribution is now done by giving the miner a template for work (stratum and getblocktemplate protocols). The miner is no longer given specific work (as with the old getwork protocol).  

---

## 2 answers

### Answer by username_2 on 2015-05-08. Score: 6

The pool's mining server gives each miner a template to use for generating blocks. When the server wants to update which transactions are included or which block to build upon it will push a new template to each miner.

To generate work for itself the miner is allowed to change the nonce, the timestamp and the extranonce.

The nonce is just a 32-bit number with no special meaning. All possible nonce values are quickly scanned by modern bitcoin ASIC hardware, so with the same timestamp and extranonce you only have a tiny amount of work.

The extranonce is part of the generation transaction, the transaction that generates new coins, which is the first transaction in the block. The extranonce has no special meaning.

The server must never send out the same block template twice, to ensure that the same work is not done multiple times. In the stratum protocol the extranonce is split in extranonce 1 and extranonce 2. Extranonce 1 belongs to the server and is in a part of the block template that the miner is not allowed to modify. To prevent sending the same work twice the server must never reuse the same extranonce 1 value unless something else (that is not modifiable by the miner) in the template has changed. For example the other (non-generation) transactions, or the previous block (the block we are building upon). As part of the template the server will tell the miner how large the extranonce 2 should be, usually 4 bytes. When the miner has tried all possible nonce values it can generate new work by changing the extranonce 2 value.

The timestamp (known as ntime) can also be useful to generate work. This can reduce the work load on a slow controller feeding work to fast ASIC chips. The controller only has to generate enough work to keep the ASICs busy for 1 second, using different extranonce 2 values. After that the ntime can be incremented by 1 every second and the same extranonce 2 values reused. This is known as "roll ntime" or "roll time", as the ntime field of the block is rolled forward. The ntime value can also be incremented every second for the purpose of more exact timestamps on blocks without reusing extranonce 2 values.

In this way the server and client cooperate to generate work and the same block is never hashed twice.

> **Comments:**
> **username_0**: Thanks for your answer! One thing is still not clear to me: "In this way the server and client cooperate to generate work and the same block is never hashed twice." - By "the same block", do you mean _the same block header hash_ or do you mean _another valid child block_ with a different hash is never created? Because in the case of a forking between a selfish and an honest subchain, there's a chance of forking on the honest pool's subchain, isn't it?  
> **username_2**: You never want to hash the same block twice (redo the same work), so you must always change some part of the block either in the header or in the set of transactions.  

---

### Answer by username_3 on 2015-05-07. Score: 0

To clarify this first, header `h` which is hashed by miners using double SHA256 is a summation of version `v`, previous block's hash `pb` root hashof `r`, time `t`, bits `b` which is the target (difficulty) in addition to a `nonce`.   
Keep in mind that the `nonce` is not a really big number. In fact a fast ASIC miner can test all different values in a `nonce`. But there are other dynamic attributes like `t` which gives a new set of possibilities for a nonce every second and also root hash `r` which is the hash of all transactions in merkle root. Depending on how you sort the transactions it makes different roots.   
Depending on the pool, the pool organizer should try not to waste its miners effort by making the most out of it efficiently. So by changing the position of transactions, pool organizer can make different `r` which can also make different works for its miners. Additionally transactions that are added every second can also change `r`.

> **Comments:**
> **username_4**: I was under the impression that updating extraNonce was the more common way for pool operators to alter the merkle root— see [this SE answer](http://bitcoin.stackexchange.com/questions/5048/what-is-the-extranonce/5049#5049).  

---

