hyperledger / caliper

A blockchain benchmark framework to measure performance of multiple blockchain solutions https://wiki.hyperledger.org/display/caliper
https://hyperledger.github.io/caliper/
Apache License 2.0
650 stars 402 forks source link

hyperledger caliper with etcdraft #442

Closed devkatcybersecurity closed 5 years ago

devkatcybersecurity commented 5 years ago

My hyperledger fabric network is deployed on a private network on 4 servers. Each server has one peer and one orderer. The network is up and running and i want to do benchmarking with hyperledger caliper on the running network. TLS is enabled in the network, and i have given absolute path everywhere.

Context

I changed the urls with the url of servers in both benchmark and network configuration file of caliper. I don't want to create any channel or enroll any admin or install chaincode because i've already done all of that steps. How does one do benchmarking from here ?

Expected Behavior

Should just run benchmark without creating channel, installing chaincode and enrolling admin...

Actual Behavior

 error: [FabricCAClientService.js]: Failed to enroll admin, error:%o message=Enrollment failed with errors [[{"code":19,"message":"CA 'ca.org0.example.com' does not exist"}]], stack=Error: Enrollment failed with errors [[{"code":19,"message":"CA 'ca.org0.example.com' does not exist"}]]

Possible Fix

Steps to Reproduce

1.My config.yaml file is as follows :

---
test:
  name: drm
  description: Benchmark for DRM scenario
  clients:
    type: local
    number: 1
  rounds:
  - label: publish
    txNumber:
    - 10
    arguments:
      itemBytes: 2048000
    rateControl:
    - type: fixed-rate
      opts:
        tps: 1
    callback: benchmark/drm/publish.js
  - label: query
    txNumber:
    - 10
    rateControl:
    - type: fixed-rate
      opts:
        tps: 1
    callback: benchmark/drm/query.js
monitor:
  type: docker
  docker:
    name:
    - http://172.28.27.54:7053/peer0.org0.example.com
    - http://172.24.144.39:7053/peer0.org1.example.com
    - http://172.27.27.175:7053/peer0.org2.example.com
    - http://172.27.28.58:7053/peer0.org3.example.com
    - http://172.28.27.54:7050/orderer0.example.com
    - http://172.24.144.39:7050/orderer1.example.com
    - http://172.27.27.175:7050/orderer2.example.com
    - http://172.27.28.58:7050/orderer3.example.com
  interval: 1
  1. My fabric-go-tls.json is as follows :
    
    {
    "caliper": {
    "blockchain": "fabric",
    "command" : {
      "start": "echo 'start' ",
      "end" : "echo 'stop'"
    }
    },
    "fabric": {
    "cryptodir": "/home/devk/hl-demo/artifacts/crypto-config",
    "network": {
      "orderer": {
        "url": "grpcs://172.28.57.54:7050",
        "mspid": "ordererMSP",
        "msp": "/home/devk/hl-demo/artifacts/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/",
        "server-hostname": "orderer.example.com",
        "tls_cacerts": "/home/devk/hl-demo/artifacts/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
      },
      "org0": {
        "name": "org0",
        "mspid": "org0MSP",
        "msp": "/home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/msp/",
        "ca": {
          "url": "https://172.28.57.54:7054",
          "name": "ca.org0.example.com"
        },
        "peer1": {
          "requests": "grpcs://172.28.57.54:7051",
          "events": "grpcs://172.28.57.54:7053",
          "server-hostname": "peer0.org0.example.com",
          "tls_cacerts": "/home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/peers/peer0.org0.example.com/tls/ca.crt"
        }
      },
      "org1": {
        "name": "org2",
        "mspid": "org2MSP",
        "msp": "/home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org1.example.com/msp/",
        "ca": {
          "url": "https://172.24.144.39:7054",
          "name": "ca.org1.example.com"
        },
        "peer1": {
          "requests": "grpcs://172.24.144.39:7051",
          "events": "grpcs://172.24.144.39:7053",
          "server-hostname": "peer0.org1.example.com",
          "tls_cacerts": "/home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
        }
      },
      "org2": {
        "name": "org2",
        "mspid": "org2MSP",
        "msp": "/home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org2.example.com/msp/",
        "ca": {
          "url": "https://172.27.27.175:7054",
          "name": "ca.org2.example.com"
        },
        "peer1": {
          "requests": "grpcs://172.27.27.175:7051",
          "events": "grpcs://172.27.27.175:7053",
          "server-hostname": "peer0.org2.example.com",
          "tls_cacerts": "/home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
        }
      },
    "org3": {
        "name": "org3",
        "mspid": "org3MSP",
        "msp": "/home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org3.example.com/msp/",
        "ca": {
          "url": "https://172.27.28.58:7054",
          "name": "ca.org3.example.com"
        },
        "peer1": {
          "requests": "grpcs://172.27.28.58:7051",
          "events": "grpcs://172.27.28.58:7053",
          "server-hostname": "peer0.org3.example.com",
          "tls_cacerts": "/home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt"
        }
      }
    },
    "channel": [
      {
        "name": "common",
        "deployed": false,
        "config": "/home/devk/hl-demo/artifacts/channel/common.tx",
        "organizations": ["org0", "org1", "org2", "org3"]
      }
    ],
    "chaincodes": [
      {"id": "drm", "path": "contract/fabric/drm", "language":"golang", "version": "v0", "channel": "common"}
    ],
    "endorsement-policy": {
      "identities": [
        {
          "role": {
            "name": "admin",
            "mspId": "org0MSP"
          }
        },
        {
          "role": {
            "name": "member",
            "mspId": "org2MSP"
          }
        },
        {
          "role": {
            "name": "member",
            "mspId": "org2MSP"
          }
        },
        {
          "role": {
            "name": "member",
            "mspId": "org3MSP"
          }
        }
      ],
      "policy": { "4-of": [{"signed-by": 0}, {"signed-by": 1}, {"signed-by": 2}, {"signed-by": 3}]}
    },
    "context": {
      "query": "common"
    }
    },
    "info" : {
    "Version": "1.4.1",
    "Size": "4 Orgs with 1 Peer",
    "Orderer": "etcdraft",
    "Distribution": "Single Host"
    }
    }

