Introducing blockchain consensus

Compared to a standard voting process, where all individuals decide independently what they want to achieve, consensus in blockchain goes a step further and aims toward making decisions that help in reaching the ultimate goal in the most efficient manner. For instance, the decisions that managers of a bridge construction project make are based on consensus to agree on the best solution to build the bridge in the most efficient time and cost manner. When it comes to blockchain, consensus is the combined group of actions that miners take to generate the best blocks possible in the most efficient manner, so that block times are reduced while miners are awarded a profitable amount of Ether.

PoW is the scheme used to process transactions and generate blocks that include those valid transactions in exchange for a difficult task, so that only the most capable computers get rewarded with the block generation. What the miners are doing when generating transactions is simply generating random hashes until they find the one that is required for the next block. Each computer is doing this independently. When a miner finds the right hash, they distribute the ingredients that generated that hash to all of their connected nodes so that they can do the same and eventually add this new block to the network while getting a reward for his efforts.

 

Why do all of the miners agree on the fact that the finder is the one that should get a reward for discovering the right hash for the next block? Because, when they mine, they are agreeing on a set of rules.

These rules are as follows:

  • The user that finds the block gets a reward.
  • As a miner, you must distribute this new block to all of your connected peers to synchronize the entire network with new transactions contained in that block.
  • You must only add valid transactions to the block.

At this point, you may be asking yourself what happens when an invalid transaction is added into a block? The answer is that whenever a miner adds invalid transactions to the block, solves the proof-of-work challenge, and tries to distribute it to others in order to update the main chain, the other miners will notice those invalid transactions and will stop distributing that block so it won't get any further, since each one of them is a validator for what goes inside each block.

The miner that solved the PoW challenge for the block that contains those invalid transactions has wasted his computing power, since it won't propagate further. That's the punishment for acting maliciously, it's a waste of energy and time.

This is a very powerful and simple checking mechanism that protects the blockchain from malicious intentions so that it only approves valid transactions that have been successfully verified.