Blockchain 3 Layer Architecture

Sahitya Kumar Suman
Jun 1, 2018 · 16 min read
Image Source : Google

We always refer the Blockchain as “The Blockchain not Blockchain” because it’s not the single technology that emerged from somewhere it is a collection of other algorithms and protocols that put together to form a single technology called The Blockchain. Most interesting part is when the first time Idea of The Blockchain is represented in its white paper given by Satoshi Nakamoto. In this white paper he never mentioned “The Blockchain” it was only mentioned as keyword called “chain of blocks” in it. He only referred the technology of the Bitcoin. Later Large corporations starting understanding the power of technology behind the Bitcoin then it is been named as Blockchain. Satoshi Nakamoto never invented Blockchain but He is the first person who represented such idea of The Blockchain. The technology that completes the blockchain is already in existence way before its main implementation started. The only thing that Satoshi Nakamoto did is put all those technical concepts in one box and gave birth to this technology which later named as Blockchain.

If we have to understand the concepts of the blockchain then we say it as 3 Layer model of a Software that completes blockchain and that’s it if as these layers mainly define The Blockchain software architectural level.

Design Layer

This means basically the properties that you need to define for your software in it. Design Layer contains all the basic rules of the software which makes it do work. For example Distribution, Decentralization, Immutability, and Peer-to-Peer.

In Design Goals, First key point is Data Distribution: So building any software system require two major point that is

  1. Data that you are collecting
  2. The action that you are performing with that data.

Data Distribution means that Database can’t be centralized because it go against the concept of the blockchain concept i.e Decentralization, And if every action that is being performed on Data and the point to access that Data is same then that System is Centralize and in such case if something goes wrong with this Central Server then the data will be lost forever and there is no other method to access or to process that Data in future. In opposite to this if the Data Distribution is Decentralized then the failure of any Single node which distributes the data doesn’t affect the other nodes to serve data to requesting node and data for which the Software System is developed will always be safe.
To get above problem we can say that every node that acts as a participant in the network should contain the copy of the all data-set on its own system just like Peer-to-Peer network. But again in the Decentralized system it can be a problem as anyone coming to this network and acting as Node can read and modify that data. To solve this problem what one can do is giving access to only a few of the node or the authorized node to modify the data in it and others have only the copy of data to serve it by synchronizing its data with a central node or the nodes that have access to modify it. Another major point of this design is that everyone on the network can read data and check the verification of the data on it which gives the transparency of the network to the public.

SO PRIVACY IS IN DANGER NOW, Well that’s what The Blockchain Solves very smoothly

Image Source : Google

Privacy and Scalability are two major problem that rise from here as every node’s had the data-set on their own system and they can see every data on it which might people don’t want and this problem is solved buy “Pseudonymity” in which an address is assigned to a user and people can receive and send transaction with that address and only thing that anyone had to prove that he/she own that address nothing else so the other nodes can see only the transactions done between address, not the actual person details. So in this way the actual identity of the person never revealed only data you will get is which address owns how much coin but to whom this address belongs is totally a mystery and hence everything is safe and secure.

When its come to solving the problem of scalability then the issue is about a volume of the data which keep increasing and every node in the chain should be updated about it all time. To keep other nodes sync with each and every node the easy way is to keep the operation only on the data and in this way each node will have known to this Idea that what are the modifications have been done to the latest changed data and whenever it comes in contact with other nodes that node can sync its data which its been lagging from other nodes and hence its own copy of the data catches the toe to toe with other nodes.
The main problems come up with this Idea that each node doesn’t store the snapshot of the data in it but the entire history of the data from its creation to the last update in the chain and because of this data set in the the node will only grow with time. People are working on this problem and there are solutions that are done with this but that discussion require a big time with another article.

