无法获取发现服务:无法获取chConfig缓存参考:读取通道对等体的配置失败

时间:2019-05-01 12:21:31

标签: hyperledger-fabric hyperledger-fabric-sdk-go

当尝试安装和实例化链码时,出现以下错误:

WSL(Linux的Windows子系统)上出现错误

  

无法安装和实例化链码:无法实例化链码:无法获取发现服务:无法获取chConfig缓存参考:读取通道对等体的配置失败

Ubuntu 16.04错误

  

无法安装和实例化链码:无法实例化链码:无法获取发现服务:无法获取chConfig缓存参考:没有为通道[mychannel]配置通道对等体

我正在关注chainHero示例。下面是运行make命令后的完整输出。

Build done
Start environment ...
Creating network "firstproject-network_default" with the default driver
Creating orderer.firstproject.com ... done
Creating ca.org1.firstproject.com ... done
Creating peer0.org1.firstproject.com ... done
Creating peer1.org1.firstproject.com ... done
Docker environment up
Start app and initializing skd with local network...
SDK created
Resource management client created

value of req is:  {mychannel <nil> /c/Projects/Go/src/github.com/hyperledger/firstproject/firstproject-network/artifacts/channel.tx [0xc0001d4fa0]}
Value of setup.Orderer is:  orderer.firstproject.com
Channel created
Channel joined
Initialization Successful
ccPkg created
Chaincode installed
Unable to install and instantiate the chaincode: failed to instantiate the chaincode: failed to get discovery service: could not get chConfig cache reference: read configuration for channel peers failed

config.yaml

name: "firstproject-network"

version: 1.0.0
client:
  organization: org1

  logging:
    level: info
  peer:
    timeout:
      connection: 10s
      response: 180s
      discovery:
        greylistExpiry: 10s
  eventService:
    timeout:
      connection: 15s
      registrationResponse: 15s
  orderer:
    timeout:
      connection: 15s
      response: 15s
  cryptoconfig:
    path: /c/Projects/Go/src/github.com/hyperledger/firstproject/firstproject-network/crypto-config

    credentialStore:
    path: /tmp/firstproject-store

    cryptoStore:
      path: /tmp/firstproject-msp

  BCCSP:
    security:
     enabled: true
     default:
      provider: "SW"
     hashAlgorithm: "SHA2"
     softVerify: true
     level: 256

  tlsCerts:
    systemCertPool: false

    client:
      keyfile:
      certfile:

channels:
  OneOrgChannel:
    peers:
      peer0.org1.firstproject.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true

      peer1.org1.firstproject.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true

    policies:
      queryChannelConfig:
        minResponses: 1
        maxTargets: 1
        retryOpts:
          attempts: 5
          initialBackoff: 500ms
          maxBackoff: 5s
          backoffFactor: 2.0

# list of participating organizations in this network
organizations:
  org1:
    mspid: Org1MSP
    cryptoPath: peerOrganizations/org1.firstproject.com/users/{userName}@org1.firstproject.com/msp
    peers:
      - peer0.org1.firstproject.com
      - peer1.org1.firstproject.com

    certificateAuthorities:
      - ca.org1.firstproject.com

orderers:
  orderer.firstproject.com:
    url: grpcs://localhost:7050

    grpcOptions:
      ssl-target-name-override: orderer.firstproject.com
      keep-alive-time: 0s
      keep-alive-timeout: 20s
      keep-alive-permit: false
      fail-fast: false
      allow-insecure: false

    tlsCACerts:
      # Certificate location absolute path
      path: /c/Projects/Go/src/github.com/hyperledger/firstproject/firstproject-network/crypto-config/ordererOrganizations/firstproject.com/tlsca/tlsca.firstproject.com-cert.pem
peers:
  peer0.org1.firstproject.com:
    # this URL is used to send endorsement and query requests
    url: grpcs://localhost:7051
    # eventUrl is only needed when using eventhub (default is delivery service)
    eventUrl: grpcs://localhost:7053

    grpcOptions:
      ssl-target-name-override: peer0.org1.firstproject.com
      keep-alive-time: 0s
      keep-alive-timeout: 20s
      keep-alive-permit: false
      fail-fast: false
      allow-insecure: false

    tlsCACerts:
      path: /c/Projects/Go/src/github.com/hyperledger/firstproject/firstproject-network/crypto-config/peerOrganizations/org1.firstproject.com/tlsca/tlsca.org1.firstproject.com-cert.pem

  peer1.org1.firstproject.com:
    url: grpcs://localhost:8051
    eventUrl: grpcs://localhost:8053

    grpcOptions:
      ssl-target-name-override: peer1.org1.firstproject.com
      keep-alive-time: 0s
      keep-alive-timeout: 20s
      keep-alive-permit: false
      fail-fast: false
      allow-insecure: false

    tlsCACerts:
      path: /c/Projects/Go/src/github.com/hyperledger/firstproject/firstproject-network/crypto-config/peerOrganizations/org1.firstproject.com/tlsca/tlsca.org1.firstproject.com-cert.pem

certificateAuthorities:
  ca.org1.firstproject.com:
    url: http://localhost:7054
    httpOptions:
      verify: false
    registrar:
      enrollId: admin
      enrollSecret: adminpw
    caName: ca.org1.firstproject.com
    tlsCACerts:
      path: /c/Projects/Go/src/github.com/hyperledger/firstproject/firstproject-network/crypto-config/peerOrganizations/org1.firstproject.com/ca/ca.org1.firstproject.com-cert.pem

