我想使用 Hyperledger Fabric v3.0.0 和 Caliper v0.6.0 来评估性能。我使用的是 Ubuntu 22.04。我完全重建了 Fabric 网络,并遵循了与 caliper 网站(link)上描述的完全相同的步骤,但是当我使用以下命令启动基准测试时,我仍然收到以下错误:
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/networkConfig.yaml --caliper-benchconfig benchmarks/myAssetBenchmark.yaml --caliper-flow-only-test
错误:
2024.12.03-13:47:32.435 info [caliper] [cli-launch-manager] Set workspace path: /home/umit/Desktop/HLF-3-0-0/caliper-workspace
2024.12.03-13:47:32.437 info [caliper] [cli-launch-manager] Set benchmark configuration path: /home/umit/Desktop/HLF-3-0-0/caliper-workspace/benchmarks/myAssetBenchmark.yaml
2024.12.03-13:47:32.437 info [caliper] [cli-launch-manager] Set network configuration path: /home/umit/Desktop/HLF-3-0-0/caliper-workspace/networks/networkConfig.yaml
2024.12.03-13:47:32.437 info [caliper] [cli-launch-manager] Set SUT type: fabric
2024.12.03-13:47:33.155 info [caliper] [benchmark-validator] No observer specified, will default to `none`
2024.12.03-13:47:33.155 info [caliper] [caliper-engine] Starting benchmark flow
2024.12.03-13:47:33.157 info [caliper] [caliper-engine] Skipping start commands due to benchmark flow conditioning
2024.12.03-13:47:33.159 info [caliper] [caliper-engine] Skipping initialization phase due to benchmark flow conditioning
2024.12.03-13:47:33.160 info [caliper] [caliper-engine] Skipping install smart contract phase due to benchmark flow conditioning
2024.12.03-13:47:40.344 error [caliper] [caliper-engine] Error while performing "test" step: Error: Multiple bindings for fabric have been detected, you need to unbind one or more to ensure only a single bind is present to continue
at _determineInstalledNodeSDKandVersion (/home/umit/node_modules/@hyperledger/caliper-fabric/lib/FabricConnectorFactory.js:52:19)
at CaliperEngine.connectorFactory [as adapterFactory] (/home/umit/node_modules/@hyperledger/caliper-fabric/lib/FabricConnectorFactory.js:132:17)
at CaliperEngine.run (/home/umit/node_modules/@hyperledger/caliper-cli/node_modules/@hyperledger/caliper-core/lib/manager/caliper-engine.js:149:64)
at LaunchManager.handler (/home/umit/node_modules/@hyperledger/caliper-cli/lib/launch/lib/launchManager.js:81:43)
at module.exports.handler (/home/umit/node_modules/@hyperledger/caliper-cli/lib/launch/launchManagerCommand.js:46:44)
at Object.runCommand (/home/umit/node_modules/@hyperledger/caliper-cli/node_modules/yargs/lib/command.js:240:40)
at Object.parseArgs [as _parseArgs] (/home/umit/node_modules/@hyperledger/caliper-cli/node_modules/yargs/yargs.js:1154:41)
at Object.runCommand (/home/umit/node_modules/@hyperledger/caliper-cli/node_modules/yargs/lib/command.js:198:30)
at Object.parseArgs [as _parseArgs] (/home/umit/node_modules/@hyperledger/caliper-cli/node_modules/yargs/yargs.js:1154:41)
at Object.get [as argv] (/home/umit/node_modules/@hyperledger/caliper-cli/node_modules/yargs/yargs.js:1088:21)
2024.12.03-13:47:40.345 info [caliper] [caliper-engine] Skipping end command due to benchmark flow conditioning
2024.12.03-13:47:40.345 error [caliper] [cli-launch-manager] Benchmark execution failed with error code: 6
Usage:
caliper launch manager --caliper-bind-sut fabric:2.2 [other options]
Options:
--help, -h Show usage information [boolean]
--version Show version information [boolean]
--caliper-bind-sut The name and version of the platform to bind to [string]
--caliper-bind-cwd The working directory for performing the SDK install [string]
--caliper-bind-args Additional arguments to pass to "npm install". Use the "=" notation when setting this parameter [string]
--caliper-bind-file Yaml file to override default (supported) package versions when binding an SDK [string]
Error: Benchmark execution failed with error code: 6
at LaunchManager.handler (/home/umit/node_modules/@hyperledger/caliper-cli/lib/launch/lib/launchManager.js:89:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
我写这篇文章是为了那些将来会遇到这个问题的人。这个解决方案导致了我另一个问题,但它不再给出这个错误。该问题是由于在使用多个超级账本结构版本时无法隔离某些文件而引起的。当我追踪错误来源时,我发现是 node_modules 文件夹中的 fabric-network 文件夹导致了这个错误。因为Hyperledger Fabric v2.4及更高版本中不使用它(https://www.npmjs.com/package/fabric-network),需要使用Fabric Gateway代替。如果你删除相关文件夹或者相应调整你的运行环境,这个问题就可以解决。