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
642 stars 403 forks source link

Caliper 0.5.0 docker image bind fails #1511

Open aritroCoder opened 5 months ago

aritroCoder commented 5 months ago

Which Caliper version are you using?

v0.5.0

Which Node.JS version are you using?

v16.20.2

Which operating system are you using?

Ubuntu 22.04.3 LTS (WSL)

Please provide some context for your error. For example, when did the error occur? What were you trying to achieve, and how?

I tried to bind my fabric 1.4.4 project to caliper v0.5.0 using the docker image. The command I used was:

 docker run \
    -e CALIPER_BIND_SUT=fabric:1.4 \
    -e CALIPER_BENCHCONFIG=benchmarks/benchmark_config.yaml \
    -e CALIPER_NETWORKCONFIG=networks/network_config.json \
    -v $PWD:/hyperledger/caliper/workspace \
    -v $PWD/../connections:/hyperledger/caliper/connections \
    --name caliper hyperledger/caliper:0.5.0 launch manager

What was the observed incorrect behavior?

The benchmark exited with error. I restarted the benchmark multiple times but got the same error.

Please provide the error logs and their surroundings.

+ fs-extra@8.1.0
+ fabric-client@1.4.20
+ fabric-network@1.4.20
+ fabric-protos@2.1.0
added 507 packages from 210 contributors in 334.918s
2024.01.15-18:35:43.147 info  [caliper] [cli-launch-manager]    Set workspace path: /hyperledger/caliper/workspace
2024.01.15-18:35:43.147 info  [caliper] [cli-launch-manager]    Set benchmark configuration path: /hyperledger/caliper/workspace/benchmarks/benchmark_config.yaml
2024.01.15-18:35:43.148 info  [caliper] [cli-launch-manager]    Set network configuration path: /hyperledger/caliper/workspace/networks/network_config.json
2024.01.15-18:35:43.148 info  [caliper] [cli-launch-manager]    Set SUT type: fabric
2024.01.15-18:35:43.153 info  [caliper] [benchmark-validator]   No observer specified, will default to `none`
2024.01.15-18:35:43.154 info  [caliper] [caliper-engine]        Starting benchmark flow
2024.01.15-18:35:43.154 info  [caliper] [caliper-engine]        Network configuration attribute "caliper.command.start" is not present, skipping start command
2024.01.15-18:35:43.832 info  [caliper] [FabricConnectorFactory]        Initializing standard connector compatible with installed fabric-network SDK: 1.4.202024.01.15-18:35:43.927 info  [caliper] [IdentityManager]       Adding user1 (admin=false) as user1 for organization UserMSP
2024.01.15-18:35:44.156 info  [caliper] [IdentityManager]       Adding insurer1 (admin=false) as _InsurerMSP_insurer1 for organization InsurerMSP
2024.01.15-18:35:44.159 info  [caliper] [IdentityManager]       Adding verifier1 (admin=false) as _VerifierMSP_verifier1 for organization VerifierMSP
2024.01.15-18:35:44.164 info  [caliper] [connectors/v1/FabricNonGateway]        Fabric SDK version: 1.4.20; TLS based on UserMSP: server
2024.01.15-18:35:44.165 info  [caliper] [caliper-engine]        Executed "init" step in 0.003 seconds
2024.01.15-18:35:44.166 info  [caliper] [connectors/v1/FabricChaincodeOperations]       Installing contracts for commonchannel...
2024.01.15-18:35:44.167 info  [caliper] [caliper-engine]        Executed "install" step in 0.002 seconds
2024.01.15-18:35:44.170 info  [caliper] [monitor.js]    No resource monitors specified
2024.01.15-18:35:44.172 info  [caliper] [default-observer]      Observer interval set to 5000 milliseconds
2024.01.15-18:35:44.175 info  [caliper] [round-orchestrator]    Preparing worker connections
2024.01.15-18:35:44.175 info  [caliper] [worker-orchestrator]   Launching worker 1 of 1
2024.01.15-18:35:44.185 info  [caliper] [worker-orchestrator]   Messenger not configured, entering configure phase...
2024.01.15-18:35:44.185 info  [caliper] [worker-orchestrator]   No existing workers detected, entering worker launch phase...
2024.01.15-18:35:44.186 info  [caliper] [worker-orchestrator]   Waiting for 1 workers to be connected...
2024.01.15-18:35:44.530 info  [caliper] [cli-launch-worker]     Worker is a locally forked process, skipping binding step already performed by the manager process
2024.01.15-18:35:44.533 info  [caliper] [cli-launch-worker]     Set workspace path: /hyperledger/caliper/workspace
2024.01.15-18:35:44.534 info  [caliper] [cli-launch-worker]     Set benchmark configuration path: /hyperledger/caliper/workspace/benchmarks/benchmark_config.yaml
2024.01.15-18:35:44.534 info  [caliper] [cli-launch-worker]     Set network configuration path: /hyperledger/caliper/workspace/networks/network_config.json
2024.01.15-18:35:44.534 info  [caliper] [cli-launch-worker]     Set SUT type: fabric
2024.01.15-18:35:44.565 info  [caliper] [worker-orchestrator]   1 workers connected, progressing to worker assignment phase.
2024.01.15-18:35:44.565 info  [caliper] [worker-orchestrator]   Workers currently unassigned, awaiting index assignment...
2024.01.15-18:35:44.567 info  [caliper] [worker-orchestrator]   Waiting for 1 workers to be assigned...
2024.01.15-18:35:44.629 info  [caliper] [worker-orchestrator]   1 workers assigned, progressing to worker initialization phase.
2024.01.15-18:35:44.629 info  [caliper] [worker-orchestrator]   Waiting for 1 workers to be ready...
2024.01.15-18:35:44.629 info  [caliper] [worker-message-handler]        Initializing Worker#0...
2024.01.15-18:35:45.238 info  [caliper] [FabricConnectorFactory]        Initializing standard connector compatible with installed fabric-network SDK: 1.4.202024.01.15-18:35:45.357 info  [caliper] [IdentityManager]       Adding user1 (admin=false) as user1 for organization UserMSP
2024.01.15-18:35:45.588 info  [caliper] [IdentityManager]       Adding insurer1 (admin=false) as _InsurerMSP_insurer1 for organization InsurerMSP
2024.01.15-18:35:45.590 info  [caliper] [IdentityManager]       Adding verifier1 (admin=false) as _VerifierMSP_verifier1 for organization VerifierMSP
2024.01.15-18:35:45.595 info  [caliper] [worker-message-handler]        Worker#0 initialized
2024.01.15-18:35:45.596 info  [caliper] [worker-orchestrator]   1 workers ready, progressing to test preparation phase.
2024.01.15-18:35:45.596 info  [caliper] [round-orchestrator]    Started round 1 (createUser)
2024.01.15-18:35:45.597 info  [caliper] [worker-message-handler]        Preparing Worker#0 for Round#0
2024.01.15-18:35:45.778 info  [caliper] [caliper-worker]        Worker [0] encountered an error during prepare test phase for round 0: Error: No orderers could be found for channel commonchannel in any of the connection profiles
    at ConnectorConfiguration.getOrderersInChannelMap (/home/node/.npm-global/lib/node_modules/@hyperledger/caliper-cli/node_modules/@hyperledger/caliper-fabric/lib/connector-configuration/ConnectorConfiguration.js:372:27)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async V1Fabric.getContext (/home/node/.npm-global/lib/node_modules/@hyperledger/caliper-cli/node_modules/@hyperledger/caliper-fabric/lib/connector-versions/v1/FabricNonGateway.js:106:41)
    at async CaliperWorker.prepareTest (/home/node/.npm-global/lib/node_modules/@hyperledger/caliper-core/lib/worker/caliper-worker.js:157:23)
    at async WorkerMessageHandler._handlePrepareMessage (/home/node/.npm-global/lib/node_modules/@hyperledger/caliper-core/lib/worker/worker-message-handler.js:210:13)

