Layering in blockchain

Tanmay Garg
Nybles
Published in
8 min readNov 15, 2022
Image from blockchain Figma templates

With Web 3.0 gaining momentum in the present digital era and paving way for a new decentralised web, various MNCs and startups are trying to incorporate blockchain in their businesses due to one of its unique characteristics. This unique feature deals with the immutability of the data that is stored in a blockchain, where each user owns their data, and central players are less vulnerable to data losses and breaches. Technically, a blockchain is described as a decentralized digital ledger made up of blocks that record data across a peer-to-peer (P2P) network. Once data is entered into this ledger (a record that stores transactions), it is nearly impossible to remove, modify, or hack it. But ever wondered what a blockchain is built of 🤷?? To answer this question and to make the most of what blockchain has to offer, we need to understand the different layers which form a blockchain. I will be giving some insights in this blog regarding these various layers of blockchain.

When we discuss different layers of the blockchain, there are two significant ways to understand blockchain technology.

  • The first one is to apprehend how blockchain technology works. It consists of 5 primary layers — the hardware layer, the data layer, the network layer, the consensus layer, and the application layer.
  • The second division is based on certain protocols, which refer to the rules governing the blockchain network. This blockchain protocol is made up of four layers — Layer 0, Layer 1, Layer 2, and Layer 3.

One obvious question that can be raised is what actually this ‘layer’ refers to. 🤔 A Layer is basically just a ‘programming script’ containing various programs that give/add functionality to our blockchain.

The Blockchain Trilemma

Image credits: Forbes

A blockchain has three major pillars, which are the defining features of any blockchain, namely-

  • Decentralization: It should not be controlled by any centralized authority in any way, otherwise no distinction will be there between a blockchain and a simple database, where an authority controls everyone’s data. Greater decentralization signifies power is in the hands of people, which is what blockchain originally pursued.
  • Security: The data and the transactions that are done on this should be secured. Decentralization brings the required security because in a distributed system there isn’t a single point of failure like there is with our present client-server setups.
  • Scalability: The capacity of a blockchain network to sustain both an increase in the number of network nodes and an increase in the volume of transactions is known as scalability. To put it simply, one can get an idea of the scalability of a blockchain by considering the number of transactions that a blockchain can handle at a time.

The challenge is balancing all three in an effective manner. While any two of the three features frequently work well together, an emphasis on the third element must necessarily be given for building a perfect blockchain. A trilemma indeed. 😓

Facing this trilemma, many blockchains like Ethereum and Bitcoin are built only on two of these pillars, namely, decentralization and security as decentralization and security dovetail nicely with each other, but this leaves out scalability — increased decentralization compromises performance and speed.

Image credit: cointelegraph.com

It takes around 10 minutes for a block to mine on Bitcoin and it can only handle a maximum of seven transactions per second.

This makes it much less scalable as we cannot use it for our day-to-day transactions like paying any merchant, booking a flight ticket etc.

Division based on Blockchain Architecture

