From e1a39e685aaafd9f424bb0ef6793ac97126001ba Mon Sep 17 00:00:00 2001 From: Surya Lanka Date: Tue, 4 Dec 2018 13:54:12 -0500 Subject: [PATCH] [FAB-12724] Upgrade from 1.3.x to 1.4.0 Adding support to upgrade from 1.3.x to 1.4.0 using upgrade_to_v14.sh and changes to byfn.sh For this, no v1_4 capabilities need to be enabled other than v1_3 capabilities on channel and application group level Only upgrading the images from v1.3.x to v.1.4.0 for peer, orderer, cli, ccenv Change-Id: I991f96c2deb3c91870ec4654aa8b561f49594248 Signed-off-by: Surya Lanka --- first-network/byfn.sh | 14 +-- first-network/configtx.yaml | 2 + first-network/scripts/capabilities.json | 9 -- first-network/scripts/upgrade_to_v13.sh | 155 ------------------------ first-network/scripts/upgrade_to_v14.sh | 66 ++++++++++ 5 files changed, 75 insertions(+), 171 deletions(-) delete mode 100644 first-network/scripts/capabilities.json delete mode 100755 first-network/scripts/upgrade_to_v13.sh create mode 100755 first-network/scripts/upgrade_to_v14.sh diff --git a/first-network/byfn.sh b/first-network/byfn.sh index d2eb65929f..5573afe505 100755 --- a/first-network/byfn.sh +++ b/first-network/byfn.sh @@ -41,7 +41,7 @@ function printHelp() { echo " - 'down' - clear the network with docker-compose down" echo " - 'restart' - restart the network" echo " - 'generate' - generate required certificates and genesis block" - echo " - 'upgrade' - upgrade the network from version 1.2.x to 1.3.x" + echo " - 'upgrade' - upgrade the network from version 1.3.x to 1.4.0" echo " -c - channel name to use (defaults to \"mychannel\")" echo " -t - CLI timeout duration in seconds (defaults to 10)" echo " -d - delay duration in seconds (defaults to 3)" @@ -57,7 +57,7 @@ function printHelp() { echo echo " byfn.sh generate -c mychannel" echo " byfn.sh up -c mychannel -s couchdb" - echo " byfn.sh up -c mychannel -s couchdb -i 1.2.x" + echo " byfn.sh up -c mychannel -s couchdb -i 1.4.0" echo " byfn.sh up -l node" echo " byfn.sh down -c mychannel" echo " byfn.sh upgrade -c mychannel" @@ -172,14 +172,14 @@ function networkUp() { fi } -# Upgrade the network components which are at version 1.2.x to 1.3.x +# Upgrade the network components which are at version 1.3.x to 1.4.x # Stop the orderer and peers, backup the ledger for orderer and peers, cleanup chaincode containers and images # and relaunch the orderer and peers with latest tag function upgradeNetwork() { - if [[ "$IMAGETAG" == *"1.3"* ]] || [[ $IMAGETAG == "latest" ]]; then + if [[ "$IMAGETAG" == *"1.4"* ]] || [[ $IMAGETAG == "latest" ]]; then docker inspect -f '{{.Config.Volumes}}' orderer.example.com | grep -q '/var/hyperledger/production/orderer' if [ $? -ne 0 ]; then - echo "ERROR !!!! This network does not appear to be using volumes for its ledgers, did you start from fabric-samples >= v1.2.x?" + echo "ERROR !!!! This network does not appear to start with fabric-samples >= v1.3.x?" exit 1 fi @@ -225,13 +225,13 @@ function upgradeNetwork() { docker-compose $COMPOSE_FILES up -d --no-deps $PEER done - docker exec cli scripts/upgrade_to_v13.sh $CHANNEL_NAME $CLI_DELAY $LANGUAGE $CLI_TIMEOUT $VERBOSE + docker exec cli scripts/upgrade_to_v14.sh $CHANNEL_NAME $CLI_DELAY $LANGUAGE $CLI_TIMEOUT $VERBOSE if [ $? -ne 0 ]; then echo "ERROR !!!! Test failed" exit 1 fi else - echo "ERROR !!!! Pass the v1.3.x image tag" + echo "ERROR !!!! Pass the v1.4.x image tag" fi } diff --git a/first-network/configtx.yaml b/first-network/configtx.yaml index 9990a736a5..b5ac5aa07c 100644 --- a/first-network/configtx.yaml +++ b/first-network/configtx.yaml @@ -191,6 +191,8 @@ Application: &ApplicationDefaults Type: ImplicitMeta Rule: "MAJORITY Admins" + Capabilities: + <<: *ApplicationCapabilities ################################################################################ # # SECTION: Orderer diff --git a/first-network/scripts/capabilities.json b/first-network/scripts/capabilities.json deleted file mode 100644 index 5c3f3e0e08..0000000000 --- a/first-network/scripts/capabilities.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "mod_policy": "Admins", - "value": { - "capabilities": { - "V1_3": {} - } - }, - "version": "0" -} diff --git a/first-network/scripts/upgrade_to_v13.sh b/first-network/scripts/upgrade_to_v13.sh deleted file mode 100755 index 905cec1bb8..0000000000 --- a/first-network/scripts/upgrade_to_v13.sh +++ /dev/null @@ -1,155 +0,0 @@ -#!/bin/bash - -echo -echo " ____ _____ _ ____ _____ " -echo "/ ___| |_ _| / \ | _ \ |_ _|" -echo "\___ \ | | / _ \ | |_) | | | " -echo " ___) | | | / ___ \ | _ < | | " -echo "|____/ |_| /_/ \_\ |_| \_\ |_| " -echo -echo "Upgrade your first network (BYFN) from v1.2.x to v1.3.x end-to-end test" -echo -CHANNEL_NAME="$1" -DELAY="$2" -LANGUAGE="$3" -TIMEOUT="$4" -VERBOSE="$5" -: ${CHANNEL_NAME:="mychannel"} -: ${DELAY:="5"} -: ${LANGUAGE:="golang"} -: ${TIMEOUT:="10"} -: ${VERBOSE:="false"} -LANGUAGE=$(echo "$LANGUAGE" | tr [:upper:] [:lower:]) -COUNTER=1 -MAX_RETRY=5 - -CC_SRC_PATH="github.com/chaincode/chaincode_example02/go/" -if [ "$LANGUAGE" = "node" ]; then - CC_SRC_PATH="/opt/gopath/src/github.com/chaincode/chaincode_example02/node/" -fi - -echo "Channel name : "$CHANNEL_NAME - -# import utils -. scripts/utils.sh - -# addCapabilityToChannel -# This function pulls the current channel config, modifies it with capabilities -# for the specified group, computes the config update, signs, and submits it. -addCapabilityToChannel() { - CH_NAME="$1" - GROUP=$2 - - setOrdererGlobals - - # Get the current channel config, decode and write it to config.json - fetchChannelConfig "$CH_NAME" config.json - - # Modify the correct section of the config based on capabilities group - if [ $GROUP == "application" ]; then - jq -s '.[0] * {"channel_group":{"groups":{"Application": {"values": {"Capabilities": .[1]}}}}}' config.json ./scripts/capabilities.json >modified_config.json - elif [ $GROUP == "channel" ]; then - jq -s '.[0] * {"channel_group":{"values": {"Capabilities": .[1]}}}' config.json ./scripts/capabilities.json > modified_config.json - fi - - # Create a config updated for this channel based on the differences between config.json and modified_config.json - # write the output to config_update_in_envelope.pb - createConfigUpdate "$CH_NAME" config.json modified_config.json config_update_in_envelope.pb - - if [ $CH_NAME != "testchainid" ] ; then - # Sign, and set the correct identity for submission. - if [ $GROUP == "application" ]; then - # Modifying the application group requires a majority of application admins to sign. - # Sign with PeerOrg1.Admin - signConfigtxAsPeerOrg 1 config_update_in_envelope.pb - # Prepare to sign the update as the PeerOrg2.Admin - setGlobals 0 2 - elif [ $GROUP == "channel" ]; then - # Modifying the channel group requires a majority of application admins and the orderer admin to sign. - # Sign with PeerOrg1.Admin - signConfigtxAsPeerOrg 1 config_update_in_envelope.pb - # Sign with PeerOrg2.Admin - signConfigtxAsPeerOrg 2 config_update_in_envelope.pb - # Prepare to sign the update as the OrdererOrg.Admin - setOrdererGlobals - fi - else - # For the orderer system channel, only the orderer admin needs sign - # which will be attached during the update - setOrdererGlobals - fi - - if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then - set -x - peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --cafile $ORDERER_CA - res=$? - set +x - else - set -x - peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --tls true --cafile $ORDERER_CA - res=$? - set +x - fi - verifyResult $res "Config update for \"$GROUP\" on \"$CH_NAME\" failed" - echo "===================== Config update for \"$GROUP\" on \"$CH_NAME\" is completed ===================== " -} - -sleep $DELAY - -#Config update for /Channel for testchainid -echo "Config update for /Channel on \"testchainid\"" -addCapabilityToChannel testchainid channel - -sleep $DELAY - -#Config update for /Channel -echo "Config update for /Channel on \"$CHANNEL_NAME\"" -addCapabilityToChannel "$CHANNEL_NAME" channel - -sleep $DELAY - -#Query on chaincode on Peer0/Org1 -echo "Querying chaincode on org1/peer0..." -chaincodeQuery 0 1 90 - -sleep $DELAY - -#Config update for /Channel/Application -echo "Config update for /Channel/Application on \"$CHANNEL_NAME\"" -addCapabilityToChannel "$CHANNEL_NAME" application - -sleep $DELAY - -#Invoke on chaincode on Peer0/Org1 -echo "Sending invoke transaction on org1/peer0..." -chaincodeInvoke 0 1 0 2 - -sleep $DELAY - -#Query on chaincode on Peer0/Org1 -echo "Querying chaincode on org1/peer0..." -chaincodeQuery 0 1 80 - -##Invoke on chaincode on Peer0/Org2 -echo "Sending invoke transaction on org2/peer0..." -chaincodeInvoke 0 2 0 1 - -sleep $DELAY - -#Query on chaincode on Peer0/Org2 -echo "Querying chaincode on org2/peer0..." -chaincodeQuery 0 2 70 - -echo -echo "===================== All GOOD, End-2-End UPGRADE Scenario execution completed ===================== " -echo - -echo -echo " _____ _ _ ____ _____ ____ _____ " -echo "| ____| | \ | | | _ \ | ____| |___ \ | ____|" -echo "| _| | \| | | | | | _____ | _| __) | | _| " -echo "| |___ | |\ | | |_| | |_____| | |___ / __/ | |___ " -echo "|_____| |_| \_| |____/ |_____| |_____| |_____|" -echo - -exit 0 diff --git a/first-network/scripts/upgrade_to_v14.sh b/first-network/scripts/upgrade_to_v14.sh new file mode 100755 index 0000000000..e26498f447 --- /dev/null +++ b/first-network/scripts/upgrade_to_v14.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +echo +echo " ____ _____ _ ____ _____ " +echo "/ ___| |_ _| / \ | _ \ |_ _|" +echo "\___ \ | | / _ \ | |_) | | | " +echo " ___) | | | / ___ \ | _ < | | " +echo "|____/ |_| /_/ \_\ |_| \_\ |_| " +echo +echo "Upgrade your first network (BYFN) from v1.3.x to v1.4.x end-to-end test" +echo +CHANNEL_NAME="$1" +DELAY="$2" +LANGUAGE="$3" +TIMEOUT="$4" +VERBOSE="$5" +: ${CHANNEL_NAME:="mychannel"} +: ${DELAY:="5"} +: ${LANGUAGE:="golang"} +: ${TIMEOUT:="10"} +: ${VERBOSE:="false"} +LANGUAGE=$(echo "$LANGUAGE" | tr [:upper:] [:lower:]) +COUNTER=1 +MAX_RETRY=5 + +CC_SRC_PATH="github.com/chaincode/chaincode_example02/go/" +if [ "$LANGUAGE" = "node" ]; then + CC_SRC_PATH="/opt/gopath/src/github.com/chaincode/chaincode_example02/node/" +fi + +echo "Channel name : "$CHANNEL_NAME + +# import utils +. scripts/utils.sh + +sleep $DELAY + +#Query on chaincode on Peer0/Org1 +echo "Querying chaincode on org1/peer0..." +chaincodeQuery 0 1 90 + +sleep $DELAY + +#Invoke on chaincode on Peer0/Org1 +echo "Sending invoke transaction on org1/peer0..." +chaincodeInvoke 0 1 0 2 + +sleep $DELAY + +#Query on chaincode on Peer0/Org1 +echo "Querying chaincode on org1/peer0..." +chaincodeQuery 0 1 80 + +echo +echo "===================== All GOOD, End-2-End UPGRADE Scenario execution completed ===================== " +echo + +echo +echo " _____ _ _ ____ _____ ____ _____ " +echo "| ____| | \ | | | _ \ | ____| |___ \ | ____|" +echo "| _| | \| | | | | | _____ | _| __) | | _| " +echo "| |___ | |\ | | |_| | |_____| | |___ / __/ | |___ " +echo "|_____| |_| \_| |____/ |_____| |_____| |_____|" +echo + +exit 0