Second Key goal: Decentralization, What we have discussed above is a good way to put the decentralization idea into the blockchain in which all nodes keep the data set but only centralize node have the access to change or modify the data. But if we think more about it then we will find it out that this point also kills the concept of decentralization which is key to all this Blockchain huluhulu. Suppose if all those node points from where Data-set can be changed or modified is hacked / compromised / corrupt /destroyed or is down due to any of the cause so every other node that stores the data is helping us to keep the data safe but we can’t change it or modify it which means the data set that is saved is almost had no meaning for now. And if anything happened to such key node then the data of the chain can be changed which is bad for Blockchain Idea. One of the most famous examples is Napster create by Sean Parker
(The guy in ‘The Social Network’ helps mark Zuckerberg to change “The Facebook” to Facebook played by Justin Timberlake that guy created this Idea).
So this is a big problem and the only way to solve this problem is when you are successfully able to distribute the data-set over the network and also decentralize the data at the same time. So if this happens then it almost impossible for anyone to corrupt the data and modify it. But the thing is if all the node making changing the data then major problems come up as the consistency of the data as if every node of this system is able to modify the data then how it will be synced with other data so that each and every node knows the modified data and make changes in its latest update. In The Blockchain, this problem can be solved with Consensus Algorithm[process in computer science used to achieve agreement on a single data value among distributed processes or systems]. This algorithm lives in every node in the entire network. This algorithm says the permission to change the data should be regular and random and other nodes will take that changes as the truth factor to implement in it and the point from where we are taking the truth of the node changes should be different every time.

Third Design goal, Immutability: When we are talking about a decentralized distributed system we can even change the data which can cause to update that data in each and every node. This can be done by rewriting the complete history of the chain. The first and the most famous implementation of the blockchain is done in the financial system so we can understand doing such change can bring a drastic change in the entire network and can cause a huge loss to one point and gain to another point. The algorithm that resides in each and every node of the network doesn’t allow you to change the data they simply allow you to just append the data so that if any changes which are not correct and appended in it can be discarded later on by confirming with other nodes with the form of transaction. And also anyone can track all the modification from starting to latest one to the first change in the network and that’s for what Blockchain is discovered for.

Fourth Key Design Goal, Trustless Enviourment: With such decentralized distributed system with Immutability should work in a trustless environment. For example, if any node wants to join the network then it can easily join it and start taking all the changing in the network by downloading all the data from it. With Trust-less environment I mean to say that trust should be built into the system rather than relying on the user for it. And this where the beauty of the blockchain comes up. Maintaining the consistency in a decentralized as distributed and immutable database where all the node trust each other is not that difficult but maintaining the same granty in a system where nodes can’t be controlled and the number cant be known in advance and where the trust can potentially diverge is the true factor of the entire network.

Bitcoin is one of the best examples of such implementation into the network with trustless environment. It is basically designed for Digital Cash system. The basic element of the transaction is keeping track on unspent transaction output or UTXo. UTXo is basically a digital equivalent of check once a check is chased in it can’t be used anymore and the author of the check has to give the signature of his to prove that he is the author of the check. Bitcoin transaction regroup the non-cash check as input and cashes them and produces a set of non-cash check as output. Any node in the network can create and sign such transaction and spread them across the network at which point they are at appending state and then in every 10 minutes there is a competition whose goal is to decide which node will append which transaction to the ledger. This appending competition happens automatically without any central supervision based on conses algorithm. In case of bitcoin it is called the proof of work concept, In simple language the network is saying “I have a very hard puzzle and the first one who find the solution of this puzzle will have to prove that he did solve this puzzle and the solution is proven and verified then the winner gets the authority to decide which transaction can be appended to the ledger and then we can start again”. To make the whole network efficient the transaction is grouped into the blocks of the transaction and those blocks get appended rather than a single transaction in the network. In this way whenever a node wins gets right to change the blocks latest transaction and spread over the network so that other nodes can update their dataset and start working on top of that changes made in the network.

