1

My fabric network is deployed in a local Kubernetes cluster(vagrant) using the following https://medium.com/swlh/how-to-implement-hyperledger-fabric-external-chaincodes-within-a-kubernetes-cluster-fd01d7544523 tutorial. The pods are up and running, and I was able to insert/read marbles from fabric-cli.

I was not able to configure caliper to measure the performance of my deployment. I ran the caliper 0.4.2 docker image in the same 'hyperledger' namespace.

the caliper deployment yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: caliper
  name: caliper
  namespace: hyperledger
spec:
  selector:
    matchLabels:
      app: caliper
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: caliper
    spec:
      containers:
        - env:
            - name: CALIPER_BIND_SUT
              value: fabric:2.2
            - name: CALIPER_BENCHCONFIG
              value: benchmarks/myAssetBenchmark.yaml
            - name: CALIPER_NETWORKCONFIG
              value: networks/networkConfig3.yaml
            - name: CALIPER_FABRIC_GATEWAY_ENABLED
              value: "true"
            - name: CALIPER_FLOW_ONLY_TEST
              value: "true"
          image: hyperledger/caliper:0.4.2
          name: caliper
          command:
            - caliper
          args:
            - launch
            - manager
          tty: true
          volumeMounts:
            - mountPath: /hyperledger/caliper/workspace
              name: caliper-workspace
            - mountPath: /hyperledger/caliper/fabric-samples
              name: fabric-workspace
          workingDir: /hyperledger/caliper/workspace
      restartPolicy: Always
      volumes:
        - name: caliper-workspace
          hostPath:
            path: /home/vagrant/caliper-workspace
            type: Directory
        - name: fabric-workspace
          hostPath:
            path: /home/vagrant/fabr          volumeMounts:
            - mountPath: /hyperledger/caliper/workspace
              name: caliper-workspace
            - mountPath: /hyperledger/caliper/fabric-samples
              name: fabric-workspace
          workingDir: /hyperledger/caliper/workspace
      restartPolicy: Always
      volumes:
        - name: caliper-workspace
          hostPath:
            path: /home/vagrant/caliper-workspace
            type: Directory
        - name: fabric-workspace
          hostPath:
            path: /home/vagrant/fabric-external-chaincodes/
            type: Directoryic-external-chaincodes/
            type: Directory

I followed https://hyperledger.github.io/caliper/v0.4.2/fabric-tutorial/tutorials-fabric-existing/ documentation on running caliper alongside existing fabric network. the networkconfig3.yaml file

name: Fabric
version: '2.0.0'
mutual-tls: true

caliper:
  blockchain: fabric
  sutOptions:
    mutualTls: true 

channels:
  - channelName: mychannel
    contracts:
    - id: marbles

organizations:
  - mspid: org1MSP
    identities:
      certificates:
      - name: 'Admin'
        admin: true
        clientPrivateKey:
          path: '../fabric-samples/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/keystore/priv_sk'
        clientSignedCert:
          path: '../fabric-samples/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/signcerts/Admin@org1-cert.pem'
      - name: 'User1'
        clientPrivateKey:
          path: '../fabric-samples/crypto-config/peerOrganizations/org1/users/User1@org1/msp/keystore/priv_sk'
        clientSignedCert:
          path: '../fabric-samples/crypto-config/peerOrganizations/org1/users/User1@org1/msp/signcerts/User1@org1-cert.pem'
    connectionProfile:
      path: 'networks/profile-org1.yaml'
      discover: true

the org1 connection profile will look like

name: Fabric
version: '1.0.0'

client:
  organization: org1
  connection:
    timeout:
      peer:
        endorser: '300'

organizations:
  org1:
    mspid: org1MSP
    peers:
    - peer0-org1

peers:
  peer0-org1:
    url: grpcs://peer0-org1:7051
    grpcOptions:
      ssl-target-name-override: peer0-org1
      grpc.keepalive_time_ms: 600000
    tlsCACerts:
      path: ../fabric-samples/crypto-config/peerOrganizations/org1/peers/peer0-org1/msp/tlscacerts/tlsca.org1-cert.pem

the myAssetBenchmark.yaml file

test:
    name: marble-benchmark
    description: test benchmark
    workers:
      type: local
      number: 2
    rounds:
    - label: initMarble
      description: init marbles benchmark
      txNumber: 100
      rateControl:
        type: fixed-load
        opts:
          tps: 25
      workload:
        module: workload/init.js
