In the first part of this series we discussed what the Hyperledger project is and all of the different frameworks and tools it hosts. In this post I will explore the Hyperledger Fabric and Hyperledger Composer in greater detail.
Below are some of the features of Hyperledger Fabric.
Hyperledger Fabric has been open source under the Linux Foundation, from the very beginning. It has been modified and improved by developers from all around the industry. Their expertise and contribution has made Hyperledger Fabric a robust and ever improving project.
Hyperledger Fabric is an enterprise solution. Cryptocurrency based blockchain technology frameworks are not good fit, since participants are usually anonymous. In a business model where multiple parties transact with each other, all the members need to be known to create trust and accountability.
Distributed Ledger Technology platform
Hyperledger Fabric is a distributed ledger technology. Simply put the data in Fabric is shared among the peers and any change has to be agreed upon by the endorsing peers. This ensures consistency. It is not bound to any central authority to control and update it. Each peer that needs to have the data has a copy of the information.
Highly modular and configurable
Hyperledger Fabric has a plug and play system for the components. Almost all of the components can be swapped out for something else. Different enterprise use cases’ needs require different consensus, identity management, key management, or cryptographic libraries. Hyperledger was designed with this in mind and can be configured to satisfy the solution necessary for most industry use cases.
Supports general purpose languages
In Fabric, smart contracts can be authored in general purpose languages such as Java, Go and Node.js, rather than having to use domain specific language (DSL). This allows industries to use the skill sets they already have instead of learning a new language.
Since Fabric is a permissioned network, all participants must be known and authorized to be able to invoke transactions. Hyperledger Fabric provides a membership identity service that manages user IDs. All participants on the network are authenticated and there can be layers of authentication levels to control the access at a individual level for each relationship.
Privacy and Confidentiality
The reason companies are looking into blockchain is because they want trust for their transaction. But privacy is also a big concern. Encryption is used to achieve confidentiality. But encryption is not always secure. Given enough time and computational power it can be broken. Since in a permissionless network, using proof of work for consensus, where the encrypted data sits in every node, the risk is higher. In a permissioned network such as Hyperledger Fabric, we can reduce that problem significantly by sharing confidential information to authorized parties by the means of “channel”. (More information on channels below)
Hyperledger Fabric is a distributed technology. This means to serve more people we can easily extend the network and add more peers to handle the additional nodes. In addition, the certificates and permissions can be managed at the organization level so the need for a central organization to handle a big network is not necessary.
Hyperledger Fabric Network
A Hyperledger Fabric Network consists of the following components.
Ledger is the core of any blockchain. It’s kind of a given with the name Hyperledger. Hyperledger Fabric’s ledger has two related components to the ledger. The ‘blockchain’ and the ‘state database.’ Blockchains are immutable. Once something is added to the blockchain it can not be modified. The state database is also called the world state. It records the latest update of any asset in the ledger. For example if there is a car that is being sold to many owners, the state database will hold the name of the newest owner. But the blockchain will have info of all the owners because every time there is a transaction from owner A to B it is stored in the blockchain database and info is updated on the state database. The transaction is done through chain code and requires consensus. More on that later.
Smart contract(s) (aka chaincode)
Smart Contracts is the business logic of a blockchain. Smart Contracts can do simple things such as an update to complex things such as executing a transaction with multiple parties and conditions involved. There are two different kinds of smart contracts — Installed and On-chain. Smart contracts are not unique to Fabric. Burrow, Iroha, and Sawtooth also support smart contracts. For Fabric the Smart Contracts are installed.
Fabric Certificate Authorities
The Hyperledger Fabric CA is the certificate authority for Hyperledger Fabric. CA provides registration of identities, issues enrollment certificates, and certificate removal and revocations.
Each organization (member) that takes part in the blockchain has their own peer setup for participating in the network. Peers are fundamental elements of the network. Each peer keeps a copy of the ledger and smart contract. All the peer needs to have their own certificates from the CA. There are three types of peers in Hyperledger Fabric : Endorser peer, Anchor peer and Orderer peer.
Endorser peers are responsible for validating transaction requests and executing the chaincode (Smart Contract). How many peers need to be endorsing peers depends on the organization. Number of endorsements needed depends on the business logic. Since all peers are not endorsing peers and only endorsing peers execute the chaincode, it makes scaling the network easier.
Each member org needs one or a cluster of anchor peer. Anchor peers are discoverable from outside the org they reside in. For different organizations to communicate to each other there needs to be at least one anchor peer on each of the organizations. For safety and fail over there are usually more than one (a cluster) anchor peer per organization.
Ordering peer is the central communication channel for Fabric Network. Ordering peer receives proposed ledger updates and delivers to all the peers.
Ordering service is a collection of ordering peers that orders transactions into a block. Ordering service is independent of the peer processes and works on a first-come-first-serve basis for all channels. Like most Fabric components, the ordering service has multiple pluggable options. The default is Solo which is suitable for development. This has a single point of failure, and is not recommended for production. For production use, Kafka is suggested.
Channel is the mechanism through which components in a blockchain network can communicate privately. In a business network, there is often the case where two or more parties need to transact among each other, but not the whole network. Hyperledger Fabric achieves this via channels. Each channel has its own channel specific ledger, member service provider, certificates, and rules.
Hyperledger Composer is a tool under the Hyperledger project with the goal of making blockchain application development easier. This is very useful in prototyping a business logic very fast. The composer interface does not have all the features of the Go, Java, or Node SDK. But is very useful for quick iteration and fine tuning the business network defin.
Hyperledger Composer has the following high level parts.
- Execution Runtimes
- Command Line Interface
- REST Server
- LoopBack Connector
- Playground Web User Interface
- Yeoman code generator
- VSCode and Atom editor plugins
We will discuss in detail how the workflow works in practice. But for now just keep the image above in your mind.
In the next post we will look into setting up our environment to develop using the Hyperledger Composer tool.