Hyperledger Fabric For Dummies

This article will increase your knowledge about Hyperledger Fabric.

If you are thinking of learning blockchain and do not know anything about the buzz word “Fabric”, then you are at the right place. I will also try my best to cover every concept associated with the Hyperledger Fabric.

Firstly, let’s start with a gentle introduction to “Hyperledger Fabric” and learn what it is.
 
So, Hyperledger Fabric is one of the projects carried by the Hyperledger Tree. It is an open-source permissioned distributed ledger that is specially designed for enterprise context only. It delivers some key differentiating capabilities or services over other ledgers and blockchain platforms.
 
Well, we all know that Hyperledger is a blockchain platform that provides distributed ledger solutions which are built based on the modular architecture due to which these solutions provide a high level of confidentiality, flexibility, & scalability.
 
The project has a diverse set of maintainers belonging to multiple organizations since its earliest commit.
 
It can provide you with innovations, versatility, and optimization because of its high level of modular and configurable architecture. As we know it is purely enterprise based so few of the use cases where it has been prominent in use are banking, finance, insurance, supply chain, healthcare, etc.
 

Smart contract in Fabric

 
In fabric language, smart contract is known as “Chain code” which functions as a trusted distributed application. It gains its trust & security from the blockchain and consensus algorithm used amongst the peers. It also serves as a business logic of the application.
 
Many blockchain platforms having smart contracts are able to follow “Order - Implement” flow in which the decision taking protocols are used as consensus protocol,
  1. Validates the transactions in order and send them to all the peer nodes that are part of that specific blockchain.
  2. Then the transactions are executed sequentially by all the peers.
The Oder - Implement architecture can be found in all the blockchain systems  whether they are permissioned / public platforms. In order to reach a specific final decision, smart contracts must be deterministic. Non - deterministic issues are handled by the smart contracts which are written in a non - standard or domain-specific language (such as Solidity).
 
There comes limitation in the performance and the scale just because the transactions are executed sequentially.
 

A New Approach

 
Fabric has introduced a new flow for transactions done on the chain which is known as “ Execute - Order - Validate ”. It solves the challenges like resiliency, flexibility, scalability, performance, and confidentiality faced by the flow described above.
 
This flow divides the transaction into 3 steps,
  1. Execute: Transaction is executed and verifying it’s correctness, thereby approving it.
  2. Order Transactions are ordered with the help of consensus protocol.
  3. Validate Transactions are again verified as per the application-specific approval policy before committing them in the ledger.
Here, application-specific approval policy can be described as which peer nodes or how many nodes are needed to assure the correct execution of a given smart contract. Thus, there is a subset of nodes which are allowed to verify or validate the transactions which satisfy the approval policy defined. Due to this parallel execution, performance and scale of the system can be increased.
 
Fabric is the 1st blockchain technology that allows the use of standard programming languages.
 

Privacy and Confidentiality

 
Fabric being a permissioned platform provides confidentiality capabilities through its channel model. In a Fabric network, the participants form a “Channel” between the subset of participants granting visibility on a set of transactions. Thus, access to the smart contract and data transacted is provided to only those nodes which are the part of the channel. Thus, in this way, Privacy and Confidentiality can be preserved.
 
Hyperledger Fabric For Dummies
 

Difference between Hyperledger Fabric and Ethereum

 
HYPERLEDGER FABRIC
ETHEREUM
Private network
Public network
No specific coins
Ether coin only
Chain Codes are written in Go and Nodejs.
Smart contracts are written in Solidity and Viper.
Mining reward: N/A
 Static block reward for winning block.
Consensus used: PBFT
 Consensus used: PoW
Key-Value typed database
 Account data
No built-in cryptocurrency
Built-in cryptocurrency called Ether.
 Confidential transactions take place.
Transparent transactions take place.
 
Hyperledger Fabric For Dummies

System Architecture

 
Advantages that Hyperledger fabric provides are,
 
Chaincode trust flexibility
 
The ordering service is provided by one group of the nodes (orderers) if some of them tend to fail or misbehave then this issue is being looked after by the endorsers' nodes which are different for each chaincode.
 
Scalability
 
As every chaincode has a different endorsers node to look after which helps the system to scale better than looking after all the functions by the same group of nodes.
 
Confidentiality
 
Architecture facilitates  deploying chaincode which fulfills the confidential requirement in context to contents and updates of the transaction done.
 
Consensus modularity
 
It uses modular architecture and allows pluggable consensus (i.e. ordering) implementation for decision making.
 
Elements of the Architecture
  1. System Architecture
  2. Flow of transaction endorsement
  3. Endorsement policies

System Architecture

 
Here, programs known as “Chaincode” are executed which store data such as state and ledger data and it also executes the transaction. Transactions are those functions which are invoked from the chaincode and for that they are supposed to be approved. Transactions are needed to be approved and in order to have an effect on the state it should be committed.
 
There exist “System Chaincodes” which is a collection of one or more special chaincodes for management functions and parameters.
 

Transactions

 
There are two type of transactions,
  1. Deploy Transaction: It creates a new chaincode which accept program as parameters. Upon its successful execution the chaincode is said to be installed “on” the blockchain.
  2. Invoke Transaction: It performs the function that are related to the deployed chaincode. Upon its successful execution, the chaincode executes specific functions that may involve modifying the corresponding state, and returning the output.

Blockchain data structure

 
State
 
The updated state of the blockchain is modeled as key-value store (KVS) where keys are names and values are random blobs. Chaincodes running on blockchain can manipulate the entries through put & get KVS operation. State are maintained by the peers only.
 
Ledger
 
It provides a history of all the successful state changes as well as unsuccessful attempts done for changing the state. It is kept at all peers and optionally, at a subset of the orderer. Ledger in context to peer is known as “PeerLedger” and ledger in context of orderer is known as “OrdererLedger”.
 
Node
 
They are the communication entities of the blockchain. A “Node” can be described as an only logical function in the sense that multiple nodes of different types can run on the same server.
 
There are 3 types of nodes,
  1. Client or submitting- client node
  2. Peer
  3. Ordering-service-node or Orderer

Conclusion

 
The differentiating capabilities of Fabric help in making highly scalable systems for permissioned blockchain which can help in supporting trust assumptions that help the platform to support a large industry use cases.
 
P.S. I don’t own rights to any photographs attached in the article except the screenshots.