2

I want to use Hyperledger Caliper to test my chaincode but encountered some problems. The hyperledger fabric network is start by the byfn.sh up command.

I use the command npx caliper benchmark run --caliper-workspace . --caliper-benchconfig benchmarks/benchmark.yaml --caliper-networkconfig benchmarks/network.yaml to run the benchmark. The error log is as follows:

Benchmark for target Blockchain type fabric about to start
2020.01.09-23:49:05.146 info  [caliper] [benchmark-validator]   No observer specified, will default to `none`
2020.01.09-23:49:05.147 info  [caliper] [caliper-flow]  ####### Caliper Test #######
2020.01.09-23:49:05.151 info  [caliper] [null-observer]         Configured observer
2020.01.09-23:49:05.154 info  [caliper] [adapters/fabric]       Fabric SDK version: 1.4.3; TLS: server
2020.01.09-23:49:05.155 warn  [caliper] [adapters/fabric]       Org1's registrar information not provided.
2020.01.09-23:49:05.155 warn  [caliper] [adapters/fabric]       Org2's registrar information not provided.
2020.01.09-23:49:05.385 warn  [caliper] [adapters/fabric]       Org1's admin's materials found locally in file system key-value stores. Make sure it is the right one!
2020.01.09-23:49:05.395 warn  [caliper] [adapters/fabric]       Org2's admin's materials found locally in file system key-value stores. Make sure it is the right one!
2020.01.09-23:49:05.411 warn  [caliper] [adapters/fabric]       client0.org1.example.com's materials found locally in file system key-value stores. Make sure it is the right one!
2020.01.09-23:49:05.421 warn  [caliper] [adapters/fabric]       client0.org2.example.com's materials found locally in file system key-value stores. Make sure it is the right one!
2020.01.09-23:49:05.422 info  [caliper] [adapters/fabric]       Channel 'mychannel' is configured as created, skipping creation
2020.01.09-23:49:05.463 info  [caliper] [adapters/fabric]       peer0.org1.example.com has already joined mychannel
2020.01.09-23:49:05.480 info  [caliper] [adapters/fabric]       peer0.org2.example.com has already joined mychannel
2020.01.09-23:49:05.482 info  [caliper] [adapters/fabric]       Installing chaincodes for mychannel...
2020.01.09-23:49:05.491 info  [caliper] [adapters/fabric]       automaster_route@1.0 is already installed on peer0.org1.example.com
2020.01.09-23:49:05.498 info  [caliper] [adapters/fabric]       automaster_route@1.0 is already installed on peer0.org2.example.com
2020.01.09-23:49:05.508 info  [caliper] [adapters/fabric]       exp0@1.0 is already installed on peer0.org1.example.com
2020.01.09-23:49:05.515 info  [caliper] [adapters/fabric]       exp0@1.0 is already installed on peer0.org2.example.com
2020.01.09-23:49:05.526 info  [caliper] [adapters/fabric]       exp1@1.0 is already installed on peer0.org1.example.com
2020.01.09-23:49:05.533 info  [caliper] [adapters/fabric]       exp1@1.0 is already installed on peer0.org2.example.com
2020.01.09-23:49:05.534 info  [caliper] [adapters/fabric]       Instantiating automaster_route@1.0 in mychannel. This might take some time...
2020.01.09-23:49:05.543 info  [caliper] [adapters/fabric]       automaster_route@1.0 is already instantiated in mychannel
2020.01.09-23:49:05.544 info  [caliper] [adapters/fabric]       Instantiating exp0@1.0 in mychannel. This might take some time...
2020.01.09-23:49:05.554 info  [caliper] [adapters/fabric]       exp0@1.0 is already instantiated in mychannel
2020.01.09-23:49:05.554 info  [caliper] [adapters/fabric]       Instantiating exp1@1.0 in mychannel. This might take some time...
2020.01.09-23:49:05.564 info  [caliper] [adapters/fabric]       exp1@1.0 is already instantiated in mychannel
2020.01.09-23:49:07.566 info  [caliper] [caliper-flow]  Started monitors successfully
2020.01.09-23:49:07.567 info  [caliper] [defaultTest]   ####### Testing 'upload' #######
2020.01.09-23:49:07.568 info  [caliper] [defaultTest]   ------ Test round 1 ------
2020.01.09-23:49:07.582 info  [caliper] [client.js]     Launching client with PID 
2020.01.09-23:49:07.583 info  [caliper] [client.js]     Waiting for 1 clients to be ready... 
2020.01.09-23:49:09.482 info  [caliper] [client.js]     Client ready message received
2020.01.09-23:49:09.481 info  [caliper] [fabric/fabricClientWorker]     Client ready
2020.01.09-23:49:09.482 info  [caliper] [client.js]     1 clients ready, starting test phase
2020.01.09-23:49:09.484 info  [caliper] [local-client.js]       txUpdateTime: 1000
2020.01.09-23:49:09.626 info  [caliper] [local-client.js]       Info: client 2183 init test :invoke
2020.01.09-23:49:10.627 info  [caliper] [local-client.js]       Info: client 2183 start test runFixedNumber():invoke
2020.01.09-23:49:10.650 error [caliper] [adapters/fabric]       Transaction[4751ea2b2c] life-cycle errors:
        - Proposal response error by peer0.org1.example.com: 2 UNKNOWN: access denied: channel [mychannel] creator org [Org1MSP]
        - Proposal response error by peer0.org2.example.com: 2 UNKNOWN: access denied: channel [mychannel] creator org [Org1MSP]

I thought it may be the problem with tls or the crypto materials, but i checked the crypto materials' path found nothing, below is my network.yaml:

name: Fabric
version: "1.0"
mutual-tls: false

