Skip to content

Commit

Permalink
Improve BFT sample on test-network (#1083)
Browse files Browse the repository at this point in the history
This patch includes:
- Fixed a minor bug in the parsing of the BFT flag
- Added check for when a user attempts to use BFT orderer in
  Fabric network with CA
- Update of printHelp for use of the BFT flag
- Fixed explanations

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
  • Loading branch information
satota2 authored Aug 28, 2023
1 parent eb16caf commit 7d5aaf1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion test-network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

You can use the `./network.sh` script to stand up a simple Fabric test network. The test network has two peer organizations with one peer each and a single node raft ordering service. You can also use the `./network.sh` script to create channels and deploy chaincode. For more information, see [Using the Fabric test network](https://hyperledger-fabric.readthedocs.io/en/latest/test_network.html). The test network is being introduced in Fabric v2.0 as the long term replacement for the `first-network` sample.

If you are planning to run the test network with consesnsus type BFT then please pass `-bft` flag as input to the `network.sh` script when creating the channel.
If you are planning to run the test network with consensus type BFT then please pass `-bft` flag as input to the `network.sh` script when creating the channel. Note that currently this sample does not yet support the use of consensus type BFT and CA together.
That is to create a network use:
```bash
./network.sh up -bft
Expand Down
6 changes: 5 additions & 1 deletion test-network/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ while [[ $# -ge 1 ]] ; do
;;
-bft )
BFT=1
shift
;;
-ca )
CRYPTO="Certificate Authorities"
Expand Down Expand Up @@ -513,6 +512,11 @@ while [[ $# -ge 1 ]] ; do
shift
done

## Check if user attempts to use BFT orderer and CA together
if [[ $BFT -eq 1 && "$CRYPTO" == "Certificate Authorities" ]]; then
fatalln "This sample does not yet support the use of consensus type BFT and CA together."
fi

if [ $BFT -eq 1 ]; then
export FABRIC_CFG_PATH=${PWD}/bft-config
COMPOSE_FILE_BASE=compose-bft-test-net.yaml
Expand Down
4 changes: 4 additions & 0 deletions test-network/scripts/createChannel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ setAnchorPeer() {
}


## User attempts to use BFT orderer in Fabric network with CA
if [ $BFT -eq 1 ] && [ -d "organizations/fabric-ca/ordererOrg/msp" ]; then
fatalln "Fabric network seems to be using CA. This sample does not yet support the use of consensus type BFT and CA together."
fi

## Create channel genesis block
FABRIC_CFG_PATH=$PWD/../config/
Expand Down
17 changes: 13 additions & 4 deletions test-network/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function printHelp() {
println " network.sh \033[0;32mup\033[0m [Flags]"
println
println " Flags:"
println " -ca <use CAs> - Use Certificate Authorities to generate network crypto material"
println " -ca - Use Certificate Authorities to generate network crypto material"
println " -bft - Use Orderers with consensus type BFT (Not available in Fabric v2.x)"
println " -c <channel name> - Name of channel to create (defaults to \"mychannel\")"
println " -s <dbtype> - Peer state database to deploy: goleveldb (default) or couchdb"
println " -r <max retry> - CLI times out after certain number of attempts (defaults to 5)"
Expand All @@ -25,15 +26,19 @@ function printHelp() {
println
println " Possible Mode and flag combinations"
println " \033[0;32mup\033[0m -ca -r -d -s -verbose"
println " \033[0;32mup\033[0m -bft -r -d -s -verbose"
println " \033[0;32mup createChannel\033[0m -ca -c -r -d -s -verbose"
println " \033[0;32mup createChannel\033[0m -bft -c -r -d -s -verbose"
println
println " Examples:"
println " network.sh up createChannel -ca -c mychannel -s couchdb "
println " network.sh up createChannel -bft -c mychannel -s couchdb "
elif [ "$USAGE" == "createChannel" ]; then
println "Usage: "
println " network.sh \033[0;32mcreateChannel\033[0m [Flags]"
println
println " Flags:"
println " -bft - Use Orderers with consensus type BFT (Not available in Fabric v2.x)"
println " -c <channel name> - Name of channel to create (defaults to \"mychannel\")"
println " -r <max retry> - CLI times out after certain number of attempts (defaults to 5)"
println " -d <delay> - CLI delays for a certain number of seconds (defaults to 3)"
Expand All @@ -42,10 +47,11 @@ function printHelp() {
println " -h - Print this message"
println
println " Possible Mode and flag combinations"
println " \033[0;32mcreateChannel\033[0m -c -r -d -verbose"
println " \033[0;32mcreateChannel\033[0m -bft -c -r -d -verbose"
println
println " Examples:"
println " network.sh createChannel -c channelName"
println " network.sh createChannel -bft"
elif [ "$USAGE" == "deployCC" ]; then
println "Usage: "
println " network.sh \033[0;32mdeployCC\033[0m [Flags]"
Expand Down Expand Up @@ -104,7 +110,8 @@ function printHelp() {
println
println " Flags:"
println " Used with \033[0;32mnetwork.sh up\033[0m, \033[0;32mnetwork.sh createChannel\033[0m:"
println " -ca <use CAs> - Use Certificate Authorities to generate network crypto material"
println " -ca - Use Certificate Authorities to generate network crypto material"
println " -bft - Use Orderers with consensus type BFT (Not available in Fabric v2.x)"
println " -c <channel name> - Name of channel to create (defaults to \"mychannel\")"
println " -s <dbtype> - Peer state database to deploy: goleveldb (default) or couchdb"
println " -r <max retry> - CLI times out after certain number of attempts (defaults to 5)"
Expand All @@ -126,8 +133,10 @@ function printHelp() {
println
println " Possible Mode and flag combinations"
println " \033[0;32mup\033[0m -ca -r -d -s -verbose"
println " \033[0;32mup\033[0m -bft -r -d -s -verbose"
println " \033[0;32mup createChannel\033[0m -ca -c -r -d -s -verbose"
println " \033[0;32mcreateChannel\033[0m -c -r -d -verbose"
println " \033[0;32mup createChannel\033[0m -bft -c -r -d -s -verbose"
println " \033[0;32mcreateChannel\033[0m -bft -c -r -d -verbose"
println " \033[0;32mdeployCC\033[0m -ccn -ccl -ccv -ccs -ccp -cci -r -d -verbose"
println
println " Examples:"
Expand Down

0 comments on commit 7d5aaf1

Please sign in to comment.