Blockplain, home page
← Back to home

How the computers agree

Thousands of computers keep copies of the same record, and none of them is in charge. They need a rule for who adds the next block, and for which copy counts when two disagree. That rule is called the consensus model.

Information, not advice.

The problem

On an open network anyone can join, and some may try to cheat, for example by spending the same money twice (a double spend).

Making many identities online costs nothing, so “one computer, one vote” would let a cheat outvote everyone. The network needs a vote that costs something real.

Whatever the model, every computer checks every block itself, against rules everyone accepted when they joined.

Technical detail

Making many identities to gain influence is a Sybil attack. The Bitcoin paper: a majority based on one IP address, one vote could be subverted by anyone able to allocate many IPs.

Every network starts from an agreed first block, the genesis block. From there, each node can check every block since, so no trusted third party has to tell it the state of the record.

Proof of work

Computers compete to solve a puzzle that is hard to solve and quick to check: find a number that, added to the block, gives a hash starting with enough zeros. There is no shortcut, only guess after guess. The first to find one publishes the block and is paid in the network's own coin.

This is called mining. Bitcoin uses it, and changes how hard the puzzle is every 2,016 blocks so that a block is made about once every ten minutes.

Try a small version below. Each extra zero makes it about sixteen times harder.

Try it

Worked out in your browser. Nothing you type or choose is sent anywhere.

Find a number that, added to the word “blockchain”, gives a SHA-256 fingerprint starting with this many zeros:

Technical detail

NIST's example: find a nonce so that SHA256("blockchain" + nonce) starts with 000000. It took 10,730,896 guesses (54 seconds on old hardware); the answer is blockchain10730895. One more zero took 934,224,175 guesses, in 1 hour 18 minutes.

Checking an answer takes one hash. Miners often join pools that split the range of guesses between them and share the reward.

What proof of work costs

All those guesses take hardware and electricity, by design. NIST describes the resource use as significant, and notes that miners move to places where electricity is cheap. In return, rewriting the record means outspending everyone else who is mining.

Figures for how much electricity are on the limits page.

Proof of stake

Instead of spending electricity, participants lock up some of the network's coin as a stake. The network picks who proposes the next block, and more stake means more chance of being picked. A participant who breaks the rules can have part of their stake destroyed.

Ethereum switched from proof of work to proof of stake on 15 Sep 2022, in a change it calls the Merge. On Ethereum, a validator deposits 32 ETH, and time is split into 12-second slots.

Technical detail

NIST describes four ways of using stake: random choice in proportion to stake, rounds of voting, “coin age”, and voting for delegates. It notes the “nothing at stake” problem, where a validator can back two competing chains at no cost, and that those with more to stake can earn more.

On Ethereum, destroying part of a dishonest validator's stake is called slashing. Proposing two blocks in one slot, or contradictory votes, are examples ethereum.org gives.

Who takes part

On open networks, anyone with the hardware (proof of work) or the coin to stake (proof of stake) can try to publish blocks. Most do it for the reward.

On networks run by a known group, members are approved and known by name, so they can simply take turns, or be trusted for their reputation. No costly puzzle is needed. See public and private blockchains.

Technical detail

Models NIST lists for permissioned networks include round robin (members take turns), proof of authority or identity (publishers stake their known reputation) and proof of elapsed time (a random wait from secure hardware).

When two blocks arrive at once

Sometimes two computers publish a block at almost the same moment, and the network splits for a while. Each computer carries on from the first one it saw. When the next block lands on one side, that side is longer, and everyone switches to it.

The other block is dropped (an orphan block) and its transactions go back into the queue. This is why people wait for a few more blocks before treating a payment as settled.