hyperledger fabric 发现服务背书失败

hyperledger fabric discovery service failing endorsement

大家好,我正在尝试将服务发现与节点 js 客户端结合使用来生成交易提案,我遇到的问题是,当发现生成背书计划时,它会将提案发送给同一对等点,但背书失败, 这是生成的背书计划之一,idk 为什么但是对等名称都是错误的

{
  "chaincode": "auditoria-cc",
  "groups": {
    "G0": {
      "peers": [
        {
          "mspid": "Org1MSP",
          "endpoint": "peer0.org1.autentia-bchain.com:7051",
          "ledger_height": {
            "low": 11,
            "high": 0,
            "unsigned": true
          },
          "chaincodes": [
            {
              "name": "auditoria-cc",
              "version": "1.0"
            }
          ],
          "name": "peer0.org1.autentia-bchain.com"
        }
      ]
    },
    "G1": {
      "peers": [
        {
          "mspid": "Org2MSP",
          "endpoint": "peer0.org2.autentia-bchain.com:7051",
          "ledger_height": {
            "low": 11,
            "high": 0,
            "unsigned": true
          },
          "chaincodes": [
            {
              "name": "auditoria-cc",
              "version": "1.0"
            }
          ],
          "name": "peer0.org1.autentia-bchain.com"
        }
      ]
    },
    "G2": {
      "peers": [
        {
          "mspid": "Org3MSP",
          "endpoint": "peer0.org3.autentia-bchain.com:7051",
          "ledger_height": {
            "low": 11,
            "high": 0,
            "unsigned": true
          },
          "chaincodes": [
            {
              "name": "auditoria-cc",
              "version": "1.0"
            }
          ],
          "name": "peer0.org1.autentia-bchain.com"
        }
      ]
    },
    "G3": {
      "peers": [
        {
          "mspid": "Org4MSP",
          "endpoint": "peer0.org4.autentia-bchain.com:7051",
          "ledger_height": {
            "low": 11,
            "high": 0,
            "unsigned": true
          },
          "chaincodes": [
            {
              "name": "auditoria-cc",
              "version": "1.0"
            }
          ],
          "name": "peer0.org1.autentia-bchain.com"
        }
      ]
    }
  },
  "layouts": [
    {
      "G1": 1,
      "G2": 1,
      "G0": 1
    },
    {
      "G3": 1,
      "G0": 1,
      "G1": 1
    },
    {
      "G2": 1,
      "G3": 1,
      "G0": 1
    },
    {
      "G2": 1,
      "G3": 1,
      "G1": 1
    }
  ],
  "plan_id": "{\"chaincodes\":[{\"name\":\"auditoria-cc\"}]}",
  "endorsements": {

  }
}

这是发送提案时的日志

[2019-05-13 12:39:39.894] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _endorse - starting layout plan 0
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _endorse_layout - start
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G2:0 - start
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G2:0 - send endorsement to peer0.org1.autentia-bchain.com
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G3:1 - start
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G3:1 - send endorsement to peer0.org1.autentia-bchain.com
[2019-05-13 12:39:39.895] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:2 - start
[2019-05-13 12:39:39.896] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:2 - send endorsement to peer0.org1.autentia-bchain.com
[2019-05-13 12:39:39.902] [WARN] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:2 - endorsement failed - Error: failed to execute transaction fe2fb28959f06b693e5b834ecfe5fab3aabe8e393f4cc1b2376db7b5aed9f096: error sending: txid: fe2fb28959f06b693e5b834ecfe5fab3aabe8e393f4cc1b2376db7b5aed9f096(auditoria-channel) exists
[2019-05-13 12:39:39.902] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G0:2 - not able to get a completed endorsement
[2019-05-13 12:39:39.902] [WARN] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G3:1 - endorsement failed - Error: failed to execute transaction fe2fb28959f06b693e5b834ecfe5fab3aabe8e393f4cc1b2376db7b5aed9f096: error sending: txid: fe2fb28959f06b693e5b834ecfe5fab3aabe8e393f4cc1b2376db7b5aed9f096(auditoria-channel) exists
[2019-05-13 12:39:39.902] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G3:1 - not able to get a completed endorsement
[2019-05-13 12:39:39.965] [DEBUG] Helper - [DiscoveryEndorsementHandler]: _build_endorse_group_member >> G2:0 - endorsement completed to peer0.org1.autentia-bchain.com - 200

编辑 1: 初始化日志

[2019-05-13 17:31:18.543] [DEBUG] Helper - getClientForOrg - ****** END Org1 test1 


