As you are probably aware, we are on the verge of an Ethereum revolution, colloquially known as ETH 2.0. This upgrade is going to bring in a lot of innovations to the popular Ethereum protocol.
We have covered two of the most significant changes – Casper and Sharding – in detail before. In this guide, let’s cover another exciting innovation that is going to give the overall scalability a significant boost – Ethereum layer-2 scaling.
Ethereum layer-2: Solving the scalability problem
Numerous sources have very extensively documented Ethereum’s scalability problems. Decentralized cryptocurrencies are inherently non-scalable due to their design issues. Ethereum does around 25 transactions per second, which is pretty abysmal but still marginally better than Bitcoin, which can only do seven transactions per second.
This low transaction throughput happens because of the amount of time it takes to validate and put in a transaction within the block.
Design problems of Ethereum
The transaction validation and fulfillment process is extremely sequential in Ethereum. For example:
- If you want to send someone 1 ETH, it will first have to wait in the mempool.
- Following that, the miners pick up the transaction from the mempool and verify the validity of the transaction.
- After that, they put the transactions in the block.
- In Ethereum, a block gets mined every 15 seconds, Meaning every transaction requires 15 seconds to be validated.
Now, these are just theoretical mechanics. We still haven’t even considered the “gas” factor. Long story short, “gas” is a metric used to decide how much fees it would take to execute a particular transaction. These gas fees are collected by the miner, who then proceeds to add the transaction. This is where we hit our next bottleneck.
The gas problem
The chart above shows the average gas price since November 2019. While the average price is pretty consistent, there are some noticeable spikes in price. This is noteworthy because you need to put in a certain amount of gas within your transactions to incentivize miners to put them inside their blocks. This is why wealthier users can bloat their transactions with high gas fees and get more preference from the miners.
Hence, if you just pay the standard gas price, your transaction can take anywhere between 15 seconds to 5 mins to process a transaction.
Orphan block rate
Orphan blocks are empty blocks in the blockchain that contain no data whatsoever. Some of the best mining pools in Ethereum also end up having a 1-2% orphan block rate. These empty blocks create an extra time lag on our transactions, which reduces the probability that they will be included in a block. As a user, the worst part about this experience is that your transaction can get delayed for factors entirely outside your control.
Ethereum Layer-2 Protocol: Scaling things up
The lack of scalability is the biggest obstacle for mainstream adoption. After all, why will people opt to transact with cryptocurrencies when they can’t enjoy instant fulfillment. This also makes it highly impractical for microtransactions. Eg. Imagine that you have an agreement with your milkman wherein you pay them 25 cents for each liter of milk delivered every single day. Now, let’s say that you want to make your relationship completely digital and make the payments only with cryptocurrencies. This will be a problem because the gas fees associated with each microtransaction will make it highly impractical.
There is another big issue we must consider.
The underlying Ethereum blockchain isn’t well-equipped to handle high-value smart contracts. In fact, we have seen this play-out first-hand with the cryptokitties fiasco. The cryptokitties game became so popular that the underlying blockchain simply couldn’t cope with demand. As such, Ethereum got bloated, and the number of pending transactions went through the roof.
ETH Layer 2: Difference between layer 1 and layer 2
So, as you can imagine, we needed to resolve the scalability issue as fast as we possibly can. The crypto community as a whole is working on two schools of techniques – layer 1 and layer 2.
- Layer 1: These are techniques that work in the base-layer of the blockchain itself. Eth 2.0 will be bringing in layer-1 scalability with sharding.
- Layer 2: Techniques that work on top of the underlying chain are ETH layer 2 techniques.
Ethereum Layer-2 Protocol: Why use it?
One of the biggest problems that Bitcoin and Ethereum face is blockchain bloat. As more and more users enter the crypto space, the number of transactions fulfilled is only going to go up. This will bloat the blockchain, making it harder for individual nodes to download and maintain the whole chain. As such, nodes will need to invest in expensive hardware to store the extra data.
One possible solution here to increase the block size itself. However, the block size debate can get very long and drawn out, splitting up the community in the process as we have seen with the Bitcoin and Bitcoin Cash.
This is why ETH 2.0 is looking to delegate more complex operations to layer 2 protocol, keeping the base blockchain as activity-free as possible. Ethereum layer-2 scalability can be achieved with the following methods:
Raiden: ETH layer 2 protocol
Raiden is similar to Bitcoin’s lightning network in the sense that they are HTLC state channels as well. You can think of state channels as a two-way communication channel between users. This allows the network to conduct standard on-chain transactions, off the chain. This is especially helpful for microtransactions since it gives users a way to conduct these without having to commit each and every one of those to the blockchain
Now, this brings us to the next question…
Ethereum layer-2 with off-chain state channel: How does it work?
- A piece of the blockchain’s state is locked up and segregated by a smart contract or a multi-signature.
- The conditions governing these state channels are pre-agreed upon by the participants.
- The participants directly interact with each other without having to submit anything to the miners in the interim.
- The condition which dictates when the channel closes can either be time-lapsed (the channel closes after one hour) or total transaction completed (channel closes only after $50 worth of transactions have been completed).
Ethereum Layer-2: How do HTLCs work?
While there are many kinds of state channels out there, the most common form happens to be hashed timelock contracts (or HTLCs). HTLC allows users to transact directly with each other before a pre-agreed deadline by submitting cryptographic proofs.
So, how does your general HTLC transaction work? Let’s take a look. Imagine Alice and Charlie want to transact with each other, through their shared connection in Bob.
- Bob opens a channel with both Alice and Charlie. Alice and Charlie both want to interact with each other.
- Charlie declares a random number X and generates its hash X’. Charlie then sends over the hash X’ to Alice.
- Alice sends over 0.2 ETH to Bob with the condition that she will unlock the fees only if someone sends over a number, which on hashing gives X’.
- Bob hands over the funds to Charlie using the same condition.
- Charlie hands over the number X to Alice, she then proceeds to unlock the funds for him.
Looking into Raiden
Raiden is an Ethereum layer-2 solution. Unlike the Lightning Network, Raiden isn’t just a simple payment channel. You can transfer smart contract details, as well. As per Brainbot, the company behind Raiden, says that Raiden will be a mesh-like structure laying on top of Ethereum.
ETH Layer 2 Raiden: Advantages
- It allows users to conduct microtransactions.
- Enables Ethereum to scale up significantly.
- It can be used to send any ERC20 token.
- Reduces blockchain bloat
- Raiden’s native token is RDN.
Plasma: Ethereum Layer-2 protocol
Trust us when we say this, that meme is so accurate that it is scary. Plasma is a network of blockchains built on top of the base root blockchain. To paint yourself a mental picture, think of the main chain as the root of a tree, and the plasma chains as the branches.
Image credit: Hackernoon
Rules of the root chain
- The root chain puts down the law for the entire network. The plasma chains are solely responsible for all the calculations that take place within the network. Following that, they commit the final results to the root chain, where it becomes the undisputed truth.
- The root chain only comes into play for dispute resolution.
- For the root chain to be the base of the entire system, it should be as devoid of regular calculations as possible.
- In the case of Ethereum, The Ethereum blockchain is the root chain.
ETH 2.0 Plasma Structure – The Court Structure
Following is how a normal court structure works:
Image Credit: Duke Law
So, in our typical court structure, the Supreme Court acts as the root chan, while your Criminal and Civil courts serve as the plasma chains. Each of these plasma chains has its own plasma chains. So, now think about how the whole structure works:
- If you want to bring up a civil lawsuit, you usually shouldn’t be able to go directly to the Supreme Court.
- You will first have to go to the County Courts. After that, you eventually move up the ladder, depending on your unhappiness with the final results.
ETH layer 2 scaling: Plasma design goals
Plasma was formulated by Ethereum co-founder Vitalik Buterin and Lightning Network co-founder Joseph Poon. The design goals of plasma are as follows:
- As stated multiple times before, the main chain is the root blockchain that puts down the law of the land. The root chain doesn’t interfere with the daily activities of the plasma chain. Except in the event of disputes.
- Like the root chain, the plasma chains have to produce a trustless environment as well.
- The individual plasma chains should be as scalable as the root chain to cope with increasing demand.
- They should also be compatible with scalability techniques like raiden and sharding as well.
- Conducting localized computations is critical for the success of this project. This is why these plasma chains should be well-equipped to perform calculations on their own.
- In the event of a dispute, a user in the plasma chain can send a verifiable proof-of-fraud to the root chain.
- Every plasma chain can integrate its own unique governance rules and consensus protocols.
Ethereum Layer-2 Plasma: MapReduce
Now, let’s look at how the whole system works. MapReduce is a very well-known programming model that allows you to process and create big data sets via a parallel, distributed algorithm. As the name suggests, there are two parts to MapReduce:
- Map: A large dataset is divided and delegated to different entities, who then solve it in parallel.
- Reduce: The entities answer the queries, creates a summary of their findings and hands it back. The summaries are collated, and a final master summary is created to present a solution to the initial data set.
To understand how this works, let’s take an example. Alice needs to submit a report on how Ethereum works. She hands the article over to Bob. Bob then assigns Charlie, David, and Eric specific tasks. Charlie needs to write on how mining works, David has to show how Ether’s tokenomics works, while Eric has to come up with a future projection for Ethereum.
This is how this process works from the POV of Map/Reduce.
- Alice hands over the writing task to Bob.
- Bob assigns individual tasks to Charlie, David, and Eric.
- Charlie, David, and Eric compile their summaries and hand it over to Bob.
- Bob collates the summaries and hands over the final result to Alice.
Finally, let’s see how Map/Reduce works in the context of blockchains and plasma.
Image Credit: Trust Nodes.
- The Plasma chain in tree depth 1 gives a task to Plasma chain 2.
- Plasma chain 2 proceeds to delegate portions of the tasks to different plasma chains in level 3.
- Level 3 plasma chains compute and return the summarized version of their findings to plasma 2 in the form of Merkelized data.
- Plasma 2 receives the final data, collates it, and sends the ultimate Merkelized data back to chain 1.
Ethereum Layer-2 Protocol Plasma: Dispute Resolution
Finally, let’s look at one of the essential aspects of plasma chains – dispute resolution.
Let’s look at the following diagram to understand how it potentially works.
- Imagine that Alice has 1 ETH in plasma block 3 but doesn’t have it in block 4.
- She feels that the person in charge of that block is malicious in nature and has handed over her ETH to someone else.
- The plasma smart contract empowers her to send a Fraud proof to the root chain for dispute reporting.
- The root chain checks the validity of the proof. If it’s valid, they roll-back the plasma block 4, and reverts the state of the plasma chain back to block 3.
- The creator of plasma block 4 gets suitably penalized.
To get a diagrammatic version of this incident, look at the following image:
ETH Layer 2 plasma chains: Possible use cases
- PayPal, one of the most famous payment processors in the world generates 5M txns/day. Ethereum can barely do a million (~945,942). Plasma can exponentially boost up this number by enabling faster and cheaper transactions. Plasma can even integrate with existing DeFi protocols to create newer financial offerings.
- Remember that plasma chains can operate by their own rules and are interoperable. As such, the plasma chains can operate via laws that help in the facilitation of enterprise blockchains.
- Enterprises can use plasma to scale up and transparently trace the ownership of assets right to its origins. Plus, they can also control the modularity and access controls on the plasma chain to ensure that the data’s privacy is maintained.
- The core nature of supply chains is extremely opaque and cross-border payments can be a pain. By using plasma, enterprises will have the ability to digitize royalty payments and send them over to the appropriate party at very low costs.
- Banking the unbanked: OmiseGo, An Ethereum-based dApp, is the primary organization working on plasma implementation and plans on banking the unbanked. A staggering 2 billion people around the world don’t even have a bank account. In fact, a study done by McKinsey shows that reaching the unbanked population in ASEAN could increase the economic contribution of the region from $17 billion to $52 billion by 2030. Low-cost, interoperable, and scalable chains like Plasma can help mitigate this crisis.
- Bond Brand Loyalty released a report, where it was stated that nearly a $100 billion has been left unclaimed in loyalty points. Using the plasma chains, one can transfer their unclaimed loyalty points to other payment channels to redeem it in other forms.
- Stablecoin projects will have the ability to interact with and siphon in liquidity from tokens across different networks via plasma.
Decentralized exchanges with Ethereum Layer-2 scaling
Decentralized exchanges can benefit immensely from Plasma integration. Let’s take a look how:
- Plasma also allows for the creation of high-throughput decentralized exchanges (DEXs). DEXs can use plasma to scale their settlement by an exponential amount. With the increase in speed, Plasma integration can also allow users to conduct trades with significantly low fees.
- Plasma enables exchanges to pool their liquidity into one consolidated and decentralized sidechain, which in turn empowers them to run with less on-chain data.
- Staying on the DEX topic, Plasma facilitates cross-chain interoperability for DEXs. This means that DEXs can use Plasma to create new trading pair offerings and decentralized business models.
- With plasma and SNARK integration, DEX can support Dark Pool Exchanges. These exchanges are the ones where users have no clue of what the order book looks like. This prevents arbitrage or any other form of front-running attacks.
Ethereum Layer-2 Conclusion
With layer 2 integration, ETH 2.0 will enjoy immense scalability and interoperability. As mentioned before, scalability and interoperability are the two most significant pain points in the crypto space. With Ethereum layer-2, developers have the rare opportunity to kill two birds with one stone. Plus, the sheer number of use cases and utility that Raiden and Plasma will bring in is significant, to say the least.
Do you want to know more about how Ethereum 2.0 works? Do you want to know about how the blockchain in general works? If yes, then do check out our blockchain courses. We have the absolute best resources in the world that will give you all that you need to educate you and make you extremely proficient in this space.