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
Lisa could censor transactions like a dictator. No cookies for John.
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.
Both Lisa and Qi draws a lucky number at the same time. The situation is not resolved yet.
Tom is the next lucky miner and he gets to extend "his" branch which will now become the longest branch.
One of the branches experiences yet another split. This new split is resolved like the previous split.
Proof of work is how we select a leader without a leader.
The block signatures are replaced by proof of work.
The block id must be less than or equal to the target in the header. Otherwise the block is invalid.
Qi tests if her block is valid by verifying the proof of work
Qi increases the nonce and makes a second attempt at finding a valid proof of work. This also fails.
Changing the input of a cryptographic hash function will result in a completely different output.
Qi’s try with nonce 227,299,124. Close but no cigar!
Qi keeps on working.
The nonce 492781982 is a winner!
Block verification has changed. The verifier doesn’t need anything from outside the block anymore.
The blockchain works just as when lucky numbers were used.
The block header can be changed in different ways
Adjusting the target based on the last 2016 blocks. The goal is 2016 blocks in two weeks.
Two blocks are mined with decreasing timestamps. That’s OK.
A natural split with differing timestamps between the branches will cause one branch to become stronger than the other in case of a retarget.
Lisa creates two transactions that spend one common output. She pays a 0.5 CT in transaction fee.
Lisa pulls off a double spend attack - and succeeds in spite of her small hashrate.
Lisa tries to double spend a transaction with 6 confirmations. She fails.
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.
Hashrate distribution. Two miners can collude to control a majority of the hashrate.
29. New hashrate distribution. It’s much harder to get control over a majority of the hashrate.
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.
John includes a transaction fee that the miner who mines a block with his transaction gets.
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.
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.
A valid proof of work. The block header hash is lower than the target.
The block reward is collected in the coinbase output.
Proof of work will cause splits of the blockchain. They will be resolved over time.
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.
Grokking Bitcoin ebook for free