Hyperledger Composer add a new peer - docker

I am modifying existing docker-compose.yml, crypto-config.yaml and configtx.yaml to add a extra peer to the existing hyperledger composer sample, located under hlfv11 folder of the fabric-tools/fabric-scripts.
I regenerated required certificates and genesis block and it generates the peer container without any issue.
However I am having difficulty adding this peer to a channel. I modified startFabric.sh to join this peer to a channel, however I am getting an error with following message:
Error getting endorser client channel: endorser client failed to connect to peer1.org1.example.com:8051: failed to create a new connection: context deadline exceeded.
Can someone please help or advise?

I was trying to join me additional peer to channel directly through PEER CHANELL JOIN command. It actually requires to fetch the channel through orderer on new peer and then it can join it.
Code update follows:
# Create the channel
docker exec peer0.org1.example.com peer channel create -o
orderer.example.com:7050 -c composerchannel -f
/etc/hyperledger/configtx/composer-channel.tx
# Join peer0.org1.example.com to the channel.
docker exec -e "CORE_PEER_MSPCONFIGPATH=
/etc/hyperledger/msp/users/Admin#org1.example.com/msp
peer0.org1.example.com peer channel join -b composerchannel.block
# Create the channel
docker exec -e "CORE_PEER_MSPCONFIGPATH=
/etc/hyperledger/msp/users/Admin#org1.example.com/msp"
peer1.org1.example.com peer channel fetch config -o orderer.example.com:7050
-c composerchannel
# Join peer1.org1.example.com to the channel.
docker exec -e "CORE_PEER_MSPCONFIGPATH=
/etc/hyperledger/msp/users/Admin#org1.example.com/msp
peer1.org1.example.com peer channel join -b composerchannel_config.block

Related

Port conflicts in starting test-network of Hyperledger Fabric using fabric-samples folder

I'm a new starter and have been struggling for a while about these port errors
When I run ./network.sh in the directory: fabric-samples/test-network
the following port errors occurred:
yujindeMBP:test-network yujin$ ./network.sh up
Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
LOCAL_VERSION=2.3.0
DOCKER_IMAGE_VERSION=2.3.0
/Users/yujin/fabric-samples-with-bis/test-network/../bin/cryptogen
Generating certificates using cryptogen tool
Creating Org1 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
Creating Org2 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
Creating Orderer Org Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
Generating CCP files for Org1 and Org2
Creating network "net_test" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating orderer.example.com ... error
Creating peer0.org2.example.com ...
Creating peer0.org1.example.com ...
Creating peer0.org1.example.com ... error
Creating peer0.org2.example.com ... done
ERROR: for peer0.org1.example.com Cannot start service peer0.org1.example.com: Ports are not available: listen tcp 0.0.0.0:7051: bind: address already in use
ERROR: for orderer.example.com Cannot start service orderer.example.com: Ports are not available: listen tcp 0.0.0.0:7050: bind: address already in use
ERROR: for peer0.org1.example.com Cannot start service peer0.org1.example.com: Ports are not available: listen tcp 0.0.0.0:7051: bind: address already in use
ERROR: Encountered errors while bringing up the project.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6feb86580f43 hyperledger/fabric-orderer:latest "orderer" 1 second ago Created orderer.example.com
dbfae1aa4c11 hyperledger/fabric-peer:latest "peer node start" 1 second ago Created peer0.org1.example.com
d0367a0d6089 hyperledger/fabric-peer:latest "peer node start" 1 second ago Up Less than a second 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com
It seems the orderer, the org1 and the org2 are using the same ports 7050 and 7051, they got conflicted with each other. I have thought I can avoid these port errors by running docker. However, it seems that I'm wrong. I checked the docker environment before I run ./network.sh and I'm sure no other processes are running in the same time.
yujindeMBP:test-network yujin$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
The docker's processes table is clear before I tried to start the test-network.
I'm really confused and need your help. Thanks a lot!
Try docker ps -a This list all the active container.
Remove containers using the command docker rm -f [container_id/container_name]
once all containers removed then bring back your network.
If you're still facing the issue then go to your crypto-config-org1.yaml, crypto-config-org2.yaml, crypto-config-orderer.yaml edit and change the ports. Also you can ask question on https://chat.hyperledger.org/

Hyperledger Fabric v2 new chaincode lifecycle install problem with dind vm endpoint + tls

