Setting up a Fabric network on multiple computers: Unable to instantiate chain code on peers of 2nd Org - hyperledger-fabric

I am trying to setup the balance-transfer network on multiple computers.
This is similar to the query at
unable to Instantiate any chaincodes on peers of newly Added org
However, there was no resolution to that question
My approach is described below:
1 Org1, Orderer, CA1 on 1st computer
2.Org2, CA2 on 2nd computer
3.Split the docker-compose file accordingly
4.Added the IP's in the network-config file
I was able to register users of both Orgs and install chain code on both the hosts. However, I am not able to instantiate the chain code on Org 2 (ie. the second computer)
I get the following error :
[2018-07-19 11:20:31.401] [ERROR] instantiate-chaincode - REQUEST_TIMEOUT:10.228.27.96:8051
[2018-07-19 11:20:31.402] [ERROR] instantiate-chaincode - Error: ChannelEventHub has been shutdown
at ChannelEventHub.disconnect (/Users/digital3/Desktop/Final/balance-transfer/node_modules/fabric-client/lib/ChannelEventHub.js:444:21)
at Timeout.setTimeout (/Users/digital3/Desktop/Final/balance-transfer/app/instantiate-chaincode.js:101:10)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
[2018-07-19 11:20:31.403] [ERROR] instantiate-chaincode - Error: ChannelEventHub has been shutdown
at ChannelEventHub.disconnect (/Users/digital3/Desktop/Final/balance-transfer/node_modules/fabric-client/lib/ChannelEventHub.js:444:21)
at Timeout.setTimeout (/Users/digital3/Desktop/Final/balance-transfer/app/instantiate-chaincode.js:101:10)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
[2018-07-19 11:20:31.403] [ERROR] instantiate-chaincode - Failed to instantiate. cause:Error: ChannelEventHub has been shutdown
(node:3837) UnhandledPromiseRejectionWarning: Error: Failed to instantiate. cause:Error: ChannelEventHub has been shutdown
From what I understand, the proposal is sent to orderer but fails there.
The peer logs suggest the same: Failed connecting to orderer.example.com:7050 Could not connect to any of the endpoints
Could someone help me with this? Should I add any extra-hosts parameter in the docker-compose file for ORG2. I have only included the IP's in the network-config files for now.
Docker compose for ORG 2 is shown below
ca.org2.example.com:
image: hyperledger/fabric-ca
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-org2
- FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
- FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/a7d47efa46a6ba07730c850fed2c1375df27360d7227f48cdc2f80e505678005_sk
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
- FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/a7d47efa46a6ba07730c850fed2c1375df27360d7227f48cdc2f80e505678005_sk
ports:
- "8054:7054"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ./channel/crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
container_name: ca_peerOrg2
peer0.org2.example.com:
container_name: peer0.org2.example.com
extends:
file: base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.org2.example.com
- CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_ADDRESS=peer0.org2.example.com:7051
ports:
- 8051:7051
- 8053:7053
volumes:
- ./channel/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/:/etc/hyperledger/crypto/peer
peer1.org2.example.com:
container_name: peer1.org2.example.com
extends:
file: base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer1.org2.example.com
- CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_ADDRESS=peer1.org2.example.com:7051
ports:
- 8056:7051
- 8058:7053
volumes:
- ./channel/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/:/etc/hyperledger/crypto/peer

Related

Hyperledger Fabric Multiple hosts fails endorsement : error sending: txid: exists

