<p>The &quot;cumulative chain work&quot; of a chain (which is used to determine which of two competing chains to pick in case multiple valid ones exist) in Bitcoin Core is determined by summing the expected number of hashes needed per block. That is, it equals the sum of <em>⌊2<sup>256</sup> / (block_target + 1)⌋</em> over all blocks in the chain, with <em>block_target</em> the target encoded by the individual blocks' <em>nBits</em> values.</p>
<p>See the <a href="https://github.com/bitcoin/bitcoin/blob/v27.1/src/chain.cpp#L131L144" rel="nofollow noreferrer"><code>GetBlockProof</code></a> function in the Bitcoin Core 27.1 source code.</p>
<blockquote>
<p>Concretely, let’s assume there were two competing chaintips {P, A₁, A₂} and {P, B₁}, where P is the last shared ancestor, A₁ and A₂ were mined with the 20-minute exception rule and therefore have the nBits field in the header set to the maximum target, and B₁ was mined at the actual difficulty. Which chaintip would count as more work?</p>
</blockquote>
<p>If B₁ has a difficulty higher than 2, then {P, B₁} would be treated as having more chain work than {P, A₁, A₂}.</p>

CC BY-SA 4.0
2024-07-19T19:57:44.170Z
2024-07-19T19:57:44.170Z
Pieter Wuille
<p>Do 20-minute exception blocks on Testnet 3 contribute total work according to their <code>nBits</code> or according to the actual difficulty of the current period?</p>
<p>Concretely, let’s assume there were two competing chaintips {P, A₁, A₂} and {P, B₁}, where P is the last shared ancestor, A₁ and A₂ were mined with the 20-minute exception rule and therefore have the <code>nBits</code> field in the header set to the maximum target, and B₁ was mined at the actual difficulty. Which chaintip would count as more work?</p>

<blockchain-fork><testnet>
What is the total-work contribution of 20-minute exception blocks on Testnet 3?
Murch
# What is the total-work contribution of 20-minute exception blocks on Testnet 3?

(Asked by: username_0 on 2024-07-19)

Do 20-minute exception blocks on Testnet 3 contribute total work according to their `nBits` or according to the actual difficulty of the current period?

Concretely, let’s assume there were two competing chaintips {P, A₁, A₂} and {P, B₁}, where P is the last shared ancestor, A₁ and A₂ were mined with the 20-minute exception rule and therefore have the `nBits` field in the header set to the maximum target, and B₁ was mined at the actual difficulty. Which chaintip would count as more work?

**Tags:** blockchain-fork, testnet


---

## 1 answers

### Answer by username_1 on 2024-07-19. Score: 1 | Accepted answer

The "cumulative chain work" of a chain (which is used to determine which of two competing chains to pick in case multiple valid ones exist) in Bitcoin Core is determined by summing the expected number of hashes needed per block. That is, it equals the sum of *⌊2256 / (block\_target + 1)⌋* over all blocks in the chain, with *block\_target* the target encoded by the individual blocks' *nBits* values.

See the [`GetBlockProof`](https://github.com/bitcoin/bitcoin/blob/v27.1/src/chain.cpp#L131L144) function in the Bitcoin Core 27.1 source code.

> Concretely, let’s assume there were two competing chaintips {P, A₁, A₂} and {P, B₁}, where P is the last shared ancestor, A₁ and A₂ were mined with the 20-minute exception rule and therefore have the nBits field in the header set to the maximum target, and B₁ was mined at the actual difficulty. Which chaintip would count as more work?

If B₁ has a difficulty higher than 2, then {P, B₁} would be treated as having more chain work than {P, A₁, A₂}.


---

