Caliper (v.0.4.2) is installed and setup the configuration on my machine (laptop), and ready to communicate with the existing deployed fabric network which is in google-cloud. To communicate these two caliper and fabric network, I have provided connection profile of org1(where my contract is deployed). I found the error and not solved.
How to solve this error?
Error: Could not find details for contract ID
Below is information for finding the solutions of given problem.
Caliper is startup using following commands
gopal@gopal:~/workspace/newcalliper/caliper-workspace$ npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/networkConfig.yaml --caliper-benchconfig benchmarks/myAssetBenchmark.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
Setting on networkConfig:
name: Fabric Calier test network
version: "2.0.0"
caliper:
blockchain: fabric
sutOptions:
mutualTls: false
channels:
- channelName: mychannel
contract:
- id: abc
organizations:
- mspid: Org1MSP
identities:
certificates:
- name: 'adminorg1'
admin: true
clientPrivateKey:
path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/crypto-config/peerOrganizations/org1.example.com/msp/keystore/key.pem'
clientSignedCert:
path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/crypto-config/peerOrganizations/org1.example.com/msp/signcerts/cert.pem'
connectionProfile:
path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/connection-org1.yaml'
discover: false
benchmark config :
test:
name: basic-contract-benchmark
description: test benchmark
workers:
type: local
number: 1
rounds:
- label: readAsset
description: Read asset benchmark
txDuration: 5
rateControl:
type: fixed-load
opts:
transactionLoad: 1
workload:
module: workload/readAsset.js
arguments:
contractId: abc
readAsset.js and submit transaction :
'use strict';
const { WorkloadModuleBase } = require('@hyperledger/caliper-core');
class MyWorkload extends WorkloadModuleBase {
constructor() {
super();
}
// this initializeWorkloadModule is called by the workloadeModuleBase.js from the caliper inside.
//and send to sutAdptor as a request to simulate.
async initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext) {
await super.initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext);
const request = {
contractId: this.roundArguments.contractId,
contractFunction: 'GetAllAssetCategory',
invokerIdentity: 'adminorg1',
contractArguments: [],
readOnly: false
};
await this.sutAdapter.sendRequests(request);
}
async submitTransaction() {
const myArgs = {
contractId:this.roundArguments.contractId,
contractFunction: 'GetAllAssetCategory',
invokerIdentity: 'adminorg1',
contractArguments: [],
readOnly: false,
targetPeers:['peer0.org1.exmple.com'],
targetOrganizations:['peer0.org1.example.com'],
orderer:['orderer0.org1.example.com'],
channel:['mychannel']
};
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}: Deleting asset ${assetID}`);
const request = {
contractId: this.roundArguments.contractId,
contractFunction: 'GetAllAssetCategory',
invokerIdentity: 'adminorg1',
contractArguments: [],
readOnly: false
};
await this.sutAdapter.sendRequests(request);
}
}
}
function createWorkloadModule() {
return new MyWorkload();
}
module.exports.createWorkloadModule = createWorkloadModule;
Caliper Log:
2021.01.26-23:11:54.759[32m info [39m [caliper] [caliper-worker] Info: worker 0 prepare test phase for round 0 is starting...
2021.01.26-23:11:54.764[90m debug[39m [caliper] [workload-module-base] Workload module initialized with: workerIndex=0, totalWorkers=1, roundIndex=0, roundArguments={"contractId":"abc"}
**2021.01.26-23:11:54.771[32m info [39m [caliper] [caliper-worker] Worker [0] encountered an error during prepare test phase for round 0: Error: Could not find details for contract ID abc
at V2FabricGateway._sendSingleRequest (/home/gopal/node_modules/@hyperledger/caliper-fabric/lib/connector-versions/v2/FabricGateway.js:156:23)**
at V2FabricGateway.sendRequests (/home/gopal/node_modules/@hyperledger/caliper-core/lib/common/core/connector-base.js:78:39)
at MyWorkload.initializeWorkloadModule (/home/gopal/workspace/newcalliper/caliper-workspace/workload/readAsset.js:20:35)
at process._tickCallback (internal/process/next_tick.js:68:7)
2021.01.26-23:11:54.772[32m info [39m [caliper] [caliper-worker] Info: worker 0 prepare test phase for round 0 is completed
2021.01.26-23:11:54.773[90m debug[39m [caliper] [process-messenger] Process "10624" sent message: {"sender":"10624","recipients":["10611"],"type":"prepared","content":{},"date":"2021-01-26T17:26:54.773Z","error":"Error: Could not find details for contract ID abc"}
2021.01.26-23:11:54.774[31m error[39m [caliper] [worker-message-handler] Error while handling "prepare" message for Worker (10624): Error: Could not find details for contract ID abc
at V2FabricGateway._sendSingleRequest (/home/gopal/node_modules/@hyperledger/caliper-fabric/lib/connector-versions/v2/FabricGateway.js:156:23)
at V2FabricGateway.sendRequests (/home/gopal/node_modules/@hyperledger/caliper-core/lib/common/core/connector-base.js:78:39)
at MyWorkload.initializeWorkloadModule (/home/gopal/workspace/newcalliper/caliper-workspace/workload/readAsset.js:20:35)
at process._tickCallback (internal/process/next_tick.js:68:7)
2021.01.26-23:11:54.793[90m debug[39m [caliper] [process-messenger] Process "10624" handling message: {"sender":"10611","recipients":["all"],"type":"exit","content":{},"date":"2021-01-26T17:26:54.793Z"}
2021.01.26-23:11:54.798[90m debug[39m [caliper] [worker-message-handler] Handling "exit" message for Worker (10624): {"sender":"10611","recipients":["all"],"type":"exit","content":{},"date":"2021-01-26T17:26:54.793Z"}
2021.01.26-23:11:54.799[32m info [39m [caliper] [worker-message-handler] Worker#0 is exiting
2021.01.26-23:11:54.799[90m debug[39m [caliper] [worker-message-handler] Handled "exit" message for Worker (10624)
Additionally, when discover: true
for the Connection profile, only peer show the info on console as
2021-01-27 14:25:22.811 UTC [comm.grpc.server] 1 -> INFO 098 unary call completed grpc.service=discovery.Discovery grpc.method=Discover grpc.peer_address=202.52.76.41:33878 grpc.peer_subject="CN=fabric-common" grpc.code=OK grpc.call_duration=1.059889ms
but none of orderer and CA shows any info of caliper request which was submitted as transaction using gateway . Following error is additionally shown in caliper console :
2021.01.27-19:25:35.887 info [caliper] [connectors/v2/FabricGateway] Successfully connected user with identity adminorg1 to a Network Gateway
2021.01.27-19:25:35.892 info [caliper] [connectors/v2/FabricGateway] Generating contract map for user adminorg1
2021-01-27T13:40:39.803Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Committer- name: orderer0.org1.example.com:7050, url:grpcs://localhost:7050, connected:false, connectAttempted:true
2021-01-27T13:40:39.808Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server orderer0.org1.example.com:7050 url:grpcs://localhost:7050 timeout:3000
2021-01-27T13:40:39.810Z - error: [DiscoveryService]: _buildOrderer[mychannel] - Unable to connect to the discovered orderer orderer0.org1.example.com:7050 due to Error: Failed to connect before the deadline on Committer- name: orderer0.org1.example.com:7050, url:grpcs://localhost:7050, connected:false, connectAttempted:true
2021-01-27T13:40:42.844Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer0.org1.example.com:7051, url:grpcs://localhost:7051, connected:false, connectAttempted:true
2021-01-27T13:40:42.844Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.org1.example.com:7051 url:grpcs://localhost:7051 timeout:3000
2021-01-27T13:40:42.845Z - error: [DiscoveryService]: _buildPeer[mychannel] - Unable to connect to the discovered peer peer0.org1.example.com:7051 due to Error: Failed to connect before the deadline on Endorser- name: peer0.org1.example.com:7051, url:grpcs://localhost:7051, connected:false, connectAttempted:true
2021.01.27-19:25:42.854 info [caliper] [caliper-worker] Info: worker 0 prepare test phase for round 0 is starting...
2021.01.27-19:25:42.861 info [caliper] [caliper-worker] Worker [0] encountered an error during prepare test phase for round 0: Error: Could not find details for contract ID abc
Edit : Added additional results of setup with discover
true and false case to define the problem clearly.
Thank you!
Your network config file is not complete. Caliper still has to explicitly know about the chaincodes (aka contracts) that have been deployed onto your channels.
Referring to this section in the tutorial
https://hyperledger.github.io/caliper/v0.4.2/fabric-tutorial/tutorials-fabric-existing/#populating-the-template-file
you will see a section on Channels
which describe adding information about channels to the network config file. For example from that tutorial it defines this section
channels:
- channelName: mychannel
contracts:
- id: basic
This states that there is a channel mychannel
that has a contract (chaincode) deployed with an id of basic