Caliper (v.0.4.2) 已安装并在我的机器(笔记本电脑)上设置配置,并准备与 google-cloud 中现有的已部署结构网络进行通信。为了沟通这两个 caliper 和 fabric 网络,我提供了 org1 的连接配置文件(部署了我的合约)。我发现了错误并没有解决。
如何解决这个错误?
错误:找不到合同 ID 的详细信息
以下是用于查找给定问题的解决方案的信息。
Caliper 正在使用以下命令启动
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
在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
基准配置:
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 并提交交易:
'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;
卡尺日志:
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)
此外,discover: true
对于连接配置文件,只有对等方将控制台上的信息显示为
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
但是订购者和 CA 都没有显示使用网关作为事务提交的卡尺请求的任何信息。caliper 控制台中还显示以下错误:
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
编辑:添加了带有discover
真假情况的附加设置结果,以清楚地定义问题。
谢谢!