Please provide your benchmark configuration file content, if possible.

test:
    name: caliper_benchmark
    description: test benchmark
    workers:
      number: 1
    rounds:
      - label: createUser
        description: Query User benchmark
        txDuration: 30
        rateControl:
          type: fixed-load
          opts:
            transactionLoad: 2
        workload:
          module: benchmarks/callbacks/createProfileBenchmark.js
          arguments:
            assets: 10

Please provide your network configuration file content, if possible.

{
    "name": "metasurance",
    "version": "2.0.0",
    "caliper": {
        "blockchain": "fabric"
    },
    "organizations":[
        {
            "mspid": "UserMSP",
            "connectionProfile": {
                "path": "../connections/connection-user.json",
                "discover": false
            },
            "identities": {
                "certificates": [
                    {
                        "name": "user1",
                        "clientPrivateKey": {
                            "pem": "-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQglTQlpZDgt0zpI6x8\ncfnSvj8zP1ZvpYOfHiGB1GM95vihRANCAARYsnMXY0Zx5btIxKFDPZUVEPNEOMnt\nMt26Bwu3XBt7/SZ8o9wzIqU2/f29gGuHkG5Z2B68awggyaEfNAU4WXTu\n-----END PRIVATE KEY-----\n"
                        },
                        "clientSignedCert": {
                            "pem": "-----BEGIN CERTIFICATE-----\nMIICZzCCAg6gAwIBAgIRAPgbReOgOx4963kgFrFJ4t8wCgYIKoZIzj0EAwIwfjEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG\ncmFuY2lzY28xHTAbBgNVBAoTFHVzZXIubWV0YXN1cmFuY2UuY29tMSMwIQYDVQQD\nExp0bHNjYS51c2VyLm1ldGFzdXJhbmNlLmNvbTAeFw0yNDAxMTUxNzAwMDBaFw0z\nNDAxMTIxNzAwMDBaMH4xCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh\nMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMR0wGwYDVQQKExR1c2VyLm1ldGFzdXJh\nbmNlLmNvbTEjMCEGA1UEAxMadGxzY2EudXNlci5tZXRhc3VyYW5jZS5jb20wWTAT\nBgcqhkjOPQIBBggqhkjOPQMBBwNCAATOiKWl+VNidi/P3fwak32Vm1fS515GenXE\nSEXztQBjCJfaBdYx90DGTJs/0c8p0zliYuRgFSARqDDXTKbhRm5Uo20wazAOBgNV\nHQ8BAf8EBAMCAaYwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMBMA8GA1Ud\nEwEB/wQFMAMBAf8wKQYDVR0OBCIEIHfxRgT5IJMtqBWPLjrgCJknZXzMHyWmLn7x\n7sccL7NlMAoGCCqGSM49BAMCA0cAMEQCIG4eWHoq/0YY8YJ0Uk4994Yav5UcbMAA\nax14zP092NFqAiAtXLa8cLUV1tbHW2AGujKLsncoaEJ9cfn4QTvd71UfVQ==\n-----END CERTIFICATE-----\n"
                        }
                    }
                ]
            }
        },
        {
            "mspid": "InsurerMSP",
            "connectionProfile": {
                "path": "../connections/connection-insurer.json",
                "discover": false
            },
            "identities": {
                "certificates": [
                    {
                        "name": "insurer1",
                        "clientPrivateKey": {
                            "pem": "-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgQnnVJQ0eyZZ+sUCQ\n4I2HyzX+hIwL8dPIrU0ztvZvmMGhRANCAAQ9OhmGwVmQynQ5+pZ4OJZeXAfik2Zz\nxHF5z2c1QHEkWYPOslHALxRomc2uBUrJMlDpVBSvV91vqA0PeF6E7qgG\n-----END PRIVATE KEY-----\n"
                        },
                        "clientSignedCert": {
                            "pem": "-----BEGIN CERTIFICATE-----\nMIICdTCCAhygAwIBAgIRANnkl4N78Wliq9KJeUOU7QswCgYIKoZIzj0EAwIwgYQx\nCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4g\nRnJhbmNpc2NvMSAwHgYDVQQKExdpbnN1cmVyLm1ldGFzdXJhbmNlLmNvbTEmMCQG\nA1UEAxMddGxzY2EuaW5zdXJlci5tZXRhc3VyYW5jZS5jb20wHhcNMjQwMTE1MTcw\nMDAwWhcNMzQwMTEyMTcwMDAwWjCBhDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNh\nbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xIDAeBgNVBAoTF2luc3Vy\nZXIubWV0YXN1cmFuY2UuY29tMSYwJAYDVQQDEx10bHNjYS5pbnN1cmVyLm1ldGFz\ndXJhbmNlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJa60w2m4vgGNaIT\nnVGBr6lR9xFgTpUePcqpaZaZ9H0RXSUatLtOEJiJvXHxIBsOsHracuw1oWijyVqC\nu6dEC4qjbTBrMA4GA1UdDwEB/wQEAwIBpjAdBgNVHSUEFjAUBggrBgEFBQcDAgYI\nKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB/zApBgNVHQ4EIgQg1rJEdqsK4SIR0ufs\ndWiumvBhgJxht1+vNeh/VRIc/BUwCgYIKoZIzj0EAwIDRwAwRAIgPVpPtxLfKx3e\nch3KTenSpmkY2HrhAYNJiIyunXZcFowCIEyl57sq5RG8IM/Vtlme0SrVle70L7Qn\n79l5yiCeNbDL\n-----END CERTIFICATE-----\n"
                        }
                    }
                ]
            }
        },
        {
            "mspid": "VerifierMSP",
            "connectionProfile": {
                "path": "../connections/connection-verifier.json",
                "discover": false
            },
            "identities": {
                "certificates": [
                    {
                        "name": "verifier1",
                        "clientPrivateKey": {
                            "pem": "-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg4NOPQTz6M13PPP0N\ngaaM/hYy4ZU4Ii1IQIJ9MHTyt1WhRANCAATjBx12DrQqqxyXRzN3JPGFbyDrXKU/\n+ZH2MnpQ3OE/gqJ+AFq4Exc0D5tcDhVn/oyweT4r4n20Kp8IlUaR6qcW\n-----END PRIVATE KEY-----\n"
                        },
                        "clientSignedCert": {
                            "pem": "-----BEGIN CERTIFICATE-----\nMIICejCCAiCgAwIBAgIRAM5XNGbBWxyVhMibew6ANfIwCgYIKoZIzj0EAwIwgYYx\nCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4g\nRnJhbmNpc2NvMSEwHwYDVQQKExh2ZXJpZmllci5tZXRhc3VyYW5jZS5jb20xJzAl\nBgNVBAMTHnRsc2NhLnZlcmlmaWVyLm1ldGFzdXJhbmNlLmNvbTAeFw0yNDAxMTUx\nNzAwMDBaFw0zNDAxMTIxNzAwMDBaMIGGMQswCQYDVQQGEwJVUzETMBEGA1UECBMK\nQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEhMB8GA1UEChMYdmVy\naWZpZXIubWV0YXN1cmFuY2UuY29tMScwJQYDVQQDEx50bHNjYS52ZXJpZmllci5t\nZXRhc3VyYW5jZS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASnWId6xIC2\natsXR8Be6tf9YboHJ5ciBNZ9zaZqvTaI0aJE8sLeNPbs1sd4Jofm8QeLj53aWgOX\nexMKfRgHSYFio20wazAOBgNVHQ8BAf8EBAMCAaYwHQYDVR0lBBYwFAYIKwYBBQUH\nAwIGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMBAf8wKQYDVR0OBCIEIKBzgMxQZ39R\nH3FQLEin8u2M4Ith7P5AM3Zw0iiUBmtwMAoGCCqGSM49BAMCA0gAMEUCIQDzcfb4\ng3IGS642iMTR60log2Br/HWRJw4JcfMN/AFSEwIgRK526DLVnKWUruLlCW+x2Vz0\nmB9LTSfndmgp7S3XtQ8=\n-----END CERTIFICATE-----\n"
                        }
                    }
                ]
            }
        }
    ],
    "channels":[
        {
            "channelName": "commonchannel",
            "orderers": [
                "orderer.metasurance.com"
            ],
            "contracts":[
                {
                    "id": "user_cc",
                    "version": "1.8"
                },
                {
                    "id": "insurer_cc",
                    "version": "1.9"
                },
                {
                    "id": "verifier_cc",
                    "version": "1.8"
                },
                {
                    "id": "asset_cc",
                    "version": "1.8"
                },
                {
                    "id": "policy_cc",
                    "version": "2.7"
                },
                {
                    "id": "policyusermapping_cc",
                    "version": "1.8"
                },
                {
                    "id": "claim_cc",
                    "version": "1.9"
                }
            ]
        }
    ]
}

