Proof of Work & Proof of Stake: Understanding The Foundation Of All Blockchains
In the traditional financial system, we rely on companies that provide the services of storing, verifying, and approving our transactions.
Now, let's take a look at how this works typically:
A transaction happens;
Someone registers it on the books;
Someone else does the audit work to ensure the recorded transaction is valid.
When we look at the crypto world, it follows a similar process flow. The only difference is that instead of trusting a particular institution to do the work, the crypto space removes the traditional intermediaries and offers a decentralized mechanism. When a transaction happens, it gets grouped with other transactions and registered into a block. Once the block is uploaded and linked to the rest of the chain (hence, the name blockchain), it gets verified and validated in the network.
The people who do this book-keeping work are the famous "Miners". The underlying mechanism that defines the rules by which miners work is called "Proof of Work" (PoW), and the action of carrying out this process is called "Mining".
Let's take a closer look at how this works by answering key questions!
Who are Miners?
Anyone can be a part of the mining network for a particular blockchain. Even you can become a miner if you want to. The only requirement to do so is that you will need to get the right computer hardware and servers that will enable you to solve the algorithmic puzzles and win the right to mine the block.
What do miners do?
Miners are the group of people that will:
create the block, which means registering the transactions and uploading them on the chain;
validate the information in the block, primarily ensuring there are no invalid transactions or double spending cases.
This is a mutually exclusive role per block: every time a block is created, someone will be in charge of step 1, and the rest of the miners will be in charge of running step 2. This is a check and balance system where the mining community holds each other accountable.
What do the miners get in exchange for doing this work?
The miner who successfully gained the right to register transactions and create the block is rewarded with native coins of the blockchain they are mining on. It turns out that new coins are also created with every newly mined block.
In the case of Bitcoin, for example, the miner gets to add a special transaction to their block called a "coinbase transaction" that specifies the amount of Bitcoin that gets minted and rewarded to the miner for mining the block. That particular amount gets halved every four years: it started with 50 BTC when Satoshi Nakamoto mined the first block, and right now, it's currently at 6.25 BTC per block.
If the miner that gets rewarded is the one who does step 1 (generating the block), how do you determine who gets to do that?
Comes in, Proof of Work (PoW).
Crypto follows the PoW mechanism in which the miners need to solve an underlying algorithmic puzzle that has millions of potential answers. Without going too technical, let's just say that this puzzle involves a Hash Function, a special function where you put in any string of letters, numbers or data. You will get a long string of numbers combination.
Now, it's guesswork. Imagine rolling a giant die that produces numbers from 0 to the number of atoms in the universe. To win the guess, you have to roll out a number below the set target for that particular block.
This is a probability game: the more times you roll the die, the more chances you have to get it right.
The miner who wins this race wins the right to generate and upload the block. The process of playing this PoW lottery game is called mining. The rest of the mining community will do the validation work.
How do we ensure nobody wants to cheat?
A miner needs to race to solve the algorithmic puzzle, and since you already know that it's a probability game, the more and faster you can generate your guesses, the better.
To do so, one needs to invest in a good set of hardware that will allow them to do that and power it up with a considerable amount of electricity required to keep "rolling the die" and increase the chances of winning the lottery.
One might win the race or not, but since they are investing a decent amount in equipment and energy, they want to make sure everyone accepts and approves your block and therefore be able to receive your reward. Therefore, due to economic rewards, everyone is highly incentivized to ensure the ledger is correct.
The alternative is to get your block rejected and lose all the investment you put in. This is how PoW ensure it is real-world costly. Game theory simple.
This last point gives some perspective regarding why there is so much criticism around energy consumption against the crypto industry.
To solve this issue, many blockchains are already running on a Proof of Stake mechanism or with a roadmap to transition into this latter, presenting a solution to network congestion and optimizing energy consumption.
If PoW is described as a race where everyone has to participate, put in the hard work to run, and have one final winner, PoS is more of a solo race, where you have one person who is nominated to represent the rest.
One can think of PoS as an exclusive club. If one wants to be part of it, they must put in a certain amount of money as a safe deposit to gain access.
Once you are part of the club, they are responsible for collectively maintaining and validating the club's books.
Now, how to get picked among the entire group to do the job?
To ensure everyone has a fair shot, different blockchains consider different factors, such as total coins staked, how long you have been staking, or even randomness. Most algorithms will combine all three of these factors, and if you'd like to understand the particular weightage and details, the best way to do so is to read their whitepaper.
PoW incentives no cheating, positive behaviour by ensuring all miners put in hard work + hardware and electricity cost. However, this mechanism is inefficient in terms of having to have everyone run the race for every single block.
With PoS, instead of doing this every time, one only has to lock up a predetermined amount of native coins of that particular blockchain in the network as an entry rule. If they don't mine their block within a set amount of time, or if there were invalid or fake transactions, there is a high chance of losing staked coins. Therefore, by having your coins at stake, the PoS mechanism keeps it real-world costly, incentivizing good behaviour.
For example, for the upcoming Ethereum 2.0 version, one will have to stake 32 ETH in the network. That's a lot of money at stake.
What are some of the key benefits PoS offers?
More efficient energy usage – miners, aren't competing to solve the mathematical puzzle and win the race anymore; the energy usage level is naturally lesser.
Speed - typically, in a PoW set-up, the more people participating in the race, the longer the race to solve the algorithmic puzzle. With PoS, there is no need to make it more complicated as there is no racing, so that it can be significantly shorter.
Lower entry barrier - following the "no more racing" line, the hardware requirements also go down, together with energy usage, so it's more affordable to become a miner.
Decentralization – as the entry barrier is lower, more people have access to it, increasing participation. At the same time, it should also lead to more network nodes (which refers to computers), making it more centralization resistant.
Due to these benefits, PoS has generally been considered a better mechanism than PoW, which is why the newer blockchain projects are generally PoS, and the ones that have been around longer are in the works to transition to this format, such as Ethereum.
It is worth noting, though, that from a risk point of view, the timing and maturity of a blockchain are essential factors to consider. If you are/become a PoS blockchain too early, you might risk suffering a 51% attack (which is when coin holders get together to rule as a majority). If you do it too late, you'll have scalability issues and people wasting too much energy on mine. It's a balance here.