How does Hyperledger Fabric works?

Hyperledger Fabric is a permissioned blockchain network that gets set by the organizations that intends to setup a consortium. The organizations that take part in building the Hyperledger Fabric network are called the “members”.

Each member organization in the blockchain network is responsible to setup their peers for participating in the network. All of these peers need are configured with appropriate cryptographic materials like Certificate Authority and other information.

Peers in the member organization receives transaction invocation requests from the clients inside the organization. A client can be any specific application/portal serving specific organization/business activities. Client application uses Hyperledger Fabric SDK or REST web service to interact with the Hyperledger Fabric network. Chaincode (similar to Ethereum Smart Contract) installed in peers causes to initiate transaction invocation request.

All the peers maintain their one ledger per channel that they are subscribed to. Hence Distributed Ledger Technology (DLT). But unlike Ethereum in Hyperledger Fabric blockchain network peers have different roles.

So not all peer nodes are same. There are different types of peer nodes with different roles in the network:

  • Endorser peer
  • Anchor peer
  • Orderer peer

Endorser peer

Peers can be marked as Endorser peer (ie Endorsing peer). Upon receiving the “transaction invocation request” from the Client application the Endorser peer

  • Validates the transaction. ie Check certificate details and roles of the requester.
  • Executes the Chaincode(ie Smart Contract) and simulates the outcome of the transaction. But it does not update the ledger.

At the end of the above two tasks the Endorser may approve to disapprove the transaction.

As only the Endorser node executes the Chaincode (Smart Contract) so there is no necessity to install Chaincode in each and every node of the network which increases the scalibility of the network.

Anchor peer

Anchor peer or cluster of Anchor peers is configured at the time of Channel configuration. Just to remind you, in Hyperledger Fabric you can configure secret channels among the peers and transactions among the peers of that channel are visible only to them.

Anchor peer receives updates and broadcasts the updates to the other peers in the organization. Anchor peers are discoverable. So any peer marked as Anchor peer can be discovered by the Orderer peer or any other peer.

Orderer peer

Orderer peer is considered as the central communication channel for the Hyperledger Fabric network. Orderer peer/node is responsible for consistent Ledger state accross the network. Orderer peer creates the block and delivers that to all the peers.

Orderer is built on top of a message oriented architecture. There are two options are currently available to implement Orderer peer:

  • Solo: Suitable for development. Single point failure. Solo should not be used for the production ready network.
  • Kafka: Production ready Hyperledger Fabric network uses Kafka as the Orderer implementation. Kafka is a messaging software that has high throughput fault tolerant feature.

Hyperledger Fabric Workflow

Hyperledger Fabric Workflow
  1. A participant in the member Organization invokes a transaction request through the client application.
  2. Client application broadcasts the transaction invocation request to the Endorser peer.
  3. Endorser peer checks the Certificate details and others to validate the transaction. Then it executes the Chaincode (ie. Smart Contract) and returns the Endorsement responses to the Client. Endorser peer sends transaction approval or rejection as part of the endorsement response.
  4. Client now sends the approved transaction to the Orderer peer for this to be properly ordered and be included in a block.
  5. Orderer node includes the transaction into a block and forward the block to the Anchor nodes of different member Organizations of the Hyperledger Fabric network.
  6. Anchor nodes then broadcast the block to the other peers inside their own organization. These individual peers then update their local ledger with the latest block. Thus all the network gets the ledger synced.