-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-14487] Make FabCar use BYFN, not basic-network
Update FabCar to use BYFN. As a result, the sample client applications need to change so that they use the correct connection profile paths, and so that they use service discovery. Change-Id: If02b7fb4ad308c6a7d1e1aa9f953e1bc4e942719 Signed-off-by: Simon Stone <[email protected]>
- Loading branch information
Simon Stone
committed
May 3, 2019
1 parent
25d7de4
commit f2d0fa0
Showing
9 changed files
with
143 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Exit on first error | ||
set -e | ||
set -ex | ||
|
||
# don't rewrite paths for Windows Git Bash users | ||
export MSYS_NO_PATHCONV=1 | ||
|
@@ -14,13 +14,13 @@ CC_SRC_LANGUAGE=${1:-"go"} | |
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]` | ||
if [ "$CC_SRC_LANGUAGE" = "go" -o "$CC_SRC_LANGUAGE" = "golang" ]; then | ||
CC_RUNTIME_LANGUAGE=golang | ||
CC_SRC_PATH=github.com/fabcar/go | ||
CC_SRC_PATH=github.com/hyperledger/fabric-samples/chaincode/fabcar/go | ||
elif [ "$CC_SRC_LANGUAGE" = "javascript" ]; then | ||
CC_RUNTIME_LANGUAGE=node # chaincode runtime language is node.js | ||
CC_SRC_PATH=/opt/gopath/src/github.com/fabcar/javascript | ||
CC_SRC_PATH=/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/fabcar/javascript | ||
elif [ "$CC_SRC_LANGUAGE" = "typescript" ]; then | ||
CC_RUNTIME_LANGUAGE=node # chaincode runtime language is node.js | ||
CC_SRC_PATH=/opt/gopath/src/github.com/fabcar/typescript | ||
CC_SRC_PATH=/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/fabcar/typescript | ||
echo Compiling TypeScript code into JavaScript ... | ||
pushd ../chaincode/fabcar/typescript | ||
npm install | ||
|
@@ -38,30 +38,123 @@ fi | |
rm -rf ./hfc-key-store | ||
|
||
# launch network; create channel and join peer to channel | ||
cd ../basic-network | ||
./start.sh | ||
|
||
# Now launch the CLI container in order to install, instantiate chaincode | ||
# and prime the ledger with our 10 cars | ||
docker-compose -f ./docker-compose.yml up -d cli | ||
docker ps -a | ||
|
||
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli \ | ||
peer lifecycle chaincode package fabcar.tar.gz --path "$CC_SRC_PATH" --lang "$CC_RUNTIME_LANGUAGE" --label fabcarv1 | ||
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli \ | ||
peer lifecycle chaincode install fabcar.tar.gz | ||
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli \ | ||
/bin/bash -c "peer lifecycle chaincode queryinstalled > log" | ||
PACKAGE_ID=`docker exec cli sed -nr '/Label: fabcarv1/s/Package ID: (.*), Label: fabcarv1/\1/p;' log` | ||
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli \ | ||
peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --channelID mychannel --name fabcar --version 1.0 --init-required --signature-policy "OR ('Org1MSP.member','Org2MSP.member')" --sequence 1 --waitForEvent --package-id $PACKAGE_ID | ||
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli \ | ||
peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name fabcar --version 1.0 --init-required --signature-policy "OR ('Org1MSP.member','Org2MSP.member')" --sequence 1 --waitForEvent | ||
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli \ | ||
peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n fabcar --isInit -c '{"Args":[]}' | ||
sleep 10 | ||
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" cli \ | ||
peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n fabcar -c '{"function":"initLedger","Args":[]}' | ||
pushd ../first-network | ||
echo y | ./byfn.sh down | ||
echo y | ./byfn.sh up -a -n -s couchdb | ||
popd | ||
|
||
CONFIG_ROOT=/opt/gopath/src/github.com/hyperledger/fabric/peer | ||
ORG1_MSPCONFIGPATH=${CONFIG_ROOT}/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp | ||
ORG1_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt | ||
ORG2_MSPCONFIGPATH=${CONFIG_ROOT}/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp | ||
ORG2_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt | ||
ORDERER_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem | ||
|
||
PEER_ORG1="docker exec | ||
-e CORE_PEER_LOCALMSPID=Org1MSP | ||
-e CORE_PEER_ADDRESS=peer0.org1.example.com:7051 | ||
-e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH} | ||
-e CORE_PEER_TLS_ROOTCERT_FILE=${ORG1_TLS_ROOTCERT_FILE} | ||
cli | ||
peer | ||
--tls=true | ||
--cafile=${ORDERER_TLS_ROOTCERT_FILE} | ||
--orderer=orderer.example.com:7050" | ||
|
||
PEER_ORG2="docker exec | ||
-e CORE_PEER_LOCALMSPID=Org2MSP | ||
-e CORE_PEER_ADDRESS=peer0.org2.example.com:9051 | ||
-e CORE_PEER_MSPCONFIGPATH=${ORG2_MSPCONFIGPATH} | ||
-e CORE_PEER_TLS_ROOTCERT_FILE=${ORG2_TLS_ROOTCERT_FILE} | ||
cli | ||
peer | ||
--tls=true | ||
--cafile=${ORDERER_TLS_ROOTCERT_FILE} | ||
--orderer=orderer.example.com:7050" | ||
|
||
echo "Packaging smart contract on peer0.org1.example.com" | ||
${PEER_ORG1} lifecycle chaincode package \ | ||
fabcar.tar.gz \ | ||
--path "$CC_SRC_PATH" \ | ||
--lang "$CC_RUNTIME_LANGUAGE" \ | ||
--label fabcarv1 | ||
|
||
echo "Installing smart contract on peer0.org1.example.com" | ||
${PEER_ORG1} lifecycle chaincode install \ | ||
fabcar.tar.gz | ||
|
||
echo "Determining package ID for smart contract on peer0.org1.example.com" | ||
REGEX='Package ID: (.*), Label: fabcarv1' | ||
if [[ `${PEER_ORG1} lifecycle chaincode queryinstalled` =~ $REGEX ]]; then | ||
PACKAGE_ID_ORG1=${BASH_REMATCH[1]} | ||
else | ||
echo Could not find package ID for fabcarv1 chaincode on peer0.org1.example.com | ||
exit 1 | ||
fi | ||
|
||
echo "Approving smart contract for org1" | ||
${PEER_ORG1} lifecycle chaincode approveformyorg \ | ||
--package-id ${PACKAGE_ID_ORG1} \ | ||
--channelID mychannel \ | ||
--name fabcar \ | ||
--version 1.0 \ | ||
--signature-policy "AND('Org1MSP.member','Org2MSP.member')" \ | ||
--sequence 1 \ | ||
--waitForEvent | ||
|
||
echo "Packaging smart contract on peer0.org2.example.com" | ||
${PEER_ORG2} lifecycle chaincode package \ | ||
fabcar.tar.gz \ | ||
--path "$CC_SRC_PATH" \ | ||
--lang "$CC_RUNTIME_LANGUAGE" \ | ||
--label fabcarv1 | ||
|
||
echo "Installing smart contract on peer0.org2.example.com" | ||
${PEER_ORG2} lifecycle chaincode install fabcar.tar.gz | ||
|
||
echo "Determining package ID for smart contract on peer0.org2.example.com" | ||
REGEX='Package ID: (.*), Label: fabcarv1' | ||
if [[ `${PEER_ORG2} lifecycle chaincode queryinstalled` =~ $REGEX ]]; then | ||
PACKAGE_ID_ORG2=${BASH_REMATCH[1]} | ||
else | ||
echo Could not find package ID for fabcarv1 chaincode on peer0.org2.example.com | ||
exit 1 | ||
fi | ||
|
||
echo "Approving smart contract for org2" | ||
${PEER_ORG2} lifecycle chaincode approveformyorg \ | ||
--package-id ${PACKAGE_ID_ORG2} \ | ||
--channelID mychannel \ | ||
--name fabcar \ | ||
--version 1.0 \ | ||
--signature-policy "AND('Org1MSP.member','Org2MSP.member')" \ | ||
--sequence 1 \ | ||
--waitForEvent | ||
|
||
echo "Committing smart contract" | ||
${PEER_ORG1} lifecycle chaincode commit \ | ||
--channelID mychannel \ | ||
--name fabcar \ | ||
--version 1.0 \ | ||
--signature-policy "AND('Org1MSP.member','Org2MSP.member')" \ | ||
--sequence 1 \ | ||
--waitForEvent \ | ||
--peerAddresses peer0.org1.example.com:7051 \ | ||
--peerAddresses peer0.org2.example.com:9051 \ | ||
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \ | ||
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE} | ||
|
||
echo "Submitting initLedger transaction to smart contract on mychannel" | ||
${PEER_ORG1} chaincode invoke \ | ||
-C mychannel \ | ||
-n fabcar \ | ||
-c '{"function":"initLedger","Args":[]}' \ | ||
--waitForEvent \ | ||
--waitForEventTimeout 300s \ | ||
--peerAddresses peer0.org1.example.com:7051 \ | ||
--peerAddresses peer0.org2.example.com:9051 \ | ||
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \ | ||
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE} | ||
|
||
cat <<EOF | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters