CN111290958A - Method and device for debugging intelligent contract - Google Patents

Method and device for debugging intelligent contract Download PDF

Info

Publication number
CN111290958A
CN111290958A CN202010106109.9A CN202010106109A CN111290958A CN 111290958 A CN111290958 A CN 111290958A CN 202010106109 A CN202010106109 A CN 202010106109A CN 111290958 A CN111290958 A CN 111290958A
Authority
CN
China
Prior art keywords
debugging
intelligent contract
debugged
contract
block chain
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
CN202010106109.9A
Other languages
Chinese (zh)
Other versions
CN111290958B (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.)
Union Mobile Pay Co Ltd
Original Assignee
Linkage Advantage Beijing Digital Technology Co Ltd
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 Linkage Advantage Beijing Digital Technology Co Ltd filed Critical Linkage Advantage Beijing Digital Technology Co Ltd
Priority to CN202010106109.9A priority Critical patent/CN111290958B/en
Publication of CN111290958A publication Critical patent/CN111290958A/en
Application granted granted Critical
Publication of CN111290958B publication Critical patent/CN111290958B/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
    • 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/3644Software debugging by instrumenting at runtime
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • General Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Computer Hardware Design (AREA)
  • Development Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Technology Law (AREA)
  • Strategic Management (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a device for debugging an intelligent contract, wherein the method comprises the following steps: the method comprises the steps that a block chain node obtains a debugging request, a block chain node determines a contract function of an intelligent contract to be debugged, transaction information to be operated and a debugging strategy to be used according to the debugging request, the block chain node calls the intelligent contract to be debugged to execute the transaction information to be operated, and the block chain node executes the debugging strategy to be used in the executing process of the transaction information to be operated so as to obtain a debugging result of the intelligent contract to be debugged. The debugging results are debugging performed after the intelligent contract is deployed in the system, and the debugging is performed according to the preset debugging strategy after the debugging request is analyzed, so that local source codes are not needed, and the remote debugging is facilitated. Meanwhile, the operation code of the intelligent contract is not required to be operated, a newly added debugging channel is not required, the intelligent contract can be debugged only by deploying the intelligent contract, and the method is simple, efficient and easy to operate.

Description

Method and device for debugging intelligent contract
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for debugging an intelligent contract.
Background
With the development of technologies such as block chains, the security of an intelligent contract is more and more emphasized, and the current methods for debugging the intelligent contract generally include the following methods:
1. the manner in which the contract is debugged depends on the source code. The method specifically comprises the following steps: by local debugging by a developer with source code. For example, an Ether house intelligent contract, a developer connects to a test network through a development tool provided by the Ether house, and debugs the intelligent contract through a debug device.
However, this solution is difficult and costly to debug remotely for the case where the intelligent contract code is already deployed in the system.
2. And debugging by operating the operation code compiled by the intelligent contract. The method specifically comprises the following steps: the method comprises the steps of obtaining an operation code after the intelligent contract is compiled, determining a substitute instruction function corresponding to an operation code instruction through an operation code interpreter, and debugging the intelligent contract based on an execution result of the substitute instruction function after the instruction function is executed.
The scheme directly operates the operation codes after the intelligent contracts are compiled, is difficult to operate and is difficult to operate.
3. And establishing a test channel for debugging. The method specifically comprises the following steps: automatically creating a testing channel while creating a transaction channel, deploying the intelligent contract to be tested to the testing channel, carrying out service test on the intelligent contract by all users on the testing channel together, judging whether the intelligent contract to be tested passes the test, if so, commonly recognizing the content of the intelligent contract by all the users on the testing channel, and deploying the intelligent contract to the transaction channel after obtaining the feedback of agreeing to deploy; if not, the test is carried out again.
According to the scheme, a new test channel needs to be opened up for debugging each intelligent contract, and the performance overhead of the block chain is increased.
Disclosure of Invention
The application provides a method and a device for debugging an intelligent contract, which are used for solving the problem of how to conveniently and efficiently debug the intelligent contract.
In a first aspect, an embodiment of the present application provides a method for debugging an intelligent contract, including:
a block chain node acquires a debugging request, and the block chain node is preset with an intelligent contract to be debugged and each debugging strategy;
the block chain node determines a contract function of an intelligent contract to be debugged, transaction information to be operated and a debugging strategy to be used according to the debugging request;
the block chain node calls a contract function of the intelligent contract to be debugged to execute the transaction information to be operated;
and the block chain node executes the debugging strategy to be used in the executing process of the transaction information to be operated so as to obtain the debugging result of the intelligent contract to be debugged.
According to the scheme, the debugging results are debugged after the intelligent contract is deployed in the system, the debugging request is analyzed and then debugged according to the preset debugging strategy, and a local source code is not needed, so that remote debugging is facilitated; meanwhile, the operation code of the intelligent contract is not required to be operated, a newly added debugging channel is not required, the intelligent contract is only required to be deployed, the debugging can be realized through an open API, and the intelligent contract debugging method is simple, efficient and easy to operate.
Optionally, the obtaining, by the blockchain node, a debug request includes:
the block chain node acquires a first sub-debugging request, wherein the first sub-debugging request comprises address information used for indicating a contract function of the intelligent contract to be debugged and transaction parameters of transaction information to be operated;
the block chain node acquires a second sub-debugging request, wherein the second sub-debugging request comprises a strategy identifier of a debugging strategy to be used;
the block chain node determines a contract function of the intelligent contract to be debugged according to the debugging request, and the contract function comprises the following steps:
and the block chain link points analyze the address information and determine a contract function of the intelligent contract to be debugged.
According to the scheme, the debugging request comprises the strategy identification, each debugging strategy is preset on the block chain link point, the strategy identification can be debugged in the debugging process, a special testing channel does not need to be opened up for each intelligent contract to be tested, and the debugging is more convenient and efficient.
Optionally, the method further includes:
the block chain node receives a setting instruction, and the setting instruction is used for setting the intelligent contract to be debugged to be in a debugging state; the debugging state is used for indicating the blockchain node not to process the transaction information of the intelligent contract to be debugged.
According to the scheme, due to the arrangement of the debugging switch, the intelligent contract to be debugged does not influence the transaction of other intelligent contracts during debugging, and the user experience is improved.
Optionally, after the executing the debugging policy to be used to obtain the debugging result of the intelligent contract to be debugged, the method further includes:
the block chain node sets the intelligent contract to be debugged to be in an operating state; the running state is used for indicating the block link nodes to process the transaction information of the intelligent contract to be debugged.
It should be noted that the debugging of the smart contract is performed before the smart contract is used for a formal transaction.
Optionally, the executing the to-be-used debugging policy includes:
and the block chain node executes the debugging strategies to be used in series or in parallel according to the sequence relation among the debugging strategies to be used.
In a second aspect, an embodiment of the present application provides an apparatus for intelligent contract debugging, where the apparatus includes:
the system comprises an acquisition module, a debugging module and a debugging module, wherein the acquisition module is used for acquiring a debugging request and presetting an intelligent contract to be debugged and each debugging strategy;
the processing module is used for determining a contract function of the intelligent contract to be debugged, transaction information to be operated and a debugging strategy to be used according to the debugging request;
calling the intelligent contract to be debugged to execute the transaction information to be operated;
and in the executing process of the transaction information to be operated, executing the debugging strategy to be used so as to obtain a debugging result of the intelligent contract to be debugged.
Optionally, the processing module is specifically configured to:
acquiring a first sub-debugging request, wherein the first sub-debugging request comprises address information used for indicating a contract function of the intelligent contract to be debugged and transaction parameters of transaction information to be run;
acquiring a second sub-debugging request, wherein the second sub-debugging request comprises a strategy identifier of a debugging strategy to be used;
optionally, the processing module is specifically configured to:
and analyzing the address information and determining a contract function of the intelligent contract to be debugged.
Optionally, the processing module is further configured to:
before the block chain node acquires a debugging request, the block chain node receives a setting instruction, wherein the setting instruction is used for setting the intelligent contract to be debugged to be in a debugging state; the debugging state is used for indicating the blockchain node not to process the transaction information of the intelligent contract to be debugged.
Optionally, the processing module is further configured to:
after the debugging strategy to be used is executed so as to obtain a debugging result of the intelligent contract to be debugged, setting the intelligent contract to be debugged to be in a running state; the running state is used for indicating the block link nodes to process the transaction information of the intelligent contract to be debugged.
Optionally, the processing module is specifically configured to:
and executing the debugging strategies to be used in series or in parallel according to the sequence relation among the debugging strategies to be used.
Correspondingly, an embodiment of the present invention further provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instruction stored in the memory and executing the data storage method of the block chain according to the obtained program.
Accordingly, an embodiment of the present invention further provides a computer-readable non-volatile storage medium, which includes computer-readable instructions, and when the computer-readable instructions are read and executed by a computer, the computer is caused to execute the data storage method of the above block chain.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be 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 to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a system framework of an intelligent contract debugging method according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of an intelligent contract debugging method according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of an intelligent contract debugging method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an intelligent contract debugging apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, 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.
First, some terms in the present application are explained so as to be understood by those skilled in the art.
A Smart contract (Smart contract) is a computer protocol intended to propagate, verify or execute contracts in an informational manner. Smart contracts allow trusted transactions to be conducted without third parties, which transactions are traceable and irreversible. The objective is to provide a secure method over traditional contracts and reduce other transaction costs associated with the contracts.
In order to solve the problems in the prior art, an embodiment of the present invention provides an intelligent contract debugging method, which may be applied to a system architecture shown in fig. 1, where the system architecture includes a server 100 and a blockchain node 200.
The intelligent contract to be debugged is deployed on the blockchain node 200.
Specifically, server 100 is configured to send a debug request to block link point 200.
It should be noted that the debug request sent by the server 100 is received by a plurality of different external interfaces of the block link node 200, and the block link node 200 may obtain address information of an access interface of the debug request sent by the server 100. The blockchain node 200 matches a contract function according to the address information to determine a debug result.
After acquiring the debug request sent by the server 100, the blockchain node 200 processes the debug request to generate a debug result.
It should be noted that fig. 1 is only an example of a system architecture according to an embodiment of the present application, and the present application is not limited to this specifically.
Based on the system architecture illustrated in fig. 1, fig. 2 is a schematic flowchart corresponding to a method for intelligent contract debugging according to an embodiment of the present invention, where the process may be executed by an apparatus for intelligent contract debugging, which may be a block link point of the foregoing. As shown in fig. 2, the method includes:
step 201, obtaining a debugging request by a block link point;
it should be noted that the block link points are preset with the intelligent contracts to be debugged and the debugging strategies.
Step 202, the block chain node determines a contract function of the intelligent contract to be debugged, transaction information to be operated and a debugging strategy to be used according to the debugging request.
And step 203, calling the intelligent contract to be debugged by the block chain node to execute the transaction information to be operated.
And 204, executing the debugging strategy to be used by the block chain node in the executing process of the transaction information to be operated so as to obtain the debugging result of the intelligent contract to be debugged.
In the embodiment of the invention, a block chain system is taken as an example, a block chain platform is started, and an intelligent contract is loaded.
Specifically, before the blockchain node obtains the debug request, that is, before step 201, the blockchain node calls the debug interface. That is to say, the block chain node receives a setting instruction, the setting instruction is used for setting the block chain node to be in a debugging state, and the debugging state is used for indicating the block chain node not to process the transaction information of the intelligent contract to be debugged.
As can be seen from the above, in the embodiment of the present invention, the debug switch may be turned on first, for example, the toolendedbagflag is changed to toolean debuggFlag is changed to true, all transactions will go through the debug process after the debug switch is turned on, and the normal transaction process of the user is performed when the debug switch is turned off, and the debug will not be performed. It should be noted that the method for starting debugging is not specifically limited in the present application.
Based on this, in step 201, an intelligent contract is deployed in a block link point of a block link node to obtain a debugging request, since the intelligent contract allows a trusted transaction without a third party, the transaction can be traced, and the block link node can obtain address information of the debugging request.
It should be noted that the block link point may obtain a debugging request of an external server, or may directly and actively call, for example, call a URl address, that is, may generate a debugging request according to a transaction request included in the URl address.
In addition, in one possible implementation manner, the transaction information in the debugging request may directly invoke the transaction information in the real-time transaction request, and in another possible implementation manner, the transaction information in the debugging request may change the transaction parameters in the transaction information for debugging after invoking the transaction information in the real-time transaction request.
In step 201, a block link point obtains a first sub-debugging request, where the first sub-debugging request includes address information used for indicating a contract function of an intelligent contract to be debugged and transaction parameters of transaction information to be run;
and the block chain node acquires a second sub-debugging request, wherein the second sub-debugging request comprises a strategy identifier of a debugging strategy to be used.
Based on this, in step 202, the block link point determines, according to the debugging request, a contract function of the intelligent contract to be debugged, transaction information to be run, and a debugging policy to be used. Such as sending a transfer request from account a to account B for 1 unit of virtual currency or credit, using a debug policy of 1+2+3, such as debug policy "types": "1, 2, 3", wherein typeis a policy parameter.
The transaction information to be operated is virtual currency or credit with the amount of 1 unit, which is transferred from the account A to the account B; the debugging strategy to be used is the debugging strategy 1+2+ 3.
Further, a contract function of the intelligent contract to be debugged, transaction information to be run and a debugging strategy to be used are identified according to a preset rule. In the embodiment of the present application, the preset rule may adopt keyword recognition, for example, the policy parameter is set to type, and when "type" is recognized, a parameter value of "type" is extracted as a parameter value of the policy parameter.
In the embodiment of the present application, determining, by a block link point, a contract function of an intelligent contract to be debugged according to a debugging request includes:
and resolving the address information by the block chain link points, and determining a contract function of the intelligent contract to be debugged.
The above block chain node analyzes the address information, and determines a contract function of the intelligent contract to be debugged, specifically, for example, when the called URl address information is as follows:
http:// www.makerorder.com/dev/transorder, the matching contract function is:
transferfunc(String A,String B,Integer 1)。
specifically, in step 204, the specific flow is as shown in fig. 3:
step 301, matching a corresponding strategy according to parameter values of strategy parameters;
step 302, calling a strategy function corresponding to the strategy according to the strategy;
step 303, the debug request is processed according to the policy function.
In the embodiment of the present application, the debugging policy includes or is not limited to the following policy combinations:
collecting access parameters, collecting return values of debugging results, collecting memory and disk occupation conditions, and collecting network traffic data.
It should be noted that the debugging strategy may also be counting the number of exceptions, and the like, which is not specifically limited in the present application.
For example, four debugging strategies are preset, 1 is collecting the input parameters (i.e. the initial input parameters); 2, collecting a debugging result return value; 3, collecting memory and disk occupation conditions; and 4, collecting network traffic data. At this time, in the debug request "types": "1, 2, 3" indicates that the debugging strategy of collecting entry parameters, collecting return values of debugging results and collecting memory and disk occupation conditions is executed in the debugging.
In the embodiment of the application, the block link points provide special interfaces, so that the test user can dynamically increase or decrease the strategy modes except for the preset four strategies for the intelligent contract.
Based on the above, when the matching debugging policy is "types": when the number of the block chain nodes is '1, 2 and 3', a recording function funcRecord () is called to automatically record parameters (namely an account A, an account B and the number 1), a return value, a current node memory and disk information into a log, and transaction parameters are dynamically monitored and updated.
It should be noted that, the block chain nodes execute the debugging strategies to be used in series or in parallel according to the sequential relationship between the debugging strategies to be used.
In the embodiment of the application, after the debugging strategy to be used is executed so as to obtain the debugging result of the intelligent contract to be debugged, the block link point sets the intelligent contract to be debugged to be in the running state; the running state is used for indicating the blockchain node to process the transaction information of the blockchain system. Before setting the intelligent contract to be debugged as a running state, whether the intelligent contract reaches an expected value is judged according to a debugging result.
It should be noted that before determining whether the debugging result is expected, the blockchain node may obtain log information recorded in the debugging process, and format and output the log information to the user.
Further, in a possible implementation manner, the user analyzes whether the expected value is reached according to the output result. In another possible implementation manner, a threshold is preset in the block link point, and if the debugging result shows abnormal or is greater than the threshold, it is determined that the debugging request contains an illegal transaction.
In order to better illustrate the embodiments of the present invention, specific examples are illustrated below.
Firstly, each node in the blockchain system is preset with various debugging strategies, that is, each node can debug the intelligent contract running on the node according to the preset debugging strategies. The preset debugging strategy at the node can be deployed through a preset interface, and meanwhile, the debugging strategy can be modified through the interface. Assume that four debug strategies are preset in a node at present, which are respectively: 1 represents collection of ginseng; 2 represents collecting a debug result return value; 3 represents collecting the disk occupation condition; and 4, collecting network traffic data.
Then, an intelligent contract to be tested, such as a "transaction transfer contract", is deployed on the node, and the function included in the "transaction transfer contract" is transfer function (String from, String to, String from, Integer amount). Wherein, transferfunc is the function name, String and Integer represent the parameter type of the parameter, fromoud represents the transfer account, toUid represents the receiving account, and amount represents the transfer amount.
It should be noted that, a plurality of intelligent contracts may be deployed on a node, and if an a contract that has been debugged to pass is currently deployed on the node and a B contract to be tested is deployed at the same time, the node may continue to execute the a contract when the B contract is debugged, so that the original service of the node is not affected. To implement this function, a feasible way is to set a debug switch for each smart contract, for example, when the debug switch is turned off, the transaction of the smart contract can be directly executed without debugging the smart contract. When the debug switch is turned on, for example, the bootean debug flag is true, the debug is performed first, and the transaction is performed after the test of the intelligent contract to be tested is completed.
In addition, one intelligent contract may contain one or more transactions, and in the embodiment of the application, only one transaction, namely the "transaction transfer contract", in the deployed intelligent contract is taken as an example. Further, when one intelligent contract comprises a plurality of transactions, such as "transaction transfer contract" and "transaction loan contract", the test of "transaction loan contract" can be directly performed after the test of "transaction transfer contract" is completed without redeploying the intelligent contract.
After the deployment of the debugging strategy and the intelligent contract is completed, the subsequent debugging work can be performed, which specifically comprises the following steps:
s101, acquiring a debugging request; the debugging request comprises a field indicating a contract function of the intelligent contract to be debugged, a field indicating transaction parameters and a field indicating debugging strategies.
In particular, the field indicating the contract function of the intelligent contract to be debugged may be a URl address, such ashttp:// 120.92.11729:18321/UChains/dir/umfne_dir/transaction
Wherein 120.92.11729:18321 is the IP address and the specific address formed by the ports, and UChains/dir/umfnet dir/transaction is the contract function corresponding to the address.
The fields indicating transaction parameters and the fields indicating debugging strategies can be realized by setting parameter fields, for example, the following request bodies can be used:
Figure BDA0002388171930000101
namely, the account number is changed from account100 to account101, the amount is 1578379035098 units of virtual coins/credits, and the debugging strategy is 1+2+ 3.
It should be noted that one debugging policy may also include a plurality of debugging sub-policies, for example, the debugging policy 1 includes the debugging sub-policies a and b, which is not specifically limited in this application.
In addition, the debugging request can be compiled and sent to the node by a debugging person through a debugging interface; or a debugger can directly write a section of debugging request corresponding code and send the debugging request corresponding code to the node.
S102, identifying strategy parameters and transaction parameters according to preset rules; in the embodiment of the application, the parameter values of the transaction parameters are identified and extracted according to the keywords, and the parameter values comprise: account100, account101, quantity 1578379035098. And identifying and extracting parameter values of the strategy parameters according to the keywords, wherein the parameter values comprise the following parameters: 1. 2 and 3.
It should be noted that the policy parameter and the transaction parameter may also be identified according to preset location information, which is not specifically limited in this application.
S103, identifying that the debugging strategies are 1,2 and 3 according to the keywords;
it should be noted that, in the embodiment of the present application, the transaction parameters and the debugging request are subjected to real-time summary statistics and analysis, for example, the updated results of the transaction parameters are recorded and are counted at different index latitudes, such as the total transfer of the account a within one hour. For another example, the results of the debugging requests are counted, and the transaction success times and the transaction failure times are respectively calculated.
According to the embodiment of the application, the strategy is adjusted in real time according to result data in the debugging process by performing real-time summary statistics and analysis on transaction parameters and debugging requests.
S104, according to the address information of the debugging request, matching a contract function of the debugging request, namely dev/transorder of the content; in the embodiment of the present application, the contract function is transfer func (String a, String B, Integer1) according to URl address matching.
Based on this, the parameter value of the policy parameter "types" matched and debugged is "1, 2, 3", and corresponds to the policy 1: collecting ginseng; strategy 2: collecting a debugging result return value; strategy 3: and collecting the occupation conditions of the memory and the disk. And then processing the debugging request according to the strategy corresponding to the strategy parameter.
Specifically, policy 1 is executed first: collecting the entry references, specifically, calling a recording function funcRecord () to automatically record the entry references (i.e., account100, account101, number 1578379035098).
In one possible implementation, the debug request obtained by the block link point may be input by a developer, such as:
"catalogld": f "," catalogName: "f catalog", "catalogtype": umf ";
from the above, the blockchain node obtains the transaction data from the f directory for debugging.
Policy 2 is then implemented: collecting a debugging result return value;
it should be noted that, after the contract function is called to generate the return value, i.e., the transaction result, the block link point automatically updates the record, i.e., the return value is not recorded or is recorded as a null value when not generated, and when the contract function is called to generate the return value, i.e., the transaction result, the block link point automatically updates the record.
Further, according to different strategies, after logging, such as after collecting the entry references mentioned above, the block link point calls a contract function transferfunc (StringA, StringB, Integer1), and returns a function result as follows:
Figure BDA0002388171930000121
as can be seen from the above, the "code" 200, the "msg" OK "indicates that the transaction information is successfully transmitted, and meanwhile, the account100 transfers the transaction to the account 101.
S105, collecting log information recorded in the debugging process by using the block chain nodes; specifically, a statistical function may be called, and then formatted recording and output to the user, and the user analyzes whether the contract expectation is reached according to the output result. Based on the above, the following is specific:
Figure BDA0002388171930000122
Figure BDA0002388171930000131
wherein, the 'inputData' corresponds to the strategy 1 and is a collected parameter entering result; "meta" indicates that the transaction message was sent successfully; "outData" corresponds to policy 2, and indicates that the transaction is successful in order to return a result; diskMsg is policy 3: and collecting output results of the memory and the disk occupation situation, wherein the embodiment is the specific occupation situation of the disk.
It should be noted that, the block link point may also be compared with a preset threshold to determine whether the debugging result is expected.
Further, if the debugging result shows abnormal or is larger than the threshold value, the debugging request is determined to contain illegal transactions.
For example, if the debugging request includes a transfer transaction, when the transaction parameter value is a negative value, the debugging result displays an abnormal return error indication, which indicates that the debugging request includes an illegal transaction.
In a possible implementation manner, policy 1 collects the input parameters and cannot find the corresponding parameters in the execution process, and the returned result is "code": 2222 "at this time, which indicates that an error occurs.
According to the scheme, the debugging results are debugged after the intelligent contract is deployed in the system, and local debugger mode debugging is not needed, so that remote debugging is facilitated. Meanwhile, the operation code of the intelligent contract is not required to be operated, a newly added debugging channel is not required, the intelligent contract is only required to be deployed, the debugging can be realized through an open API (application program interface), the operation is simple and easy, and the broadband resource is saved. In addition, the invention can flexibly use various debugging strategies to carry out various limit tests on the line for the approximation, and the debugging result based on the online environment is more accurate.
Based on the same inventive concept, fig. 4 exemplarily shows an apparatus for debugging an intelligent contract, which may be used for a flow of an intelligent contract debugging method according to an embodiment of the present invention.
The device for debugging the intelligent contract comprises:
an obtaining module 401, configured to obtain a debugging request, where the obtaining module presets an intelligent contract to be debugged and each debugging policy;
a processing module 402, configured to determine, according to the debugging request, a contract function of the intelligent contract to be debugged, transaction information to be run, and a debugging policy to be used;
calling the intelligent contract to be debugged to execute the transaction information to be operated;
and in the executing process of the transaction information to be operated, executing the debugging strategy to be used so as to obtain a debugging result of the intelligent contract to be debugged.
Optionally, the processing module 402 is specifically configured to:
acquiring a first sub-debugging request, wherein the first sub-debugging request comprises address information used for indicating a contract function of the intelligent contract to be debugged and transaction parameters of transaction information to be run;
acquiring a second sub-debugging request, wherein the second sub-debugging request comprises a strategy identifier of a debugging strategy to be used;
optionally, the processing module 402 is specifically configured to:
and analyzing the address information and determining a contract function of the intelligent contract to be debugged.
Optionally, the processing module 402 is further configured to:
before the block chain node acquires a debugging request, the block chain node receives a setting instruction, wherein the setting instruction is used for setting the block chain node to be in a debugging state; the debug status is used to instruct the blockchain node not to process transaction information of the blockchain system.
Optionally, the processing module 402 is further configured to:
after the debugging strategy to be used is executed so as to obtain a debugging result of the intelligent contract to be debugged, setting the intelligent contract to be debugged to be in a running state; the operating state is used for indicating the blockchain node to process transaction information of the blockchain system.
Optionally, the processing module 402 is specifically configured to:
and executing the debugging strategies to be used in series or in parallel according to the sequence relation among the debugging strategies to be used.
Based on the same inventive concept, an embodiment of the present invention further provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instruction stored in the memory and executing the data storage method of the block chain according to the obtained program.
Based on the same inventive concept, embodiments of the present invention further provide a computer-readable non-volatile storage medium, which includes computer-readable instructions, and when the computer reads and executes the computer-readable instructions, the computer is caused to execute the data storage method of the above block chain.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A method of debugging a smart contract, comprising:
a block chain node acquires a debugging request, and the block chain node is preset with an intelligent contract to be debugged and each debugging strategy;
the block chain node determines a contract function of an intelligent contract to be debugged, transaction information to be operated and a debugging strategy to be used according to the debugging request;
the block chain node calls a contract function of the intelligent contract to be debugged to execute the transaction information to be operated;
and the block chain node executes the debugging strategy to be used in the executing process of the transaction information to be operated so as to obtain the debugging result of the intelligent contract to be debugged.
2. The method of claim 1, wherein the blockchain node obtaining a debug request comprises:
the block chain node acquires a first sub-debugging request, wherein the first sub-debugging request comprises address information used for indicating a contract function of the intelligent contract to be debugged and transaction parameters of transaction information to be operated;
the block chain node acquires a second sub-debugging request, wherein the second sub-debugging request comprises a strategy identifier of a debugging strategy to be used;
the block chain node determines a contract function of the intelligent contract to be debugged according to the debugging request, and the contract function comprises the following steps:
and the block chain link points analyze the address information and determine a contract function of the intelligent contract to be debugged.
3. The method of claim 1, wherein prior to the blockchain node obtaining a debug request, the method further comprises:
the block chain node receives a setting instruction, and the setting instruction is used for setting the intelligent contract to be debugged to be in a debugging state; the debugging state is used for indicating the blockchain node not to process the transaction information of the intelligent contract to be debugged.
4. The method of claim 1, wherein after the executing the debug policy to be used to obtain the debug result of the smart contract to be debugged, the method further comprises:
the block chain node sets the intelligent contract to be debugged to be in an operating state; the running state is used for indicating the block link nodes to process the transaction information of the intelligent contract to be debugged.
5. The method of claim 1, wherein the executing the debug policy to be used comprises:
and the block chain node executes the debugging strategies to be used in series or in parallel according to the sequence relation among the debugging strategies to be used.
6. An apparatus for debugging smart contracts, comprising:
the system comprises an acquisition module, a debugging module and a debugging module, wherein the acquisition module is used for acquiring a debugging request and presetting an intelligent contract to be debugged and each debugging strategy;
the processing module is used for determining a contract function of the intelligent contract to be debugged, transaction information to be operated and a debugging strategy to be used according to the debugging request;
calling a contract function of the intelligent contract to be debugged to execute the transaction information to be operated;
and in the executing process of the transaction information to be operated, executing the debugging strategy to be used so as to obtain a debugging result of the intelligent contract to be debugged.
7. The apparatus of claim 6, wherein the processing module is specifically configured to:
acquiring a first sub-debugging request, wherein the first sub-debugging request comprises address information used for indicating a contract function of the intelligent contract to be debugged and transaction parameters of transaction information to be run;
acquiring a second sub-debugging request, wherein the second sub-debugging request comprises a strategy identifier of a debugging strategy to be used;
the processing module is specifically configured to:
and analyzing the address information and determining a contract function of the intelligent contract to be debugged.
8. The apparatus of claim 6, wherein the processing module is further to:
before the block chain node acquires a debugging request, the block chain node receives a setting instruction, wherein the setting instruction is used for setting the intelligent contract to be debugged to be in a debugging state; the debugging state is used for indicating the blockchain node not to process the transaction information of the intelligent contract to be debugged.
9. A computing device, comprising:
a memory for storing program instructions;
a processor for calling program instructions stored in said memory to execute the method of any one of claims 1 to 5 in accordance with the obtained program.
10. A computer-readable non-transitory storage medium including computer-readable instructions which, when read and executed by a computer, cause the computer to perform the method of any one of claims 1 to 5.
CN202010106109.9A 2020-02-20 2020-02-20 Method and device for debugging intelligent contract Active CN111290958B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010106109.9A CN111290958B (en) 2020-02-20 2020-02-20 Method and device for debugging intelligent contract

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010106109.9A CN111290958B (en) 2020-02-20 2020-02-20 Method and device for debugging intelligent contract

Publications (2)

Publication Number Publication Date
CN111290958A true CN111290958A (en) 2020-06-16
CN111290958B CN111290958B (en) 2023-05-30

Family

ID=71017880

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010106109.9A Active CN111290958B (en) 2020-02-20 2020-02-20 Method and device for debugging intelligent contract

Country Status (1)

Country Link
CN (1) CN111290958B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767215A (en) * 2020-06-23 2020-10-13 中国工商银行股份有限公司 Block chain continuous integration test method, device and system
CN113010409A (en) * 2020-09-16 2021-06-22 腾讯科技(深圳)有限公司 Intelligent contract testing method and device, electronic equipment and storage medium
CN113407166A (en) * 2021-06-29 2021-09-17 湖南省起航嘉泰网络科技有限公司 Safe and controllable agile software development method under controlled network environment
CN113419821A (en) * 2021-07-09 2021-09-21 杭州复杂美科技有限公司 evm contract debugging method, computer device and storage medium
CN113961202A (en) * 2021-12-21 2022-01-21 北京中科金财科技股份有限公司 Method and system for automatically debugging intelligent contract

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107329888A (en) * 2017-05-31 2017-11-07 深圳前海微众银行股份有限公司 Intelligent contract command code coverage rate computational methods and system
CN108073513A (en) * 2017-04-21 2018-05-25 富士通株式会社 The apparatus and method tested the intelligent contract based on block chain
CN109446096A (en) * 2018-11-06 2019-03-08 北京知道创宇信息技术有限公司 A kind of intelligence contract adjustment method, device and its storage medium
CN109670951A (en) * 2018-11-19 2019-04-23 苏宁易购集团股份有限公司 A kind of block chain intelligence contract debugging dissemination method and system
CN109783195A (en) * 2019-01-16 2019-05-21 杭州趣链科技有限公司 A kind of real-time adjustment method of intelligent contract based on container
CN109800175A (en) * 2019-02-20 2019-05-24 河海大学 A kind of ether mill intelligence contract reentry leak detection method based on code pitching pile
CN110177079A (en) * 2019-04-17 2019-08-27 北京百度网讯科技有限公司 The calling system and call method of intelligent contract
CN110287107A (en) * 2019-05-27 2019-09-27 丹阳市萌咔信息技术有限公司 The data processing of block chain and intelligent contract combined debugging integrated approach, system and computer readable storage medium
US20190303623A1 (en) * 2018-04-02 2019-10-03 Ca, Inc. Promotion smart contracts for software development processes
CN110413316A (en) * 2019-07-31 2019-11-05 中国工商银行股份有限公司 Non-intrusion type test macro and method towards block chain intelligence contract
CN110633200A (en) * 2018-06-25 2019-12-31 富士通株式会社 Method and device for testing intelligent contracts

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108073513A (en) * 2017-04-21 2018-05-25 富士通株式会社 The apparatus and method tested the intelligent contract based on block chain
CN107329888A (en) * 2017-05-31 2017-11-07 深圳前海微众银行股份有限公司 Intelligent contract command code coverage rate computational methods and system
US20190303623A1 (en) * 2018-04-02 2019-10-03 Ca, Inc. Promotion smart contracts for software development processes
CN110633200A (en) * 2018-06-25 2019-12-31 富士通株式会社 Method and device for testing intelligent contracts
CN109446096A (en) * 2018-11-06 2019-03-08 北京知道创宇信息技术有限公司 A kind of intelligence contract adjustment method, device and its storage medium
CN109670951A (en) * 2018-11-19 2019-04-23 苏宁易购集团股份有限公司 A kind of block chain intelligence contract debugging dissemination method and system
CN109783195A (en) * 2019-01-16 2019-05-21 杭州趣链科技有限公司 A kind of real-time adjustment method of intelligent contract based on container
CN109800175A (en) * 2019-02-20 2019-05-24 河海大学 A kind of ether mill intelligence contract reentry leak detection method based on code pitching pile
CN110177079A (en) * 2019-04-17 2019-08-27 北京百度网讯科技有限公司 The calling system and call method of intelligent contract
CN110287107A (en) * 2019-05-27 2019-09-27 丹阳市萌咔信息技术有限公司 The data processing of block chain and intelligent contract combined debugging integrated approach, system and computer readable storage medium
CN110413316A (en) * 2019-07-31 2019-11-05 中国工商银行股份有限公司 Non-intrusion type test macro and method towards block chain intelligence contract

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
JIAMING YE等: "Clairvoyance: Cross-contract Static Analysis for Detecting Practical Reentrancy Vulnerabilities in Smart Contracts", 《2020 IEEE/ACM 42ND INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING: COMPANION PROCEEDINGS (ICSE-COMPANION)》 *
JOHN DEVADOSS等: "Programming Smart Contract in C#", 《MSDN MAGAZINE》 *
冯峰: "基于区块链智能合约技术的智能电网***设计与实现", 《中国优秀硕士学位论文全文数据库 工程科技Ⅱ辑》 *
王文明等: "基于区块链技术的交易及其安全性研究", 《信息网络安全》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767215A (en) * 2020-06-23 2020-10-13 中国工商银行股份有限公司 Block chain continuous integration test method, device and system
CN111767215B (en) * 2020-06-23 2023-08-08 中国工商银行股份有限公司 Block chain continuous integration test method, device and system
CN113010409A (en) * 2020-09-16 2021-06-22 腾讯科技(深圳)有限公司 Intelligent contract testing method and device, electronic equipment and storage medium
CN113010409B (en) * 2020-09-16 2023-09-15 腾讯科技(深圳)有限公司 Intelligent contract testing method and device, electronic equipment and storage medium
CN113407166A (en) * 2021-06-29 2021-09-17 湖南省起航嘉泰网络科技有限公司 Safe and controllable agile software development method under controlled network environment
CN113407166B (en) * 2021-06-29 2022-08-19 湖南省起航嘉泰网络科技有限公司 Safe and controllable agile software development method under controlled network environment
CN113419821A (en) * 2021-07-09 2021-09-21 杭州复杂美科技有限公司 evm contract debugging method, computer device and storage medium
CN113961202A (en) * 2021-12-21 2022-01-21 北京中科金财科技股份有限公司 Method and system for automatically debugging intelligent contract

Also Published As

Publication number Publication date
CN111290958B (en) 2023-05-30

Similar Documents

Publication Publication Date Title
CN111290958B (en) Method and device for debugging intelligent contract
WO2020029375A1 (en) Interface testing method and system, and computer device and storage medium
CN104281520B (en) Tracking and method, the apparatus and system of debugging
US20060253837A1 (en) Using a call stack hash to record the state of a process
CN111897724B (en) Automatic testing method and device suitable for cloud platform
CN111427765B (en) Method and system for automatically starting interface performance test realized based on jmeter
US10824549B1 (en) System and method for regression testing of an application programming interface
CN110968437A (en) Method, device, equipment and medium for parallel execution of single contract based on Java intelligent contract
CN110750458A (en) Big data platform testing method and device, readable storage medium and electronic equipment
CN114185808A (en) Automatic testing method and device, electronic equipment and computer readable storage medium
TWI626538B (en) Infrastructure rule generation
US20230359746A1 (en) Systems and methods for shift left testing
CN111767218B (en) Automatic test method, equipment and storage medium for continuous integration
CN110297748A (en) The method, apparatus and computer readable storage medium of error are called in a kind of positioning
CN116097226A (en) Apparatus and method for injecting faults into a distributed system
CN112181784A (en) Code fault analysis method and system based on bytecode injection
CN111193631B (en) Information processing method, system, and computer-readable storage medium
CN116467188A (en) Universal local reproduction system and method under multi-environment scene
CN115757084A (en) Test method and test device and storage medium
CN110362294A (en) Development task executes method, apparatus, electronic equipment and storage medium
CN113282504A (en) Incremental code coverage rate detection method and service development method and device
KR20220091897A (en) Method and apparatus for analyzing pattern-based interaction failures in systems-of-systems
CN114371866A (en) Version reconfiguration test method, device and equipment of service system
CN111258879A (en) Service test scheduling method and device based on page acquisition and intelligent terminal
CN114812695B (en) Product testing method and device, computer equipment and storage medium

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 501, 5 / F, block B, No. 28, Xinjiekou Wai Street, Xicheng District, Beijing 100032

Applicant after: Joint digital technology (Beijing) Co.,Ltd.

Address before: Room 501, 5 / F, block B, No. 28, Xinjiekou Wai Street, Xicheng District, Beijing 100032

Applicant before: Linkage advantage (Beijing) Digital Technology Co.,Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20220119

Address after: 100082 7th floor, block a, Jingshi science and technology building, 12 Xueyuan South Road, Haidian District, Beijing

Applicant after: UNION MOBILE PAY Co.,Ltd.

Address before: Room 501, 5 / F, block B, No. 28, Xinjiekou Wai Street, Xicheng District, Beijing 100032

Applicant before: Joint digital technology (Beijing) Co.,Ltd.

GR01 Patent grant
GR01 Patent grant