paint-brush
Blockchain Algorithms 101: A Introduction to Consensus Protocolsby@professor_91038
3,192 reads
3,192 reads

Blockchain Algorithms 101: A Introduction to Consensus Protocols

by Professor BlockchainJuly 3rd, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Niccolo Machiavelli once said, “Of mankind we may say in general they are fickle, hypocritical, and greedy of gain”. This quote, speaking on the trustlessness necessary for navigating a world filled with untrustworthy people, can be held as truth equally in both his own time and ours.

Company Mentioned

Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - Blockchain Algorithms 101: A Introduction to Consensus Protocols
Professor Blockchain HackerNoon profile picture

Blockchain 101: A Introduction to Consensus Protocols

Niccolo Machiavelli once said, “Of mankind we may say in general they are fickle, hypocritical, and greedy of gain”. This quote, speaking on the trustlessness necessary for navigating a world filled with untrustworthy people, can be held as truth equally in both his own time and ours.

In a world of “fake , it is important to understand the fickle nature of trust, and to find some measure of consensus amongst ourselves in regards to that which we hold as ‘truth’. Although this challenge, which has faced humankind for centuries, may not be completely solvable in our time, we have come astonishingly closer than our ancestors through the innovations brought about by Blockchain technology. In the world of Blockchain there are 5 ‘main’ (largely known and utilized) consensus protocols;

1. Proof of Work (PoW)

2. Proof of Stake (PoS)

3. Proof of Important (PoI)

4. Proof of Elapsed Time (PoET)

5. Delegated Proof of State (DPoS)

Although there are many more proposed and theoretical consensus algorithms that have propped up since the original conception of the Blockchain, they are mostly out of the scope of this article.

The most widely utilized and well-known consensus algorithm throughout the Blockchain ecosystem is the Proof of Work algorithm.

This algorithm, which is utilized by nearly all major coins such as Bitcoin and Ethereum (to a certain degree), works by confirming chain transactions and the creation of new blocks through special nodes called miners. Imagine, for a moment, a that the number 64 is written on a board in a classroom.

Seated in the classroom are many students each with 10 individual dice in their hands, rolling for a perfect 64. While each individual roll takes little effort it would take many consecutive rolls for any one individual to finally roll a perfect ‘64’, regardless of how many combinations of sides may add up to 64.

Now imagine that each person rolling is competing to find new combinations of numbers that add up to 64 for a certain prize, and that every time a competitor rolls a certain combination that does indeed add up to 64, no other competitor may submit that combination for a prize ever again, forcing each competitor to make more and more attempts before finally receiving a prize-winning roll.

This form of first-past-the-post work-for-prize is basically how PoW works, except instead of trying to roll dice for a unique combination adding up to 64, they are using computers to perform complex mathematical functions called Hash functions in hopes of finding new, very specifically formatted, hashes.

To make the concept of Proof of Work consensus contains the three main components are the transaction, the blocks, and the miners — with the miners connecting to additional constituents. Although the Proof of Work algorithm seems (and generally is) very straight forward and useful, there are a number of factors — such as its overall cost, power consumption, and security (in regards to some attacks such as the 51% attack) — that downplay its overall functionality.

Take the example of Bitcoin mining; Bitcoin, the first cryptocurrency to be invented, utilizes the PoW consensus algorithm to facilitate its continuous stream of transactions and the creation of new blocks every 10 minutes. Each block, created by the first miner to successfully solve the mathematical function explained above, takes numerous, extremely powerful and highly specialized, computers to create.

Upon solving, the successful miner (or group of miners) are rewarded with a total of 12.5 bitcoins (valued at $69,962.50 as of 11/18/2018). Obviously, this high-dollar reward attracts a multitude of highly competitive miners working (and consuming large amounts of power) 24 hours a day, every single day. As such, the amount of power consumed by the Bitcoin network is equivalent to that of the entire country of Singapore.

In addition to the massive amount of power that the Proof of Work consensus algorithm requires, it has become clear over time that large consortiums, which have been created through the conglomeration of multiple high-growth and high-power miners, have moved to specialized locations — such as deserts in order to harness solar energy, or Tundra in order to naturally cool their machines.

As a result of their growth and creative energy-sourcing solutions, these groups have quickly pushed the ‘hobbyist-miner’ into near-extinction, effectively centralizing the mining ability of an intentionally decentralized protocol. This form of ‘attack’ on the network, which is known as the 51% attack, is becoming a massive problem as computing power increases and becomes cheaper.

While Proof of Work remains an integral part of the Bitcoin ecosystem, many other cryptocurrencies — such as Ethereum — are trying to move away from this consensus protocol and toward the Proof of Stake protocol. In Proof of Stake based cryptocurrencies, the creator of each consecutive block is chosen in one of two ways:

a. Through a randomized block selection

b. Through a coin-based selection

Randomized block selection utilizes a formula that combines the lowest hash value on the chain (much like the resultant hashes of the Proof of Work algorithm’s mathematical functions) with the stake (amount invested into a black) of a block.

Since stakes are public, each node can predict which account will win the right to forge a new block. This type of selection, which allows for multiple participants to build blocks, does not exclude any individual from participating in the transactions regardless of the amount of funds they have invested into any one, or multiple, blocks.

In this way, Randomized block selection as implemented by the Proof of Stake algorithm makes each participant/competitor more equal.

