Blockchain Layers Explained: A Beginner's Guide to Understanding Layers

If you're  into cryptocurrencies or blockchain, chances are you've encountered terms like layer one and layer two protocols. Are you interested in understanding what these layers entail and their underlying purpose? Let's dive into the architecture of blockchain layers in this discussion.


Blockchain technology is a unique amalgamation of various existing technologies, encompassing cryptography, game theory, and more. It holds a wide array of potential applications, notably in cryptocurrencies. Cryptography involves the mathematical and computational processes of encoding and decoding data. 

Meanwhile, game theory dives into the study of mathematical models governing strategic interactions among rational decision-makers. By eliminating intermediaries, blockchain enhances transparency and security, reducing costs and enhancing overall efficiency.


Without a central authority, distributed ledger technology (DLT) employs cryptography to verify information among a consensus of users operating under a predefined network protocol. This combination of technologies establishes trust among parties who may not have an inherent incentive to do so otherwise. It enables blockchain networks to exchange both value and data between users securely.

Given the decentralized nature of blockchains, ensuring robust security is imperative. Additionally, they must exhibit exceptional scalability to accommodate a growing user base, increased transactions, and expanding data volumes. Layers were introduced to address the need for scalability while upholding top-tier security measures.

What is blockchain scalability?

The term "scaling" in blockchain technology pertains to elevating the system's capacity for processing transactions, typically measured in transactions per second. Given the widespread integration of cryptocurrencies into everyday transactions, it has become imperative for blockchain layers to enhance network security, record-keeping, and other essential functions.


Throughput denotes the number of transactions a system can handle per second. For instance, VisaNet, Visa's electronic payment network, can process over 20,000 transactions per second. In contrast, Bitcoin's primary chain manages only up to seven transactions per second.


The blockchain serves as the initial layer within a decentralized ecosystem. Layer two functions as an additional integration, working with layer one to augment the number of nodes and subsequently enhance system throughput. Numerous layer-two blockchain technologies are presently being implemented, often utilizing smart contracts to automate transactions.

Blockchain developers are striving to expand blockchain management, especially as Bitcoin gains prominence in the commercial realm. They aim to reduce processing times and boost TPS by refining blockchain layers and optimizing the scalability of layer two.

The blockchain trilemma

The blockchain trilemma posits that in the realm of decentralization, security, and scalability, decentralized networks can only excel in two out of these three aspects at any given time.

In the 1980s, computer scientists introduced the CAP theorem, highlighting the significant challenge of balancing consistency, availability, and partition tolerance in decentralized data storage like blockchain. According to this theorem, blockchain systems can only simultaneously fulfill two of these three guarantees.


In today's distributed networks, this concept has evolved into what is now known as the blockchain trilemma. The widely accepted belief is that public blockchain infrastructure has a trade-off between security, decentralization, and scalability.

Thus, the ultimate goal in blockchain technology is to establish a network that achieves impeccable security within a broadly decentralized framework, all while handling transactional loads at an internet-scale level.


Before going deeper into the dynamics of the trilemma, it's important to define scalability, security, and decentralization in broad terms:

  • Scalability: in the blockchain context pertains to its capacity to process more transactions.
     
  • Security:  involves safeguarding blockchain data from various attacks and ensuring the system's resilience against double-spending.
     
  • Decentralization: is a form of network redundancy that guarantees the network is not dominated by a small number of entities.

The connection between scalability, security, and decentralization

The network must first reach a consensus on its validity to finalize a transaction. This consensus process may be time-consuming, especially in networks with many participants. Consequently, scalability and decentralization have an inverse relationship when security parameters remain constant.

Assuming two proof-of-work blockchains exhibit equal degrees of decentralization, with security defined by the blockchain's hash rate, we observe that higher hash rates lead to faster confirmation times and improved scalability. Thus, scalability and security are directly related under consistent decentralization.

As a result, a blockchain cannot simultaneously optimize for all three desired features, necessitating trade-offs. Ethereum serves as a recent example of this trilemma in practice. The surge in decentralized finance (DeFi) application usage this summer led to increased demand on the Ethereum platform, but it ultimately faced limitations. 

Due to the heightened demand, transaction fees rose to a point where some users could not interact with the blockchain. The escalating fees on Ethereum exemplify the trilemma, illustrating that Ethereum could not achieve scalability without compromising security or decentralization.

Bitcoin and Ethereum blockchains

Ethereum prioritized decentralization and security, limiting transactions per second (scalability). Users were willing to pay higher fees to incentivize miners to prioritize their transactions. Similarly, in Bitcoin, decentralization and security have taken precedence over scalability.

The fact that blockchains like Bitcoin and Ethereum currently face scalability constraints is well-known. Consequently, a global community of startups, corporations, and technologists is working diligently on layer one and layer two solutions to address the blockchain trilemma.


Layer one blockchain networks are engineered for speed, security, and expansion. Layer two encompasses technological enhancements and products to enhance the scalability of existing blockchain networks. Striking the right balance between these two layers could be a game-changer for blockchain adoption and the growth of decentralized networks.

