CN115102866B - A consensus algorithm-oriented block chain TPS estimation method and its verification method - Google Patents
A consensus algorithm-oriented block chain TPS estimation method and its verification method Download PDFInfo
- Publication number
- CN115102866B CN115102866B CN202210634856.9A CN202210634856A CN115102866B CN 115102866 B CN115102866 B CN 115102866B CN 202210634856 A CN202210634856 A CN 202210634856A CN 115102866 B CN115102866 B CN 115102866B
- Authority
- CN
- China
- Prior art keywords
- blockchain
- tps
- node
- transaction
- time
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 38
- 238000012795 verification Methods 0.000 title claims abstract description 28
- 238000012360 testing method Methods 0.000 claims abstract description 39
- 238000004891 communication Methods 0.000 claims abstract description 35
- 238000013178 mathematical model Methods 0.000 claims abstract description 32
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 4
- 238000004364 calculation method Methods 0.000 claims description 17
- 238000012545 processing Methods 0.000 claims description 12
- 238000004806 packaging method and process Methods 0.000 claims description 7
- 238000004458 analytical method Methods 0.000 claims description 5
- 230000003068 static effect Effects 0.000 claims description 4
- 230000005540 biological transmission Effects 0.000 claims description 3
- 230000001419 dependent effect Effects 0.000 claims description 2
- 230000008676 import Effects 0.000 claims description 2
- 238000010276 construction Methods 0.000 abstract description 4
- 230000008569 process Effects 0.000 abstract description 3
- 238000010586 diagram Methods 0.000 description 8
- 238000005516 engineering process Methods 0.000 description 5
- 238000004590 computer program Methods 0.000 description 4
- 238000011161 development Methods 0.000 description 4
- 238000013473 artificial intelligence Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 230000008520 organization Effects 0.000 description 2
- 238000011160 research Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012858 packaging process Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/14—Network analysis or design
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/14—Network analysis or design
- H04L41/145—Network analysis or design involving simulating, designing, planning or modelling of a network
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/14—Network analysis or design
- H04L41/147—Network analysis or design for predicting network behaviour
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明公开了一种面向共识算法的区块链TPS估算方法及其验证方法,该方法通过对基于拜占庭容错算法的区块链系统交易流程进行分析,建立区块链TPS与节点通信和计算能力之间的数学模型,以进行TPS估算;准确性验证方法通过搭建不同结构的区块链网络进行TPS测试,将实际的测试结果与数学模型的预测结果进行比较,以此来验证区块链TPS数学模型的准确性。本发明实现了在区块链系统部署前对区块链网络性能的预测,预测误差不超过10%,该数学模型方便实际部署区块链系统时进行区块链节点的硬件选购和网络搭建成本估计,并且可以通过对区块链性能的估算来验证在特定网络结构下实际部署区块链系统的可行性。
The invention discloses a consensus algorithm-oriented block chain TPS estimation method and a verification method thereof. The method analyzes the block chain system transaction process based on a Byzantine fault-tolerant algorithm, and establishes a mathematical model between the block chain TPS and node communication and computing capabilities to perform TPS estimation; the accuracy verification method uses block chain networks with different structures to perform TPS tests, and compares the actual test results with the prediction results of the mathematical model to verify the accuracy of the block chain TPS mathematical model. The present invention realizes the prediction of the performance of the blockchain network before the deployment of the blockchain system, and the prediction error does not exceed 10%. The mathematical model is convenient for the hardware selection of the blockchain nodes and the cost estimation of the network construction when the blockchain system is actually deployed, and the feasibility of actually deploying the blockchain system under a specific network structure can be verified by estimating the performance of the blockchain.
Description
技术领域technical field
本发明属于通信网络领域,具体涉及一种面向共识算法的区块链TPS估算方法及其验证方法。The invention belongs to the field of communication networks, and in particular relates to a consensus algorithm-oriented block chain TPS estimation method and a verification method thereof.
背景技术Background technique
经过多年的发展,物联网应用取得长足发展。然而,大规模发展物联网仍然面临着一些关键性挑战,特别是如何平衡建设/运营成本与服务能力/效率问题。区块链技术有助于解决物联网跨行业、部门、跨网络服务系统的资源共享、数据安全传输、信用体系的构建等方面的问题。同时,大规模的互联网用户群体不仅是各类应用服务的使用者,更是网络空间大数据和应用服务的贡献者,其构成了支撑大量成功应用的群智资源。After years of development, IoT applications have made great strides. However, the large-scale development of the Internet of Things still faces some key challenges, especially how to balance construction/operating costs and service capabilities/efficiency issues. Blockchain technology helps to solve the problems of cross-industry, departmental, and cross-network service system resource sharing, data security transmission, and credit system construction of the Internet of Things. At the same time, large-scale Internet user groups are not only users of various application services, but also contributors to cyberspace big data and application services, which constitute the group intelligence resources that support a large number of successful applications.
来自人工智能、大数据、计算机协同工作和人机交互等领域的研究人员从不同的学术视角对此开展了研究,提出了众包、人计算、群体智能和社会计算等研究方向,同时工业界也推出了大量支撑数据协同的平台与应用。数据协同计算为大数据、统计机器学习等人工智能新技术的发展提供了极大的便利,而其核心在于对开放网络环境下的群智资源进行有效管理和协同利用以实现群体智能的最大化,若基于智能合约、及安全多方计算等技术,构建联盟链数据协同框架,则可以利用区块链技术可靠安全地进行数据交互,并且保证所有记录透明可追溯。Researchers from the fields of artificial intelligence, big data, computer collaborative work, and human-computer interaction have conducted research on this from different academic perspectives, and proposed research directions such as crowdsourcing, human computing, swarm intelligence, and social computing. At the same time, the industry has also launched a large number of platforms and applications that support data collaboration. Data collaborative computing provides great convenience for the development of new artificial intelligence technologies such as big data and statistical machine learning, and its core lies in the effective management and collaborative utilization of group intelligence resources in an open network environment to maximize group intelligence. If the alliance chain data collaboration framework is built based on technologies such as smart contracts and secure multi-party computing, blockchain technology can be used to reliably and safely perform data interactions, and ensure that all records are transparent and traceable.
然而,随着智慧城市、共享经济等业务的快速发展,区块链实际部署性能的未知性也成为区块链系统没有广泛应用的原因之一,因此急需一种在实际部署区块链系统前对区块链系统性能的预测方法。However, with the rapid development of smart cities, sharing economy and other businesses, the unknown of the actual deployment performance of the blockchain has become one of the reasons why the blockchain system is not widely used. Therefore, there is an urgent need for a method to predict the performance of the blockchain system before the actual deployment of the blockchain system.
发明内容Contents of the invention
为了解决上述背景技术提到的技术问题,本发明提出了一种面向共识算法的区块链TPS估算方法及其验证方法。In order to solve the technical problems mentioned above in the background technology, the present invention proposes a consensus algorithm-oriented blockchain TPS estimation method and a verification method thereof.
为了实现上述技术目的,本发明的技术方案为:In order to realize above-mentioned technical purpose, technical scheme of the present invention is:
一种面向共识算法的区块链TPS估算方法,包括以下步骤:A block chain TPS estimation method oriented to consensus algorithm, comprising the following steps:
S1,根据区块链的交易格式和测试TPS使用的智能合约,计算区块链系统发送的实际交易大小Stx,采用的测试交易内容和格式均相同;S1, according to the transaction format of the blockchain and the smart contract used by the test TPS, calculate the actual transaction size S tx sent by the blockchain system, using the same test transaction content and format;
S2,根据实际部署的网络节点情况,获取每条交易在客户端处生成的时间Ttxbuild,计算每条交易由客户端生成并发送到该客户端连接的区块链节点的时间Ttxsend;S2, according to the actual deployed network nodes, obtain the time T txbuild of each transaction generated at the client, and calculate the time T txsend of each transaction generated by the client and sent to the blockchain node connected to the client;
S3,获取交易的验签时间Ttxcheck,每条交易的验签时间相同,且验签时间在交易的处理总时间中只考虑一次;S3, get the signature verification time T txcheck of the transaction, the signature verification time of each transaction is the same, and the signature verification time is only considered once in the total transaction processing time;
S4,获取区块的打包时间Tblockpk、区块头的大小Sblockhead和每个区块包含的交易数量n,计算交易打包区块并发送到其他的区块链节点的总时间Tblocksend;S4, obtain the packaging time T blockpk of the block, the size of the block header S blockhead and the number n of transactions contained in each block, and calculate the total time T blocksend of the transaction packaging block and sending it to other blockchain nodes;
S5,获取区块验证的时间Tblockcheck和每条交易执行的时间Ttx,计算每个区块验证并在节点上执行的时间Tblockdone;S5, obtain the block verification time T blockcheck and the execution time T tx of each transaction, and calculate the time T blockdone of each block verification and execution on the node;
S6,获取交易落盘的时间Tblocksave;S6, obtain the time T blocksave of the transaction order;
S7,根据步骤S2~S6获取的Ttxbuild、Ttxsend、Tblockpk、Tblocksend、Tblockcheck、Tblockdone、Tblocksave,计算完成一个区块的总时间Ttot;将Ttot分成通信时间Tcomm和计算时间Tcomp;通过进行多次单节点交易处理的方式得到每条交易处理的平均时间Ttxcomp;S7, according to T txbuild , T txsend , T blockpk , T blocksend , T blockcheck , T blockdone , T blocksave obtained in steps S2-S6, calculate the total time T tot of completing a block; divide T tot into communication time T comm and calculation time T comp ; obtain the average time T txcomp of each transaction by performing multiple single-node transaction processing;
S8,建立区块链TPS数学模型,以节点的通信能力为自变量导入模型绘制对区块链系统的TPS估算曲线。S8. Establish a blockchain TPS mathematical model, and use the communication capability of the node as an independent variable to import the model to draw a TPS estimation curve for the blockchain system.
优选地,所述步骤S2具体指:将每个区块链节点最大的上下行速率上限记为C,则每条交易在两个区块链节点之间传输的时间为获取每条交易在区块链节点处生成的时间Ttxbuild,则每条交易由客户端生成并发送到区块链节点的时间为/> Preferably, the step S2 specifically refers to: record the maximum uplink and downlink speed limit of each blockchain node as C, then the time for each transaction to be transmitted between two blockchain nodes is Get the time T txbuild of each transaction generated at the blockchain node, then the time for each transaction generated by the client and sent to the blockchain node is />
优选地,所述步骤S4中交易打包区块并发送到其他区块链节点的总时间Preferably, in the step S4, the total time for the transaction to package the block and send it to other blockchain nodes
Tblocksend的计算公式如下:The calculation formula of T blocksend is as follows:
其中C为每个区块链节点最大的上下行速率上限。Where C is the maximum uplink and downlink rate limit of each blockchain node.
优选地,所述步骤S5中每个区块验证并在节点上执行的时间Tblockdone的计Preferably, in the step S5, the time T blockdone of each block verification and execution on the node is counted
算公式如下:The calculation formula is as follows:
Tblockdone=Tblockcheck+nTtx。T blockdone = T blockcheck + nT tx .
优选地,所述步骤S7中完成一个区块的总时间Ttot的计算公式如下:Preferably, the calculation formula of the total time T tot for completing a block in the step S7 is as follows:
Ttot=n(Ttxbuild+Ttxsend+Ttxcheck)+Tblockpk+Tblocksend+Tblockdone+Tconsensus+Tblocksave T tot =n(T txbuild +T txsend +T txcheck )+T blockpk +T blocksend +T blockdone +T consensus +T blocksave
其中Tconsensus指区块的共识时间,在计算通信时间时忽略不计;Among them, T consensus refers to the consensus time of the block, which is ignored when calculating the communication time;
通信时间Tcomm的计算公式如下:The formula for calculating the communication time T comm is as follows:
式中,N为区块链节点的数量,C为每个区块链节点最大的上下行速率上限;In the formula, N is the number of blockchain nodes, and C is the maximum uplink and downlink rate limit of each blockchain node;
计算时间Tcomp的计算公式如下:The calculation formula of the calculation time T comp is as follows:
Tcomp=n(Ttxbuild+Ttxcheck)+Tblockpk+Tblockcheck+nTtx+Tblocksave。T comp =n(T txbuild +T txcheck )+T blockpk +T blockcheck +nT tx +T blocksave .
优选地,所述步骤S8中区块链TPS数学模型计算公式表达如下:Preferably, the calculation formula of the block chain TPS mathematical model in the step S8 is expressed as follows:
式中,N为区块链节点的数量,C为每个区块链节点最大的上下行速率上限,Stx为每条交易的大小。In the formula, N is the number of blockchain nodes, C is the maximum uplink and downlink speed limit of each blockchain node, and S tx is the size of each transaction.
一种面向共识算法的区块链TPS估算方法的准确性验证方法,包括如下步骤:A method for verifying the accuracy of a consensus algorithm-oriented block chain TPS estimation method, comprising the steps of:
步骤一,搭建与区块链TPS数学模型分析中使用的网络结构相同的区块链网络,并在所述区块链网络上部署测试智能合约;Step 1, build a blockchain network with the same network structure as that used in the blockchain TPS mathematical model analysis, and deploy and test smart contracts on the blockchain network;
步骤二,在区块链网络外的Linux主机上部署Caliper区块链性能测试软件;Step 2, deploy the Caliper blockchain performance testing software on the Linux host outside the blockchain network;
步骤三,在每个区块链节点上安装系统带宽限制软件,修改每个节点的最大上下行带宽,验证不同速率下区块链TPS数学模型预测的结果与实际TPS的误差;Step 3, install system bandwidth limiting software on each blockchain node, modify the maximum uplink and downlink bandwidth of each node, and verify the error between the predicted results of the blockchain TPS mathematical model and the actual TPS at different rates;
步骤四,修改完成节点的最大上下行带宽后,通过区块链网络外的Linux主机使用Caliper区块链性能测试软件对已部署的区块链网络发起多轮TPS测试,并记录测试的实际TPS结果,对相同速率下的多组数据取平均值;步骤五,对实际结果绘制曲线图,与区块链TPS数学模型预测得出的TPS理论值进行比较,并分别计算不同的节点通信能力下数学模型预测得出的结果与实际测试的误差,判断区块链TPS估算方法的准确性。Step 4: After modifying the maximum uplink and downlink bandwidth of the node, use the Caliper blockchain performance testing software to initiate multiple rounds of TPS tests on the deployed blockchain network through the Linux host outside the blockchain network, and record the actual TPS results of the test, and take the average of multiple sets of data at the same rate; Step 5, draw a curve for the actual results, compare it with the TPS theoretical value predicted by the blockchain TPS mathematical model, and calculate the errors predicted by the mathematical model under different node communication capabilities and the actual test to judge the accuracy of the blockchain TPS estimation method .
优选地,所述步骤一中搭建与区块链TPS数学模型结构相同的区块链网络,具体包括以下步骤:Preferably, in the first step, a block chain network with the same structure as the block chain TPS mathematical model is built, specifically including the following steps:
S101,提供多个物理机,多个物理机之间通过路由器相互访问,配置物理机的静态IP地址,并在命令行中使用Ping命令检测各个区块链节点之间的通信情况;S101, provide multiple physical machines, and multiple physical machines access each other through a router, configure the static IP address of the physical machine, and use the Ping command in the command line to detect the communication between each blockchain node;
S102,在物理机上配置区块链节点运行所需的环境;S102, configuring the environment required for the operation of the blockchain node on the physical machine;
S103,下载建链脚本,根据区块链网络的实际情况修改ipconf配置文件,将区块链节点的ip地址与所属机构在ipconf配置文件对应配置;S103, downloading the chain building script, modifying the ipconf configuration file according to the actual situation of the blockchain network, and correspondingly configuring the ip address of the blockchain node and the affiliated institution in the ipconf configuration file;
S104,执行建链脚本,根据ipconf配置文件中的配置自动生成搭建区块链网络所需的节点证书,通过SCP方式将生成的证书发送至各个区块链节点;S104, execute the chain building script, automatically generate the node certificates required to build the blockchain network according to the configuration in the ipconf configuration file, and send the generated certificates to each blockchain node through SCP;
S105,编写脚本,逐个访问区块链节点,分别在区块链网络内的每个Linux主机上执行区块链节点启动程序,所述启动程序将在区块链节点下运行docker容器,将预先设定的docker容器端口映射到物理机端口上实现与其他docker容器的通信;S105, writing a script, accessing the blockchain nodes one by one, respectively executing the blockchain node startup program on each Linux host in the blockchain network, the startup program will run the docker container under the blockchain node, and map the preset docker container port to the physical machine port to realize communication with other docker containers;
S106,通过TC指令禁止两个节点之间的互相访问,被禁止的节点在获取对方发来的交易或区块时,需等待区块链网络中其他节点收到交易后的广播;S106, prohibiting mutual access between two nodes through the TC command, when the prohibited node obtains the transaction or block sent by the other party, it needs to wait for the broadcast after receiving the transaction from other nodes in the blockchain network;
S107,全部区块链节点启动完毕后,选择任意一个区块链节点,执行查看命令,并观察是否所有区块链网络中的节点都能够通过直接或多条的方式互相发现。S107, after all the blockchain nodes are started, select any blockchain node, execute the view command, and observe whether all the nodes in the blockchain network can discover each other directly or in multiple ways.
优选地,所述步骤三中修改每个节点的最大上下行速率具体包括以下步骤:S301,在每个物理机上下载wondershaper带宽限制软件;Preferably, modifying the maximum uplink and downlink rate of each node in the step 3 specifically includes the following steps: S301, downloading the wondershaper bandwidth limiting software on each physical machine;
S302,编写自动化脚本SpeedControl.sh,将需要限制的上下行带宽分别作为脚本的两个输入值;S302, writing the automation script SpeedControl.sh, using the uplink and downlink bandwidths to be limited as the two input values of the script respectively;
S303,再在所有区块链节点上安装iperf3带宽测试软件;S303, installing iperf3 bandwidth testing software on all blockchain nodes;
S304,执行SpeedControl.sh,将节点带宽限制为设定值;S304, execute SpeedControl.sh, and limit the node bandwidth to a set value;
S305,启动iperf3带宽测试软件,测试任意两个节点之间的通信带宽以验证带宽限制是否起作用。S305, start the iperf3 bandwidth testing software, and test the communication bandwidth between any two nodes to verify whether the bandwidth limitation works.
优选地,所述步骤四具体包括以下步骤:Preferably, said step four specifically includes the following steps:
S401,从Github网站下载Caliper开源代码;S401, download the Caliper open source code from the Github website;
S402,在区块链网络外的一台Linux主机上配置Caliper的依赖环境;S402, configuring the dependent environment of Caliper on a Linux host outside the blockchain network;
S403,在Linux系统中部署Caliper,并将Caliper软件与实际的区块链平台S403, deploy Caliper in the Linux system, and integrate the Caliper software with the actual blockchain platform
进行绑定;bind;
S404,修改Caliper测试所需的配置文件config.yaml,将文件config.yamlS404, modify the configuration file config.yaml required for the Caliper test, and convert the file config.yaml
中的测试智能合约方法改为实际部署的智能合约方法;The test smart contract method in the test is changed to the actual deployed smart contract method;
S405,启动Caliper软件进行TPS测试。S405, start the Caliper software to perform the TPS test.
采用上述技术方案带来的有益效果:The beneficial effect brought by adopting the above-mentioned technical scheme:
(1)本方法基于交易流程分析,建立了区块链网络TPS与区块链节点的通信能力、计算能力之间的数学模型,实现了在区块链系统部署前对区块链网络性能的预测,该数学模型方便实际部署区块链系统时进行区块链节点的硬件选购和网络搭建成本估计,并且可以通过对区块链性能的估算来验证在特定网络结构下实际部署区块链系统的可行性。(1) Based on the analysis of the transaction process, this method establishes a mathematical model between the blockchain network TPS and the communication and computing capabilities of the blockchain nodes, and realizes the prediction of the performance of the blockchain network before the deployment of the blockchain system. This mathematical model is convenient for the hardware selection of the blockchain nodes and the cost estimation of the network construction when the blockchain system is actually deployed, and the feasibility of actually deploying the blockchain system under a specific network structure can be verified by estimating the performance of the blockchain.
(2)本方法基于搭建的实际区块链平台进行测试TPS性能测试,将测试结果与数学模型相比较,以此验证建立的数学模型的准确性,得出验证结果最大预测误差不超过10%。(2) This method tests the TPS performance based on the actual blockchain platform built, and compares the test results with the mathematical model to verify the accuracy of the established mathematical model, and obtains that the maximum prediction error of the verification result does not exceed 10%.
附图说明Description of drawings
图1是本发明实施例的区块链系统节点身份及功能示意图;Fig. 1 is a block chain system node identity and function schematic diagram of the embodiment of the present invention;
图2是本发明实施例的基于PBFT的区块链的流程示意图;FIG. 2 is a schematic flow diagram of a PBFT-based block chain according to an embodiment of the present invention;
图3是本发明实施例的区块链系统交易结构示意图;Fig. 3 is a schematic diagram of the block chain system transaction structure of the embodiment of the present invention;
图4是本发明实施例的基于PBFT区块链的交易验签的流程示意图;Fig. 4 is a schematic flow chart of transaction verification based on PBFT block chain according to an embodiment of the present invention;
图5是本发明实施例的区块链共识节点打包交易的流程示意图;Fig. 5 is a schematic flow diagram of a block chain consensus node packaging transaction according to an embodiment of the present invention;
图6是本发明实施例的区块链全网节点执行区块内部交易的流程示意图;Fig. 6 is a schematic flow diagram of the block chain internal transaction executed by the whole network node of the block chain according to the embodiment of the present invention;
图7是发明实施例的单节点交易处理平均时间与交易数量的关系图;Fig. 7 is a relationship diagram between the average time of single-node transaction processing and the number of transactions in the embodiment of the invention;
图8是本发明实施例的基于PBFT的区块链系统TPS数学模型图;Fig. 8 is a block chain system TPS mathematical model diagram based on PBFT of the embodiment of the present invention;
图9是本发明实施例的用于对区块链系统TPS数学模型进行验证的实际结构图;Fig. 9 is an actual structural diagram for verifying the TPS mathematical model of the block chain system according to the embodiment of the present invention;
图10是本发明实施例的实际测试TPS与数学模型预测的TPS值对比图。Fig. 10 is a comparison chart of the actual test TPS and the TPS value predicted by the mathematical model of the embodiment of the present invention.
具体实施方式Detailed ways
以下将结合附图,对本发明的技术方案进行详细说明。The technical solutions of the present invention will be described in detail below in conjunction with the accompanying drawings.
根据本发明分析的基于PBFT的区块链网络结构如图1示出。基于PBFT的区块链网络节点主要有接入节点、共识节点、全网节点这几种角色,每个角色负责不同的职责。The PBFT-based blockchain network structure analyzed according to the present invention is shown in FIG. 1 . PBFT-based blockchain network nodes mainly have several roles: access node, consensus node, and network-wide node. Each role is responsible for different responsibilities.
参见图2,本发明提出了一种面向PBFT共识区块链网络的TPS预测方法,该方法对基于拜占庭容错算法的区块链系统进行交易流程分析,交易处理流程包括:交易生成、交易广播、交易打包、交易执行、交易共识、交易落盘,本发明提出了一种面向PBFT共识区块链网络的TPS预测方法,包括:Referring to Figure 2, the present invention proposes a TPS prediction method oriented to the PBFT consensus blockchain network. The method analyzes the transaction flow of the blockchain system based on the Byzantine fault-tolerant algorithm. The transaction processing flow includes: transaction generation, transaction broadcast, transaction packaging, transaction execution, transaction consensus, and transaction placement. The present invention proposes a TPS prediction method oriented to the PBFT consensus blockchain network, including:
S1,根据区块链的交易格式和根据测试TPS使用的智能合约,计算区块链系统发送的实际交易大小记为Stx方便分析,采用的测试交易内容、格式均相同;S1. According to the transaction format of the blockchain and the smart contract used by the test TPS, calculate the actual transaction size sent by the blockchain system and record it as S tx for easy analysis. The test transaction content and format used are the same;
参见图3,上述区块链交易格式,包括图中的内容,如交易类型,随机数nonce,接收方地址等交易相关信息。See Figure 3, the above blockchain transaction format, including the content in the figure, such as transaction type, random number nonce, recipient address and other transaction-related information.
S2,根据实际部署的网络节点情况,将每个节点最大的上下行速率上限记为C,那么每条交易在两个节点之间传输的时间为同时假定每条交易在节点处生成的时间为Ttxbuild,所以每条交易由客户端生成并发送到区块链节点的时间为/> S2, according to the actual deployment of network nodes, record the maximum uplink and downlink rate limit of each node as C, then the transmission time of each transaction between two nodes is At the same time, it is assumed that the time for each transaction to be generated at the node is T txbuild , so the time for each transaction to be generated by the client and sent to the blockchain node is />
S3,假设交易验签的时间为Ttxcheck,因为采用的测试交易内容、格式均相同,所以每条交易的验签时间均为Ttxcheck,且验签时间在交易的处理总时间中只考虑一次;S3, assuming that the transaction signature verification time is T txcheck , because the test transaction content and format adopted are the same, so the signature verification time of each transaction is T txcheck , and the signature verification time is only considered once in the total transaction processing time;
参见图4,上述区块链交易验签过程,包括验证交易是否合法或重复,若不合法或交易重复则直接丢弃交易;若交易合法且不存在重复,则将交易存入节点的本地交易池中。Referring to Figure 4, the above-mentioned blockchain transaction signature verification process includes verifying whether the transaction is legal or repeated. If it is illegal or the transaction is repeated, the transaction will be discarded directly; if the transaction is legal and there is no duplication, the transaction will be stored in the local transaction pool of the node.
S4,假设区块的打包时间为Tblockpk、区块头的大小为Sblockhead、每个区块包含n条交易,交易打包为区块并发送到其他节点的总时间为: S4, assuming that the packaging time of the block is T blockpk , the size of the block header is S blockhead , and each block contains n transactions, the total time for the transaction to be packaged into a block and sent to other nodes is:
参见图5,上述区块链交易打包过程,包括从交易池的头部取出交易,由Sealer将若干条交易作为区块的主体,将当前节点的信息附加在区块头中,将以上信息打包为一个区块,将该区块发送给其余区块链节点。Referring to Figure 5, the above-mentioned blockchain transaction packaging process includes taking out transactions from the head of the transaction pool. The Sealer takes several transactions as the main body of the block, attaches the information of the current node to the block header, packs the above information into a block, and sends the block to other blockchain nodes.
S5,假设区块验证的时间为Tblockcheck,每条交易执行的时间为Ttx,那么每个区块验证并在节点上执行的时间为Tblockcheck+nTtx;S5, assuming that the block verification time is T blockcheck and the execution time of each transaction is T tx , then the time for each block verification and execution on the node is T blockcheck +nT tx ;
S6,节点在一个区块执行完成之后会向其他区块链节点广播区块的执行结果,区块执行结果的数据大小与区块的大小相比可以忽略不计,假定交易落盘的时间为Tblocksave。S6. After the execution of a block is completed, the node will broadcast the execution result of the block to other blockchain nodes. The data size of the block execution result is negligible compared with the size of the block. It is assumed that the time for placing the transaction is T blocksave .
参见图6,其余区块链节点接收到其他节点发送来的区块信息,首先通过区块验证器验证区块的基本信息,包括验证发送节点的身份信息和签名是否合法,若区块通过合法性检测,则执行引擎会从区块中逐个取出交易,并根据交易的具体内容从本地的智能合约库查找相关智能合约代码并逐条执行,执行完成后当前节点会将执行的结果在全网中进行广播。See Figure 6. The rest of the blockchain nodes receive the block information sent by other nodes. First, the basic information of the block is verified by the block validator, including verifying whether the identity information and signature of the sending node are legal. If the block passes the legality test, the execution engine will take out transactions from the block one by one, and search for relevant smart contract codes from the local smart contract library according to the specific content of the transaction and execute them one by one. After the execution is completed, the current node will broadcast the execution results on the entire network.
S7,执行完成一个区块的总时间为S7, the total time to execute a block is
Ttot=n(Ttxbuild+Ttxsend+Ttxcheck)+Tblockpk+Tblocksend+Tblockdone+Tconsensus+Tblocksave。T tot =n(T txbuild +T txsend +T txcheck )+T blockpk +T blocksend +T blockdone +T consensus +T blocksave .
S8,将处理交易的时间分成两个部分,通信时间Tcomm和计算时间Tcomp。其中计算部分的时间为Tcomp=n(Ttxbuild+Ttxcheck)+Tblockpk+Tblockcheck+nTtx+Tblocksave,计算通信时间时可以将区块头的大小忽略不计,所以通信时间可以表示为 S8, dividing the transaction processing time into two parts, the communication time T comm and the calculation time T comp . The calculation time is T comp =n(T txbuild +T txcheck )+T blockpk +T blockcheck +nT tx +T blocksave , and the size of the block header can be ignored when calculating the communication time, so the communication time can be expressed as
S9,区块链处理交易的计算时间受到很多因素的影响,难以精确量化,所以通过进行多次单节点交易处理的方式得到每条交易处理的平均时间Ttxcomp,记录不同交易数量下的测试结果绘制每条交易的执行时间与交易量之间的关系图。S9, the calculation time of blockchain processing transactions is affected by many factors, and it is difficult to quantify accurately. Therefore, the average time T txcomp of each transaction processing is obtained by performing multiple single-node transaction processing, and the test results under different transaction quantities are recorded to draw the relationship between the execution time of each transaction and the transaction volume.
参见图7,这一步在单个机器上搭建单节点进行测试,目的是为了测得较为精确的交易创建、交易执行和交易落盘的总时间,图7展示了向区块链发送不同的交易数量与每条交易执行的时间之间的关系,可以看出每条交易在区块链中生成、验证、执行、落盘的总时间与每次测试输入的交易数量没有明显关系,图中所有交易的平均时间为0.7397ms,下文中将该数值作为区块链处理每条交易的平均时间带入数学模型进行拟合。See Figure 7. In this step, a single node is built on a single machine for testing. The purpose is to measure the more accurate total time of transaction creation, transaction execution, and transaction placement. Figure 7 shows the relationship between the number of different transactions sent to the blockchain and the execution time of each transaction. It can be seen that the total time for each transaction to be generated, verified, executed, and placed in the blockchain has no obvious relationship with the number of transactions entered in each test. The average time of all transactions in the figure is 0.7397ms. In the following, this value is used as the average time for each transaction to be processed by the blockchain. into the mathematical model for fitting.
S10,所以建立的区块链TPS数学模型为使用Matlab程序以节点的通信能力为自变量可以绘制出区块链系统的TPS曲线。S10, so the established blockchain TPS mathematical model is Using the Matlab program, the TPS curve of the blockchain system can be drawn with the communication capability of the node as the independent variable.
参见图8,可见当区块链节点的通信能力较差时,区块链的TPS值主要受到区块链节点通信能力的影响,提升节点的最大上下行速率可以有效的提升区块链网络的TPS,但是当节点的通信能力上升到一定大小后,继续提升节点的通信能力,对区块链TPS的影响将逐渐减小。Referring to Figure 8, it can be seen that when the communication capability of the blockchain nodes is poor, the TPS value of the blockchain is mainly affected by the communication capabilities of the blockchain nodes. Increasing the maximum uplink and downlink rate of the nodes can effectively improve the TPS of the blockchain network. However, when the communication capabilities of the nodes increase to a certain size, the impact on the TPS of the blockchain will gradually decrease if the communication capabilities of the nodes continue to be improved.
S11,搭建与数学模型网络结构相同的实际区块链网络,对实际的区块链网络进行TPS测试,与上述的理论分析值进行比较。S11, build an actual blockchain network with the same network structure as the mathematical model, conduct a TPS test on the actual blockchain network, and compare it with the above-mentioned theoretical analysis value.
S1101,提供多个物理机,多个物理机之间通过路由器相互访问,配置物理机的静态IP地址,并在命令行中使用Ping命令检测各个区块链节点之间的通信情况。S1101, provide multiple physical machines, and multiple physical machines access each other through a router, configure the static IP address of the physical machine, and use the Ping command in the command line to detect the communication between each blockchain node.
参见图9,搭建实际的区块链网络。See Figure 9 to build an actual blockchain network.
例如:利用1个路由器实现10台物理机之间的相互访问,区块链网络的结构如图2所示。在物理机上启动Linux操作系统,配置10台物理机的静态IP地址为192.168.1.200~209。For example: using one router to achieve mutual access between 10 physical machines, the structure of the blockchain network is shown in Figure 2. Start the Linux operating system on the physical machines, and configure the static IP addresses of 10 physical machines as 192.168.1.200-209.
S1102,在物理机上配置区块链节点运行所需的环境。例如:安装openssl、curl、java 14.0.2、docker等软件。S1102, configuring the environment required for running the blockchain node on the physical machine. For example: install openssl, curl, java 14.0.2, docker and other software.
S1103,下载建链脚本build_chain.sh,根据区块链网络的实际情况修改ipconf配置文件,将区块链节点的ip地址与所属机构(联盟链中所属的机构,按:联盟链由多个机构组成)在ipconf配置文件一一对应配置。S1103, download the chain building script build_chain.sh, modify the ipconf configuration file according to the actual situation of the blockchain network, and configure the ip address of the blockchain node and the organization to which it belongs (the organization in the alliance chain, press: the alliance chain is composed of multiple institutions) in the ipconf configuration file.
S1104,执行建链脚本build_chain.sh,根据ipconf配置文件中的配置自动生成搭建区块链网络所需的节点证书,通过SCP方式将生成的证书发送至各个区块链节点。S1104, execute the chain building script build_chain.sh, automatically generate the node certificates required to build the blockchain network according to the configuration in the ipconf configuration file, and send the generated certificates to each blockchain node through SCP.
S1105,编写脚本,逐个访问区块链节点,执行指定目录下的区块链节点启动程序,启动程序将在当前区块链节点下运行docker容器,将预先设定的docker容器端口映射到物理机端口上实现与其他docker容器的通信。S1105, write a script, access the blockchain nodes one by one, execute the blockchain node startup program in the specified directory, the startup program will run the docker container under the current blockchain node, and map the preset docker container port to the physical machine port to realize communication with other docker containers.
S1106,若想要让区块链网络中的两个节点之间不能直接通信,则需要通过TC指令禁止两个几点之间的互相访问,被禁止的节点想要获取对方发来的交易或区块,只能等待区块链网络中其他节点收到交易后的广播;S1106, if you want to prevent direct communication between two nodes in the blockchain network, you need to prohibit the mutual access between the two points through the TC command. If the prohibited node wants to obtain the transaction or block sent by the other party, it can only wait for other nodes in the blockchain network to receive the broadcast after the transaction;
S1107,全部区块链节点启动完毕后,选择任意一个区块链节点,执行查看命令,观察是否所有区块链网络中的节点都可以通过直接或多条的方式互相发现;S1107, after all the blockchain nodes are started, select any blockchain node, execute the view command, and observe whether all the nodes in the blockchain network can discover each other directly or in multiple ways;
S1108,在区块链网络外的一个Linux主机上配置Caliper区块链TPS测试软件,通过该节点向区块链网络的任意节点发送交易进行TPS测试;S1108, configure the Caliper blockchain TPS testing software on a Linux host outside the blockchain network, and send transactions to any node of the blockchain network through the node for TPS testing;
S1109,修改每个节点的最大上下行速率,分别进行多次测试,以此与数学模型不同速率下的TPS预测值进行比较;S1109, modifying the maximum uplink and downlink rates of each node, and performing multiple tests respectively, so as to compare with the TPS prediction values at different rates of the mathematical model;
S1110,通过Matlab软件对实际网络的测试结果和数学模型的预测曲线进行绘图比较,并计算最大误差。S1110, drawing and comparing the test results of the actual network and the prediction curve of the mathematical model through Matlab software, and calculating the maximum error.
参见图10,可以看出建立的数学模型和实际搭建的10节点全连接区块链系统在通信速率较低的情况下具有较高的精度,在节点的最大通信速率大于10Mbyte/s的情况下出现了较大的误差。误差原因主要是受限于测试环境的影响,实际搭建的区块链系统中使用的千兆路由器最大允许的流量为100Mbyte/s,若一个节点的上下行速率高于10Mbyte/s时会在路由器中产生排队发送现象,导致通信效率下降,从而影响实验最终的TPS值。从实际测试的TPS曲线也能看出在网络带宽来到10Mbyte/s后,节点通信能力的提升对于实际的网络TPS几乎没有影响。取上图中节点最高通信速率为50Kbyte/s—10Mbyte/s的数据作为有效数据,可以得到数学模型在全局耦合网络中的最大误差为6.74%。Referring to Figure 10, it can be seen that the established mathematical model and the actual 10-node fully-connected blockchain system have high accuracy when the communication rate is low, and a large error occurs when the maximum communication rate of the nodes is greater than 10Mbyte/s. The reason for the error is mainly due to the influence of the test environment. The gigabit router used in the actually built blockchain system allows a maximum flow rate of 100Mbyte/s. If the uplink and downlink rate of a node is higher than 10Mbyte/s, queuing and sending will occur in the router, resulting in a decrease in communication efficiency and affecting the final TPS value of the experiment. It can also be seen from the TPS curve of the actual test that after the network bandwidth reaches 10Mbyte/s, the improvement of node communication capabilities has little effect on the actual network TPS. Taking the data with the highest communication rate of 50Kbyte/s-10Mbyte/s of nodes in the above figure as valid data, it can be obtained that the maximum error of the mathematical model in the global coupling network is 6.74%.
本发明提出了一种电子设备,电子设备包括存储器和处理器,存储器存储有计算机程序,处理器执行计算机程序时实现如上任一项方法的步骤。The present invention provides an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.
本发明提出了一种计算机可读存储介质,存储有计算机程序,计算机程序被处理器执行时实现如上任一项方法的步骤。The present invention provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above methods are realized.
应理解,所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-OnlyMemory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。It should be understood that if the integrated units are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention is essentially a part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, the computer software product is stored in a storage medium, and includes several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk, and other media that can store program codes.
实施例仅为说明本发明的技术思想,不能以此限定本发明的保护范围,凡是按照本发明提出的技术思想,在技术方案基础上所做的任何改动,均落入本发明保护范围之内。The embodiment is only to illustrate the technical idea of the present invention, and can not limit the protection scope of the present invention. Any modification made on the basis of the technical solution according to the technical idea proposed in the present invention all falls within the protection scope of the present invention.
Claims (5)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210634856.9A CN115102866B (en) | 2022-06-06 | 2022-06-06 | A consensus algorithm-oriented block chain TPS estimation method and its verification method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210634856.9A CN115102866B (en) | 2022-06-06 | 2022-06-06 | A consensus algorithm-oriented block chain TPS estimation method and its verification method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115102866A CN115102866A (en) | 2022-09-23 |
CN115102866B true CN115102866B (en) | 2023-07-25 |
Family
ID=83289347
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210634856.9A Active CN115102866B (en) | 2022-06-06 | 2022-06-06 | A consensus algorithm-oriented block chain TPS estimation method and its verification method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115102866B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110971684A (en) * | 2019-11-28 | 2020-04-07 | 北京工业大学 | PBFT-based block chain network node load balancing method |
CN111612455A (en) * | 2020-04-21 | 2020-09-01 | 国网江苏省电力有限公司电力科学研究院 | A Byzantine Fault Tolerant Consortium Chain Consensus Method for Protection of Electricity Information and Its System and Storage Medium |
CN113569296A (en) * | 2021-09-26 | 2021-10-29 | 南京中网卫星通信股份有限公司 | Sharing facility safe leasing system based on alliance chain and implementation method thereof |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP3769490B1 (en) * | 2019-10-16 | 2022-05-04 | Alipay (Hangzhou) Information Technology Co., Ltd. | Implementing a blockchain-based web service |
-
2022
- 2022-06-06 CN CN202210634856.9A patent/CN115102866B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110971684A (en) * | 2019-11-28 | 2020-04-07 | 北京工业大学 | PBFT-based block chain network node load balancing method |
CN111612455A (en) * | 2020-04-21 | 2020-09-01 | 国网江苏省电力有限公司电力科学研究院 | A Byzantine Fault Tolerant Consortium Chain Consensus Method for Protection of Electricity Information and Its System and Storage Medium |
CN113569296A (en) * | 2021-09-26 | 2021-10-29 | 南京中网卫星通信股份有限公司 | Sharing facility safe leasing system based on alliance chain and implementation method thereof |
Non-Patent Citations (1)
Title |
---|
基于改进的PBFT算法的性能模型研究;储劲松;鲍可进;夏纯中;;计算机与数字工程(第09期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN115102866A (en) | 2022-09-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021203853A1 (en) | Key generation method, device, apparatus, and medium | |
US10587732B2 (en) | Secure client-server communication | |
CN110519246A (en) | Based on the degree of belief calculation method for trusting block chain link point | |
CN110650216B (en) | Cloud service request method and device | |
US20140173279A1 (en) | Securely identifying host systems | |
CN108401037A (en) | User terminal and the binding method of equipment, device and system | |
CN108900324B (en) | Method and device for checking communication performance of virtual machine | |
US20210089356A1 (en) | Data Processing System using Directed Acyclic Graph and Method of use thereof | |
CN117056084B (en) | Data processing method, device, equipment and medium based on hierarchical blockchain network | |
CN113297133B (en) | Service migration quality guarantee method and system | |
CN107948210A (en) | A kind of login method, device, client, server and medium | |
CN110910110A (en) | A data processing method, device and computer storage medium | |
CN110730189A (en) | Communication authentication method, device, equipment and storage medium | |
CN114598500B (en) | Security service providing method, platform, electronic device, medium and program | |
Huang et al. | A secure cost‐effective migration of enterprise applications to the cloud | |
CN116244062A (en) | Data processing method and device, electronic equipment and storage medium | |
CN113836573B (en) | User information processing method and device based on distributed storage | |
CN115102866B (en) | A consensus algorithm-oriented block chain TPS estimation method and its verification method | |
CN111600755B (en) | Internet access behavior management system and method | |
CN105516134B (en) | A kind of authentication method and system of the system integration | |
CN115623001B (en) | A blockchain-based collaborative method for trusted access and traceable services for cloud-edge services | |
CN114880300A (en) | Processing method and device based on block chain file, processor and electronic equipment | |
CN114389819A (en) | Signature verification method and device | |
CN116095074A (en) | Resource allocation method, device, related equipment and storage medium | |
CN114979996B (en) | Business card generation method and device based on SIM card and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |