区块链安全应用------压力测试

news/2024/5/11 1:17:04

测试要求:

  • 1. 对以下AccountManager智能合约进行压测(基础要求set函数测试,balanceOf涵为20分加分项)
  • 2. 在本地链进行测试,需要监控本地进程的资源使用情况。每个进程的multiOutput属性为Avg
  • 3. 需要将每一个更改的配置文件截图,和执行命令截图放在word中。提交word代码。

第一步:智能合约添加到caliper-bench中,操作和代码截图

在benchmarks/caliper-benchmarks/src/fisco-bcos/文件下创建AccountManager文件存放智能合约

mkdir -p /root/benchmarks/caliper-benchmarks/src/fisco-bcos/AccountManager
cd /root/benchmarks/caliper-benchmarks/src/fisco-bcos/AccountManager
vim AccountManager.sol

第二步:更改网络配置参数,操作和代码截图

  • a) 在/root/benchmarks/caliper-benchmarks/networks/fisco-bcos目录下创建test目录
  • b) 在该目录下添加网络配置文件fisco-bcos.json
mkdir -p /root/benchmarks/caliper-benchmarks/networks/fisco-bcos/test
cd /root/benchmarks/caliper-benchmarks/networks/fisco-bcos/test
vim fisco-bcos.json

 

{"caliper": {"blockchain": "fisco-bcos","command": {"start": "docker-compose -f networks/fisco-bcos/4nodes1group/docker-compose.yaml up -d; sleep 3s","end": "docker-compose -f networks/fisco-bcos/4nodes1group/docker-compose.yaml down"}},"fisco-bcos": {"config": {"privateKey": "bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad67dd","account": "0x64fa644d2a694681bd6addd6c5e36cccd8dcdde3"},"network": {"nodes": [{"ip": "127.0.0.1","rpcPort": "8914","channelPort": "20914"},{"ip": "127.0.0.1","rpcPort": "8915","channelPort": "20915"},{"ip": "127.0.0.1","rpcPort": "8916","channelPort": "20916"},{"ip": "127.0.0.1","rpcPort": "8917","channelPort": "20917"}],"authentication": {"key": "/home/myy/Desktop/benchmarks/caliper-benchmarks/networks/fisco-bcos/4nodes1group/sdk/node.key","cert": "/home/myy/Desktop/benchmarks/caliper-benchmarks/networks/fisco-bcos/4nodes1group/sdk/node.crt","ca": "/home/myy/Desktop/benchmarks/caliper-benchmarks/networks/fisco-bcos/4nodes1group/sdk/ca.crt"},"groupID": 1,"timeout": 100000},"smartContracts": [{"id": "helloworld","path": "src/fisco-bcos/helloworld/HelloWorld.sol","language": "solidity","version": "v0"},{"id": "parallelok","path": "src/fisco-bcos/transfer/ParallelOk.sol","language": "solidity","version": "v0"},{"id": "dagtransfer","address": "0x0000000000000000000000000000000000005002","language": "precompiled","version": "v0"},{"id": "AccountManager","path": "src/fisco-bcos/AccountManager/AccountManager.sol" ,"language": "solidity" ,"version": "v1"}]},"info": {"Version": "2.0.0","Size": "4 Nodes","Distribution": "Single Host"}
}

第三步:测试配置文件参数,操作和代码截图

  • a)在/root/benchmarks/caliper-benchmarks/benchmarks/samples/fisco-bcos目录下创建AccountManager文件
  • b)编辑配置测试文件配置
mkdir -p /root/benchmarks/caliper-benchmarks/benchmarks/samples/fiscobcos/AccountManagercd /root/benchmarks/caliper-benchmarks/benchmarks/samples/fiscobcos/AccountManagervim config.yaml

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#---
test:name: AccountManagerdescription: This is a AccountManager benchmark of FISCO BCOS for caliperclients:type: localnumber: 1rounds:- label: setAccountdescription: Test performance of getting accounttxNumber:- 10000rateControl:- type: fixed-rateopts:tps: 1000callback: /home/myy/Desktop/benchmarks/caliper-benchmarks/benchmarks/samples/fisco-bcos/AccountManager/set.jsmonitor:type:- docker- processdocker:name:- node0- node1- node2- node3process:- command: nodearguments: fiscoBcosClientWorker.jsmultiOutput: avginterval: 0.5

