CN114202215A - Intelligent contract transaction exception maintenance method, device, equipment and readable storage medium - Google Patents

Intelligent contract transaction exception maintenance method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN114202215A
CN114202215A CN202111538076.6A CN202111538076A CN114202215A CN 114202215 A CN114202215 A CN 114202215A CN 202111538076 A CN202111538076 A CN 202111538076A CN 114202215 A CN114202215 A CN 114202215A
Authority
CN
China
Prior art keywords
transaction
source code
abnormal
intelligent contract
value
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.)
Pending
Application number
CN202111538076.6A
Other languages
Chinese (zh)
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.)
Sun Yat Sen University
Original Assignee
Sun Yat Sen University
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 Sun Yat Sen University filed Critical Sun Yat Sen University
Priority to CN202111538076.6A priority Critical patent/CN114202215A/en
Publication of CN114202215A publication Critical patent/CN114202215A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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/0631Resource planning, allocation, distributing or scheduling for enterprises or organisations
    • G06Q10/06311Scheduling, planning or task assignment for a person or group
    • 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/20Administration of product repair or maintenance
    • 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

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

Abstract

The application discloses an intelligent contract transaction exception maintenance method, an intelligent contract transaction exception maintenance device, equipment and a readable storage medium, wherein the method comprises the following steps: recording the current stack state of the Ether house virtual machine; tracking the transaction process of the intelligent contract on the Ethengfang virtual machine to obtain transaction information of the transaction; after the transaction is finished, judging whether the transaction is abnormal or not; if so, determining an abnormal source code corresponding to the value of the abnormal program counter contained in the transaction information according to the corresponding relation between the value of the preset program counter and the source code of the intelligent contract; modifying relevant parameters of the transaction according to the abnormal source code; the modified transaction is executed on the same EtherFan virtual machine as the stack state. Obviously, the abnormal source code causing the intelligent contract transaction can be determined according to the preset corresponding relation, the transaction can be modified according to the abnormal source code, and the modified transaction is executed on the same Ethernet virtual machine as the transaction before modification so as to verify whether the modified transaction can be executed successfully or not.

Description