I'm working on Hyperledger Fabric v1.4.6 and node sdk v1.4.8 and trying to configure it on multiple hosts using Docker Swarm and Compose. My network consist of 2 channels, 3 org and a single raft Orderer. Anchor peers have been successfully updated on channels.
Host 1: channel1 has peer0org1 and peer0org2 + CA-org1 and CA-org2 a Cli and an Orderer
Host 2: channel2 has peer0org1 and peer0org3 + CA-org1 and CA-org3.
My endorsement policy is "AND ('Org1MSP.peer','Org2MSP.peer')" for channel1, for channel2 it is "AND ('Org1MSP.peer','Org3MSP.peer')"
I'm able to successfully build the network and invoke/query transactions via cli but the error starts
when I'm trying to invoke the chaincode via node sdk.
Node sdk error when trying to invoke using invoke.js
- warn: [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G1:1 - endorsement failed - Error: failed
to execute transaction 3b8eb8fe01815c3dd03e1fb840f35a3092974de83694e83a0ec13e548682458d: error sending: txid: 3b8eb8fe01815c3dd03e1fb840f35a3092974de83694e83a0ec13e548682458d(channel1) exists
- error: [DiscoveryEndorsementHandler]: _endorse - endorsement failed::Error: Endorsement has failed
at DiscoveryEndorsementHandler._endorse (/home/ubuntu/utils/node_modules/fabric-network/node_modules/fabric-client/lib/impl/DiscoveryEndorsementHandler.js:185:19)
This error resolves when I use a single org endorsement policy "AND('Org1MSP.peer')".
Additionally, my gateway has discovery: { enabled: true, asLocalhost: true } });
org1 yaml file:
org1peer0:
image: hyperledger/fabric-peer:$IMAGE_TAG
environment:
# couchdb params
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
# the following setting starts chaincode containers on the same
# bridge network as the peers
# https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric
- CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
#- CORE_LOGGING_LEVEL=INFO
- FABRIC_LOGGING_SPEC=INFO
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_VM_DOCKER_ATTACHSTDOUT=true
- CORE_CHAINCODE_STARTUPTIMEOUT=1200s
- CORE_CHAINCODE_EXECUTETIMEOUT=800s
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
- peer0.org1.example.com:/var/hyperledger/production
deploy:
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints:
- node.hostname == $WORKER1_HOSTNAME
ports:
- published: 7051
target: 7051
mode: host
Also, the node sdk app is running outside the docker network.

unexpected signal during runtime execution [signal SIGSEGV: segmentation violation ..] when creating channel