[2019-05-13 17:31:18.544] [DEBUG] invoke-chaincode - Successfully got the fabric client for the organization "Org1"
[2019-05-13 17:31:18.544] [DEBUG] Helper - [NetworkConfig101.js]: getChannel - name auditoria-channel
[2019-05-13 17:31:18.544] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.546] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.546] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.546] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.547] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.547] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.547] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: _addPeersToChannel - peer0.org1.autentia-bchain.com - grpcs://localhost:7051
[2019-05-13 17:31:18.547] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.548] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.548] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org2
[2019-05-13 17:31:18.548] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.548] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org2.autentia-bchain.com
[2019-05-13 17:31:18.549] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.549] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org2
[2019-05-13 17:31:18.549] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.549] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.549] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org2.autentia-bchain.com
[2019-05-13 17:31:18.549] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.549] [DEBUG] Helper - [NetworkConfig101.js]: _addPeersToChannel - peer0.org2.autentia-bchain.com - grpcs://localhost:8051
[2019-05-13 17:31:18.550] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org3.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.553] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.553] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.554] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.554] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.554] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org2
[2019-05-13 17:31:18.555] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org2.autentia-bchain.com
[2019-05-13 17:31:18.555] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org3
[2019-05-13 17:31:18.555] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.555] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org3.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org3.autentia-bchain.com
[2019-05-13 17:31:18.556] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org3
[2019-05-13 17:31:18.556] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org3.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org3.autentia-bchain.com
[2019-05-13 17:31:18.556] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: _addPeersToChannel - peer0.org3.autentia-bchain.com - grpcs://localhost:9051
[2019-05-13 17:31:18.556] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org4.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.557] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-05-13 17:31:18.557] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.557] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org1.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.557] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org1.autentia-bchain.com
[2019-05-13 17:31:18.558] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.558] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org2
[2019-05-13 17:31:18.559] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org2.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org2.autentia-bchain.com
[2019-05-13 17:31:18.559] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org3
[2019-05-13 17:31:18.559] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org3.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.559] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org3.autentia-bchain.com
[2019-05-13 17:31:18.559] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org4
[2019-05-13 17:31:18.560] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org4.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org4.autentia-bchain.com
[2019-05-13 17:31:18.560] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org4
[2019-05-13 17:31:18.560] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getPeer - name peer0.org4.autentia-bchain.com, channel_org: undefined
[2019-05-13 17:31:18.560] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca.org4.autentia-bchain.com
[2019-05-13 17:31:18.560] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-05-13 17:31:18.561] [DEBUG] Helper - [NetworkConfig101.js]: _addPeersToChannel - peer0.org4.autentia-bchain.com - grpcs://localhost:10051
[2019-05-13 17:31:18.561] [DEBUG] Helper - [NetworkConfig101.js]: getOrderer - name orderer.autentia-bchain.com
[2019-05-13 17:31:18.563] [DEBUG] Helper - [DiscoveryEndorsementHandler]: initialize - 

当我执行 channel.getChannelPeers() 时,我得到了一份包含同行的列表,其中包含正确的姓名。

