Hyperledger Fabric is becoming the most popular blockchain framework used by enterprises and medium-sized companies. Due to its flexibility and power, however, it can be difficult to understand. In this article we will be looking at its components and parts, and provide a gentle guide to getting started.
A Blockchain Primer
Before we delve into the good stuff, it is essential to understand what blockchain is, why it's important, and how it works. These are the first steps for getting into the world of blockchain and the frameworks which allow you to build on top of it.
Blockchain is a technology that allows for a distributed ledger that keeps track of all changes, or transactions that occur within a network. This ledger is decentralized and is hosted on every system that is a part of it (members of the system are known as nodes or peers), rather than one isolated server.
A blockchain network also uses a software module called a smart contract (also referred to as chaincode within Fabric), that allows for controlling access to the distributed ledger, automating processes, controlling aspects of transactions, and executing certain actions if defined conditions are met. Changes or transactions that take place within the network are ratified or rejected via consensus between all the members of a network. Once ratified, a transaction is then recorded to the ledger. Data or transactions occurring within the network and entered into the ledger get encrypted, stored into a block, and then become non-modifiable (or immutable).
For a more detailed overview of what blockchain is, how it works and why it is an incredibly revolutionary technology, please check out this article.
What is Hyperledger Fabric?
Hyperledger Fabric is a private blockchain framework and is one of many projects within the Hyperledger blockchain platform. The framework is used as a foundation from which to develop blockchain-based applications, networks, and more. Fabric (as it is often shortened to) was designed for creating private blockchains that can be used within a single organization or group of aligned organizations that link to other blockchain implementations. Fabric prioritizes several key features as part of its architecture:
- Privacy: Fabric requires all computers within its network to be identified; the prospective members of a Fabric supported network must join and identify themselves via a Membership Service Provider (MSP). This is what is called a "permissioned" membership. Maintaining the privacy of data is essential to many industries and this aspect alone makes Fabric an attractive option. It is important to note that Fabric does not require all parts of a blockchain to be permissioned; the necessity for permissions is decided at the discretion of whoever designs the network.
- Channels: Fabric provides the ability to partition ledgers into “channels,” where members of the network may create a separate set of transactions that are not visible to the larger network. This allows for more sensitive data to be segregated from nodes who do not require access.
- Scalability: Another appealing characteristic of Fabric for larger enterprises is the immensely scalable network that Fabric provides. Like other implementations, the number of nodes participating in the network can quickly scale; but the system is capable of still processing large amounts of data with a smaller set of resources. This allows for a best of both worlds approach. The blockchain can be created with a small set of nodes, and scale on demand.
- Modularity: Fabric’s architecture is designed to allow separate components to be added and implemented at different times. Many of the components are optional, and can be omitted completely or introduced later without affecting functionality. This feature is intended to give a company power over what is and is not necessary to implement. Some of the components that are considered modular, or "plug-and-play", include the method of achieving consensus, membership services for identification, the ledger store itself, specific access APIs, and chaincode integration.
With the aim of developing an incredibly scalable, permissioned, and secure framework powered by blockchain’s distributed ledger technology, Hyperledger Fabric is poised to take the world of corporate networks by storm. Fabric is already finding itself at the center of some incredible industry projects.
What Hyperledger Fabric is Not
With some idea of what Fabric provides, it's also important to understand what Fabric is not. Hyperledger Fabric is a block chain framework. It works together with other Hyperledger projects such as Burrow and Sawtooth to provide a scalable data platform. Hyperledger Fabric is a platform on which applications may be developed. Other members of the ecosystem, such as Composer, Quilt, and Explorer consume data from Fabric networks.
- Hyperledger Burrow: A modular client designed to function as permisssioned Ethereum smart contract interpreter as a node on a blockchain. Burrow executes smart contract code on a Ethereum Virtual Machine. Burrow is not considered a fix-all, or highly pluggable.
- Hyperledger Sawtooth: This modular Hyperledger platform is designed for creating, and deploying blockchains; it is also a platform for coding applications to interact with the blockchain. It also supports a number of different, pluggable approaches to reaching consensus.
Together (or apart), the platforms of Burrow, Sawtooth, and Fabric are either clients, or were created to advance the designing, implementation, and deployment of clients, applications, and blockchain solutions.
- Hyperledger Composer: Composer was a collection of tools for constructing the actual blockchain network used by Hyperledger platforms (primarily Fabric). Since August 2019, Composer has been phased out of use, and the functionality provided by Composer has been folded into Fabric itself.
- Hyperledger Quilt: Quilt is a Hyperledger tool that is meant to facilitate transfer of transactions between different blockchain networks, and even between blockchains and non-distributed networks. This is made possible by using the Interledger protocol.
- Hyperledger Explorer: This tool was developed primarily for accessing every bit of information within a blockchain network; the querying of blocks, accessing transactional data, members and respective nodes, info about the network itself, and just about everything that is part of that specific blockchain.
In this sense, it becomes easier to see the total role of Fabric within a blockchain networks' functionality. Whereas Fabric is a platform that allows for the definition, acceptance, and construction of data, the tools under the project of Hyperledger are geared toward accessing and consuming the data of a blockchain.
A Note on Hyperledger and Cryptocurrency
A central facet of Hyperledger is that as a project, Hyperledger is not a cryptocurrency. It does not use cryptocurrency in any form and was purposefully designed this way. Hyperledger is developed simply for advancing the technology of blockchain and providing a robust implementation of a highly scalable data storage technology. Fabric, of course, is merely a blockchain framework under the umbrella project.
It is important to keep in mind that blockchain provides just the foundation for an immutable database with a distributed ledger, and in turn for a decentralized form of currency to be developed as well. Blockchain itself is not Bitcoin or cryptocurrency in general. Hyperledger Fabric takes the foundation of blockchain and provides a framework on top of it, utilizing its qualities as a network. I this context, Cryptocurrency is a specific application of the technology, rather than the primary motivation.
Understanding that Hyperledger does not rely on a "proof of work" system that involves bitcoin mining, and by circumventing a reliance on any form of crypto (unlike blockchain frameworks under Ethereum), Fabric is more attractive to enterprises looking to adopt a new form of business-to-business transaction networking rather than a whole new currency.
Fabric Smart Contracts (Chaincode)
Smart contracts (frequently referred to within Hyperledger Fabric as chaincode), along with the ledger, are the most vital aspects of a Fabric network. In blockchain, smart contracts take on the role of lawyers, helping to trade money, goods, or whatever other assets are represented within the network. These contracts may set prices, lay out rules, outline agreements, and even delegate actions to be done when certain requirements are met. These can be limitless and as simple as paying a certain amount, getting a refund if goods aren't delivered, or giving digital receipts. These contracts take place within a blockchain as executable code.
These smart contracts take on a more familiar role within Fabric, acting as the literal contracts agreed upon between two professional entities when making a trade. Having smart contracts significantly simplifies the process of trading by automating processes and handling exchanges of payment. While the smart contract code handles executing all of the above, the chaincode is what deploys the smart contract into the network, so although they are developed together they tend to do different things.
Hyperledger Fabric Components
Like all blockchain-based technologies or platforms, Hyperledger Fabric is built upon a few central components:
- a distributed ledger for all data recorded about the transactions
- multiple peers (or nodes)
- smart contracts that maintain transaction logic
Also like most blockchain networks, transactions must be ratified by a consensus of all nodes entered to the ledger. In Fabric, this is referred to as an endorsement.
Peers (or Nodes)
Organizations and members are represented by peers themselves. Peers play an integral role within a blockchain network -- that is, they host instances of ledgers and smart contracts. In this way, peers are most vital in a Fabric blockchain when relating to transactions or the transaction workflow.
When a transaction is to take place the transaction must first be validated by a majority of the members of a network (represented as endorser peers), or a channel within a network. This process is called consensus. If you're a bit confused, don't worry - this complicated procedure is explained in depth later in the article.
In addition to consensus, peers take on additional roles within the transaction workflow. Within a channel they act as components, and provide infrastructure for the movement and processing of data. Some examples of these roles include:
- Orderer Peers - The peers (or nodes) that are specially designated as orderers, ensure that all the peers within a channel have the same updated ledger. In this sense, orderer peers ensure consistency of data and protect integrity of the ledger. Orderers also construct the blocks after the endorsement of a transaction and enter the record into them. The orderer peers, which are collectively known as the ordering service when working in cohesion, then mail out the new blocks to each peer within a channel to update their respective ledgers. The ordering service is a modular component. It is important to acknowledge that there are several methods for implementing this ordering service within a Fabric network:
- Solo - The Solo method is built upon utilizing only one orderer node within a network. It is simple to set up and just as easy to manage. This is useful for development environments, although becomes a bottleneck in larger networks. Worse, the solo method has no security in crash tolerance which puts production data at risk. As such, Solo is only recommended for testing and development purposes. It is recommended not to design upon Solo in a project in which you intend to later expand.
- Raft - Raft implementations are well suited to being used as a single node for both development, and being extended to multiple nodes within a production environment. Raft also includes some built-in crash fault tolerance. Raft implementations are simpler than setting up Kafka nodes as well and occasionally versatile in deployment.
- Kafka - Used primarily for production, Kafka is a sturdy distributed streaming platform that may publish to records, store records and process records. Like Raft implementations, Kafka is crash-tolerant. This comes at the expense of requiring that Kafka cluster be deployed and managed.
- Endorser Peers - Peers can be designated in the Endorser role. This is within the transaction workflow to either ratify a transaction request as valid and accept it to be added to the ledger, or refuse it outright. They handle execution of chaincode to do so.
Hyperledger Fabric CA
The Hyperledger Fabric CA (or Fabric Certificate Authority) acts as the Membership Service Provider for Hyperledger Fabric. It handles registration of members, certification, and regulation of nodes. As such, certificate authorities perform a central role in making Fabric a permissioned blockchain, registering members, keeping track of identities within the network, and removing deprecated accounts.
The Hyperledger Fabric CA server communicates with components of the Fabric network via REST APIs, which in turn interact with either a Fabric SDK that the client application was designed with, or a special instance of the Fabric CA client. The Fabric CA is an optional, modular component. More information may be found within the official documentation.
The distributed ledger is what makes blockchain special. This ledger is at the center of what Hyperledger Fabric is all about. It is within this ledger that you will find every record of every transaction to have ever taken place within a channel of the network, including details about a given transaction. These details include when the transaction occurred, between whom, how much it was for, what it was for, and just about anything else you might possibly want to know. It is this ledger (or ledgers, rather) that also protects the security of this data through blockchains famous immutability. Once added into the ledger, data cannot be modified in any way.
Ledgers are composed of the blocks of data. Their most important components include an ID, an up-to-date hash of the integrated transactions, and the hash of the previous block on which the current relies upon.
Interestingly, the blocks within the ledger not only keep a record of all transactions that have been endorsed and successfully entered, but those that were rejected during the endorsement process as well. This helps prevent re-submission and re-evaluation of already unapproved attempted transactions.