3.
4.
Any help would be really appreciated
@bramwelt @huikang @ryjones @pono @tykeal 
aklenik commented 5 years ago

@devendra491 I suggest using the Fabric-CCP adapter for multi-orderer networks. Then set the created attribute to true in the channel section of the config. The chaincode deploy and channel joining info will be queried and not performed again is not needed.

Then you just add your node (orderer/peer/ca) sections to the config file with the correct endpoint addresses.

ttaishiteru commented 5 years ago

https://stackoverflow.com/questions/44905444/when-trying-to-issue-an-identity-it-says-my-ca-does-not-exist The same question.

aklenik commented 5 years ago

@ttaishiteru I'm not sure how that SO question is related to this issue. Could you elaborate? @devendra491 Did you manage to get it working?

devkatcybersecurity commented 5 years ago

@aklenik I'm not still able to benchmark it with caliper yet. However, I managed to run network benchmarks with PTE ( from fabric test tools ). But fabric test tools don't have that much support for analyzing results of PTE using graphs. I want to benchmark my network with caliper but I'm not able to configure the files properly, I'd really appreciate if you could tell me the mistakes in my configuration file so that i can correct them.

aklenik commented 5 years ago

@devendra491 I've just finished putting together a Kafka-based Fabric example. I'll put together a Raft-based example today. In the meantime, you can start playing around with the Kafka network (it's also multi-orderer, Caliper doesn't really care what consensus they run).

About skipping channel creation, check out the new runtime config features of Caliper and the Fabric CCP adapter: https://hyperledger.github.io/caliper/docs/Fabric_Ccp_Configuration.html#configuring-the-adapter

devkatcybersecurity commented 5 years ago

@aklenik thanks for the help. I'll be waiting for the raft example with caliper. Also, you never told me how to skip enrollment of admin in the network which is the actual error in the issue?

aklenik commented 5 years ago

@devendra491 ah, sorry. Now I understand the link of @ttaishiteru. You need to make sure that the CA name in your Caliper network settings matches the CA name set for the CA server (in the Docker compose file, for example).

But if you don't use the CAs during the Caliper init phase (like enrolling users dynamically), then you can remove them from the network and its config)

