Skip to content

Hyperledger Fabric Network with Working Kafka Consensus.

Notifications You must be signed in to change notification settings

skcript/hlf-kafka-network

Repository files navigation

Kafka Fabric Network

This repository holds the configuration and the sample chaincode for testing a kafka enabled network.

Introduction

The Hyperledger Fabric has introduced Kafka as it’s primary consensus mechanism among the orderers. While in development, for testing purposes, a solo config orderer is used. However, in production, you need to have multiple orderer nodes set up to have fail proof systems. In the case of a hardware/software failure, this is what will rescue you from critical situations. Kafka helps implement this easily. To understand in detail how all of this works, refer to this article [TODO].

Assumptions

You already know how to work with Hyperledger Fabric and deploy chaincode to the network in development. You are also comfortable with docker and docker-compose. To get comfortable with these topics, refer to these articles.

Network Architecture

We have a simple network configuration

  • 3 Orderers.
  • 2 Organizations.
  • 4 peers, 2 for each organization.
  • 4 Kafka broker instances.
  • 3 Zookeper instances.

Technical Documentation

Folder Structure

./
├── bin
│   ├── configtxgen
│   ├── configtxlator
│   ├── cryptogen
│   ├── fabric-ca-client
│   ├── get-docker-images.sh
│   ├── orderer
│   └── peer
├── chaincode
│   └── sacc.go
├── network-config
│   ├── configtx.yaml
│   ├── crypto-config.yaml
│   ├── docker-compose-base.yml
│   ├── docker-compose-cli.yml
│   ├── docker-compose-couchdb.yml
│   ├── docker-compose-kafka.yml
│   ├── docker-compose-peer-org3.yml
│   └── docker-compose-solo.yml
├── generate.sh
├── install.sh
├── README.md
├── start.sh
├── stop.sh
├── teardown.sh
├── test.sh
└── update.sh

3 directories, 24 files

Description

  • bin/ contains all the binaries required for generating crypto material.
  • chaincode/ contains the sacc chaincode, present in fabric-samples.
  • network-config/ contains all the configuration yaml files for the network.
  • generate.sh will generate all the crypto-material required for the network to run.
  • install.sh will install and instantiate the chaincode.
  • start.sh will start all the containers in docker-compose files.
  • stop.sh will stop and remove all docker containers, use with caution.
  • teardown.sh will kill containers and remove images generated by the network.
  • test.sh is used to test an invoke query.
  • update.sh is used to install and upgrade chaincode.

Steps

  • Make sure you've grabbed all the prerequisites and samples for running hyperledger fabric.
  • In your $GOPATH, make sure you have the hyperledger fabric source.
cd $GOPATH/src/github.com/
mkdir hyperledger
cd hyperledger
git clone https://github.com/hyperledger/fabric.git
  • Clone this repository and enter the directory.
git clone https://github.com/Presto412/Kafka-Fabric-Network.git
cd Kafka-Fabric-Network

NOTE : Give exec permissions to the shell scripts chmod 777 ./script-name.sh

  • Generate the crypto-material
./generate.sh
  • Start the network
./start.sh
  • Install and Instantiate the chaincode
./install.sh
  • Verify if all the docker containers are running
docker ps 
  • Test a sample invoke command
./test.sh
  • Stop every docker container and kill all the containers
./stop.sh

About

Hyperledger Fabric Network with Working Kafka Consensus.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published