With ETH 2.0 just around the corner, now is a good time as any to look into one of the most critical updates it’s bringing along - proof-of-stake (PoS). In this article, we will look at why the current proof-of-work (PoW) system isn’t refined enough for future scalability needs and then see how eth 2.0 is looking to integrate PoS.
Quite like Bitcoin, Ethereum also uses a proof-of-work (PoW) consensus protocol. The core principle of PoW works like this:
Disadvantages of PoW
Ethereum is planning to move on from PoW due to its several issues:
Proof of Stake (PoS) has already become one of the most sought after consensus protocols in the space. The idea is simple. Lock up a part of your tokens in the system and become a validator in the network. Following that, this is how the process will work:
The biggest problem with PoS is the “nothing-at-stake” problem. To understand what we mean by that, consider, the following issue:
So consider the situation we have above. There is a main dominant chain (blue) and a secondary chain (pink) that’s branching out of it. Typically, an honest miner/validator should append blocks to the longest chain. However, what if a malicious miner Alice chooses to mine on the red block and overwrite the transaction history written in block B, C, and D?
In PoW, the sheer costs involved can quickly mitigate this situation. Since the miner has to spend so much of their resources just to mine one block, they have no incentive to go against the rest of the system. After all, they don't want to do all that work for nothing, right?
However, PoS is a different story.
In PoS, a validator can simply place a bet on both the blue and pink chains. Whatever chain gets a successful addition, the block reward should be enough to compensate them for their losses. In this case, we are looking at a situation where no matter what the attacker does, they will still be in an advantageous position.
This is the biggest issue with PoS, the “Nothing at Stake” problem. To make sure that the attacker doesn’t freely move around the chains, Ethereum will use the Casper Protocol.
Casper changes the PoS game by bringing in a punishment factor to keep all the validators honest. To understand how this works, let’s look at the standard PoS system and observe how Casper changes things.
As you can see, Casper acts in the interest of the entire network by aligning individual goals with the goals of the whole network. Since malicious validators have a lot to lose (i.e., their stake) they are forced to act honestly. Along with this, validators will also have to be very careful about their node availability. If they are not available in time to validate their blocks, they will risk losing their stake altogether.
Casper actually consists of two different algorithms. The first one is called "Casper the Friendly Finality Gadget" or Casper FFG and the other is "Casper Correct-by-Construction" (Casper CBC). So, let’s put each of these under the limelight and see what they are about.
Casper FFG has been worked upon by Ethereum founder Vitalik Buterin himself. FFG will be a hybrid PoW/PoS consensus mechanism that’s going to make the transition from PoW to PoS extremely smooth. The idea behind it is pretty simple:
The way it achieves this is by layering the PoS protocol on top of the ethash PoW protocol.
What does Finality mean?
Finality is a quality wherein an operation, once executed, gets forever etched in history. Nothing that you can do will ever erase or reverse it. When it comes to monetary matters, finality is an absolute must. Eg all your mutual funds must have full finality. Imagine if tomorrow, because of a software error, you lose all your funds? Mutual funds investment, as with all monetary interactions, must have complete finality. According to some, PoW is the only way to achieve 100% finality. However, as we know, the process is hugely wasteful.
Casper FFG claims that it can provide complete finality, provided 2/3rd of all the validators make bets on the finalized blocks. As with any byzantine fault-tolerant system, Casper assumes that less than 2/3rd nodes in a network will be malicious. To illustrate how Casper FFG will help ETH 2.0 achieve stronger finality, let’s see an example:
This feature of FFG is known as Total Economic Finality. As Vlad Zamfir puts it, “Imagine a version of the proof of work where if you participate in a 51% attack, your mining hardware burns down.” In other words, there is little to none economic incentive for validators to go against the system.
Fork Prevention in FFG
Casper FFG also has mechanisms for fork prevention. Instead of blindly choosing the longest chain, FFG follows and tracks the justified checkpoint of the greatest height. To understand what we mean by that, check out the following diagram.
As evident from the diagram, the correct chain is r->b1->b2->b3.
To understand how a correct-by-construction protocol differs from standard protocol design, let’s first examine how the latter works.
As you can see, this is a pretty statically-defined protocol. Now, let’s look at how a CBC protocol works:
So, if you think about it, CBC allows the protocol to derive itself dynamically, and one of the ways it does so is by declaring an “ideal adversary.” An ideal adversary is a metric that:
The LMD Ghost fork choice allows you to choose the most optimal chain instead of the longest one. To understand how it works, take a look at the following diagram:
The Staking Process
As you can see, we have divided the entire state into 7 positions.
Hence we can deduce that the correct path here is A,B,C,E.
Another interesting part about this protocol is that a minority of the network can never beat a majority. Once again, consider the image above, let’s bring it back here:
If the validator D continues to validate blocks on the A-B-D path at a rate that’s faster than the one in the other chain, it will still be rendered useless, since Ethereum 2.0 will only consider block weight as a valid metric.
The first iteration of Casper will be launched in 2020 with the Phase 0 of Ethereum 2.0. The first instance of this transition will be in the form of the beacon chain, which will manage the registration of the validators. The first block of the beacon will launch only upon meeting the following conditions:
During this phase, Ethereum will continue to be mainly a PoW chain, while the beacon runs in the background. Later on, in Phase 1.5, the beacon and PoW chain will join together to create the Ethereum 2.0 PoS chain.
Casper will help in addressing the three biggest problems with PoW:
The barriers to entry for a PoW blockchain is exceptionally high. Miners have to consider a lot of factors, such as:
When it comes to staking, any average user will obviously get intimidated by the initial minimum investment of 32 ETH (~$6,500). However, Ethereum allows their validators to run “staking pools.” Similar to how mining pools work, validators will be able to pool in their ETH tokens and receive rewards that’s proportional to the percentage of their stake within the pool.
Decentralizing the Power
The centralization issue with PoW is definitely a huge problem. As mentioned before, Bitcoin’s hashrate distribution is extremely centralized, with three mining pools owning over 51% of the network hashrate. The reason why this is dangerous is because of something called 51% attack.
In a 51% attack, a malicious entity gains full dominance over a decentralized network by owning more than 51% of the overall hashrate. In this situation, they have the power to:
As you can imagine, this can be extremely catastrophic to the network. So, how does Ethereum do when it comes to hashrate distribution?
Apparently, over the last 24 hours, two pools - Sparkpool and Ethermine - managed to hoard over 50% of the network hashrate. This is really not a good look now, is it?
However, with PoS, there will be significantly fewer barriers to entry and removes any sort of hashrate centralization. You will only need three things to be a validator in a PoS chain:
The two most critical upgrades in Ethereum 2.0 are the implementation of PoS and Sharding. While it is possible to implement Sharding with PoW, it will be extremely difficult to execute it properly.
The two most critical upgrades in Ethereum 2.0 are the implementation of PoS and Sharding. While it is possible to implement Sharding with PoW, it will be challenging to execute it properly.
To understand why, think of a pizza. Now think of a single slice taken out of that pizza. Which one will be easier for you to eat? The slice, right?
The same concept holds for a blockchain and its shards. Shards are fragmented states of the blockchain i.e., slices of the pizza. The individual shards’ hashrate won’t be anywhere close to the main chain’s hashrate. This is why a miner with a considerable amount of hashrate will be able to take over the shard easily.
On the other hand, in PoS chains, it is possible to know who the validators are due to the address attached to their deposit. Through a provably randomizing algorithm, these chains can make sure that the validators selected to validate a block in the different shard chains are entirely random.
Ethereum 2.0 is going to be truly monumental. While Casper integration is definitely the biggest change, there are other amazing innovations as well, such as – Sharding, raiden, plasma, eWASM, etc. We will be looking into each one of these innovations in the subsequent articles, starting with Sharding.
If you are interested in learning more about the ins and outs of Ethereum before ETH 2.0 kicks in, check out some of the courses available on one the world’s most successful blockchain education platforms, Ivan on Tech Academy. We have several high-value accredited courses on blockchain and cryptocurrency that have been created by our in-house trainers and industry experts. Along with Ethereum, the run-up to ETH 2.0 and the different phases of ETH 2.0, we also cover blockchain basics and have several developer courses, as well.
Get to work in a fast growing industry. Start learning blockchain together with our 20,000+ students today.