Consensus algorithm

It is evident that miners perform validation of the transaction and build their own block of transactions. Once they solve the puzzle and create a new valid block, they broadcast it to the blockchain network. This is where the consensus algorithm of the blockchain appears, which will ensure that the blockchain network reaches a consensus about the ordering of the transactions and about whose valid block needs to be added to the blockchain. Remember, the decision about whose block to be considered as the next block on the blockchain also determines the reward to the miner. This is taken care of by consensus algorithms such as PoW or PoS.

Ethereum uses PoW and will move to PoS soon. With PoS being the consensus algorithm for the blockchain network, any miner who solves the problem first and broadcasts the valid block will be considered the winner. With PoS, the creator of a new block is chosen in a deterministic way, depending on its wealth, which is also defined as its stake. Interestingly, there are no block rewards in PoS and so the miners will be offered transaction fees. This is the reason why miners are forgers in PoS and not miners. The following table lists the differences between PoW and PoS:

PoW

PoS

PoW is the original consensus algorithm in a blockchain network.

The next consensus algorithm for a blockchain, such as Ethereum.

Miners compete with each other to validate and propose a valid block to be added to the blockchain so that the miners get rewarded.

There are no miners and no mining rewards. Forgers (creators of new blocks) are chosen deterministically and are offered transaction fees.

The first miner of the valid block is rewarded.

The creator of a block is determined by their share, or stake, in a currency.

Solving difficulty by many miners is expensive and needs computation power and energy.

The PoS method is greener and cheaper.

The main benefits are the anti-DoS attack defenses and the low impact of stake on mining possibilities. Mining possibilities may result in cases, where the holders of a high stake, can turn out to be in charge of the blockchain network.

With PoS Casper, there will be a validator pool and network that will select the forger from this pool. Forgers need to submit a deposit to participate and be listed as a validator in the validator pool. If they violate or misbehave, they will be charged economically, their deposits will be taken away, and the forger will be delisted.

The main disadvantages are huge expenditures, uselessness of computations, and 51% attacks, where a 51% attack means a user or a group is in charge of the majority of the mining power of the network.

For a validator to perform a 51% attack, they need to own 51% of the overall supply of the value (currency). So, for someone to attack Ethereum, the dollar amount is in billions, and its occurrence is far from reality.

The following outlines some of the consensus methods in detail:

  • PoW: This is the pioneer consensus algorithm. It is used in Bitcoin and other cryptocurrencies. Consensus is an algorithm that processes blocks of transactions and adds them to blockchain when an agreement is reached between the nodes. Hence, for a network that follows PoW consensus, that network is following the PoW rules to establish various processing blocks of transactions and add them to blockchain. The process of generating PoW and to allow a node to add a block to the blockchain is known as mining, and nodes that participate in mining are called miners. Before a miner adds a block to blockchain, PoW requires miners to solve a complex business problem (also known as a puzzle). In exchange for solving the business problem (puzzle), miners are rewarded. In a currency-based blockchain like Bitcoin or Ethereum, they are awarded with cryptocurrency. Essentially, miners compete with other miners to find a correct hash for each hash function. As soon as a miner reaches the solution and finds the correct hash, it propagates it to all the other nodes in the P2P network. Other nodes verify the hash before adding the block (set of transactions) to the blockchain. To maintain block time, the difficulty level of the problem (puzzle) is dynamically changed by the network. In the event of multiple miners solving the problem at the same time, then the longest chain is considered the winner, as the longest chain is the most trustworthy chain.
    It solves the double spending problem, but is slow and costly from an energy and fee perspective, and not considered scalable.
  • PoS: This is an alternative to PoW, suggested in 2011, and was first implemented by Peercoin (2012). In PoS, the miner’s probability to mine depends on the stake (coins) the miners own in the system. For example, a miner with 15% of the stake (coins) has a 15% probability of mining the next block. It is expensive to attack a blockchain network based on PoS consensus, and it is energy efficient as well. Hence, in PoS, the probability of creating a block and being rewarded is determined by the stake in the network. Essentially, the probability of creating a block is directly proportional to the stake in the underlying cryptocurrency.
    But doesn't this mean the rich get richer? To prevent this, PoS follows randomization, that is, checking centralization, which may arise when a rich node gets richer and finally takes over the entire network. An attacker loses its stake for every attempt it makes to attach the blockchain network based on PoS. The problem with PoS is the nothing at stake problem, where a block generator can vote for multiple blockchain(s), also known as forks, and so, they can block the system from achieving consensus.
  • Proof of Elapsed Time (PoET): Introduced by Intel in 2016, the PoET consensus algorithm suits permissioned blockchain networks such as Hyperledger sawtooth. The PoET algorithm is based on wait time, where the participating nodes (known as validators) wait for a randomly selected period. Essentially, validators generate a random wait time and sleep for that time. The first one that wakes up (also known as the one with the shortest wake time) will get the chance to commit a new block to the blockchain and propagate that information to all the nodes in the P2P network. With this random wait time, each node has a fair and similar probability to add blocks to the network. The PoET algorithm needs to take care of two tasks—firstly, it needs to ensure that participating nodes have really selected a random sleep time (not the shortest sleep time), and secondly, that the node has reached the sleep time and not woke up in the middle of the sleep time. PoET is cost-effective and offers equal opportunity to all participants. However, it is not suited for permissionless public blockchain networks.
    PoET results in a leader selection, where leadership is randomly distributed to the validators in the entire network. As the cost of the participation of the validators is low, it enlarges the population of validators, and therefore, enhances the robustness of the consensus algorithm.
  • Byzantine Fault Tolerance (BFT): This is not from the family of Proof algorithms. Its name is derived from the classic Byzantine general’s problem. An army, along with their Byzantine generals, surrounded a fort city. Generals are scattered around the fort city and, for an attack to succeed, they need to attack in unison. If all the generals do not attack in unison, they will lose the war. Now, they need to communicate with each other to reach a consensus so that they attack at the same time.
    In technical terms, it needs a system with several peer nodes to reach a consensus, even if there are few attackers and malicious nodes trying to influence the nodes. The Practical Byzantine Fault Tolerance algorithm can help solve the BFT.
  • Practical Byzantine Fault Tolerance (PBFT): Hyperledger Fabric uses this consensus mechanism. PBFT offers a Byzantine state machine replication that is designed to tolerate malicious nodes (Byzantine faults). All the nodes are sequentially ordered, where one node is declared as the leader node (primary node) and other nodes are known as follower nodes (secondary/backup nodes). Any node will become a leader by transitioning from follower node to leader node, mostly via a round-robin algorithm. All nodes communicate and need to perform two tasks—firstly, they need to verify that the message came from a specific peer node, and secondly, they need to verify and ensure that the message was not modified during its communication. All nodes will reach a consensus, irrespective of the state of the network, using majority rule. The entire network is based on the assumption that no more than one-third of the network nodes are malicious. The more nodes, the more secure the network will be. It has the following phases:
  1. A client sends a request to a leader node
  2. Leader node propagates this message to all the follower (secondary) nodes
  3. All the nodes (leader and follower) will perform a task, as requested by the client, and send a response back to the client
  4. The client will verify the responses and ensure that the request (attack or retreat) is served successfully when it receives n + 1 replies with the same result, where n is the max number of malicious nodes

This is also based on the fact that the nodes are deterministic. The final result is attained when all honest nodes reach an agreement on the order and collectively accept or reject the order.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset