Error in starting Hyperledger fabcar sample application - hyperledger-fabric

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

Related

Hyperledger Composer ping on REST multi-user mode: ECONNREFUSED for issued identities from single user REST

Following: https://hyperledger.github.io/composer/v0.19/tutorials/google_oauth2_rest
I have the same problem of:
Hyperledger Composer multi-user mode: ECONNREFUSED for issued identities
Basically, i have two rest server and when i issue a id from port 3001 (admin card single user) then import and try to ping on port 3000 (multi-user), the same error appears. Seems like the card are being imported with the wrong hostname.
But i can't do the same that the user says:
" I changed the URLs over there instead of modifying the cards after creating them. This has solved the issue as now the cards are generated with proper container URLs rather than localhost. "
When i do
composer identity issue -c admin#amachains -f restadmin.card -u restadmin -a "resource:org.hyperledger.composer.system.NetworkAdmin#restadmin"
composer card import -f restadmin.card
composer network ping -c restadmin#amachains
cd ..
sed -e 's/localhost:7051/peer0.org1.example.com:7051/' -e 's/localhost:7053/peer0.org1.example.com:7053/' -e 's/localhost:7054/ca.org1.example.com:7054/' -e 's/localhost:7050/orderer.example.com:7050/' < $HOME/.composer/cards/restadmin#amachains/connection.json > /tmp/connection.json && cp -p /tmp/connection.json $HOME/.composer/cards/restadmin#amachains/
and then export this and import in 3000 rest server, the ping works.
That is my script for start my whole project:
# !/bin/bash
sudo kill $(sudo lsof -t -i:3000)
sudo kill $(sudo lsof -t -i:3001)
sudo kill $(sudo lsof -t -i:4200)
# Stop Fabric & Teardown Fabric
~/fabric-dev-servers/stopFabric.sh && ~/fabric-dev-servers/teardownFabric.sh
# Clean Composer
rm -rf ~/.composer
# Clean Docker containers
docker kill $(docker ps -q)
docker rm $(docker ps -aq)
# Clean Docker images
docker rmi $(docker images dev-* -q)
# Clean Docker images
docker rmi $(docker images amachains/* -q)
# Start Fabric & Create Peer Admin Card
~/fabric-dev-servers/startFabric.sh && ~/fabric-dev-servers/createPeerAdminCard.sh
docker run -d --name mongo --network composer_default -p 27017:27017 mongo
cd dockertmp
docker build -t amachains/amachains-rest-server .
cd ..
# Install BNA on Hyperledger Faric with Hyperledger Composer
cd ./amachains-bna
composer archive create -t dir -n .
composer network install --card PeerAdmin#hlfv1 --archiveFile amachains#0.0.1.bna
composer network start --networkName amachains --networkVersion 0.0.1 --networkAdmin admin --networkAdminEnrollSecret adminpw --card PeerAdmin#hlfv1 --file networkadmin.card
composer card import --file networkadmin.card
composer network ping -c admin#amachains
composer participant add -c admin#amachains -d '{"$class":"org.hyperledger.composer.system.NetworkAdmin", "participantId":"restadmin"}'
composer identity issue -c admin#amachains -f restadmin.card -u restadmin -a "resource:org.hyperledger.composer.system.NetworkAdmin#restadmin"
composer card import -f restadmin.card
composer network ping -c restadmin#amachains
cd ..
sed -e 's/localhost:7051/peer0.org1.example.com:7051/' -e 's/localhost:7053/peer0.org1.example.com:7053/' -e 's/localhost:7054/ca.org1.example.com:7054/' -e 's/localhost:7050/orderer.example.com:7050/' < $HOME/.composer/cards/restadmin#amachains/connection.json > /tmp/connection.json && cp -p /tmp/connection.json $HOME/.composer/cards/restadmin#amachains/
source envvars.txt
docker run \
-d \
-e COMPOSER_CARD=${COMPOSER_CARD} \
-e COMPOSER_NAMESPACES=${COMPOSER_NAMESPACES} \
-e COMPOSER_AUTHENTICATION=${COMPOSER_AUTHENTICATION} \
-e COMPOSER_MULTIUSER=${COMPOSER_MULTIUSER} \
-e COMPOSER_PROVIDERS="${COMPOSER_PROVIDERS}" \
-e COMPOSER_DATASOURCES="${COMPOSER_DATASOURCES}" \
-v ~/.composer:/home/composer/.composer \
--name rest \
--network composer_default \
-p 3000:3000 \
amachains/amachains-rest-server
# docker ps |grep rest
# docker logs -f rest
cd amachains-client/
composer-rest-server -c admin#amachains -p 3001 & npm start
system/ping on rest server port 3000 should be ok status but i get:
ERROR Error: Uncaught (in promise): HttpErrorResponse: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":500,"statusText":"Internal Server Error","url":"http://localhost:3000/api/system/ping","ok":false,"name":"HttpErrorResponse","message":"Http failure response for http://localhost:3000/api/system/ping: 500 Internal Server Error","error":{"error":{"statusCode":500,"name":"Error","message":"Error trying login and get user Context. Error: Error trying to enroll user. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]","stack":"Error: Error trying login and get user Context. Error: Error trying to enroll user. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]\n at HLFConnection.login (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:477:30)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:189:7)"}}}

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.

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')

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.

Error while trying to join peer to channel in 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.

Resources