In Hyperledger Fabric, how do I join a channel if I cannot use the peer channel fetch command?

Viewed 1623

I want to be able to have my peer join a channel (mychannel in this case). This specific peer does not have the mychannel.block file on its filesystem.

What I then tried was to use peer channel fetch 0 -c mychannel. I then get the following error:

2019-01-15 08:11:18.948 UTC [msp] Validate -> DEBU 036 MSP ZafitMSP validating identity
2019-01-15 08:11:18.949 UTC [msp] GetDefaultSigningIdentity -> DEBU 037 Obtaining default signing identity
2019-01-15 08:11:18.949 UTC [grpc] DialContext -> DEBU 038 parsed scheme: ""
2019-01-15 08:11:18.949 UTC [grpc] DialContext -> DEBU 039 scheme "" not registered, fallback to default scheme
2019-01-15 08:11:18.949 UTC [grpc] watcher -> DEBU 03a ccResolverWrapper: sending new addresses to cc: [{peer1.zafit.example.com:7051 0  <nil>}]
2019-01-15 08:11:18.949 UTC [grpc] switchBalancer -> DEBU 03b ClientConn switching balancer to "pick_first"
2019-01-15 08:11:18.950 UTC [grpc] HandleSubConnStateChange -> DEBU 03c pickfirstBalancer: HandleSubConnStateChange: 0xc4202b78d0, CONNECTING
2019-01-15 08:11:18.952 UTC [grpc] HandleSubConnStateChange -> DEBU 03d pickfirstBalancer: HandleSubConnStateChange: 0xc4202b78d0, READY
2019-01-15 08:11:18.953 UTC [channelCmd] InitCmdFactory -> INFO 03e Endorser and orderer connections initialized
2019-01-15 08:11:18.953 UTC [msp] GetDefaultSigningIdentity -> DEBU 03f Obtaining default signing identity
2019-01-15 08:11:18.953 UTC [msp] GetDefaultSigningIdentity -> DEBU 040 Obtaining default signing identity
2019-01-15 08:11:18.953 UTC [msp/identity] Sign -> DEBU 041 Sign: plaintext: 0AF2060A1508051A0608A6ABF6E10522...1BB3248E4BFA12080A021A0012021A00
2019-01-15 08:11:18.953 UTC [msp/identity] Sign -> DEBU 042 Sign: digest: C8988576954088FD1A61D6D4FFA7A7280E52F10B2F2671693C260B54B09F3B89
2019-01-15 08:11:18.954 UTC [cli/common] readBlock -> INFO 043 Got status: &{NOT_FOUND}

However, when I copy the mychannel.block file from another peer I am able to join mychannel successfully. The peer channel fetch command also works successfully after joining the channel.

To me this seems like a chicken and egg scenario, I need to join the channel as a peer, but I can't join because I need the genesis block. But I can't get the genesis block because I need to join the channel?

So the question is what is the appropriate command to retrieve the genesis mychannel.block file?

3 Answers

It turns out that I needed to add the orderer parameter -o. Additionally, since I was connecting with TLS, I needed to specify --tls true as well as specify the --cafile.

The full command is as follows:?

peer channel fetch 0 -c mychannel -o orderer.example.com:7050 --tls true --cafile $ORDERER_CA

You need to add the -o (--orderer) flag and set it to an ordering service endpoint. If you don't set this flag, then peer channel fetch tries to get the block from the peer (which obviously does not have it). You could also specific a different --peer.address / CORE_PEER_ADDRESS when running without -o to get the config block from a different peer as well.

peer channel fetch 0 -c mychannel 

Note: You don't need to fetch channel in order to join channel create channel will give .block file as a token of success.

join channel will make use of this inorder to complete the joining process

In case you miss .block then you need fetch command

Note: for latest fetch commands

https://hyperledger-fabric.readthedocs.io/en/release-1.4/commands/peerchannel.html

peer channel join -b channel.block --tls --cafile /etc/hyperledger/crypto/peer/tls/ca.crt

when you try to join a cahnnel you must contact the orderer to get config information that's why you will mention -o orderer_name in order to know about orderer by CLI

Related