Blockchain Architecture

prashun javeri
8 min readJan 13, 2019

--

Data layer: This layer acts as the block chain data structure and physical storage.The ledger is built using a linked list or Merkel trees , of blocks, which are encrypted using asymmetric encryption. The Data layer consists of the following components

Blocks : Blocks are data structures whose purpose is to bundle sets of transactions and be distributed to all nodes in the network. Blocks are created by miners. Blocks contain a block header, which is the metadata that helps verify the validity of a block.

Typical block metadata contains:

  • version — the current version of the block structure
  • previous block header hash — the reference this block’s parent block
  • merkle root hash — a cryptographic hash of all of the transactions included in this block
  • time — the time that this block was created
  • nBits — the current difficulty that was used to create this block
  • nonce (“number used once”) — a random value that the creator of a block is allowed to manipulate however they so choose

These 6 fields constitute the block header. The rest of a block contains transactions that the miner has chosen to include in the block that they created.

The first block in a blockchain is called as the genesis block ,It is the universal parent of all the blocks in the blockchain . Each block chain must have at least one block .

Merkel trees and transactions : the transactions in a blockchain are stored as part of a tree called as a Merkel tree . A Merkel tree summarizes all the transactions in a block by producing a digital fingerprint of the entire set of transactions, thereby enabling a user to verify whether or not a transaction is included in a block. Each leaf node is a hash of transactional data, and each non-leaf node is a hash of its previous hashes. Merkel trees are binary and therefore require an even number of leaf nodes. If the number of transactions is odd, the last hash will be duplicated once to create an even number of leaf nodes.

There are two ways the blocks can be identified. These are cryptographic hash and block height. The Merkel Root summarizes all of the data in the related transactions, and is stored in the block header.

Blockchain : A blockchain will thus consists all the transactions defined by user as linked together by storing the hash of the pervious block , where each block stores the root hash of the Merkel tree where the actual transactions are stored. transmission of blockchains across a given network is further secured using asymmetric encryption or public private key pairs .

Network Layer: The blockchain makes use of the distributed network, such that everyone downloads and interacts with all the information that is available on the Blockchain. the P2P network is used to propagate/broadcast transactions among nodes. One of the key issues is to fully utilize underlying network bandwidth.there are mainly 3 types of networks utilized by blockchain platforms

o Centralized networks: In case of a centralized network, we have a central network owner. The central network owner is a single point of contact for information sharing. The biggest issue with a centralized network is with a single central owner it also becomes a single point of failure. Further, with a single copy stored with the owner, every instance of access to the resource leads to an access issue with time.

o Decentralized networks: In a decentralized, non-distributed (or co-located) system, all the parts of the system are in the same physical location. With multiple central owners that have the copy of the resources. This eliminates the biggest problem of single point of failure with centralized network. With multiple owners, if a particular central node fails, the information can still be accessed from the other nodes. Further, with multiple owners the speed of access to the information is also reduced.

o Distributed networks: In a distributed network the nodes are not collocated but distributed geographically also It avoids the centralization completely. The main idea for the distributed network lies in the concept that everyone gets access, and everyone gets equal access.

Physical Layer: Consists of servers, edge nodes, IoT devices which act as nodes on the blockchain network.these are generally connected as a P2P network where Peers are equally privileged, equipotent participants in the application.

A node can be any active electronic device, including a computer, phone or even a printer, as long as it is connected to the internet and as such has an IP address. The role of a node is to support the network by maintaining a copy of a blockchain and, in some cases, to process transactions. Nodes are often arranged in the structure of trees, known as binary trees.Processing these transactions can require large amounts of computing and processing power, meaning that the average computer’s capabilities are inadequate.

A node can either be a communication endpoint or a point of communication redistribution, linking to other nodes. Every node on the network is considered equal, however certain nodes have different roles in the manner in which they support the network. For example, not all nodes will store a full copy of a blockchain or validate transactions.

A full node downloads a complete copy of a blockchain and checks any new transactions coming in based on the consensus protocol utilized by that particular cryptocurrency or utility token. All nodes use the same consensus protocol to remain compatible with each other. It is the nodes on the network that confirm and validate transactions, putting them into blocks. Nodes always come to their own conclusion on whether a transaction is valid and should be added to a block with other transactions, irrespective of how other nodes act.

