Fabric Network Upgrade

Dinesh Rivankar
3 min readDec 20, 2019

Network is the backbone of any application which provides the infrastructure and a path for interaction with different modules. There can be many reasons which can lead to network up-gradation like incorporating new features of security, scalability or dependency resolution due to addition of new component. Since blockchain is a distributed and decentralized network, having consensus from all the participants and understanding the impact of other interrelated component is the major planning activity.

Hyperledger fabric components are dockerized for deployment which makes it easily upgradable. Upgrading fabric images from version 1.3.0 to 1.4.0 doesn’t require any channel capabilities to be enabled, however upgradation from 1.4.0 to 1.4.2 will need to enable channel capabilities. (Channel, Orderer and Application)

For exploration, we will use 2 org deployment with single orderer. Org 1 will run the CLI container which will be used to communicate with the network.

# Step 1

Clone the below git repository on VM as shown below.

git clone https://github.com/dineshrivankar/fabric-network-upgrade.git

# Step 2

Generate Crypto material for all the participants and deploy the containers by running the below script. For exploration we will use orderer in solo mode.

./deploy.sh

After successful deployment, we will find the below containers. Note, all the containers are deployed with Image 1.3.0

peer0.org2.example.com:hyperledger/fabric-peer:1.3.0 : Up 5 seconds
peer1.org2.example.com:hyperledger/fabric-peer:1.3.0 : Up 3 seconds
cli.org1.example.com:hyperledger/fabric-tools:1.3.0 : Up 10 seconds
peer1.org1.example.com:hyperledger/fabric-peer:1.3.0 : Up 15 seconds
peer0.org1.example.com:hyperledger/fabric-peer:1.3.0 : Up 19 seconds
orderer.example.com:hyperledger/fabric-orderer:1.3.0 : Up 25 seconds

# Step 3

Let’s verify that network is functioning properly. Org1 runs a cli container, we will use the cli container to create a channel, join all the peers to the channel, install & instantiate chaincode, invoke & query chaincode.

./run.sh

# Step 4

After testing the network with chaincode invoke and query, we are all set to upgrade the network to the latest version. Network component upgrade will follow the below process, kindly note that we need to upgrade component in linear fashion.

  1. Stop the orderer / peer.
  2. Back up the orderer’s / peer’s ledger and MSP.
  3. Remove chaincode containers and images (Only for peer’s).
  4. Restart the orderer / peer with latest image.
  5. Verify upgrade completion.

We are using persistent data store for each container, therefore we will skip the backup process. Below is the sample for creating persistent data store via docker file.

// Orderer container
-/var/mynetwork/orderer.example.com:/var/hyperledger/production/orderer
// Peer0 org1 container
- /var/mynetwork/peer0.org1.example.com:/var/hyperledger/production

// Peer1 org1 container
- /var/mynetwork/peer1.org1.example.com:/var/hyperledger/production

// Peer0 org2 container
- /var/mynetwork/peer0.org2.example.com:/var/hyperledger/production

// Peer1 org2 container
- /var/mynetwork/peer1.org2.example.com:/var/hyperledger/production

Upgrade the network component with below script.

./upgrade.sh

After completion of the script, we will see below output. All the container are upgraded from image 1.3.0 to latest.

# ------------------------------------------------------------------
# Stop and upgrade the orderer containers
# ------------------------------------------------------------------
orderer.example.com
Recreating orderer.example.com ... done
# ------------------------------------------------------------------
# Stop the org1 containers.
# Remove chaincode containers and images.
# Upgrade org1 containers.
# ------------------------------------------------------------------
peer0.org1.example.com
peer1.org1.example.com
cli.org1.example.com
Untagged: mynetwork-peer0.org1.example.com-example-01-1.0-044b79821d407b1bffa7155e3a109f4a4d4eb8ba96f4a503a9e2d4c97d706dba:latest
Deleted: sha256:8c71dfdcaaad3625fdd0f108bafe5746ccae4a2efd409e6328ae0a8dd5086e4a
Deleted: sha256:be6119b31b79c947247bd68f0b03e4074c15bbfc02e636a0f520603aa8158587
Deleted: sha256:69d5d989d4e58cc75b612dc3ceecb98c94a761ea766bc9c299771a2fd1356644

Recreating peer1.org1.example.com ... done
Recreating cli.org1.example.com ... done
Recreating peer0.org1.example.com ... done
# ------------------------------------------------------------------
# Upgrade the Org2 containers
# ------------------------------------------------------------------
peer0.org2.example.com
peer1.org2.example.com
Recreating peer1.org2.example.com ... done
Recreating peer0.org2.example.com ... done
peer0.org2.example.com:hyperledger/fabric-peer:latest: Up 5 seconds
peer1.org2.example.com:hyperledger/fabric-peer:latest: Up 5 seconds
cli.org1.example.com:hyperledger/fabric-tools:latest: Up 17 seconds
peer1.org1.example.com:hyperledger/fabric-peer:latest: Up 18 seconds
peer0.org1.example.com:hyperledger/fabric-peer:latest: Up 19 seconds
orderer.example.com:hyperledger/fabric-orderer:latest: Up 32 seconds

# Step 5

Reset network by running below script.

./reset.sh

That’s it!!

Feel free to shout out for any suggestions or improvements.
Happy Learning !!!

--

--

Dinesh Rivankar

Architect, Blockchain Innovation Group. #TOGAF #ConfidentialComputing #Corda #Hyperledger #SmartContract