having trouble with new v2 chaincode lifecycle, I am using docker vm dind endpoint https://127.0.0.1 with tls on, peer has all docker client crypto material set
CORE_VM_DOCKER_TLS_ENABLED=true
CORE_VM_DOCKER_TLS_CERT=/tmp/org1/peer1/docker/cert.pem
CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=host
CORE_VM_DOCKER_TLS_KEY=/tmp/org1/peer1/docker/key.pem
CORE_VM_ENDPOINT=https://127.0.0.1:2376
CORE_VM_DOCKER_TLS_CA=/tmp/org1/peer1/docker/ca.pem
Trying to install chaincode package.
peer lifecycle chaincode install patient_consent-v0.0.1-package.tar.gz \
--peerAddresses fabric-dev-peer1-org1:7051 --connTimeout 10s \
--tlsRootCertFiles /tmp/org1/peer1/tls/msp/cacerts/fabric-dev-tlsca-org1-7052.pem \
-o fabric-dev-orderer1-org1:7050 --tls --cafile /tmp/org1/peer1/tls/msp/cacerts/fabric-dev-tlsca-org1-7052.pem
This gives me
Error: chaincode install failed with
status: 500 - failed to invoke backing implementation of 'InstallChaincode'
could not build chaincode
docker build failed
docker image inspection failed
Get https://127.0.0.1:2376/images/dev-peer1-org1-patient_consent-v0.0.1-9aedb4f5f58cb4bf18cf38f53751928caf9074c4bcb6859d8417fb37c09ab596-0acf342a6da8bfef85ec6b4d9dbe3ca4236ab9e52d903bb9fb014db836696d7b/json
remote error:
tls: bad certificate
In the peer chaincode install command, you have put the wrong tlsRootCertFiles for the orderer. The --cafile is same as the peer. It is the orderer CA file .
--tlsRootCertFiles /tmp/org1/peer1/tls/msp/cacerts/fabric-dev-tlsca-org1-7052.pem \
-o fabric-dev-orderer1-org1:7050 --tls --cafile /tmp/org1/peer1/tls/msp/cacerts/fabric-dev-tlsca-org1-7052.pem
Usually when you spin up the test-network (2.0/1),the orderer tls CA files is found at organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
You can check in your setup and put the right path for orderer --cafile flag.

Find out which members verified a transaction in Hyperledger Fabric

I am using Hyperledger Fabric in combination with docker. My question is, how do i find out which peers verified a transaction in Hyperledger Fabric?
I use this code to instantiate my chaincode, which works:
docker exec -e "CORE_PEER_ADDRESS=peer0.org1.example.com:7051" cli peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -l golang -v ${CC_VERSION} -c '{"Args":["entry","5"]}' -P "OutOf(2, 'Org1MSP.member', 'Org1MSP.member')"
I am using peers from the same organization to verify the transaction.
All of my code works, but after running the code (which includes invokes), can i somehow check the block to see which peers endorsed the transactions that were made?
I have tried using the configtxlator to decode and view the block, but cannot find any information about endorsements in mychannel.block.
Probably mychannel.block was old
You have to check the latest block, where a transaction has been committed
------ OR -----
Use query with txid
A sample snippet of NodeJS
await this.channel.queryTransaction(trxnID, peer);
Took endorser block from large payload
"endorser": {
"Mspid": "nbdMSP",
"IdBytes": "-----BEGIN CERTIFICATE-----\nMIIB8jCCAZmgAwIBAgIRAMMkec+NjAhiRxaQeDWktWkwCgYIKoZIzj0EAwIwWTEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG\ncmFuY2lzY28xDDAKBgNVBAoTA25iZDEPMA0GA1UEAxMGY2EubmJkMB4XDTE5MDcx\nNzA3MjQwMFoXDTI5MDcxNDA3MjQwMFowTjELMAkGA1UEBhMCVVMxEzARBgNVBAgT\nCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xEjAQBgNVBAMTCXBl\nZXIyLm5iZDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABFkiesAiYm/TLpIuV2XB\nIDqAN42tIBftBBitwftt2OSLgjhgzqS0JGIy6cFf4kmemNm9o4s79qgqRodUUMFw\nfXCjTTBLMA4GA1UdDwEB/wQEAwIHgDAMBgNVHRMBAf8EAjAAMCsGA1UdIwQkMCKA\nIEtwfai3aqFfvBEI/oh4NdaSBeK1ndO6SFAsFkXNuhpbMAoGCCqGSM49BAMCA0cA\nMEQCIDQFjJ7LpSsiM8YImjZkJ00zwU2GDKV32Bi7WK3EyBkfAiBSDgkv3bv7cocu\n1O4Ak+jJMrQvOook+JRq3kHmCVKDig==\n-----END CERTIFICATE-----\n"
},

