CN113050925A - Intelligent contract repairing method and device for block chain - Google Patents

Intelligent contract repairing method and device for block chain Download PDF

Info

Publication number
CN113050925A
CN113050925A CN202110295709.9A CN202110295709A CN113050925A CN 113050925 A CN113050925 A CN 113050925A CN 202110295709 A CN202110295709 A CN 202110295709A CN 113050925 A CN113050925 A CN 113050925A
Authority
CN
China
Prior art keywords
intelligent contract
repairing
flow chart
code
repair
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.)
Granted
Application number
CN202110295709.9A
Other languages
Chinese (zh)
Other versions
CN113050925B (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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202110295709.9A priority Critical patent/CN113050925B/en
Publication of CN113050925A publication Critical patent/CN113050925A/en
Application granted granted Critical
Publication of CN113050925B publication Critical patent/CN113050925B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0633Workflow analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Theoretical Computer Science (AREA)
  • Human Resources & Organizations (AREA)
  • Economics (AREA)
  • Strategic Management (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Entrepreneurship & Innovation (AREA)
  • General Business, Economics & Management (AREA)
  • Finance (AREA)
  • General Engineering & Computer Science (AREA)
  • Development Economics (AREA)
  • Accounting & Taxation (AREA)
  • Marketing (AREA)
  • Game Theory and Decision Science (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • Operations Research (AREA)
  • Computing Systems (AREA)
  • Educational Administration (AREA)
  • Technology Law (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a method and a device for repairing a block chain intelligent contract, and belongs to the technical field of block chains. The intelligent contract repairing method for the block chain comprises the following steps: uploading the intelligent contract to a block chain test network so that the block chain test network executes the intelligent contract and generates an operation log; receiving an operation log from a block chain test network, and generating an actual service flow chart according to the operation log; comparing the actual business flow chart with a corresponding preset business flow chart to generate a repair code; and repairing the intelligent contract according to the repairing code. The invention can reduce the development and operation and maintenance cost of the intelligent contract and improve the accuracy of the internal logic of the intelligent contract.

Description

Intelligent contract repairing method and device for block chain
Technical Field
The invention relates to the technical field of block chains, in particular to a method and a device for repairing a block chain intelligent contract.
Background
The intelligent contract can only be tested by being deployed on a block chain network, the test is generally realized by adopting a test means of compiling an automatic test case and carrying out a large amount of input and output checks, and a plurality of existing companies provide a static code scanning and formal verification mode of the intelligent contract to restrict the compiling specification of the intelligent contract.
Although there are many automated tools to ensure specification and mass testing of contracts, problem troubleshooting during testing and repairing of contract problems are mainly done by manually checking contract execution logs, and the accuracy of contract execution is also dependent on manual work, thus causing two problems: firstly, the development and operation and maintenance labor cost of an intelligent contract is high, the contract itself can be tested only by executing transaction through a deployment network, and if an execution error occurs or a result is wrong in the testing process, the code problem can be checked and repaired only by manually checking a contract execution log and finding error information; secondly, the logic accuracy of the intelligent contract can not be guaranteed, contract codes are a set of business logic, the integrity of an exchange link on the link can not be tracked in real time, logic loopholes can be passively discovered only when account is checked or errors are reported, and problems are difficult to reproduce due to unclear links.
Disclosure of Invention
The embodiment of the invention mainly aims to provide a method and a device for repairing a block chain intelligent contract, so as to reduce the development and operation and maintenance cost of the intelligent contract and improve the accuracy of the internal logic of the intelligent contract.
In order to achieve the above object, an embodiment of the present invention provides a method for repairing a block chain intelligent contract, including:
uploading the intelligent contract to a block chain test network so that the block chain test network executes the intelligent contract and generates an operation log;
receiving an operation log from a block chain test network, and generating an actual service flow chart according to the operation log;
comparing the actual business flow chart with a corresponding preset business flow chart to generate a repair code;
and repairing the intelligent contract according to the repairing code.
An embodiment of the present invention further provides a device for repairing a block chain intelligent contract, including:
the uploading module is used for uploading the intelligent contract to the block chain test network so that the block chain test network executes the intelligent contract and generates an operation log;
the actual business flow chart module is used for receiving the operation log from the block chain test network and generating an actual business flow chart according to the operation log;
the repair code module is used for comparing the actual business flow chart with the corresponding preset business flow chart to generate a repair code;
and the intelligent contract repairing module is used for repairing the intelligent contract according to the repairing code.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and runs on the processor, wherein the steps of the intelligent contract repairing method for the block chain are realized when the processor executes the computer program.
The embodiment of the invention also provides a computer readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for repairing the block chain intelligent contract are realized.
The method and the device for repairing the intelligent block chain contract, provided by the embodiment of the invention, have the advantages that the intelligent contract is uploaded to the block chain test network firstly, so that the block chain test network executes the intelligent contract and generates the operation log, then the actual business flow chart is generated according to the operation log, the actual business flow chart is compared with the corresponding preset business flow chart, the repair code is generated, and finally the intelligent contract is repaired according to the repair code, so that the development, operation and maintenance costs of the intelligent contract can be reduced, and the accuracy of the internal logic of the intelligent contract can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
FIG. 1 is a flow chart of a method for blockchain intelligent contract repair in an embodiment of the invention;
FIG. 2 is a flow chart of a method for blockchain intelligent contract repair in another embodiment of the present invention;
FIG. 3 is a flowchart of S104 in an embodiment of the present invention;
FIG. 4 is a flow chart of an actual business in an embodiment of the present invention;
FIG. 5 is a schematic diagram comparing a preset business flow chart and an actual business flow chart;
FIG. 6 is a block diagram of an apparatus for block chain intelligent contract repair according to an embodiment of the present invention;
FIG. 7 is a block diagram of an apparatus for block chain intelligent contract repair according to another embodiment of the present invention;
FIG. 8 is a block diagram of a server in which a blockchain intelligent contract repairing apparatus is located according to another embodiment of the present invention;
FIG. 9 is a process flow diagram of a contract variable and flow management node;
FIG. 10 is a component framework diagram of a data collection node;
FIG. 11 is a process flow diagram of a business logic matching node;
fig. 12 is a block diagram showing the structure of a computer device in the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As will be appreciated by one skilled in the art, embodiments of the present invention may be embodied as a system, apparatus, device, method, or computer program product. Accordingly, the present disclosure may be embodied in the form of: entirely hardware, entirely software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
In view of the fact that development, operation and maintenance of intelligent contracts in the prior art are high in labor cost and logic accuracy cannot be guaranteed, the embodiment of the invention provides a method for repairing a block chain intelligent contract, and overcomes the defects of the existing intelligent contract in the aspects of link tracking, testing and problem repairing. The invention is based on the technology of combining NSQ and full link tracking, reduces the development, operation and maintenance cost of the intelligent contract, and improves the accuracy of the internal logic of the intelligent contract.
The NSQ is an open-source distributed real-time message platform based on the Go language, can be used for real-time message service in a large-scale system, can process hundreds of millions of messages every day, has a distributed and decentralized topological structure, has the characteristics of no single point fault, fault tolerance, high availability and reliable message transmission, is easy to configure and deploy, and supports numerous message protocols. Smart contracts are event-driven, stateful, programs that run on top of a replicated, shared ledger and are able to keep assets on the ledger. The full link tracking refers to transaction full link tracking, and the operation of the whole transaction forms a complete link, so that error troubleshooting and problem analysis are facilitated. The present invention will be described in detail below with reference to the accompanying drawings.
Fig. 1 is a flowchart of a method for repairing a blockchain intelligent contract according to an embodiment of the present invention. Fig. 2 is a flowchart of a method for blockchain intelligent contract repair according to another embodiment of the present invention. As shown in fig. 1 and fig. 2, the method for repairing a blockchain intelligent contract includes:
s101: and uploading the intelligent contract to the block chain test network so that the block chain test network executes the intelligent contract and generates an operation log.
Table 1 is an intelligent contract file format table. In specific implementation, the intelligent contract uploaded according to the intelligent contract file format shown in table 1 can be received by the contract variable and process management node located in the contract variable and process management server.
TABLE 1
Figure BDA0002984258670000041
The block chain test network is a special test network of the intelligent contract and is used for completing execution of the contract through consensus of the verification nodes, namely executing an automatic test case and testing the contract interface. The non-verification node is used for marking the step operation of the same link branch as the same link tracking ID (Traceid), and packaging and transmitting the operation log of the uplink to a data acquisition server under the link in a message pushing mode through the NSQ.
S102: and receiving an operation log from the block chain test network, and generating an actual business flow chart according to the operation log.
In an implementation, the operation log from the blockchain test network may be received by a data collection node located in the data collection server. Table 2 is an operation log example table. As shown in table 2, the parameters in the oplog are separated by [ ], i.e., [ link trace id (traceid) ] [ operation time ] [ file name ] [ parent-child method name ] [ import function ] [ export function ] [ other information ].
TABLE 2
Figure BDA0002984258670000051
In one embodiment, generating the actual business process diagram from the operation log comprises: sequencing the operation logs according to the operation time; and generating an actual business flow chart according to the sorted operation log.
In specific implementation, the data acquisition node located in the data acquisition server performs service flow drawing on the operation logs according to the full link tracking technology, and performs sequencing, checking, analyzing, flow drawing and storing on the operation logs according to the receiving time. Checking, i.e., checking the integrity of the operation log, checking whether the operation log contains Traceid, whether the format meets the example specification of table 2, and the like. The analysis is to analyze the content in the operation log respectively, including fields such as Traceid, operation time, file name, parent-child method name, input function, output function, etc.
Fig. 4 is a flow chart of an actual service in the embodiment of the present invention. The process drawing is to perform full link tracking according to the Traceid and the operation time, namely to track and draw the actual service process diagram shown in fig. 4 according to the operation time sequence for the same Traceid operation step in the operation log. The storage is to store the contents of Traceid, operation time, file name, parent method name-child method name, input function, output function and the like of the actual business process diagram into a file system of the server, and simultaneously transmit the actual business process diagram to a business logic matching node of the business logic matching server.
S103: and comparing the actual business flow chart with the corresponding preset business flow chart to generate a repair code.
Before executing S103, the method further includes:
and presetting a service flow according to service requirements, and storing the service flow according to a preprocessing content storage format through a preprocessing node on a service logic preprocessing server. Table 3 is a preprocessed content storage format table. Table 4 is a preprocessed content storage format table under the contract of the warranty service scenario. As shown in tables 3 and 4, the preset service flow includes a step name (link branch), a dependent step, a step operation, an execution condition, an input function, and an output function. And generating a preset service flow chart corresponding to each step name (link branch) according to the preset service flow.
TABLE 3
Figure BDA0002984258670000052
Figure BDA0002984258670000061
TABLE 4
Figure BDA0002984258670000062
In specific implementation, the service logic matching node located in the service logic matching server receives the actual service flow chart from the data acquisition node located in the data acquisition server and the preset service flow chart of the preprocessing node located on the service logic preprocessing server, compares the actual service flow chart with the corresponding preset service flow chart, and searches for a difference. Fig. 5 is a schematic diagram comparing a preset business flow chart and an actual business flow chart. As shown in fig. 5, with the preset service flowchart as a reference, a difference content set between the actual service flowchart and the preset service flowchart is output, and if the actual service flowchart has fewer operation steps than the preset service flowchart, an additional entry scheme is output, for example, a difference operation C (including operation time, step operation, and link branch) is absent; if the actual business flow chart has more operation steps than the preset business flow chart, if the difference operation E is carried out, the difference is output to ensure that business personnel delete or reserve the difference, and a repair code is generated according to the difference repair scheme confirmed by the business personnel.
S104: and repairing the intelligent contract according to the repairing code.
Fig. 3 is a flowchart of S104 in the embodiment of the present invention. As shown in fig. 3, S104 includes:
s201: and analyzing the intelligent contract to obtain an intelligent contract source code.
When the intelligent contract is implemented specifically, the code packet of the intelligent contract can be decompressed through the contract variables and the process management nodes which are positioned in the contract variables and the process management server, meanwhile, the source packaging file is reserved, and the contract content is analyzed according to the decompressed file according to the directory. Go business chain branch number, main calling method (function name) and branch business description (function description), then according to main calling method resolving corresponding method flow in functions, at the same time resolving corresponding structure input and output under structs in method (including data type, data length and data field name), and calling common function in common. And outputting and storing the analysis content in a contract variable and a database of a process management server to form a program logic process of each link branch. Table 5 is the parsed intelligent contract storage format table. Table 6 is the intelligent contract source code in the evidence-storing business scenario. Table 7 is a storage format table of the intelligent contract source code in the scenario of the evidence storage service. As shown in tables 5 to 7, the link branch is used to record a main link name and a calling link branch name of main.go, the function name is a name of a file name _ calling method used in a functions directory, the parent function is a function name called in the function, the input function and the output function are respectively defined according to structures in structs corresponding to an input structure and an output structure of the function, the temporary variable is a variable defined in the function and not required to be output externally, the step operation is an operation record between the input variable and the temporary variable, and the function description is a business meaning corresponding to the function name.
TABLE 5
Figure BDA0002984258670000071
TABLE 6
Figure BDA0002984258670000072
Figure BDA0002984258670000081
TABLE 7
Figure BDA0002984258670000091
Figure BDA0002984258670000101
S202: and repairing the intelligent contract source code according to the repair code, and converting the repaired intelligent contract source code into the repaired intelligent contract.
In one embodiment, repairing intelligent contract source code based on repair code comprises: determining a function name corresponding to the file name of the operation log where the repair code is located; and repairing the intelligent contract source code corresponding to the function name according to the repair code.
During specific implementation, the repair codes are transmitted to contract variables and process management nodes of a contract variable and process management server, and the intelligent contract source codes under the same link branch are determined according to the function names corresponding to the file names of the operation logs where the repair codes are located. And if the missing operation steps need to be additionally recorded, inserting an additional recording step, converting the additional recording step into codes, and repairing the intelligent contract. For example, a variable with the function name of C and an operation record are inserted into the record with the function name of B in the intelligent contract source code, the record is converted into a code form, and the code (repair code) is added after the operation with the function name of B, so that the automatic repair of the intelligent contract source code is realized. And if the redundant operation steps need to be deleted, deleting the redundant operation steps in the intelligent contract source code under the same link branch, and repairing the intelligent contract.
The execution subject of the blockchain intelligent contract repairing method shown in fig. 1 may be a server. As can be seen from the process shown in fig. 1, in the method for repairing a block chain intelligent contract according to the embodiment of the present invention, an intelligent contract is uploaded to a block chain test network, so that the block chain test network executes the intelligent contract and generates an operation log, an actual business flow chart is generated according to the operation log, the actual business flow chart is compared with a corresponding preset business flow chart, a repair code is generated, and finally, the intelligent contract is repaired according to the repair code, so that the development, operation and maintenance costs of the intelligent contract can be reduced, and the accuracy of the internal logic of the intelligent contract can be improved.
The specific process of the embodiment of the invention is as follows:
1. and uploading the intelligent contract to the block chain test network so that the block chain test network executes the intelligent contract and generates an operation log.
2. And receiving the operation logs from the block chain test network, sequencing the operation logs according to the operation time, and generating an actual service flow chart according to the sequenced operation logs.
3. And comparing the actual business flow chart with the corresponding preset business flow chart to generate a repair code.
4. And analyzing the intelligent contract to obtain an intelligent contract source code.
5. And determining a function name corresponding to the file name of the operation log where the repair code is located, and repairing the intelligent contract source code corresponding to the function name according to the repair code.
6. And converting the repaired intelligent contract source code into the repaired intelligent contract.
In summary, the invention can automatically repair the error report of the intelligent contract based on the technology of combining NSQ and full link tracking, and the specific effects of the invention are as follows:
1. the method is characterized in that transactions on a block chain are transmitted to the lower part of the block chain in real time based on the technology of combining NSQ with full link tracking, a complete transaction link diagram is formed for the same service according to a link tracking ID, whether the transaction link is consistent with preset service logic or not is further confirmed, and the accuracy of the service logic is guaranteed.
2. Based on the variable and flow management of the intelligent contract, the error business logic generated in the process of verifying a large amount of data is automatically repaired through the comparison difference between a transaction link and the preset business, and only the fact that whether the repairing step is reasonable or not needs to be confirmed manually is needed, so that the manual problem troubleshooting and the operation and maintenance repairing cost are greatly reduced.
Based on the same inventive concept, the embodiment of the invention also provides a device for repairing the block chain intelligent contract, and as the principle of solving the problem of the device is similar to that of the method for repairing the block chain intelligent contract, the implementation of the device can be referred to the implementation of the method, and repeated parts are not described again.
Fig. 6 is a block diagram of a block chain intelligent contract repairing apparatus according to an embodiment of the present invention. Fig. 7 is a block diagram of a blockchain intelligent contract repairing apparatus according to another embodiment of the present invention. Fig. 8 is a block diagram of a server in which the blockchain intelligent contract repairing apparatus is located according to another embodiment of the present invention. FIG. 9 is a process flow diagram of a contract variable and flow management node. FIG. 10 is a component framework diagram of a data collection node. FIG. 11 is a flow chart of a process of a business logic matching node. As shown in fig. 6 to 11, the block chain intelligent contract repairing apparatus includes:
the uploading module is used for uploading the intelligent contract to the block chain test network so that the block chain test network executes the intelligent contract and generates an operation log;
the actual business flow chart module is used for receiving the operation log from the block chain test network and generating an actual business flow chart according to the operation log;
the repair code module is used for comparing the actual business flow chart with the corresponding preset business flow chart to generate a repair code;
and the intelligent contract repairing module is used for repairing the intelligent contract according to the repairing code.
In one embodiment, the intelligent contract repair module comprises:
the analysis unit is used for analyzing the intelligent contract to obtain an intelligent contract source code;
and the intelligent contract repairing unit is used for repairing the intelligent contract source code according to the repairing code and converting the repaired intelligent contract source code into the repaired intelligent contract.
In one embodiment, the oplog includes an operation time;
the actual business flow chart module comprises:
the sorting unit is used for sorting the operation logs according to the operation time;
and the actual business flow chart unit is used for generating an actual business flow chart according to the sorted operation logs.
In one embodiment, the intelligent contract repairing unit comprises:
the function name determining subunit is used for determining a function name corresponding to the file name of the operation log where the repair code is located;
and the intelligent contract source code repairing subunit is used for repairing the intelligent contract source code corresponding to the function name according to the repairing code.
As shown in fig. 7-11, in practical application, the blockchain intelligent contract repairing apparatus includes a preprocessing node 1, a contract variable and flow management node 2, a data acquisition node 4 and a service logic matching node 5. The contract variable and flow management node 2 and the data acquisition node 4 interact with an external test network node 3, and the test network node 3 is located in an external blockchain test network 13 and comprises a verification node 31 and a non-verification node 32. The preprocessing node 1 is located in a service logic preprocessing server 11, the contract variable and process management node 2 is located in a contract variable and process management server 12, the data acquisition node 4 is located in a data acquisition server 14, and the service logic matching node 5 is located in a service logic matching server 15.
In specific implementation, the preprocessing node 1 draws a preset service flow chart according to service requirements, and stores the preset service flow chart in the service logic preprocessing server 11 after being confirmed by service personnel; the contract variable and flow management node 2 is used for separating input and output, temporary variables and operation steps used by each method in the contract according to the syntactic analysis of the intelligent contract, and storing the data in the contract variable and flow management server 2; the test network node 3 is a network node for contract deployment test, the blockchain test network 13 is a network for automatically testing the interface and service logic of the contract, wherein the verification node is used for verifying the function of the contract interface, and executing the operation of uplink service data after the consensus is completed, and the non-verification node is used for collecting the operation log and transmitting the operation log to the data acquisition server 14 under the chain through NSQ; the data acquisition node 4 is configured to receive and analyze an operation log and uplink data transmitted by the NSQ, store the operation log and the uplink data in a linked relational database, draw a large amount of uplink service logic flow charts after data verification, store the uplink service logic flow charts (actual service flow charts) in the data acquisition server 14, and transmit the actual service flow charts to the service logic matching node 5; the business logic matching node is used for comparing an actual business flow chart transmitted by the data acquisition node 4 with a preset business flow chart drawn by the preprocessing node 1, outputting the difference, confirming whether the difference needs to be modified by business personnel, if so, outputting the difference to the contract variable and flow management node 2 for automatic repair of the intelligent contract, and storing the history record of the difference in the business logic matching server 15.
The service logic preprocessing server 11 is used for storing a service logic flow formulated by service personnel for service requirements, and mainly includes contents such as step names (link branches), dependence steps, step operations, execution conditions, input functions and output functions.
The contract variable and process management server 12 includes an upload module and an intelligent contract repair module, and is configured to store the contents of an input data structure, an output data structure, temporary variables, and operation steps (step operations) of the analyzed code of the intelligent contract, and repair the intelligent contract.
The blockchain test network 13 is a dedicated test network of the intelligent contract, and is used for completing execution of the contract through consensus of the verification nodes, that is, executing an automated test case, and testing the contract interface. The non-verification node is configured to mark the step operation of the same link branch as the same link tracking id (traceid), and package and transmit the operation log of the uplink to the data acquisition server 14 under the link in a message pushing manner through the NSQ.
The data collection server 14 includes an actual service flow chart module, which is used to collect messages transmitted from the chain to the chain via NSQ, and perform service flow drawing on the operation log according to the full link tracking technology, as shown in fig. 10, the data collection server mainly includes two parts, namely, message receiving and message processing, where the message receiving is to receive the messages transmitted from NSQ, including receiving, sorting and distributing the messages; to NSQ message (operation log) received, the operation log is sequenced according to the receiving time, then the operation log is distributed to the message processing part; the message processing mainly realizes four parts of message verification, message analysis, message flow drawing and message storage. The message checks, i.e., checks the integrity of the oplog, checks whether the oplog contains Traceid, whether the format meets the example specification of table 2, etc. The message analysis is to analyze the content in the operation log respectively, including fields such as Traceid, operation time, file name, parent-child method name, input function, output function, etc. The message flow drawing is to perform full link tracking according to the Traceid and the operation time, that is, to track and draw the actual service flow chart shown in fig. 4 according to the operation time sequence for the same Traceid operation step in the operation log. The message storage is to store the contents of the Traceid, the operation time, the file name, the parent-child method name, the input function, the output function and the like of the actual business process diagram into the file system of the server, and simultaneously transmit the actual business process diagram to the business logic matching node 5 located in the business logic matching server 15.
The service logic matching server 15 includes a repair code module, which is used to check whether there is a difference between the preset service flow chart and the actual service flow chart of the uplink, and output a solution to the difference, thereby ensuring the service logic integrity and accuracy of the contract code.
In summary, the device for repairing a block chain intelligent contract according to the embodiment of the present invention uploads an intelligent contract to a block chain test network first, so that the block chain test network executes the intelligent contract and generates an operation log, generates an actual service flowchart according to the operation log, compares the actual service flowchart with a corresponding preset service flowchart, generates a repair code, and repairs the intelligent contract according to the repair code, thereby reducing development and operation and maintenance costs of the intelligent contract and improving accuracy of internal logic of the intelligent contract.
The embodiment of the invention also provides a specific implementation mode of the computer equipment, which can realize all the steps in the intelligent contract repairing method of the block chain in the embodiment. Fig. 12 is a block diagram of a computer device in an embodiment of the present invention, and referring to fig. 12, the computer device specifically includes the following:
a processor (processor)1201 and a memory (memory) 1202.
The processor 1201 is configured to call a computer program in the memory 1202, and the processor implements all the steps in the block chain intelligent contract repairing method in the above embodiment when executing the computer program, for example, the processor implements the following steps when executing the computer program:
uploading the intelligent contract to a block chain test network so that the block chain test network executes the intelligent contract and generates an operation log;
receiving an operation log from a block chain test network, and generating an actual service flow chart according to the operation log;
comparing the actual business flow chart with a corresponding preset business flow chart to generate a repair code;
and repairing the intelligent contract according to the repairing code.
To sum up, the computer device of the embodiment of the present invention first uploads the intelligent contract to the blockchain test network, so that the blockchain test network executes the intelligent contract and generates an operation log, then generates an actual service flow chart according to the operation log, compares the actual service flow chart with a corresponding preset service flow chart, generates a repair code, and finally repairs the intelligent contract according to the repair code, which can reduce the development and operation and maintenance costs of the intelligent contract and improve the accuracy of the internal logic of the intelligent contract.
An embodiment of the present invention further provides a computer-readable storage medium capable of implementing all the steps in the intelligent block chain contract repairing method in the foregoing embodiment, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements all the steps of the intelligent block chain contract repairing method in the foregoing embodiment, for example, when the processor executes the computer program, the processor implements the following steps:
uploading the intelligent contract to a block chain test network so that the block chain test network executes the intelligent contract and generates an operation log;
receiving an operation log from a block chain test network, and generating an actual service flow chart according to the operation log;
comparing the actual business flow chart with a corresponding preset business flow chart to generate a repair code;
and repairing the intelligent contract according to the repairing code.
To sum up, the computer-readable storage medium of the embodiment of the present invention uploads the intelligent contract to the blockchain test network first, so that the blockchain test network executes the intelligent contract and generates an operation log, generates an actual service flowchart according to the operation log, compares the actual service flowchart with a corresponding preset service flowchart, generates a repair code, and finally repairs the intelligent contract according to the repair code, which can reduce the development and operation and maintenance costs of the intelligent contract and improve the accuracy of the internal logic of the intelligent contract.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.
Those of skill in the art will further appreciate that the various illustrative logical blocks, units, and steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate the interchangeability of hardware and software, various illustrative components, elements, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design requirements of the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present embodiments.
The various illustrative logical blocks, or elements, or devices described in connection with the embodiments disclosed herein may be implemented or performed with a general purpose processor, a digital signal processor, an Application Specific Integrated Circuit (ASIC), a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general-purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a digital signal processor core, or any other similar configuration.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. For example, a storage medium may be coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC, which may be located in a user terminal. In the alternative, the processor and the storage medium may reside in different components in a user terminal.
In one or more exemplary designs, the functions described above in connection with the embodiments of the invention may be implemented in hardware, software, firmware, or any combination of the three. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media that facilitate transfer of a computer program from one place to another. Storage media may be any available media that can be accessed by a general purpose or special purpose computer. For example, such computer-readable media can include, but is not limited to, RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to carry or store program code in the form of instructions or data structures and which can be read by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Additionally, any connection is properly termed a computer-readable medium, and, thus, is included if the software is transmitted from a website, server, or other remote source via a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wirelessly, e.g., infrared, radio, and microwave. Such discs (disk) and disks (disc) include compact disks, laser disks, optical disks, DVDs, floppy disks and blu-ray disks where disks usually reproduce data magnetically, while disks usually reproduce data optically with lasers. Combinations of the above may also be included in the computer-readable medium.

Claims (10)

1. A method for repairing a blockchain intelligent contract, comprising:
uploading an intelligent contract to a blockchain test network to enable the blockchain test network to execute the intelligent contract and generate an operation log;
receiving an operation log from the block chain test network, and generating an actual service flow chart according to the operation log;
comparing the actual business flow chart with a corresponding preset business flow chart to generate a repair code;
and repairing the intelligent contract according to the repair code.
2. The method of block chain intelligent contract repair according to claim 1, wherein repairing the intelligent contract according to the repair code comprises:
analyzing the intelligent contract to obtain an intelligent contract source code;
and repairing the intelligent contract source code according to the repair code, and converting the repaired intelligent contract source code into a repaired intelligent contract.
3. The blockchain intelligent contract repairing method according to claim 2, wherein said operation log includes an operation time;
generating an actual business flow chart according to the operation log comprises the following steps:
sequencing the operation logs according to the operation time;
and generating an actual business flow chart according to the sorted operation log.
4. The blockchain intelligent contract repair method of claim 2, wherein repairing the intelligent contract source code according to the repair code comprises:
determining a function name corresponding to the file name of the operation log where the repair code is located;
and repairing the intelligent contract source code corresponding to the function name according to the repair code.
5. A blockchain intelligent contract repair apparatus, comprising:
the system comprises an uploading module, a block chain testing network and a control module, wherein the uploading module is used for uploading an intelligent contract to the block chain testing network so that the block chain testing network executes the intelligent contract and generates an operation log;
the actual business flow chart module is used for receiving the operation log from the block chain test network and generating an actual business flow chart according to the operation log;
the repair code module is used for comparing the actual business flow chart with the corresponding preset business flow chart to generate a repair code;
and the intelligent contract repairing module is used for repairing the intelligent contract according to the repairing code.
6. The blockchain intelligent contract repair apparatus of claim 5, wherein the intelligent contract repair module comprises:
the analysis unit is used for analyzing the intelligent contract to obtain an intelligent contract source code;
and the intelligent contract repairing unit is used for repairing the intelligent contract source code according to the repairing code and converting the repaired intelligent contract source code into a repaired intelligent contract.
7. The blockchain intelligent contract repairing apparatus according to claim 6, wherein said operation log includes an operation time;
the actual business flow chart module comprises:
the sorting unit is used for sorting the operation logs according to the operation time;
and the actual business flow chart unit is used for generating an actual business flow chart according to the sorted operation logs.
8. The blockchain intelligent contract repairing apparatus according to claim 6, wherein said intelligent contract repairing unit includes:
the function name determining subunit is used for determining a function name corresponding to the file name of the operation log where the repair code is located;
and the intelligent contract source code repairing subunit is used for repairing the intelligent contract source code corresponding to the function name according to the repairing code.
9. A computer apparatus comprising a memory, a processor and a computer program stored on the memory and running on the processor, wherein the steps of the method for blockchain intelligent contract repair of any of claims 1 to 4 are implemented when the computer program is executed by the processor.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the blockchain intelligent contract remediation method of any one of claims 1 to 4.
CN202110295709.9A 2021-03-19 2021-03-19 Block chain intelligent contract repairing method and device Active CN113050925B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110295709.9A CN113050925B (en) 2021-03-19 2021-03-19 Block chain intelligent contract repairing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110295709.9A CN113050925B (en) 2021-03-19 2021-03-19 Block chain intelligent contract repairing method and device

Publications (2)

Publication Number Publication Date
CN113050925A true CN113050925A (en) 2021-06-29
CN113050925B CN113050925B (en) 2024-02-13

Family

ID=76513796

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110295709.9A Active CN113050925B (en) 2021-03-19 2021-03-19 Block chain intelligent contract repairing method and device

Country Status (1)

Country Link
CN (1) CN113050925B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118014334A (en) * 2024-04-08 2024-05-10 微神马科技(大连)有限公司 Service recording method and system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108829436A (en) * 2018-06-15 2018-11-16 北京京东尚科信息技术有限公司 Hot restorative procedure, device, system, electronic equipment and computer-readable medium
CN110413316A (en) * 2019-07-31 2019-11-05 中国工商银行股份有限公司 Non-intrusion type test macro and method towards block chain intelligence contract
CN110807195A (en) * 2019-09-26 2020-02-18 图灵人工智能研究院(南京)有限公司 Intelligent contract issuing method, issuing platform device and issuing system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108829436A (en) * 2018-06-15 2018-11-16 北京京东尚科信息技术有限公司 Hot restorative procedure, device, system, electronic equipment and computer-readable medium
CN110413316A (en) * 2019-07-31 2019-11-05 中国工商银行股份有限公司 Non-intrusion type test macro and method towards block chain intelligence contract
CN110807195A (en) * 2019-09-26 2020-02-18 图灵人工智能研究院(南京)有限公司 Intelligent contract issuing method, issuing platform device and issuing system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118014334A (en) * 2024-04-08 2024-05-10 微神马科技(大连)有限公司 Service recording method and system

Also Published As

Publication number Publication date
CN113050925B (en) 2024-02-13

Similar Documents

Publication Publication Date Title
CN112506807B (en) Automatic test system for interface serving multiple systems
CN103678124B (en) Video surveillance platform auto-test method and device based on continuous integrated environment
CN104268079A (en) POS (Point Of Sale) application program testing method and system
CN104899134A (en) Automatic domain name registration server testing system and method
CN111552632A (en) Interface testing method and device
CN112506771A (en) Message comparison method and device
CN114489629A (en) Rapid development and test method based on interface document
CN114500312B (en) Communication line verification method, device, electronic equipment and system
CN111897715A (en) Method and device for automatically generating configuration data of simulation test environment
CN113050925B (en) Block chain intelligent contract repairing method and device
CN116090380B (en) Automatic method and device for verifying digital integrated circuit, storage medium and terminal
CN109508204B (en) Front-end code quality detection method and device
CN112416457A (en) Interface configuration file generation method and device
CN116506340A (en) Flow link testing method and device, electronic equipment and storage medium
CN105302731A (en) Testing system and method for upgrading website configuration
CN113760761A (en) Automatic testing method and device based on software and hardware stock market system
CN109426576A (en) Fault-tolerance processing method and fault-tolerant component
CN111045953A (en) Distributed test case execution system and method
CN113419877B (en) Implementation method and device of decision service interface, electronic equipment and storage medium
CN116010349B (en) Metadata-based data checking method and device, electronic equipment and storage medium
CN113138911B (en) Track traffic monitoring data reproduction system and fault repair verification method
CN111796998B (en) AML language performance verification system
CN111796805B (en) AML language performance verification method
CN117370202A (en) Method, device, equipment and storage medium for testing full link of multiple bins
CN117194104A (en) Disaster recovery switching processing method and device applied to multiple systems

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