Understanding Blockchain Layers
Table of contents
No headings in the article.
I’ve always been confused by crypto buzzwords like layer 2 and lightning network for bitcoin so I decided to do a little research and I discovered that this terms are rooted in the concept of blockchain layers, so this article is going to be a deep dive on the layers of the blockchain.
A blockchain is a transparent and immutable distributed ledger that records data across a network of computers. This is known as decentralized network since there is no central computer storing the data.
Blockchain technology is broad and has many applications but the most common application of blockchain is cryptocurrency. Cryptocurrencies operate on blockchain decentralized networks and transactions made with cryptocurrencies are stored on the blockchain.
Well known cryptocurrencies like bitcoin and ethereum use this system.
Users can buy, sell and transfer cryptocurrencies peer to peer (between themselves) without the need for intermediaries or a bank since all transactions can be initiated by the users and the transactions are stored on the blockchain.
Due to the lack of a centralized authority, blockchain must be secure and must be scalable to handle more users and increasing transactions. Layers were created to handle security and scalability.
Bitcoin’s main chain can handle only seven transactions per second. In comparison visa's electronic payment network can process over 20,000 transactions per second. This led to a need for scaling to enhance the processing capacity of the blockchain. This need is being fulfilled by layer 2 blockchain technology.
The blockchain is the first layer in the decentralized ecosystem it is also known as the base layer. Layer 2 blockchain technology is being built by blockchain developers to increase scalability and security while also maintaining decentralization. An example of layer 2 technology are smart contracts which automates transactions thereby increasing processing time.
Layer two comprises third party integrations designed to address the scalability issues of blockchain layer one
Some layer two scaling solutions include:
State channels
State channels allows users to carry out transactions and validate transactions on an off-chain transactional channel without the involvement of the blockchain at every step. Participants in a state channel agree on the initial state of a transaction, conduct off-chain transactions and then submit the final state to the main chain. State channels are particularly useful for micropayments and frequent, low-value transactions. Examples include the lightning network for bitcoin and raiden network for ethereum. Blockchain using state channels sacrifice a bit of decentralization for stability
Nested blockchains/plasma:
Plasma is a framework that enables creation of hierarchical trees structure of smart contracts. The main chain (root) is responsible for security and the individual branches process transactions independently, enhancing scalability. An example of this is the OMG plasma project
Sidechains
Sidechains are separate blockchains that are interoperable with the main blockchain. They are transactional chains that runs alongside the main blockchain and are used for massive bulk transactions. Sidechains have their own consensus method which can be adjusted for speed and stability.
Sidechains differ from state channels because they are openly published on a ledger unlike state channels which are private. Also security breaches on the side chain do not affect the main chain. An example of this is Bitcoin’s liquid sidechain
Rollups
Rollups bundle multiple transactions off chain and submit a summary of proof to the main chain. There are two types of rollups: optimistic rollups, which assumes the transactions are valid unless proven otherwise and zk-rollups which use zero-knowledge proofs to ensure validity of transactions.
Examples include: optimistic rollups (e.g. Optimism on ethereum) and zk-rollups (e.g., zksync on ethereum)
Hybrid solutions
Some projects combine multiple scaling solutions to achieve better performance and scalability. for example, a combination of state channels, sidechains and rollups to address different use cases and requirements an example is Matic network(polygon) utilizing a combination of sidechains and plasma
Validium chains
Validium chains combine elements of rollups and sidechains and submit only the validity proofs to the main chain, providing scalability while ensuring security an example is ZkPorter.
In conclusion, the second layer of the blockchain was created to improve upon the functions off the base layer blockchain i.e. decentralization, security and scalability. Innovations are still being made to improve the second layer, and in the future a good balance would be made between scalability, decentralization and security without any tradeoffs.