0

I'm trying to instantiate the code using fabric-tools. The peer runs on Container Optimized OS in Google Cloud. Install works (sorry maybe some parameters are not necessary):

docker exec -e \"CORE_PEER_LOCALMSPID=${ORGANIZATION^}MSP\" ^
-e \"CORE_PEER_MSPCONFIGPATH=/home/crypto/peerOrganizations/${ORGANIZATION}/users/Admin@${ORGANIZATION}/msp\" ^
-e \"CORE_PEER_TLS_CERT_FILE=/home/crypto/peerOrganizations/${ORGANIZATION}/peers/${PEER_NAME}.${ORGANIZATION}/tls/server.crt\" ^
-e \"CORE_PEER_TLS_KEY_FILE=/home/crypto/peerOrganizations/${ORGANIZATION}/peers/${PEER_NAME}.${ORGANIZATION}/tls/server.key\" ^
-e \"CORE_PEER_TLS_ROOTCERT_FILE=/home/crypto/peerOrganizations/${ORGANIZATION}/peers/${PEER_NAME}.${ORGANIZATION}/tls/ca.crt\" ^
-e \"CORE_PEER_ADDRESS=${PEER_NAME}:7051\" ^
-e \"CORE_PEER_CHAINCODEADDRESS=${PEER_NAME}:7052\" ^
$CLI peer chaincode install -n my-blockchain -v 0.0.3 -p //home//github.com//my-blockchain -l node

Instantiate fails:

docker exec -e \"CORE_PEER_LOCALMSPID=${ORGANIZATION^}MSP\" ^
-e \"CORE_PEER_MSPCONFIGPATH=/home/crypto/peerOrganizations/${ORGANIZATION}/users/Admin@${ORGANIZATION}/msp\" ^
-e \"CORE_PEER_TLS_CERT_FILE=/home/crypto/peerOrganizations/${ORGANIZATION}/peers/${PEER_NAME}.${ORGANIZATION}/tls/server.crt\" ^
-e \"CORE_PEER_TLS_KEY_FILE=/home/crypto/peerOrganizations/${ORGANIZATION}/peers/${PEER_NAME}.${ORGANIZATION}/tls/server.key\" ^
-e \"CORE_PEER_TLS_ROOTCERT_FILE=/home/crypto/peerOrganizations/${ORGANIZATION}/peers/${PEER_NAME}.${ORGANIZATION}/tls/ca.crt\" ^
-e \"CORE_PEER_ADDRESS=${PEER_NAME}:7051\" ^
-e \"CORE_PEER_CHAINCODEADDRESS=${PEER_NAME}:7052\" ^
$CLI peer chaincode instantiate -o orderer1:7050 -C my-channel -n my-blockchain ^
-l node -v 0.0.3 -c \"{\\\"Args\\\":[]}\" ^
-P \"OR ('Org1MSP.member')\" ^
--tls --cafile $TLS_CERT --keyfile $KEY_FILE --cafile $ORDERER_TLS_CERT -o orderer1:7050

with

2020-03-19 22:09:03.562 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-03-19 22:09:03.562 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "cp: cannot stat '/chaincode/input/src/.': No such file or directory

My CLI docker-compose file looks like that (/var/run stuff looks strange because I tried to make it work on Google COS where parts of the system are immutable):

version: '3'

networks:
  my_net:

services:
  cli-org1:
    hostname: cli-org1
    image: hyperledger/fabric-tools:1.4
    tty: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=info
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=hyperledger_my_net
      - CORE_PEER_ID=peer0
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_MSPCONFIGPATH=/home/crypto/peerOrganizations/org1/users/Admin@org1/msp
      - CORE_PEER_LOCALMSPID=Org1MSP
      #peerOrganizations/org1/peers/peer0.org1/tls/server.crt
      - CORE_PEER_TLS_CERT_FILE=/home/crypto/peerOrganizations/org1/peers/peer0.org1/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/home/crypto/peerOrganizations/org1/peers/peer0.org1/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/home/crypto/peerOrganizations/org1/peers/peer0.org1/tls/ca.crt
      - CORE_PEER_ADDRESS=peer0:7051
      - CORE_PEER_CHAINCODEADDRESS=peer0:7052
      - CORE_CHAINCODE_KEEPALIVE=10
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
        - ./var/cli_run/:/host/var/run/
        - /var/run/docker.sock:/var/run/docker.sock
        - /var/run/docker.sock:/host/run/var/docker.sock
        - ./chaincode/:/home/github.com/
        - ./crypto-config:/home/crypto/
    extra_hosts:
       - "orderer1:111.111.111.111"
       - "peer0:111.111.111.111"
    networks:
      my_net:
           aliases:
              - cli-org1

This is how orderer logs look like:

