Ensure you have all the necessary prerequisites for Caliper and Hyperledger Fabric prerequisites
Hyperledger Fabric provides a test network as part of its samples. This test network is a good generalised network that you can used to get started.
Steps to setup an environment to use caliper-benchmarks with Fabric samples test-network
mkdir fabric-benchmarks
cd fabric-benchmarks
git clone https://github.com/hyperledger/caliper-benchmarks
cd caliper-benchmarks
npm install --only=prod @hyperledger/caliper-cli
To bind with fabric 2.2 (which uses the legacy node-sdk 2.2) which can be used with a Fabric 2.2 or higher SUT run:
npx caliper bind --caliper-bind-sut fabric:2.2
To bind with fabric 2.4 and utilise the new peer-gateway service introduced in fabric 2.4 run:
npx caliper bind --caliper-bind-sut fabric:2.4
If you wish to change the version of binding make sure to unbind your current binding (for example if you bound to fabric:2.2 unbind first with caliper unbind --caliper-bind-sut fabric:2.2
) before binding to the new one.
cd ../fabric-samples/test-network directory
mychannel
./network.sh up createChannel -s couchdb
This will create a fabric network using couchdb
as the state database because some of the chaincodes use rich queries. If you want to test with leveldb
you can drop the -s couchdb
option but make sure the chaincode you deploy doesn't require it.
The test-network caliper configuration file is coded to work with cryptogen generated material so do not start test-network using fabric-cas for the generated keys and certificates (ie don't use the -ca
option).
To terminate the network use the ./network.sh down
command
Now you are ready to choose a chaincode to deploy and run some benchmarks. There are some pre-requisites for test-network
The network configuration file provided by this repo for test-network called networks/fabric/test-network.yaml
is configured to support all the chaincodes listed in this README. It also looks for certificates created using cryptogen by test-network, which is the default when starting test-network and is reflected in the commands provided in this README.
Fabcar has chaincode for Go, Java, Javascript. It doesn't make use of rich queries so can be used with a leveldb
based fabric network rather than couchdb
Ensure you are in the fabric-samples/test-network
directory
./network.sh deployCC -ccn fabcar -ccp ../../caliper-benchmarks/src/fabric/samples/fabcar/go -ccl go
./network.sh deployCC -ccn fabcar -ccp ../../caliper-benchmarks/src/fabric/samples/fabcar/java -ccl java
./network.sh deployCC -ccn fabcar -ccp ../../caliper-benchmarks/src/fabric/samples/fabcar/node -ccl javascript
Ensure you are in the caliper-benchmarks
directory
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/fabric/test-network.yaml --caliper-benchconfig benchmarks/samples/fabric/fabcar/config.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
Marbles comes in both rich query and no rich query flavours and has has chaincode for Go and Javascript.
Ensure you are in the fabric-samples/test-network
directory
./network.sh deployCC -ccn marbles -ccp ../../caliper-benchmarks/src/fabric/samples/marbles/go -ccl go
./network.sh deployCC -ccn marbles -ccp ../../caliper-benchmarks/src/fabric/samples/marbles-norichquery/go -ccl go
./network.sh deployCC -ccn marbles -ccp ../../caliper-benchmarks/src/fabric/samples/marbles/node -ccl javascript
./network.sh deployCC -ccn marbles -ccp ../../caliper-benchmarks/src/fabric/samples/marbles-norichquery/node -ccl javascript
Ensure you are in the caliper-benchmarks
directory
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/fabric/test-network.yaml --caliper-benchconfig benchmarks/samples/fabric/marbles/config.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
Simple has chaincode for Go, Javascript. It doesn't make use of rich queries so can be used with a leveldb
based fabric network rather than couchdb
Ensure you are in the fabric-samples/test-network
directory
./network.sh deployCC -ccn simple -ccp ../../caliper-benchmarks/src/fabric/scenario/simple/go -ccl go
./network.sh deployCC -ccn simple -ccp ../../caliper-benchmarks/src/fabric/scenario/simple/node -ccl javascript
Ensure you are in the caliper-benchmarks
directory
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/fabric/test-network.yaml --caliper-benchconfig benchmarks/scenario/simple/config.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
Smallbank has chaincode for Go only. It doesn't make use of rich queries so can be used with a leveldb
based fabric network rather than couchdb
Ensure you are in the fabric-samples/test-network
directory
./network.sh deployCC -ccn smallbank -ccp ../../caliper-benchmarks/src/fabric/scenario/smallbank/go -ccl go
Ensure you are in the caliper-benchmarks
directory first
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/fabric/test-network.yaml --caliper-benchconfig benchmarks/scenario/smallbank/config.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
This is a complete set of benchmarks for hyperledger fabric focusing on managing a simple asset. The chaincodes are written to use the Hyperledger fabric contract api and are available for Go, Java and Javascript. These chaincodes require couchdb
as they perform rich queries.
The benchmarks require a Prometheus server to be running that is collecting Hyperledger Fabric metrics. the Fabric Samples provide a test Prometheus and Grafana server for test-network. To start this environment:
test-network
directory change to the prometheus-grafana
directorydocker-compose up -d
to bring up the serversYou can terminate the servers with the command docker-compose down
.
There are several benchmarks available within the benchmarks/api/fabric
directory to choose from and each file contains a description of their purpose
Ensure you are in the fabric-samples/test-network
directory
./network.sh deployCC -ccn fixed-asset -ccp ../../caliper-benchmarks/src/fabric/api/fixed-asset/go -ccl go -cccg ../../caliper-benchmarks/src/fabric/api/fixed-asset/collections-config.json
./network.sh deployCC -ccn fixed-asset -ccp ../../caliper-benchmarks/src/fabric/api/fixed-asset/java -ccl java -cccg ../../caliper-benchmarks/src/fabric/api/fixed-asset/collections-config.json
./network.sh deployCC -ccn fixed-asset -ccp ../../caliper-benchmarks/src/fabric/api/fixed-asset/node -ccl javascript -cccg ../../caliper-benchmarks/src/fabric/api/fixed-asset/collections-config.json
Ensure you are in the caliper-benchmarks
directory. As there a several benchmarks to choose from the example below just shows the get-asset.yaml
benchmark invocation
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/fabric/test-network.yaml --caliper-benchconfig benchmarks/api/fabric/get-asset.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
fixed-asset-base is equivalent to fixed-asset but instead it doesn't make use of the contract-api. It also doesn't provide a java chaincode version. Refer back to the fixed-asset section for more details
Ensure you are in the fabric-samples/test-network
directory. Note here that we deploy with a chaincode ID of fixed-asset
not fixed-asset-base
.
./network.sh deployCC -ccn fixed-asset -ccp ../../caliper-benchmarks/src/fabric/api/fixed-asset-base/go -ccl go -cccg ../../caliper-benchmarks/src/fabric/api/fixed-asset-base/collections-config.json
./network.sh deployCC -ccn fixed-asset -ccp ../../caliper-benchmarks/src/fabric/api/fixed-asset-base/node -ccl javascript -cccg ../../caliper-benchmarks/src/fabric/api/fixed-asset-base/collections-config.json
Ensure you are in the caliper-benchmarks
directory. As there a several benchmarks to choose from the example below just shows the get-asset.yaml
benchmark invocation
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/fabric/test-network.yaml --caliper-benchconfig benchmarks/api/fabric/get-asset.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。