Developers are approaching this challenge from various angles. For instance, the attempt to increase Bitcoin's scalability through an augmented block size in Bitcoin Cash has not shown clear evidence of success.


Bitcoin seeks to address the issue by introducing an additional layer on top of the existing blockchain. The layer two solutions aggregate numerous transactions and only interact with the base layer blockchain periodically, aligning with the scaling solutions concept. Ethereum is pursuing a hybrid strategy, utilizing sharding to scale the base layer blockchain, while the community anticipates several layer two solutions to enhance throughput further.

The layered structure of the blockchain architecture

In a distributed network within blockchain architecture, every participant is responsible for upholding, validating, and introducing new records. The arrangement of blocks containing transactions in a particular sequence forms the foundation of blockchain technology. These records can be stored either as a flat file (in txt format) or a basic database. Blockchain architecture can manifest in public, private, or consortium variations.

The layered structure of blockchain is classified into five distinct layers.

1. Hardware infrastructure layer 

The blockchain's content is stored on a server in a data center located around the world. When users browse the internet or use applications, they request content or data from application servers, which follow the client-server architecture.

Now, clients can connect directly with other clients and exchange information. A peer-to-peer (P2P) network is a large collection of computers that collaborate in sharing data. In the case of the blockchain, it operates as a P2P network of computers that collectively process, authenticate and log transactions in an organized manner within a shared ledger. This process creates a distributed database where all data, transactions, and relevant information are stored. In a P2P network, a node refers to an individual computer participating in the network.

2. Data layer

A blockchain's data structure is represented as a linked series of blocks where transactions are arranged. It comprises two key components: pointers and a linked list. The linked list consists of interconnected blocks containing data and references to the previous block.
 

Pointers are variables that indicate the position of another variable, while a linked list comprises linked blocks containing data and references to the preceding block. The Merkle tree, on the other hand, forms a binary tree of hashes. 

Each block includes the Merkle tree's root hash and details like the previous block's hash, timestamp, nonce, block version number, and current difficulty level. A Merkle tree ensures security, integrity, and indisputability in blockchain systems. The foundation of the blockchain system lies in Merkle trees, cryptography, and consensus algorithms. 

To safeguard the security and integrity of blockchain data, transactions are digitally signed. Transactions are signed using a private key; anyone with a public key can verify the signer. The digital signature serves as a safeguard against data manipulation. Since both encrypted data and signatures are intertwined, digital signatures ensure consistency. Therefore, any manipulation would invalidate the signature.

The encrypted data remains confidential and resistant to tampering, even if intercepted. The digital signature also shields the sender's or owner's identity, legally binding the signature to its owner and making it irrefutable.

3. Network layer

The network layer, the P2P layer, oversees communication between nodes. This layer manages tasks like discovery, transactions, and block dissemination. It's sometimes referred to as the propagation layer.


This P2P layer is crucial for nodes to locate and communicate with each other, ensuring they can collaborate, communicate, and maintain synchronization to uphold the legitimacy of the blockchain network. 

In a P2P network, nodes are dispersed and collectively share the network's responsibilities to achieve a shared objective. The nodes are responsible for executing the transactions on the blockchain.

4. Consensus layer

Blockchain platforms hinge on the consensus layer. This layer is significant in all blockchains, Ethereum, Hyperledger, or any other platform. Its primary role is to authenticate, arrange, and ensure unanimous agreement on the blocks.

5. Application layer

The application layer encompasses smart contracts, chaincode, and decentralized applications (DApps). This layer has further subdivisions into the application and execution layers. The application layer includes the programs that end-users employ to interact with the blockchain network. This encompasses scripts, application programming interfaces (APIs), user interfaces, and frameworks.


The blockchain network functions as the underlying technology for these applications, communicating with them through APIs. The execution layer encompasses smart contracts, foundational rules, and chain codes.


Even though a transaction progresses from the application layer to the execution layer, its validation and execution occur at the semantic layer. Applications provide instructions to the execution layer, which then carries out transactions and ensures the blockchain's deterministic nature.

Blockchain layers explained

Layer 0

layers_213eng.pngLayer zero of the blockchain comprises elements essential for bringing the blockchain concept to life. This foundational technology is instrumental in operating blockchain networks like Bitcoin and Ethereum. It encompasses crucial components such as the internet, hardware, and connections that facilitate the seamless functioning of layer one.

Layer one 

This forms the foundational level, and its security hinges on its unchangeable nature. When people refer to Ethereum, they're typically talking about the Ethereum network, or what's known as the first layer. This layer manages consensus procedures, programming languages, block time, conflict resolution, and the regulations and settings that uphold the fundamental operations of a blockchain network. It's also recognized as the execution layer. An illustration of a first-layer blockchain is Bitcoin.

Problems with layer one

These scalability solutions enhance the network's capacity when employed collectively. Nevertheless, with the increasing user base of the blockchain, the primary layer is inadequate. The outdated and cumbersome proof-of-work consensus mechanism persists in the first layer of the blockchain.

