How to Add an Organization dynamically to existing consortium — Hyperledger Fabric ?
Scenario :
We want to add an org to existing consortium and create separate channels accordingly without disturbing the existing network .
Solution:
Intention is to modify the genesis block of existing network which is wired up to orderer . We would be using configtxlator to achieve the same. We would modify the genesis block with updated consortium and sign the same and send it back to orderer.
When following the steps below, please ensure that you have orderer MSP in CLI.
Steps :
- peer channel fetch config sys_config_block.pb -o orderer.example.com:7050 -c testchainid — tls — cafile $ORDERER_CA
- configtxlator proto_decode — input sys_config_block.pb — type common.Block | jq .data.data[0].payload.data.config > sys_config_block.json
- jq .data.data[0].payload.data.config sys_config_block.json > sys_config.json
Make sure you have the newly org we want to add to consortium (let’s call it org3) msp converted to Json
4. jq -s ‘.[0] * {“channel_group”:{“groups”:{“Consortiums”:{“groups”: {“SampleConsortium”: {“groups”: {“Org3MSP”:.[1]}}}}}}}’ sys_config.json /org3.json >& sys_updated_config.json
5. configtxlator proto_encode — input sys_config.json — type common.Config — output sys_config.pb
6. configtxlator proto_encode — input sys_updated_config.json — type common.Config — output sys_updated_config.pb
7.configtxlator compute_update — channel_id testchanid — original sys_config.pb — updated sys_updated_config.pb — output diff_config.pb
8.configtxlator proto_decode — input diff_config.pb — type common.ConfigUpdate | jq . > diff_config.json
9.echo ‘{“payload”:{“header”:{“channel_header”:{“channel_id”:”mychannel”, “type”:2}},”data”:{“config_update”:’$(cat diff_config.json)’}}}’ | jq . > diff_config_envelope.json
10.configtxlator proto_encode — input diff_config_envelope.json — type common.Envelope — output diff_config_envelope.pb
11.peer channel update -f sys_config_update_in_envelope.pb -c testchainid -o orderer.example.com:7050 — tls true — cafile $ORDERER_CA
The above steps ensures that a new org is added to existing consortium. Next steps would be to create channels and ensure peer joins the channel which is of standard process.
References :