devkatcybersecurity commented 5 years ago

I've removed the ca from the configuration file but now it's forcing me to install the chaincode. If i don't mention the path and just give it the id of chaincode already installed on my channel then it gives an error of ' Error: Util.resolvePath: Parameter is undefined' . Is there any way to use my already installed chaincode on the deployed network for the benchmarking ? @aklenik

aklenik commented 5 years ago

@devendra491 Are you still using the old Fabric adapter? If yes, then switch to the CCP adapter, it handles these things automatically. Read through the docs for the available settings and features: https://hyperledger.github.io/caliper/docs/Fabric_Ccp_Configuration.html

devkatcybersecurity commented 5 years ago

No, i think i am using the correct adapter following is my configuration file :

name: Fabric
version: "1.0"

mutual-tls: false

caliper:
  blockchain: fabric-ccp
  command:
    start: echo 'start'
    end: echo 'end'

info:
  Version: 1.4.1
  Size: 4 Orgs with 1 Peer each 
  Orderer: raft
  Distribution: Multi Host
  StateDB: GoLevelDB

clients:
  client0.org0.example.com:
    client:
      organization: org0
      credentialStore:
        path: "/tmp/hfc-kvs/org0"
        cryptoStore:
          path: "/tmp/hfc-cvs/org0"
      clientPrivateKey:
        path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/users/User1@org0.example.com/msp/keystore/server.key
      clientSignedCert:
        path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/users/User1@org0.example.com/msp/signcerts/User1@org0.example.com-cert.pem

channels:
  common:
    configBinary: /home/devk/hl-demo/artifacts/channel/common.tx
    created: true 
    orderers:
    - orderer0.example.com
    peers:
      peer0.org0.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true

    chaincodes:
    - id: reference 
      version: v1.0
      targetPeers:
      - peer0.org0.example.com

organizations:
  org0:
    mspid: org0MSP
    peers:
    - peer0.org0.example.com
    #- peer1.org1.example.com
 #   certificateAuthorities:
    #- ca.org0.example.com
    adminPrivateKey:
      path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/users/Admin@org0.example.com/msp/keystore/server.key
    signedCert:
      path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/users/Admin@org0.example.com/msp/signcerts/Admin@org0.example.com-cert.pem

orderers:
  orderer0.example.com:
    url: grpcs://localhost:7050
    grpcOptions:
      ssl-target-name-override: orderer0.example.com
      grpc-max-send-message-length: 15
    tlsCACerts:
      path: /home/devk/hl-demo/artifacts/crypto-config/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem

peers:
  peer0.org0.example.com:
    url: grpcs://localhost:7051
    grpcOptions:
      ssl-target-name-override: peer0.org0.example.com
      grpc.keepalive_time_ms: 600000
    tlsCACerts:
      path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/peers/peer0.org0.example.com/msp/tlscacerts/tlsca.org0.example.com-cert.pem
aklenik commented 5 years ago

@devendra491 In that case, could you share the error logs, please? Maybe there's an unnecessary check that expects the chaincode path to be set.

devkatcybersecurity commented 5 years ago

@aklenik Following are the logs :

2019-05-29T10:54:52+05:30 - INFO [scripts/run.js]: Benchmark for target Blockchain type fabric-ccp about to start 

2019-05-29T10:54:52+05:30 - INFO [caliper-flow]: ####### Caliper Test ####### 

2019-05-29T10:54:52+05:30 - INFO [caliper-flow]: Executing command: cd /home/devk/Healthsector/caliper/packages/caliper-application/;echo 'start' 

2019-05-29T10:54:52+05:30 - INFO [adapters/fabric-ccp]: Fabric SDK version: 1.4.1; TLS: mutual 

2019-05-29T10:54:52+05:30 - WARN [adapters/fabric-ccp]: org0's registrar information not provided. 

2019-05-29T10:54:52+05:30 - WARN [adapters/fabric-ccp]: org0's admin's materials found locally. Make sure it is the right one! 

2019-05-29T10:54:52+05:30 - WARN [adapters/fabric-ccp]: client0.org0.example.com's materials found locally. Make sure it is the right one! 

2019-05-29T10:54:52+05:30 - INFO [adapters/fabric-ccp]: Channel 'common' is configured as created, skipping creation 

