CN114510431B - Workload-aware intelligent contract defect prediction method, system and equipment - Google Patents

Workload-aware intelligent contract defect prediction method, system and equipment Download PDF

Info

Publication number
CN114510431B
CN114510431B CN202210413743.6A CN202210413743A CN114510431B CN 114510431 B CN114510431 B CN 114510431B CN 202210413743 A CN202210413743 A CN 202210413743A CN 114510431 B CN114510431 B CN 114510431B
Authority
CN
China
Prior art keywords
intelligent contract
intelligent
contract
defect
logistic regression
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
Application number
CN202210413743.6A
Other languages
Chinese (zh)
Other versions
CN114510431A (en
Inventor
胡文华
陆万鹏
刘李明
李富洋
余啸
杨佩鑫
邹宽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan University of Technology WUT
Original Assignee
Wuhan University of Technology WUT
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Wuhan University of Technology WUT filed Critical Wuhan University of Technology WUT
Priority to CN202210413743.6A priority Critical patent/CN114510431B/en
Publication of CN114510431A publication Critical patent/CN114510431A/en
Application granted granted Critical
Publication of CN114510431B publication Critical patent/CN114510431B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a workload-aware intelligent contract defect prediction method, a system and equipment, which are characterized in that firstly, a logistic regression classification model is established by using an intelligent contract data set, then, a multi-objective optimization algorithm is utilized to establish a linear regression model by taking the number of defects detected in a maximized mode and the number of intelligent contracts required to be detected in a minimized mode as targets when twenty percent of code line number is detected, finally, the relative defect density of the intelligent contracts to be predicted is predicted by combining the two models, and the intelligent contracts are sequenced according to the relative defect density. According to the technical scheme, software testing personnel can detect more intelligent contract defects and fewer intelligent contracts needing to be detected under a certain workload, namely when the number of code lines of the first twenty percent is detected.

Description

Workload-aware intelligent contract defect prediction method, system and equipment
Technical Field
The invention belongs to the technical field of intelligent contract software defect prediction, relates to a workload-aware intelligent contract defect prediction method, a workload-aware intelligent contract defect prediction system and workload-aware intelligent contract defect prediction equipment, and particularly relates to the workload-aware intelligent contract defect prediction method, the workload-aware intelligent contract defect prediction system and the workload-aware intelligent contract defect prediction equipment based on multi-objective optimization.
Background
The block chain is a novel decentralized protocol, can safely store digital currency transactions or other data, and information can not be forged and falsified without the auditing of any centralized organization. On various types of platforms based on blockchain technology (e.g., etherhouses), transactions of various digital currencies, which all rely on smart contracts, are most frequently performed. An intelligent contract is a computer protocol intended to propagate, validate, or execute contracts in an informational manner. Smart contracts allow trusted transactions, which are traceable and irreversible, to be conducted without a third party. With the development of blockchain technology, intelligent contracts are widely applied to various fields (such as finance, insurance, games, share funding and the like) to realize automatic point-to-point reliable transactions. For example, a bank may use smart contracts to loan or to pay automatically; insurance companies can process a portion of a claim using intelligent contracts; the carrier may use smart contracts to make payments, etc. Since smart contracts generally hold a huge amount of digital currency, and once deployed on a blockchain platform, anyone including an attacker can invoke the smart contract by sending the transaction to the corresponding smart contract address. These two key features make the smart contracts vulnerable to hackers if they are defective. Therefore, how to quickly and effectively predict whether the intelligent contract has defects or not has high application value.
At present, some intelligent contract defect prediction methods exist, but the methods only predict whether defects exist in intelligent contracts and cannot distinguish intelligent contracts with higher defect density from intelligent contracts with lower defect density. Workload-aware smart contract defect prediction aims at predicting defect density in a smart contract (i.e., the number of defects present in a smart contract divided by the number of code lines in the smart contract), and then instructing software testers to preferentially test smart contracts with higher defect densities and find more defects when testing the same number of code lines (i.e., using the same workload). Meanwhile, the number of detected intelligent contracts is small when the number of code lines with the same number is detected, and the detection and conversion are prevented from being too frequent.
At present, some workload-aware defect prediction methods for conventional software (such as Java project, C + + project, and JavaScript project) have been proposed. At present, the CBS + method proposed by Huang et al in the document [1] achieves a good effect on the workload-aware defect prediction of Java projects. Then Ni et al verified that the CBS + method also achieves a good prediction effect on JavaScript projects in document [2 ].
The execution process of CBS + is mainly divided into two steps, firstly, a software module is brought into a logic regression classification model which is trained in advance, and then the defect density of the logic regression classification model is calculated according to the following formula:
Figure 28271DEST_PATH_IMAGE001
wherein prob (c)i) Representing software modules ciDefect density of (2), pred (c)i) Representing the probability of a classification, effort (c), obtained by the software module in the classification model being predicted as defectivei) Representing the workload of the software module check, where the number is equal to the number of code lines of the software module, C represents a larger constant. When the software module is predicted to be defective by the classification model, i.e. the classification probability pred (c)i) And when the defect density of the module is more than or equal to 0.5, the classification probability is divided by the workload and a larger constant is added. When the software module is predicted to be defect-free by the classification model, i.e. the classification probability pred (c)i) Less than 0.5, the defect density of the module is calculated by dividing the classification probability by the workload minus a large constant. The constant C here serves to distinguish defective and non-defective software modules, and to avoid that a small number of non-defective modules get a higher defect density due to the removal of a smaller amount of work. I.e. to ensure that all software modules predicted to be defective are ranked ahead of software modules predicted to be non-defective in the final ranking result according to defect density. The CBS + method is excellent in classification index, but is general in workload perception index, namely when the previous twenty percent of code line numbers are detected, the number of detected software defects is not large. The main reason is that the defect density calculation only depends on the classification probability and the code line number provided by the classifier, and the classification probability only can indicate the possibility of the software module having defects and cannot indicate how many defects the software module has defects. This results in a defect density for the CBS + calculation that does not well represent how much the software module is defective per unit of workload. Thus, CBS + has room for optimization in workload aware defect prediction.
The document [1] Huang, Q., Xia, X., Lo, D.. Revisiting super and unsupervised models for effect-oriented in-time defect prediction, Empirical Software Engineering 2019, 24, 2823-.
Document [2] NI, C, XIA, X, LO, D, YANG, X, HASSAN, A.E., 2022. Just-in-time defect prediction on javascript programs: A reproduction study. ACM Transactions on Software Engineering and method, 2022.
Disclosure of Invention
The invention provides a workload perception intelligent contract defect prediction method, system and equipment based on multi-objective optimization, aiming at the problem that the number of defects detected by the existing workload perception defect prediction method is not high.
The method adopts the technical scheme that: a workload-aware intelligent contract fault prediction method comprises the following steps:
step 1: extracting the data to be predictedmOf a personal intelligent contractpA feature of formingmAnpA feature vector of the dimension;
step 2: will be provided withmAnpInputting the feature vector of the dimension into a workload-aware intelligent contract defect prediction model, predicting the relative defect density of the intelligent contract to be predicted, and sequencing the intelligent contracts according to the predicted relative defect density from large to small to obtain the intelligent contract defect densitymThe priority order of the intelligent contracts for testing, and the prediction result is the test order;
the workload-aware intelligent contract defect prediction model comprises a logistic regression classification model c (x) And a multiobjective optimization model h: (x);
The logistic regression classification model
Figure 273307DEST_PATH_IMAGE002
(ii) a Wherein the content of the first and second substances,
Figure 256307DEST_PATH_IMAGE003
a coefficient vector representing a logistic regression classification model,xa feature vector representing the smart contract;
the multi-objective optimization model
Figure 979412DEST_PATH_IMAGE004
Wherein, in the step (A),ba coefficient vector representing the multi-objective optimization model,xa feature vector representing the smart contract;
the relative defect Density (Densityx) Comprises the following steps:
Figure 888725DEST_PATH_IMAGE005
wherein loc: (x) The number of code lines representing the smart contract X,Cis a preset large constant; when c is (x) When the number is more than or equal to 0.5, the intelligent contract is predicted to be defective by the logistic regression classification model; when c is (x) Less than 0.5, this indicates that the smart contract was predicted to be defect free by the logistic regression classification model.
The technical scheme adopted by the system of the invention is as follows: a workload-aware intelligent contract fault prediction system comprising the following modules:
module 1 for extracting the prediction to be mademOf a personal intelligent contractpA feature of formingmAnpA feature vector of the dimension;
module 2 for connectingmAnpInputting the feature vector of the dimension into a workload-aware intelligent contract defect prediction model, predicting the relative defect density of the intelligent contract to be predicted, and sequencing the intelligent contracts according to the predicted relative defect density from large to small to obtain the intelligent contract defect densitymThe priority order of the intelligent contracts for testing, and the prediction result is the test order;
the workload-aware intelligent contract defect prediction model comprises a logistic regression classification model c (x) And a multiobjective optimization model h: (x);
The logistic regression classification model
Figure 914450DEST_PATH_IMAGE002
(ii) a Wherein the content of the first and second substances,
Figure 774958DEST_PATH_IMAGE003
a coefficient vector representing a logistic regression classification model,xa feature vector representing the smart contract;
the multi-objective optimization model
Figure 301754DEST_PATH_IMAGE004
Wherein, in the step (A),ba coefficient vector representing the multi-objective optimization model,xa feature vector representing the smart contract;
the relative defect Density (Densityx) Comprises the following steps:
Figure 439475DEST_PATH_IMAGE005
wherein loc: (x) The number of code lines representing the smart contract X,Cis a preset large constant; when c is (x) When the number is more than or equal to 0.5, the intelligent contract is predicted to be defective by the logistic regression classification model; when c is (x) Less than 0.5, this indicates that the smart contract was predicted to be defect free by the logistic regression classification model.
The technical scheme adopted by the equipment of the invention is as follows: a workload-aware intelligent contract fault prediction device comprising:
one or more processors;
a storage device to store one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the workload-aware intelligent contract fault prediction method.
The invention provides a workload-aware intelligent contract defect prediction model combining a logistic regression classification model and multi-objective optimization. The technical scheme of the invention can enable software testers to detect more intelligent contract defects and fewer intelligent contracts needing to be detected under a certain workload (namely, when the number of code lines of the first twenty percent is detected).
Drawings
FIG. 1 is a flow chart of an embodiment of the present invention.
Detailed Description
In order to facilitate the understanding and implementation of the present invention for those of ordinary skill in the art, the present invention is further described in detail with reference to the accompanying drawings and examples, it is to be understood that the embodiments described herein are merely illustrative and explanatory of the present invention and are not restrictive thereof.
The invention provides a workload-aware intelligent contract defect prediction method which comprises the steps of firstly establishing a logistic regression classification model by using an intelligent contract data set, then establishing a multi-objective optimization model by using a multi-objective optimization algorithm with the aim of maximizing the number of detected defects and minimizing the number of intelligent contracts to be detected when twenty percent of code lines are detected, finally predicting the relative defect density of intelligent contracts to be predicted by combining the two models, and sequencing the intelligent contracts according to the relative defect density.
Please refer to fig. 1, which specifically includes the following steps:
step 1: mining intelligent contract historical data and extracting from the historical datanAn intelligent contract; then marking the defect number of the intelligent contracts;
step 2: the method comprises the steps of extracting defect-related features in the intelligent contract, and extracting 10 features, wherein the 10 features comprise weighted function values (WFC), public function Numbers (NPF), function average complexity (AFC), degree of Coupling Between Contracts (CBC), corresponding numbers in the contract (RFC), Coupling Between Functions (CBF), degree of function condensation (LCOM), degree of condensation between Contracts (CAF), number of subcontracts (NOC) and code line number (LOC).
After the steps 1 and 2, the present embodiment assumes that after 15 intelligent contracts are extracted, the following intelligent contract data set including 15 intelligent contract data is formedSEach intelligent contract data is composed of a 10-dimensional feature vectorx i=(x 1i,x 2i,x 3i,x 4i,x 5i,x 6i,x 7i,x 8i,x 9i,x 10i) And the number of defects of the intelligent contracty iAnd (4) forming.
X 1={(4,2,14,42,29,2,12,5,0.725,395), “0”},
X 2={(1,1,8,32,49,4,4,12,0.835164835,257), “2”},
X 3={(2,0,1,9,0,0,1,1,0,58), “0”},
X 4={(3,0,12,37,32,0,12,12,0.858585859,310), “0”},
X 5={(3,0,4,21,1,0,4,6,0.7,136), “0”},
X 6={(1,0,3,15,0,2,1,4,0.5,137), “0”},
X 7={(4,0,6,32,6,0,6,1,2,325), “0”},
X 8={(3,0,3,40,84,1,2,16,0.658333333,604), “0”},
X 9={(5,0,5,21,0,0,5,4,0.333333333,87),“0”},
X 10={(3,0,10,55,76,5,6,11,0.59375,461), 3”},
X 11={(3,0,9,29,0,0,9,9,0.583333333,168), “0”},
X 12={(3,0,3,14,1,0,3,3,0.5,84), “4”},
X 13={(3,0,5,41,21,1,5,7,0.793650794,360), “0”},
X 14={(2,0,9,64,76,7,2,9,0.879166667,713), “1”},
X 15={(1,5,12,11,8,11,1,5,0.75,59), “0”};
And step 3: intelligent contract data set based on logistic regression classification algorithmSEstablishing a logistic regression classification model c (x) (ii) a The specific implementation comprises the following steps:
step 3.1: before data is input into a logistic regression classification model, the number of defects needs to be processed due to a two-classification problem, and an intelligent contract data set is obtainedSThe intelligent contract class label number of which the defect number is more than 0 of the intelligent contract contained in the intelligent contract is set to be 1, and the intelligent contract of which the defect number is equal to 0 is setThe class number is set to 0.
Step 3.2: based on the intelligent contract data set processed in step 3.1SSubstituting into the logistic regression classification model to train the logistic regression classification model c: (x) The logistic regression classification model is used for predicting the tendency of the intelligent contract to have defects based on the intelligent contract characteristics, and the logistic regression classification model is shown as the following formula:
Figure 760735DEST_PATH_IMAGE002
wherein the content of the first and second substances,
Figure 344425DEST_PATH_IMAGE003
a coefficient vector representing a logistic regression classification model,xa feature vector representing the smart contract;
in this embodiment, intelligent contract X2Intelligent contract X10Intelligent contract X12Intelligent contract X14The number of defects is: 2.3, 4, 1, and thus the class labels of the four intelligent contracts are set to 1, and the class labels of the rest intelligent contracts are all set to 0. The processed data is used as a training set of a logistic regression classification model to obtain a coefficient vector of the logistic regression classification model
Figure 284699DEST_PATH_IMAGE003
Has a value of;
Figure 401560DEST_PATH_IMAGE003
=[-0.18672685,-0.29409737,-0.13012983,0.34076387,0.23358039,-0.00843151,-0.20187372,-0.49759544 ,0.20180981,-0.04383217]。
and 4, step 4: based on NSGA-II by utilizing multi-objective optimization algorithmSEstablishing a multi-objective optimization model
Figure 159300DEST_PATH_IMAGE004
Wherein, in the step (A),ba coefficient vector representing the multi-objective optimization model,xa feature vector representing the smart contract. The optimization goal of NSGA-II is to be one hundred times before detectionWhen the number of code lines is twenty, the number of detected defects is maximized and the number of intelligent contracts needing to be detected is minimized, so that the coefficient vector of the multi-objective optimization model is obtainedb
The specific implementation comprises the following substeps:
step 4.1: generating an initial parent population: each intelligent contract feature in the defect dataset is encoded as a genotype of the individual. Individuals in the defect data set form an initial father population and comprise N individuals in total;
step 4.2: performing individual selection operation: carrying out non-domination sorting and crowding degree calculation on the individuals in the parent population to obtain the non-domination sorting and crowding degree of each individual, and carrying out selection operation to select the individuals participating in the evolution operation next;
step 4.3: simulating binary crossover, polynomial mutation operations yields new individuals: by performing simulated binary crossover, polynomial mutation operations on the individuals selected to participate in the evolution operation, a number, also N, of sub-populations is generated and merged with the initial parent population.
Step 4.4: environment selection operations form a new generation of population: adopting a competition selection strategy of parent-child two-generation combination, carrying out rapid non-dominant sorting and congestion degree calculation on the population combined in the step 4.3, preferentially selecting individuals with small non-dominant orders, and selecting individuals with large congestion degree when the non-dominant orders are the same until N individuals are selected to form a new parent population;
step 4.5: and (4) iterating and circulating the steps from 4.2 to 4.4 for one thousand times, finally returning a non-dominant population, selecting an individual from the population, and taking the genotype of the individual as a coefficient vector of the multi-objective optimization model.
In this embodiment, through the training of the multi-objective optimization algorithm, the multi-objective optimization model h (c) ((c))x) The coefficient vector of (a) is:b=[0.372813,0.090313123,-0.49875211,0.68903453,0.512101127,-0.1378441,-0.204621121,-0.564312132 ,0.15473221,-0.12809113]。
and 5: using the model c (trained in step 3 and step 4)x) And h (a)x) Predicting the relative defect density of the intelligent contract to be predicted, anThese intelligent contracts are ordered according to predicted relative defect density.
Step 5.1: extracting 10 features extracted in the synchronization step 2 of the intelligent contract to be predicted to form a 10-dimensional feature vector of the software modulex. This embodiment assumes that 5 smart contracts X to be predicted are extracted16、X17、X18、X19、X20The feature vectors formed by the respective 10-dimensional features are respectively as follows:
x 16 =(1,0,9,49,1,0,9,8,0.920634921,382),
x 17 =(4,0,16,72,165,1,16,16,0.904761905,675),
x 18 =(1,0,4,13,0,0,4,5,0.5,65),
x 19 =(4,1,15,104,185,2,13,8,0.839285714,1180),
x 20 =(3,0,11,83,291,2,9,20,0.889423077,658);
step 5.2: the feature vector of the intelligent contract to be predicted obtained in the step 5.1 is usedxThe relative defect density is calculated by substituting the following formula.
Figure 604188DEST_PATH_IMAGE005
Wherein, sensitivity: (x) Representing the relative defect density of the intelligent contract X to be predicted, h: (x) Expressing the probability of defects predicted by the multi-objective optimization model on the intelligent contract X, c: (x) Indicating the propensity of the logistic regression classification model to defects predicted by the intelligent contract X, loc: (x) The number of code lines representing the smart contract X,Crepresenting a larger constant, taken as 10000. When the smart contract is predicted to be defective by the logistic regression classification model, i.e., (cx) When the defect density of the intelligent contract is more than or equal to 0.5, the defect probability h (of the intelligent contract) is calculatedx) Dividing by the number of code lines loc: (x) Plus a larger constant C. When the smart contract is predicted to be defect-free by the logistic regression classification model, i.e., (cx) When the defect density of the intelligent contract is less than 0.5, the defect tendency c (C) of the module is calculatedx) Dividing by the number of code lines loc (x) And then a larger constant C is subtracted. And finally, sequencing according to the relative defect densities of the intelligent contracts to obtain the priority sequence of the intelligent contract detection.
In this embodiment, the logistic regression algorithm trained in step 3 is used to predict the defect tendency c (c) of the intelligent contract to be predictedx) Obtaining:
Figure 207208DEST_PATH_IMAGE006
due to the fact that
Figure 680040DEST_PATH_IMAGE007
According to the formula of relative defect density
Figure 484048DEST_PATH_IMAGE008
Due to the fact that
Figure 540865DEST_PATH_IMAGE009
According to the formula of relative defect density
Figure 947576DEST_PATH_IMAGE010
Due to the fact that
Figure 914395DEST_PATH_IMAGE011
According to the formula of relative defect density
Figure 13938DEST_PATH_IMAGE012
Due to the fact that
Figure 793937DEST_PATH_IMAGE013
According to the formula of relative defect density
Figure 145284DEST_PATH_IMAGE014
Due to the fact that
Figure 825664DEST_PATH_IMAGE015
According to the formula of relative defect density
Figure 96109DEST_PATH_IMAGE016
At this point, the relative defect densities of the 5 smart contracts to be predicted are calculated. Then, the relative defect densities of the 5 intelligent contracts can be ranked from large to small to obtain the relative defect densitiesmThe priority order of testing the intelligent contracts; in this embodiment, the priority order of the test is: x20、X17、X19、X18、X16. The predicted result is the priority order of the test.
All the steps of the embodiment can be automatically executed by a person skilled in the art by adopting computer software technology.
The specific embodiments of the present invention described are merely illustrative of the spirit of the invention. Various modifications or additions may be made to the described embodiments or alternatives may be employed by those skilled in the art without departing from the spirit or ambit of the invention as defined in the appended claims.

