Overview

7 Proof of work

This chapter explains how Bitcoin removes a single point of control and achieves censorship resistance by replacing a signed, leader-based blockchain with a competitive proof-of-work process. Instead of trusting one authority to decide which transactions enter the ledger, many independent miners race to discover the next block by expending computational work. Occasional simultaneous wins create temporary splits, which resolve as miners converge on the branch with the most accumulated proof of work—the strongest chain—thereby maintaining a unified, tamper-resistant history.

Proof of work is realized by hashing block headers until the resulting hash falls below a network-wide target, varied by miners through a nonce and other header fields. Verification is self-contained: anyone can validate a block’s work and contents from the block itself, no external keys required. Because network hashrate fluctuates, Bitcoin periodically adjusts difficulty—retargeting every set number of blocks—so average block time remains stable. Timestamps are constrained to prevent gaming the retarget, and the distinction between longest and strongest chains matters, especially around difficulty changes.

The chapter also analyzes miner incentives and security. Miners earn a block reward consisting of the subsidy plus transaction fees; since larger blocks propagate and verify more slowly, fees motivate which transactions get included and underpin a fee market when block space is scarce. Double-spend defenses rely on waiting for multiple confirmations, making attacks increasingly unlikely and costly unless an adversary controls a majority of hashrate, in which case economic self-interest and broader participation help discourage or dilute centralization. Over time, as the subsidy halves, fees play a growing role in sustaining mining and network security.

 Proof of work
visual toc proof of work.png
  Lisa could censor transactions like a dictator. No cookies for John.
censorship.png
  Three miners build blocks. Usually blocks are created nicely one by one, but sometimes they will compete to become the next block, as at height 106.
three miners and a fork.png
chain fork simple resolution.png
  Both Lisa and Qi draws a lucky number at the same time. The situation is not resolved yet.
chain fork of depth 2.png
  Tom is the next lucky miner and he gets to extend "his" branch which will now become the longest branch.
chain fork delayed resolution.png
  One of the branches experiences yet another split. This new split is resolved like the previous split.
chain fork of fork.png
  Proof of work is how we select a leader without a leader.
periscope proof of work.png
  The block signatures are replaced by proof of work.
proof of work overview.png
  The block id must be less than or equal to the target in the header. Otherwise the block is invalid.
valid pow example.png
  Qi tests if her block is valid by verifying the proof of work
create pow example 1.png
  Qi increases the nonce and makes a second attempt at finding a valid proof of work. This also fails.
create pow example 2.png
  Changing the input of a cryptographic hash function will result in a completely different output.
2ndcol hashing a modified cat.png
  Qi’s try with nonce 227,299,124. Close but no cigar!
create pow example 4.png
  Qi keeps on working.
create pow example 5.png
  The nonce 492781982 is a winner!
create pow example 6.png
  Block verification has changed. The verifier doesn’t need anything from outside the block anymore.
verify block then and now.png
  The blockchain works just as when lucky numbers were used.
three miners proof of work.png
07_19_F1
  The block header can be changed in different ways
change header.png
  Adjusting the target based on the last 2016 blocks. The goal is 2016 blocks in two weeks.
retarget.png
  Two blocks are mined with decreasing timestamps. That’s OK.
timestamps diff.png
  A natural split with differing timestamps between the branches will cause one branch to become stronger than the other in case of a retarget.
strength length.png
formula7 2.png
  Lisa creates two transactions that spend one common output. She pays a 0.5 CT in transaction fee.
double spend transaction.png
  Lisa pulls off a double spend attack - and succeeds in spite of her small hashrate.
double spend attack success.png
  Lisa tries to double spend a transaction with 6 confirmations. She fails.
double spend attack fail.png
  Tom attempts to double spend with 18% hashrate and gives up. He’s actually lucky finding two blocks in about the same time the honest miners finds three.
double spend attack tom fail.png
  Hashrate distribution. Two miners can collude to control a majority of the hashrate.
Description: chart hashrate distribution then
29. New hashrate distribution. It’s much harder to get control over a majority of the hashrate.
Description: chart hashrate distribution now
  Lisa and Tom compete to get Qi and the other miners to mine on top of their block. Tom wins this race because his block was smaller.
block size matters.png
  John includes a transaction fee that the miner who mines a block with his transaction gets.
transaction fee.png
Lisa is working on a block and she has included John’s transaction and a few others. She collects the fees in the coinbase output.
lisa collects transaction fees.png
 In a fee market, transactions compete for block space. The numbers in the transactions are fee level in CT/byte
  When there is no fee market, transactions don’t compete with each other. They just have to pay for the lost competitiveness.