2019-05-29T10:54:52+05:30 - INFO [adapters/fabric-ccp]: peer0.org0.example.com has already joined common 

2019-05-29T10:54:52+05:30 - INFO [adapters/fabric-ccp]: Installing chaincodes for common... 

2019-05-29T10:54:52+05:30 - ERROR [caliper-flow]: Error: Error: Couldn't install reference@v1.0 on peers peer0.org0.example.com: Missing "chaincodePath" parameter in the proposal request
    at Fabric._installChaincodes (/home/devk/Healthsector/caliper/packages/caliper-fabric-ccp/lib/fabric.js:1029:31)
    at <anonymous> 

2019-05-29T10:54:52+05:30 - INFO [demo.js]: [Transaction Info] - Submitted: 0 Succ: 0 Fail:0 Unfinished:0 

2019-05-29T10:54:52+05:30 - INFO [caliper-flow]: Executing command: cd /home/devk/Healthsector/caliper/packages/caliper-application/;echo 'end' 

These are the logs generated when i don't give a path to chaincode. The reason I don't want to provide a path is that my chaincode is already installed and instantiated

devkatcybersecurity commented 5 years ago

@aklenik somehow that error has stopped showing. Now I am using the following configuration file :

name: Fabric
version: "1.0"

mutual-tls: true

caliper:
  blockchain: fabric-ccp
  command:
    start: echo 'start'
    end: echo 'end'

info:
  Version: 1.4.1
  Size: 4 Orgs with 1 Peer each 
  Orderer: raft
  Distribution: Multi Host
  StateDB: GoLevelDB

clients:
  client0.org0.example.com:
    client:
      organization: org0
      credentialStore:
        path: "/tmp/hfc-kvs/org0"
        cryptoStore:
          path: "/tmp/hfc-cvs/org0"
      clientPrivateKey:
        path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/users/User1@org0.example.com/msp/keystore/server.key
      clientSignedCert:
        path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/users/User1@org0.example.com/msp/signcerts/User1@org0.example.com-cert.pem

channels:
  common:
    created: true 
    orderers:
    - orderer0.example.com
    peers:
      peer0.org0.example.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true

    chaincodes:
    - id: relationship 
      version: v1.0
      language: golang
      targetPeers:
      - peer0.org0.example.com

organizations:
  org0:
    mspid: org0MSP
    peers:
    - peer0.org0.example.com
    certificateAuthorities:
    - ca.org0.example.com
    adminPrivateKey:
      path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/users/Admin@org0.example.com/msp/keystore/server.key
    signedCert:
      path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/users/Admin@org0.example.com/msp/signcerts/Admin@org0.example.com-cert.pem

orderers:
  orderer0.example.com:
    url: grpcs://localhost:7050
    grpcOptions:
      ssl-target-name-override: orderer0.example.com
      grpc-max-send-message-length: 15
    tlsCACerts:
      path: /home/devk/hl-demo/artifacts/crypto-config/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem

peers:
  peer0.org0.example.com:
    url: grpcs://localhost:7051
    grpcOptions:
      ssl-target-name-override: peer0.org0.example.com
      grpc.keepalive_time_ms: 600000
    tlsCACerts:
      path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/peers/peer0.org0.example.com/msp/tlscacerts/tlsca.org0.example.com-cert.pem
      #path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/peers/peer0.org0.example.com/tls/ca.crt 

certificateAuthorities:
  ca.org0.example.com:
    url: https://localhost:7054
    tlsCACerts:
     path: /home/devk/hl-demo/artifacts/crypto-config/peerOrganizations/org0.example.com/tlsca/tlsca.org0.example.com-cert.pem

and the following are the error logs :

2019-05-29T12:02:04+05:30 - INFO [scripts/run.js]: Benchmark for target Blockchain type fabric-ccp about to start 

2019-05-29T12:02:05+05:30 - INFO [caliper-flow]: ####### Caliper Test ####### 

2019-05-29T12:02:05+05:30 - INFO [caliper-flow]: Executing command: cd /home/devk/Healthsector/caliper/packages/caliper-application/;echo 'start' 

2019-05-29T12:02:05+05:30 - INFO [adapters/fabric-ccp]: Fabric SDK version: 1.4.1; TLS: mutual 

