Skip to content
This repository was archived by the owner on Dec 14, 2020. It is now read-only.

Executing the ordering service outside docker v1.2 & v1.3

jcs47 edited this page Oct 16, 2018 · 1 revision

If you need to fiddle with the code outside of any docker container, read the page explaining how to compile the code before proceeding with these instructions.

Make also sure to set the $FABRIC_CFG_PATH environment variable to the absolute path of the ./sampleconfig directory of the fork. You should be able to do this by typing export FABRIC_CFG_PATH=$GOPATH/src/github.com/hyperledger/fabric/sampleconfig/ in the command line. If you are using multiple terminals, you might need to type this command in each one of them.

Launching 4 ordering nodes and a single frontend

The first step is to generate the genesis block for the ordering service. Make sure the parameter Orderer->Addresses in the ./fabric/sampleconfig/configtx.yaml file is set to - 127.0.0.1:7050. Next, generate the block as follows:

cd $GOPATH/src/github.com/hyperledger/fabric/
./.build/bin/configtxgen -profile SampleSingleMSPBFTsmart -channelID <system channel ID> -outputBlock <path to genesis file>

The <path to genesis file> argument should match both the absolute path in the GenesisFile parameter in the General section in of the ./fabric/sampleconfig/orderer.yaml configuration file and the GENESIS parameter in the ./hyperledger-bftmart/config/node.config. Keep in mind that in the case of this ordering service, the GenesisMethod parameter must always be set to file. Otherwise the frontends will generate genesis blocks distinct from the one loaded by the ordering node, thus leading to inconsistencies.

After creating the genesis block, edit the ./hyperledger-bftmart/config/hosts.config file with the loopback address for your machine. It should look something like this:

#server id, address and port (the ids from 0 to n-1 are the service replicas) 
0 127.0.0.1 11000
1 127.0.0.1 11010
2 127.0.0.1 11020
3 127.0.0.1 11030
7001 127.0.0.1 11100

Next, enter the main directory for this repository and execute the startReplica.sh script in 4 different terminals as follows:

./startReplica.sh 0
./startReplica.sh 1
./startReplica.sh 2
./startReplica.sh 3

Once all nodes have outputed the message -- Ready to process operations, you can launch the Java component of the frontend as follows:

./startFrontend.sh 1000 10 9999

The first argument is the ID of the frontend, and it should match one of the IDs specified in the RECEIVERS parameter in the ./hyperledger-bftmart/config/node.config file. The second argument is the number of UNIX connections available in the pool between the Go and Java components, and it should match the ConnectionPoolSizeparameter from the BFTsmart section in the ./fabric/sampleconfig/orderer.yaml file. The third parameter is the TCP port from which the Java component delivers blocks to the Go component, and should match the RecvPort parameter in the previous section/file.

You can now launch the Go component as follows:

./.build/bin/orderer start

Running the example chaincode

To execute an example chaincode using this ordering service, generate the rest of the HLF artifacts as follows:

cd $GOPATH/src/github.com/hyperledger/fabric/
./.build/bin/configtxgen -profile SampleSingleMSPChannel -outputCreateChannelTx <path to channel creation tx> -channelID <channel ID>
./.build/bin/configtxgen -profile SampleSingleMSPChannel -outputAnchorPeersUpdate <path to anchor peer update tx> -channelID <channel ID> -asOrg SampleOrg

Note that the channel ID that you use for generating the channel creation transaction must be different that the one used to generate the genesis block. When creating the genesis block, you specify the ID for the system channel, whereas when generating the channel creating transaction, you are going to request a new normal channel to be created.

With the ordering service bootstrapped, you can now launch an endorsing peer. To do so, make sure that the fileSystemPath parameter of the peer section in the ./sampleconfig/core.yaml configuration file is set to a directory where you have write previledges. Following this, start the endorsing peer process by executing:

./.build/bin/peer node start

Use a client to join a channel and install/execute chaincode as follows:

./.build/bin/peer channel create -o 127.0.0.1:7050 -c <channel ID> -f <path to channel creation tx>
./.build/bin/peer channel join -b ./<channel ID>.block
./.build/bin/peer channel update -o 127.0.0.1:7050 -c <channel ID> -f <path to anchor peer update tx>
./.build/bin/peer chaincode install -n <chaincode ID> -v <fabric version> -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd
./.build/bin/peer chaincode instantiate -o 127.0.0.1:7050 -C <channel ID> -n <chaincode ID> -v <fabric version> -c '{"Args":["init","a","100","b","200"]}'
./.build/bin/peer chaincode query -C <channel ID> -n <chaincode ID> -c '{"Args":["query","a"]}'
./.build/bin/peer chaincode invoke -C <channel ID> -n <chaincode ID> -c '{"Args":["invoke","a","b","10"]}'
./.build/bin/peer chaincode query -C <channel ID> -n <chaincode ID> -c '{"Args":["query","a"]}'
./.build/bin/peer chaincode invoke -C <channel ID> -n <chaincode ID> -c '{"Args":["invoke","a","b","-10"]}'
./.build/bin/peer chaincode query -C <channel ID> -n <chaincode ID> -c '{"Args":["query","a"]}'

Running with the sample clients

To submit a heavy workload of representative transactions using the sample clients available in ./fabric/sample_clients, execute the commands bellow in the following order:

Execute go build at directories ./fabric/orderer/sample_clients/deliver_stdout, ./fabric/orderer/sample_clients/broadcast_msg/ and ./fabric/orderer/sample_clients/broadcast_config/ to compile the sample clients

Launch a client to receive the generated blocks as follows:

cd $GOPATH/src/github.com/hyperledger/fabric/
./orderer/sample_clients/deliver_stdout/deliver_stdout --quiet --verify --channelID <system channel ID>

Launch a client to submit transactions to the service as follows:

./orderer/sample_clients/broadcast_msg/broadcast_msg --channelID <system channel ID> --size <size of each transaction> --messages <number of transactions to send>

You can also create a new channel as follows:

./orderer/sample_clients/broadcast_config/broadcast_config --cmd newChain --chainID <channel ID>