当前位置:网站首页>Hyperledger caliper is built on fabric for performance test
Hyperledger caliper is built on fabric for performance test
2022-07-27 19:50:00 【Beihai shad is awake】
Fabric Introduce ( Recommended articles )
Hyperledger( Super ledger ) yes Linux Projects under the foundation ,Fabric yes Hyperledger Blockchain project is the earliest and most widely used blockchain project in the project , By the first IBM Development , Later donated to the foundation .
- It is an open source enterprise level distributed ledger technology platform that needs to be licensed
- Is a highly modular and configurable architecture (a,b,c)
- Supports pluggable implementations of different components
- Smart contracts support multilingualism :go,java,node.js etc.
Hyperledger Caliper Introduce ( Official documents )
Hyperledger Caliper It is a general blockchain performance testing framework , It allows users to test different blockchain solutions using custom use cases , And get a set of performance test results .
Caliper Currently, the following blockchain platforms are supported :
- Hyperledger Besu
- Hyperledger Burrow
- Ethereum
- Hyperledger Fabric
- FISCO BCOS
- Hyperledger Iroha
- Hyperledger Sawtooth
Caliper Currently supported performance metrics include :
- transaction / Read throughput
- transaction / Read delay : Minimum 、 Maximum 、 Average 、 percentage
- resource consumption :CPU、 Memory 、 The Internet IO…
install nodejs
This test requires docker、docker-compose、go、nodejs Environment , There is no installation introduction here , Just a brief introduction to nodejs Installation .
Here I use the following versions node, Which read the wrong information to use . But every time you install a new one, you need to rebuild the installation node-gyp Build automation tools . Go to node Of bin Look in the catalogue to see if there is node-gyp Command is enough .

wget https://nodejs.org/dist/v16.15.0/node-v16.15.0-linux-x64.tar.xz
tar -xvf node-v16.15.0-linux-x64.tar.xz
sudo vim /etc/profile
export NODE_HOME= Your own installation directory
export PATH=$NODE_HOME/bin:$PATH
source /etc/profile
node -v
# install node-gyp Build automation tools
sudo npm install -g node-gyp
build Hyperledger caliper( Official website )
Before the test is to ensure that our blockchain project has been successfully installed , The previous related steps have been completed .
You can also refer to the official website , Less very detailed .
Create and initialize Fabric The Internet
cd test-network
./network.sh up createChannel
establish Caliper The workspace
In the and network.sh Create... In the same level directory caliper-workspace Folder and create three subfolders
mkdir -p caliper-workspace/{
networks,benchmarks,workload}
Initialize workspace
Get into caliper-workspace Directory execute command
npm init -y
install caliper-cli, This will download the used dependencies to the current workspace node_modules Under the table of contents
# The version should match ,0.4 Corresponding fabric2.x,0.3 Corresponding fabric1.4
npm install --only=prod @hyperledger/[email protected]
matters needing attention :
linux For safety's sake ,root User execution npm The command will be replaced by a nobody Users of , And this user basically has no permission , So when you execute this command, you can log in with other users , Then give other users to operate our fabric Permissions of the workspace .( Reference article )
# The following command enables all users of this folder to operate
chmod -R 777 /home/workspace/
Bind terminal SDK
npx caliper bind --caliper-bind-sut fabric:2.1
Build test files
Build the load module of the test work .
stay workload Create under folder createAsset.js file , Create test account command , Randomly generate accounts id And make an initialization call .
'use strict';
const {
WorkloadModuleBase } = require('@hyperledger/caliper-core');
class MyWorkload extends WorkloadModuleBase {
constructor() {
super();
}
async initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext) {
await super.initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext);
}
async submitTransaction() {
const randomId = Math.random();
const assetID = `${
this.roundArguments.prefix}_${
randomId}`;
console.log(`Creating asset ${
assetID}`);
const request = {
contractId: this.roundArguments.contractId,
contractFunction: 'CreateAsset',
invokerIdentity: '[email protected]',
contractArguments: [assetID,'blue','20','500','500'],
readOnly: false
};
await this.sutAdapter.sendRequests(request);
}
async cleanupWorkloadModule() {
}
}
function createWorkloadModule() {
return new MyWorkload();
}
module.exports.createWorkloadModule = createWorkloadModule;
stay networks Create a folder named networkConfig.json The file of .
Here's an explanation ,networkConfig.json In your file path The path is the path corresponding to the file in your project .
Other names and host The configuration inside corresponds to , If you don't modify it, don't modify it .
{
"version" : "1.0",
"name": "Caliper test",
"caliper" : {
"blockchain": "fabric"
},
"clients": {
"[email protected]": {
"client": {
"credentialStore": {
"path": "/tmp/org1",
"cryptoStore": {
"path": "/tmp/org1"
}
},
"organization": "Org1",
"clientPrivateKey": {
"path": "/root/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/priv_sk"
},
"clientSignedCert": {
"path": "/root/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
},
"connection": {
"timeout": {
"peer": {
"endorser": "3000"
}
}
}
}
}
},
"channels": {
"mychannel": {
"created" : true,
"orderers":[
"orderer.example.com"
],
"peers":{
"peer0.org1.example.com": {
}
},
"contracts": [
{
"id":"basic",
"version":"1.0"
}
]
}
},
"organizations":{
"Org1": {
"mspid": "Org1MSP",
"peers": [
"peer0.org1.example.com"
]
}
},
"orderers":{
"orderer.example.com": {
"url": "grpcs://orderer.example.com:7050",
"tlsCACerts": {
"path": "/root/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
},
"grpcOptions": {
"ssl-target-name-override": "orderer.example.com"
}
}
},
"peers": {
"peer0.org1.example.com": {
"url": "grpcs://peer0.org1.example.com:7051",
"tlsCACerts": {
"path": "/root/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com",
"hostnameOverride": "peer0.org1.example.com"
}
}
}
}
Build benchmark test configuration file
stay benchmarks Create a folder named myAssetBenchmark.yaml
The benchmark configuration file defines the benchmark rounds and references the defined workload modules . It will specify the number of test workers to use when generating the load 、 Number of test rounds 、 Duration of each round 、 Rate control applied to the transaction load during each round and monitor related options .
In this file, we can also configure the total transaction volume of the test 、 Sent tps Etc .
- tps: Transaction sending rate
- txNumber: Total transaction delivery

