Error while trying to join peer to channel in fabric - hyperledger-fabric

I am trying to build a fabric network with two channels. One peer is able to join the channel but while trying to join the second peer to channel getting following error:
Error: genesis block file not found open mychannel.block: no such file or directory
this is my code used for channel creation and joining peers:
Creating channel:
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org2.example.com/msp" peer0.org2.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
Joining peers:
docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org2.example.com/msp" peer0.org2.example.com peer channel join -b mychannel.block
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer0.org1.example.com peer channel join -b mychannel.block
Please correct if something is wrong.

i run in the same situation and find a solution.
Since the mychannel.block is known only to peer0.org2.example.com container, all the joins have to be done from there.
For the second peer you can issue:
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" -e "peer0.org1.example.com:7051" peer0.org2.example.com peer channel join -b mychannel.block
M

The issue is that mychannel.block is only available within the peer0.org2.example.com container (since that is the container where you ran the channel create command). The peer0.org1.example.com container does not have access to mychannel.block and that's why you get the error.
What you will need to do is to actually have to do is mount a shared volume for both containers and make sure that you when you run channel create that mychannel.block is output in the shared volume

I had the same problem, but the scenario was slightly different: I had two peers (peer0 and peer1) in one org (org1). I used the following commands to join them to the same channel, and it works:
//Join peer0.org1.example.com to the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e
"CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp"
peer0.org1.example.com peer channel join -b mychannel.block
//Join peer1.org1.example.com to the channel.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e
"CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" -e "CORE_PEER_ADDRESS=peer1.org1.example.com:7051" peer0.org1.example.com peer
channel join -b mychannel.block

you need to check your docker-compose.yaml file to see how you're mapping volumes in there
in the definitions of the two peers, ensure there is a common mapped volume, for example in peer0 you may have something like this;
volumes:
- /var/run/:/host/var/run/
- ./:/etc/hyperledger/configtx
- ./crypto-config/peers/peer0/msp:/etc/hyperledger/peer/msp
- ./crypto-config/users/user0/msp:/etc/hyperledger/msp/users
and in your peer1 you may have;
volumes:
- /var/run/:/host/var/run/
- ./:/etc/hyperledger/configtx
- ./crypto-config/peers/peer1/msp:/etc/hyperledger/peer/msp
- ./crypto-config/users/user1/msp:/etc/hyperledger/msp/users
You can see here there are two shared volume mappings, the first two in each definition point to the sample place.
So to be clear, the volume mapping is defined as follows:
[path on local machine]:[path to map in docker image]

This issue is due to mychannel.block was not found in peer0.org1.example.com
You can copy mychannel.block from peer0.org2.example.com to peer0.org1.example.com
try these commands
docker cp peer0.org2.example.com:/opt/gopath/src/github.com/hyperledger/fabric/mychannel.block mychannel.block
docker cp mychannel.block peer0.org1.example.com:/opt/gopath/src/github.com/hyperledger/fabric/
sudo rm mychannel.block
Now try rejoining peer0.org1.example.com to mychannel.

Related

Hyperledger Fabric - Peer unable to join channel

We are getting an error while trying a peer node to join a channel. Both members have separate peer nodes and separate EC2 machines acting as clients for the network. Member1 has created a channel and joined its peer node to the channel. Member2 has pulled the genesis block from their client but when trying to join the channel, we get the error:
Error: genesis block file not found open ourchannel.block: no such file or directory
despite seeing ourchannel.block in the directory we run the command. The command we're using to join the channel is:
docker exec -e "CORE_PEER_TLS_ENABLED=true" \
-e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
-e "CORE_PEER_ADDRESS=$PEER" \
-e "CORE_PEER_LOCALMSPID=$MSP" \
-e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
cli peer channel join -b ourchannel.block \
-o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls
You only have the genesis block (the file with .block extension) if you create a channel in a separate container, which is cli container in your case. Please check by using ls command inside the cli container.
A simple command to jump into cli container:
docker exec -it cli bash
Just in case you can't find genesis block, you can get it from the orderer (remember to modify the path to the cafile fit your project):
peer channel fetch 0 ourchannel.block -o orderer.example.com:7050 -c ourchannel --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
After this, you can join the channel with peer channel join command.
Simple issue, we had to specify the absolute path to the block file.
Instead of
cli peer channel join -b ourchannel.block
we used
cli peer channel join -b /opt/home/ourchannel.block \
and it worked.

Missing log for "Failed to reach implicit threshold of 1 sub-policies, required 1 remaining"

I have a docker container with CORE_LOGGING_LEVEL=debug. However, I never get the output of this debug-block: /common/policies/implicitmeta.go#L75
I get the Failed to reach implicit threshold of 1 sub-policies, required 1 remaining but I'm missing details about which policy is remaining.
docker logs peer1.org1.example.com --details also doesn't show the desired information.
How can I influence this behavior?
NB: The triggering command is:
docker exec -w /mnt/docker-shared-mount -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer1.org1.example.com peer channel create -o orderer.org1.example.com:7050 -c archive -f /etc/hyperledger/configtx/channel.tx
Already stopped and wiped all containers beforehand.
This information is only available to the orderer. Hence, this command allows me to see the desired debug log:
docker logs orderer.org1.example.com --details

Endorsement from multiple peers one arg

I have a multiple peer, one org Org1MSP network where I want the transactions to be endorsed by multiple peers.
Is there a way to specify endorsement policy using CLI for e.g. during instantiate chaincode
For e.g.
peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n
mycc -v 1.0 -c '{"Args":[]}' -P "OutOf(2, 'Org1MSP.peer')"
Just specify the same org twice with an AND:
AND('Org1MSP.peer', 'Org1MSP.peer')

Error in starting Hyperledger fabcar sample application

I am trying to run fab car sample application from http://hyperledger-fabric.readthedocs.io/en/release-1.1/write_first_app.html
when ./startFabric.sh node trying to create channel with below command
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
It gives error as
flag provided but not defined: -e
What am I doing wrong here?
The Fabric samples require Docker 17.06.2-ce or later

Getting error when adding new Peer to basicnetwork-Tuna App

We are using Tuna-App to setup basicnetwork along with tuna-app, and trying to add additional peer. Here is the source code of tuna-app
https://github.com/hyperledger/education/tree/master/LFS171x/fabric-material
We are able to add the Peer to the basicnetwork. We verified docker containers, all peer0, peer1, cli, ca, orderer, coughdb, coughdb2, and tuna-app-1.0 are running.
Peer0 sucessfully got added to channel with following command:
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer0.org1.example.com peer channel join -b mychannel.block
We are trying to add Peer1 to the same channel with command:
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer1.org1.example.com peer channel join -b mychannel.block
it throws an error:
genesis block file not found open mychannel.block: no such file or directory
Please help me. How can we resolve this issue?
Enter the cli container:
docker exec -it cli bash
In that terminal, export the required variables:
export CHANNEL_NAME=mychannel
CORE_PEER_LOCALMSPID="Org1MSP"
CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp
CORE_PEER_ADDRESS=peer1.org1.example.com:7051
Add the peer to the channel:
peer channel join -b mychannel.block
Try the below commands:
docker exec peer1.org1.example.com peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c mychannel
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#$org1.example.com/msp" peer1.org1.example-swarm.com peer channel join -b mychannel.block
Create channel from the CLI container. As in firstnetwork.
Because mychannel.block is available only in peer0.
You can't join the channel from peer1 since no mychannel.block file is available.

Resources