09 / 7362016

Difficulty Adjustment

adjusting mining difficulty

How Bitcoin adjusts the effort required to mine, keeping the long-term average close to one new block every ten minutes.

Difficulty Adjustment automatically changes how hard it is to mine a block. When miners find blocks too quickly, the rules make the search harder; when they find them too slowly, it becomes easier. This helps Bitcoin keep a roughly steady pace despite large changes in computing power. Every fully validating node checks the adjustment using the same rules; no administrator decides it.

Imagine many new machines joining the mining network. Together they try more calculations each second, so at the same difficulty they find blocks faster on average. A block is a batch of confirmed transactions, and creating one can also create new bitcoin. Without an adjustment, more powerful machines would speed up that issuance too. Miners repeatedly calculate a hash, a numerical fingerprint of the block header. They succeed when the result is small enough. A stricter threshold makes each attempt less likely to succeed, so finding a block takes more work on average. [3]

On Bitcoin's main network, called mainnet, difficulty is recalculated every 2,016 blocks. At an average of ten minutes per block, that is roughly two weeks. But there is no timer: the adjustment is triggered by reaching the relevant block number, or height. If many miners suddenly switch off their machines, the remaining blocks may take longer to arrive. The network finishes the period at the old difficulty first; mainnet has no immediate emergency reduction. [1] [2]

Suppose the time used in the calculation is 10 days rather than the target of 14. The next period becomes harder: difficulty rises by roughly the ratio of 14 to 10, or 40%. If the measured period instead takes 28 days, difficulty roughly halves. These simplified examples ignore rounding and assume the minimum permitted difficulty does not come into play. If computing power then stays unchanged, the new setting brings the expected block time back towards ten minutes. [1] [2]

Ten minutes is a long-term average, not a promised waiting time. Two blocks may arrive close together, while another may take considerably longer. Your transaction may not be in the very next block either: its fee and other waiting transactions also matter. The adjustment does not control the BTC price or guarantee miners a profit. It also leaves unchanged the amount of new bitcoin allowed per block; its periodic reduction by half, Halving, follows a separate rule. [2] [3]

The rules use a numerical threshold called the target. A smaller target means harder mining; the figure called difficulty expresses that relationship in reverse. The new target equals the old target multiplied by the measured time and divided by the target time of 1,209,600 seconds. Before calculating, the measured time is clamped to between one quarter and four times the target duration, limiting the size of one adjustment. The target must also stay at or below the maximum allowed value, powLimit. It is stored in the block header in the compact nBits representation. That format has limited precision, which is why the example percentages are approximate. [1] [2]

Bitcoin Core compares the header timestamp of the last block in the completed period with that of its first block. There are 2,015 gaps between 2,016 blocks; the rules retain this historical quirk. Miners choose header timestamps within the network's rules. These are neither precise measurements of when a block was found nor Median Time Past, a different time value calculated from earlier blocks. You do not need this detail to understand why the adjustment exists, but it matters when reproducing the exact calculation. [1]

Websites often display an estimate of the next difficulty change. Until the period ends, more blocks arrive and that estimate can change. You can verify a completed adjustment with your own node: compare the boundary blocks' timestamps, convert their nBits into numerical targets, and repeat the calculation including its limits and rounding. Every Full Node, a node that independently validates Bitcoin's rules, checks the required target when accepting a block. This procedure describes mainnet; test networks can use different rules. [1] [2]

For the clearest picture, read this entry together with Proof of Work, Mining, Timechain / Blockchain, Block Subsidy. The reverse links also lead from Timechain / Blockchain, Proof of Work, Mining, Halving.

DOC · 001Bitcoin Core v29.0: retargetPrimary DOC · 002Bitcoin Core v29.0: network parametersPrimary DOC · 003Bitcoin Developer Guide — Proof of Work and difficultyPrimary
Revised: Source-first · No investment advice