Intelligent contract transaction exception maintenance method, device, equipment and readable storage medium
Technical Field
The application relates to the technical field of block chains, in particular to an intelligent contract transaction exception maintenance method, device, equipment and readable storage medium.
Background
In recent years, more and more attention is paid to decentralized application intelligent contracts based on a blockchain, an ether house is one of the most popular intelligent contract platforms at present, the intelligent contracts on the ether house are executed on an ether house virtual machine, a user can call the intelligent contracts in a transaction mode on the ether house by paying certain fee, and when the transaction execution fails, the procedure fee paid by the user cannot return. Since the transaction failure still requires payment of the procedure fee, the transaction causes a certain loss to the user and hinders the development of the intelligent contract.
Most of researches on intelligent contracts in the current etherhouses are focused on vulnerability detection, fuzzy test tools, static analysis and the like, the researches are based on the intelligent contracts to detect possible vulnerabilities, are more biased to the preventive action before the intelligent contracts are traded, and lack of abnormal positioning and repairing methods after the trades are abnormal.
Therefore, how to realize the positioning and the repair of the intelligent contract transaction abnormity is a problem worthy of research.
Disclosure of Invention
In view of the above, the present application provides a method, an apparatus, a device and a readable storage medium for maintaining an intelligent contract transaction exception, which are used to implement positioning and repairing of an intelligent contract transaction exception.
In order to achieve the above object, the following solutions are proposed:
an intelligent contract transaction exception maintenance method comprises the following steps:
recording the current stack state of the Ether house virtual machine;
tracking the transaction process of the intelligent contract on the EtherFang virtual machine to obtain transaction information of the transaction;
after the transaction is finished, judging whether the transaction is abnormal or not;
if so, determining an abnormal source code corresponding to the value of the abnormal program counter contained in the transaction information according to the corresponding relation between the value of the preset program counter and the source code of the intelligent contract;
modifying relevant parameters of the transaction according to the abnormal source code;
executing the modified transaction on the same EtherFan virtual machine as the stack state.
Preferably, the process of establishing the correspondence between the value of the program counter and the source code of the intelligent contract includes:
compiling the intelligent contract to obtain a contract combination code, wherein the contract combination code comprises: a plurality of bytecode instructions, an instruction value of each of the bytecode instructions, and a correspondence of each of the bytecode instructions with source code of the intelligent contract;
obtaining the value of a program counter corresponding to each bytecode instruction according to the instruction value and the initial value of the program counter;
and determining the corresponding relation between the value of each program counter and the source code of the intelligent contract according to the corresponding relation between each bytecode instruction and the source code of the intelligent contract.
Preferably, the modifying the relevant parameters of the transaction according to the abnormal source code comprises:
determining the abnormal type of the transaction as gasoline fee shortage according to the abnormal source code;
adjusting the gasoline fee allowed to be consumed by an account initiating the transaction in the Etherhouse virtual machine, so that the gasoline fee allowed to be consumed is larger than the gasoline fee required by the transaction contained in the transaction information;
or the like, or, alternatively,
determining the abnormal type of the transaction as the bytecode instruction execution abnormality of the intelligent contract according to the abnormal source code;
determining stack information of a bytecode instruction corresponding to the value of the abnormal program counter according to the value of the abnormal program counter;
and modifying the relevant parameters of the transaction according to the first two elements at the top of the stack information.
Preferably, the modifying the relevant parameters of the transaction according to the first two elements of the stack top of the stack information includes:
respectively matching a first stack top element and a second stack top element with relevant parameters of the transaction to obtain a first transaction parameter matched with the first stack top element in the relevant parameters of the transaction and/or a second transaction parameter matched with the second stack top element in the relevant parameters of the transaction, wherein the first stack top element and the second stack top element are the first two elements of the stack top;
modifying the first transaction parameter or the second transaction parameter so that the logical relationship between the first transaction parameter and the second stack top element or the logical relationship between the second transaction parameter and the first stack top element is consistent with the logical relationship between operators contained in the abnormal source code.
Preferably, the executing the modified transaction on the same etherhouse virtual machine as the current state includes:
establishing an Ether house virtual machine according to the current state;
and executing the modified transaction at the newly built Ethernet shop virtual machine.
Preferably, the method further comprises the following steps:
if the modified transaction is successfully executed, outputting the abnormal source code and the position of the abnormal source code in the intelligent contract, and modifying a suggestion, wherein the modifying suggestion comprises: modifying the relevant parameters of the transaction;
and if the modified transaction execution is abnormal, outputting the abnormal source code position and the position of the abnormal source code position in the intelligent contract.
An intelligent contract transaction exception maintenance device comprising:
the stack recording unit is used for recording the current stack state of the Ether house virtual machine;
the transaction tracking unit is used for tracking the transaction process of the intelligent contract on the Ethenhouse virtual machine to obtain transaction information of the transaction;
the abnormity judging unit is used for judging whether the transaction is abnormal or not after the transaction is finished;
an abnormal source code determining unit, configured to determine, if the transaction execution is abnormal, an abnormal source code corresponding to a value of an abnormal program counter included in the transaction information according to a corresponding relationship between a value of a preset program counter and a source code of the intelligent contract;
the transaction modification unit is used for modifying the relevant parameters of the transaction according to the abnormal source code;
and the transaction re-execution unit is used for executing the modified transaction on the Ethernet shop virtual machine with the same stack state.
Preferably, the abnormal source code determining unit includes a correspondence relationship establishing unit configured to establish a correspondence relationship between the value of the program counter and the source code of the intelligent contract, and the correspondence relationship establishing unit includes:
a contract compiling unit, configured to compile the intelligent contract to obtain a contract combination code, where the contract combination code includes: a plurality of bytecode instructions, an instruction value of each of the bytecode instructions, and a correspondence of each of the bytecode instructions with source code of the intelligent contract;
the value determining unit of the program counter is used for obtaining the value of the program counter corresponding to each bytecode instruction according to the instruction value and the initial value of the program counter;
and the corresponding relation determining unit is used for determining the corresponding relation between the value of each program counter and the source code of the intelligent contract according to the corresponding relation between each bytecode instruction and the source code of the intelligent contract.
An intelligent contract transaction exception maintenance device comprises a memory and a processor;
the memory is used for storing programs;
the processor is used for executing the program and realizing the steps of the intelligent contract transaction exception maintenance method.
A readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the above-described intelligent contract transaction exception maintenance method.
According to the scheme, the intelligent contract transaction exception maintenance method provided by the application comprises the following steps: recording the current stack state of the Ether house virtual machine; tracking the transaction process of the intelligent contract on the EtherFang virtual machine to obtain transaction information of the transaction; after the transaction is finished, judging whether the transaction is abnormal or not; if so, determining an abnormal source code corresponding to the value of the abnormal program counter contained in the transaction information according to the corresponding relation between the value of the preset program counter and the source code of the intelligent contract; modifying relevant parameters of the transaction according to the abnormal source code; executing the modified transaction on the same EtherFan virtual machine as the stack state. Obviously, the method and the device can determine the source code causing the abnormal transaction of the intelligent contract according to the corresponding relation between the value of the preset program counter and the source code of the intelligent contract, modify the transaction of the intelligent contract according to the abnormal source code, and then execute the modified transaction on the same Ethenhouse virtual machine before transaction modification so as to verify whether the modified transaction can be executed successfully or not.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a schematic flow chart illustrating a method for maintaining an intelligent contract transaction exception according to an embodiment of the present disclosure;
FIG. 2 is a schematic structural diagram of an intelligent contract transaction exception maintenance device disclosed in an embodiment of the present application;
fig. 3 is a block diagram of a hardware structure of an intelligent contract transaction exception maintenance device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, 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 application.
Referring to fig. 1, fig. 1 is a schematic flow chart of an intelligent contract transaction exception maintenance method provided in an embodiment of the present application, where the method includes:
step S100: and recording the current stack state of the EtherFang virtual machine.
Specifically, the stack state of the ethernet house virtual machine may be recorded before the transaction of the intelligent contract is executed on the ethernet house virtual machine.
Step S110: and tracking the transaction process of the intelligent contract on the Ethernet virtual machine to obtain the transaction information of the transaction.
Specifically, the basic information of the transaction account on the ethernet virtual machine and the related information during the transaction execution process can be tracked and recorded.
The basic information of the transaction account introduced above may include: information such as a transaction initiating address (tx _ from), a transaction target address (tx _ to), gasoline fee (gas), gasoline fee unit price (gas _ price), transaction parameters (calldata), a block number and the like.
The relevant information during the execution of the transaction may include: the value (PC value) of each program counter, and the information of the operating instruction, gasoline cost consumption, stack state and the like obtained after the intelligent contract source code is compiled.
Step S120: and judging whether the transaction is abnormal or not after the transaction is finished. If the transaction execution is abnormal, step S130 is executed.
Specifically, whether the transaction is abnormal may be determined according to the PC values introduced in step 110, if the transaction is abnormal, the PC value corresponding to the abnormality may be marked with an abnormality identifier, and whether the transaction is abnormal may be known by determining whether the abnormality identifier is marked on each tracked PC value.
Step S130: and determining an abnormal source code corresponding to the abnormal value of the program counter contained in the transaction information according to the corresponding relation between the preset value of the program counter and the source code of the intelligent contract.
Specifically, the value of the program counter, that is, the PC value, may establish a correspondence relationship with the source code of the intelligent contract in advance, and then may determine, according to the correspondence relationship, the abnormal source code corresponding to the PC value labeled with the abnormal identifier included in the tracked transaction information.
Step S140: and modifying relevant parameters of the transaction according to the abnormal source code.
Specifically, the related parameters of the transaction can be modified according to the reason that the abnormal source code causes the transaction execution abnormality, so that the modified transaction can be executed successfully as much as possible.
Step S150: executing the modified transaction on the same EtherFan virtual machine as the stack state.
Specifically, the modified transaction may be executed on an Etherhouse virtual machine that is in exactly the same stack state as before the transaction was executed.
According to the scheme, the abnormal source code causing the intelligent contract transaction can be determined according to the preset corresponding relation, the transaction can be modified according to the abnormal source code, and the modified transaction is executed on the same Ethernet virtual machine as that before the transaction is modified so as to verify whether the modified transaction can be executed successfully or not.
In some embodiments of the application, the above step S130 is introduced, a process of determining an abnormal source code corresponding to the value of the abnormal program counter included in the transaction information according to a preset corresponding relationship between the value of the program counter and the source code of the intelligent contract is described, and a process of establishing a corresponding relationship between the value of the program counter and the source code of the intelligent contract is described next.
Specifically, the process may include the steps of:
s1, compiling the intelligent contract to obtain a contract combination code, wherein the contract combination code comprises: a plurality of bytecode instructions, an instruction value of each of the bytecode instructions, and a correspondence of each of the bytecode instructions with source code of the intelligent contract.
In particular, the intelligent contracts may be written in different languages, here in the example of an intelligent contract written in the ontology language. The intelligent contract may be compiled first to obtain a compilation result, where the compilation result may include: a contract Bytecode (Bytecode) and a contract combination Code (asybly Code), wherein the contract combination Code may include: the byte code instruction, the instruction value of the byte code instruction and the source code corresponding to the byte code instruction in the intelligent contract.
And S2, obtaining the value of the program counter corresponding to each bytecode instruction according to the instruction value and the initial value of the program counter.
Specifically, each instruction value may be different, and thus the obtained PC values corresponding to the bytecode instruction may also be different.
Next, a procedure of determining the value of each PC will be described by taking the contract composition Code (acquisition Code) of step S1 described above as an example.
Specifically, the offset value corresponding to each bytecode instruction in the AssmblyCode may be obtained according to the definition of the bytecode instruction on the ethernet virtual machine, the initial value of the PC may be 0, and the initial values of the PC are accumulated according to the offset value of the bytecode instruction to obtain the PC value corresponding to each bytecode instruction in the AssmblyCode, for example: the first two bytecode instructions of a contract: and the push1 and the push2 are respectively, wherein the push1 command offset value is 2, the push2 command offset value is 3, the PC value corresponding to the push1 is 0, and the PC value corresponding to the push2 is 2.
And S3, determining the corresponding relation between the value of each program counter and the source code of the intelligent contract according to the corresponding relation between each bytecode instruction and the source code of the intelligent contract.
Specifically, the corresponding relationship between each PC value and the source code of the intelligent contract may be determined according to the corresponding relationship between each bytecode instruction compiled in the step S1 and the source code of the intelligent contract, and the corresponding relationship between each bytecode instruction calculated in the step S2 and the PC value.
In some embodiments of the application, the process of modifying the relevant parameters of the transaction according to the abnormal source code in step S140 is introduced, and the process will be further described below.
Specifically, the process may determine the relevant parameters of different transactions according to different transaction exception types, including the following steps:
and in the first situation, determining that the abnormal type of the transaction is insufficient gasoline charge according to the abnormal source code.
In such a case, the allowed gasoline fee to be consumed by the account initiating the transaction in the EtherFang virtual machine is adjusted so that the allowed gasoline fee to be consumed is greater than the gasoline fee required by the transaction and contained in the transaction information
Specifically, the related information obtained in the transaction execution process can be tracked, and the gasoline fee allowed to be consumed by the transaction initiation account of the Ethenhouse virtual machine is adjusted to be larger than the gasoline fee required by normal execution of the transaction.
And in the second situation, determining the abnormal type of the transaction as the bytecode instruction execution abnormity of the intelligent contract according to the abnormal source code.
S21, according to the abnormal program counter value, determining the stack information of the bytecode instruction corresponding to the abnormal program counter value.
Specifically, the abnormal bytecode instruction can be determined according to the abnormal PC value, and then the stack information of the abnormal bytecode instruction can be determined.
S22, modifying the relevant parameters of the transaction according to the first two elements of the stack top of the stack information.
Specifically, the transaction may be modified according to the first two elements of the stack information and the related parameters obtained by tracking the transaction.
In some embodiments of the present application, the above step S22 is introduced, and a process of modifying relevant parameters of the transaction according to the first two elements on the top of the stack information is described, where the process may perform dynamic transaction repair on relevant transactions containing three operators, i.e., less than, equal to, and greater than, in the exception source code, and the process will be further described below.
Specifically, the exception source code may include a binary operator, where the binary operator has two operands corresponding to a first top element and a second top element of the stack, and the process may include the following steps:
s221, matching a first stack top element and a second stack top element with relevant parameters of the transaction respectively to obtain a first transaction parameter matched with the first stack top element in the relevant parameters of the transaction and/or a second transaction parameter matched with the second stack top element in the relevant parameters of the transaction, wherein the first stack top element and the second stack top element are the first two elements of the stack top.
Specifically, the first two elements on the top of the stack may be matched with the transaction parameters (calldata) in the relevant parameters of the transaction and the ethernet information related to the transaction account, and different matching results may be obtained according to different situations, where the matching results may include: only obtaining a first transaction parameter matched with the first stack top element, or only obtaining a second transaction parameter matched with the second stack top element, or simultaneously obtaining the first transaction parameter matched with the first stack top element and the second transaction parameter matched with the second stack top element.
S222, modifying the first transaction parameter or the second transaction parameter to enable the logical relationship between the first transaction parameter and the second stack top element or the logical relationship between the second transaction parameter and the first stack top element to be consistent with the logical relationship between operators contained in the abnormal source code.
Specifically, one or two elements at the top of the stack may be modified according to an operator included in the exception source code and a matching result of the foregoing steps.
The process of modifying relevant parameters of a transaction is described next with a specific example.
a) For the less than symbol case, wherein the less than symbol includes: and when the two elements at the front of the stack top on the Ethengfang virtual machine are matched with the transaction parameters or the related information of the transaction account, adjusting the parameters of the matched stack top element in the two stack top elements. Examples are as follows: if the first stack top element is matched, adjusting the corresponding matching value of the first stack top element to be smaller than the second stack top element; if the second stack top element is matched, the corresponding matching value is adjusted to be larger than the first stack top element.
b) And if any one of the first stack top element or the second stack top element is matched with the transaction parameter or the transaction account related information, modifying the matching parameter corresponding to the matched stack top element to ensure that the matching parameter is the same as the other stack top element.
c) For the greater than symbol case, wherein greater than symbol includes: if the unsigned value is greater than or equal to the signed value, it is necessary to satisfy that the first stack top element is greater than the second stack top element, and at this time, the parameter of the stack top element matched with the first stack top element may be adjusted. Examples are as follows: if the first stack top element is matched, adjusting the corresponding matching value to be larger than the second stack top element; if the second stack top element is matched, the corresponding matching value is adjusted to be smaller than the first stack top element.
In order to let the user know the related condition of the transaction abnormality, the embodiment of the application may further add a process for outputting the related condition of the transaction abnormality.
Specifically, the process may include the steps of:
in case one, if the modified transaction is successfully executed, outputting the abnormal source code and the position of the abnormal source code in the intelligent contract, and modifying a suggestion, wherein the modifying suggestion comprises: a manner of modifying a parameter associated with the transaction.
Specifically, the modification manner may include a modification manner of the transaction related parameter obtained according to a re-execution result of the transaction, where the transaction related parameter may include a transaction parameter (calldata), transaction initiator information (sender), gasoline fee (gas), and the like.
And in the second situation, if the modified transaction execution is abnormal, outputting the abnormal source code position and the position of the abnormal source code position in the intelligent contract.
Specifically, the transaction re-execution exception may output the source code causing the exception and the location of the source code in the smart contract, as well as other information causing the exception.
The following describes the intelligent contract transaction exception maintenance device provided in the embodiment of the present application, and the below-described intelligent contract transaction exception maintenance device and the above-described intelligent contract transaction exception maintenance method may be referred to in correspondence with each other.
First, the intelligent contract transaction exception maintenance apparatus is described with reference to fig. 2, and as shown in fig. 2, the intelligent contract transaction exception maintenance apparatus may include:
a stack recording unit 100, configured to record a current stack state of the ethernet workshop virtual machine;
a transaction tracking unit 110, configured to track a transaction process of an intelligent contract on the ethernet virtual machine, to obtain transaction information of the transaction;
an exception determining unit 120, configured to determine whether the transaction is abnormal after the transaction is ended;
an abnormal source code determining unit 130, configured to determine, if the transaction execution is abnormal, an abnormal source code corresponding to a value of an abnormal program counter included in the transaction information according to a corresponding relationship between a preset value of the program counter and a source code of the intelligent contract;
a transaction modification unit 140, configured to modify a parameter related to the transaction according to the abnormal source code;
a transaction re-execution unit 150, configured to execute the modified transaction on the same ethernet virtual machine as the stack state.
Optionally, the abnormal source code determining unit 130 may include a correspondence establishing unit, configured to establish a correspondence between the value of the program counter and the source code of the intelligent contract, where the correspondence establishing unit may include:
a contract compiling unit, configured to compile the intelligent contract to obtain a contract combination code, where the contract combination code includes: a plurality of bytecode instructions, an instruction value of each of the bytecode instructions, and a correspondence of each of the bytecode instructions with source code of the intelligent contract;
the value determining unit of the program counter is used for obtaining the value of the program counter corresponding to each bytecode instruction according to the instruction value and the initial value of the program counter;
and the corresponding relation determining unit is used for determining the corresponding relation between the value of each program counter and the source code of the intelligent contract according to the corresponding relation between each bytecode instruction and the source code of the intelligent contract.
Optionally, the transaction modification unit 140 may include:
the first abnormity determining unit is used for determining that the abnormity type of the transaction is insufficient gasoline charge according to the abnormity source code;
a relevant parameter modification unit of the first transaction, configured to adjust a gasoline fee allowed to be consumed by an account initiating the transaction in the ethernet virtual machine, so that the gasoline fee allowed to be consumed is greater than the gasoline fee required by the transaction included in the transaction information;
or the like, or, alternatively,
the second abnormity determining unit is used for determining that the abnormity type of the transaction is a bytecode instruction execution abnormity of the intelligent contract according to the abnormity source code;
the abnormal stack determining unit is used for determining stack information of the bytecode instruction corresponding to the value of the abnormal program counter according to the value of the abnormal program counter;
and the related parameter modification unit of the second transaction is used for modifying the related parameters of the transaction according to the first two elements at the top of the stack information.
Optionally, the related parameter modifying unit for the second transaction may include:
a stack top element matching unit, configured to match a first stack top element and a second stack top element with relevant parameters of the transaction, respectively, to obtain a first transaction parameter that matches the first stack top element in the relevant parameters of the transaction, and/or a second transaction parameter that matches the second stack top element in the relevant parameters of the transaction, where the first stack top element and the second stack top element are the first two elements of the stack top;
a transaction parameter modification unit, configured to modify the first transaction parameter or the second transaction parameter, so that a logical relationship between the first transaction parameter and the second top-of-stack element or a logical relationship between the second transaction parameter and the first top-of-stack element is consistent with a logical relationship between operators included in the abnormal source code.
Optionally, the transaction re-execution unit 150 may include:
a virtual machine newly building unit, configured to newly build an ethernet workshop virtual machine according to the current state;
and the new transaction execution unit is used for executing the modified transaction in the newly-built Ethernet shop virtual machine.
Optionally, the intelligent contract transaction exception maintenance device may further include:
a modification success prompting unit, configured to output the abnormal source code and the position thereof in the intelligent contract if the modified transaction is successfully executed, and a modification suggestion, where the modification suggestion includes: modifying the relevant parameters of the transaction;
and the modification failure prompt unit is used for outputting the abnormal source code position and the position of the abnormal source code in the intelligent contract if the modified transaction execution is abnormal.
The intelligent contract transaction abnormity maintenance device provided by the embodiment of the application can be applied to intelligent contract transaction abnormity maintenance equipment. Fig. 3 shows a block diagram of a hardware structure of the intelligent contract transaction exception maintenance device, and referring to fig. 3, the hardware structure of the intelligent contract transaction exception maintenance device may include: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4;
in the embodiment of the application, the number of the processor 1, the communication interface 2, the memory 3 and the communication bus 4 is at least one, and the processor 1, the communication interface 2 and the memory 3 complete mutual communication through the communication bus 4;
the processor 1 may be a central processing unit CPU, or an application Specific Integrated circuit asic, or one or more Integrated circuits configured to implement embodiments of the present invention, etc.;
the memory 3 may include a high-speed RAM memory, and may further include a non-volatile memory (non-volatile memory) or the like, such as at least one disk memory;
wherein the memory stores a program and the processor can call the program stored in the memory, the program for:
recording the current stack state of the Ether house virtual machine;
tracking the transaction process of the intelligent contract on the EtherFang virtual machine to obtain transaction information of the transaction;
after the transaction is finished, judging whether the transaction is abnormal or not;
if so, determining an abnormal source code corresponding to the value of the abnormal program counter contained in the transaction information according to the corresponding relation between the value of the preset program counter and the source code of the intelligent contract;
modifying relevant parameters of the transaction according to the abnormal source code;
executing the modified transaction on the same EtherFan virtual machine as the stack state.
Alternatively, the detailed function and the extended function of the program may be as described above.
Embodiments of the present application further provide a storage medium, where a program suitable for execution by a processor may be stored, where the program is configured to:
recording the current stack state of the Ether house virtual machine;
tracking the transaction process of the intelligent contract on the EtherFang virtual machine to obtain transaction information of the transaction;
after the transaction is finished, judging whether the transaction is abnormal or not;
if so, determining an abnormal source code corresponding to the value of the abnormal program counter contained in the transaction information according to the corresponding relation between the value of the preset program counter and the source code of the intelligent contract;
modifying relevant parameters of the transaction according to the abnormal source code;
executing the modified transaction on the same EtherFan virtual machine as the stack state.
Alternatively, the detailed function and the extended function of the program may be as described above.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. An intelligent contract transaction exception maintenance method, comprising:
recording the current stack state of the Ether house virtual machine;
tracking the transaction process of the intelligent contract on the EtherFang virtual machine to obtain transaction information of the transaction;
after the transaction is finished, judging whether the transaction is abnormal or not;
if so, determining an abnormal source code corresponding to the value of the abnormal program counter contained in the transaction information according to the corresponding relation between the value of the preset program counter and the source code of the intelligent contract;
modifying relevant parameters of the transaction according to the abnormal source code;
executing the modified transaction on the same EtherFan virtual machine as the stack state.
2. The method of claim 1, wherein the establishing of the correspondence between the value of the program counter and the source code of the intelligent contract comprises:
compiling the intelligent contract to obtain a contract combination code, wherein the contract combination code comprises: a plurality of bytecode instructions, an instruction value of each of the bytecode instructions, and a correspondence of each of the bytecode instructions with source code of the intelligent contract;
obtaining the value of a program counter corresponding to each bytecode instruction according to the instruction value and the initial value of the program counter;
and determining the corresponding relation between the value of each program counter and the source code of the intelligent contract according to the corresponding relation between each bytecode instruction and the source code of the intelligent contract.
3. The method of claim 1, wherein modifying the parameters associated with the transaction based on the anomalous source code comprises:
determining the abnormal type of the transaction as gasoline fee shortage according to the abnormal source code;
adjusting the gasoline fee allowed to be consumed by an account initiating the transaction in the Etherhouse virtual machine, so that the gasoline fee allowed to be consumed is larger than the gasoline fee required by the transaction contained in the transaction information;
or the like, or, alternatively,
determining the abnormal type of the transaction as the bytecode instruction execution abnormality of the intelligent contract according to the abnormal source code;
determining stack information of a bytecode instruction corresponding to the value of the abnormal program counter according to the value of the abnormal program counter;
and modifying the relevant parameters of the transaction according to the first two elements at the top of the stack information.
4. The method of claim 3, wherein modifying the relevant parameters of the transaction according to the first two elements of the stack information comprises:
respectively matching a first stack top element and a second stack top element with relevant parameters of the transaction to obtain a first transaction parameter matched with the first stack top element in the relevant parameters of the transaction and/or a second transaction parameter matched with the second stack top element in the relevant parameters of the transaction, wherein the first stack top element and the second stack top element are the first two elements of the stack top;
modifying the first transaction parameter or the second transaction parameter so that the logical relationship between the first transaction parameter and the second stack top element or the logical relationship between the second transaction parameter and the first stack top element is consistent with the logical relationship between operators contained in the abnormal source code.
5. The method of claim 1, wherein the performing the modified transaction on the same Etherhouse virtual machine as the current state comprises:
establishing an Ether house virtual machine according to the current state;
and executing the modified transaction at the newly built Ethernet shop virtual machine.
6. The method of claim 1, further comprising:
if the modified transaction is successfully executed, outputting the abnormal source code and the position of the abnormal source code in the intelligent contract, and modifying a suggestion, wherein the modifying suggestion comprises: modifying the relevant parameters of the transaction;
and if the modified transaction execution is abnormal, outputting the abnormal source code position and the position of the abnormal source code position in the intelligent contract.
7. An intelligent contract transaction exception maintenance device, comprising:
the stack recording unit is used for recording the current stack state of the Ether house virtual machine;
the transaction tracking unit is used for tracking the transaction process of the intelligent contract on the Ethenhouse virtual machine to obtain transaction information of the transaction;
the abnormity judging unit is used for judging whether the transaction is abnormal or not after the transaction is finished;
an abnormal source code determining unit, configured to determine, if the transaction execution is abnormal, an abnormal source code corresponding to a value of an abnormal program counter included in the transaction information according to a corresponding relationship between a value of a preset program counter and a source code of the intelligent contract;
the transaction modification unit is used for modifying the relevant parameters of the transaction according to the abnormal source code;
and the transaction re-execution unit is used for executing the modified transaction on the Ethernet shop virtual machine with the same stack state.
8. The method according to claim 7, wherein the abnormal source code determining unit includes a correspondence establishing unit configured to establish a correspondence between the value of the program counter and the source code of the smart contract, the correspondence establishing unit including:
a contract compiling unit, configured to compile the intelligent contract to obtain a contract combination code, where the contract combination code includes: a plurality of bytecode instructions, an instruction value of each of the bytecode instructions, and a correspondence of each of the bytecode instructions with source code of the intelligent contract;
the value determining unit of the program counter is used for obtaining the value of the program counter corresponding to each bytecode instruction according to the instruction value and the initial value of the program counter;
and the corresponding relation determining unit is used for determining the corresponding relation between the value of each program counter and the source code of the intelligent contract according to the corresponding relation between each bytecode instruction and the source code of the intelligent contract.
9. An intelligent contract transaction exception maintenance device is characterized by comprising a memory and a processor;
the memory is used for storing programs;
the processor is used for executing the program to realize the steps of the intelligent contract transaction exception maintenance method according to any one of claims 1-6.
10. A readable storage medium having stored thereon a computer program, wherein the computer program, when executed by a processor, performs the steps of the smart contract transaction exception maintenance method of any one of claims 1-6.
CN202111538076.6A 2021-12-15 2021-12-15 Intelligent contract transaction exception maintenance method, device, equipment and readable storage medium Pending CN114202215A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111538076.6A CN114202215A (en) 2021-12-15 2021-12-15 Intelligent contract transaction exception maintenance method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111538076.6A CN114202215A (en) 2021-12-15 2021-12-15 Intelligent contract transaction exception maintenance method, device, equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114202215A true CN114202215A (en) 2022-03-18