Here is one thing that anyone can ask that what motivates anyone to participate in this challenging network and work on it. The answer is Winner in this whole game gets an opportunity to make one more transaction into the block that creates the amount of bitcoin and send it to themselves. The no of Bitcoin that should be created is decided by conses algorithm at the time of writing this article the amount of bitcoin that one can create is 12.5 bitcoin for every block and its get divided by 2 in every four years. This process actually severs two main goals

  1. This is the only method through which bitcoin gets created
  2. Put the interest of the miners to work in the network.

Implementation Layer

Now we need Trinity of Software Development (Just for fun)

Image Source : Google

This layer of the software basically contains the implementation of the Design goals that you have decided as the property of the Software System. You can choose to implement some of whole of the Idea in Design goal in it. If I say straight forward then its about getting ready for do some codebase or set of codebase which is mentioned in design layer. For example peer to peer, Immutitbility, or Decentreralization. The main aim for this layer is to create protocols how node is going to collaborate and communicate with each other. Bitcoin and Ethererum as the just few examples of Implementation of blockchain.

When we are talking about such system in implementational work then we can say that there is software created with open source code base in different languages and they all implement the same protocols and algorithms such that block produced by other versions should be accepted by other versions too. Every single implementation of this blockchain is always open source so that anyone can get that and check if the code is working what is supposed to work and its free from any security bugs.

As this is open source many of the developers downloaded that code and make a slight change in the code base or adding some new features in it helps them to create new cryptocurrency. Just like Ethereum, It is completely taken an idea from Bitcoin protocol and adding few new things to it and putting in between the miners to start mining this currency. Such implementation opens the path for others to notice that the generic implementation of blockchain can be used for different purpose opening a whole new level of the trustless system in the world. Such implementation in which previous Blockchain system is used to build on the top of the parent protocols called Sidechain. (Any new Blockchain implementation is done on Bitcoin blockchain will be called Sidechain of the Bitcoin Blockchain). Although Ethereum is very much inspired from bitcoin protocol there are some extra changes that are been done in it for example in Ethereum there are no UTXos because Ethereum block has the store state which makes it possible to store the balance of each account after each block.

In Bitcoin, the amount of time to make every block sync with the changed block is 10 minutes so that this changed block can be spread over the internet and existing blocks can update their data set and this decrease the chance of having two competing chains based on two different blocks calculated by non-synchronised miners.
In Ethereum this block delay is 12(previously it was 17 then changed to 15) second because of different implementation of conses algorithms.

Another one is in Ethereum transaction can be attached with turning code and this code can be run by any node in the network. This Turing code attachment to every node in the network helps to attach more sophisticated and logical code written in the “Smart Contract” which is a secure and non-editable way. So Giving such permission to execute this code on each node can also create a problem in it, for example, You can write a code in Smart contract with a loop like recursion without a base condition which will make it execute forever and this forever execution can let that node to jam the entire network. That’s why in Ethereum the developer creates the concept of gas which you buy with cryptocurrency called ether which is like payment for executing your every instruction written in your smart contract to get executed their Ethereum Virtual Machine.
It is very important to note that those principles which makes Ethereum is not written stone on the network or off the network so any individual blockchain implementation can decide to change the way to open up new possibilities or solve some of its problem for example currently the work is being done in the Ethereum to change the ‘Proof of Work’ concept to ‘Proof of Stake’ algorithm, the aim of this is to make Ethereum more efficient and less energy wasting protocol.

Bitcoin blockchain is implemented so that anyone can participate in the network and start working around. But later when Blockchain true architecture is explored then different kind of blockchain environment comes up and when I say different environment, Different enviourment of the blockchain means that who has authority to change and not to change the transaction.

Hpyerledger is kinda rebel in this case as it bend some of the principles of the blockchain design goal. Especially by dropping out Decentralization concept from The Blockchain and this gives a new term to us as Permission Blockchain which is centralized the power to make changes into the network which make sure that who has the right to change the dataset and who has the permission to see what changes are done. Since there is no goal to let anyone participate in the network and start mining for the blockchain these kinds of Blockchain mostly don’t have any cryptocurrency for. It feels little wired to see such implementation of theblockchain it’s like you Buy Playstation to play but you didn’t buy its controller through which you are gonna play the game.

