The three most common Consensus for public blockchains.
Developing consensus in a blockchain involves complex mathematics and coding. Consensus is when all participants in a network agree to the validity of transactions. This ensures all ledgers in the blockchain contain exact copies of each other. Since the dawning of Bitcoin, introduced by Satoshi Nakamoto in 2008, new algorithms have developed to make achieving consensus best suited for each respective blockchain. Let’s take an in-depth look at some of the most common algorithms.
Proof of Work (PoW)
The grandfather of consensus algorithms, as used in Bitcoin and many similar public blockchains, is actually better described as a competition. Nodes compete in solving a cryptographic puzzle. The first node to provide a correct answer gets to append his version of the transaction order to the existing history.
Let’s use the Bitcoin algorithm as an example. Nodes create a block and fill it up with transactions. They then repeatedly calculate an SHA-256 HASH of the block until the resulting value starts with a certain number of leading 0s. Each time they modify a single field in the block header, in order for the result of the calculation to change. The number of leading 0s required defines the difficulty. The algorithm calibrates the difficulty to create a block every 10 minutes on average. Once a solution is found, the winning node broadcasts it over the network. Occasional concurrent solutions are solved by allowing short forks in the chain. The fork with the most computing power supporting it eventually dominates. Thus, to cheat in Bitcoin consensus, an attacker would need more than 50 % of the computational power of the network.
PoW works surprisingly well but has a number of disadvantages. It is easy to see how the algorithm causes a lot of machines to work in parallel on an essentially useless puzzle, just to throw away the result. The process wastes massive amounts of energy.
Proof of Stake (PoS)
PoW uses computational power to weight probabilities to choose a winner in a computation. PoS replace computational power with wealth. Network participants can stake their coins to participate in the consensus competition.
In a simple version of PoS, the block producer is chosen randomly, weighing the probability with the wealth staked. The more money a node stakes, the higher the probability to be chosen as a block producer. Essentially, staking is the equivalent of buying various tickets for a raffle. The more tickets you buy, the more likely you are to win.
There are a couple of problems that were present in early PoS implementations, namely the nothing at stake problem and long range attacks. We won’t go into detail here (you can check the detailed description in the links), but these issued can be solved by making dishonest nodes pay penalties from their staked coins and by introducing unlock periods, during which the coins are frozen after unstaking.
Delegated Proof of Stake (DPoS)
DPoS is an optimization of PoS. In this group of protocols, the stake of the nodes is used to vote for a fixed number of delegates. The number of votes a node can emit is proportional to the number of coins staked. It is the role of the delegates to produce new blocks. They can do this according to a round robin order or using a more complex voting algorithm. The advantage of DPoS is improved performance. This advantage comes at the cost of increased centralization.
There are many versions of these protocols, many of which worthy of a whole article for themselves. This overview is meant to give a general idea of how consensus works in public blockchains.
This topic was modified 5 months ago by alberdioni8406