DEV Community

Cover image for Layers of a Blockchain: A Guided Tour
DappaDan
DappaDan

Posted on

Layers of a Blockchain: A Guided Tour

The journey of learning about blockchain has many twists and turns along the way but the path always includes a stop at the 'layers of a blockchain' station. Like ogres and onions, blockchains consist of layers that help enable the complex operations required to run smoothly and efficiently.

It is common to compare the layers of a Blockchain to the layers of the Internet Protocol suite(IP) to explain how they work. There are some great parallels between the two and since many hope blockchain technology will reinvent the world much like the internet did, the comparison makes sense.

If you have a good understanding of IP, this is of course an effective way to learn this concept. But if you are like most internet users who happily use the internet and don't care about how exactly HTTP is working in the background, this is not so great.

For this tour of the layers of a blockchain, let's take something more familiar - a typical company - to explain the function of each layer in a blockchain. But first, what are these layers everyone is talking about and why do we have them?

What Are Layers?

A layer is a set of rules or protocols on how internal processes should be handled and how information on those processes should be shared with other layers externally.

To start our business analogy, a layer would be a specific team in the company. Each team has its own set of goals, its own set of tools to meet these goals, and a way to communicate with other teams about them. Although each team has a different focus area, they all aim to serve the business as a whole.

In the "blockchain company" the ultimate goal is to balance the decentralization, security, and scalability of the network. Each layer contributes to this goal in its unique way.

Why Have Layers?

Operating in a layered architecture provides the benefits of flexibility to be upgraded, interoperability, and the ability to be designed for and applied to multiple use cases.

Without layered system design, the internet would not be what it is today. We would be required to upgrade and use specific hardware and software to perform the common functions that we take for granted. Luckily one can access this article on the latest Macbook Pro or the long and forgotten closet PC.

As a business scales from the 'wear multiple hats' start-up stage to a larger organization, specialization of roles and teams naturally happens. When a blockchain needs to scale, a similar type of specialization is needed by creating separate but connected layers.

Like most things in the world of blockchain, the number of layers and naming is up for debate. For the sake of simplicity, let's look at the main three layers:

Layers of Blockchain
Source GetSmarter

Layer 1 - Protocol Layer - *The Accounting/Legal Team *

No, the sacred developer rule of starting with 0 has not been broken. Layer 0 is best described as the 'groundwork layer'. It is made up of physical components like the hardware and infrastructure to support Layer 1.

Layer 1, the protocol layer, is the base layer of any blockchain network. It supports the architecture as a whole and it is what proceeding layers are built on top of. This is where the familiar names such as Bitcoin and Etheruem 'live'.

In a business, Layer 1 would be the accounting and legal departments. It performs the slow but necessary work that requires due diligence and attention to detail. The main functions of layer 1 are:

  • Preventing "double-spend" - using a centralized or decentralized ledger to ensure that the same money promised to one party is not also promised or sent to another.

  • Building Consensus - using popular algorithms like proof of stake (PoS) or proof of work (PoW) to ensure all participating nodes agreed on the present state of the ledger.

  • Verification of Information - like the financial reviews of an accounting department, Layer 1 also acts as the source of truth for settling transactions.

This is a lot of responsibility for one layer to handle. And like the quote goes, "with great responsibility, comes a great amount of time to handle this responsibility". Since no one likes to wait, more scalable and faster solutions are required.

Layer 2 - The Networking Layer - *The Sales Team *

As anyone knows who has worked in any type of sales or commercial fashion, the ABC's of sales is "Always Be Closing". Like a skilled sales team, Layer 2 solutions want to process transactions faster and in an affordable way so that the customer keeps coming back.

There are many flavors of these types of solutions but at their core, they provide methods to escrow assets so that two or more parties can transact at a faster pace without involving the main chain (Layer 1) settling every time. These methods are growing in popularity as more and more transactions are hitting the popular networks.

Rollups

Rollups allow for computation of non-critical elements to the blockchain like executing the code smart contracts to be done off-chain. Information that is processed by the rollup on a sidechain is then 'rolled up' on to the main chain. This is done under one signature and added to a block as any normal transaction would. The two most popular approaches to this are Optimistic Rollups (OR ) and Zero-Knowledge Rollups (ZK). Optimistic rollups, like Polygon, send their final computations "optimistically" without any requiring proof of validation. ZK rollups, like zkSync, uses the cryptographic concept of zero-knowledge proofs which allow for a submitter to prove knowledge of certain information without exposing that information. It is the 'secret handshake to get into the club' of the blockchain world.

Sharding

Sharding achieves scalability by dividing tasks up into more manageable pieces and then spreading those tasks across the entire network. This allows for the necessary tasks of both validating and authenticating transactions to happen in sequential order and at the same time. This is the project manager on the team that lives and breathes on a JIRA board. It makes sure everyone is working dutifully and towards the same goal.

State Channels

State channels allow for a larger amount of assets to be committed to a certain transaction with the idea there will be several smaller transactions that are within this amount. In this case, a party can transact multiple times with another in an open state channel that is not committed to the main chain. Only after the parties agree to close the state channel, do the transactions get broadcasted and settled from each account. While there could have been many transactions that took place between the two parties, the main chain only sees two. This saves on compute for the settlement.

Layers of Blockchain
Source: @deversifi

Layer 3 - Application Layer - The Marketing Team

So we have established a base for the transactions to take place (layer 1) and made sure that these transactions can be done in a scalable fashion (layer 2). Now it's time to tell the world about our accomplishments! Like any good marketing team inside a company, you want to get your product out in the real world and have customers use it. This is where Layer 3 or 'the application layer' comes into the mix.

Like a magician that doesn't reveal its secrets, the goal of Layer 3 is to abstract away all of the work of the earlier layers to allow users direct interaction with applications. Through the creation of DApps (Decentralized Applications) that live on Layer 3, real-world use cases can be addressed to enable the greater expansion of blockchain technology.

Since the goal of layer 3 is to mask the unique technical and semantic aspects of a given network, this layer is also prime real estate for interoperability. As this area of research grows, innovations around layer 3 will be important to deliver a seamless user experience similar to the Internet Protocol. Hopefully one day we can say "Blockchain, it just works!".


Like any business, teams and structures can and will change. The layered architecture that we have currently may very well do the same. As Web3 continues to embrace new use cases and discover unknown challenges, investment in research and development for solutions will be needed. Luckily, there is a well-beaten path from the Internet Protocol to act as a guide for the future.

Photo by Chastagner Thierry on Unsplash

Top comments (0)