DeFi is evolving, growing and taking over the world. And with it so are the complex issues with each blockchain architecture. The solution we often hear to problems like gas fees and scalability are terms like Layer-1 and Layer-2 development. But what does it all mean?
What Is a Layer-1?
In DeFi, Layer-1 refers to the base layer blockchain. Layer-1s are the pillars that keep the whole network working and communicating, allowing other projects to build on top of it. Layer-1 scaling solutions hence refer to adjustments made directly to the base layer of the blockchain to improve scalability. For example, adjusting the amount of data that can be written in each block in order to increase the output per block.
Let’s look at the case of Ethereum, the leading Layer-1 after Bitcoin. It enables smart contracts to work on top of its blockchain and network, making it possible to offer users a more complete experience. In fact, a lot of other projects work on the Ethereum Layer-1, such as Aave and Compound, all on their ERC-20 token standard.
Some Layer-1 scaling solutions include consensus protocol improvements and sharding.
Consensus Protocol Changes
Ethereum and many others are switching consensus mechanisms, from Proof-of-Work (PoW) to the more environmentally friendly Proof-of-Stake (PoS). Both Bitcoin and Ethereum 1.0 are still using PoW, a mechanism where blockchain consensus is reached with miners solving cryptographic equations by using their computational power. The method has proven to have its pros such as superb security.
Switching over to PoS will improve scalability, solving many problems brought about by PoW such as its intensive energy use, high gas fees, and network congestion.
Sharding is another popular Layer-1 solution that developers are adopting. The network doesn’t work on each transaction individually but breaks it down into small data sets called “shards”. This makes the data much easier to process, as each shard is worked on by different nodes at the same time. It distributes the heavy workload into distinct partitions, which can improve network latency.
However, the blockchain trilemma trade-off for the increased scalability with sharding is lowered security. Being a relatively new concept in the blockchain space, sharding is still being tested, and several issues have not been addressed yet.
What Is a Layer-2?
Layer-2 solutions are third-party integrations built upon Layer-1s to improve their scalability. They add benefits and value to the Layer-1 foundation, providing users with more functionality.
To make the example as clear as possible, let’s compare it to a city. Layer-1 is the infrastructure, such as roads and buildings, whereas Layer-2 is the cars and systems set in place to take advantage of and improve the Layer-1 processes.
On Layer-2, developers can create more advanced features without the need to add what’s already provided by Layer-1. And by using the already proven Layer-1 technology, the second layer runs smoother and better than without it. An example of a Layer-2 would be Bitcoin’s Lightning Network.
The major downside to these projects is that they can only exist and function well if the Layer-1 projects work effectively. If something hinders the ETH chain, such as gas congestion or a problem with ERC-20 compatibility, then Layer-2 projects would be insolvent.
Two popular Layer-2 solutions are state channels and nested blockchains.
A state channel is an off-chain communication method between two participants, allowing them to transact multiple times while submitting only two on-chain transactions. This enables much higher throughput, effectively improving the blockchain’s scalability.
In simple terms, this is how it all works:
- Part of the chain is sealed with methods like multi-signature or a smart contract, of course, agreed by participants.
- This allows the participants in the network to interact and exchange with each other without needing a third party.
- Once done, the final state is added to the blockchains.
Two examples of this method are Bitcoin’s Lightning Network and Ethereum’s Raiden Network. Both use the Hashed Timelock Contracts (HTLCs) to execute the transactions. The Lightning Network manages a huge number of microtransactions in a limited time period, while the Raiden Network also allows for smart contracts.
Nested Blockchains are another Layer-2 solution that has risen to fame in recent times. A great example is Plasma, a popular Ethereum solution developed by OmiseGo. It works in the following way:
- The main blockchain lays down all the rules for the whole system. The only time it participates in the operations is to resolve disputes between parties.
- On top of the main blockchain, multiple levels of chains will be built. Connecting and creating a parent-child connection, with the parent chain delegating to its child chains. The child chain then executes and sends it back to the parent chain.
- Doing so significantly reduces the load to the root chain and can potentially increase the scalability exponentially.
Crypto has gained a lot of traction in the past few years. Many existing networks are straining under the load of DeFi’s rapidly expanding user base. As a result, scaling solutions came into the picture. Both Layer-1 and Layer-2 solutions address the same issue, each in their own way. However, they often come at the cost of either decentralisation or security, per the infamous blockchain trilemma. These strategies are hence often used in conjunction with each other in order to try and mitigate the loss of decentralisation and security.