超账结构发现服务认可失败

时间:2019-05-13 16:58:12

标签: hyperledger-fabric service-discovery hyperledger-fabric-sdk-js

大家好,我正在尝试通过Node 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: 

2 个答案:

答案 0 :(得分:0)

我们能否看到有关通道初始化时间的调试日志。查看从对等发现服务读取的发现结果将很有帮助。认可计划中显示的对等方名称不是来自发现服务,这是由NodeSDK分配的名称,这些名称应该是唯一的,并且包含主机和端口。由于它们不是唯一的,因此确实使用了相同的Peer。

答案 1 :(得分:0)

当NodeSDK应用程序正在运行并且在本地虚拟环境中(其中对等地址被视为“ 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