Skip to content

Commit

Permalink
[fabric] Update chaincode charts to be compatible with version 2.5.4
Browse files Browse the repository at this point in the history
Primary Changes
--------------
 1. Updated  chaincode charts
 2. Fixed a bug that occurred when creating the genesis file with an incorrect channel name
 3. Removed $NAME variables from charts due to conflicts

Modifications in docs
-----------------------
docs/source/_static/TopLevelClass-Fabric.png
docs/source/operations/fabric_networkyaml.md

Modifications in charts
-----------------------
platforms/hyperledger-fabric/charts/commit_chaincode/templates/commit_chaincode.yaml platforms/hyperledger-fabric/charts/install_chaincode/templates/install_chaincode.yaml

Modifications in roles and tpl files
-----------------------
platforms/hyperledger-fabric/configuration/chaincode-ops.yaml platforms/hyperledger-fabric/configuration/deploy-network.yaml platforms/hyperledger-fabric/configuration/roles/helm_component/templates/commit_chaincode_job.tpl

Others Modifications
----------------------------------------
platforms/hyperledger-fabric/configuration/samples/network-fabricv2.yaml

fixes #2385

Signed-off-by: mgCepeda <[email protected]>
  • Loading branch information
mgCepeda authored and suvajit-sarkar committed Oct 25, 2023
1 parent d70e20d commit a8cd445
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 39 deletions.
Binary file modified docs/source/_static/TopLevelClass-Fabric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion docs/source/operations/fabric_networkyaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The sections in the sample configuration file are:

`type` defines the platform choice like corda/fabric, here in the example its Fabric

`version` defines the version of platform being used. The current Fabric version support is 1.4.8 & 2.2.2
`version` defines the version of platform being used. The current Fabric version support is 1.4.8, 2.2.2 & 2.5.4

`frontend` is a flag which defines if frontend is enabled for nodes or not. Its value can only be enabled/disabled. This is only applicable if the sample Supplychain App is being installed.