第四步:测试文件编写,操作和代码截图

  • a)在/root/benchmarks/caliper-benchmarks/benchmarks/samples/fiscobcos/AccountManager目录下编辑测试文件配置  
cd /root/benchmarks/caliper-benchmarks/benchmarks/samples/fiscobcos/AccountManagervim set.js

/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/'use strict';module.exports.info = ' setting account';let initMoney = 100000000;
let bc, contx;
let txnPerBatch;module.exports.init = function (blockchain, context, args) {txnPerBatch = 1;bc = blockchain;contx = context;return Promise.resolve();
};/*** Generates simple workload* @return {Object} array of json objects*/
function generateWorkload() {let workload = [];for (let i = 0; i < txnPerBatch; i++) {let w = {'transaction_type': 'set(string,uint256)','name': 'hello! - from ' + process.pid.toString(),'num': initMoney};workload.push(w);}return workload;
}module.exports.run = function () {let args = generateWorkload();return bc.invokeSmartContract(contx, 'AccountManager', 'v0', args, null);
};module.exports.end = function () {// Do nothingreturn Promise.resolve();
};

第五步:运行压测结果命令和结果截图

运行benchmark代码:

cd benchmarks
npx caliper benchmark run --caliper-workspace /home/myy/Desktop/benchmarks/caliper-benchmarks --caliper-benchconfig /home/myy/Desktop/benchmarks/caliper-benchmarks/benchmarks/samples/fisco-bcos/AccountManager/config.yaml --caliper-networkconfig /home/myy/Desktop/benchmarks/caliper-benchmarks/networks/fisco-bcos/4nodes1group/fisco-bcos.json

第六步:生成报告截图


http://www.mrgr.cn/p/22165840

相关文章

vscode 打代码光标特效

vscode 打代码光标特效 在设置里面找到settings 进入之后在代码最下方加入此代码 "explorer.confirmDelete": false,"powermode.enabled": true, //启动"powermode.presets": "fireworks", // 火花效果// particles、 simple-rift、e…

鸿蒙内核源码分析(任务调度篇) | 任务是内核调度的单元

任务即线程 在鸿蒙内核中&#xff0c;广义上可理解为一个任务就是一个线程 官方是怎么描述线程的 基本概念 从系统的角度看&#xff0c;线程是竞争系统资源的最小运行单元。线程可以使用或等待CPU、使用内存空间等系统资源&#xff0c;并独立于其它线程运行。 鸿蒙内核每个…

Rust序列化和反序列化

Rust 编写python 模块 必备库 docker 启动 nginx 服务 NGINX 反向代理配置

蛋糕购物商城

蛋糕购物商城 运行前附加数据库.mdf&#xff08;或使用sql生成数据库&#xff09; 登陆账号&#xff1a;admin 密码&#xff1a;123456 修改专辑价格时去掉&#xffe5;以及上传专辑图片 c#_asp.net 蛋糕购物商城 网上商城 三层架构 在线购物网站&#xff0c;电子商务系统 …

【Godot4.2】自定义Todo清单类 - myTodoList

概述 在写myList类的时候&#xff0c;就想到可以写一个类似的Todo清单类。 基础思路 本质还是在内部维护一个数组&#xff0c;在其基础上进行增删改查操作的封装为了方便存储数据&#xff0c;编写一个自定义内置类TodoItem&#xff0c;内部数组就变成了Array[TodoItem]类型的…

【前端开发基础知识快速入门】

前端开发基础知识&快速入门 一、VSCode 使用1.1 安装常用插件1.2 创建项目1.3 创建网页1.4 运行效果二、ES62.1 简介2.2 什么是 ECMAScript2.3 ES6 新特性2.3.1 let 声明变量2.3.2 const 声明常量(只读变量)2.3.3 解构表达式2.3.4 字符串扩展2.3.5 函数优化2.3.6 对象优化…

uniapp的bug们

1 uni-icons标签的数据绑定有问题 <uni-icons type="contact" class=" icon" size="25"></uni-icons><view>{{user_msg}}</view> <!-- 之所以不把{{user_msg}}写在uni-icons标签之内,是因为,uni-icons有一个bug,它不…

nvm基本使用

nvm基本使用 文章目录 nvm基本使用1.基本介绍2.下载地址3.常用指令 1.基本介绍 NVM是一个用于管理 Node.js 版本的工具。它允许您在同一台计算机上同时安装和管理多个 Node.js 版本&#xff0c;针对于不同的项目可能需要不同版本的 Node.js 运行环境。 NVM 主要功能&#xff…