Claims (5)

1. A workload-aware intelligent contract fault prediction method is characterized by comprising the following steps:
step 1: extracting p features of m intelligent contracts to be predicted to form m p-dimensional feature vectors;
step 2: inputting m p-dimensional feature vectors into a workload perception intelligent contract defect prediction model, predicting the relative defect density of an intelligent contract to be predicted, and sequencing the intelligent contracts according to the predicted relative defect density from large to small to obtain the priority sequence of testing the m intelligent contracts, wherein the testing sequence is a prediction result;
the workload-aware intelligent contract defect prediction model comprises a logistic regression classification model c (x) and a multi-objective optimization model h (x);
the logistic regression classification model
Figure FDA0003648951750000011
Wherein, omega represents a coefficient vector of the logistic regression classification model, and x represents a feature vector of the intelligent contract;
the multi-objective optimization model h (x) is b · x, wherein b represents a coefficient vector of the multi-objective optimization model, and x represents a feature vector of the intelligent contract;
the relative defect density (x) is:
Figure FDA0003648951750000012
wherein loc (X) represents the code line number of the intelligent contract X, and C is a preset large constant; when c (x) is greater than or equal to 0.5, the intelligent contract is predicted to be defective by the logistic regression classification model; when c (x) is less than 0.5, it indicates that the smart contract was predicted to be defect-free by the logistic regression classification model.
2. The workload-aware intelligent contract fault prediction method according to claim 1, characterized by: the coefficient vector of the logistic regression classification model in the step 2 is obtained by the following substeps:
step 2.1: mining historical data of the intelligent contracts, and extracting n intelligent contracts from the historical data; then marking the defect number of the intelligent contracts; wherein n is a preset value;
step 2.2: extracting characteristics related to defects in the intelligent contract, including weighted function values WFC, public function number NPF, function average complexity AFC, inter-contract coupling degree CBC, corresponding number RFC in the contract, inter-function coupling CBF, function cohesion degree LCOM, inter-contract cohesion degree CAF, sub-contract number NOC and code line number LOC;
forming an intelligent contract data set S containing n intelligent contract data;
step 2.3: training a logistic regression classification model c (x) based on the intelligent contract data set S by using a logistic regression classification algorithm so as to obtain a coefficient vector omega of the logistic regression classification model c (x);
firstly, processing the number of defects, setting the intelligent contract class label with the intelligent contract defect number larger than 0 in the intelligent contract data set S as 1, and setting the intelligent contract class label with the defect number equal to 0 as 0;
and taking the processed data as a training set of a logistic regression classification model c (x) to obtain a coefficient vector omega of the logistic regression classification model c (x).
3. The workload-aware intelligent contract fault prediction method according to claim 1, characterized by: the coefficient vector of the multi-objective optimization model in the step 2 is obtained by the following substeps:
step 3.1: mining historical data of the intelligent contracts, and extracting n intelligent contracts from the historical data; then marking the defect number of the intelligent contracts; wherein n is a preset value;
step 3.2: extracting characteristics related to defects in the intelligent contract, including weighted function values WFC, public function number NPF, function average complexity AFC, inter-contract coupling degree CBC, corresponding number RFC in the contract, inter-function coupling CBF, function cohesion degree LCOM, inter-contract cohesion degree CAF, sub-contract number NOC and code line number LOC;
forming an intelligent contract data set S containing n intelligent contract data;
step 3.3: training a multi-objective optimization model h (x) by using a multi-objective optimization algorithm NSGA-II based on an intelligent contract data set S, thereby obtaining a coefficient vector of the training multi-objective optimization model h (x);
the optimization objective of the multi-objective optimization algorithm NSGA-II is to maximize the number of detected defects and minimize the number of intelligent contracts needing to be detected when twenty percent of code lines are detected, so as to obtain a coefficient vector b of a multi-objective optimization model;
the specific implementation of step 3.3 comprises the following substeps:
step 3.3.1: generating an initial parent population: encoding each intelligent contract feature in the defect dataset as a genotype of the individual; individuals in the defect data set form an initial father population and comprise N individuals in total;
step 3.3.2: performing individual selection operation: carrying out non-domination sorting and crowding degree calculation on the individuals in the parent population to obtain the non-domination sorting and crowding degree of each individual, and carrying out selection operation to select the individuals participating in the evolution operation next;
step 3.3.3: simulating binary crossover, polynomial mutation operations yields new individuals: generating N sub-populations by performing simulated binary crossing and polynomial mutation operations on the selected individuals to participate in the evolution operation, and combining the sub-populations with the initial parent population;
step 3.3.4: environment selection operations form a new generation of population: adopting a competition selection strategy of parent-child two-generation combination, carrying out rapid non-dominant sorting and congestion degree calculation on the population combined in the step 3.3.3, preferentially selecting individuals with small non-dominant orders, and selecting individuals with large congestion degree when the non-dominant orders are the same until N individuals are selected to form a new parent population;
step 3.3.5: and (3) iteratively circulating the steps 3.3.2-3.3.4 for preset times, finally returning a non-dominant population, selecting an individual from the non-dominant population, and taking the genotype of the individual as a coefficient vector of the multi-objective optimization model h (x).
4. A workload-aware intelligent contract fault prediction system, comprising the following modules:
the intelligent contract prediction method comprises a module 1, a prediction module and a prediction module, wherein the module 1 is used for extracting p characteristics of m intelligent contracts to be predicted and forming m characteristic vectors with p dimensions;
the module 2 is used for inputting m p-dimensional feature vectors into a workload perception intelligent contract defect prediction model, predicting the relative defect density of the intelligent contracts to be predicted, sequencing the intelligent contracts according to the predicted relative defect density from large to small to obtain the priority order of testing the m intelligent contracts, wherein the prediction result is the testing order;
the workload-aware intelligent contract defect prediction model comprises a logistic regression classification model c (x) and a multi-objective optimization model h (x);
the logistic regression classification model
Figure FDA0003648951750000031
Wherein, omega represents a coefficient vector of the logistic regression classification model, and x represents a feature vector of the intelligent contract;
the multi-objective optimization model h (x) is b · x, wherein b represents a coefficient vector of the multi-objective optimization model, and x represents a feature vector of the intelligent contract;
the relative defect density (x) is:
Figure FDA0003648951750000032
wherein loc (X) represents the code line number of the intelligent contract X, and C is a preset large constant; when c (x) is greater than or equal to 0.5, the intelligent contract is predicted to be defective by the logistic regression classification model; when c (x) is less than 0.5, it indicates that the smart contract was predicted to be defect-free by the logistic regression classification model.
5. A workload-aware intelligent contract fault prediction device, comprising:
one or more processors;
storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the workload-aware intelligent contract fault prediction method of any one of claims 1 to 3.
CN202210413743.6A 2022-04-20 2022-04-20 Workload-aware intelligent contract defect prediction method, system and equipment Active CN114510431B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210413743.6A CN114510431B (en) 2022-04-20 2022-04-20 Workload-aware intelligent contract defect prediction method, system and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210413743.6A CN114510431B (en) 2022-04-20 2022-04-20 Workload-aware intelligent contract defect prediction method, system and equipment