As no complex computational work is needed in the Proof of Stake algorithm, there are no miners involved in Proof of Stake transactions. Instead, specialized nodes called validators are used to validate transactions and put them up onto the chain through a specialized process. Validators, who are chosen based on their total wealth in the respective asset for which they are validating, receive transaction fees as payment for validating transactions and, in general, whoever holds the most in that asset validate the greatest amount of transactions and, in turn, earn the greatest amount of transaction fees.

The third protocol we will cover in this article is the Proof of Importance (PoI) consensus algorithm, which can be described as an economic building protocol that is based upon large account balanced and trustworthiness. This protocol, which was originally designed and developed by NEM a Blockchain-based organization that issues and utilized the XEM cryptocurrency token, awards a score based on the trustworthiness of each validator/participant in the network.

In order to receive a higher, and constantly-updated, score each participant must not only have a large account balance, but also keep all assets received through transaction in the form of the cryptocurrency they are facilitating as well as maintain at least 10% of their overall balance invested in said cryptocurrency.

These stipulations, which force a user to allow his/her trustworthiness to be evaluated, attempts to maintain a long-haul view on the cryptocurrency’s overall value amongst its participants.

Much like in stock-market investing, in which the more stock one holds in a company, the more weight and power that individual has throughout the organization, the more an individual is invested into a Proof of Importance based cryptocurrency, the higher their overall trustworthiness score becomes.

Furthermore, although large stakeholders have large amounts of influence, even those with one share of a company can profit from the overall growth of the organization, or, in this case, the network.

On the one hand, the Proof of Importance algorithm is beneficial as it encourages more individuals to get involved and opens up the possibility of overall wealth distribution — as any contributor can earn more XEM.

On the other hand, however, it will always be the larger participants who have the greater ability to receive higher trustworthiness scores, and in turn, more profits. This rewarding, which is done through a process known as harvesting, happens through the distributed calculation of new blocks by each vested node on the network.

To participate in this calculation (and to become a ‘vested’ node), one must have a vested — or active — balance of at least 10,000 of the respective cryptocurrency.

In continuation with our descriptions of the consensus algorithms listed at the beginning of this article, we’ll now move on to the Proof of Elapsed Time protocol (PoET). Proof of Elapsed Time, which was designed as a ‘fair’ consensus model’, focuses on efficiency and revolves around the concept of distributed leader elections across the largest possible amount of network participants.

Moreover, the cost of controlling the process (or leading the chain), is always proportional to the value gained from it. As such, to control (or lead) the chain, one must invest large sums of time and money. Finally, all participants on the chain need to verify the leader was selected in a legitimate manner.

PoET is designed to achieve these goals through the use of new, secure, CPU instructions which are quickly becoming widely available in consumer processors.

Through utilizing these new features, PoET based coins ensure the safety and randomness of the leader election process without requiring the amount of electricity or computational power that a process such as Proof of Work requires.

Furthermore, in a PoET based cryptocurrency every validator requests a wait time from an enclave and the validator with the shortest wait time for a transaction block is elected to be the leader. This method arbitrarily distributes leadership election across the entire pool of validator with a distribution similar to that of other lottery algorithms.

As such, the probability of election is proportional to the resources contributed. However, the low cost of participation increases the likelihood that the pool of validators will be greater than that of the PoW or PoS consensus protocols. Thus, making PoET based cryptocurrencies more open and available to the general public.

Although the Proof of Elapsed Time consensus algorithm is not as widely implemented or known about as such algorithms as PoW or PoS, it may hold enormous potential due to the wider ability for more people to act as validators.

Finally, it is also important to point out that the PoET algorithm runs on CPUs rather than GPUs or ASICs, which allows for returning the “good old days” of computing, in which many could participate, rather than just those with powerful, expensive, hardware.

The fifth, and final, consensus protocol that this article will cover is the Delegated Proof of Stake (DPoS) algorithm. This protocol, which is heralded as the most democratic and ‘fair’ amongst all those previously mentioned, can be summarized as an environment in which employees (nodes) can fire their boss (leader), rather than the other way around.

Through the Delegated Proof of Stake algorithm, the power of stakeholder approval is used to resolve consensus issues. Furthermore, stakeholders (elected delegates) also decide block intervals, fees, and transaction size limits.

In the DPoS system, the stakeholders can elect any number of ‘witnesses’ to generate blocks.

Each account is allowed one vote per share per witness — a process known as approval voting. When stakeholders express their desired number of witnesses, they must also vote for at least that many witnesses from the general pool. Each time a witness produces a block, they are paid a fee that is also democratically voted upon. The group of witnesses are updated through vote tallying once daily, allowing new witnesses to earn rewards as equally as senior ones.

Although DPoS has not been widely adopted yet, it is quickly gaining momentum as more projects begin to realize its overall potential.

As the Blockchain ecosystem continues to develop over time and grows in relevance throughout both the private and public sectors of our economies and word as a whole, new protocols will continue to be released and overtake those that we utilize today.

While currently Proof of Work and Proof of Stake dominate the minds and implementations of those within the world of Blockchain, the tides of change come fast and strong, and many algorithms — possibly (and likely) some of those mentioned throughout this article — may quickly overtake them.

While these are surely not the end-all-be-all of consensus algorithms, they are a solid base for many new projects and new consensus protocols to come.

<a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a>