Specialized vs Generic and Open vs Permission there are many implementations of blockchain out there and many more to explore too.

Instances : Now you have created your system with it and ready to put all those implementation on some sort of protocol either public or custom. For example Bitcoin nodes communicate with each other on TCP protocol but this TCP protocol is customized by the developer means its not the typical TCP protocol which is used by Bitcoin node to communicate with each other. And when you created your protocol for the system then you are ready to create the instance of the system as many as you want. As of giving the Idea these instances are the different instance which work side by side and also working on different data-set i.e Ledger to build a different version of the whole network which can be used for different purpose for example Ethereum has four of its public instances ie.

  1. Kovan
  2. Rinkeby
  3. Ropsten are the test instances
  4. Main Ethereum network instances for production one.

These are the instance that are publically available and if you are using meta mask as the plugin in your Chrome or Firefox browser then you can see all these instance in it.

You can not only use these but you can also create your own private network for development purpose. These are the example of Ethereum if you look to other implementation of blockchain then you will find the same implementation with varying network. This is the major layers of the Block-chain that is being used in it and whenever we say The Blockchain Network behind the scenes these three layer exist.

So The Blockchain is something made up of Data Structure to store the history of all the modification on a state where the operations are bundled in a block. or we can say that the blockchain protocol is build to store the blockchain history and this history begins with the first block that we call Genesis block.

Genesis block is very much special than any other block of the blockchain because it doesn’t have any parent block like other and you can the Genesis block as the God block of the same blockchain because everything in that blockchain started for because and from there so there are few things that Genesis block cant do what other blocks come after it can able to do. Once you started the genesis block any system your blockchain network start working. The starting of this genesis block is called instantiation of the blockchain. And you can create your own genesis block with an exact same copy of the instruction in other blockchain and people can participate in that network to check things.

Every Instance of the network has Main Instances called the Production Instances of the network. Blockchain protocol like Ethereum had few of the instances one is Production and other three are test instances so that developer can test their smart contract on these test instances before putting it on Production Network. And this gives you also a permission to create your own genesis block and creating your own private network and thus you can implement your own instance.

It is very important to note here that cryptocurrency created at one instance cant be used on other instances even everything has the same implementation, for example, you cant use your ether created on a test network of the Ethereum on Main or Production chain or vice-versa. Because the creation and movement of these ether simply happen in the different ledger on a different network.

There can be a possible situation where you started a blockchain network from your genesis block and at some certain point you and your blockchain developer tried to improve it with some changes in it and now there are two group of people who are supporting you for your blockchain.

  1. The first group of people is following the old or the origin history of the blockchain and still following the same chain even after the improvement done by your team.
  2. The second group of people is those people who are following those chain of the blocks which causes the change in it means are they are following the new chain of the group.

This situation of the block is called fork of Blockchain. Always remember that the fork is happening on the Blockchain history started from same Genesis block. It is not necessary that fork in the blockchain always happened due to improvement in it sometimes it happens because of some sort of bug in it and sometimes it takes place voluntarily by the group of people. This fork is very important for the economy of the blockchain as the value of the cryptocurrency supported by that blockchain is totally dependent on the no. of people are following it. When a fork happens the currency created after the fork can only be spent on the same chain created after the fork. and both chains had the effect to lose some of the value in it. This is what happened on June 16 last year when an attacker tried to attack it. Some group of the people decided to follow the previous or the old blockchain while other decided to update the software to follow new blockchain. In case of Ethereum when the fork happened there are two group of people come up to follow their own blockchain of it Majority of the people who followed the old rules called Ether or ETH and a new group with minority started following with new one is called Ethereum Classic.


Sahitya Kumar Suman

Written by

Full Stack Android Engineer →Blockchain Developer.