diff --git a/full-stack-asset-transfer-guide/infrastructure/sample-network/network b/full-stack-asset-transfer-guide/infrastructure/sample-network/network index 8b0fe20391..1cb0b286a2 100755 --- a/full-stack-asset-transfer-guide/infrastructure/sample-network/network +++ b/full-stack-asset-transfer-guide/infrastructure/sample-network/network @@ -81,8 +81,6 @@ context PEER_IMAGE ghcr.io/hyperledger-labs/fabric-builder-k8s/k8 context PEER_IMAGE_LABEL 0.11.0 # When using k8s-fabric-peer in Fabric v2.5+, 0.11.0+ should be specified context ORDERER_IMAGE ${FABRIC_CONTAINER_REGISTRY}/fabric-orderer context ORDERER_IMAGE_LABEL ${FABRIC_VERSION} -context TOOLS_IMAGE ${FABRIC_CONTAINER_REGISTRY}/fabric-tools -context TOOLS_IMAGE_LABEL ${FABRIC_VERSION} context OPERATOR_IMAGE ghcr.io/hyperledger-labs/fabric-operator context OPERATOR_IMAGE_LABEL 1.0.4 context INIT_IMAGE registry.access.redhat.com/ubi8/ubi-minimal @@ -102,7 +100,6 @@ export FABRIC_DEPLOYER_IMAGE=${DEPLOYER_IMAGE}:${DEPLOYER_IMAGE_LABEL} export FABRIC_CA_IMAGE=${CA_IMAGE}:${CA_IMAGE_LABEL} export FABRIC_PEER_IMAGE=${PEER_IMAGE}:${PEER_IMAGE_LABEL} export FABRIC_ORDERER_IMAGE=${ORDERER_IMAGE}:${ORDERER_IMAGE_LABEL} -export FABRIC_TOOLS_IMAGE=${TOOLS_IMAGE}:${TOOLS_IMAGE_LABEL} export TEMP_DIR=${PWD}/temp diff --git a/test-network/addOrg3/addOrg3.sh b/test-network/addOrg3/addOrg3.sh index f1beba84bd..446c37c152 100755 --- a/test-network/addOrg3/addOrg3.sh +++ b/test-network/addOrg3/addOrg3.sh @@ -158,16 +158,17 @@ function addOrg3 () { infoln "Bringing up Org3 peer" Org3Up - # Use the CLI container to create the configuration transaction needed to add + # Create the configuration transaction needed to add # Org3 to the network infoln "Generating and submitting config tx to add Org3" - ${CONTAINER_CLI} exec cli ./scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE + cp ${PWD}/../../config/core.yaml ${PWD} + . ../scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE if [ $? -ne 0 ]; then fatalln "ERROR !!!! Unable to create config tx" fi infoln "Joining Org3 peers to network" - ${CONTAINER_CLI} exec cli ./scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE + . ../scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE if [ $? -ne 0 ]; then fatalln "ERROR !!!! Unable to join Org3 peers to network" fi diff --git a/test-network/compose/compose-bft-test-net.yaml b/test-network/compose/compose-bft-test-net.yaml index cdab05e349..4ab8305952 100644 --- a/test-network/compose/compose-bft-test-net.yaml +++ b/test-network/compose/compose-bft-test-net.yaml @@ -262,26 +262,3 @@ services: - 9445:9445 networks: - test - - cli: - container_name: cli - image: hyperledger/fabric-tools:latest - labels: - service: hyperledger-fabric - tty: true - stdin_open: true - environment: - - GOPATH=/opt/gopath - - FABRIC_LOGGING_SPEC=INFO - - FABRIC_CFG_PATH=/etc/hyperledger/peercfg - #- FABRIC_LOGGING_SPEC=DEBUG - working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer - command: /bin/bash - volumes: - - ../organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations - - ../scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/ - depends_on: - - peer0.org1.example.com - - peer0.org2.example.com - networks: - - test \ No newline at end of file diff --git a/test-network/compose/compose-test-net.yaml b/test-network/compose/compose-test-net.yaml index ba3a968c10..dcac21b02f 100644 --- a/test-network/compose/compose-test-net.yaml +++ b/test-network/compose/compose-test-net.yaml @@ -135,26 +135,3 @@ services: - 9445:9445 networks: - test - - cli: - container_name: cli - image: hyperledger/fabric-tools:latest - labels: - service: hyperledger-fabric - tty: true - stdin_open: true - environment: - - GOPATH=/opt/gopath - - FABRIC_LOGGING_SPEC=INFO - - FABRIC_CFG_PATH=/etc/hyperledger/peercfg - #- FABRIC_LOGGING_SPEC=DEBUG - working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer - command: /bin/bash - volumes: - - ../organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations - - ../scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/ - depends_on: - - peer0.org1.example.com - - peer0.org2.example.com - networks: - - test \ No newline at end of file diff --git a/test-network/compose/docker/docker-compose-bft-test-net.yaml b/test-network/compose/docker/docker-compose-bft-test-net.yaml index 68f6dc565b..421d8e0bcf 100644 --- a/test-network/compose/docker/docker-compose-bft-test-net.yaml +++ b/test-network/compose/docker/docker-compose-bft-test-net.yaml @@ -30,9 +30,3 @@ services: volumes: - ./docker/peercfg:/etc/hyperledger/peercfg - ${DOCKER_SOCK}:/host/var/run/docker.sock - - cli: - container_name: cli - image: hyperledger/fabric-tools:latest - volumes: - - ./docker/peercfg:/etc/hyperledger/peercfg diff --git a/test-network/compose/docker/docker-compose-test-net.yaml b/test-network/compose/docker/docker-compose-test-net.yaml index 68f6dc565b..421d8e0bcf 100644 --- a/test-network/compose/docker/docker-compose-test-net.yaml +++ b/test-network/compose/docker/docker-compose-test-net.yaml @@ -30,9 +30,3 @@ services: volumes: - ./docker/peercfg:/etc/hyperledger/peercfg - ${DOCKER_SOCK}:/host/var/run/docker.sock - - cli: - container_name: cli - image: hyperledger/fabric-tools:latest - volumes: - - ./docker/peercfg:/etc/hyperledger/peercfg diff --git a/test-network/network.sh b/test-network/network.sh index 9739a68b18..569cee659a 100755 --- a/test-network/network.sh +++ b/test-network/network.sh @@ -70,10 +70,10 @@ function checkPrereqs() { errorln "https://hyperledger-fabric.readthedocs.io/en/latest/install.html" exit 1 fi - # use the fabric tools container to see if the samples and binaries match your + # use the fabric peer container to see if the samples and binaries match your # docker images LOCAL_VERSION=$(peer version | sed -ne 's/^ Version: //p') - DOCKER_IMAGE_VERSION=$(${CONTAINER_CLI} run --rm hyperledger/fabric-tools:latest peer version | sed -ne 's/^ Version: //p') + DOCKER_IMAGE_VERSION=$(${CONTAINER_CLI} run --rm hyperledger/fabric-peer:latest peer version | sed -ne 's/^ Version: //p') infoln "LOCAL_VERSION=$LOCAL_VERSION" infoln "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION" diff --git a/test-network/scripts/configUpdate.sh b/test-network/scripts/configUpdate.sh index 87087ac4d3..a54d14109c 100755 --- a/test-network/scripts/configUpdate.sh +++ b/test-network/scripts/configUpdate.sh @@ -6,7 +6,13 @@ # # import utils -. scripts/envVar.sh +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works +test_network_home=${test_network_home:-${PWD}} +. ${test_network_home}/scripts/envVar.sh # fetchChannelConfig # Writes the current channel config for a given channel to a JSON file @@ -20,7 +26,7 @@ fetchChannelConfig() { infoln "Fetching the most recent configuration block for the channel" set -x - peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile "$ORDERER_CA" + peer channel fetch config config_block.pb -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile "$ORDERER_CA" { set +x; } 2>/dev/null infoln "Decoding config block to JSON and isolating config to ${OUTPUT}" diff --git a/test-network/scripts/createChannel.sh b/test-network/scripts/createChannel.sh index 6ff5ae04a9..8f7980d431 100755 --- a/test-network/scripts/createChannel.sh +++ b/test-network/scripts/createChannel.sh @@ -2,8 +2,6 @@ # imports . scripts/envVar.sh -. scripts/utils.sh - CHANNEL_NAME="$1" DELAY="$2" @@ -94,7 +92,7 @@ joinChannel() { setAnchorPeer() { ORG=$1 - ${CONTAINER_CLI} exec cli ./scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME + . scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME } diff --git a/test-network/scripts/envVar.sh b/test-network/scripts/envVar.sh index c30376c382..c4b19b5a02 100755 --- a/test-network/scripts/envVar.sh +++ b/test-network/scripts/envVar.sh @@ -8,13 +8,19 @@ # This is a collection of bash functions used by different scripts # imports -. scripts/utils.sh +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works +test_network_home=${test_network_home:-${PWD}} +. ${test_network_home}/scripts/utils.sh export CORE_PEER_TLS_ENABLED=true -export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem -export PEER0_ORG1_CA=${PWD}/organizations/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem -export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem -export PEER0_ORG3_CA=${PWD}/organizations/peerOrganizations/org3.example.com/tlsca/tlsca.org3.example.com-cert.pem +export ORDERER_CA=${test_network_home}/organizations/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem +export PEER0_ORG1_CA=${test_network_home}/organizations/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem +export PEER0_ORG2_CA=${test_network_home}/organizations/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem +export PEER0_ORG3_CA=${test_network_home}/organizations/peerOrganizations/org3.example.com/tlsca/tlsca.org3.example.com-cert.pem # Set environment variables for the peer org setGlobals() { @@ -28,17 +34,17 @@ setGlobals() { if [ $USING_ORG -eq 1 ]; then export CORE_PEER_LOCALMSPID="Org1MSP" export CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG1_CA - export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp + export CORE_PEER_MSPCONFIGPATH=${test_network_home}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp export CORE_PEER_ADDRESS=localhost:7051 elif [ $USING_ORG -eq 2 ]; then export CORE_PEER_LOCALMSPID="Org2MSP" export CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG2_CA - export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp + export CORE_PEER_MSPCONFIGPATH=${test_network_home}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp export CORE_PEER_ADDRESS=localhost:9051 elif [ $USING_ORG -eq 3 ]; then export CORE_PEER_LOCALMSPID="Org3MSP" export CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG3_CA - export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp + export CORE_PEER_MSPCONFIGPATH=${test_network_home}/organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp export CORE_PEER_ADDRESS=localhost:11051 else errorln "ORG Unknown" diff --git a/test-network/scripts/org3-scripts/joinChannel.sh b/test-network/scripts/org3-scripts/joinChannel.sh index 904d79426c..b10c13c721 100755 --- a/test-network/scripts/org3-scripts/joinChannel.sh +++ b/test-network/scripts/org3-scripts/joinChannel.sh @@ -23,11 +23,18 @@ COUNTER=1 MAX_RETRY=5 # import environment variables -. scripts/envVar.sh +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works +export test_network_home=.. +. ${test_network_home}/scripts/envVar.sh # joinChannel ORG joinChannel() { ORG=$1 + setGlobals $ORG local rc=1 local COUNTER=1 ## Sometimes Join takes time, hence retry @@ -46,7 +53,7 @@ joinChannel() { setAnchorPeer() { ORG=$1 - scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME + ${test_network_home}/scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME } setGlobalsCLI 3 @@ -54,7 +61,7 @@ BLOCKFILE="${CHANNEL_NAME}.block" echo "Fetching channel config block from orderer..." set -x -peer channel fetch 0 $BLOCKFILE -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME --tls --cafile "$ORDERER_CA" >&log.txt +peer channel fetch 0 $BLOCKFILE -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME --tls --cafile "$ORDERER_CA" >&log.txt res=$? { set +x; } 2>/dev/null cat log.txt diff --git a/test-network/scripts/org3-scripts/updateChannelConfig.sh b/test-network/scripts/org3-scripts/updateChannelConfig.sh index 6a9df1f510..c0d6b91104 100755 --- a/test-network/scripts/org3-scripts/updateChannelConfig.sh +++ b/test-network/scripts/org3-scripts/updateChannelConfig.sh @@ -23,9 +23,13 @@ MAX_RETRY=5 # imports -. scripts/envVar.sh -. scripts/configUpdate.sh -. scripts/utils.sh +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works +export test_network_home=.. +. ${test_network_home}/scripts/configUpdate.sh infoln "Creating config transaction to add org3 to network" @@ -34,7 +38,7 @@ fetchChannelConfig 1 ${CHANNEL_NAME} config.json # Modify the configuration to append the new org set -x -jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./organizations/peerOrganizations/org3.example.com/org3.json > modified_config.json +jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ${test_network_home}/organizations/peerOrganizations/org3.example.com/org3.json > modified_config.json { set +x; } 2>/dev/null # Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org3_update_in_envelope.pb @@ -46,7 +50,7 @@ signConfigtxAsPeerOrg 1 org3_update_in_envelope.pb infoln "Submitting transaction from a different peer (peer0.org2) which also signs it" setGlobals 2 set -x -peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA" +peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA" { set +x; } 2>/dev/null successln "Config transaction to add org3 to network submitted" diff --git a/test-network/scripts/setAnchorPeer.sh b/test-network/scripts/setAnchorPeer.sh index 743203ebaa..39a073f24f 100755 --- a/test-network/scripts/setAnchorPeer.sh +++ b/test-network/scripts/setAnchorPeer.sh @@ -6,8 +6,13 @@ # # import utils -. scripts/envVar.sh -. scripts/configUpdate.sh +# test network home var targets to test network folder +# the reason we use a var here is considering with org3 specific folder +# when invoking this for org3 as test-network/scripts/org3-scripts +# the value is changed from default as $PWD(test-network) +# to .. as relative path to make the import works +test_network_home=${test_network_home:-${PWD}} +. ${test_network_home}/scripts/configUpdate.sh # NOTE: this must be run in a CLI container since it requires jq and configtxlator @@ -42,7 +47,7 @@ createAnchorPeerUpdate() { } updateAnchorPeer() { - peer channel update -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ${CORE_PEER_LOCALMSPID}anchors.tx --tls --cafile "$ORDERER_CA" >&log.txt + peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ${CORE_PEER_LOCALMSPID}anchors.tx --tls --cafile "$ORDERER_CA" >&log.txt res=$? cat log.txt verifyResult $res "Anchor peer update failed"