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
Related
Have setup a 3-node Elasticsearch cluster using docker-compose. Followed below steps:
On one of the master nodes, es11, gets below error, however same curl command works fine on other 2 nodes i.e. es12, es13:
Error:
curl -X GET 'https://localhost:9316'
curl: (35) Encountered end of file
Below error in logs:
"stacktrace": ["org.elasticsearch.transport.RemoteTransportException: [es13][SOMEIP:9316][internal:cluster/coordination/join]",
"Caused by: org.elasticsearch.transport.ConnectTransportException: [es11][SOMEIP:9316] handshake failed. unexpected remote node {es13}{SOMEVALUE}{SOMEVALUE
"at org.elasticsearch.transport.TransportService.lambda$connectionValidator$6(TransportService.java:468) ~[elasticsearch-7.17.6.jar:7.17.6]",
"at org.elasticsearch.action.ActionListener$MappedActionListener.onResponse(ActionListener.java:95) ~[elasticsearch-7.17.6.jar:7.17.6]",
"at org.elasticsearch.transport.TransportService.lambda$handshake$9(TransportService.java:577) ~[elasticsearch-7.17.6.jar:7.17.6]",
https://localhost:9316 on browser gives site can't be reached error as well.It seems SSL certificate as created in step 4 below is having some issues in es11.
Any leads please? OR If I repeat step 4, do i need to copy the certs again to es12 & es13?
Below elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
Ports as defined in all 3 nodes docker-compose.yml
environment:
- node.name=es11
- transport.port=9316
ports:
- 9216:9200
- 9316:9316
Initialize a docker swarm. On ES11 run docker swarm init. Follow the instructions to join 12 and 13 to the swarm.
Create an overlay network docker network create -d overlay --attachable elastic
If necessary, bring down the current cluster and remove all the associated volumes by running docker-compose down -v
Create SSL certificates for ES with docker-compose -f create-certs.yml run --rm create_certs
Copy the certs for es12 and 13 to the respective servers
Use this busybox to create the overlay network on 12 and 13 sudo docker run -itd --name containerX --net [network name] busybox
Configure certs on 12 and 13 with docker-compose -f config-certs.yml run --rm config_certs
Start the cluster with docker-compose up -d on each server
Set the passwords for the built-in ES accounts by logging into the cluster docker exec -it es11 sh then running bin/elasticsearch-setup-passwords interactive --url localhost:9316
(as per your https://discuss.elastic.co thread)
you cannot talk HTTP to the transport protocol port, which you have defined in transport.port. you need to talk to port 9200 in the container, which you have mapped to 9216 outside the container
the transport port runs a binary protocol that is not HTTP accessible
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.
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"
},
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.
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