Please provide your workload module content, if possible.

'use strict';

const { WorkloadModuleBase } = require('@hyperledger/caliper-core');

class MyWorkload extends WorkloadModuleBase {
    constructor() {
        super();
    }

    async initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext) {
        await super.initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext);

        for (let i = 0; i < this.roundArguments.assets; i++) {
            const uname = `${this.workerIndex}_${i}`;
            console.log(`Worker ${this.workerIndex}: Creating user ${uname}`);
            const request = {
                contractId: "user_cc",
                contractFunction: 'register',
                invokerIdentity: 'user1',
                contractArguments: [uname, "user1", "user@email.com", "1234567890", "1234"],
                readOnly: false
            };

            await this.sutAdapter.sendRequests(request);
        }
    }

    async submitTransaction() {
        const randomId = Math.floor(Math.random() * this.roundArguments.assets);
        const myArgs = {
            contractId: "user_cc",
            contractFunction: 'readUserProfile',
            invokerIdentity: 'user1',
            contractArguments: [`${this.workerIndex}_${randomId}`],
            readOnly: true
        };

        await this.sutAdapter.sendRequests(myArgs);
    }

    async cleanupWorkloadModule() {
        for (let i = 0; i < this.roundArguments.assets; i++) {
            const assetID = `${this.workerIndex}_${i}`;
            console.log(`Worker ${this.workerIndex}: Checking user ${assetID}`);
            const request = {
                contractId: "user_cc",
                contractFunction: 'checkUserExists',
                invokerIdentity: 'user1',
                contractArguments: [assetID],
                readOnly: false
            };
            await this.sutAdapter.sendRequests(request);
        }
    }
}