test:
# The name of the test
name: basic-contract-benchmark
# Basic descriptive information
description: test benchmark
workers:
type: local
number: 5
rounds:
- label: createAsset-total20
description: create asset benchmark
# The total number of transactions sent
txNumber: 20
rateControl:
type: fixed-rate
opts:
# The rate at which transactions are sent
tps: 2
workload:
# This configuration we just created js Path to file
module: workload/createAsset.js
arguments:
prefix: assetv1
assets: 5
contractId: basic
monitors:
resource:
- module: docker
options:
interval: 5
containers:
- all
To configure host file
vim /etc/hosts
# Add the following domain name resolution
127.0.0.1 peer0.org1.example.com
127.0.0.1 peer0.org2.example.com
127.0.0.1 peer1.org1.example.com
127.0.0.1 peer1.org2.example.com
127.0.0.1 orderer.example.com
function caplier Perform performance testing
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/networkConfig.json --caliper-benchconfig benchmarks/myAssetBenchmark.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
After running, a report.html file 
Press on this report File can .
边栏推荐
- The go zero singleton service uses generics to simplify the registration of handler routes
- C language: 9. Return in main function
- DatePicker(日期选择器)与TimePicker(时间选择器)
- C language: 10. Input stream, output stream, error stream
- MarqueeTextview(跑马灯)
- 【深度学习基础知识 - 49】Kmeans
- 估值超156亿元!华勤通讯完成10亿元B轮融资!高通创投、英特尔资本领投
- Binary search tree
- rxbinding
- IDEA:解决代码没有提示问题
猜你喜欢

S32k series chips -- Introduction

rxbinding

SQlife(数据库)

Fabric上搭建Hyperledger caliper进行性能测试

Chinese character search Pinyin wechat applet project source code

C language: 8. Makefile preparation

Original pw4203 step-down 1-3 lithium battery charging chip
技术实践干货 | 初探大规模 GBDT 训练

Tab control of MFC advanced control (CTabCtrl)

SystemService(系统服务)
随机推荐
[basic knowledge of in-depth learning - 40] Why does CNN have more advantages than DNN in the field of images
Hdu1573 x problem [univariate linear congruence equations]
嵌入式C语言指针别名
Fabric上搭建Hyperledger caliper进行性能测试
Turn Hyper-V on and off
Session攻击
Surpass Huawei? Ericsson has won more than 75 5g commercial contracts
OPPO发布首款AR眼镜,宣布未来3年投入500亿进行研发
Embedded C language pointer alias
IDEA:解决代码没有提示问题
英特尔发布Horse Ridge芯片:22nm工艺,能够控制多个量子位
redis底层数据结构详解
【日常积累 - 06】查看cuda和cudnn版本
技术实践干货 | 初探大规模 GBDT 训练
嵌入式C语言循环展开
influxDB系列(三)influxDB配置文件详解
一种比读写锁更快的锁,还不赶紧认识一下
Adhering to the integration of software and hardware, one Hengke makes efforts to the intelligent educational robot market
Debian recaptured the "debian.community" domain name, but it's still not good to stop and rest
What's new in helix QAC 2022.2, the ace code static testing tool (1)