docker-compose-files/hyperledger_fabric/1.0.4
Baohua Yang 271918b5a9 Add config blocks and logs 2017-12-05 17:17:05 +08:00
..
config_update Support fabric 1.0.4 now 2017-11-02 10:19:05 +08:00
kafka Finish configtxlator usage 2017-12-01 23:11:37 +08:00
scripts Add config blocks and logs 2017-12-05 17:17:05 +08:00
solo Add config blocks and logs 2017-12-05 17:17:05 +08:00
Makefile Add config blocks and logs 2017-12-05 17:17:05 +08:00
README.md Update example code 2017-11-29 21:06:41 +08:00
base-dev.yaml Remove unused e2e staff 2017-11-02 10:29:33 +08:00
base-event.yaml Add event support 2017-11-02 11:31:08 +08:00
base-kafka.yaml Update chaincode path 2017-11-29 20:20:01 +08:00
base-solo.yaml Update chaincode path 2017-11-29 20:20:01 +08:00
base.yaml Add config blocks and logs 2017-12-05 17:17:05 +08:00
config.json Start with blockchain-explorer support 2017-11-17 22:04:18 +08:00
docker-compose-1orgs-1peers-dev.yaml Support fabric 1.0.4 now 2017-11-02 10:19:05 +08:00
docker-compose-2orgs-4peers-couchdb.yaml Support fabric 1.0.4 now 2017-11-02 10:19:05 +08:00
docker-compose-2orgs-4peers-event.yaml Fix #104: Remove unused files 2017-11-03 16:41:57 +08:00
docker-compose-2orgs-4peers-kafka.yaml Support fabric 1.0.4 now 2017-11-02 10:19:05 +08:00
docker-compose-2orgs-4peers-solo-be.yaml Fix while loop bug 2017-11-23 17:17:29 +08:00
docker-compose-2orgs-4peers-solo.yaml Fix while loop bug 2017-11-23 17:17:29 +08:00
fabricexplorer.sql Start with blockchain-explorer support 2017-11-17 22:04:18 +08:00

README.md

Hyperledger fabric 1.0.4

Here we show steps on how to setup a fabric 1.0.4 network on Linux (e.g., Ubuntu/Debian), and then use it to run chaincode tests.

If you're not familiar with Docker and Blockchain technology yet, feel free to have a look at 2 books (in CN):

Pass-through

The following command will run the entire process (start a fabric network, create channel, test chaincode and stop it.) pass-through.

$ make setup # install docker/compose, and pull required images
$ make all

tldr :)

make all actually call following command sequentially.

  • make start
  • make init
  • make test_cc
  • make stop

Otherwise, if u wanna know more or run the command manually, then go on reading the following part.

Environment Setup

The following scripts will setup the environment by installing Docker, Docker-Compose and download required docker images.

$ make setup # setup environment

If you want to setup the environment manually, then have a look at manually setup.

Bootup Fabric Network

Start a 4 peer (belonging to 2 organizations) fabric network.

$ make start  # Start a fabric network

The script actually uses docker-compose to boot up the fabric network with several containers.

There will be 7 running containers, include 4 peers, 1 cli, 1 ca and 1 orderer.

$ make ps
CONTAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS              PORTS                                                                                                NAMES
f6686986fe18        hyperledger/fabric-tools:x86_64-1.0.4     "bash -c 'cd /tmp;..."   6 seconds ago       Up 14 seconds                                                                                                            fabric-cli
c7f274bf60bc        yeasy/hyperledger-fabric-peer:1.0.4       "peer node start"        6 seconds ago       Up 11 seconds       7050/tcp, 7054-7059/tcp, 0.0.0.0:10051->7051/tcp, 0.0.0.0:10052->7052/tcp, 0.0.0.0:10053->7053/tcp   peer1.org2.example.com
c6c5f69f2d53        yeasy/hyperledger-fabric-peer:1.0.4       "peer node start"        6 seconds ago       Up 12 seconds       7050/tcp, 7054-7059/tcp, 0.0.0.0:8051->7051/tcp, 0.0.0.0:8052->7052/tcp, 0.0.0.0:8053->7053/tcp      peer1.org1.example.com
3cad0c519e6f        yeasy/hyperledger-fabric-peer:1.0.4       "peer node start"        6 seconds ago       Up 13 seconds       7050/tcp, 7054-7059/tcp, 0.0.0.0:7051-7053->7051-7053/tcp                                            peer0.org1.example.com
8b371209f6b8        yeasy/hyperledger-fabric-peer:1.0.4       "peer node start"        6 seconds ago       Up 11 seconds       7050/tcp, 7054-7059/tcp, 0.0.0.0:9051->7051/tcp, 0.0.0.0:9052->7052/tcp, 0.0.0.0:9053->7053/tcp      peer0.org2.example.com
ba1f00a9c83c        hyperledger/fabric-orderer:x86_64-1.0.4   "orderer start"          6 seconds ago       Up 14 seconds       0.0.0.0:7050->7050/tcp                                                                               orderer.example.com

Initialize Fabric network

$ make init  # Start a fabric network

The command actually calls the ./scripts/initialize.sh script in the fabric-cli container to:

  • create a new application channel businesschannel
  • join all peers into the channel
  • install and instantiate chaincode example02 for testing

This script only needs to be executed once.

You should see result like the following if the initialization is successful.

==============================================
==========initialize businesschannel==========
==============================================

Channel name: businesschannel
Creating channel...

...

===================== All GOOD, initialization completed ===================== 

And there will be new chaincode container generated in the system, looks like

$ make ps
CONTAINER ID        IMAGE                                 COMMAND                  CREATED              STATUS              PORTS                                                                                                NAMES
9971c9fd1971        dev-peer1.org2.example.com-mycc-1.0   "chaincode -peer.a..."   54 seconds ago       Up 53 seconds                                                                                                            dev-peer1.org2.example.com-mycc-1.0
e3092961b81b        dev-peer1.org1.example.com-mycc-1.0   "chaincode -peer.a..."   About a minute ago   Up About a minute                                                                                                        dev-peer1.org1.example.com-mycc-1.0
57d3555f56e5        dev-peer0.org2.example.com-mycc-1.0   "chaincode -peer.a..."   About a minute ago   Up About a minute                                                                                                        dev-peer0.org2.example.com-mycc-1.0
c9974dbc21d9        dev-peer0.org1.example.com-mycc-1.0   "chaincode -peer.a..."   23 minutes ago       Up 23 minutes                                                                                                            dev-peer0.org1.example.com-mycc-1.0

Test Chaincode

$ make test_cc # test invoke and query with chaincode

More details, see chaincode test.

Stop the network

$ make stop # stop the fabric network

Clean environment

Clean all related containers and images.

$ make clean # clean the environment

More to learn

Topics Description
Detailed Explanation Explain in detail how a 1-peer network start and test.
Fetch blocks Fetch blocks using peer channel fetch cmd.
Use Events Get events with block-listener
Artifacts Generation Will explain the usage of cryptogen and configtxgen to prepare the artifacts for booting the fabric network.
couchDB Use couchDB as the state DB.
kafka Use kafka as the ordering backend
configtxlator Use configtxlator to convert the configurations
[WIP] Some verification tests

Acknowledgement