2020-03-19 21:57:50.723 UTC [orderer.common.server] replicateDisabledChains -> DEBU 87d No inactive chains to try to replicate
2020-03-19 22:02:50.724 UTC [orderer.common.server] replicateDisabledChains -> DEBU 87e No inactive chains to try to replicate
2020-03-19 22:07:50.724 UTC [orderer.common.server] replicateDisabledChains -> DEBU 87f No inactive chains to try to replicate
2020-03-19 22:12:50.724 UTC [orderer.common.server] replicateDisabledChains -> DEBU 880 No inactive chains to try to replicate
2020-03-19 22:16:00.250 UTC [orderer.common.server] Broadcast -> DEBU 881 Starting new Broadcast handler
2020-03-19 22:16:00.250 UTC [orderer.common.broadcast] Handle -> DEBU 882 Starting new broadcast loop for 178.4.35.173:52041
2020-03-19 22:16:01.131 UTC [orderer.common.broadcast] Handle -> WARN 883 Error reading from 178.4.35.173:52041: rpc error: code = Canceled desc = context canceled
2020-03-19 22:16:01.131 UTC [orderer.common.server] func1 -> DEBU 884 Closing Broadcast stream
2020-03-19 22:16:01.131 UTC [comm.grpc.server] 1 -> INFO 885 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=178.4.35.173:52041 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=881.822921ms
2020-03-19 22:16:01.131 UTC [grpc] infof -> DEBU 886 transport: loopyWriter.run returning. connection error: desc = "transport is closing"
2020-03-19 22:17:50.724 UTC [orderer.common.server] replicateDisabledChains -> DEBU 887 No inactive chains to try to replicate
2020-03-19 22:19:26.918 UTC [orderer.common.server] Broadcast -> DEBU 888 Starting new Broadcast handler
2020-03-19 22:19:26.918 UTC [orderer.common.broadcast] Handle -> DEBU 889 Starting new broadcast loop for 178.4.35.173:52073
2020-03-19 22:19:27.780 UTC [grpc] infof -> DEBU 88a transport: loopyWriter.run returning. connection error: desc = "transport is closing"
2020-03-19 22:19:27.780 UTC [orderer.common.broadcast] Handle -> DEBU 88b Received EOF from 178.4.35.173:52073, hangup
2020-03-19 22:19:27.780 UTC [orderer.common.server] func1 -> DEBU 88c Closing Broadcast stream
2020-03-19 22:19:27.780 UTC [comm.grpc.server] 1 -> INFO 88d streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=178.4.35.173:52073 grpc.code=OK grpc.call_duration=861.76369ms

What could be the problem? For example where is this folder /chaincode/input/src/. is missing? On a host system? But because the root directory is immutable I cannot create /chaincode there.

Fedor Petrov
  • 990
  • 9
  • 19
  • UPD. I analyzed the LOGs of my peer. It seems that the CouchDB entries are empty even if the code is installed. According to at least this post: https://stackoverflow.com/questions/52794726/hyperledger-fabric-couchdb-persistent couchdb data is stored under /opt/couchdb/data Since I use Google COS, no directory can be created there. – Fedor Petrov Mar 19 '20 at 23:18
  • Mounting /home/hyperledger/couchdb_data to /opt/couchdb/data didn't solve the problem. The error with missing /chaincode/input/src is still there – Fedor Petrov Mar 20 '20 at 09:47
  • Moving to Debian as host didn't help. There should be something in the configs... – Fedor Petrov Mar 20 '20 at 14:46

1 Answers1

0

The problem is simple and has at this point almost nothing to do with Hyperledger. I work under Windows but use Git Bash to automate some processes. Docker under Windows doesn't work good with Git Bash. Earlier I was running the installation inside my script like this:

COMMAND="docker exec -e \"CORE_PEER_LOCALMSPID=${ORGANIZATION^}MSP\" ^
-e \"CORE_PEER_MSPCONFIGPATH=/home/crypto/peerOrganizations/${ORGANIZATION}/users/Admin@${ORGANIZATION}/msp\" ^
-e \"CORE_PEER_TLS_CERT_FILE=/home/crypto/peerOrganizations/${ORGANIZATION}/peers/${PEER_NAME}.${ORGANIZATION}/tls/server.crt\" ^
-e \"CORE_PEER_TLS_KEY_FILE=/home/crypto/peerOrganizations/${ORGANIZATION}/peers/${PEER_NAME}.${ORGANIZATION}/tls/server.key\" ^
-e \"CORE_PEER_TLS_ROOTCERT_FILE=/home/crypto/peerOrganizations/${ORGANIZATION}/peers/${PEER_NAME}.${ORGANIZATION}/tls/ca.crt\" ^
-e \"CORE_PEER_ADDRESS=${PEER_NAME}:7051\" ^
-e \"CORE_PEER_CHAINCODEADDRESS=${PEER_NAME}:7052\" ^
$CLI peer chaincode install -n my-blockchain -v 0.0.3 -p //home//github.com//my-blockchain -l node"
cmd //c $COMMAND

Exactly this execution messed up "successful" chaincode installation. And made it impossible to instantiate the code later. I replaced // with / in //home//github.com//my-blockchain, saved the whole command to a file, and executed it as follows:

echo "$COMMAND" > install.bat
cmd "//c install.bat"

After that everything works fine. However, since the installation had status 200, but no entries in CouchDB have been entered I find it a little bit incorrect.

Fedor Petrov
  • 990
  • 9
  • 19