[ ChannelPeer {
    _mspid: 'Org1MSP',
    _channel: 
     Channel {
       _name: 'auditoria-channel',
       _channel_peers: [Object],
       _anchor_peers: [],
       _orderers: [Object],
       _kafka_brokers: [],
       _clientContext: [Object],
       _msp_manager: [Object],
       _discovery_interests: [Object],
       _discovery_results: [Object],
       _last_discover_timestamp: 1557779840912,
       _use_discovery: true,
       _as_localhost: true,
       _endorsement_handler: [Object],
       _commit_handler: [Object],
       _last_refresh_request: [Object] },
    _name: 'peer0.org1.autentia-bchain.com',
    _peer: 
     Peer {
       _options: [Object],
       clientCert: undefined,
       _url: 'grpcs://localhost:7051',
       _endpoint: [Object],
       _name: 'peer0.org1.autentia-bchain.com',
       _request_timeout: 45000,
       _grpc_wait_for_ready_timeout: 3000,
       _endorserClient: [Object],
       _discoveryClient: [Object] },
    _roles: 
     { endorsingPeer: true,
       chaincodeQuery: true,
       ledgerQuery: true,
       eventSource: true } },
  ChannelPeer {
    _mspid: 'Org2MSP',
    _channel: 
     Channel {
       _name: 'auditoria-channel',
       _channel_peers: [Object],
       _anchor_peers: [],
       _orderers: [Object],
       _kafka_brokers: [],
       _clientContext: [Object],
       _msp_manager: [Object],
       _discovery_interests: [Object],
       _discovery_results: [Object],
       _last_discover_timestamp: 1557779840912,
       _use_discovery: true,
       _as_localhost: true,
       _endorsement_handler: [Object],
       _commit_handler: [Object],
       _last_refresh_request: [Object] },
    _name: 'peer0.org2.autentia-bchain.com',
    _peer: 
     Peer {
       _options: [Object],
       clientCert: undefined,
       _url: 'grpcs://localhost:8051',
       _endpoint: [Object],
       _name: 'peer0.org2.autentia-bchain.com',
       _request_timeout: 45000,
       _grpc_wait_for_ready_timeout: 3000,
       _endorserClient: [Object],
       _discoveryClient: [Object] },
    _roles: 
     { endorsingPeer: true,
       chaincodeQuery: true,
       ledgerQuery: true,
       eventSource: true } },
  ChannelPeer {
    _mspid: 'Org3MSP',
    _channel: 
     Channel {
       _name: 'auditoria-channel',
       _channel_peers: [Object],
       _anchor_peers: [],
       _orderers: [Object],
       _kafka_brokers: [],
       _clientContext: [Object],
       _msp_manager: [Object],
       _discovery_interests: [Object],
       _discovery_results: [Object],
       _last_discover_timestamp: 1557779840912,
       _use_discovery: true,
       _as_localhost: true,
       _endorsement_handler: [Object],
       _commit_handler: [Object],
       _last_refresh_request: [Object] },
    _name: 'peer0.org3.autentia-bchain.com',
    _peer: 
     Peer {
       _options: [Object],
       clientCert: undefined,
       _url: 'grpcs://localhost:9051',
       _endpoint: [Object],
       _name: 'peer0.org3.autentia-bchain.com',
       _request_timeout: 45000,
       _grpc_wait_for_ready_timeout: 3000,
       _endorserClient: [Object],
       _discoveryClient: [Object] },
    _roles: 
     { endorsingPeer: true,
       chaincodeQuery: true,
       ledgerQuery: true,
       eventSource: true } },
  ChannelPeer {
    _mspid: 'Org4MSP',
    _channel: 
     Channel {
       _name: 'auditoria-channel',
       _channel_peers: [Object],
       _anchor_peers: [],
       _orderers: [Object],
       _kafka_brokers: [],
       _clientContext: [Object],
       _msp_manager: [Object],
       _discovery_interests: [Object],
       _discovery_results: [Object],
       _last_discover_timestamp: 1557779840912,
       _use_discovery: true,
       _as_localhost: true,
       _endorsement_handler: [Object],
       _commit_handler: [Object],
       _last_refresh_request: [Object] },
    _name: 'peer0.org4.autentia-bchain.com',
    _peer: 
     Peer {
       _options: [Object],
       clientCert: undefined,
       _url: 'grpcs://localhost:10051',
       _endpoint: [Object],
       _name: 'peer0.org4.autentia-bchain.com',
       _request_timeout: 45000,
       _grpc_wait_for_ready_timeout: 3000,
       _endorserClient: [Object],
       _discoveryClient: [Object] },
    _roles: 

我们能看到通道初始化时的调试日志吗?查看从 Peer 的 Discovery Service 中读取的 Discovery 结果会很有帮助。背书计划中看到的 Peer 的名称不是来自 Discovery Service,这是 NodeSDK 分配的名称,这些名称应该是唯一的并且包含主机和端口。由于它们不是唯一的,因此确实使用了同一个 Peer。

当 NodeSDK 应用程序是 运行 第一级并且在本地虚拟环境中使用 fabric 网络时,对等地址被视为 "localhost",虚拟环境中的端口地址必须也是独一无二的。在 docker-compose 将虚拟端口映射到真实端口时,使用相同的地址是最简单的。请注意,在以下示例中,定义虚拟环境的端口地址与主机映射相同。

    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer0.org2.example.com
      - CORE_PEER_ADDRESS=peer0.org2.example.com:8051
      - CORE_PEER_LISTENADDRESS=peer0.org2.example.com:8051
      - CORE_PEER_GOSSIP_ENDPOINT=peer0.org2.example.com:8051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:8051
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/peerOrg2/msp
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:8051

    ports:
      - 8051:8051

请记住,主机名也必须从虚拟名称映射到 "localhost",这是通过在初始化通道时使用连接选项 "aslocalhost:true" 完成的。

await channel.initialize({discover:true, asLocalhost:true})

希望以下内容对您有所帮助

https://fabric-sdk-node.github.io/release-1.4/tutorial-discovery.html