entityMatchers:
  peer:
    - pattern: (\w*)peer0.org1.firstproject.com(\w*)
      urlSubstitutionExp: grpcs://localhost:7051
      eventUrlSubstitutionExp: grpcs://localhost:7053
      sslTargetOverrideUrlSubstitutionExp: peer0.org1.firstproject.com
      mappedHost: peer0.org1.firstproject.com

    - pattern: (\w*)peer1.org1.firstproject.com(\w*)
      urlSubstitutionExp: grpcs://localhost:8051
      eventUrlSubstitutionExp: grpcs://localhost:8053
      sslTargetOverrideUrlSubstitutionExp: peer1.org1.firstproject.com
      mappedHost: peer1.org1.firstproject.com

  orderer:
    - pattern: (\w+).firstproject.(\w+):(\d+)
      urlSubstitutionExp: grpcs://localhost:7050
      sslTargetOverrideUrlSubstitutionExp: orderer.firstproject.com
      mappedHost: orderer.firstproject.com  

    - pattern: (\w+).firstproject.(\w+)
      urlSubstitutionExp: grpcs://localhost:7050
      sslTargetOverrideUrlSubstitutionExp: orderer.firstproject.com
      mappedHost: orderer.firstproject.com


  certificateAuthorities:
    - pattern: (\w*)ca.org1.firstproject.com(\w*)
      urlSubstitutionExp: http://localhost:7054
      mappedHost: ca.org1.firstproject.com

docker-compose.yaml

version: '2'

networks:
  default:

services:
  orderer.firstproject.com:
    container_name: orderer.firstproject.com
    extends:
      file: peer-base.yaml
      service: orderer-base
    volumes:
      - ./crypto-config/ordererOrganizations/firstproject.com/orderers/orderer.firstproject.com/msp:/var/hyperledger/orderer/msp
      - ./artifacts/orderer.genesis.block:/var/hyperledger/orderer/orderer.genesis.block
      - ./crypto-config/ordererOrganizations/firstproject.com/orderers/orderer.firstproject.com/tls:/var/hyperledger/orderer/tls

    ports:
      - 7050:7050


  ca.org1.firstapplication.com:
    image: hyperledger/fabric-ca:latest
    container_name: ca.org1.firstproject.com
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca.org1.firstproject.com
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.firstproject.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/78da3186373e52832b71dd83ec4d36ef84722a3e3ed15e8df214b482fe2723e7_sk
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.firstproject.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/78da3186373e52832b71dd83ec4d36ef84722a3e3ed15e8df214b482fe2723e7_sk
    ports:
      - 7054:7054
    command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org1.firstproject.com/ca/:/etc/hyperledger/fabric-ca-server-config


  peer0.org1.firstproject.com:
    container_name: peer0.org1.firstproject.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:

      - CORE_PEER_NETWORKID=firstproject
      - CORE_PEER_ID=peer0.org1.firstproject.com
      - CORE_PEER_ADDRESSAUTODETECT=true
      - CORE_PEER_ADDRESS=peer0.org1.firstproject.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.firstproject.com:7051
      - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
      - CORE_PEER_TLS_SERVERHOSTOVERRIDE=peer0.org1.firstproject.com
      #- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.firstapplication.com:7051

    volumes:
        - ./var/run/:/host/var/run/
        - ./crypto-config/peerOrganizations/org1.firstproject.com/peers/peer0.org1.firstproject.com/msp:/var/hyperledger/msp
        - ./crypto-config/peerOrganizations/org1.firstproject.com/peers/peer0.org1.firstproject.com/tls:/var/hyperledger/tls

    ports:
      - 7051:7051
      - 7053:7053
    depends_on:
      - orderer.firstproject.com
    links:
      - orderer.firstproject.com  
    networks:
      default:
        aliases:
          - peer0.org1.firstproject.com  


  peer1.org1.firstproject.com:
    container_name: peer1.org1.firstproject.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:

      - CORE_PEER_NETWORKID=firstproject
      - CORE_PEER_ID=peer1.org1.firstproject.com
      - CORE_PEER_ADDRESSAUTODETECT=true
      - CORE_PEER_ADDRESS=peer1.org1.firstproject.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.firstproject.com:7051
      - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
      - CORE_PEER_TLS_SERVERHOSTOVERRIDE=peer1.org1.firstproject.com
      #- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.firstapplication.com:7051

    volumes:
        - /var/run/:/host/var/run/
        - ./crypto-config/peerOrganizations/org1.firstproject.com/peers/peer1.org1.firstproject.com/msp:/var/hyperledger/msp
        - ./crypto-config/peerOrganizations/org1.firstproject.com/peers/peer1.org1.firstproject.com/tls:/var/hyperledger/tls

    ports:
      - 8051:7051
      - 8053:7053
    depends_on:
      - orderer.firstproject.com
    links:
      - orderer.firstproject.com  
    networks:
      default:
        aliases:
          - peer1.org1.firstproject.com  

peer-base.yaml

version: '2'

services:
  peer-base:
    image: hyperledger/fabric-peer:latest
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_ATTACHSTDOUT=true
      - FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_LOCALMSPID=Org1MSP
      - 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=/var/hyperledger/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/var/hyperledger/tls/server.key  
      - CORE_PEER_TLS_ROOTCERT_FILE=/var/hyperledger/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/var/hyperledger/msp

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start

  orderer-base:
    image: hyperledger/fabric-orderer:latest
    environment:
      - FABRIC_LOGGING_SPEC=DEBUG
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      # enabled TLS
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: orderer  

1 个答案:

答案 0 :(得分:2)

您使用错误的通道名称来实例化链码,在config.yaml中,您定义了与对等方peer0,peer1一起使用的通道OneOrgChannel。但是,您似乎正在使用通道mychannel来实例化链码。

将频道名称更改为OneOrgChannel或在config.yaml中添加mychannel