function createWorkloadModule() {
    return new MyWorkload();
}

module.exports.createWorkloadModule = createWorkloadModule;

Please provide any additional information you deem relevant to the error.

No response

davidkel commented 5 months ago

Because you are using the 1.4 fabric connector, haven't specified using the gateway option (as only the gateway option supports using discovery) and your network configuration file specifically specifies discovery=false) this is expected because without discovery you have to provide a complete description of your fabric network, including all the peers involved and all the orderers. You haven't specified the orderers in the network configuration file which is why you get this error. See https://hyperledger.github.io/caliper/v0.5.0/fabric-config/new/#binding-with-fabric-14 and the section in general about how to configure a network configuration file for hyperledger fabric.

If you are still using fabric 1.4 (really you shouldn't) you can still bind to the fabric 2.2 connector as it will work with fabric 1.4. With fabric 2.2 it always uses the gateway mechanism and then you can enable discovery in your network configuration file which would mean you wouldn't have to explicitly describe your whole fabric network.

aritroCoder commented 5 months ago

Because you are using the 1.4 fabric connector, haven't specified using the gateway option (as only the gateway option supports using discovery) and your network configuration file specifically specifies discovery=false) this is expected because without discovery you have to provide a complete description of your fabric network, including all the peers involved and all the orderers. You haven't specified the orderers in the network configuration file which is why you get this error. See https://hyperledger.github.io/caliper/v0.5.0/fabric-config/new/#binding-with-fabric-14 and the section in general about how to configure a network configuration file for hyperledger fabric.

If you are still using fabric 1.4 (really you shouldn't) you can still bind to the fabric 2.2 connector as it will work with fabric 1.4. With fabric 2.2 it always uses the gateway mechanism and then you can enable discovery in your network configuration file which would mean you wouldn't have to explicitly describe your whole fabric network.

Thanks for the reply, I tried what you suggested by using the command with fabric:2.2 and setting discover as true. With that, I am getting timeout from calliper when it's trying to connect to fabric blockchain. The logs are here:

2024.01.16-16:11:29.065 info  [caliper] [worker-message-handler]        Preparing Worker#0 for Round#0
2024.01.16-16:11:29.238 info  [caliper] [connectors/v2/FabricGateway]   Connecting user with identity user1 to a Network Gateway
2024-01-16T16:11:32.410Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer0.user.metasurance.com, url:grpcs://localhost:8051, connected:false, connectAttempted:true
2024-01-16T16:11:32.411Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.user.metasurance.com url:grpcs://localhost:8051 timeout:3000
2024-01-16T16:11:32.413Z - info: [NetworkConfig]: buildPeer - Unable to connect to the endorser peer0.user.metasurance.com due to Error: Failed to connect before the deadline on Endorser- name: peer0.user.metasurance.com, url:grpcs://localhost:8051, connected:false, connectAttempted:true
    at checkState (/home/node/.npm-global/lib/node_modules/fabric-network/node_modules/@grpc/grpc-js/build/src/client.js:74:26)
    at Timeout._onTimeout (/home/node/.npm-global/lib/node_modules/fabric-network/node_modules/@grpc/grpc-js/build/src/channel.js:479:17)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7) {
  connectFailed: true
}
2024.01.16-16:11:32.413 info  [caliper] [connectors/v2/FabricGateway]   Successfully connected user with identity user1 to a Network Gateway
2024.01.16-16:11:32.414 info  [caliper] [connectors/v2/FabricGateway]   Generating contract map for user user1
2024-01-16T16:11:35.432Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Discoverer- name: peer0.user.metasurance.com, url:grpcs://localhost:8051, connected:false, connectAttempted:true
2024-01-16T16:11:35.432Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.user.metasurance.com url:grpcs://localhost:8051 timeout:3000
2024-01-16T16:11:35.432Z - error: [ServiceEndpoint]: ServiceEndpoint grpcs://localhost:8051 reset connection failed :: Error: Failed to connect before the deadline on Discoverer- name: peer0.user.metasurance.com, url:grpcs://localhost:8051, connected:false, connectAttempted:true
2024-01-16T16:11:35.432Z - error: [DiscoveryService]: send[commonchannel] - no discovery results
2024.01.16-16:11:35.432 warn  [caliper] [connectors/v2/FabricGateway]   Couldn't initialize commonchannel for user1. user1 not available for use on this channel. Error: DiscoveryService has failed to return results
2024.01.16-16:11:35.433 info  [caliper] [connectors/v2/FabricGateway]   Connecting user with identity _InsurerMSP_insurer1 to a Network Gateway
2024-01-16T16:11:38.525Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer0.insurer.metasurance.com, url:grpcs://localhost:7051, connected:false, connectAttempted:true
2024-01-16T16:11:38.526Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.insurer.metasurance.com url:grpcs://localh
davidkel commented 5 months ago

There is a connectivity problem now between caliper and the peer peer0.user.metasurance.com on url:grpcs://localhost:8051. It could be that the connection-profile you specified is incorrect in some way, for example the tls ca certificates specified are not correct. This is really a fabric issue now as caliper just uses the standard fabric node sdk to communicate with fabric and the initial discovery is all handled by the fabric node sdk. Suggest you check your connection profile is correct, your peer is contactable on localhost:8051 and that the tls CA certs are correct (ie they were the CA certs that signed the tls cert being used by the peer).

aritroCoder commented 5 months ago

There is a connectivity problem now between caliper and the peer peer0.user.metasurance.com on url:grpcs://localhost:8051. It could be that the connection-profile you specified is incorrect in some way, for example the tls ca certificates specified are not correct. This is really a fabric issue now as caliper just uses the standard fabric node sdk to communicate with fabric and the initial discovery is all handled by the fabric node sdk. Suggest you check your connection profile is correct, your peer is contactable on localhost:8051 and that the tls CA certs are correct (ie they were the CA certs that signed the tls cert being used by the peer).

Just for clarity, the clientSignedCert is the tlsca certificate (located in "backend\crypto-config\peerOrganizations\user.metasurance.com\tlsca"), and the clientPrivateKey is the is the private key (located at "backend\crypto-config\peerOrganizations\user.metasurance.com\users\Admin@user.metasurance.com\msp\keystore"), am I right?

aritroCoder commented 5 months ago

Hello @davidkel is it possible by any chance that the docker images of peer orgs are running in my local system(eg: port 8051 in localhost of host PC), and caliper docker container cannot access the localhost from inside the container? Because I already have a working backend and frontend for my fabric network, and everything seems to work smoothly there, only in caliper there is the timeout error

davidkel commented 5 months ago

I haven't used fabric for a long time now so can't remember the contents of the tlsca directory generated by cryptogen, but clientSignedCert wouldn't be the one I would use for a tlsca certificate. It sounds like you are not familiar with the concept of containers, so I would highly recommend that you do some reading about Docker and what a container is. From a networking point of view containers can appear to be standalone systems and as such have their own network card, mac address and ip address. As such running localhost in a container would be refering to itself and not another container.

aritroCoder commented 5 months ago

Okay, I was unable to fix the error, but I was able to run caliper locally from npm after switching from WSL to a linux system(I was getting some build errors in WSL). For record purposes, my issue with docker seems similiar to this in stackoverflow: https://stackoverflow.com/questions/65605285/why-containerized-version-of-hl-caliper-is-always-trying-to-connect-to-localhost, but the solution given as of now did not work for me. Maybe it will get more answers in the future.

If anyone facing the build error while binding with fabric like me, try to use a Linux system rather than WSL, node v16 LTS or v14 LTS is best, python v3.10 is required(does not work with 3.11 unfortunately).

I guess we can close this issue for now.

davidkel commented 5 months ago

@aritroCoder The specific problem in that stackoverflow issue was due to a mistake in the docs which meant it didn't correctly turn off converting hostnames to localhost when fabric discovery results are returned. Networking in docker is something that really needs to be understood (and thus to get correct name resolution) in order to get containers to be able to communicate with each other and it's vital that fabric knows these hostnames as well. Fabric test network runs containers and explicitly opens a port on the host machine which routes to the port of the process running in the container which makes it easier to run processes on the host that can then communicate with the fabric process using localhost. The legacy node SDK has a default to convert all hostnames to localhost on returning the discovery results which makes it easy for a simple setup but ultimately confuses everyone and has to be turned off for any other type of environment (It's a really dumb default). To get the Caliper container image working correctly really need to understand the networking aspects of your whole environment as well as the fabric network topology to ensure that components can not only talk to each other but validate TLS certificates correctly. Unfortunately this is not a trivial thing for fabric and it's really upto the Fabric Project to describe this and maybe provide examples perhaps starting with the fabric-samples test network. Be nice if their documentation and samples had something but I don't think they do. The test network hides loads of the network complexities but of course never explains why things are done the way they are. I use WSL all the time and my version is also Ubuntu 22.04.3 (but it's going to be identical to a standard linux machine running 22.04.3 bar running systemd unless you have enabled systemd for WSL) and my version of python is 3.9 (although I do note that 3.10 and 3.11 are installed well) as that is my default python version. So I think something in your wsl instance may have set python to 3.11 as a default. But it's really useful to hear that python3.11 causes issues for caliper, so thank you very much for the feedback, much appreciated.