Though this method is more secure than alternative approaches, it is constrained by its pace. Miners need to decipher cryptographic algorithms through computational resources. Consequently, additional computational power and time are necessary in the extended period. 

Furthermore, the workload on the first layer blockchain has surged with the expanding user base, leading to a decrease in processing speeds and capacities.

Possible solutions

Proof-of-stake, which Ethereum 2.0 implements, offers an alternative consensus mechanism. This method verifies new transaction blocks by considering the staked collateral of network participants, leading to a more streamlined process.


Sharding serves as a scaling solution to address the challenges faced by the layer one blockchain. Simply, it partitions the responsibilities of validating and confirming transactions into smaller, more manageable segments. 

Consequently, the workload can be dispersed across the network to leverage the computing power of additional nodes. This parallel processing of shards enables handling multiple transactions both in succession and concurrently.

2. Layer two

Layer two solutions, or L2 solutions, refer to additional networks that operate on top of the foundational blockchain layer. These protocols leverage this second layer to improve scalability by shifting certain interactions away from the primary layer. 

Consequently, smart contracts on the main blockchain protocol primarily handle transactions involving deposits and withdrawals, ensuring that off-chain transactions comply with regulatory requirements. An instance of a layer two blockchain is Bitcoin's Lightning Network.
 

What’s the difference between a layer one and a layer two blockchain?

 
Layer-1 is the core of a decentralized ecosystem. In contrast,  layer-2 represents an external integration that collaborates with layer-1 to augment the number of nodes and, consequently, system throughput. Currently, numerous technologies for layer two blockchains are being actively deployed.

Layer two scaling solutions

In recent years, layer two protocols have experienced a surge in popularity, emerging as a highly effective strategy for addressing scalability challenges, especially within PoW networks. The subsequent sections provide detailed explanations of diverse layer-two scaling solutions.

Nested blockchain

This is a secondary blockchain layer operates on top of a primary one. The primary layer sets the parameters, while the secondary layer handles the processes. Multiple blockchain layers can coexist within a single mainchain, resembling a typical organizational hierarchy.

Rather than a single individual (like a manager) overseeing all tasks, responsibilities are assigned to subordinates who report back to the management upon completion. 

This approach reduces the manager's workload and enhances scalability. For instance, the OctaSpace project is a secondary blockchain layer for Ethereum's primary protocol, enabling swifter and more cost-effective transactions.

State channels

A state channel enhances overall transaction capacity and speed by enabling bidirectional communication between a blockchain and off-chain transactional channels through various methods. The validation of a transaction within a state channel does not necessitate immediate involvement from a miner.

Instead, it functions as a network-adjacent resource safeguarded by a multi-signature or smart contract mechanism. The final status of the channel, along with all its inherent transitions, is recorded on the underlying blockchain when a transaction or set of transactions is concluded within a state channel.

Examples of state channels include Bitcoin Lightning and Ethereum's Raiden Network. In the trilemma trade-off, state channels trade off some decentralization for enhanced scalability.
 

Sidechains

A sidechain is a separate chain of transactions that operates alongside the main blockchain, mainly handling large-scale transactions. Sidechains have their own consensus mechanism, which can be customized for speed and scalability. A utility token is often employed in facilitating data transfers between the side and main chains. The primary role of the main chain is to ensure overall security and resolve disputes.

In contrast to state channels, sidechains exhibit several significant distinctions. Firstly, transactions on sidechains are not confidential among participants; they are openly recorded on the ledger. Security breaches on sidechains also do not impact the main chain or other sidechains. Constructing a sidechain from scratch demands a substantial investment of time and effort.

Rollups

Rollups represent a layer-two scaling technique in blockchain technology. They execute transactions off the primary layer and record the transaction data on the layer two blockchain. The security of rollups is maintained by layer one, as the data is rooted in the foundational layer. This gives users advantages, including increased transaction capacity, broader engagement, and reduced gas expenses.

Layer three 

The application layer, also known as layer three (L3), serves as a user interface, concealing the technical intricacies of the communication channel. Blockchains find their practical use within L3 applications, following the hierarchical design of blockchain architecture.


 

Can the blockchain trilemma be solved?

The challenges that initially affected distributed data storage, giving rise to blockchains, were transferred to blockchains. To better understand these challenges and their associated issues, we use the term "blockchain trilemma" to categorize them.

Conclusion

One of the obstacles preventing the widespread adoption of cryptocurrency in the blockchain industry is the issue of scalability. With the increasing demand for cryptocurrencies, mounting pressure exists to expand blockchain protocols. 

However, both levels of the blockchain have their own limitations, necessitating the development of a system capable of resolving the scalability challenge.

Layer one is pivotal as it forms the basis of decentralized systems. The scalability issues of the underlying blockchain are addressed through layer two protocols.  Unfortunately, most layer three protocols (DApps) currently operate exclusively on layer one, bypassing layer two. 

While layer three applications play a crucial role in creating practical use cases for blockchains, they are unlikely to capture nearly as much value as their foundational blockchain, unlike traditional networks.