Prepare CLI Environment in Server1
First, exec into the CLI container:
docker exec -it cli bash
Export the ORDERER_CA
and CHANNEL_NAME
variables:
export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem && export CHANNEL_NAME=mychannel
Check to make sure the variables have been properly set:
echo $ORDERER_CA && echo $CHANNEL_NAME
Fetch the Configuration
Now we have a CLI container with our two key environment variables – ORDERER_CA
and CHANNEL_NAME
exported. Let’s go fetch the most recent config block for the channel – mychannel
.
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA
Convert the Configuration to JSON and Trim It Down
Now we will make use of the configtxlator
tool to decode this channel configuration block into JSON format (which can be read and modified by humans). We also must strip away all of the headers, metadata, creator signatures, and so on that are irrelevant to the change we want to make. We accomplish this by means of the jq
tool:
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > config.json
Add the Org4 Crypto Material
We’ll use the jq
tool once more to append the Org4 configuration definition – org4.json
– to the channel’s application groups field, and name the output – modified_config.json
.
jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org4MSP":.[1]}}}}}' config.json ./channel-artifacts/org4.json > modified_config.json
Convert config.json
into protobuf called config.pb
:
configtxlator proto_encode --input config.json --type common.Config --output config.pb
Next, encode modified_config.json
to modified_config.pb
:
configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb
Now use configtxlator
to calculate the delta between these two config protobufs. This command will output a new protobuf binary named org4_update.pb
:
configtxlator compute_update --channel_id $CHANNEL_NAME --original config.pb --updated modified_config.pb --output org4_update.pb
Decode it editable json format and call it org4_update.json
configtxlator proto_decode --input org4_update.pb --type common.ConfigUpdate | jq . > org4_update.json
Now, we have a decoded update file – org4_update.json
– that we need to wrap in an envelope message:
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL_NAME'", "type":2}},"data":{"config_update":'$(cat org4_update.json)'}}}' | jq . > org4_update_in_envelope.json
Finally, convert it again protobuf format:
configtxlator proto_encode --input org4_update_in_envelope.json --type common.Envelope --output org4_update_in_envelope.pb
Copy Final Protobuf file org4_update_in_envelope.bp
to Server2 and Server3
org4_update_in_envelope.bp
to Server2 and Server3In Server1
docker cp cli:/opt/gopath/src/github.com/hyperledger/fabric/peer/org4_update_in_envelope.pb
We use localhost as a bridge. In localhost temp directory:
sudo scp -i ~/<path to server1 key file> [email protected]<server1 publick DNS-IP v4>:/<path to network directory>/org4_update_in_envelope.pb
Copy this file to server2 and server3 from localhost temp directory:
sudo scp -i ~/<path to server2 key file> org4_update_in_envelope.pb [email protected]<server2 publick DNS-IP v4>:/<path to network directory>/
sudo scp -i ~/<path to server3 key file> org4_update_in_envelope.pb [email protected]<server3 publick DNS-IP v4>:/<path to network directory>/
Copy it into org2 and org3 peers:
docker cp org4_update_in_envelope.pb org2cli:/opt/gopath/src/github.com/hyperledger/fabric/peer/
docker cp org4_update_in_envelope.pb org3cli:/opt/gopath/src/github.com/hyperledger/fabric/peer/
Updated about 2 years ago