Expand Down Expand Up @@ -155,6 +155,8 @@ The snapshot of channels section with its fields and sample values is below
- channel:
consortium: SupplyChainConsortium
channel_name: AllChannel
osn_creator_org:
name: supplychain
chaincodes:
- "chaincode_name"
orderers:
Expand Down Expand Up @@ -239,6 +241,7 @@ The fields under the `channel` are
|---------------------------------|------------------------------------------------------------|
| consortium | Name of the consortium, the channel belongs to |
| channel_name | Name of the channel |
| osn_creator_org.name | Name of the organization whose orderers will create the channel |
| chaincodes | Contains list of chaincodes for the channel |
| genesis.name | Name of the genesis block |
| orderers | List of names of the organizations providing ordering service |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ spec:
value: {{ $.Values.metadata.component_type }}
- name: COMPONENT_NAME
value: {{ $.Values.metadata.namespace }}
- name: NAME
- name: ORG_NAME_EXT
value: {{ $.Values.metadata.org_name }}
- name: PROXY
value: {{ .Values.metadata.proxy }}
Expand All @@ -187,7 +187,7 @@ spec:
mkdir -p ${MOUNT_PATH}
OUTPUT_PATH="/crypto-config/${COMPONENT_TYPE}Organizations/${COMPONENT_NAME}"
mkdir -p ${OUTPUT_PATH}/ca
mkdir -p /root/ca-tools/${NAME}
mkdir -p /root/ca-tools/${ORG_NAME_EXT}
SECRET_CERT={{ $.Values.vault.secretcert }}
vault_secret_key=$(echo ${SECRET_CERT} |awk -F "?" '{print $1}')
Expand Down Expand Up @@ -353,7 +353,7 @@ spec:
value: {{ $.Values.metadata.component_type }}
- name: COMPONENT_NAME
value: {{ $.Values.metadata.namespace }}
- name: NAME
- name: ORG_NAME_EXT
value: {{ $.Values.metadata.org_name }}
- name: REFRESH_CERTS
value: "{{ $.Values.checks.refresh_cert_value }}"
Expand Down Expand Up @@ -391,12 +391,12 @@ spec:
SK_NAME=$(find ${ORG_CYPTO_FOLDER}/msp/keystore/ -name "*_sk")
if [ -n "$SK_NAME" ]; then
rm ${ORG_CYPTO_FOLDER}/msp/keystore/*_sk
rm /root/ca-tools/${NAME}/admin/msp/keystore/*_sk
rm /root/ca-tools/${NAME}/admin/tls/keystore/*_sk
rm /root/ca-tools/${ORG_NAME_EXT}/admin/msp/keystore/*_sk
rm /root/ca-tools/${ORG_NAME_EXT}/admin/tls/keystore/*_sk
fi;
# Generate crypto material for organization orderers (admin)
cd /root/ca-tools/${NAME}
cd /root/ca-tools/${ORG_NAME_EXT}
./generate-crypto-orderer.sh
fi;
Expand All @@ -410,10 +410,10 @@ spec:
SK_NAME=$(find ${ORG_CYPTO_ORDERER_FOLDER}/${ORDERER_NAME}.${COMPONENT_NAME}/msp/keystore/ -name "*_sk")
if [ -n "$SK_NAME" ]; then
rm ${ORG_CYPTO_ORDERER_FOLDER}/${ORDERER_NAME}.${COMPONENT_NAME}/msp/keystore/*_sk
rm /root/ca-tools/${NAME}/cas/orderers/msp/keystore/*_sk
rm /root/ca-tools/${NAME}/cas/orderers/tls/keystore/*_sk
rm /root/ca-tools/${ORG_NAME_EXT}/cas/orderers/msp/keystore/*_sk
rm /root/ca-tools/${ORG_NAME_EXT}/cas/orderers/tls/keystore/*_sk
fi;
cd /root/ca-tools/${NAME}
cd /root/ca-tools/${ORG_NAME_EXT}
./orderer-script.sh ${ORDERER_NAME}
fi;
done
Expand All @@ -433,12 +433,12 @@ spec:
SK_NAME=$(find ${ORG_CYPTO_FOLDER}/msp/keystore/ -name "*_sk")
if [ -n "$SK_NAME" ]; then
rm ${ORG_CYPTO_FOLDER}/msp/keystore/*_sk
rm /root/ca-tools/${NAME}/admin/msp/keystore/*_sk
rm /root/ca-tools/${NAME}/admin/tls/keystore/*_sk
rm /root/ca-tools/${ORG_NAME_EXT}/admin/msp/keystore/*_sk
rm /root/ca-tools/${ORG_NAME_EXT}/admin/tls/keystore/*_sk
fi;
# Generate crypto material for organization peers
cd /root/ca-tools/${NAME}
cd /root/ca-tools/${ORG_NAME_EXT}
if [ "$ADD_PEER" = "false" ]; then
./generate-crypto-peer.sh
break
Expand All @@ -455,7 +455,7 @@ spec:
do
if ([ "$USERS" ] && [ -e ${MOUNT_PATH}/absent_msp_${USER}.txt ]) || [ "$REFRESH_CERTS" = "true" ]
then
cd /root/ca-tools/${NAME}
cd /root/ca-tools/${ORG_NAME_EXT}
./generate-user-crypto.sh peer ${USERS}
break
fi;
Expand Down Expand Up @@ -513,8 +513,6 @@ spec:
value: {{ $.Values.metadata.component_type }}
- name: COMPONENT_NAME
value: {{ $.Values.metadata.namespace }}
- name: NAME
value: {{ $.Values.metadata.org_name }}
- name: REFRESH_CERTS
value: "{{ $.Values.checks.refresh_cert_value }}"
- name: PROXY
Expand All @@ -533,7 +531,6 @@ spec:
args:
- |-
. /scripts/package-manager.sh
# Define the packages to install
packages_to_install="jq curl bash"
install_packages "$packages_to_install"
Expand Down Expand Up @@ -567,7 +564,6 @@ spec:
if [ -e /certcheck/certs_not_found.txt ]; then
exit 1
fi
tail -f /dev/null
volumeMounts:
- name: ca-tools-pv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ spec:
- name: scripts-volume
configMap:
name: bevel-vault-script
- name: package-manager
configMap:
name: package-manager
initContainers:
- name: certificates-init
image: {{ $.Values.metadata.images.alpineutils }}
Expand Down Expand Up @@ -187,6 +190,18 @@ spec:
args:
- |-
#!/bin/bash sh
. /scripts/package-manager.sh
version2_5=`echo $NETWORK_VERSION | grep -c 2.5`
if [ $version2_5 = 1 ]
then
GOPATH="/root/go"
mkdir -p $GOPATH
# Define the packages to install
packages_to_install="openssh-client git"
install_packages "$packages_to_install"
fi
## Checking committed chaincode
COMMITTED=$(peer lifecycle chaincode querycommitted --channelID ${CHANNEL_NAME} --name ${CHAINCODE_NAME} -O json | \
jq --arg SEQUENCE "$CHAINCODE_SEQUENCE" --arg VERSION "$CHAINCODE_VERSION" \
Expand Down Expand Up @@ -239,7 +254,7 @@ spec:
COMMITREADINESS_CMD=${COMMITREADINESS_CMD}${collection_config}
fi
echo "Commit Readiness command post collection config " ${COMMITREADINESS_CMD}
echo "Commit command post collection config " ${COMMIT_CMD}
echo "Commit command post collection config " ${COMMIT_CMD}
if [ -z ${ENDORSEMENT_POLICIES} ]
then
## check commit readiness
Expand Down Expand Up @@ -304,10 +319,15 @@ spec:
value: "{{ $.Values.chaincode.pdc.collectionsconfig }}"
- name: PDC_ENABLED
value: "{{ $.Values.chaincode.pdc.enabled }}"
- name: NETWORK_VERSION
value: "{{ $.Values.metadata.network.version }}"
volumeMounts:
- name: certificates
mountPath: /opt/gopath/src/github.com/hyperledger/fabric/crypto
readOnly: true
- name: package-manager
mountPath: /scripts/package-manager.sh
subPath: package-manager.sh
{{ if .Values.chaincode.pdc.enabled }}
- name: pdcconfig
mountPath: /opt/pdc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ spec:
value: {{ $.Values.vault.secretcredentialsprefix }}
- name: COMPONENT_NAME
value: {{ $.Values.metadata.component_name }}
- name: NAME
- name: ORG_NAME
value: {{ $.Values.metadata.name }}
- name: CA_SUBJECT
value: "{{ $.Values.ca.subject }}"
Expand Down Expand Up @@ -189,12 +189,11 @@ spec:
then
# Calling a function to retrieve the vault token.
vaultBevelFunc "init"

echo "
{
\"data\":
{
\"user\": \"${NAME}-adminpw\"
\"user\": \"${ORG_NAME}-adminpw\"
}
}" > payload.json

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,28 @@ spec:
#!/bin/bash sh
. /scripts/package-manager.sh
# Define the packages to install
packages_to_install="curl openssh"
install_packages "$packages_to_install"
## Git repository clone for chaincode
mkdir -p /root/.ssh/
version2_5=`echo $NETWORK_VERSION | grep -c 2.5`
if [ $version2_5 = 1 ]
then
GOPATH="/root/go"
mkdir -p $GOPATH
# Define the packages to install
packages_to_install="openssh-client git"
install_packages "$packages_to_install"
else
# Define the packages to install
packages_to_install="curl openssh"
install_packages "$packages_to_install"
fi
mkdir -p /root/.ssh/
ssh-keyscan {{ $.Values.chaincode.repository.hostname }} > /root/.ssh/known_hosts
git_password=$(cat /opt/gopath/src/github.com/hyperledger/fabric/crypto/user_cred)
cd /tmp && git clone https://{{ $.Values.chaincode.repository.git_username }}:$git_password@{{ $.Values.chaincode.repository.url }} -b {{ $.Values.chaincode.repository.branch }} chaincode > git.log 2>&1
## Check if the repository was cloned correctly
if [[ ! $? -eq 0 ]];
if [ $? -ne 0 ];
then
cat git.log
exit 1
Expand All @@ -168,6 +178,11 @@ spec:
# Get dependencies
mkdir -p $GOPATH/bin && curl https://raw.githubusercontent.com/hyperledger/bevel/main/platforms/hyperledger-fabric/scripts/install.sh | sh
if [ $version2_5 = 1 ]
then
export PATH=$PATH:$GOPATH/bin
go env -w GO111MODULE=auto
fi
cd $GOPATH/src/github.com/chaincode && dep ensure
#chaincode path
Expand Down Expand Up @@ -266,10 +281,6 @@ spec:
## Installing Chaincode
peer lifecycle chaincode install ${CHAINCODE_NAME}.tar.gz
echo "Chaincode installed for Fabric v.2.X"
#query installed
echo "peer query installed"
peer lifecycle chaincode queryinstalled
## Check if chaincode got installed
INSTALLED=$(peer lifecycle chaincode queryinstalled -O json | jq '.installed_chaincodes?' | \
jq --arg CCLABEL "${CHAINCODE_NAME}_${CHAINCODE_VERSION}" '.[]? | select(.label==$CCLABEL)')
Expand All @@ -279,6 +290,10 @@ spec:
exit 1
fi
fi
#query installed
echo "peer query installed"
peer lifecycle chaincode queryinstalled
env:
- name: PEER_NAME
value: {{ $.Values.peer.name }}
Expand Down
12 changes: 7 additions & 5 deletions platforms/hyperledger-fabric/configuration/chaincode-ops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
loop_control:
loop_var: channel
when: participants is defined

# Instantiate chaincode on all participants for Fabric 1.4
- name: Instantiate chaincode
include_role:
Expand All @@ -55,7 +56,8 @@
participants: "{{ item.participants }}"
docker_url: "{{ network.docker.url }}"
loop: "{{ network['channels'] }}"
when: participants is defined and '2.2.' in network.version
when: participants is defined and ('2.2.' in network.version or '2.5.' in network.version)

# Commit chaincode on all participants for Fabric 2.2
- name: Commit chaincode
include_role:
Expand All @@ -65,8 +67,8 @@
docker_url: "{{ network.docker.url }}"
approvers: "{{ item.endorsers }}"
loop: "{{ network['channels'] }}"
when: add_new_org == 'false' and '2.2.' in network.version
when: add_new_org == 'false' and ('2.2.' in network.version or '2.5.' in network.version)

# This task invokes chaincode after the chaincode has been commited in v2 and
# after chaincode installation for the new organization to be added in existing network
- name: Invoke chaincode
Expand All @@ -77,8 +79,8 @@
docker_url: "{{ network.docker.url }}"
approvers: "{{ item.endorsers | default(' ', true) }}"
loop: "{{ network['channels'] }}"
when: add_new_org == 'true' or '2.2.' in network.version
when: add_new_org == 'true' or '2.2.' in network.version or '2.5.' in network.version

vars: #These variables can be overriden from the command line
privilege_escalate: false #Default to NOT escalate to root privledges
install_os: "linux" #Default to linux OS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
vars:
build_path: "./build"
genesis: "{{ item.genesis }}"
channel_name: "{{ item.channel_name }}"
channel_name: "{{ item.channel_name | lower }}"
loop: "{{ network['channels'] }}"

# This role creates value file for zk-kafka (if kafka consensus is chosen) and orderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
values:
metadata:
namespace: {{ namespace }}
network:
version: {{ network.version }}
images:
fabrictools: {{ fabrictools_image }}
alpineutils: {{ alpine_image }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ network:
# Network level configuration specifies the attributes required for each organization
# to join an existing network.
type: fabric
version: 2.2.2 # currently tested 1.4.8 and 2.2.2
version: 2.2.2 # currently tested 1.4.8, 2.2.2 and 2.5.4

frontend: enabled #Flag for frontend to enabled for nodes/peers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ command_exists() {

# Function to determine the Linux distribution
get_linux_distro() {
if [ "$(uname -s)" == "Linux" ]; then
if [ "$(uname -s)" = "Linux" ]; then
if command_exists lsb_release; then
DISTRO=$(lsb_release -si | tr '[:upper:]' '[:lower:]')
elif [ -f "/etc/os-release" ]; then
Expand Down

0 comments on commit a8cd445

Please sign in to comment.