mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 17:45:10 +00:00
Stop using deprecated outputAnchorPeersUpdate in test-network (#394)
* Stop using deprecated outputAnchorPeersUpdate in test-network FAB-18381 Signed-off-by: Will Lahti <wtlahti@us.ibm.com> * Improve consistency of test-network output Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
This commit is contained in:
parent
df752bfc7b
commit
b690d8f30f
16 changed files with 392 additions and 467 deletions
|
|
@ -15,6 +15,8 @@ export PATH=${PWD}/../../bin:${PWD}:$PATH
|
||||||
export FABRIC_CFG_PATH=${PWD}
|
export FABRIC_CFG_PATH=${PWD}
|
||||||
export VERBOSE=false
|
export VERBOSE=false
|
||||||
|
|
||||||
|
. ../scripts/utils.sh
|
||||||
|
|
||||||
# Print the usage message
|
# Print the usage message
|
||||||
function printHelp () {
|
function printHelp () {
|
||||||
echo "Usage: "
|
echo "Usage: "
|
||||||
|
|
@ -52,38 +54,28 @@ function printHelp () {
|
||||||
|
|
||||||
# Create Organziation crypto material using cryptogen or CAs
|
# Create Organziation crypto material using cryptogen or CAs
|
||||||
function generateOrg3() {
|
function generateOrg3() {
|
||||||
|
|
||||||
# Create crypto material using cryptogen
|
# Create crypto material using cryptogen
|
||||||
if [ "$CRYPTO" == "cryptogen" ]; then
|
if [ "$CRYPTO" == "cryptogen" ]; then
|
||||||
which cryptogen
|
which cryptogen
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "cryptogen tool not found. exiting"
|
fatalln "cryptogen tool not found. exiting"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
echo
|
infoln "Generating certificates using cryptogen tool"
|
||||||
echo "##########################################################"
|
|
||||||
echo "##### Generate certificates using cryptogen tool #########"
|
|
||||||
echo "##########################################################"
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "##########################################################"
|
infoln "Creating Org3 Identities"
|
||||||
echo "############ Create Org3 Identities ######################"
|
|
||||||
echo "##########################################################"
|
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
cryptogen generate --config=org3-crypto.yaml --output="../organizations"
|
cryptogen generate --config=org3-crypto.yaml --output="../organizations"
|
||||||
res=$?
|
res=$?
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
if [ $res -ne 0 ]; then
|
if [ $res -ne 0 ]; then
|
||||||
echo "Failed to generate certificates..."
|
fatalln "Failed to generate certificates..."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create crypto material using Fabric CAs
|
# Create crypto material using Fabric CA
|
||||||
if [ "$CRYPTO" == "Certificate Authorities" ]; then
|
if [ "$CRYPTO" == "Certificate Authorities" ]; then
|
||||||
|
|
||||||
fabric-ca-client version > /dev/null 2>&1
|
fabric-ca-client version > /dev/null 2>&1
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "ERROR! fabric-ca-client binary not found.."
|
echo "ERROR! fabric-ca-client binary not found.."
|
||||||
|
|
@ -93,10 +85,7 @@ function generateOrg3() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
infoln "Generating certificates using Fabric CA"
|
||||||
echo "##########################################################"
|
|
||||||
echo "##### Generate certificates using Fabric CA's ############"
|
|
||||||
echo "##########################################################"
|
|
||||||
|
|
||||||
IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1
|
IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1
|
||||||
|
|
||||||
|
|
@ -104,16 +93,12 @@ function generateOrg3() {
|
||||||
|
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
echo "##########################################################"
|
infoln "Creating Org3 Identities"
|
||||||
echo "############ Create Org3 Identities ######################"
|
|
||||||
echo "##########################################################"
|
|
||||||
|
|
||||||
createOrg3
|
createOrg3
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
infoln "Generating CCP files for Org3"
|
||||||
echo "Generate CCP files for Org3"
|
|
||||||
./ccp-generate.sh
|
./ccp-generate.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,22 +106,17 @@ function generateOrg3() {
|
||||||
function generateOrg3Definition() {
|
function generateOrg3Definition() {
|
||||||
which configtxgen
|
which configtxgen
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "configtxgen tool not found. exiting"
|
fatalln "configtxgen tool not found. exiting"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
echo "##########################################################"
|
infoln "Generating Org3 organization definition"
|
||||||
echo "####### Generating Org3 organization definition #########"
|
|
||||||
echo "##########################################################"
|
|
||||||
export FABRIC_CFG_PATH=$PWD
|
export FABRIC_CFG_PATH=$PWD
|
||||||
set -x
|
set -x
|
||||||
configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json
|
configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json
|
||||||
res=$?
|
res=$?
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
if [ $res -ne 0 ]; then
|
if [ $res -ne 0 ]; then
|
||||||
echo "Failed to generate Org3 config material..."
|
fatalln "Failed to generate Org3 organization definition..."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
echo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Org3Up () {
|
function Org3Up () {
|
||||||
|
|
@ -147,20 +127,15 @@ function Org3Up () {
|
||||||
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1
|
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1
|
||||||
fi
|
fi
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "ERROR !!!! Unable to start Org3 network"
|
fatalln "ERROR !!!! Unable to start Org3 network"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate the needed certificates, the genesis block and start the network.
|
# Generate the needed certificates, the genesis block and start the network.
|
||||||
function addOrg3 () {
|
function addOrg3 () {
|
||||||
|
|
||||||
# If the test network is not up, abort
|
# If the test network is not up, abort
|
||||||
if [ ! -d ../organizations/ordererOrganizations ]; then
|
if [ ! -d ../organizations/ordererOrganizations ]; then
|
||||||
echo
|
fatalln "ERROR: Please, run ./network.sh up createChannel first."
|
||||||
echo "ERROR: Please, run ./network.sh up createChannel first."
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# generate artifacts if they don't exist
|
# generate artifacts if they don't exist
|
||||||
|
|
@ -169,39 +144,26 @@ function addOrg3 () {
|
||||||
generateOrg3Definition
|
generateOrg3Definition
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CONTAINER_IDS=$(docker ps -a | awk '($2 ~ /fabric-tools/) {print $1}')
|
infoln "Bringing up Org3 peer"
|
||||||
if [ -z "$CONTAINER_IDS" -o "$CONTAINER_IDS" == " " ]; then
|
|
||||||
echo "Bringing up network"
|
|
||||||
Org3Up
|
Org3Up
|
||||||
fi
|
|
||||||
|
|
||||||
# Use the CLI container to create the configuration transaction needed to add
|
# Use the CLI container to create the configuration transaction needed to add
|
||||||
# Org3 to the network
|
# Org3 to the network
|
||||||
echo
|
infoln "Generating and submitting config tx to add Org3"
|
||||||
echo "###############################################################"
|
docker exec cli ./scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
|
||||||
echo "####### Generate and submit config tx to add Org3 #############"
|
|
||||||
echo "###############################################################"
|
|
||||||
docker exec Org3cli ./scripts/org3-scripts/step1org3.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "ERROR !!!! Unable to create config tx"
|
fatalln "ERROR !!!! Unable to create config tx"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
infoln "Joining Org3 peers to network"
|
||||||
echo "###############################################################"
|
docker exec cli ./scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
|
||||||
echo "############### Have Org3 peers join network ##################"
|
|
||||||
echo "###############################################################"
|
|
||||||
docker exec Org3cli ./scripts/org3-scripts/step2org3.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "ERROR !!!! Unable to have Org3 peers join network"
|
fatalln "ERROR !!!! Unable to join Org3 peers to network"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tear down running network
|
# Tear down running network
|
||||||
function networkDown () {
|
function networkDown () {
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
./network.sh down
|
./network.sh down
|
||||||
}
|
}
|
||||||
|
|
@ -286,9 +248,7 @@ while [[ $# -ge 1 ]] ; do
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo
|
errorln "Unknown flag: $key"
|
||||||
echo "Unknown flag: $key"
|
|
||||||
echo
|
|
||||||
printHelp
|
printHelp
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
@ -299,7 +259,7 @@ done
|
||||||
|
|
||||||
# Determine whether starting, stopping, restarting or generating for announce
|
# Determine whether starting, stopping, restarting or generating for announce
|
||||||
if [ "$MODE" == "up" ]; then
|
if [ "$MODE" == "up" ]; then
|
||||||
echo "Add Org3 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'"
|
infoln "Adding org3 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'"
|
||||||
echo
|
echo
|
||||||
elif [ "$MODE" == "down" ]; then
|
elif [ "$MODE" == "down" ]; then
|
||||||
EXPMODE="Stopping network"
|
EXPMODE="Stopping network"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp All Rights Reserved
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
. ../../scripts/utils.sh
|
||||||
|
|
||||||
function createOrg3 {
|
function createOrg3 {
|
||||||
|
infoln "Enrolling the CA admin"
|
||||||
echo
|
|
||||||
echo "Enroll the CA admin"
|
|
||||||
echo
|
|
||||||
mkdir -p ../organizations/peerOrganizations/org3.example.com/
|
mkdir -p ../organizations/peerOrganizations/org3.example.com/
|
||||||
|
|
||||||
export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org3.example.com/
|
export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org3.example.com/
|
||||||
|
|
@ -30,23 +34,17 @@ function createOrg3 {
|
||||||
Certificate: cacerts/localhost-11054-ca-org3.pem
|
Certificate: cacerts/localhost-11054-ca-org3.pem
|
||||||
OrganizationalUnitIdentifier: orderer' > ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml
|
OrganizationalUnitIdentifier: orderer' > ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml
|
||||||
|
|
||||||
echo
|
infoln "Registering peer0"
|
||||||
echo "Register peer0"
|
|
||||||
echo
|
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-org3 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
fabric-ca-client register --caname ca-org3 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
echo
|
infoln "Registering user"
|
||||||
echo "Register user"
|
|
||||||
echo
|
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-org3 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
fabric-ca-client register --caname ca-org3 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
echo
|
infoln "Registering the org admin"
|
||||||
echo "Register the org admin"
|
|
||||||
echo
|
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-org3 --id.name org3admin --id.secret org3adminpw --id.type admin --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
fabric-ca-client register --caname ca-org3 --id.name org3admin --id.secret org3adminpw --id.type admin --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -54,18 +52,14 @@ function createOrg3 {
|
||||||
mkdir -p ../organizations/peerOrganizations/org3.example.com/peers
|
mkdir -p ../organizations/peerOrganizations/org3.example.com/peers
|
||||||
mkdir -p ../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com
|
mkdir -p ../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com
|
||||||
|
|
||||||
echo
|
infoln "Generating the peer0 msp"
|
||||||
echo "## Generate the peer0 msp"
|
|
||||||
echo
|
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp --csr.hosts peer0.org3.example.com --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp --csr.hosts peer0.org3.example.com --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/config.yaml
|
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/config.yaml
|
||||||
|
|
||||||
echo
|
infoln "Generating the peer0-tls certificates"
|
||||||
echo "## Generate the peer0-tls certificates"
|
|
||||||
echo
|
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls --enrollment.profile tls --csr.hosts peer0.org3.example.com --csr.hosts localhost --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls --enrollment.profile tls --csr.hosts peer0.org3.example.com --csr.hosts localhost --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -87,9 +81,7 @@ function createOrg3 {
|
||||||
mkdir -p ../organizations/peerOrganizations/org3.example.com/users
|
mkdir -p ../organizations/peerOrganizations/org3.example.com/users
|
||||||
mkdir -p ../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com
|
mkdir -p ../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com
|
||||||
|
|
||||||
echo
|
infoln "Generating the user msp"
|
||||||
echo "## Generate the user msp"
|
|
||||||
echo
|
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://user1:user1pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
fabric-ca-client enroll -u https://user1:user1pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -98,13 +90,10 @@ function createOrg3 {
|
||||||
|
|
||||||
mkdir -p ../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com
|
mkdir -p ../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com
|
||||||
|
|
||||||
echo
|
infoln "Generating the org admin msp"
|
||||||
echo "## Generate the org admin msp"
|
|
||||||
echo
|
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://org3admin:org3adminpw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
fabric-ca-client enroll -u https://org3admin:org3adminpw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/config.yaml
|
cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/config.yaml
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,3 +123,25 @@ services:
|
||||||
- 9051:9051
|
- 9051:9051
|
||||||
networks:
|
networks:
|
||||||
- test
|
- test
|
||||||
|
|
||||||
|
cli:
|
||||||
|
container_name: cli
|
||||||
|
image: hyperledger/fabric-tools:$IMAGE_TAG
|
||||||
|
tty: true
|
||||||
|
stdin_open: true
|
||||||
|
environment:
|
||||||
|
- GOPATH=/opt/gopath
|
||||||
|
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
|
||||||
|
- FABRIC_LOGGING_SPEC=INFO
|
||||||
|
#- FABRIC_LOGGING_SPEC=DEBUG
|
||||||
|
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
|
||||||
|
command: /bin/bash
|
||||||
|
volumes:
|
||||||
|
- /var/run/:/host/var/run/
|
||||||
|
- ../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
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export PATH=${PWD}/../bin:$PATH
|
||||||
export FABRIC_CFG_PATH=${PWD}/configtx
|
export FABRIC_CFG_PATH=${PWD}/configtx
|
||||||
export VERBOSE=false
|
export VERBOSE=false
|
||||||
|
|
||||||
source scriptUtils.sh
|
. scripts/utils.sh
|
||||||
|
|
||||||
# Obtain CONTAINER_IDS and remove them
|
# Obtain CONTAINER_IDS and remove them
|
||||||
# TODO Might want to make this optional - could clear other containers
|
# TODO Might want to make this optional - could clear other containers
|
||||||
|
|
@ -131,7 +131,6 @@ function checkPrereqs() {
|
||||||
|
|
||||||
# Create Organization crypto material using cryptogen or CAs
|
# Create Organization crypto material using cryptogen or CAs
|
||||||
function createOrgs() {
|
function createOrgs() {
|
||||||
|
|
||||||
if [ -d "organizations/peerOrganizations" ]; then
|
if [ -d "organizations/peerOrganizations" ]; then
|
||||||
rm -Rf organizations/peerOrganizations && rm -Rf organizations/ordererOrganizations
|
rm -Rf organizations/peerOrganizations && rm -Rf organizations/ordererOrganizations
|
||||||
fi
|
fi
|
||||||
|
|
@ -142,9 +141,9 @@ function createOrgs() {
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
fatalln "cryptogen tool not found. exiting"
|
fatalln "cryptogen tool not found. exiting"
|
||||||
fi
|
fi
|
||||||
infoln "Generate certificates using cryptogen tool"
|
infoln "Generating certificates using cryptogen tool"
|
||||||
|
|
||||||
infoln "Create Org1 Identities"
|
infoln "Creating Org1 Identities"
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output="organizations"
|
cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output="organizations"
|
||||||
|
|
@ -154,7 +153,7 @@ function createOrgs() {
|
||||||
fatalln "Failed to generate certificates..."
|
fatalln "Failed to generate certificates..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
infoln "Create Org2 Identities"
|
infoln "Creating Org2 Identities"
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output="organizations"
|
cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output="organizations"
|
||||||
|
|
@ -164,7 +163,7 @@ function createOrgs() {
|
||||||
fatalln "Failed to generate certificates..."
|
fatalln "Failed to generate certificates..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
infoln "Create Orderer Org Identities"
|
infoln "Creating Orderer Org Identities"
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output="organizations"
|
cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output="organizations"
|
||||||
|
|
@ -176,10 +175,9 @@ function createOrgs() {
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create crypto material using Fabric CAs
|
# Create crypto material using Fabric CA
|
||||||
if [ "$CRYPTO" == "Certificate Authorities" ]; then
|
if [ "$CRYPTO" == "Certificate Authorities" ]; then
|
||||||
|
infoln "Generating certificates using Fabric CA"
|
||||||
infoln "Generate certificates using Fabric CA's"
|
|
||||||
|
|
||||||
IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA up -d 2>&1
|
IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA up -d 2>&1
|
||||||
|
|
||||||
|
|
@ -194,21 +192,21 @@ function createOrgs() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
infoln "Create Org1 Identities"
|
infoln "Creating Org1 Identities"
|
||||||
|
|
||||||
createOrg1
|
createOrg1
|
||||||
|
|
||||||
infoln "Create Org2 Identities"
|
infoln "Creating Org2 Identities"
|
||||||
|
|
||||||
createOrg2
|
createOrg2
|
||||||
|
|
||||||
infoln "Create Orderer Org Identities"
|
infoln "Creating Orderer Org Identities"
|
||||||
|
|
||||||
createOrderer
|
createOrderer
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
infoln "Generate CCP files for Org1 and Org2"
|
infoln "Generating CCP files for Org1 and Org2"
|
||||||
./organizations/ccp-generate.sh
|
./organizations/ccp-generate.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,7 +238,6 @@ function createOrgs() {
|
||||||
|
|
||||||
# Generate orderer system channel genesis block.
|
# Generate orderer system channel genesis block.
|
||||||
function createConsortium() {
|
function createConsortium() {
|
||||||
|
|
||||||
which configtxgen
|
which configtxgen
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
fatalln "configtxgen tool not found."
|
fatalln "configtxgen tool not found."
|
||||||
|
|
@ -267,7 +264,6 @@ function createConsortium() {
|
||||||
|
|
||||||
# Bring up the peer and orderer nodes using docker compose.
|
# Bring up the peer and orderer nodes using docker compose.
|
||||||
function networkUp() {
|
function networkUp() {
|
||||||
|
|
||||||
checkPrereqs
|
checkPrereqs
|
||||||
# generate artifacts if they don't exist
|
# generate artifacts if they don't exist
|
||||||
if [ ! -d "organizations/peerOrganizations" ]; then
|
if [ ! -d "organizations/peerOrganizations" ]; then
|
||||||
|
|
@ -289,10 +285,10 @@ function networkUp() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## call the script to join create the channel and join the peers of org1 and org2
|
# call the script to create the channel, join the peers of org1 and org2,
|
||||||
|
# and then update the anchor peers for each organization
|
||||||
function createChannel() {
|
function createChannel() {
|
||||||
|
# Bring up the network if it is not already up.
|
||||||
## Bring up the network if it is not already up.
|
|
||||||
|
|
||||||
if [ ! -d "organizations/peerOrganizations" ]; then
|
if [ ! -d "organizations/peerOrganizations" ]; then
|
||||||
infoln "Bringing up network"
|
infoln "Bringing up network"
|
||||||
|
|
@ -304,23 +300,16 @@ function createChannel() {
|
||||||
# configtx.yaml is mounted in the cli container, which allows us to use it to
|
# configtx.yaml is mounted in the cli container, which allows us to use it to
|
||||||
# create the channel artifacts
|
# create the channel artifacts
|
||||||
scripts/createChannel.sh $CHANNEL_NAME $CLI_DELAY $MAX_RETRY $VERBOSE
|
scripts/createChannel.sh $CHANNEL_NAME $CLI_DELAY $MAX_RETRY $VERBOSE
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fatalln "Create channel failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## Call the script to deploy a chaincode to the channel
|
## Call the script to deploy a chaincode to the channel
|
||||||
function deployCC() {
|
function deployCC() {
|
||||||
|
|
||||||
scripts/deployCC.sh $CHANNEL_NAME $CC_NAME $CC_SRC_PATH $CC_SRC_LANGUAGE $CC_VERSION $CC_SEQUENCE $CC_INIT_FCN $CC_END_POLICY $CC_COLL_CONFIG $CLI_DELAY $MAX_RETRY $VERBOSE
|
scripts/deployCC.sh $CHANNEL_NAME $CC_NAME $CC_SRC_PATH $CC_SRC_LANGUAGE $CC_VERSION $CC_SEQUENCE $CC_INIT_FCN $CC_END_POLICY $CC_COLL_CONFIG $CLI_DELAY $MAX_RETRY $VERBOSE
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
fatalln "Deploying chaincode failed"
|
fatalln "Deploying chaincode failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -345,7 +334,6 @@ function networkDown() {
|
||||||
docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf addOrg3/fabric-ca/org3/msp addOrg3/fabric-ca/org3/tls-cert.pem addOrg3/fabric-ca/org3/ca-cert.pem addOrg3/fabric-ca/org3/IssuerPublicKey addOrg3/fabric-ca/org3/IssuerRevocationPublicKey addOrg3/fabric-ca/org3/fabric-ca-server.db'
|
docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf addOrg3/fabric-ca/org3/msp addOrg3/fabric-ca/org3/tls-cert.pem addOrg3/fabric-ca/org3/ca-cert.pem addOrg3/fabric-ca/org3/IssuerPublicKey addOrg3/fabric-ca/org3/IssuerRevocationPublicKey addOrg3/fabric-ca/org3/fabric-ca-server.db'
|
||||||
# remove channel and script artifacts
|
# remove channel and script artifacts
|
||||||
docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf channel-artifacts log.txt *.tar.gz'
|
docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf channel-artifacts log.txt *.tar.gz'
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source scriptUtils.sh
|
source scripts/utils.sh
|
||||||
|
|
||||||
function createOrg1() {
|
function createOrg1() {
|
||||||
|
infoln "Enrolling the CA admin"
|
||||||
infoln "Enroll the CA admin"
|
|
||||||
mkdir -p organizations/peerOrganizations/org1.example.com/
|
mkdir -p organizations/peerOrganizations/org1.example.com/
|
||||||
|
|
||||||
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org1.example.com/
|
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org1.example.com/
|
||||||
|
|
@ -30,17 +29,17 @@ function createOrg1() {
|
||||||
Certificate: cacerts/localhost-7054-ca-org1.pem
|
Certificate: cacerts/localhost-7054-ca-org1.pem
|
||||||
OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml
|
OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml
|
||||||
|
|
||||||
infoln "Register peer0"
|
infoln "Registering peer0"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-org1 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
fabric-ca-client register --caname ca-org1 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
infoln "Register user"
|
infoln "Registering user"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-org1 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
fabric-ca-client register --caname ca-org1 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
infoln "Register the org admin"
|
infoln "Registering the org admin"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-org1 --id.name org1admin --id.secret org1adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
fabric-ca-client register --caname ca-org1 --id.name org1admin --id.secret org1adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -48,14 +47,14 @@ function createOrg1() {
|
||||||
mkdir -p organizations/peerOrganizations/org1.example.com/peers
|
mkdir -p organizations/peerOrganizations/org1.example.com/peers
|
||||||
mkdir -p organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com
|
mkdir -p organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com
|
||||||
|
|
||||||
infoln "Generate the peer0 msp"
|
infoln "Generating the peer0 msp"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp --csr.hosts peer0.org1.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp --csr.hosts peer0.org1.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/config.yaml
|
cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/config.yaml
|
||||||
|
|
||||||
infoln "Generate the peer0-tls certificates"
|
infoln "Generating the peer0-tls certificates"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls --enrollment.profile tls --csr.hosts peer0.org1.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls --enrollment.profile tls --csr.hosts peer0.org1.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -76,7 +75,7 @@ function createOrg1() {
|
||||||
mkdir -p organizations/peerOrganizations/org1.example.com/users
|
mkdir -p organizations/peerOrganizations/org1.example.com/users
|
||||||
mkdir -p organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com
|
mkdir -p organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com
|
||||||
|
|
||||||
infoln "Generate the user msp"
|
infoln "Generating the user msp"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://user1:user1pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
fabric-ca-client enroll -u https://user1:user1pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -85,18 +84,16 @@ function createOrg1() {
|
||||||
|
|
||||||
mkdir -p organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com
|
mkdir -p organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com
|
||||||
|
|
||||||
infoln "Generate the org admin msp"
|
infoln "Generating the org admin msp"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://org1admin:org1adminpw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
fabric-ca-client enroll -u https://org1admin:org1adminpw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/config.yaml
|
cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/config.yaml
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOrg2() {
|
function createOrg2() {
|
||||||
|
infoln "Enrolling the CA admin"
|
||||||
infoln "Enroll the CA admin"
|
|
||||||
mkdir -p organizations/peerOrganizations/org2.example.com/
|
mkdir -p organizations/peerOrganizations/org2.example.com/
|
||||||
|
|
||||||
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org2.example.com/
|
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org2.example.com/
|
||||||
|
|
@ -122,17 +119,17 @@ function createOrg2() {
|
||||||
Certificate: cacerts/localhost-8054-ca-org2.pem
|
Certificate: cacerts/localhost-8054-ca-org2.pem
|
||||||
OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml
|
OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml
|
||||||
|
|
||||||
infoln "Register peer0"
|
infoln "Registering peer0"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-org2 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
fabric-ca-client register --caname ca-org2 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
infoln "Register user"
|
infoln "Registering user"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-org2 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
fabric-ca-client register --caname ca-org2 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
infoln "Register the org admin"
|
infoln "Registering the org admin"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-org2 --id.name org2admin --id.secret org2adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
fabric-ca-client register --caname ca-org2 --id.name org2admin --id.secret org2adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -140,14 +137,14 @@ function createOrg2() {
|
||||||
mkdir -p organizations/peerOrganizations/org2.example.com/peers
|
mkdir -p organizations/peerOrganizations/org2.example.com/peers
|
||||||
mkdir -p organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com
|
mkdir -p organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com
|
||||||
|
|
||||||
infoln "Generate the peer0 msp"
|
infoln "Generating the peer0 msp"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp --csr.hosts peer0.org2.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp --csr.hosts peer0.org2.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/config.yaml
|
cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/config.yaml
|
||||||
|
|
||||||
infoln "Generate the peer0-tls certificates"
|
infoln "Generating the peer0-tls certificates"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls --enrollment.profile tls --csr.hosts peer0.org2.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls --enrollment.profile tls --csr.hosts peer0.org2.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -168,7 +165,7 @@ function createOrg2() {
|
||||||
mkdir -p organizations/peerOrganizations/org2.example.com/users
|
mkdir -p organizations/peerOrganizations/org2.example.com/users
|
||||||
mkdir -p organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com
|
mkdir -p organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com
|
||||||
|
|
||||||
infoln "Generate the user msp"
|
infoln "Generating the user msp"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://user1:user1pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
fabric-ca-client enroll -u https://user1:user1pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -177,18 +174,16 @@ function createOrg2() {
|
||||||
|
|
||||||
mkdir -p organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com
|
mkdir -p organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com
|
||||||
|
|
||||||
infoln "Generate the org admin msp"
|
infoln "Generating the org admin msp"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/config.yaml
|
cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/config.yaml
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOrderer() {
|
function createOrderer() {
|
||||||
|
infoln "Enrolling the CA admin"
|
||||||
infoln "Enroll the CA admin"
|
|
||||||
mkdir -p organizations/ordererOrganizations/example.com
|
mkdir -p organizations/ordererOrganizations/example.com
|
||||||
|
|
||||||
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/ordererOrganizations/example.com
|
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/ordererOrganizations/example.com
|
||||||
|
|
@ -214,12 +209,12 @@ function createOrderer() {
|
||||||
Certificate: cacerts/localhost-9054-ca-orderer.pem
|
Certificate: cacerts/localhost-9054-ca-orderer.pem
|
||||||
OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml
|
OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml
|
||||||
|
|
||||||
infoln "Register orderer"
|
infoln "Registering orderer"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-orderer --id.name orderer --id.secret ordererpw --id.type orderer --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
fabric-ca-client register --caname ca-orderer --id.name orderer --id.secret ordererpw --id.type orderer --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
infoln "Register the orderer admin"
|
infoln "Registering the orderer admin"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client register --caname ca-orderer --id.name ordererAdmin --id.secret ordererAdminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
fabric-ca-client register --caname ca-orderer --id.name ordererAdmin --id.secret ordererAdminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -229,14 +224,14 @@ function createOrderer() {
|
||||||
|
|
||||||
mkdir -p organizations/ordererOrganizations/example.com/orderers/orderer.example.com
|
mkdir -p organizations/ordererOrganizations/example.com/orderers/orderer.example.com
|
||||||
|
|
||||||
infoln "Generate the orderer msp"
|
infoln "Generating the orderer msp"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/config.yaml
|
cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/config.yaml
|
||||||
|
|
||||||
infoln "Generate the orderer-tls certificates"
|
infoln "Generating the orderer-tls certificates"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls --enrollment.profile tls --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls --enrollment.profile tls --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
@ -254,11 +249,10 @@ function createOrderer() {
|
||||||
mkdir -p organizations/ordererOrganizations/example.com/users
|
mkdir -p organizations/ordererOrganizations/example.com/users
|
||||||
mkdir -p organizations/ordererOrganizations/example.com/users/Admin@example.com
|
mkdir -p organizations/ordererOrganizations/example.com/users/Admin@example.com
|
||||||
|
|
||||||
infoln "Generate the admin msp"
|
infoln "Generating the admin msp"
|
||||||
set -x
|
set -x
|
||||||
fabric-ca-client enroll -u https://ordererAdmin:ordererAdminpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
fabric-ca-client enroll -u https://ordererAdmin:ordererAdminpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/config.yaml
|
cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/config.yaml
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
61
test-network/scripts/configUpdate.sh
Executable file
61
test-network/scripts/configUpdate.sh
Executable file
|
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
# import utils
|
||||||
|
. scripts/envVar.sh
|
||||||
|
|
||||||
|
# fetchChannelConfig <org> <channel_id> <output_json>
|
||||||
|
# Writes the current channel config for a given channel to a JSON file
|
||||||
|
# NOTE: this must be run in a CLI container since it requires configtxlator
|
||||||
|
fetchChannelConfig() {
|
||||||
|
ORG=$1
|
||||||
|
CHANNEL=$2
|
||||||
|
OUTPUT=$3
|
||||||
|
|
||||||
|
setGlobals $ORG
|
||||||
|
|
||||||
|
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
|
||||||
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
|
infoln "Decoding config block to JSON and isolating config to ${OUTPUT}"
|
||||||
|
set -x
|
||||||
|
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config >"${OUTPUT}"
|
||||||
|
{ set +x; } 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# createConfigUpdate <channel_id> <original_config.json> <modified_config.json> <output.pb>
|
||||||
|
# Takes an original and modified config, and produces the config update tx
|
||||||
|
# which transitions between the two
|
||||||
|
# NOTE: this must be run in a CLI container since it requires configtxlator
|
||||||
|
createConfigUpdate() {
|
||||||
|
CHANNEL=$1
|
||||||
|
ORIGINAL=$2
|
||||||
|
MODIFIED=$3
|
||||||
|
OUTPUT=$4
|
||||||
|
|
||||||
|
set -x
|
||||||
|
configtxlator proto_encode --input "${ORIGINAL}" --type common.Config >original_config.pb
|
||||||
|
configtxlator proto_encode --input "${MODIFIED}" --type common.Config >modified_config.pb
|
||||||
|
configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb >config_update.pb
|
||||||
|
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate >config_update.json
|
||||||
|
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . >config_update_in_envelope.json
|
||||||
|
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope >"${OUTPUT}"
|
||||||
|
{ set +x; } 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# signConfigtxAsPeerOrg <org> <configtx.pb>
|
||||||
|
# Set the peerOrg admin of an org and sign the config update
|
||||||
|
signConfigtxAsPeerOrg() {
|
||||||
|
ORG=$1
|
||||||
|
CONFIGTXFILE=$2
|
||||||
|
setGlobals $ORG
|
||||||
|
set -x
|
||||||
|
peer channel signconfigtx -f "${CONFIGTXFILE}"
|
||||||
|
{ set +x; } 2>/dev/null
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source scriptUtils.sh
|
# imports
|
||||||
|
. scripts/envVar.sh
|
||||||
|
. scripts/utils.sh
|
||||||
|
|
||||||
CHANNEL_NAME="$1"
|
CHANNEL_NAME="$1"
|
||||||
DELAY="$2"
|
DELAY="$2"
|
||||||
|
|
@ -11,38 +13,16 @@ VERBOSE="$4"
|
||||||
: ${MAX_RETRY:="5"}
|
: ${MAX_RETRY:="5"}
|
||||||
: ${VERBOSE:="false"}
|
: ${VERBOSE:="false"}
|
||||||
|
|
||||||
# import utils
|
|
||||||
. scripts/envVar.sh
|
|
||||||
|
|
||||||
if [ ! -d "channel-artifacts" ]; then
|
if [ ! -d "channel-artifacts" ]; then
|
||||||
mkdir channel-artifacts
|
mkdir channel-artifacts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
createChannelTx() {
|
createChannelTx() {
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/${CHANNEL_NAME}.tx -channelID $CHANNEL_NAME
|
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/${CHANNEL_NAME}.tx -channelID $CHANNEL_NAME
|
||||||
res=$?
|
res=$?
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
if [ $res -ne 0 ]; then
|
verifyResult $res "Failed to generate channel configuration transaction..."
|
||||||
fatalln "Failed to generate channel configuration transaction..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
createAnchorPeerTx() {
|
|
||||||
|
|
||||||
for orgmsp in Org1MSP Org2MSP; do
|
|
||||||
|
|
||||||
infoln "Generating anchor peer update transaction for ${orgmsp}"
|
|
||||||
set -x
|
|
||||||
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/${orgmsp}anchors.tx -channelID $CHANNEL_NAME -asOrg ${orgmsp}
|
|
||||||
res=$?
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
if [ $res -ne 0 ]; then
|
|
||||||
fatalln "Failed to generate anchor peer update transaction for ${orgmsp}..."
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createChannel() {
|
createChannel() {
|
||||||
|
|
@ -53,7 +33,7 @@ createChannel() {
|
||||||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
set -x
|
set -x
|
||||||
peer channel create -o localhost:7050 -c $CHANNEL_NAME --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block --tls --cafile $ORDERER_CA >&log.txt
|
peer channel create -o localhost:7050 -c $CHANNEL_NAME --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock $BLOCKFILE --tls --cafile $ORDERER_CA >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
let rc=$res
|
let rc=$res
|
||||||
|
|
@ -61,11 +41,11 @@ createChannel() {
|
||||||
done
|
done
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Channel creation failed"
|
verifyResult $res "Channel creation failed"
|
||||||
successln "Channel '$CHANNEL_NAME' created"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# queryCommitted ORG
|
# joinChannel ORG
|
||||||
joinChannel() {
|
joinChannel() {
|
||||||
|
FABRIC_CFG_PATH=$PWD/../config/
|
||||||
ORG=$1
|
ORG=$1
|
||||||
setGlobals $ORG
|
setGlobals $ORG
|
||||||
local rc=1
|
local rc=1
|
||||||
|
|
@ -74,7 +54,7 @@ joinChannel() {
|
||||||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
set -x
|
set -x
|
||||||
peer channel join -b ./channel-artifacts/$CHANNEL_NAME.block >&log.txt
|
peer channel join -b $BLOCKFILE >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
let rc=$res
|
let rc=$res
|
||||||
|
|
@ -84,31 +64,9 @@ joinChannel() {
|
||||||
verifyResult $res "After $MAX_RETRY attempts, peer0.org${ORG} has failed to join channel '$CHANNEL_NAME' "
|
verifyResult $res "After $MAX_RETRY attempts, peer0.org${ORG} has failed to join channel '$CHANNEL_NAME' "
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAnchorPeers() {
|
setAnchorPeer() {
|
||||||
ORG=$1
|
ORG=$1
|
||||||
setGlobals $ORG
|
docker exec cli ./scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME
|
||||||
local rc=1
|
|
||||||
local COUNTER=1
|
|
||||||
## Sometimes Join takes time, hence retry
|
|
||||||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
|
||||||
sleep $DELAY
|
|
||||||
set -x
|
|
||||||
peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls --cafile $ORDERER_CA >&log.txt
|
|
||||||
res=$?
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
let rc=$res
|
|
||||||
COUNTER=$(expr $COUNTER + 1)
|
|
||||||
done
|
|
||||||
cat log.txt
|
|
||||||
verifyResult $res "Anchor peer update failed"
|
|
||||||
successln "Anchor peers updated for org '$CORE_PEER_LOCALMSPID' on channel '$CHANNEL_NAME'"
|
|
||||||
sleep $DELAY
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyResult() {
|
|
||||||
if [ $1 -ne 0 ]; then
|
|
||||||
fatalln "$2"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FABRIC_CFG_PATH=${PWD}/configtx
|
FABRIC_CFG_PATH=${PWD}/configtx
|
||||||
|
|
@ -117,28 +75,24 @@ FABRIC_CFG_PATH=${PWD}/configtx
|
||||||
infoln "Generating channel create transaction '${CHANNEL_NAME}.tx'"
|
infoln "Generating channel create transaction '${CHANNEL_NAME}.tx'"
|
||||||
createChannelTx
|
createChannelTx
|
||||||
|
|
||||||
## Create anchorpeertx
|
|
||||||
infoln "Generating anchor peer update transactions"
|
|
||||||
createAnchorPeerTx
|
|
||||||
|
|
||||||
FABRIC_CFG_PATH=$PWD/../config/
|
FABRIC_CFG_PATH=$PWD/../config/
|
||||||
|
BLOCKFILE="./channel-artifacts/${CHANNEL_NAME}.block"
|
||||||
|
|
||||||
## Create channel
|
## Create channel
|
||||||
infoln "Creating channel ${CHANNEL_NAME}"
|
infoln "Creating channel ${CHANNEL_NAME}"
|
||||||
createChannel
|
createChannel
|
||||||
|
successln "Channel '$CHANNEL_NAME' created"
|
||||||
|
|
||||||
## Join all the peers to the channel
|
## Join all the peers to the channel
|
||||||
infoln "Join Org1 peers to the channel..."
|
infoln "Joining org1 peer to the channel..."
|
||||||
joinChannel 1
|
joinChannel 1
|
||||||
infoln "Join Org2 peers to the channel..."
|
infoln "Joining org2 peer to the channel..."
|
||||||
joinChannel 2
|
joinChannel 2
|
||||||
|
|
||||||
## Set the anchor peers for each org in the channel
|
## Set the anchor peers for each org in the channel
|
||||||
infoln "Updating anchor peers for org1..."
|
infoln "Setting anchor peer for org1..."
|
||||||
updateAnchorPeers 1
|
setAnchorPeer 1
|
||||||
infoln "Updating anchor peers for org2..."
|
infoln "Setting anchor peer for org2..."
|
||||||
updateAnchorPeers 2
|
setAnchorPeer 2
|
||||||
|
|
||||||
successln "Channel successfully joined"
|
successln "Channel '$CHANNEL_NAME' joined"
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source scriptUtils.sh
|
source scripts/utils.sh
|
||||||
|
|
||||||
CHANNEL_NAME=${1:-"mychannel"}
|
CHANNEL_NAME=${1:-"mychannel"}
|
||||||
CC_NAME=${2}
|
CC_NAME=${2}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Copyright IBM Corp All Rights Reserved
|
# Copyright IBM Corp All Rights Reserved
|
||||||
#
|
#
|
||||||
|
|
@ -6,7 +7,8 @@
|
||||||
|
|
||||||
# This is a collection of bash functions used by different scripts
|
# This is a collection of bash functions used by different scripts
|
||||||
|
|
||||||
source scriptUtils.sh
|
# imports
|
||||||
|
. scripts/utils.sh
|
||||||
|
|
||||||
export CORE_PEER_TLS_ENABLED=true
|
export CORE_PEER_TLS_ENABLED=true
|
||||||
export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
||||||
|
|
@ -14,13 +16,6 @@ export PEER0_ORG1_CA=${PWD}/organizations/peerOrganizations/org1.example.com/pee
|
||||||
export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
|
export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
|
||||||
export PEER0_ORG3_CA=${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
|
export PEER0_ORG3_CA=${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
|
||||||
|
|
||||||
# Set OrdererOrg.Admin globals
|
|
||||||
setOrdererGlobals() {
|
|
||||||
export CORE_PEER_LOCALMSPID="OrdererMSP"
|
|
||||||
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
|
||||||
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set environment variables for the peer org
|
# Set environment variables for the peer org
|
||||||
setGlobals() {
|
setGlobals() {
|
||||||
local USING_ORG=""
|
local USING_ORG=""
|
||||||
|
|
@ -55,11 +50,31 @@ setGlobals() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set environment variables for use in the CLI container
|
||||||
|
setGlobalsCLI() {
|
||||||
|
setGlobals $1
|
||||||
|
|
||||||
|
local USING_ORG=""
|
||||||
|
if [ -z "$OVERRIDE_ORG" ]; then
|
||||||
|
USING_ORG=$1
|
||||||
|
else
|
||||||
|
USING_ORG="${OVERRIDE_ORG}"
|
||||||
|
fi
|
||||||
|
if [ $USING_ORG -eq 1 ]; then
|
||||||
|
export CORE_PEER_ADDRESS=peer0.org1.example.com:7051
|
||||||
|
elif [ $USING_ORG -eq 2 ]; then
|
||||||
|
export CORE_PEER_ADDRESS=peer0.org2.example.com:9051
|
||||||
|
elif [ $USING_ORG -eq 3 ]; then
|
||||||
|
export CORE_PEER_ADDRESS=peer0.org3.example.com:11051
|
||||||
|
else
|
||||||
|
errorln "ORG Unknown"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# parsePeerConnectionParameters $@
|
# parsePeerConnectionParameters $@
|
||||||
# Helper function that sets the peer connection parameters for a chaincode
|
# Helper function that sets the peer connection parameters for a chaincode
|
||||||
# operation
|
# operation
|
||||||
parsePeerConnectionParameters() {
|
parsePeerConnectionParameters() {
|
||||||
|
|
||||||
PEER_CONN_PARMS=""
|
PEER_CONN_PARMS=""
|
||||||
PEERS=""
|
PEERS=""
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright IBM Corp All Rights Reserved
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
# This is a collection of bash functions used by different scripts
|
|
||||||
|
|
||||||
ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
|
||||||
PEER0_ORG1_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
|
|
||||||
PEER0_ORG2_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
|
|
||||||
PEER0_ORG3_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
|
|
||||||
|
|
||||||
# Set OrdererOrg.Admin globals
|
|
||||||
setOrdererGlobals() {
|
|
||||||
CORE_PEER_LOCALMSPID="OrdererMSP"
|
|
||||||
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
|
||||||
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set environment variables for the peer org
|
|
||||||
setGlobals() {
|
|
||||||
ORG=$1
|
|
||||||
if [ $ORG -eq 1 ]; then
|
|
||||||
CORE_PEER_LOCALMSPID="Org1MSP"
|
|
||||||
CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG1_CA
|
|
||||||
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
|
|
||||||
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
|
|
||||||
elif [ $ORG -eq 2 ]; then
|
|
||||||
CORE_PEER_LOCALMSPID="Org2MSP"
|
|
||||||
CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG2_CA
|
|
||||||
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
|
|
||||||
CORE_PEER_ADDRESS=peer0.org2.example.com:9051
|
|
||||||
elif [ $ORG -eq 3 ]; then
|
|
||||||
CORE_PEER_LOCALMSPID="Org3MSP"
|
|
||||||
CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG3_CA
|
|
||||||
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
|
|
||||||
CORE_PEER_ADDRESS=peer0.org3.example.com:11051
|
|
||||||
else
|
|
||||||
echo "================== ERROR !!! ORG Unknown =================="
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$VERBOSE" == "true" ]; then
|
|
||||||
env | grep CORE
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyResult() {
|
|
||||||
if [ $1 -ne 0 ]; then
|
|
||||||
echo $'\e[1;31m'!!!!!!!!!!!!!!! $2 !!!!!!!!!!!!!!!!$'\e[0m'
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
70
test-network/scripts/org3-scripts/joinChannel.sh
Executable file
70
test-network/scripts/org3-scripts/joinChannel.sh
Executable file
|
|
@ -0,0 +1,70 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
# This script is designed to be run in the cli container as the
|
||||||
|
# second step of the EYFN tutorial. It joins the org3 peers to the
|
||||||
|
# channel previously setup in the BYFN tutorial and install the
|
||||||
|
# chaincode as version 2.0 on peer0.org3.
|
||||||
|
#
|
||||||
|
|
||||||
|
CHANNEL_NAME="$1"
|
||||||
|
DELAY="$2"
|
||||||
|
TIMEOUT="$3"
|
||||||
|
VERBOSE="$4"
|
||||||
|
: ${CHANNEL_NAME:="mychannel"}
|
||||||
|
: ${DELAY:="3"}
|
||||||
|
: ${TIMEOUT:="10"}
|
||||||
|
: ${VERBOSE:="false"}
|
||||||
|
COUNTER=1
|
||||||
|
MAX_RETRY=5
|
||||||
|
|
||||||
|
# import environment variables
|
||||||
|
. scripts/envVar.sh
|
||||||
|
|
||||||
|
# joinChannel ORG
|
||||||
|
joinChannel() {
|
||||||
|
ORG=$1
|
||||||
|
local rc=1
|
||||||
|
local COUNTER=1
|
||||||
|
## Sometimes Join takes time, hence retry
|
||||||
|
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
||||||
|
sleep $DELAY
|
||||||
|
set -x
|
||||||
|
peer channel join -b $BLOCKFILE >&log.txt
|
||||||
|
res=$?
|
||||||
|
{ set +x; } 2>/dev/null
|
||||||
|
let rc=$res
|
||||||
|
COUNTER=$(expr $COUNTER + 1)
|
||||||
|
done
|
||||||
|
cat log.txt
|
||||||
|
verifyResult $res "After $MAX_RETRY attempts, peer0.org${ORG} has failed to join channel '$CHANNEL_NAME' "
|
||||||
|
}
|
||||||
|
|
||||||
|
setAnchorPeer() {
|
||||||
|
ORG=$1
|
||||||
|
scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
setGlobalsCLI 3
|
||||||
|
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
|
||||||
|
res=$?
|
||||||
|
{ set +x; } 2>/dev/null
|
||||||
|
cat log.txt
|
||||||
|
verifyResult $res "Fetching config block from orderer has failed"
|
||||||
|
|
||||||
|
infoln "Joining org3 peer to the channel..."
|
||||||
|
joinChannel 3
|
||||||
|
|
||||||
|
infoln "Setting anchor peer for org3..."
|
||||||
|
setAnchorPeer 3
|
||||||
|
|
||||||
|
successln "Channel '$CHANNEL_NAME' joined"
|
||||||
|
successln "Org3 peer successfully added to network"
|
||||||
|
|
@ -1,116 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright IBM Corp. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
# This script is designed to be run in the org3cli container as the
|
|
||||||
# first step of the EYFN tutorial. It creates and submits a
|
|
||||||
# configuration transaction to add org3 to the test network
|
|
||||||
#
|
|
||||||
|
|
||||||
CHANNEL_NAME="$1"
|
|
||||||
DELAY="$2"
|
|
||||||
TIMEOUT="$3"
|
|
||||||
VERBOSE="$4"
|
|
||||||
: ${CHANNEL_NAME:="mychannel"}
|
|
||||||
: ${DELAY:="3"}
|
|
||||||
: ${TIMEOUT:="10"}
|
|
||||||
: ${VERBOSE:="false"}
|
|
||||||
COUNTER=1
|
|
||||||
MAX_RETRY=5
|
|
||||||
|
|
||||||
|
|
||||||
# import environment variables
|
|
||||||
. scripts/org3-scripts/envVarCLI.sh
|
|
||||||
|
|
||||||
|
|
||||||
# fetchChannelConfig <channel_id> <output_json>
|
|
||||||
# Writes the current channel config for a given channel to a JSON file
|
|
||||||
fetchChannelConfig() {
|
|
||||||
ORG=$1
|
|
||||||
CHANNEL=$2
|
|
||||||
OUTPUT=$3
|
|
||||||
|
|
||||||
setOrdererGlobals
|
|
||||||
|
|
||||||
setGlobals $ORG
|
|
||||||
|
|
||||||
echo "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
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
|
|
||||||
echo "Decoding config block to JSON and isolating config to ${OUTPUT}"
|
|
||||||
set -x
|
|
||||||
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config >"${OUTPUT}"
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# createConfigUpdate <channel_id> <original_config.json> <modified_config.json> <output.pb>
|
|
||||||
# Takes an original and modified config, and produces the config update tx
|
|
||||||
# which transitions between the two
|
|
||||||
createConfigUpdate() {
|
|
||||||
CHANNEL=$1
|
|
||||||
ORIGINAL=$2
|
|
||||||
MODIFIED=$3
|
|
||||||
OUTPUT=$4
|
|
||||||
|
|
||||||
set -x
|
|
||||||
configtxlator proto_encode --input "${ORIGINAL}" --type common.Config >original_config.pb
|
|
||||||
configtxlator proto_encode --input "${MODIFIED}" --type common.Config >modified_config.pb
|
|
||||||
configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb >config_update.pb
|
|
||||||
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate >config_update.json
|
|
||||||
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . >config_update_in_envelope.json
|
|
||||||
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope >"${OUTPUT}"
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# signConfigtxAsPeerOrg <org> <configtx.pb>
|
|
||||||
# Set the peerOrg admin of an org and signing the config update
|
|
||||||
signConfigtxAsPeerOrg() {
|
|
||||||
PEERORG=$1
|
|
||||||
TX=$2
|
|
||||||
setGlobals $PEERORG
|
|
||||||
set -x
|
|
||||||
peer channel signconfigtx -f "${TX}"
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "========= Creating config transaction to add org3 to network =========== "
|
|
||||||
echo
|
|
||||||
|
|
||||||
# Fetch the config for the channel, writing it to config.json
|
|
||||||
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
|
|
||||||
{ 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
|
|
||||||
createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org3_update_in_envelope.pb
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "========= Config transaction to add org3 to network created ===== "
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "Signing config transaction"
|
|
||||||
echo
|
|
||||||
signConfigtxAsPeerOrg 1 org3_update_in_envelope.pb
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "========= Submitting transaction from a different peer (peer0.org2) which also signs it ========= "
|
|
||||||
echo
|
|
||||||
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}
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "========= Config transaction to add org3 to network submitted! =========== "
|
|
||||||
echo
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright IBM Corp. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
# This script is designed to be run in the org3cli container as the
|
|
||||||
# second step of the EYFN tutorial. It joins the org3 peers to the
|
|
||||||
# channel previously setup in the BYFN tutorial and install the
|
|
||||||
# chaincode as version 2.0 on peer0.org3.
|
|
||||||
#
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "========= Getting Org3 on to your test network ========= "
|
|
||||||
echo
|
|
||||||
CHANNEL_NAME="$1"
|
|
||||||
DELAY="$2"
|
|
||||||
TIMEOUT="$3"
|
|
||||||
VERBOSE="$4"
|
|
||||||
: ${CHANNEL_NAME:="mychannel"}
|
|
||||||
: ${DELAY:="3"}
|
|
||||||
: ${TIMEOUT:="10"}
|
|
||||||
: ${VERBOSE:="false"}
|
|
||||||
COUNTER=1
|
|
||||||
MAX_RETRY=5
|
|
||||||
|
|
||||||
# import environment variables
|
|
||||||
. scripts/org3-scripts/envVarCLI.sh
|
|
||||||
|
|
||||||
## Sometimes Join takes time hence RETRY at least 5 times
|
|
||||||
joinChannelWithRetry() {
|
|
||||||
ORG=$1
|
|
||||||
setGlobals $ORG
|
|
||||||
|
|
||||||
set -x
|
|
||||||
peer channel join -b $CHANNEL_NAME.block >&log.txt
|
|
||||||
res=$?
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
cat log.txt
|
|
||||||
if [ $res -ne 0 -a $COUNTER -lt $MAX_RETRY ]; then
|
|
||||||
COUNTER=$(expr $COUNTER + 1)
|
|
||||||
echo "peer0.org${ORG} failed to join the channel, Retry after $DELAY seconds"
|
|
||||||
sleep $DELAY
|
|
||||||
joinChannelWithRetry $PEER $ORG
|
|
||||||
else
|
|
||||||
COUNTER=1
|
|
||||||
fi
|
|
||||||
verifyResult $res "After $MAX_RETRY attempts, peer0.org${ORG} has failed to join channel '$CHANNEL_NAME' "
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
echo "Fetching channel config block from orderer..."
|
|
||||||
set -x
|
|
||||||
peer channel fetch 0 $CHANNEL_NAME.block -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME --tls --cafile $ORDERER_CA >&log.txt
|
|
||||||
res=$?
|
|
||||||
{ set +x; } 2>/dev/null
|
|
||||||
cat log.txt
|
|
||||||
verifyResult $res "Fetching config block from orderer has Failed"
|
|
||||||
|
|
||||||
joinChannelWithRetry 3
|
|
||||||
echo "===================== peer0.org3 joined channel '$CHANNEL_NAME' ===================== "
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "========= Finished adding Org3 to your test network! ========= "
|
|
||||||
echo
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
52
test-network/scripts/org3-scripts/updateChannelConfig.sh
Executable file
52
test-network/scripts/org3-scripts/updateChannelConfig.sh
Executable file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
# This script is designed to be run in the cli container as the
|
||||||
|
# first step of the EYFN tutorial. It creates and submits a
|
||||||
|
# configuration transaction to add org3 to the test network
|
||||||
|
#
|
||||||
|
|
||||||
|
CHANNEL_NAME="$1"
|
||||||
|
DELAY="$2"
|
||||||
|
TIMEOUT="$3"
|
||||||
|
VERBOSE="$4"
|
||||||
|
: ${CHANNEL_NAME:="mychannel"}
|
||||||
|
: ${DELAY:="3"}
|
||||||
|
: ${TIMEOUT:="10"}
|
||||||
|
: ${VERBOSE:="false"}
|
||||||
|
COUNTER=1
|
||||||
|
MAX_RETRY=5
|
||||||
|
|
||||||
|
|
||||||
|
# imports
|
||||||
|
. scripts/envVar.sh
|
||||||
|
. scripts/configUpdate.sh
|
||||||
|
. scripts/utils.sh
|
||||||
|
|
||||||
|
infoln "Creating config transaction to add org3 to network"
|
||||||
|
|
||||||
|
# Fetch the config for the channel, writing it to config.json
|
||||||
|
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
|
||||||
|
{ 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
|
||||||
|
createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org3_update_in_envelope.pb
|
||||||
|
|
||||||
|
infoln "Signing config transaction"
|
||||||
|
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}
|
||||||
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
|
successln "Config transaction to add org3 to network submitted"
|
||||||
58
test-network/scripts/setAnchorPeer.sh
Executable file
58
test-network/scripts/setAnchorPeer.sh
Executable file
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright IBM Corp. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
# import utils
|
||||||
|
. scripts/envVar.sh
|
||||||
|
. scripts/configUpdate.sh
|
||||||
|
|
||||||
|
|
||||||
|
# NOTE: this must be run in a CLI container since it requires jq and configtxlator
|
||||||
|
createAnchorPeerUpdate() {
|
||||||
|
infoln "Fetching channel config for channel $CHANNEL_NAME"
|
||||||
|
fetchChannelConfig $ORG $CHANNEL_NAME ${CORE_PEER_LOCALMSPID}config.json
|
||||||
|
|
||||||
|
infoln "Generating anchor peer update transaction for Org${ORG} on channel $CHANNEL_NAME"
|
||||||
|
|
||||||
|
if [ $ORG -eq 1 ]; then
|
||||||
|
HOST="peer0.org1.example.com"
|
||||||
|
PORT=7051
|
||||||
|
elif [ $ORG -eq 2 ]; then
|
||||||
|
HOST="peer0.org2.example.com"
|
||||||
|
PORT=9051
|
||||||
|
elif [ $ORG -eq 3 ]; then
|
||||||
|
HOST="peer0.org3.example.com"
|
||||||
|
PORT=11051
|
||||||
|
else
|
||||||
|
errorln "Org${ORG} unknown"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
|
# Modify the configuration to append the anchor peer
|
||||||
|
jq '.channel_group.groups.Application.groups.'${CORE_PEER_LOCALMSPID}'.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "'$HOST'","port": '$PORT'}]},"version": "0"}}' ${CORE_PEER_LOCALMSPID}config.json > ${CORE_PEER_LOCALMSPID}modified_config.json
|
||||||
|
{ set +x; } 2>/dev/null
|
||||||
|
|
||||||
|
# Compute a config update, based on the differences between
|
||||||
|
# {orgmsp}config.json and {orgmsp}modified_config.json, write
|
||||||
|
# it as a transaction to {orgmsp}anchors.tx
|
||||||
|
createConfigUpdate ${CHANNEL_NAME} ${CORE_PEER_LOCALMSPID}config.json ${CORE_PEER_LOCALMSPID}modified_config.json ${CORE_PEER_LOCALMSPID}anchors.tx
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
res=$?
|
||||||
|
cat log.txt
|
||||||
|
verifyResult $res "Anchor peer update failed"
|
||||||
|
successln "Anchor peer set for org '$CORE_PEER_LOCALMSPID' on channel '$CHANNEL_NAME'"
|
||||||
|
}
|
||||||
|
|
||||||
|
ORG=$1
|
||||||
|
CHANNEL_NAME=$2
|
||||||
|
setGlobalsCLI $ORG
|
||||||
|
|
||||||
|
createAnchorPeerUpdate
|
||||||
|
|
||||||
|
updateAnchorPeer
|
||||||
Loading…
Reference in a new issue