Types of Nodes:

  • Root node — The highest node in a binary tree.
  • Parent node — A node that has other nodes extending from it.
  • Child node — A node that extends from a different node.
  • Leaf node — A node with no children.
  • Sibling nodes — Nodes connected to the same parent node.
  • Tree — A data structure of nodes starting with a root node.
  • Forest — A set of trees of nodes.

Virtualization Layer: Hardware virtualization layer used to allocate hardware and resources to virtual machines

Consensus Layer:· This layer deals with the enforcement of network rules that describe what nodes within the network should do to reach consensus about the broadcasted transactions. It also deals with the generation and verification of blocks. it’s just a method to decide within a group. Let me clear it up with an example. Imagine a group of ten people that want to make a decision about a project that benefits them all. Every one of them can suggest an idea, but the majority will be in favor of the one that helps them the most. Others have to deal with this decision whether they liked it or not.

Without consensus, blockchain is simply a way of storing encrypted/unencrypted data. Consensus allows it to decentralized because all the nodes in network follow the same rules and it will maintain uniformity in all the copies of a blockchain. So each and every change in a single blockchain is verified and adopt by another blockchain in the network.

When we speak about consensus, we mean the collaborative process that participating nodes of the network use to agree that a transaction is valid and to keep the distributed ledger synchronized at all times. These consensus mechanisms lower the risk of malicious (or fraudulent) transactions because they would have to occur (or be executed) across many locations at the same time, or else the tampering will be noticed almost immediately by other nodes. To reach consensus, the majority of the participants need to agree that the transaction is valid before it is permanently recorded in the ledger.

Once a transaction is permanent, no one, not even a system administrator, can delete the transaction from the ledger. The cost and time needed to reach consensus depends on the mechanism in place and the number of nodes participating in the consensus. the process of reaching a consensus on a high level include mining and propagation of blocks in the network defined by the consensus algorithm .

Example: two miners, miner A and miner B. Both miner A and miner B can decide to include transaction X into their block. A block has a maximum size of data. On the Bitcoin blockchain, the maximum size of a block is data up to 1 MB. But before adding the transaction to their block, a miner needs to check if the transaction is eligible to be executed according to the blockchain history. If the senders’ wallet balance has sufficient funds according to the existing blockchain history, the transaction is considered valid and can be added to the block. Miners will usually prioritize transactions that have a high transaction fee set, because this gives them a higher reward.this mined block is then propagated to other nodes where the transaction is individually executed until a majority of them are in the same state

There are various consensus models used in blockchains .These Blockchain consensus models consist of some particular objectives, such as:

  • Coming to an agreement: The mechanism gathers all the agreements from the group as much as it can.
  • Collaboration: Every one of the group aims toward a better agreement that results in the groups’ interests as a whole.
  • Co-operation: Every individual will work as a team and put their own interests aside.
  • Equal Rights: Every single participant has the same value in voting. This means that every person’s vote is important.
  • Participation: Everyone inside the network needs to participate in the voting. No one will be left out or can stay out without a vote.
  • Activity: every member of the group is equally active. There is no one with more responsibility in the group.

Incentive Layer:· This layer deals with the distribution of rewards that are earned by nodes in the network for the work they do to reach consensus. Whether this layer is implemented or not depends on the consensus mechanism in use.

The incentive layer include capabilities that describe what kinds of incentives are given by the network, when and how incentives can be earned by nodes, and the minimum amount of transaction fees needed to perform actions on the blockchain.

Contract Layer: consists of the services and optional components and serves to enable integration of the blockchain platform with other technologies these include

  • Data feeds
  • Smart contracts
  • On chain and off chain computing
  • Digital wallets
  • Digital ids
  • Multi signatures
  • Oracles
  • DAOs and governance
  • State channels

API Layer: provides application interfaces on top of the blockchain, and how third-party applications can interact with the digital ledger and smart contracts.

Application Layer:The application layer includes capabilities that provide applications on top of the blockchain.

--

--