am getting the following error when creating a channel, a similar question has been asked but no answer was provided. Am using the fabric samples (git clone -b issue-6978 https://github.com/sstone1/fabric-samples.git) Previously I never hard this problem untill when I restarted my machine. Am using ubuntu 18.04
This is how I fixed the problem, I added GODEBUG=netdns=go to the environment variables of peer, orderer, and cli inside the docker compose yaml files. A more detailed explanation can be got from this site. This is how the environemental variable should look like.
peer-base:
image: hyperledger/fabric-peer
environment:
- GODEBUG=netdns=go
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
# the following setting starts chaincode containers on the same
# bridge network as the peers
# https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn
#- CORE_LOGGING_LEVEL=ERROR
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start

Error During up the first Network using CouchDB

while join the peer to the channel got the following error:-
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
Note that:-
I have used CouchDb. write the following command:-
docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml up -d
maybe you can do some validation against the docker-compose-couch.yaml and your old file, I asume that you replace it but the file is still there.
Validate that all the services are pointing to use CouchDB now, maybe the docker-compose-cli.yaml is pointing to the other DB type.
peer0.org1.example.com:
container_name: peer0.org1.example.com
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org1.example.com
- CORE_LOGGING_PEER=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
# # the following setting starts chaincode containers on the same
# # bridge network as the peers
# # https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
# The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
# provide the credentials for ledger to connect to CouchDB. The username and password must
# match the username and password set for the associated CouchDB.
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
# command: peer node start --peer-chaincodedev=true
ports:
- 7051:7051
- 7053:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
extra_hosts:
- "peer1.org1.example.com:209.97.128.176"
depends_on:
- orderer.example.com
- couchdb
networks:
- basic
couchdb:
container_name: couchdb
image: hyperledger/fabric-couchdb
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
environment:
- COUCHDB_USER=
- COUCHDB_PASSWORD=
ports:
- 5984:5984
networks:
- basic
In the example you have one peer service and the couchDB service, you can take it as example.
Also, I have a tutorial of how to setup a Hyperledger Fabric in mutiple hosts based in the Basic Network example of the Fabric Samples. Maybe you can take it as reference.
https://medium.com/1950labs/setup-hyperledger-fabric-in-multiple-physical-machines-d8f3710ed9b4
Regards!

Adding peers to the Fabcar Network - Hyperledger Fabric

I tried to extend the fabcar network to 2 peers running on the same system. I encountered some errors.
I made the following changes to the docker compose file.
peer1.org1.example.com:
container_name: peer1.org1.example.com
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer1.org1.example.com
- CORE_LOGGING_PEER=debug
- CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer1.org1.example.com:7051
# # the following setting starts chaincode containers on the same
# # bridge network as the peers
# # https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
# The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
# provide the credentials for ledger to connect to CouchDB. The username and password must
# match the username and password set for the associated CouchDB.
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
# command: peer node start --peer-chaincodedev=true
ports:
- 8051:7051
- 8053:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.example.com
- couchdb1
networks:
- basic
couchdb1:
container_name: couchdb1
image: hyperledger/fabric-couchdb
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
environment:
- COUCHDB_USER=
- COUCHDB_PASSWORD=
ports:
- 6984:5984
networks:
- basic
In the start.sh file, I added a line of code to join peer 1 to the channel.
When I execute ./startFabric.sh node, I get the following error:
Error response from daemon, container not running.
Logs are as below:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b602e1898831 hyperledger/fabric-peer "peer node start" 3 minutes ago Exited (1) 3 minutes ago peer1.org1.example.com
780acf5be420 hyperledger/fabric-couchdb "tini -- /docker-ent…" 3 minutes ago Up 3 minutes 4369/tcp, 9100/tcp, 0.0.0.0:6984->5984/tcp couchdb1
d93c8d14e07d hyperledger/fabric-peer "peer node start" 3 minutes ago Up 3 minutes 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
f8d5a07e0c14 hyperledger/fabric-couchdb "tini -- /docker-ent…" 3 minutes ago Up 3 minutes 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb
0c8be993aaad hyperledger/fabric-orderer "orderer" 3 minutes ago Up 3 minutes 0.0.0.0:7050->7050/tcp orderer.example.com
29484423ee69 hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 3 minutes ago Exited (1) 3 minutes ago ca.example.com
Digitals-MacBook-Air-3:fabcar digital3$ docker logs b602e1898831
2018-06-28 08:12:18.923 UTC [main] main -> ERRO 001 **Cannot run peer because error when setting up MSP of type bccsp from directory /etc/hyperledger/msp/peer/: could not load a valid signer certificate from directory /etc/hyperledger/msp/peer/signcerts: stat /etc/hyperledger/msp/peer/signcerts: no such file or directory**
Changes I made are:
In crypto-config: changed template count to 2.
In docker-compose , added another service for peer1 with database as couchdb1. No changes to CLI.
In the start.sh file, I wrote a line of code to add peer 1 to the channel.
When I run ./startFabric.sh node in the fabcar directory, I get the above mentioned errors.
I am making edits in the basic-network and not first network.
I just checked my certificate directory: It looks as below
CRYPTOCONFIG - PeerOrganisations - Peers - peer0 , peer1
Peer0 has all the certificates
Peer1 only has the msp folder, no tls folder. The msp folder only has admincerts and keystore
Update:
I managed to generate the certificates for both peers and successful ran the ./startFabric.sh node command from the fabcar directory. However, I faced an issue when I executed the enrollAdmin command.
Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 10.228.27.101:7054]
at ClientRequest. (/Users/digital3/fabric-samples/fabcar/node_modules/fabric-ca-client/lib/FabricCAClientImpl.js:883:12)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Failed to enroll admin: Error: Failed to enroll admin
Could you help me with this
If you want to add additional peer node(s), you will also need to generate the relevant crypto material.
On line 63 of the crypto-config.yaml file in the basic-network directory, set the value of Count to '2', e.g.:
# "Template"
# ---------------------------------------------------------------------------
# Allows for the definition of 1 or more hosts that are created sequentially
# from a template. By default, this looks like "peer%d" from 0 to Count-1.
# You may override the number of nodes (Count), the starting index (Start)
# or the template used to construct the name (Hostname).
#
# Note: Template and Specs are not mutually exclusive. You may define both
# sections and the aggregate nodes will be created for you. Take care with
# name collisions
# ---------------------------------------------------------------------------
Template:
Count: 2
# Start: 5
# Hostname: {{.Prefix}}{{.Index}} # default
This will have the cryptogen step generate key material for two peer nodes for the org: Org1.

