Select Page

Understanding Blockchain Technology Part 3/4 – Mining and Proof-of-Work

written by FuturisticLawyer
September 6, 2020

The next and crucial step to develop our understanding of blockchain technology is the concept of mining. Mining is how new bitcoins are generated, and while the use of hash functions makes any changes to the blockchain visible in the network, the mining process is what makes data on the blockchain infeasible to tamper with. In the Bitcoin blockchain, mining is based on a proof-of-work system, which means that the miners are required to solve a difficult mathematical puzzle before a new block can be added to the blockchain. The blockchain is programmed to generate a new block every 10 minutes on average, and the difficulty level of the puzzles are mathematically adjusted every 2.016 blocks (two weeks) to hit the 10-minutes target.[1] If the mining process is too fast, say a new block is mined every 8 minutes on average, then the difficulty level will increase accordingly, and if the average mining time is above 10 minutes per block, the difficulty level will be reduced.

To solve the proof of  work-puzzle of a block, the miners are essentially competing in a guessing game. The miners are trying to calculate a nonce – an arbitrary number – that, when combined with the remaining data in the block header, generates a block hash initiated with a certain number of zeros. The difficulty of the puzzle is determined by the number of leading zeros. For example, a relatively easy proof-of-work puzzle may require three or four zeros at the start of the hash. If we imagine that the block header consisted of the phrase “Hello, world!” we would guess on random numbers until SHA-256 had generated a hash number with our targeted value.[2]

In reality, the proof-of-work puzzles are much harder. To take a random example, the hash of block 646057 (timestamp: 2020-08-31 03:02) starts with 19 consecutive zeros.[3] The difficulty level is 17,557,993,035,167.31 which means it would take on average more than 17 trillion random guesses before the block’s hash value is found. Whoever is first to solve the puzzle, validates the block and receives a reward of currently 6.25 BTC (2020), and additionally picks up transaction fees of the block. Every fourth year the reward of mining bitcoins is halved (2024: 3.125 BTC, 2028: 1,56 BTC, 2032: 0,78 BTC) until 2140 when all bitcoins are distributed.[4]

51 % Attacks, Malicious Nodes, and More on the Mining Process 

The idea behind the proof-of-work system is to motivate nodes to stay honest by making it computationally costly to validate transactions, while also rewarding the network users for their efforts.[5] The blockchain’s hash functions make it impossible to go back and successfully change or falsify any data on the blockchain without rewriting its entire history. Imagining that anyone would put in the effort to rewrite all Merkle Trees and block headers on all blocks of the chain, the proof of work puzzles would make the process prohibitively expensive, and ultimately fruitless with no rewards for “reverse-mining”.

Another issue is the so-called 51 % attack, which Satoshi Nakamoto discussed in Bitcoins white paper. The danger is that if malicious nodes gained control over 51 % of the network, they could validate false transactions. To fully understand the issue, a more detailed description of the mining process is necessary. We will summarize what we have already learned in the previous posts and patch up some holes in our knowledge as well.

Let’s say that I wanted to send one bitcoin to a friend. The message would be broadcasted on the network in a so-called memory pool, also known as mempool, consisting of pending transactions that are recognized by all nodes but have not yet been validated.[6] Miners validate the pending transaction, by checking that I own the one bitcoin I want to send to my friend. This can easily be done because the transaction history of each bitcoin is recorded on the global ledger, and the Bitcoins protocol rules would not accept the transfer of a fabricated coin. The miner’s job is then to group transactions from the memory pool together into a “candidate block” and try to add this candidate block to the blockchain.[7]

As we have already learned, once the nodes have verified the transactions of the blocks they are hashed over and over again in a Merkle tree until the Merkle root of a block is found. The miners are then competing to find a nonce that will get the block hash below a certain target value. As soon as a miner has found a nonce which generates the targeted block hash value, the new block is broadcasted out unto to the network, where the other nodes have to verify the block header before it can be accepted as a new block.

In the validation process, the role of the nodes is to act as referees instead of competitors. For the same reason, tampering with data on a block in the blockchain is next to impossible. The other nodes will check with great scrutiny if the hash values of the block add up, as the competition to mine the block and reap the enclosed rewards continues if a new block header is found to be invalid.[8] The validation process is reminiscent of a voting process, where the majority of nodes decide if a new block is valid and should be added to the chain. The greatest danger to the security of the blockchain network is an attack, where malicious nodes control at least 51 % of the collective computer power of the network and can manipulate the validation process.

However, such an attack will, even if accomplished, not throw the system open to arbitrary changes, such as creating value out of thin air or taking money that never belonged to the attacker, as the honest nodes would never accept an invalid transaction as payment, or accept a block that contains invalid transactions.[9] As Satoshi Nakamoto pointed out in the Bitcoin white paper, an attacker can only accomplish to change one of his transactions to take back money he recently spent.[10]

Longest Chain-Criterion

Occasionally a fork can appear in the blockchain. This can happen when two nodes finish the proof of work for their blocks nearly at the same time. The two nodes then transmit the proof-of-work solutions out unto the network so the blocks can be validated by the other nodes. Some nodes may receive and validate block A first, while others receive and validate block B first which causes different versions of the blockchain among the nodes.[11] As a result, the order of the transaction history and the rightful ownership of bitcoins may be unclear.[12] Luckily, the Bitcoin protocol rules offer a simple solution to the conflicting versions of the transaction history: the longer chain eventually prevails, while the shorter ones are abandoned.

 

In the diagram, chain B is the longest and thus carried by the greatest level of proof-of-work. The majority of nodes, and eventually all nodes, will accept chain B as the correct version of the ledger. They will continue to work on chain B, while chain A and chain C will be abandoned and removed from the blockchain as if they never had existed. The blocks in chain A and B are orphan blocks.[13] The rewards that miners received for validating the blocks are reclaimed, and the transaction data will be put in the nodes inboxes again to be re-processed and added to the blockchain data structure later on.[14]

As it appears, transaction data that previously was a part of the authoritative chain can be abandoned, and the final validation of transactions can be delayed. For this reason, a transaction is generally not considered to be valid and permanent, before six subsequent confirmations have occurred. The initial transaction block represents the first confirmation, and it is advised to wait until five additional blocks are added (1 hour for six confirmations) before it can be ensured that the blockchain has an agreed-upon time ordering of the blocks.[15]

**************************

[1] http://billybitco.in/ (31-08-2020).

[2] http://www.michaelnielsen.org/ddi/how-the-bitcoin-protocol-actually-works/ (31-08-2020).

[3]https://www.blockchain.com/btc/block/0000000000000000000d210fd3d6ca21fa1c60027e240f6090ea00129e804384 (31-08-2020).

[4] http://billybitco.in/ (31-08-2020).

[5] http://www.michaelnielsen.org/ddi/how-the-bitcoin-protocol-actually-works/ (31-08-2020).

[6] http://billybitco.in/ (31-08-2020).

[7] https://learnmeabitcoin.com/beginners/blocks (31-08-2020).

[8] Drescher (2017), pg. 125.

[9] Nakamoto (2008), pg. 6.

[10] Ibid.

[11] http://www.michaelnielsen.org/ddi/how-the-bitcoin-protocol-actually-works/ (opened 31-08-2020).

[12] Ibid.

[13] Drescher (2017), pg. 135.

[14] Ibid, pg. 136.

[15] http://bitcoins.net/guides/bitcoin-confirmations (opened 31-08-2020).

Related Posts

Comments

0 Comments

Submit a Comment

Your email address will not be published.