Publications (2)

Publication Number Publication Date
CN114510431A CN114510431A (en) 2022-05-17
CN114510431B true CN114510431B (en) 2022-07-05

Family

ID=81555084

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210413743.6A Active CN114510431B (en) 2022-04-20 2022-04-20 Workload-aware intelligent contract defect prediction method, system and equipment

Country Status (1)

Country Link
CN (1) CN114510431B (en)

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103713990A (en) * 2012-09-29 2014-04-09 西门子公司 Method and device for predicting defaults of software
CN107515822B (en) * 2017-08-16 2019-09-03 南京大学 Software defect positioning method based on multiple-objection optimization
CN109947652A (en) * 2019-03-26 2019-06-28 中山大学 A kind of improvement sequence learning method of software defect prediction
CN111045920B (en) * 2019-10-12 2021-05-04 浙江大学 Workload-aware multi-branch software change-level defect prediction method
CN111353653B (en) * 2020-03-13 2020-12-11 大连理工大学 Photovoltaic output short-term interval prediction method
CN111949535B (en) * 2020-08-13 2022-12-02 西安电子科技大学 Software defect prediction device and method based on open source community knowledge
CN112579463B (en) * 2020-12-25 2024-05-24 大卜科技(北京)有限公司 Solidity intelligent contract-oriented defect prediction method
CN113064812A (en) * 2021-02-20 2021-07-02 山东英信计算机技术有限公司 Project development process quality defect prediction method, device and medium
CN113176998A (en) * 2021-05-10 2021-07-27 南通大学 Cross-project software defect prediction method based on source selection
CN113780986B (en) * 2021-08-26 2024-02-27 济南浪潮数据技术有限公司 Measurement method, system, equipment and medium for software research and development process

