Consensus Mechanisms: Solving the Byzantine Generals' Problem
A critical element of a blockchain system is its consensus mechanism. This is the way in which agreement, trust, and security are achieved across a decentralised computer network. There are various methods of consensus mechanisms that are used with the aim to solve the Byzantine Generals’ Problem.
What is the Byzantine Generals’ Problem?
This is a game theory problem that describes the difficulty that dispersed parties have in arriving at a consensus without relying on a trusted central party. How can members of a network collectively agree on a certain truth when no one can verify the identities of other members?
In the Byzantine Generals’ Problem, there are multiple different Byzantine generals gathered around a besieged city with their own armies. However, they have to collectively decide when to attack. If all the generals attack at the same time, they win, but if they attack at different times they will lose.
Due to the communication channels not being secure, there runs a risk of a point of failure. This is known as a Byzantine fault, where components may fail and there is imperfect information on whether a component has failed.
If we think about this in a contextual manner, to solve this problem, society has relied on trusted third parties (or what is deemed to be trusted) as a central point of truth. One example is, if I recorded that I had sent you R100 and you had recorded that you had only received R80, we would rely on the bank as the trusted source of information to come to a consensus.
In a blockchain system that operates in a decentralised and self-regulating manner which is on a global scale and functions without any single authority, reaching consensus between the participants is imperative.
What is a consensus mechanism and how does it aim to solve the problem?
In the blockchain world, a consensus mechanism is a fault-tolerant mechanism that is used to achieve the necessary agreement on a single data value or a single state of the network among distributed processes. It is the process used by a group of peers to agree on the validity of the transactions submitted to the network to arrive at the single truth of the network.
It is the standardised way of how the blockchain nodes reliably reach an agreement on which blocks are to be added to the chain and which nodes are valid.
In laments terms, it is a set of rules that decides on the legitimacy of contributions made by the various participants on the blockchain. You can play the game as long as you are willing to follow the rules. In this game, the points that you score only count if you follow the game's rules. If you decide not to follow the rules, the other players wouldn't want to play with you anymore, and you would need to find new players who are willing to play by your new rules.
A blockchain aims to solve this problem by creating a layer that can be trusted without needing to trust every individual.
领英推荐
Miners and validators are the players of the game. The game they are playing is adding new entries to the ledger, and to do so, they need to follow the rules of the game. When they manage to add new entries and follow the rules of the game, they are rewarded with points. Nodes are like referees; they check the new entries to the ledger and decide whether players (miners or validators) followed the rules of the game. If they are happy that the rules have been followed, they add these new entries to the ledger (the blockchain) by filling in another page of their book. They then wait patiently to receive the next page worth of information
What consensus mechanisms are used?
Currently, there are two main consensus mechanisms that are used in the blockchain industry. There is Proof-of-Work (“PoW”) and Proof-of-Stake (“PoS”), these are not the only two but are the most prevalent in the space.
Proof-of-Work:
PoW is a decentralised consensus mechanism that requires members of a network to expend effort, in the form of computing power, to solve a mathematical puzzle to prevent anyone from gaming the system. This effort is used for mining and validating the network in order to allow for peer-to-peer transactions to be processed in a secure manner without the need for a trusted third party.
In practice, the Bitcoin network uses a hash function to detect tampering, which are long strings of numbers assigned to a set of data. A given set of data that is put through a hash function, will only ever generate one hash, and essentially assigned its fingerprint. Any data that is changed in that data set would result in a completely different hash (which in turn would be rejected by the network). On the Bitcoin network, miners expend work by generating a valid hash for the respective data, and the difficulty is set by the network. Once a miner has solved the hash, it is broadcast to the network, and the block is added to the blockchain.
Proof of work makes it extremely difficult to alter any aspect of the blockchain since such an alteration would require re-mining all existing blocks in the blockchain. It also makes it difficult for a user or pool of users to monopolise the network's computing power since the machinery and power required to complete the hash functions are expensive. The rewards are programmed in such a way that the reward for the mining efforts expended only makes economic sense up until a certain point, this is how the power remains decentralised.
Proof-of-Stake:
PoS reduces the amount of computational work needed to verify blocks and transactions that keep the?blockchain secure. PoS changes the way blocks are verified using the machines of coin owners. The owners offer their coins as collateral for the chance to validate blocks. Coin owners with staked coins become "validators".
Validators are then selected randomly to mine, or validate the block. This system randomises who gets to mine rather than using a competition-based mechanism like proof-of-work. To become a validator, a coin owner must stake a specific number of coins. For example,?Ethereum?will require 32 ETH to be staked before a user can become a validator.?Blocks are validated by more than one validator, and when a specific number of the validators verify that the block is accurate, it is finalised and closed (subsequently added to the blockchain). A validator will verify the transactions and share them with the network and subsequently an attestation process is followed, where a certain number of validators need to agree that the transactions are valid before a block is closed.??
In exchange for staking, they get a chance to validate new transactions and earn a reward. But if they improperly validate bad or fraudulent data, they may lose some or all of their stake as a penalty.
Thus through rules and computing techniques, there is an ability to arrive at a single truth without the need for a third party by aligning the incentives of the participants.
Feel free to reach out to me if you have any queries in the space, keep following on our journey of closing the knowledge gap.