Shubham Chadokar
Shubham Chadokar

Reputation: 2763

Add a new org to the existing consortium? Hyperledger Fabric

There are 3 orgs: Org1, Org2 and Org3.
Org1 and Org2 created a consortium named SampleConsortium

Now, I want to add Org3 to the SampleConsortium. There is no channel created yet.

In the documentation, there is a tutorial to add an org to an existing channel. I want org to join the consortium not the channel.

How can I do this? Please add resources that will be very helpful.

Thanks!

Upvotes: 2

Views: 656

Answers (2)

Shubham Chadokar
Shubham Chadokar

Reputation: 2763

Thanks to @alexander for this tutorial link.

The tutorial is written by Allison Irvin

Updating the Consortium Definition in Hyperledger Fabric

The answer to this question:

We have to update the system genesis block to add a new organization in the consortium. Then only the new organization can create a channel.

Tutorial's Intro:
The creation of channels is controlled by members of Consortia, which consist of one or more organizations that are defined at the network level. As Fabric networks evolve and grow, it is expected that the list of organizations requiring the ability to create channels will change. Therefore, we need the ability to add or modify Consortia definitions without interrupting any of the network components.

Upvotes: 1

Vijaya Prakash
Vijaya Prakash

Reputation: 111

I have written the script to add/delete org into consortium and add/delete org into channel.

## Make sure network is up
## Make sure certificates are generated using cryptogen
## Make sure you are executing this script in cli
## docker exec -it cli bash

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=byfn-sys-channel

CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/[email protected]/msp
CORE_PEER_ADDRESS=orderer.example.com:7050
CORE_PEER_LOCALMSPID=OrdererMSP
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt


peer channel fetch config config_block.pb -c $CHANNEL_NAME -o orderer.example.com:7050 --tls --cafile $ORDERER_CA

configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > config.json

#### Add Org into Consortium ######
jq -s '.[0] * {"channel_group":{"groups":{"Consortiums":{"groups": {"SampleConsortium": {"groups": {"Org3MSP":.[1]}}}}}}}' config.json ./channel-artifacts/org3.json > modified_config.json

#### Delete Org from Consortium ######
 cat config.json | jq "del(.channel_group.groups.Consortiums.groups.SampleConsortium.groups.Org3MSP)" > modified_config.json

#### Add Organization to channel #####
jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./channel-artifacts/org3.json > modified_config.json

#### Delete Oraganization from channel ####
jq 'del(.channel_group.groups.Application.groups.Org3MSP)' config.json > modified_config.json


configtxlator proto_encode --input config.json --type common.Config --output config.pb

configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb

configtxlator compute_update --channel_id $CHANNEL_NAME --original config.pb --updated modified_config.pb --output org3_update.pb

configtxlator proto_decode --input org3_update.pb --type common.ConfigUpdate | jq . > org3_update.json

echo '{"payload":{"header":{"channel_header":{"channel_id":"byfn-sys-channel", "type":2}},"data":{"config_update":'$(cat org3_update.json)'}}}' | jq . > org3_update_in_envelope.json

configtxlator proto_encode --input org3_update_in_envelope.json --type common.Envelope --output org3_update_in_envelope.pb


peer channel signconfigtx -f org3_update_in_envelope.pb

peer channel update -f org3_update_in_envelope.pb -c $CHANNEL_NAME -o orderer.example.com:7050 --tls --cafile $ORDERER_CA

Upvotes: 3

Related Questions