@ -542,41 +542,45 @@ and diminishes with time, following a fixed issuance schedule.
Mining achieves a fine balance between cost and reward. Mining uses
Mining achieves a fine balance between cost and reward. Mining uses
electricity to solve a mathematic al problem. A successful miner will
electricity to solve a computation al problem. A successful miner will
collect a _reward_ in the form of new bitcoin and transaction fees.
collect a _reward_ in the form of new bitcoin and transaction fees.
However, the reward will only be collected if the miner has correctly
However, the reward will only be collected if the miner has correctly
validated all the transactions, to the satisfaction of the rules of
validated all the transactions, to the satisfaction of the rules of
_consensus_. This delicate balance provides security for bitcoin without
_consensus_. This delicate balance provides security for bitcoin without
a central authority.
a central authority.
A good way to describe mining is like a giant competitive game of sudoku
Mining is designed to be a decentralized lottery. Each miner can create
that resets every time someone finds a solution and whose difficulty
their own lottery ticket by creating a _block template_ that includes
automatically adjusts so that it takes approximately 10 minutes to find
the new transactions they want to mine plus some additional data fields.
a solution. Imagine a giant sudoku puzzle, several thousand rows and
The miner inputs their template into a specially-designed algorithm that
columns in size. If I show you a completed puzzle you can verify it
scrambles (or "hashes") the data, producing output that looks nothing
quite quickly. However, if the puzzle has a few squares filled and the
like the input data. This _hash_ function will always produce the same
rest are empty, it takes a lot of work to solve! The difficulty of the
output for the same input--but nobody can predict what the output will
sudoku can be adjusted by changing its size (more or fewer rows and
look like for a new input, even if it is only slighly different from a
columns), but it can still be verified quite easily even if it is very
previous input. If the output of hash function matches a template
large. The "puzzle" used in bitcoin is based on a cryptographic hash and
determined by the Bitcoin protocol, the miner wins the lottery and
exhibits similar characteristics: it is asymmetrically hard to solve but
Bitcoin users will accept the block template with its transactions as a
easy to verify, and its difficulty can be adjusted.
valid block. If the output doesn't match the template, the miner makes
a small change to their block template and tries again. As of this
writing, the number of block templates miners need to try before finding
a winning combination is about 168 billion trillions. That's also how
many times the hash function needs to be run.
However, once a winning combination has been found, anyone can verify
the block is valid by running the hash function just once. That makes a
valid block something that requires an incredible amount of work to
create but only a trivial amount of work to verify. The simple
verification process is able to probabalistically prove the work was
done, so the data necessary to generate that proof--in this case, the
block--is called Proof-of-Work (PoW).
((("mining and consensus", "mining farms and pools")))In
((("mining and consensus", "mining farms and pools")))In
<<user-stories>>, we introduced ((("use cases", "mining for
<<user-stories>>, we introduced ((("use cases", "mining for
bitcoin")))Jing, an entrepreneur in Shanghai. Jing runs a _mining farm_,
bitcoin")))Jing, an entrepreneur in Shanghai. Jing runs a _mining farm_,
which is a business that runs thousands of specialized mining computers,
which is a business that runs thousands of specialized mining computers,
competing for the reward. Every 10 minutes or so, Jing's mining
competing for the block reward. Jing's mining
computers compete against thousands of similar systems in a global race
computers compete against thousands of similar systems in the global
to find a solution to a block of transactions. ((("Proof-of-Work
lottery to create the next block.
algorithm")))((("mining and consensus", "Proof-of-Work
algorithm")))Finding such a solution, the so-called _Proof-of-Work_
(PoW), requires quadrillions of hashing operations per second across the
entire Bitcoin network. The algorithm for Proof-of-Work involves
repeatedly hashing the header of the block and a random number with the
SHA256 cryptographic algorithm until a solution matching a predetermined
pattern emerges. The first miner to find such a solution wins the round
of competition and publishes that block into the blockchain.
Jing started mining in 2010 using a very fast desktop computer to find a
Jing started mining in 2010 using a very fast desktop computer to find a
suitable Proof-of-Work for new blocks. As more miners started joining
suitable Proof-of-Work for new blocks. As more miners started joining
@ -628,14 +632,14 @@ round.
((("candidate blocks")))((("blocks", "candidate blocks")))Alice's
((("candidate blocks")))((("blocks", "candidate blocks")))Alice's
transaction was picked up by the network and included in the pool of
transaction was picked up by the network and included in the pool of
unverified transactions. Once validated by the mining software it was
unverified transactions. Once validated by a full node, it was
included in a new block, called a _candidate block_, generated by Jing's
included in a block template generated by Jing's
mining pool. All the miners participating in that mining pool
mining pool. All the miners participating in that mining pool
immediately start compu ting Proof-of-Work for the candidate block.
immediately start try ing to generate a Proof-of-Work for the block template .
Approximately five minutes after the transaction was first transmitted
Approximately five minutes after the transaction was first transmitted
by Alice's wallet, one of Jing's ASIC miners found a solution for the
by Alice's wallet, one of Jing's ASIC miners found a solution for the
candidate block and announced it to the network. Once other miners
block and announced it to the network. After other miners
validated the winning block they started the race to generate the next
validated the winning block, they started a new lottery to generate the next
block.
block.
Jing's winning block became part of the blockchain as block #277316,
Jing's winning block became part of the blockchain as block #277316,