What is Layer1 vs Layer2

· Resources

The growing popularity of blockchain and cryptocurrency is challenged by scalability issues, despite the technology's revolutionary potential. Public blockchains that prioritize high security and decentralization often struggle with low transaction throughput, a dilemma known as the Blockchain Trilemma. This principle suggests it's difficult for decentralized systems to simultaneously achieve high security, scalability, and decentralization, typically achieving only two of these three goals. However, many enthusiasts and experts are actively developing solutions to improve scalability, including modifications to the main blockchain architecture (Layer 1) and implementing Layer 2 protocols that enhance the underlying network.

Layer 1 refers to the base protocol of a blockchain, which is the fundamental system where transactions are finalized and recorded. Essentially, Layer 1 is the underlying main blockchain architecture. Examples of Layer 1 blockchains include Bitcoin, Ethereum, and Binance Smart Chain.

Layer 2 refers to a network or technology that operates on top of a Layer 1 blockchain to enhance its scalability and efficiency. Layer 2 solutions are secondary protocols built to decrease the burden that the base layer (Layer 1) handles. They do not require changes to the Layer 1 blockchain itself but work alongside it to handle transactions off the main chain before settling on it.

Basically, Layer 1 scaling solutions are changes to the blockchain network’s base protocol that improve scalability. Layer 2 scaling solutions instead use off-chain services or networks to make scalability better.

Types of Layer 1 Blockchain Scaling Solutions

Increased Block Size

Some Layer 1 cryptocurrency blockchains have updated their code to increase the block size, allowing more transactions to be verified at a time, thus expanding the overall capacity of the network. An example of this is the Bitcoin Cash (BCH) network, which upgraded its block size to 8 megabytes (MBs) from 1 MB, then further to 32 MBs, allowing it to process more than 100 transactions per second vs. Bitcoin’s seven transactions per second.

Updated Consensus Mechanism

The consensus mechanism of a blockchain is the method by which it validates transactions to ensure the accuracy and security of the network. Bitcoin, for example, uses a proof-of-work (PoW) consensus mechanism, requiring tremendous processing power to solve a complex equation in order to be allowed to record the next block in the blockchain. Ethereum also originally used PoW, but has since upgraded to a proof-of-stake (PoS) consensus mechanism, which requires node operators to lock up a large Ether (ETH) deposit to be allowed to process transactions.

Sharding

Sharding is similar to database partitioning, allowing a blockchain database to be broken up into smaller parts so that transactions can be processed simultaneously. This increases the overall capacity of a Layer 1 blockchain network.

Types of Layer 2 Blockchain Scaling Solutions

Rollups

Instead of processing transactions individually, bundles of transactions can be “rolled up” into a single transaction, vastly increasing the number of transactions that can be processed at once. The transactions are outsourced to be recorded off chain, bundled, and then brought onto the main chain to process as a single entity. The primary types of rollups are:

Optimistic Rollups

Optimistic Rollups assume that off-chain transactions are valid by default and only check the validity of transactions if a fraud proof is submitted.

Key features include:

  • Assumption of Validity: Transactions are assumed to be valid optimistically. This means that transactions are processed quickly without immediate verification.
  • Fraud Proofs: If someone suspects a transaction is fraudulent, they can submit a fraud proof within a specified challenge period. If the fraud proof is correct, the invalid transaction is reverted, and the fraudster is penalized.
  • Lower Costs: By not verifying every transaction immediately, Optimistic Rollups reduce the computational load, leading to lower transaction costs.
  • Data Availability: All transaction data is posted on-chain, ensuring that anyone can reconstruct the rollup’s state.

Examples of Optimistic Rollups

  • Arbitrum: Known for its extensive compatibility with Ethereum Virtual Machine (EVM), allowing developers to easily port their existing Ethereum-based dApps.
  • Optimism: Focuses on simplifying the transition for developers and users from Ethereum to its rollup, offering high throughput and low fees.

ZK Rollups

ZK Rollups (Zero-Knowledge Rollups) use zero-knowledge proofs to validate transactions off-chain.

Key features include:

  • Zero-Knowledge Proofs: ZK Rollups generate cryptographic proofs (zk-SNARKs) that prove the correctness of a batch of transactions. These proofs are submitted on-chain and verified by smart contracts.
  • Immediate Validity: Because the zero-knowledge proof verifies the correctness of transactions, there is no need for a challenge period. Transactions are considered valid as soon as the proof is verified.
  • Higher Security: The cryptographic proofs provide a high level of security, ensuring that the transactions are valid without needing to trust any single party.
  • Efficient Data Use: ZK Rollups require less data to be posted on-chain compared to Optimistic Rollups, making them more efficient in terms of data usage.

Examples of ZK Rollups:

  • zkSync: Aims to provide low-cost transactions and instant confirmation while maintaining security through zk-SNARKs.
  • Scroll: Designed for scalability and security, providing high transaction throughput while maintaining compatibility with Ethereum smart contracts.

Optimistic Rollups and ZK Rollups differ fundamentally in their validation methods and security models. Optimistic Rollups assume transactions are valid by default and rely on a challenge period during which users can submit fraud proofs if they detect invalid transactions, leading to lower immediate computational costs but potential delays due to the challenge period. In contrast, ZK Rollups use zero-knowledge proofs to validate transactions off-chain, generating cryptographic proofs that ensure transaction validity without the need for a challenge period, resulting in immediate validation and higher security. ZK Rollups generally require more computational resources upfront to generate proofs but offer more efficient data usage and stronger security guarantees, whereas Optimistic Rollups benefit from simpler implementation and lower initial costs but rely on the effectiveness of fraud detection mechanisms.

Side Chains

Side chains are independent blockchain networks with their own set of validators that allow transactions to be processed in parallel. This vastly increases the transaction-processing power of a blockchain, but you must trust the integrity of the side chain network, as well as the bridge network that connects it to the main blockchain.

State Channels

State channels are similar to a side chain, as transactions are recorded off chain, but these transactions are recorded in bulk off chain, then the state of the channel is set at complete. The transactions are then recorded in bulk on the main blockchain network by broadcasting a completed “state” to the main network. This is how Bitcoin’s Lightning Network is set up.