Kapil Sachdeva

Bootstrapping the Hyperledger Fabric Network (Part 2)


In the Part 1 I talked about the various entities in the Hyperledger Fabric Network and ended up creating certificates & private keys for them using cryptogen tool.

In this post I will try to run the ordering service (consists of only 1 node). Hyperledger Fabric project provides docker images that can be easily customized by either using them as base image and/or by providing the environment variables and volumes to provide the input data.

Because of the heavy usage of docker tools (specially Docker Compose) I would strongly suggest that you first acquaint yourself with it. One of the best resources other than the documentation provided by Docker is an open source tutorial called docker-curriculum.

Here is a list of items we need to start the Ordering service:

  • Trusted root certificates for various entities participating in the network
  • Orderer certificates and the IP addresses
  • Properties of various algorithms used by network (e.g. crypto, consensus etc)
  • Access control policies

All of the above information except the private keys for the Orderers is captured in genesis block. Hyperledger Fabric project provides a tool called configtxgen (that also got downloaded by the script that we executed in Part 1) and very much like cryptogen this tool requires a yaml input file so as to generate the genesis block.

The Hyperledger Fabric wiki provides a good information on what is expected in the yaml file expected by configtxgen tool. Here is the one that we would use:

Things for you to note are MSP directories specified in the yaml file. If you will go inside these directories (note - crypto-config directory was created by cryptogen tool in the Part 1) to see that they contain only public certificates and no secret key material.

Time to generate the genesis block

configtxgen -profile ThreeOrgsOrdererGenesis -outputBlock ./genesis.block

The genesis.block is a binary file. If you want to inspect the contents of it you can issue following command :

configtxgen -profile ThreeOrgsOrdererGenesis -inspectBlock ./genesis.block

Now we have all the pieces that are required to start the orderer service. We will use docker compose to specify the various environment variables and mapping of artifacts (certs, keys, genesis block etc) that we have generated using the volumes. Here is the file :

In order to execute it use following command:

docker-compose -f docker-compose-orderer.yaml up

If you inspect the running containers (docker ps -a) you should now see a container named orderer.ksachdeva-exp.com. Also look at the logs that are generated when you started the orderer service.

If you want to run the orderer service in the background then use following command -

docker-compose -f docker-compose-orderer.yaml up -d

Similar Posts

Comments