Family

ID=80654190

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111538076.6A Pending CN114202215A (en) 2021-12-15 2021-12-15 Intelligent contract transaction exception maintenance method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114202215A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102262537A (en) * 2011-07-21 2011-11-30 复旦大学 Method for processing abnormities of execution engine working in mixed model
CN109034814A (en) * 2018-09-14 2018-12-18 百度在线网络技术(北京)有限公司 Intelligent contract treating method and apparatus based on ether mill virtual machine
CN110263536A (en) * 2019-06-21 2019-09-20 深圳前海微众银行股份有限公司 The monitoring method and device of intelligent contract in a kind of block chain
CN110287002A (en) * 2019-06-19 2019-09-27 清华大学 A kind of ether mill virtual machine defect inspection method and system
CN111259395A (en) * 2020-01-16 2020-06-09 图灵人工智能研究院(南京)有限公司 Method and device for acquiring utilization program of intelligent contract and storage medium
WO2020249572A1 (en) * 2019-06-12 2020-12-17 NEC Laboratories Europe GmbH Method and contract rewriting framework system for supporting smart contracts in a blockchain network

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102262537A (en) * 2011-07-21 2011-11-30 复旦大学 Method for processing abnormities of execution engine working in mixed model
CN109034814A (en) * 2018-09-14 2018-12-18 百度在线网络技术(北京)有限公司 Intelligent contract treating method and apparatus based on ether mill virtual machine
WO2020249572A1 (en) * 2019-06-12 2020-12-17 NEC Laboratories Europe GmbH Method and contract rewriting framework system for supporting smart contracts in a blockchain network
US20220318399A1 (en) * 2019-06-12 2022-10-06 NEC Laboratories Europe GmbH Method and contract rewriting framework system for supporting smart contracts in a blockchain network
CN110287002A (en) * 2019-06-19 2019-09-27 清华大学 A kind of ether mill virtual machine defect inspection method and system
CN110263536A (en) * 2019-06-21 2019-09-20 深圳前海微众银行股份有限公司 The monitoring method and device of intelligent contract in a kind of block chain
CN111259395A (en) * 2020-01-16 2020-06-09 图灵人工智能研究院(南京)有限公司 Method and device for acquiring utilization program of intelligent contract and storage medium