initDeliver -> ERRO 129 Cannot dial to 0.0.0.0:7050, because of grpc: timed out when dialing

What am I doing wrong?
I'm trying to familiarize myself with Hyperledger. I thought I'd run the Fabric locally and use the Marbles demo. I think the errors below explain why Marbles is unable to access the local Fabric. I deployed Blockchain on Bluemix per the Marbles' instructions and that worked correctly.
I'm following the instructions here:
https://hyperledger-fabric.readthedocs.io/en/latest/Setup/Network-setup/
Running Docker 1.12.5 on Ubuntu (4.4.0-57-generic)
Regardless of whether I run a single peer or multiple, I receive the following errors for each of the peers. It makes no difference whether I remove 7050:7050 from the vp0 peer's published ports. I'm unable to curl what I think should be a REST endpoint on 7050.
vp0_1 | 2017-01-08 04:46:42.723 UTC [committer] initDeliver -> ERRO 129 Cannot dial to 0.0.0.0:7050, because of grpc: timed out when dialing
vp0_1 | 2017-01-08 04:46:42.723 UTC [committer] startDeliver -> ERRO 12a Can't initiate deliver protocol [grpc: timed out when dialing]
vp1_1 | 2017-01-08 04:46:43.443 UTC [committer] initDeliver -> ERRO 12d Cannot dial to 0.0.0.0:7050, because of grpc: timed out when dialing
vp1_1 | 2017-01-08 04:46:43.443 UTC [committer] startDeliver -> ERRO 12e Can't initiate deliver protocol [grpc: timed out when dialing]
Here's the docker-compose.yml that I mangled from the instructions [unfamiliar with docker-compose]:
vp0:
image: hyperledger/fabric-peer
ports:
- "7050:7050"
- "7051:7051"
- "7052:7052"
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=vp0
command: peer node start
vp1:
image: hyperledger/fabric-peer
environment:
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=vp1
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
command: peer node start
links:
- vp0
Running docker-compose up subsequently, the issue appears to no longer occur. The only changes that I'm aware of are:
-- I did some Docker house-keeping, cleaning up old containers/images
-- Time passed
I think your problem is that u don't declare the orderer service
try to add
orderer:
container_name: orderer
image: hyperledger/fabric-orderer:latest
environment:
- ORDERER_GENERAL_LEDGERTYPE=ram
- ORDERER_GENERAL_BATCHTIMEOUT=10s
- ORDERER_GENERAL_BATCHSIZE_MAXMESSAGECOUNT=10
- ORDERER_GENERAL_MAXWINDOWSIZE=1000
- ORDERER_GENERAL_ORDERERTYPE=solo
- ORDERER_GENERAL_LOGLEVEL=debug
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_LISTENPORT=7050
- ORDERER_RAMLEDGER_HISTORY_SIZE=100
command: orderer
ports:
- 7050:7050
volumes:
- ./orderer-config.yaml:/etc/hyperledger/fabric/orderer.yaml
networks:
- bridge

Resources