运行 Hyperledger Caliper V0.4.2 与 Fabric 2.1 的验证错误

Validation Error in running Hyperledger Caliper V0.4.2 with Fabric 2.1

当我运行使用 Caliper V0.4.2 测量 Fabric 2.1.0 1.4.7 的基准时,出现以下错误

ValidationError: child "version" fails because ["version" must be one of [1.0]]. child "clients" fails because ["clients" is required]. child "channels" fails because ["channels" must be an object]. child "organizations" fails because ["organizations" must be an object]. child "orderers" fails because ["orderers" is required]. child "peers" fails because ["peers" is required]

    at Object.exports.process (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hapi/joi/lib/errors.js:202:19)
    at internals.Object._validateWithOptions (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hapi/joi/lib/types/any/index.js:763:31)
    at module.exports.internals.Any.root.validate (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hapi/joi/lib/index.js:145:23)
    at Function._validateTopLevel (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hyperledger/caliper-fabric/lib/configValidator.js:208:26)
    at Function.validateNetwork (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hyperledger/caliper-fabric/lib/configValidator.js:58:25)
    at new FabricConnector (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hyperledger/caliper-fabric/lib/fabric-connector.js:107:25)
    at CaliperEngine.connectorFactory [as adapterFactory] (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hyperledger/caliper-fabric/lib/connectorFactory.js:26:23)
    at CaliperEngine.run (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hyperledger/caliper-core/lib/manager/caliper-engine.js:93:36)
    at Function.handler (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hyperledger/caliper-cli/lib/launch/lib/launchManager.js:62:43)
    at Object.module.exports.handler (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/@hyperledger/caliper-cli/lib/launch/launchManagerCommand.js:46:44)
  isJoi: true,
  name: 'ValidationError',
  details:
   [ { message: '"version" must be one of [1.0]',
       path: [Array],
       type: 'any.allowOnly',
       context: [Object] },
     { message: '"clients" is required',
       path: [Array],
       type: 'any.required',
       context: [Object] },
     { message: '"channels" must be an object',
       path: [Array],
       type: 'object.base',
       context: [Object] },
     { message: '"organizations" must be an object',
       path: [Array],
       type: 'object.base',
       context: [Object] },
     { message: '"orderers" is required',
       path: [Array],
       type: 'any.required',
       context: [Object] },
     { message: '"peers" is required',
       path: [Array],
       type: 'any.required',
       context: [Object] } ],
  _object:
   { name: 'Caliper Benchmarks',
     version: '2.1.0',
     caliper: { blockchain: 'fabric' },
     channels: [ [Object] ],
     organizations: [ [Object] ] },
  annotate: [Function] }

我运行的命令,

npm init -y

npm install --only=prod @hyperledger/caliper-cli@0.4.0

npx 卡尺绑定 --caliper-bind-sut fabric:2.1

./network.sh deployCC -ccn simple -ccp ../../caliper-benchmarks/src/fabric/scenario/simple/node -ccl javascript

npx caliper 启动管理器 --caliper-workspace ./ --caliper-networkconfig networks/fabric/test-network.yaml --caliper-benchconfig benchmarks/scenario/simple/config.yaml --caliper-flow-only-test - -caliper-fabric-gateway-enabled

Hyperledger 网络创建、通道创建和 Chaincode 部署均已成功。

如何解决这个错误?

看起来您正在使用 caliper-benchmarks 的主分支。我建议你 https://github.com/hyperledger/caliper-benchmarks/blob/main/networks/fabric/README.md

根据您发布的内容,您应该使用最新可用的 caliper 版本,即 0.4.2,而不是 0.4.0。为此,您应该发出的命令是

npm install --only=prod @hyperledger/caliper-cli

您应该绑定到最新的 2.2 sdk(不要绑定到 2.1,因为 fabric 不支持 2.1)。请注意,这是选择用于与结构网络交互的 sdk 版本,而不是您正在使用的结构网络版本。 2.2 将与 fabric 2.2 及更高版本 2.x 版本

一起使用
npx caliper bind --caliper-bind-sut fabric:2.2

最后您似乎尝试更改网络配置文件中的版本号。不要更改版本(它必须是 2.0.0)因为它指的是网络配置文件的版本而不是你要测试的结构版本

当您使用 test-network 时,取决于您使用的 fabric-samples 的哪个分支定义了 fabric 的版本。主分支测试最新版本的fabric,应该没有问题。