Bitcoin mining

To implement a distributed timestamp server on a peer-to-peer basis, bitcoin uses a proof-of-work system similar to Adam Back’s Hashcash, rather than newspaper or Usenet posts. This is often called bitcoin mining.

The mining process or proof-of-work process involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits. The average work required is exponential in the number of zero bits required and can be verified by executing a single hash.

For the bitcoin timestamp network, it implements the mining process or “proof-of-work” by incrementing a nonce in the record or “block” until a value is found that gives the block’s hash the required zero bits. Once the hashing effort has been expended to make it satisfy the proof-of-work, the block cannot be changed without redoing the work. As later records or “blocks” are chained after it, the work to change the block would include redoing all the blocks after it.
The main chain (black) consists of the longest series of transaction records from the genesis block (green) to the current block or record. Orphaned records (purple) exist outside of the main chain.

The mining process solves the problem of determining representation in majority decision making. If the majority were based on one-IP-address-one-vote, it could be subverted by anyone able to allocate many IPs. Mining is essentially one-CPU-one-vote.

The majority decision is represented by the longest chain, which has the greatest proof-of-work effort invested in it. If a majority of computing power is controlled by honest nodes, the honest chain will grow the fastest and outpace any competing chains. To modify a past block, an attacker would have to redo the proof-of-work of the block and all blocks after it and then catch up with and surpass the work of the honest nodes. The probability of a slower attacker catching up diminishes exponentially as subsequent blocks are added.

To compensate for increasing hardware speed and varying interest in running nodes over time, the proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour. If they’re generated too fast, the difficulty increases.

The steps to run the network and generate or “mine” bitcoins are as follows:

New transactions are broadcast to all nodes.
Each node collects new transactions into a block.
Each node works on finding a difficult proof-of-work for its block.
When a node finds a proof-of-work, it broadcasts the block to all nodes.
Bitcoins are successfully collected or “mined” by the receiving node which found the proof-of-work.
Nodes accept the block only if all transactions in it are valid and not already spent.
Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.

Nodes always consider the longest chain to be the correct one and will keep working on extending it. If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in case it becomes longer. The tie will be broken when the next proof-of-work is found and one branch becomes longer; the nodes that were working on the other branch will then switch to the longer one.

New transaction broadcasts do not necessarily need to reach all nodes. As long as they reach many nodes, they will get into a block before long. Block broadcasts are also tolerant of dropped messages. If a node does not receive a block, it will request it when it receives the next block and realizes it missed one.

Leave a Reply

You must be logged in to post a comment.