The overall meaning of the phrase consensus algorithm may be understood by understanding the meaning of both words in this phrase. The first word, consensus, means a general agreement between members of a group, whereas the second word, algorithm, denotes a sequence of steps that a computer follows in a program.
Taking the definition of these words together, we can rephrase consensus algorithm as, “a set of rules which are followed to coordinate and arrive at an agreement between members of a group.”
At its core, a consensus algorithm is used for multiple parties or computers to agree on a system’s state. This decision will be added onto the blockchain and can then be considered as an irrefutable Single Source of Truth. Consensus algorithms are based on Distributed Computing concepts, in which multiple machines aim to achieve a reliable network by deriving results following a decision-making process through consensus.
A very simplified analogy of a Consensus Algorithm is a simple majority voting process.
For example, you’d like someone to represent your community in a particular yearly event, and would like to hold a very distributed voting process. There are two candidates, Alice and Bob, as well as 500 people in your community. Each community member can be thought of as a machine on the system. Not all community members know each other, but they do know that they have to vote for 1 of 2 candidates, and a simple majority is required to declare the winner. In addition, in this set-up, voters are also the people who are counting the votes. Thus, the overall rules of this voting process will be as follows:
1. Two candidates are identified: Alice and Bob
2. 500 eligible voters are identified, and agree to participate in the vote and the rules associated with the process
3. Should a voter not agree with the rules, they may feel free to drop out of the process
4. Once a voter has sent in their vote, they will know how many people have voted for each party and the current state of the votes
5. If there is a simple majority (e.g. 251 out of 500 votes if there are no dropouts) for a specific candidate, a winner will be declared
At the end of this process, if at least half of the votes count towards a specific candidate, it is then known and agreed upon by all parties that this candidate is the winner. The decision on who is the winner may then be added to a list or record of winners. However, because we love blockchains, this can be done in a blockchain which shows both a timestamp and a result, as represented in Figure 2.
A direct comparison of this analogy is in cryptocurrencies, where the blockchain will show a timestamp and a list of transactions. Miners will select which transactions will be eligible to be in the next block in their blockchain, and this process is done in a distributed fashion.
The above shows a very simplified analogy of consensus algorithms, and do not take into account topics such as fault-tolerance and consistency. These are deeper topics which we may choose to explore in future articles.
There are many variants and applications of consensus algorithms. However, in the cryptocurrency space, the most popular ones are Proof-of-Work and Proof-of-Stake, which we will discuss in future articles in these series.