BackgroundBlockchain has gained lot of traction through bitcoin (and other cryptocurrencies.) It generated a lot of interest from technologists on applications of blockchain in areas other than payments. So much that entreprises took strong notice and started thinking how they can make use of this new technology for themselves. Hyperledger Fabric was born by one such effort by IBM.
What are we trying to achieve in primer?It’s a simple walkthrough of the most important aspects of hyperledger fabric as a permissioned blockchain. This article is meant for both developers and managers who want to understand Hyperledger Fabric and start generating ideas on how it could be beneficial to your business case. This is not a developer overview.
Prerequisites for understanding this primerA basic knowledge of what distributed ledgers mean and an interest in what blockchain technology can do. Check out this link to get a better understanding on distributed ledgers.
Why was Hyperledger Fabric developed?A prerequisite for public blockchain is that, all data needs to be accessible publicly. Unlimited copies of the same data are maintained in the network. Anyone can join the network and become a participant and create their own copies of the data. Confidentiality is maintained by making the data intelligible only to certain participants whenever needed. This is a necessary prerequisite for achieving the level of proclaimed security (transparency, trust, availability, fault tolerance to hardware failures and malicious attacks on individual nodes). Hyperledger Fabric, on the other hand, allows for permissioned and private blockchain network, where, sensitive data can be protected from the public, yet, exchanged only between trusted entities. In permissioned blockchain, the owner has the privilege to decide on the users and organisations that take part in a particular transaction.
Why do we need private blockchains?Public blockchains allow for anonymous users to take part in the consensus process; a process involving read and write operations. This allows for anonymous entities to create valid blocks and commit them to the ledger. Anonymous participants, however, are not suitable for all applications. For example, imagine a record for legal purposes: maintaining of land ownership records. Here, regulations enforce that the identity of every participant (be it a seller, buyer, surveyor or lender) needs not only to be known, but also to be validated as legitimate. Anonymous parties aren’t allowed to create a transaction.
This is when a private blockchain comes into play. In this type, the blockchain consists of organizations that have some amount of trust already established among themselves, but want to simulate the trust provided by an unbiased middleman. The distributed ledgers are only available to the the participants of the network and cannot be viewed by public. Hyperledger Fabric provides the tools and techniques to achieve such a system. In order to learn more about the difference between public and private blockchain, check out this link
Few Important Concepts
Ledger – The modifications to the states of the ledger are stored within blocks. A collection of these blocks is called the ledger. Each participating peer maintains a copy of the same ledger. These ledgers contain all the blocks that have been added since the time the network was created. Each block on the ledger consists of information regarding the transaction as well as the hash of the previous block. This hash is later used while endorsing a transaction.
State – This refers to the state of the blockchain which is stored as a key value pair. Any changes to the blockchain is a change to this state and is recorded and stored here. The state of a blockchain is a versioned key-value store which refers to the data stored. These states are manipulated by the chaincode. The state is stored persistently and changes to it are recorded. The ledgers keep track of all the successful state changes. States are only maintained by peers.
Transactions – Any exchange of assets on the network takes place through transactions. There are two types of transactions. Deploy transactions are the ones that take a chaincode program as a parameter and install a chaincode on the channel. The other types is the Invoke transactions which refer to a function of the previously installed chaincode and take the parameters for that function.
Committing Transactions – Every peer acts as a Committer, where in, a copy of the valid transaction is stored on their local copy of the ledger . Before any transaction is committed, the peers validate the transactions and mark them as valid or invalid. The transactions are committed to the local copy of the ledger stored by each of the peers after reaching consensus.
Endorsing Transactions – Some peers are named as Endorsers for certain transactions as per the Endorsing Policies. Such peers must execute the chaincode and return a proposal response to the client application. The proposal response includes information such as the signature that proves that the transaction was executed by this peer, the chaincode execution response, events as well as the result of the transaction. The Endorsement Policy specifies the peers that must execute the transactions as well as specify the combination of the endorsements required. A transaction must be acknowledged as valid by the endorsement policy before it can be committed.
Peers – Nodes refer to all types of participants of a blockchain network. This includes orderers, endorsers and committers. The nodes that perform transactions and commit them are called peers. These peers maintain the ledgers and can optionally act as endorsers as well. An organization can contain multiple peers. Endorsement policy determines the peers that will take part in validating a transaction. A peer responsible for endorsing transactions is called Endorser and every peer acts as a Committer.
Anchor Peers – Anchor peers are special peers that bear the responsibility of communicating with other Anchor Peers outside the organization. While, peers inside an organisation communicate freely, anchor peers are the gateway through which communication with peers outside the organisation is facilitated.
Orderer/Ordering-service-node – This node has the responsibility of placing the orders for transactions as well as broadcasting the same to all the participating nodes.
Fig: Smart Contracts