easyExcel快速入门

目录 &#x1f9c2;1.简单介绍 &#x1f32d;2.快速入门 &#x1f953;1.导入依赖 &#x1f37f;2.导出到excel &#x1f38f;3.读入数据 &#x1f389;4.下载 1.简单介绍 传统操作Excel大多都是利用Apach POl进行操作的,但是POI框架并不完善,使用过程非常繁琐且有较多…

C语言学习/复习36

一、程序的环境与预处理 二、翻译环境与执行环境 三、运行环境 四、预编译(预处理)详解

docker 基本命令

目录 一、docker 镜像操作命令 1.1.查询软件镜像 1.2.docker pull&#xff1a;下载镜像 1.3.docker push&#xff1a;上传镜像 1.4.docker images&#xff1a;查看本地镜像 1.5.docker inspect &#xff1a;获取镜像详细信息 1.6.docker tag&#xff1a;添加镜像标签 …

spring boot3单模块项目工程搭建-上(个人开发模板)

⛰️个人主页: 蒾酒 &#x1f525;系列专栏&#xff1a;《spring boot实战》 目录 写在前面 上文衔接 常规目录创建 common目录 exception.handle目录 result.handle目录 controller目录 service目录 mapper目录 entity目录 test目录 写在最后 写在前面 本文…

url规则

uniapp的url最后加了斜杠,如同,就不能生效了. 与之相对的django必须最后加斜杠,否则报错

英智数字孪生机器人解决方案,赋能仓库物流模式全面升级

工业机械臂、仓储机器人、物流机器人等模式的机器人系统在现代产业中扮演着愈发重要的角色&#xff0c;他们的发展推动了自动化和智能化水平的提高&#xff0c;有助于为制造业、物流业、医疗保健业和服务业等行业创造新效率并提升人们的生活质量。 行业面临的挑战 机器人开发、…

Linux - tar (tape archive)

tar 的全称是 Tape Archive。它最初是在 Unix 系统中用于将数据写入磁带的工具&#xff0c;但现在它通常用于创建、维护、修改和提取文件的归档文件。尽管 tar 可以用于压缩和解压缩文件&#xff0c;但它本身并不进行压缩&#xff0c;而是通常与 gzip 或 bzip2 等压缩工具一起使…

学习STM32第十六天

RTC实时时钟 一、简介 RTC是一个独立的BCD格式定时器&#xff0c;提供一个时钟日历&#xff0c;两个可编程报警中断&#xff0c;一个具有中断功能周期性可编程唤醒标志&#xff0c;RTC和时钟配置系统处于后备区域。 通过两个32位寄存器以BCD格式实现秒、分钟、小时&#xff08…

SAP-ERP TM运输管理模块详解-1

简介 SAP中的运输功能(即TM模块,属于SD的子模块)是后勤执行的一部分,用于自动计算交货成本。也就是说,SAP可以让系统自动对销售发货的商品计算运费,对于运费占这个成本很大比重的销售模式,可以使用该功能。运输功能相对于SD其他模块,相对比较独立的,应用面不是很广。其…

新时代凌迟:考研

我不喜欢上班&#xff0c;但我很欣赏老板的品味&#xff0c;因为咱们公司竟然还在订阅报纸&#xff0c;而且只有一份&#xff0c;《中国青年报》。 这份报纸我最喜欢看的是“冰点周刊”专栏&#xff0c;因为这个栏目能让读者相信&#xff1a;报纸远远可以超越一天的生命。 昨天…

【Linux 进程间通信】管道

文章目录 1.为什么操作系统需要向用户提供进程间通信方式&#xff1f;2.进程间通信的种类3.管道3.1管道的作用3.2管道的本质3.3管道的通信原理3.4管道的分类 1.为什么操作系统需要向用户提供进程间通信方式&#xff1f; ①&#x1f34e;资源共享&#xff1a;有的时候两个进程需…

oracle操作系统OS认证和密码文件认证

1 说明 1.1 常见认证方式 Oracle登录认证方式主要涉及到如何验证用户身份以访问数据库。Oracle数据库提供了多种认证机制来确保数据的安全性和访问控制&#xff0c;每种方式都有其特定的使用场景和安全性考虑。以下是Oracle中常见的登录认证方式&#xff1a; 1、基于操作系统…