Hyperledger fabric: Cli Bash isn't able to connect to orderer; chaincodes not instantiating on channel

Error:
error getting broadcast client: orderer client failed to connect to
orderer.example.com:7050: failed to create new connection: context
deadline exceeded
I'm getting this error when trying to start a private collection in Fabric.
Following the docs properly and everything at the basic level seems to work (creating first app, creating first network, and extending first network - have not tried upgrading network parts yet). But as I create the private collections feature, it stops precisely at this step.
This happens when I start the network, go into the peer container using docker exec -it cli bash and instantiate the chaincode on the peer (peer chaincode install -n marblesp -v 1.0 -p github.com/chaincode/marbles02_private/go/) which works.
But when I instantiate it on the channel (peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n marblesp -v 1.0 -c '{"Args":["init"]}' -P "OR('Org1MSP.member','Org2MSP.member')" --collections-config $GOPATH/src/github.com/chaincode/marbles02_private/collections_config.json --connTimeout 30s) it produces this error and I dont know how proceed further.
Can someone help me understand what's wrong here or how to get my chaincode instantiated on my channel because I have to get the private collections to work?
Its possible this question is related to some communication between different docker images as my orderer and peer are in different containers. My commands run in the peer container (atleast thats what I think) and its unable to talk to orderer container.
Here are kinematic screenshots:
UPDATE:
This is my command: (peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n marblesp -v 1.0 -c '{"Args":["init"]}' -P "OR('Org1MSP.member')" --collections-config $GOPATH/src/github.com/marbles02_private/collections_config.json --connTimeout 30s).
I get this without sudo:
Error: error getting broadcast client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded
and with sudo I get
Error: error getting endorser client for instantiate: endorser client failed to connect to 0.0.0.0:7051: failed to create new connection: context deadline exceeded
and in sudo case, it doesn't even wait 30s, it shows error within ~2 seconds.

Hyperledger Fabric: Orderer Client failed to connect to orderer.example.com

I am new to hyperledger fabric and I am trying to create a sample blockchain network from scratch using hyperledger fabric. In order to do so, I configured "crypto-config.yaml" file, and generated the respective organization's certificates by running it against the "cryptogen" tool. I also generated the respective "channel-artifacts" by configuring the "configtx.yaml" file and running it against the configtxgen tool. I then modified the "docker-compose-cli.yaml" file and "docker-compose-base" file.
Now, in order to bootstrap the network, I ran the following docker command:
docker-compose -f docker-compose-cli.yaml up
I then executed the following commands:
docker exec -it cli bash
export CHANNEL_NAME=testChannel
peer channel create -o orderer.example.com:7050 -c testChannel -f ./channel-artifacts/testChannel.tx
On executing the "peer channel create" command I received the following error:
Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded
I am not sure as to why this error is occurring. My configuration for the Address section in OrdererDefaults (in configtx.yaml file) is:
Ordertype:
- solo
Addresses:
- orderer.example.com:7050
Hence, please let me know if I am missing something in order to clear the "peer channel create" issue.
do a docker ps and see if the orderer is up and running
if not do a docker logs orderer.example.com and check orderers logs
usually the orderer logs give clear clues on what has happened
read the logs and fix the issue . that's what i did
and instead of creating a peer first going inside it and creating a channel ,i suggest you create the channel first and join the peer to it afterwards
Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" peer0.org1.tracexyz.com peer channel create -o orderer.tracexyz.com:7050 -c cheeseproduction -f /etc/hyperledger/configtx/channel.tx
Add peer 0 to the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" peer0.org1.tracexyz.com peer channel join -b cheeseproduction.block
Fetch from peer 1
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" peer1.org1.tracexyz.com peer channel fetch config -o orderer.tracexyz.com:7050 -c cheeseproduction
Join peer 1 also to the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" -e "CORE_PEER_ADDRESS=peer1.org1.tracexyz.com:7061" peer0.org1.tracexyz.com peer channel join -b cheeseproduction.block
this is how i connected two peers to a single channel. my org name was tracexyz (tracexyz instead of example ) and my channel name was cheeseproduction
I guesss you can replace those with your own values
after doing these go inside the peer with
docker exec -it cli bash
it will take you inside the default peer which is peer0.org1
then do a peer channel list to see the channels to which peer0 has joined
you will see it will list cheeseproduction

Resources