Layered Architecture of blockchain
  1. The hardware layer: This layer consists of hardware, like network connections, the computers within the network, and data servers. Data servers house the data that is kept inside a blockchain, and computers connected to the blockchain network can share this data with each other. As a result, a P2P network is developed in which each network node (or computer) independently verifies the information. Notably, the nodes form the heart of this layer. A device is referred to and regarded as a node when it joins a blockchain network. These nodes are distributed and decentralized on a blockchain network. Nodes are responsible for validating transactions, organizing them into blocks, broadcasting them to the blockchain network, and so on. In this layer, virtualization is included (creation of virtual resources such as storage, network, servers, etc.).
  2. The data layer: This layer is responsible for managing the information that is stored on the blockchain. This layer is made up of blocks of information with each block connected to the previous one with a hash. The genesis block is the sole one that is not connected to any other blocks (the first block in the network). A hash is a distinct data digest. A fixed-length hash value of the data can be produced by a cryptographic hash algorithm (like the SHA 256 algorithm). These hashes make it simple to recognize blocks and make it possible to spot any alterations that have been performed. Blockchain is essentially a chain of hashes because each block contains a hash of the previous block. Any new node connected to the blockchain will receive a copy of the blockchain network. Blocks are only added to the local blockchain if there is consensus.
  3. The network layer: This also known as the P2P layer fosters communication between the different nodes within the blockchain network. Additionally, blocks are created and uploaded to the blockchain in this layer. As a result, this layer is also known as the propagation layer. This P2P layer ensures that nodes can discover each other and can communicate, propagate and synchronize with each other to maintain the valid current state of the blockchain network.
  4. The consensus layer: The consensus layer is the core of the existence of blockchain platforms. This layer ensures one node cannot simply add a transaction to the blockchain; to do so, all nodes in the network must concur on it. The likelihood of fraudulent transactions being added to the blockchain is reduced by this level of verification. Following are some of the important characteristics of this layer-
    — Consensus keeps all the nodes synchronized.
    — Consensus guarantees that a single chain is followed and that it holds the truth.
    — Consensus ensures that power remains distributed and decentralized.
    — It specifies the rules that nodes must follow to ensure that transactions are validated within the boundaries of those rules and that blocks follow those rules.
    — Reliability in a P2P network is achieved by this consensus protocol.
  5. The application layer: This layer serves as the blockchain’s user interface and is basically what a user would run into when interacting with a blockchain network. This layer is comprised of smart contracts, chain code, and dApps. It facilitates the use of the blockchain for a wide range of purposes.

A Merkle tree is a binary tree of hashes. Each block contains a hash of the Merkle root with information such as the hash of the previous block, timestamp, nonce, the block version number, and the current difficulty target. It offers security, integrity, and invincibility for the blockchain technology.

dagsdf
The data layer: how blocks are connected to each other

Division based on Blockchain Protocols

  • Layer 0: Layer 0 is a network framework made up of hardware, connections, protocols, miners, and other elements that form the foundation of the blockchain ecosystem. It is where the network hardware (the internet and connected devices) coexist. It is the foundation on which the rest of the layers are built. Simply, it is just a program that has been named Layer-0. This program establishes the infrastructure of a blockchain for developers and also specifies how different blockchains interact with each other.
  • Layer 1: This layer of the blockchain provides security to the blockchain with different consensus mechanisms, like, PoW (Proof of Work) in Bitcoin and PoS (Proof of Stake) in Ethereum being a part of this layer. It provides security over layer 0. To better understand PoW and PoS, refer to the following article: jumpstartmag.com
  • Layer 2: This is considered the most important layer of the blockchain as most of the blockchains lack this layer, which deals with the scalability/speed of a blockchain. This is the layer that creates the distinction between Polygon and Ethereum blockchains as the polygon is the same as Ethereum with the only major difference being the presence of layer-2 with polygon, which makes it scalable and that is why it is used to a much greater extent than Ethereum to build projects. Similarly, the Bitcoin blockchain is quite slower and hence not scalable. Therefore, ‘Bitcoin Lighting Network’ (not a blockchain, but just a program that forms layer-2 for Bitcoin) was introduced in 2015, which is a layer-2 solution for the bitcoin blockchain.
Some of the most common Layer 2 solutions. To read more: cryptorobin.com
  • Layer 3: The blockchain protocol’s application layer is represented by this. Real interoperability is the primary goal of layer 3 solutions, which would be accomplished without the involvement of intermediaries or custodians. Simply, it is just a program that defines the UI interface of a blockchain. It consists of the various decentralized autonomous organizations (DAOs) and blockchain-based applications (Dapps) that are currently available on the market, such as Uniswap and CryptoKitties.
Image credits: @nick.5montana

With this, I would like to end this blog. Thank you and hats off! if you read it till the end 😁. If you are interested to know more: packt.com, horizen.io.

About Me:

Hi guys, My name is Tanmay Garg. I am a sophomore at IIIT-Allahabad & member of the Blockchain wing at GeekHaven, IIIT-A.

You can contact and connect with me on Linkedin and Github. Don’t forget to 👏 if this blog gave you some insights and clarity regarding the blockchain and its various layers.

--

--