2019-05-29T12:02:05+05:30 - WARN [adapters/fabric-ccp]: org0's registrar information not provided. 

2019-05-29T12:02:06+05:30 - WARN [adapters/fabric-ccp]: org0's admin's materials found locally. Make sure it is the right one! 

2019-05-29T12:02:06+05:30 - WARN [adapters/fabric-ccp]: client0.org0.example.com's materials found locally. Make sure it is the right one! 

2019-05-29T12:02:06+05:30 - INFO [adapters/fabric-ccp]: Channel 'common' is configured as created, skipping creation 

2019-05-29T12:02:06+05:30 - INFO [adapters/fabric-ccp]: peer0.org0.example.com has already joined common 

2019-05-29T12:02:06+05:30 - INFO [adapters/fabric-ccp]: Installing chaincodes for common... 

2019-05-29T12:02:06+05:30 - INFO [adapters/fabric-ccp]: relationship@v1.0 is already installed on peer0.org0.example.com 

2019-05-29T12:02:06+05:30 - INFO [adapters/fabric-ccp]: Instantiating relationship@v1.0 in common. This might take some time... 

2019-05-29T12:02:07+05:30 - ERROR [caliper-flow]: Error: Error: Orderer error for instantiating relationship@v1.0 in common: 8 RESOURCE_EXHAUSTED: Sent message larger than max (3549 vs. 15)
    at Fabric._instantiateChaincodes (/home/devk/Healthsector/caliper/packages/caliper-fabric-ccp/lib/fabric.js:1217:31)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7) 

2019-05-29T12:02:07+05:30 - INFO [demo.js]: [Transaction Info] - Submitted: 0 Succ: 0 Fail:0 Unfinished:0 

2019-05-29T12:02:07+05:30 - INFO [caliper-flow]: Executing command: cd /home/devk/Healthsector/caliper/packages/caliper-application/;echo 'end' 

Could you please tell me the reason of this error?

aklenik commented 5 years ago

@devendra491

  1. Some thoughts on the chaincode installation/instantiation: the id and version in the config file must match the deployed ones, those are used for the comparison.
  2. Your orderer section in the config contains this setting: grpc-max-send-message-length: 15, and that causes your problem. The Fabric SDK doc site lists the available gRPC settings you can attach to a node in the config. So a solution would be to omit the above setting or increase the number if you absolutely need a limit. After that, you should see in the logs that relationship@v1.0 is already instantiated in common
devkatcybersecurity commented 5 years ago

@aklenik Now it started giving new error:


info: [scripts/run.js]: Benchmark for target Blockchain type fabric-ccp about to start
error: [scripts/run.js]: Error while executing the benchmark: Error: Fabric 1.0 compatibility mode is detected, but SDK version 1.4.1 is used
    at new Fabric (/home/devk/Healthsector/caliper/packages/caliper-fabric-ccp/lib/fabric.js:157:19)
    at main (/home/devk/Healthsector/caliper/packages/caliper-application/scripts/run-benchmark.js:65:29)
    at Object.<anonymous> (/home/devk/Healthsector/caliper/packages/caliper-application/scripts/run-benchmark.js:78:1)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)

Even I am changing the version inside configuration files, it is still retaining it in cache somehow. how should i resolve this error ?

devkatcybersecurity commented 5 years ago

@aklenik It's been more than 10 days since I've been trying to configure it without any success, so I think it's better for me to stop working with caliper and stick with fabric test tools. Hope you'll make it more easy to use in the future. Thanks for all the help.

aklenik commented 5 years ago

@devendra491 The error indicates that you provided event URLs for the peers (v1.0 Fabric "feature"), but you're using 1.4 SDK, so it's not consistent.

Note about difficulty: Fabric is quite complex, so we can't really provide point-and-click benchmark support for it. We have to support every scenario that Fabric (and the SDK) supports, hence the configuration complexity. But the adapter is well documented, and you only have to put together the configuration once. So don't give up, once you're through this step, the real benchmarking can begin :)

aklenik commented 5 years ago

@devendra491 A raft example is now available. https://github.com/hyperledger/caliper/tree/master/packages/caliper-application/network/fabric-v1.4.1/raft