Adding a new channel in Hyperledger Fabric¶
Prerequisites¶
To add a new channel a fully configured Fabric network must be present already, i.e. a Fabric network which has Orderers, Peers, Channels (with all Peers already in the channels). The corresponding crypto materials should also be present in their respective Hashicorp Vault.
NOTE: Do not try to add a new organization as a part of this operation. Use only existing organization for new channel addition.
Modifying Configuration File¶
Refer this guide for details on editing the configuration file.
While modifying the configuration file(network.yaml
) for adding new channel, all the existing channel should have channel_status
tag as existing
and the new channel should have channel_status
tag as new
under network.channels
e.g.
# The channels defined for a network with participating peers in each channel
channels:
- channel:
consortium: SupplyChainConsortium
channel_name: AllChannel
channel_status: existing
chaincodes:
- "chaincode_name"
orderers:
- supplychain
participants:
- organization:
name: carrier
type: creator # creator organization will create the channel and instantiate chaincode, in addition to joining the channel and install chaincode
org_status: existing
peers:
- peer:
name: peer0
gossipAddress: peer0.carrier-net.org3proxy.blockchaincloudpoc.com:443 # Must include port, External or internal URI of the gossip peer
peerAddress: peer0.carrier-net.org3proxy.blockchaincloudpoc.com:443 # Must include port, External URI of the peer
ordererAddress: orderer1.org1proxy.blockchaincloudpoc.com:443 # Must include port, External or internal URI of the orderer
- organization:
name: warehouse
type: joiner
org_status: new
peers:
- peer:
name: peer0
gossipAddress: peer0.warehouse-net.org5proxy.blockchaincloudpoc.com:443
peerAddress: peer0.warehouse-net.org5proxy.blockchaincloudpoc.com:443 # Must include port, External URI of the peer
ordererAddress: orderer1.org1proxy.blockchaincloudpoc.com:443
- organization:
name: manufacturer
type: joiner
org_status: new
peers:
- peer:
name: peer0
gossipAddress: peer0.manufacturer-net.org2proxy.blockchaincloudpoc.com:443
peerAddress: peer0.manufacturer-net.org2proxy.blockchaincloudpoc.com:443 # Must include port, External URI of the peer
ordererAddress: orderer1.org1proxy.blockchaincloudpoc.com:443
- organization:
name: store
type: joiner # joiner organization will only join the channel and install chaincode
org_status: new
peers:
- peer:
name: peer0
gossipAddress: peer0.store-net.org4proxy.blockchaincloudpoc.com:443
peerAddress: peer0.store-net.org4proxy.blockchaincloudpoc.com:443 # Must include port, External URI of the peer
ordererAddress: orderer1.org1proxy.blockchaincloudpoc.com:443
endorsers:
# Only one peer per org required for endorsement
- organization:
name: carrier
peers:
- peer:
name: peer0
corepeerAddress: peer0.carrier-net.org3proxy.blockchaincloudpoc.com:443
certificate: "/path/carrier/server.crt" # certificate path for peer
- organization:
name: warehouse
peers:
- peer:
name: peer0
corepeerAddress: peer0.warehouse-net.org5proxy.blockchaincloudpoc.com:443
certificate: "/path/warehouse/server.crt" # certificate path for peer
- organization:
name: manufacturer
peers:
- peer:
name: peer0
corepeerAddress: peer0.manufacturer-net.org2proxy.blockchaincloudpoc.com:443
certificate: "/path/manufacturer/server.crt" # certificate path for peer
- organization:
name: store
peers:
- peer:
name: peer0
corepeerAddress: peer0.store-net.org4proxy.blockchaincloudpoc.com:443
certificate: "/path/store/server.crt" # certificate path for peer
genesis:
name: OrdererGenesis
- channel:
consortium: SupplyChainConsortium
channel_name: ChannelTwo
channel_status: new
orderers:
- supplychain
participants:
- organization:
name: carrier
type: joiner # creator organization will create the channel and instantiate chaincode, in addition to joining the channel and install chaincode
org_status: new
peers:
- peer:
name: peer0
gossipAddress: peer0.carrier-net.org3proxy.blockchaincloudpoc.com:443 # Must include port, External or internal URI of the gossip peer
peerAddress: peer0.carrier-net.org3proxy.blockchaincloudpoc.com:443 # Must include port, External URI of the peer
ordererAddress: orderer1.org1proxy.blockchaincloudpoc.com:443 # Must include port, External or internal URI of the orderer
- organization:
name: store
type: creator # joiner organization will only join the channel and install chaincode
org_status: new
peers:
- peer:
name: peer0
gossipAddress: peer0.store-net.org4proxy.blockchaincloudpoc.com:443
peerAddress: peer0.store-net.org4proxy.blockchaincloudpoc.com:443 # External URI of the peer
ordererAddress: orderer1.org1proxy.blockchaincloudpoc.com:443
endorsers:
# Only one peer per org required for endorsement
- organization:
name: carrier
peers:
- peer:
name: peer0
corepeerAddress: peer0.carrier-net.org3proxy.blockchaincloudpoc.com:443
certificate: "/path/carrier/server.crt" # certificate path for peer
- organization:
name: store
peers:
- peer:
name: peer0
corepeerAddress: peer0.store-net.org4proxy.blockchaincloudpoc.com:443
certificate: "/path/store/server.crt" # certificate path for peer
genesis:
name: ChannelTwoGenesis
The network.yaml
file should contain the specific network.organization
details along with the orderer information.
For reference, see network-fabric-add-channel.yaml
file here.
Run playbook¶
The add-new-channel.yaml playbook is used to add a new channel to the existing network. This can be done using the following command
ansible-playbook platforms/hyperledger-fabric/configuration/add-new-channel.yaml --extra-vars "@path-to-network.yaml"
NOTE: Make sure that the channel_status
label was set as new
when the network is deployed for the first time. If you have additional applications, please deploy them as well.