A miner must make at least enough money to pay for the electricity.
mining economy.png
A valid proof of work. The block header hash is lower than the target.
summary valid pow.png
  The block reward is collected in the coinbase output.
lisa collects transaction fees.png
  Proof of work will cause splits of the blockchain. They will be resolved over time.
three miners proof of work.png
  Requiring many confirmations can protect the merchant from double spends.

 Recap

In this chapter you learned that

  • We now have multiple miners to avoid a central authority that can censor transactions.
  • Proof of work is used to select who gets to create a block.
  • Proof of work enables anyone to start mining without asking for permission.
  • The target is automatically calibrated every 2016 blocks to keep the money creation at the predetermined rate.
  • A transaction fee is used to give miners incentive to include the transaction in its block.
  • The recipient of cookie tokens, or bitcoins, select how many confirmations are needed, to keep the risk of double spends low.
  • A miner get as much block rewards it deserves. The more hashrate it puts into the system the bigger share of the rewards it gets.
  • The stronger a chain is, the more accumulated proof of work it has, the harder it is to rewrite that chain.

FAQ

What problem does proof of work solve compared to having a single signer of blocks?Proof of work removes the need to trust a single authority to approve blocks. Instead of one signer who could censor or be coerced, many independent miners can compete to add blocks. Anyone can verify a block by checking its proof of work without any external keys, which makes the system decentralized and censorship resistant by making cheating hard and expensive rather than merely detectable.
How do you verify that a block’s proof of work is valid?Hash the block header with double SHA-256 to get the block ID and compare that 256‑bit number to the target encoded in the header. If the block ID is less than or equal to the target, the proof of work is valid; otherwise it’s invalid.
How do miners find a valid block (produce a valid proof of work)?Miners repeatedly hash slightly different block headers until the header hash is below the target. They vary the 32‑bit nonce first; if all nonce values are exhausted, they change other header-affecting fields (for example tweak the timestamp, modify the coinbase transaction, or add/reorder transactions) and continue searching.
What is the target and how does it relate to difficulty and chain selection?The target is a 256‑bit threshold stored in the header that defines how hard it is to find a valid hash. Lower target = higher difficulty. Nodes follow the strongest chain, meaning the one with the most accumulated proof of work (the sum of per‑block difficulties), not merely the longest by block count.
Why do blockchain splits happen and how are they resolved?Splits occur when two miners find valid blocks at about the same time and different peers see different blocks first. Miners then compete to extend one branch. As soon as one branch gains more accumulated work, nodes switch to it and the split resolves. Single‑block splits are occasional; deeper splits become exponentially rarer.
Why are smaller blocks more likely to “win” and how do transaction fees counter that?Smaller blocks propagate and verify faster, so other miners are more likely to build on them, giving the publisher a competitive edge. Transaction fees compensate miners for including extra bytes: miners select transactions by fee per byte, so higher‑fee‑rate transactions are more likely to be included, especially when block space is scarce (fee market).
What are difficulty adjustments (retargets) and why do they happen every 2016 blocks?Every 2016 blocks, nodes recalculate the target so that blocks continue to arrive about every 10 minutes. If the last 2016 blocks took less than two weeks, difficulty increases (target decreases); if they took longer, difficulty decreases (target increases). The change per period is bounded (e.g., within 4×) to limit manipulation and stabilize issuance.
What rules govern block timestamps and why?A block’s timestamp must be strictly greater than the median of the previous 11 blocks (Median Time Past) and within roughly ±2 hours of the validating node’s clock (for recent blocks). These rules prevent miners from skewing timestamps to game difficulty adjustments.
How do confirmations reduce the risk of double-spend attacks?An attacker who secretly mines a conflicting branch must catch up and overtake the honest chain. With less than 50% of total hashrate, the chance of ever catching up drops rapidly with each additional confirmation. Waiting for more confirmations (e.g., 6 for high‑value transactions) makes a successful double spend increasingly unlikely and economically costly.
What risks come from miner centralization and how are they mitigated?If one party (or colluding group) controls a majority of hashrate, they can reliably reorganize the chain and double spend. However, doing so threatens the currency’s value and miners’ revenues, creating strong economic disincentives. Broad participation and growing total hashrate dilute any single miner’s influence, making majority control harder and riskier to sustain over time.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bitcoin ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bitcoin ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bitcoin ebook for free