In a centralized setup, a single entity has power over the system. In most cases, they can make changes as they please – there isn’t some complex governance system for reaching consensus amongst many administrators.
But in a decentralized setup, it’s a whole other story. Say we’re working with a distributed database – how do we reach an agreement on what entries get added?
Overcoming this challenge in an environment where strangers don’t trust each other was perhaps the most crucial development paving the way for blockchains. In this article, we’ll take a look at how consensus algorithms are vital to the functioning of cryptocurrencies and distributed ledgers.
Satoshi Nakamoto, the creator of Bitcoin, proposed a Proof of Work system to coordinate participants. We’ll get into how PoW works shortly – for now, we’ll identify some of the common traits of the many consensus algorithms in existence.
Firstly, we require that users that want to add blocks (we’ll call them validators) provide a stake. The stake is some kind of value that a validator must put forward, which discourages them from acting dishonestly. If they cheat, they’ll lose their stake. Examples include computing power, cryptocurrency, or even reputation.
Why would they bother risking their own resources? Well, there’s also a reward available. This usually consists of the protocol’s native cryptocurrency and is made up of fees paid by other users, freshly-generated cryptocurrency units, or both.
The last thing we need is transparency. We need to be able to detect when someone is cheating. Ideally, it should be costly for them to produce blocks, but cheap for anyone to validate them. This ensures that validators are kept in check by regular users.
Proof of Work (PoW)
Looking at the output, you can’t possibly tell what information was fed into the function. They’re therefore useful for proving that you knew a piece of data before a certain time. You can give someone its hash, and when you later reveal the data, that person can run it through the function to make sure the output is the same.
In Proof of Work, the protocol sets out conditions for what makes a block valid. It might say, for instance, only a block whose hash begins with 00 will be valid. The only way for the miner to create one that matches that combination is to brute-force inputs. They can tweak a parameter in their data to produce a different outcome for every guess until they get the right hash.
With major blockchains, the bar is set incredibly high. To compete with other miners, you would need a warehouse full of special hashing hardware (ASICs) to be in with a chance of producing a valid block.
It’s trivial for the network to verify that you have indeed created the right block. Even if you’ve tried trillions of combinations to get the right hash, they just need to run your data through a function once. If your data produces a valid hash, it will be accepted, and you’ll get a reward. Otherwise, the network will reject it, and you’ll have wasted time and electricity for nothing.
Proof of Stake (PoS)
From there, you lock up your funds in a wallet (they can’t be moved while you’re staking). You’ll typically agree with other validators on what transactions will go into the next block. In a sense, you’re betting on the block that will be selected, and the protocol will choose one.
If your block is selected, you’ll receive a proportion of the transaction fees, depending on your stake. The more funds you have locked up, the more you stand to gain. But if you attempt to cheat by proposing invalid transactions, you’ll lose a portion (or all) of your stake. Therefore, we have a similar mechanism to PoW – acting honestly is more profitable than acting dishonestly.
Generally, there aren’t freshly-created coins as part of the reward for validators. The blockchain’s native currency must thus be issued in some other way. This can be done either via an initial distribution (i.e., an ICO or IEO) or by having the protocol launch with PoW before later transitioning to PoS.
To date, pure Proof of Stake has only really been deployed in smaller cryptocurrencies. Therefore, it’s unclear if it can serve as a viable alternative to PoW. While it appears theoretically sound, it will be very different in practice.
Once PoS is rolled out on a network with a large amount of value, the system becomes a playing field of game theory and financial incentives. Anyone with the know-how to “hack” a PoS system would likely only do so if they could gain from it – therefore, the only way to find out if it’s feasible is on a live network.
Proof of Work and Proof of Stake are the most-discussed consensus algorithms. But there’s a wide variety of other ones, all with their own advantages and disadvantages. Check out the following articles:
Mechanisms for achieving consensus are vital to the functioning of distributed systems. Many believe that the greatest innovation in Bitcoin was the use of Proof of Work to enable users to agree on a shared set of facts.
Consensus algorithms today underpin not only digital money systems, but blockchains allowing developers to run code across a distributed network. They’re now a cornerstone of blockchain technology and are critical to the long-term viability of the various networks in existence.
Of all of the consensus algorithms, Proof of Work remains the dominant offering. An alternative that’s more reliable and more secure has yet to be proposed. That said, there’s a tremendous amount of research and development into replacements for PoW, and we’re likely to see more of them surface in the coming years.