Similar Documents

Publication Publication Date Title
CN103019787B (en) Function calling relationship determines method, hot patch upgrade method and device
CN109359468B (en) Vulnerability detection method, device and equipment
CN110096439B (en) Test case generation method for solidity language
US20120030652A1 (en) Mechanism for Describing Values of Optimized Away Parameters in a Compiler-Generated Debug Output
Demir et al. Security smells in smart contracts
CN110968437A (en) Method, device, equipment and medium for parallel execution of single contract based on Java intelligent contract
CN111125697B (en) Intelligent contract defect triggerability detection method and system based on defect abstract
CN111897711B (en) Positioning method and device for bug in code, electronic equipment and readable storage medium
Pradhan et al. An optimal software enhancement and customer growth model: a control-theoretic approach
CN114237477A (en) Strategy risk positioning method and device, electronic equipment and storage medium
CN114202215A (en) Intelligent contract transaction exception maintenance method, device, equipment and readable storage medium
Hidvégi et al. Cigar: Cost-efficient program repair with llms
CN117495544A (en) Sandbox-based wind control evaluation method, sandbox-based wind control evaluation system, sandbox-based wind control evaluation terminal and storage medium
Gomathy et al. Service Oriented Architecture to improve Quality of Software System in Public Sector Organization with Improved Progress Ability
CN109166042B (en) Node device, real-time reconciliation method based on blockchain, and storage medium
KR20230082020A (en) Test methods, systems and equipment based on Excel file loading
CN114416412B (en) Arthas-based anomaly locating method and Arthas-based anomaly locating system
US7236909B1 (en) Autonomic data assurance applied to complex data-intensive software processes by means of pattern recognition
KR101843092B1 (en) Method for verifying multiple insurance computer system
KR20010076275A (en) Semiconductor memory device and program discrimination system
Beydeda et al. A graphical class representation for integrated black-and white-box testing
CN109815129A (en) Test method, device, terminal and the storage medium of securities finance application software
CN109766265A (en) Intelligent O&M method, apparatus, computer equipment and storage medium
CN113094589B (en) Intelligent service recommendation method and device
US20030074308A1 (en) System and method for optimizing collection from skip accounts

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