caliper:
  blockchain: fabric
  # command:
  #   start: ./byfn.sh up && docker exec cli bash ./scripts/setup4peers.sh && docker exec cli bash ./scripts/joinuser4peers.sh "user1"
  #   end: docker kill $(docker ps -q) && ./byfn.sh down

info:
  Version: 1.4.3
  Size: 2 Orgs with 1 Peer
  Orderer: Solo
  Distribution: Single Host
  StateDB: GoLevelDB

clients:
  client0.org1.example.com:
    client:
      organization: Org1
      credentialStore:
        path: /tmp/hfc-kvs/org1
        cryptoStore:
          path: /tmp/hfc-cvs/org1
      clientPrivateKey:
        path: crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/04650a709ab38a8024c6168344688e1b16a29a7b4d435bc864628ac2afc251bb_sk
      clientSignedCert:
        path: crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem

  client0.org2.example.com:
    client:
      organization: Org2
      credentialStore:
        path: /tmp/hfc-kvs/org2
        cryptoStore:
          path: /tmp/hfc-cvs/org2
      clientPrivateKey:
        path: crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/2190942bdaa028b7e21802e6aa210add753b466210fcac136374fb0b37d24307_sk
      clientSignedCert:
        path: crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem


channels:
  mychannel:
    configBinary: ../channel-artifacts/channel.tx
    created: true
    orderers:
    - orderer.example.com
    peers:
      peer0.org1.example.com:
        eventSource: true
      # peer1.org1.example.com:
      #   eventSource: true      
      peer0.org2.example.com:
        eventSource: true
      # peer1.org2.example.com:
      #   eventSource: true
    chaincodes:
    - id: automaster_route
      version: "1.0"
      language: java
      path: ../chaincode/master-liuqi/java
      # created: true

    - id: exp0
      version: "1.0"
      language: java
      path: ../chaincode/exp
      # created: true

    - id: exp1
      version: "1.0"
      language: java
      path: ../chaincode/exp
      # created: true

organizations:
  Org1:
    mspid: Org1MSP
    peers:
    - peer0.org1.example.com
    # certificateAuthorities:
    # - ca.org1.example.com
    adminPrivateKey:
      path: crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/67bdf39a46463e67fa8d317fe181c4c32ea371e1d4d40175a78c6ed6137410b5_sk
    signedCert:
      path: crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem

  Org2:
    mspid: Org2MSP
    peers:
    - peer0.org2.example.com
    # certificateAuthorities:
    # - ca.org2.example.com
    adminPrivateKey:
      path: crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/43432725a9c2b277991c413607326bf2f68932cd99a980183e2487926341583a_sk
    signedCert:
      path: crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem

orderers:
  orderer.example.com:
    url: grpcs://localhost:7050
    grpcOptions:
      ssl-target-name-override: orderer.example.com
    tlsCACerts:
      path: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
      # crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peers:
  peer0.org1.example.com:
    url: grpcs://localhost:7051
    grpcOptions:
      ssl-target-name-override: peer0.org1.example.com
      grpc.keepalive_time_ms: 600000
    tlsCACerts:
      path: crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem
      # crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem


  peer0.org2.example.com:
    url: grpcs://localhost:9051
    grpcOptions:
      ssl-target-name-override: peer0.org2.example.com
      grpc.keepalive_time_ms: 600000
    tlsCACerts:
      path: crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/tlscacerts/tlsca.org2.example.com-cert.pem
      # crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/tlscacerts/tlsca.org2.example.com-cert.pem


  # peer1.org1.example.com:
  #   url: grpc://localhost:8051
  #   grpcOptions:
  #     ssl-target-name-override: peer1.org1.example.com
  #     grpc.keepalive_time_ms: 600000

  # peer1.org2.example.com:
  #   url: grpc://localhost:10051
  #   grpcOptions:
  #     ssl-target-name-override: peer1.org2.example.com
  #     grpc.keepalive_time_ms: 600000

Is there anyone know how to solve this problem?

liuqi
  • 131
  • 1
  • 8
  • more details can be found in [github issue 702](https://github.com/hyperledger/caliper/issues/702) – liuqi Jan 12 '20 at 01:42

1 Answers1

0

If you use caliper-benchmarks, then the problem is from fabric.js in node_modules/@hyperledger/caliper-fabric/lib. you should open that file and change the line 760 (async_initializeChannel) into this:

async _initializeChannel(profiles, channel) {
    // initialize the channel for every client profile from the local config
    for (let profile of profiles.entries()) {
        let orgs = this.networkUtil.getOrganizationsOfChannel(channel);
        for (let org of orgs) {
            if (profile[0]===org){
                let ch = profile[1].getChannel(channel, true);
                if (ch) {
                    try {
                        await ch.initialize();
                    } catch (err) {
                        logger.error(`Couldn't initialize ${channel} for ${profile[0]}: ${err.message}`);
                        throw err;
                    }
                }
            }
        }
    }
}

if it is not from there, there are two other probabilities: from your network.yaml (1) or your expo chaincode benchmark java file configuration (2).

(1) usually, if there are more than two orgs, its easier to make affiliation org just from client configuration in this file. Just remove the clientPrivateKey and clientSignedCert and add affiliation. for example:

client0.org1.example.com:
    client:
        organization: Org1
        affiliation: org1.department1
        credentialStore:
            path: /tmp/hfc-kvs/org1
            cryptoStore:
                path: /tmp/hfc-cvs/org1

(2) from your chaincode benchmark java file configuration, you should add your invokerIdentity

the other two problems actually are already given in hyperledger caliper website on fabric configuration

Narendranath Reddy
  • 3,833
  • 3
  • 13
  • 32