monitor:
  type:
  - none

observer:
  type: local
  interval: 1

The caliper is failing because the connection to the peers is not going through. 2021-01-05T04:37:55.592Z - ^[[32minfo^[[39m: [NetworkConfig]: buildPeer - Unable to connect to the endorser peer0-org1 due to Error: Failed to connect before the deadline on Endorser- name: peer0-org1, url:grpcs://peer0-org1:7051, connected:false, connectAttempted:true

some more error logs

2021-01-04T01:08:35.466Z - error: [DiscoveryService]: send[mychannel] - no discovery results
2021-01-04T01:08:38.473Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Discoverer- name: peer0-org1, url:grpcs://peer0-org1:7051, connected:false, connectAttempted:true
2021-01-04T01:08:38.473Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0-org1 url:grpcs://peer0-org1:7051 timeout:3000
2021-01-04T01:08:38.473Z - error: [ServiceEndpoint]: ServiceEndpoint grpcs://peer0-org1:7051 reset connection failed :: Error: Failed to connect before the deadline on Discoverer- name: peer0-org1, url:grpcs://peer0-org1:7051, connected:false, connectAttempted:true

What are the issues with my current configuration? Is there any blog or documentation to look more?

  • First thing to check, are you definitely using mutual tls ? If you are then you haven't specified that correctly in your network-config definition (also I don't there is a mutual-tls option available in a connection profile either). See https://hyperledger.github.io/caliper/v0.4.2/fabric-config/new/#network-configuration-file-reference for more info about how to specify mutual tls. – david_k Jan 04 '21 at 09:28
  • The error remains unchanged even after correctly specified mutual TLS. Updated the question with correct TLS config. Thank you for the documentation @david_k. Is there any reference on writing connection profile for organization? – Arun Joseph Jan 05 '21 at 04:49

1 Answers1

0

Your connection profile doesn't look correct as you haven't specified the tlsCACert information correctly. As you need to use a connection profile that works with node 2.2 the following might work

name: Fabric

organizations:
  org1:
    mspid: org1MSP
    peers:
    - peer0-org1

peers:
  peer0-org1:
    url: grpcs://peer0-org1:7051
    tlsCACerts:
      path: ../fabric-samples/crypto-config/peerOrganizations/org1/peers/peer0-org1/msp/tlscacerts/tlsca.org1-cert.pem

there are some details here about the node sdk 2.2 expected format for the connection profile but I'm not sure how correct they are https://hyperledger.github.io/fabric-sdk-node/release-2.2/tutorial-commonconnectionprofile.html

david_k
  • 5,843
  • 2
  • 9
  • 16
  • This is not the case. the 'tlsCACerts:' was there with the actual file it got deleted when I copied. Updated the question. – Arun Joseph Jan 05 '21 at 09:47
  • The error you posted refers to org2 so I would check your org2 connection profile. Try only using a single organisation in your network configuration (ie remove org2) unless your workloads specifically codes to using multiple orgs, caliper will only drive the results from a single organisation. – david_k Jan 05 '21 at 11:11
  • I tried after removing org2. Exact same error is coming. – Arun Joseph Jan 05 '21 at 11:57
  • Personally I would avoid using mutual tls, but in any case the problem is likely to be with your connection profile and perhaps your networking setup in order for caliper to be able to communicate with your fabric. You may want to write a simple sdk client application to test your connection profiles first. caliper utilises the capabilities node-sdk to handle the connection profiles and establish the connections – david_k Jan 05 '21 at 12:05
  • You're right the issue was with the connection profile. It got fixed and stated working after I added the certification authorities to the org1 profile. https://github.com/hyperledger/caliper/blob/v0.4.2/packages/caliper-fabric/test/sample-configs/Org1ConnectionProfile.yaml having an example configuration. I added certificateAuthorities as shown there. Thanks @david for the help. – Arun Joseph Jan 06 '21 at 11:20
  • Ah right, so node sdk 1.4 connection profiles allow for certificate authorities, but in node sdk 2.2 they don't use that information anymore. Caliper still supports 1.4, but also there was a feature in the new caliper fabric connectors that is currently not implemented to allow for auto-register and enrolling for which in a 1.4 environment the information could come from a connection profile. So for the test examples the information is there in readiness for that (if it's decided it's a good feature to add). The best place to learn about connection profiles though would be the fabric docs – david_k Jan 06 '21 at 12:05