Reaching Consensus on the Network

Learn how the network decides which transactions to include in a new block.

We introduced the fundamental aspects of consensus and agreement throughout the whole this section, where we showed that a consensus mechanism allows a set of nodes to agree on a proposed state in order to reach a common, unambiguous view of the system, despite the presence of faulty or even maliciously acting participants. In a blockchain-based system, consensus mechanisms are part of two different processes:

  • Who is allowed to add a new block onto the blockchain?

  • If the system obtains several suggestions of authoritative chains, which one should be adopted by everyone?

We already said that the choice of the consensus mechanism depends on whether a blockchain is freely accessible or not (cf. this section). We’ll look at the conventional case where the blockchain system is a public system where every user can freely participate.

Creating new blocks for the authoritative chain

As discussed in this lesson, every node in the network holds its own replica of the blockchain and is able to collect unconfirmed transactions in its own memory pool. The problem is how the network can decide which transactions should be placed in a new block that’s going to be appended onto the blockchain next. One could identify the following two solutions:

  1. Let the majority of nodes decide on the order of transactions for the next block.

  2. Let any node collect unconfirmed transactions, on which every node creates a candidate block, which is then broadcasted to the rest of the network as a proposal for the next block in the authoritative chain.

The first approach would be catastrophic in the case of a permissionless system (cf. section) because of the Sybil attack, where a single entity could join the network with multiple nodes or identities in order to grab multiple votes, and thus manipulate the outcome of the election in favor of its own interests.

The second approach will also end up in very serious problems since the creation of candidate blocks only requires little computational power, which is why a very large number of blocks would be propagated simultaneously. Consequently, the creation of new blocks would occur much faster than if the system could agree on a common block. A possible solution would be to agree on the first block created, but this approach is insufficient because the system is asynchronous, which is why each block can arrive at different orders at different nodes in the networks, such that it’s impossible to decide which block was suggested first.

To avoid a Sybil attack and to prevent the nodes from broadcasting many different blocks, Nakamoto (2008)Satoshi Nakamoto. Bitcoin: A peer-to-peer electronic cash system. https://bitcoin. org/bitcoin.pdf, Dec 2008. Accessed: 2015-07-01. suggested making the process of adding a new block to the blockchain a computationally expensive task, which he called Proof-of-Work (PoW). The PoW consensus mechanism requires a node to prove that it has invested sufficient computing resources to solve the Proof-of-Work which is in fact a computation-intensive cryptographic hash puzzle. We’ll introduce the Proof-of-Work mechanism that’s used in blockchains in this lesson.

The Proof-of-Work mechanism is essential to secure the blockchain and thus to maintain the system. However, the mechanism is very costly because the nodes must expend resources, i.e., energy and time, to solve the cryptographic hash puzzle in order to expand the blockchain with new blocks, whereas the PoW is unique for every new block.

However, since no node would invest its resources for free, they need to be given financial incentives in order to encourage to contribute their computational power to solve the PoW. Thus, the nodes compete in a speed competition in order to solve the Proof-of-Work, and the node which first finds a valid solution (and hence a new valid block) will be rewarded with new coins. This is why the process of solving the Proof-of-Work is also known as mining, whereas the nodes which try to solve the PoW are called miners.

Mining

The resource-intensive process of adding new blocks to the blockchain is called mining.

Note: To get the reward is the incentive system, but it’s not the purpose of mining. Mining is the mechanism to secure the blockchain in a decentralized way.

So, the assistance of the miners is crucial to create new blocks and to secure the blockchain. Hence, the underlying rewarding system is a concept of the Nakamoto consensus, i.e., of the blockchain algorithm.

It should be noticed that the Proof-of-Work mechanism has to fulfill certain characteristics, as we’ll show in lesson. The main characteristic is that the PoW is computationally difficult to solve, but computationally efficient to verify. This means that once a miner solved the PoW and hence suggests a candidate block to the network, it can easily be verified by any other user if the block is valid.

Thus, the validation of any suggested block occurs independently by every node on the network, including the verification of the Proof-of-Work, such that the block is only accepted if the block contains a correct solution of the PoW. Otherwise, the validations fail, and the block is discarded immediately, and the competition to find a valid PoW for this block starts again. Since finding a valid PoW is rewarded with new coins, the nodes are interested in creating valid blocks as any attempt to cheat will lead to an invalid block which would immediately be detected and ignored by the network, and thus would lead to wasted computational power. This encourages the mining nodes to act honestly. Thus, independent validation of each new block by every node on the network ensures that the miners will not cheat (Daniel Drescher (2017)Daniel Drescher. Blockchain Basics: A Non-Technical Introduction in 25 Steps. Berkely, CA, 2017. Apress. and Fabin Schär et al. (2017)Fabin Schär and Aleksander Berentsen. Bitcoin, Blockchain und Kryptoassets: Eine umfassende Einführung. Norderstedt, Germany, 2017. Books on Demand.).

Once a valid block has been added to the authoritative chain, the other miners accept it due to the protocol, give up their effort, and start to work on the following block immediately. This acceptance of new blocks is caused by the incentive system, as any deviation of the protocol would lead to a smaller expectation to gain the rewards, as we’ll show in this lesson.

Get hands-on with 1400+ tech skills courses.