Also Published As

Publication number Publication date
CN114510431A (en) 2022-05-17

Similar Documents

Publication Publication Date Title
Hoang et al. Deepjit: an end-to-end deep learning framework for just-in-time defect prediction
EP4236197A2 (en) Micro-loan system
CN110458687A (en) The automatic measures and procedures for the examination and approval of decision, device and computer readable storage medium
CN110825644A (en) Cross-project software defect prediction method and system
US20210019762A1 (en) Identity resolution for fraud ring detection
CN110162478B (en) Defect code path positioning method based on defect report
CN111199469A (en) User payment model generation method and device and electronic equipment
CN113221960A (en) Construction method and collection method of high-quality vulnerability data collection model
CN116340726A (en) Energy economy big data cleaning method, system, equipment and storage medium
Khatri et al. Towards building a pragmatic cross-project defect prediction model combining non-effort based and effort-based performance measures for a balanced evaluation
CN111210332A (en) Method and device for generating post-loan management strategy and electronic equipment
CN114022058A (en) Small and medium-sized enterprise confidence loss risk prediction method based on time sequence knowledge graph
CN114510431B (en) Workload-aware intelligent contract defect prediction method, system and equipment
US11568308B2 (en) Correcting bias in supervised machine learning data
CN115809837B (en) Financial enterprise management method, equipment and medium based on digital simulation scene
CN116737111A (en) Safety demand analysis method based on scenerization
WO2022143431A1 (en) Method and apparatus for training anti-money laundering model
CN113723071B (en) Electronic archive verification method, system, storage medium and equipment
CN111651652B (en) Emotion tendency identification method, device, equipment and medium based on artificial intelligence
CN114493853A (en) Credit rating evaluation method, credit rating evaluation device, electronic device and storage medium
CN113516398A (en) Risk equipment identification method and device based on hierarchical sampling and electronic equipment
CN111882415A (en) Training method and related device of quality detection model
Zhou et al. Bridging Expert Knowledge with Deep Learning Techniques for Just-In-Time Defect Prediction
Yeh et al. Predicting failure of P2P lending platforms through machine learning: The case in China
WO2024013939A1 (en) Machine learning program, machine learning method, and information processing device

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