After our 1st edition of the series on "Hyperledger Fabric" which has given a brief introduction to this technology. Now it's time to move on to our next chapter where we'll discuss the core architecture of Hyperledger Fabric. In this second chapter of our series on "Hyperledger Fabric," you'll have a solid grasp of the system's architecture and be well-equipped to leverage its potential for your own blockchain projects. We'll also explore the underlying components and their interactions within the Fabric. Let's begin!
Introduction to Hyperledger Fabric
Hyperledger Fabric is an open-source, permissioned blockchain framework designed for enterprise use. Its architecture allows for the creation of private, secure, and scalable blockchain networks tailored to specific business needs. Fabric offers a modular and extensible approach, making it a popular choice for various industries, including finance, supply chain, healthcare, and more. HF allows organizations to create private networks where participants are known and must be granted permission to join. This enables confidentiality and control over who can participate and access data on the network.
Key Components of Hyperledger Fabric
The key components of HF that make up its architecture are as follows:
a. Peer Nodes:
Peer nodes serve as the primary execution environment within a Fabric network. They maintain a copy of the distributed ledger and execute smart contracts, known as chain codes. Each organization participating in the network typically has one or more peer nodes. Peer nodes are the instances of the Hyperledger Fabric runtime that maintain a copy of the shared ledger and smart contracts (chaincode). They are distributed across the network and communicate with other peers to maintain consensus and ensure the validity of transactions.
Types of Peer Nodes:
Endorsing Peers: These peer nodes receive transaction proposals from clients, execute the chaincode, and return the results along with an endorsement signature. Endorsing peers don't update the ledger but are critical for achieving transaction endorsement.
Committing Peers: After receiving the endorsed transaction, committing peers validate the endorsements and ensure the correctness of the endorsements before committing the transaction to the ledger.
Anchor Peers: These are specific peers in each organization that maintain communication with peers in other organizations. They are used to facilitate cross-organization communication.
b. Membership Services Provider (MSP):
The MSP manages the identity and access control policies for participants in the network. It authenticates and authorizes network participants, ensuring secure interactions. MSPs enable flexible membership models, such as Certificate Authorities (CAs) and token-based systems. It is a module within HF that manages identities, certificates, and cryptographic materials for the participants of the network. It is responsible for authenticating and authorizing network entities, such as peers, orderers, clients, and administrators.
MSP handles the creation, issuance, and revocation of digital certificates that serve as the identity credentials for network participants. These certificates are used to prove the authenticity and authority of an entity to access the network and interact with other peers.
Certificate Authorities (CAs):
MSP relies on Certificate Authorities to issue certificates to network participants. There are two types of CAs in Hyperledger Fabric:
Registration Authority (RA): RA is responsible for authenticating users and clients and registering their identities with the CA. It verifies the identity of the entity requesting the certificate.
Intermediate Certificate Authority (Intermediate CA): Intermediate CAs are used to issue certificates on behalf of the root CA. They are often deployed to create a hierarchical structure for certificate issuance, enhancing security and manageability.
Hyperledger Fabric allows the creation of multiple MSPs within a single network, each representing a distinct organization. This enables multi-organization consortium networks with separate identity management for each organization.
c. Orderer Nodes:
Orderer nodes manage the consensus mechanism in Hyperledger Fabric. They receive endorsed transactions from peer nodes, package them into blocks, and establish a total order of transactions across the network. Fabric supports multiple consensus algorithms, including Kafka, Raft, and others. Orderer nodes are responsible for receiving transaction proposals from clients, ordering them into blocks, and delivering the blocks to the endorsing and committing peers in the network. They establish a consistent transaction order and ensure that all peers have a synchronized view of the blockchain ledger.
Types of Orderer Nodes:
Solo Orderer: In a development or testing environment, a solo orderer node can be used. It operates as a single, centralized entity responsible for ordering transactions.
Kafka-based Orderer: In a production environment, a Kafka-based orderer service is commonly used. It employs Apache Kafka, a distributed streaming platform, to achieve fault tolerance and scalability.
Raft-based Orderer: Hyperledger Fabric 2.0 introduced a new consensus mechanism called Raft. Raft-based orderer nodes utilize the Raft consensus algorithm to achieve fault tolerance and consensus.
Channels in Fabric allow for the segregation of network participants into smaller, private subgroups. Each channel has its own ledger and chaincode, ensuring data confidentiality. Channels enable secure collaboration between specific parties without revealing information to the entire network. Channels in Hyperledger Fabric are private subnetworks within a larger blockchain network. They allow a subset of network participants to create a separate communication and transaction layer, ensuring privacy and confidentiality for the transactions and data shared within the channel. They are particularly useful in scenarios where multiple organizations need to collaborate while maintaining data privacy. They are commonly used in supply chain management, financial networks, and any other scenario that requires selective data sharing among participants.
It has a lifecycle that involves installation, approval, and activation. This ensures that chaincode is properly deployed, reviewed, and endorsed by the relevant network participants before being executed. This crucial components of Fabric defines the rules for transaction processing, data validation, and state updates, enabling secure and decentralized execution of business processes.
The distributed ledger in Fabric maintains a tamper-proof record of all transactions executed within the network. It is implemented as a combination of the world state and the transaction log. The world state represents the latest values of assets, while the transaction log ensures immutability and transparency.
Types of Ledger:
Hyperledger Fabric maintains mainly two types of ledgers that are as follows:
Transaction Log (Blockchain): This ledger contains an immutable, ordered log of all the transactional data, organized into blocks. Each block contains a batch of transactions.
World State: The world state ledger maintains the current state of the blockchain network after applying all the transactions. It represents the most recent state of all assets and data within the network.
Transaction Flow in Hyperledger Fabric
In Hyperledger Fabric, the transaction flow consists of three main phases: the execution phase, the ordering phase, and the validation phase. Let's explore each phase in detail:
#1. Execution Phase:
Transaction Proposal: The transaction flow begins when a client initiates a transaction by creating a transaction proposal. The proposal includes the details of the requested operation and input data. The client interacts with the Fabric network through an application or SDK.
Endorsement: The client sends the transaction proposal to endorsing peers in the network. The endorsing peers simulate the transaction by executing the proposed operation using the smart contract (chaincode) associated with the transaction. They then endorse the transaction by signing the results.
Endorsement Policy: The endorsement policy specifies the required number of endorsements for a transaction to be considered valid. The policy can be customized based on the network's requirements, such as requiring endorsement from a majority of peers or a specific set of organizations.
#2. Ordering Phase:
Transaction Assembly: After obtaining the required endorsements, the client assembles the endorsed proposals into a transaction.
Broadcast to Ordering Service: The client broadcasts the transaction to the ordering service, which is responsible for collecting and ordering transactions from various clients.
Consensus: The ordering service uses a consensus algorithm to agree on the order of the transactions and create a block containing the ordered transactions. Consensus ensures that all participating ordering service nodes reach an agreement on the transaction order.
#3. Validation Phase:
Block Distribution: Once the block is created by the ordering service, it is distributed to all peers in the network.
Transaction Validation: Upon receiving the block, each peer independently validates the transactions within the block. Validation includes verifying the digital signatures, checking for policy violations, and ensuring that endorsing peers is legitimate.
State Update: Valid transactions go through the state update process, where peers execute the transactions and update their copy of the ledger accordingly. The ledger maintains a complete history of all valid transactions.
Consensus Verification: Peers participate in a consensus protocol to ensure that all valid transactions have been executed correctly. This verification process ensures that all peers have the same view of the ledger and that the transactions comply with the consensus rules.
By following these phases, Hyperledger Fabric ensures that transactions are executed, ordered, and validated in a secure and consistent manner across the network. This transaction flow, along with Fabric's modular architecture, endorsement policies, and consensus mechanisms, contributes to its robustness and suitability for enterprise blockchain applications.
Some of the common benefits of HF architecture are as under:
Fabric's modular architecture allows for horizontal scalability, with multiple peer nodes processing transactions in parallel. It is designed to support high transaction throughput and scalability. Its architecture allows for the partitioning of the network into smaller sub-networks called channels. Each channel can have its own smart contracts and transaction logic, enabling parallel processing of transactions. This partitioning capability enhances scalability by allowing different channels to operate independently and process transactions in parallel.
b. Privacy and Confidentiality:
The concept of channels provides data segregation and privacy, enabling secure collaboration between specific network participants. It provides a modular architecture that allows for the separation of components such as consensus, membership services, and smart contracts. This modularity enables organizations to tailor the blockchain network to their specific needs. Fabric, in addition, supports private transactions by utilizing channels and endorsing peers. Private data can be shared only with authorized participants, ensuring confidentiality and privacy within the network.
Fabric's pluggable consensus mechanism and support for various programming languages offer flexibility in designing and deploying blockchain applications. It offers pluggable consensus, which means that different consensus algorithms can be used within the same network. This flexibility allows organizations to choose the consensus mechanism that best suits their requirements, whether it's a practical Byzantine fault-tolerant (PBFT) consensus algorithm, a crash fault-tolerant (CFT) consensus algorithm, or even a combination of both. The ability to choose consensus algorithms enhances network resilience, performance, and customization options.
d. Security Features:
Fabric incorporates several security features to protect the network and its data. It utilizes a permissioned network model, where participants must be authenticated and authorized to access the network. Fabric's endorsement policy and validation mechanisms ensure that only authorized transactions are committed to the ledger. It also supports the use of private channels, where sensitive data can be shared only with specific participants. These security measures make Hyperledger Fabric suitable for enterprise use cases that require data confidentiality and integrity.
e. Auditability and Transparency:
Hyperledger Fabric maintains an immutable ledger that records the complete history of transactions. This transparent and auditable ledger enables organizations to trace and verify every transaction that has occurred within the network. The ability to audit and verify transactions is crucial for compliance, accountability, and regulatory purposes.
f. Smart Contracts Support:
Understanding the architecture of Hyperledger Fabric is crucial for harnessing its potential in building robust blockchain solutions. In this chapter, we explored the key components, transaction flow, and benefits of Fabric's architecture. Armed with this knowledge, you're now ready to embark on the journey of leveraging Hyperledger Fabric's power for your enterprise blockchain projects. Stay tuned for the next chapter, where we'll delve into the advanced features and functionalities of Hyperledger Fabric.
For more information on our innovative enterprise-grade blockchain solutions, schedule a talk with our experts today!
Get started with Spydra
Spydra is a next-generation API driven Decentralization-as-a-Service platform to enable business and developers to leverage the full potential of Blockchain and the Decentralized Web Infrastructure.